2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef __INCLUDE_GATEWAY_H__
18 #define __INCLUDE_GATEWAY_H__
24 * Provide APIs for Packet fowarding in gateway configuration.
28 #include <rte_common.h>
29 #include <rte_malloc.h>
30 #include <rte_ether.h>
31 #include <rte_ethdev.h>
35 #include <rte_byteorder.h>
39 #include "vnf_common.h"
40 #include "vnf_define.h"
43 * A structure for Route table entries of IPv4
45 #define MAX_ROUTE_ENTRY_SIZE 32
46 #define MAX_ND_ROUTE_ENTRY_SIZE 32
48 extern struct route_data *p_route_data[];
49 extern struct nd_route_data *p_nd_route_data[];
51 extern uint32_t vnf_gateway;
54 * A structure for Route table entires of IPv4
57 struct route_table_entry {
58 uint32_t nh; /**< next hop */
59 uint32_t mask; /**< mask */
60 uint32_t port; /**< Physical port */
62 } __rte_cache_aligned;
65 * Routing table for IPv4
69 struct route_table_entry route_table[MAX_ROUTE_ENTRY_SIZE];
70 uint8_t route_ent_cnt;
74 * A structure for Route table entires of IPv6
77 struct nd_route_table_entry {
78 uint8_t nhipv6[16]; /**< next hop Ipv6 */
79 uint8_t depth; /**< Depth */
80 uint32_t port; /**< Port */
84 * Routing table for IPv6
87 struct nd_route_data {
88 struct nd_route_table_entry nd_route_table[MAX_ND_ROUTE_ENTRY_SIZE];
89 uint8_t nd_route_ent_cnt;
92 extern void gw_init(uint32_t num_ports);
94 extern uint32_t gw_get_num_ports(void);
96 extern uint32_t is_gateway(void);
98 extern void gw_get_nh_port_ipv4(uint32_t dst_ip_addr,
99 uint32_t *dst_port, uint32_t *nhip);
101 extern void gw_get_nh_port_ipv6(uint8_t *dst_ipv6_addr,
102 uint32_t *dst_port, uint8_t *nhipv6);