summaryrefslogtreecommitdiffstats
path: root/common/VIL
diff options
context:
space:
mode:
Diffstat (limited to 'common/VIL')
-rw-r--r--common/VIL/gateway/gateway.c218
-rw-r--r--common/VIL/gateway/gateway.h104
-rw-r--r--common/VIL/l2l3_stack/lib_arp.c456
-rw-r--r--common/VIL/l2l3_stack/lib_arp.h66
-rw-r--r--common/VIL/l2l3_stack/tsx.h6
-rw-r--r--common/VIL/pipeline_arpicmp/pipeline_arpicmp.c17
-rw-r--r--common/VIL/pipeline_arpicmp/pipeline_arpicmp_be.c3
-rw-r--r--common/VIL/pipeline_common/pipeline_common_fe.c183
-rw-r--r--common/VIL/pipeline_master/pipeline_master_be.c4
9 files changed, 653 insertions, 404 deletions
diff --git a/common/VIL/gateway/gateway.c b/common/VIL/gateway/gateway.c
new file mode 100644
index 00000000..baf22cf5
--- /dev/null
+++ b/common/VIL/gateway/gateway.c
@@ -0,0 +1,218 @@
+/*
+// Copyright (c) 2017 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+/**
+ * @file
+ * Gateway packet forwarding Implementation.
+ *
+ * Implementation of gateway packet forwarding, next hop IP and
+ * associated processing.
+ *
+ */
+
+#include <rte_mbuf.h>
+#include <rte_malloc.h>
+#include <rte_ethdev.h>
+#include <rte_memcpy.h>
+
+#include "gateway.h"
+#include "pipeline_common_fe.h"
+
+#define IP_VERSION_4 4
+#define IP_VERSION_6 6
+#define MAX_PORTS 32
+
+/* Global stats counters used in ARP */
+extern uint32_t lib_nd_nh_found;
+extern uint32_t lib_arp_nh_found;
+
+struct route_data *p_route_data[MAX_PORTS];
+struct nd_route_data *p_nd_route_data[MAX_PORTS];
+
+/**
+* VNF is configured with routing info or not
+* vnf_gateway = 0: No Routes Added , 1: Routes defined
+* Flag is part of the ARPICMP config parameter
+*/
+
+/* Initialized for IP Pkt forwarding */
+uint32_t vnf_gateway = 0;
+
+/* Initialized number of out ports to route */
+uint32_t num_out_ports = 0;
+
+/**
+ * Initialize the gateway for routing tables
+ *
+ * @param void
+ * None
+ * @return uint32_t
+ * 1 to MAX_PORTS
+ */
+
+void gw_init(uint32_t num_ports)
+{
+ void *p;
+ uint32_t size;
+ uint32_t i;
+
+ num_out_ports = num_ports;
+
+ for(i = 0; i < num_ports; i++) {
+ /* IPv4 route table */
+ size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct route_data));
+ p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
+ p_route_data[i] = (struct route_data *)p;
+
+ /* IPv6 route touble */
+ size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct nd_route_data));
+ p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
+ p_nd_route_data[i] = (struct nd_route_data *)p;
+ }
+}
+/*
+ * Get the the number of ports to route
+ * @param void
+ * None
+ * @return uint32_t
+ * Number of ports enabled in the VNF
+*/
+
+uint32_t gw_get_num_ports(void)
+{
+ return num_out_ports;
+}
+
+
+/**
+ * Check if the gateway is enabled
+ *
+ * @param void
+ * None
+ * @return uint32_t
+ * 0: No routes, 1: Route entries available
+ */
+uint32_t is_gateway(void)
+{
+ return vnf_gateway;
+}
+
+
+/**
+ * Get the next hop ip address and port number for IPv4
+ * @param dst_ip_addr
+ * Destination IPv4 address
+ * @param dst_port
+ * A pointer to destination port
+ * @param nhip
+ * A pointer to next hop ip address
+ */
+
+void gw_get_nh_port_ipv4(uint32_t dst_ip_addr,
+ uint32_t *dst_port, uint32_t *nhip)
+{
+ int i;
+ uint32_t j;
+
+ *nhip = 0;
+ *dst_port = 0xff;
+
+ for(j = 0; j < gw_get_num_ports(); j++){
+
+ for (i = 0; i < p_route_data[j]->route_ent_cnt; i++) {
+
+ if ((p_route_data[j]->route_table[i].nh_mask) ==
+ (dst_ip_addr &
+ p_route_data[j]->route_table[i].mask)) {
+
+ *dst_port = p_route_data[j]->route_table[i].port;
+ *nhip = p_route_data[j]->route_table[i].nh;
+
+ lib_arp_nh_found++;
+ return;
+ }
+ }
+ }
+}
+
+/**
+ * Get the next hop ip address and port number for IPv6
+ * @param dst_ipv6_addr
+ * Destination IPv6 address
+ * @param dst_port
+ * A pointer to destination port
+ * @param nhipv6
+ * A pointer to next hop ip address
+ */
+
+void gw_get_nh_port_ipv6(uint8_t *dst_ipv6_addr,
+ uint32_t *dst_port, uint8_t *nhipv6)
+{
+ if (!dst_ipv6_addr)
+ return;
+ uint32_t j;
+ for(j = 0; j < gw_get_num_ports(); j++){
+
+ if(p_nd_route_data[j]->nd_route_ent_cnt){
+
+ memset(nhipv6, 0, IPV6_ADD_SIZE);
+
+ int i=0;
+ uint8_t netmask_ipv6[IPV6_ADD_SIZE], netip_nd[IPV6_ADD_SIZE];
+ uint8_t netip_in[IPV6_ADD_SIZE];
+ uint8_t k = 0, depthflags = 0, depthflags1 = 0;
+ memset(netmask_ipv6, 0, sizeof(netmask_ipv6));
+ memset(netip_nd, 0, sizeof(netip_nd));
+ memset(netip_in, 0, sizeof(netip_in));
+
+ for (i = 0; i < p_nd_route_data[j]->nd_route_ent_cnt; i++) {
+
+ convert_prefixlen_to_netmask_ipv6(
+ p_nd_route_data[j]->nd_route_table[i].depth, netmask_ipv6);
+
+ for (k = 0; k < IPV6_ADD_SIZE; k++) {
+ if (p_nd_route_data[j]->nd_route_table[i].nhipv6[k] &
+ netmask_ipv6[k]) {
+
+ depthflags++;
+ netip_nd[k] = p_nd_route_data[j]->nd_route_table[i].nhipv6[k];
+ }
+
+ if (dst_ipv6_addr[k] & netmask_ipv6[k]) {
+ depthflags1++;
+ netip_in[k] = dst_ipv6_addr[k];
+ }
+ }
+
+ if ((depthflags == depthflags1) &&
+ (memcmp(netip_nd, netip_in, sizeof(netip_nd)) == 0)) {
+
+ *dst_port = p_nd_route_data[j]->nd_route_table[i].port;
+
+ lib_nd_nh_found++;
+
+ rte_mov16(nhipv6, (uint8_t *)
+ &(p_nd_route_data[j]->nd_route_table[i].nhipv6[0]));
+
+ return;
+ }
+
+ }
+
+ }
+ }
+}
+
diff --git a/common/VIL/gateway/gateway.h b/common/VIL/gateway/gateway.h
new file mode 100644
index 00000000..47a3b8a7
--- /dev/null
+++ b/common/VIL/gateway/gateway.h
@@ -0,0 +1,104 @@
+/*
+// Copyright (c) 2017 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#ifndef __INCLUDE_GATEWAY_H__
+#define __INCLUDE_GATEWAY_H__
+
+/**
+ * @file
+ * gateway.h
+ *
+ * Provide APIs for Packet fowarding in gateway configuration.
+ *
+ */
+
+#include <rte_common.h>
+#include <rte_malloc.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_ip.h>
+#include <rte_udp.h>
+#include <rte_mbuf.h>
+#include <rte_byteorder.h>
+
+#include "pipeline.h"
+#include "app.h"
+#include "vnf_common.h"
+#include "vnf_define.h"
+
+/**
+* A structure for Route table entries of IPv4
+*/
+#define MAX_ROUTE_ENTRY_SIZE 32
+#define MAX_ND_ROUTE_ENTRY_SIZE 32
+
+extern struct route_data *p_route_data[];
+extern struct nd_route_data *p_nd_route_data[];
+
+extern uint32_t vnf_gateway;
+
+/**
+ * A structure for Route table entires of IPv4
+ *
+ */
+struct route_table_entry {
+ uint32_t nh; /**< next hop */
+ uint32_t mask; /**< mask */
+ uint32_t port; /**< Physical port */
+ uint32_t nh_mask;
+} __rte_cache_aligned;
+
+/**
+ * Routing table for IPv4
+ *
+ */
+struct route_data {
+ struct route_table_entry route_table[MAX_ROUTE_ENTRY_SIZE];
+ uint8_t route_ent_cnt;
+};
+
+/**
+ * A structure for Route table entires of IPv6
+ *
+ */
+struct nd_route_table_entry {
+ uint8_t nhipv6[16]; /**< next hop Ipv6 */
+ uint8_t depth; /**< Depth */
+ uint32_t port; /**< Port */
+};
+
+/**
+ * Routing table for IPv6
+ *
+ */
+struct nd_route_data {
+ struct nd_route_table_entry nd_route_table[MAX_ND_ROUTE_ENTRY_SIZE];
+ uint8_t nd_route_ent_cnt;
+};
+
+extern void gw_init(uint32_t num_ports);
+
+extern uint32_t gw_get_num_ports(void);
+
+extern uint32_t is_gateway(void);
+
+extern void gw_get_nh_port_ipv4(uint32_t dst_ip_addr,
+ uint32_t *dst_port, uint32_t *nhip);
+
+extern void gw_get_nh_port_ipv6(uint8_t *dst_ipv6_addr,
+ uint32_t *dst_port, uint8_t *nhipv6);
+
+#endif
diff --git a/common/VIL/l2l3_stack/lib_arp.c b/common/VIL/l2l3_stack/lib_arp.c
index c37e486b..b8976d3a 100644
--- a/common/VIL/l2l3_stack/lib_arp.c
+++ b/common/VIL/l2l3_stack/lib_arp.c
@@ -40,6 +40,7 @@
#include "lib_arp.h"
#include "l3fwd_lpm4.h"
#include "vnf_common.h"
+#include "gateway.h"
#if (RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN)
#define CHECK_ENDIAN_16(x) rte_be_to_cpu_16(x)
@@ -70,7 +71,7 @@ uint32_t nd_buffer = ARP_BUF_DEFAULT;
#define IN6ADDRSZ 16
#define MAX_PORTS 32
-static int my_inet_pton_ipv6(int af, const char *src, void *dst);
+int my_inet_pton_ipv6(int af, const char *src, void *dst);
static int inet_pton_ipv6(const char *src, unsigned char *dst);
static int inet_pton_ipv4(const char *src, unsigned char *dst);
static void local_arp_cache_init(void);
@@ -140,15 +141,6 @@ void update_nhip_access(uint8_t dest_if)
p_arp_data->update_tsc[dest_if] = rte_rdtsc();
}
-/**
- * A structure defining the mbuf meta data for VFW.
- */
-struct mbuf_arp_meta_data {
-/* output port stored for RTE_PIPELINE_ACTION_PORT_META */
- uint32_t output_port;
- struct rte_mbuf *next; /* next pointer for chained buffers */
-} __rte_cache_aligned;
-
static struct arp_entry_data arp_entry_data_default = {
.status = COMPLETE,
.num_pkts = 0,
@@ -224,11 +216,6 @@ int timer_objs_mempool_count = 70000;
#define MAX_NUM_ARP_ENTRIES 64
#define MAX_NUM_ND_ENTRIES 64
-
-inline uint32_t get_nh(uint32_t, uint32_t *, struct ether_addr *addr);
-void get_nh_ipv6(uint8_t ipv6[], uint32_t *port, uint8_t nhipv6[],
- struct ether_addr *hw_addr);
-
#define MAX_ARP_DATA_ENTRY_TABLE 7
struct table_arp_entry_data arp_entry_data_table[MAX_ARP_DATA_ENTRY_TABLE] = {
@@ -260,73 +247,6 @@ struct table_nd_entry_data nd_entry_data_table[MAX_ND_DATA_ENTRY_TABLE] = {
{7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1}, 0},
};
-struct lib_nd_route_table_entry lib_nd_route_table[MAX_ND_RT_ENTRY] = {
- {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 0,
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
- {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 0,
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
- {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 0,
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} },
- {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 0,
- {0, 0, 0, 0, 0, 0, 0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0, 0, 0} }
-};
-
void print_trace(void);
uint32_t get_arp_buf(void)
@@ -368,132 +288,48 @@ void print_trace(void)
free(strings);
}
-uint32_t get_nh(uint32_t ip, uint32_t *port, struct ether_addr *addr)
-{
- int i = 0;
- for (i = 0; i < p_arp_data->lib_arp_route_ent_cnt; i++) {
- if ((p_arp_data->lib_arp_route_table[i].nh_mask) ==
- (ip & p_arp_data->lib_arp_route_table[i].mask)) {
-
- *port = p_arp_data->lib_arp_route_table[i].port;
- if (arp_cache_dest_mac_present(*port))
- ether_addr_copy(
- get_local_link_hw_addr(*port,
- p_arp_data->lib_arp_route_table[i].nh), addr);
- return p_arp_data->lib_arp_route_table[i].nh;
- }
- }
- lib_arp_no_nh_found++;
- return 0;
-}
-
-/*ND IPv6 */
-void get_nh_ipv6(uint8_t ipv6[], uint32_t *port, uint8_t nhipv6[],
-struct ether_addr *hw_addr)
-{
- int i = 0;
- uint8_t netmask_ipv6[16], netip_nd[16], netip_in[16];
- uint8_t k = 0, l = 0, depthflags = 0, depthflags1 = 0;
- memset(netmask_ipv6, 0, sizeof(netmask_ipv6));
- memset(netip_nd, 0, sizeof(netip_nd));
- memset(netip_in, 0, sizeof(netip_in));
- if (!ipv6)
- return;
- for (i = 0; i < MAX_ARP_RT_ENTRY; i++) {
-
- convert_prefixlen_to_netmask_ipv6(lib_nd_route_table[i].depth,
- netmask_ipv6);
-
- for (k = 0; k < 16; k++) {
- if (lib_nd_route_table[i].ipv6[k] & netmask_ipv6[k]) {
- depthflags++;
- netip_nd[k] = lib_nd_route_table[i].ipv6[k];
- }
- }
-
- for (l = 0; l < 16; l++) {
- if (ipv6[l] & netmask_ipv6[l]) {
- depthflags1++;
- netip_in[l] = ipv6[l];
- }
- }
- int j = 0;
- if ((depthflags == depthflags1)
- && (memcmp(netip_nd, netip_in, sizeof(netip_nd)) == 0)) {
- //&& (lib_nd_route_table[i].port == port))
- *port = lib_nd_route_table[i].port;
- lib_nd_nh_found++;
-
- for (j = 0; j < 16; j++)
- nhipv6[j] = lib_nd_route_table[i].nhipv6[j];
-
- if (nd_cache_dest_mac_present(*port)) {
- ether_addr_copy(
- get_nd_local_link_hw_addr(*port, nhipv6),
- (struct ether_addr *)hw_addr);
- }
- return;
- }
-
- if (NDIPV6_DEBUG)
- printf("No nh match\n");
- depthflags = 0;
- depthflags1 = 0;
- }
- if (NDIPV6_DEBUG)
- printf("No NH - ip 0x%x, \n", ipv6[0]);
- lib_nd_no_nh_found++;
-}
/* Added for Multiport changes*/
-struct arp_entry_data *get_dest_mac_addr_port(const uint32_t ipaddr,
- uint32_t *phy_port, struct ether_addr *hw_addr)
+struct arp_entry_data *get_dest_mac_addr_ipv4(const uint32_t nhip,
+ uint32_t phy_port, struct ether_addr *hw_addr)
{
struct arp_entry_data *ret_arp_data = NULL;
- uint32_t nhip = 0;
uint8_t index;
- nhip = get_nh(ipaddr, phy_port, hw_addr);
- if (unlikely(nhip == 0)) {
- if (ARPICMP_DEBUG)
- printf("ARPICMP no nh found for ip %x, port %d\n",
- ipaddr, *phy_port);
- return ret_arp_data;
- }
-
/* as part of optimization we store mac address in cache
* & thus can be sent without having to retrieve
*/
- if (arp_cache_dest_mac_present(*phy_port)) {
+ if (arp_cache_dest_mac_present(phy_port)) {
+ ether_addr_copy(get_local_cache_hw_addr(phy_port, nhip), hw_addr);
return &arp_entry_data_default;
}
struct arp_key_ipv4 tmp_arp_key;
- tmp_arp_key.port_id = *phy_port; /* Changed for Multi Port */
+ tmp_arp_key.port_id = phy_port; /* Changed for Multi Port */
tmp_arp_key.ip = nhip;
if (ARPICMP_DEBUG)
printf("%s: nhip: %x, phyport: %d\n", __FUNCTION__, nhip,
- *phy_port);
+ phy_port);
ret_arp_data = retrieve_arp_entry(tmp_arp_key, DYNAMIC_ARP);
if (ret_arp_data == NULL) {
- if (ARPICMP_DEBUG && ipaddr)
+ if (ARPICMP_DEBUG && nhip)
{
RTE_LOG(INFO, LIBARP,"ARPICMP no arp entry found for ip %x,"
- " port %u\n", ipaddr, *phy_port);
+ " port %u\n", nhip, phy_port);
print_arp_table();
}
lib_arp_no_arp_entry_found++;
} else if (ret_arp_data->status == COMPLETE) {
rte_rwlock_write_lock(&ret_arp_data->queue_lock);
ether_addr_copy(&ret_arp_data->eth_addr, hw_addr);
- p_arp_data->arp_cache_hw_laddr_valid[*phy_port] = 1;
- index = p_arp_data->arp_local_cache[*phy_port].num_nhip;
- p_arp_data->arp_local_cache[*phy_port].nhip[index] = nhip;
+ p_arp_data->arp_cache_hw_laddr_valid[phy_port] = 1;
+ index = p_arp_data->arp_local_cache[phy_port].num_nhip;
+ p_arp_data->arp_local_cache[phy_port].nhip[index] = nhip;
ether_addr_copy(hw_addr,
- &p_arp_data->arp_local_cache[*phy_port].link_hw_laddr[index]);
- p_arp_data->arp_local_cache[*phy_port].num_nhip++;
+ &p_arp_data->arp_local_cache[phy_port].link_hw_laddr[index]);
+ p_arp_data->arp_local_cache[phy_port].num_nhip++;
rte_rwlock_write_unlock(&ret_arp_data->queue_lock);
lib_arp_arp_entry_found++;
if (ARPICMP_DEBUG)
@@ -501,43 +337,26 @@ struct arp_entry_data *get_dest_mac_addr_port(const uint32_t ipaddr,
}
if (ret_arp_data)
- p_arp_data->update_tsc[*phy_port] = rte_rdtsc();
+ p_arp_data->update_tsc[phy_port] = rte_rdtsc();
return ret_arp_data;
}
-struct nd_entry_data *get_dest_mac_address_ipv6_port(uint8_t ipv6addr[],
- uint32_t *phy_port, struct ether_addr *hw_addr, uint8_t nhipv6[])
+
+struct nd_entry_data *get_dest_mac_addr_ipv6(uint8_t nhipv6[],
+ uint32_t phy_port, struct ether_addr *hw_addr)
{
- int i = 0, j = 0, flag = 0;
+ int i = 0;
uint8_t index;
lib_nd_get_mac_req++;
- get_nh_ipv6(ipv6addr, phy_port, nhipv6, hw_addr);
- for (j = 0; j < 16; j++) {
- if (nhipv6[j])
- flag++;
- }
-
- if (flag == 0) {
- if (NDIPV6_DEBUG)
- printf("NDIPV6 no nh found for ipv6 "
- "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
- "%02x%02x%02x%02x%02x%02x, port %d\n",
- ipv6addr[0], ipv6addr[1], ipv6addr[2],
- ipv6addr[3], ipv6addr[4], ipv6addr[5],
- ipv6addr[6], ipv6addr[7], ipv6addr[8],
- ipv6addr[9], ipv6addr[10], ipv6addr[11],
- ipv6addr[12], ipv6addr[13], ipv6addr[14],
- ipv6addr[15], *phy_port);
- return 0;
- }
-
struct nd_entry_data *ret_nd_data = NULL;
struct nd_key_ipv6 tmp_nd_key;
- tmp_nd_key.port_id = *phy_port;
+ tmp_nd_key.port_id = phy_port;
- if (nd_cache_dest_mac_present(*phy_port)) {
+ if (nd_cache_dest_mac_present(phy_port)) {
+ ether_addr_copy(get_nd_local_link_hw_addr(
+ (uint8_t)phy_port, nhipv6), hw_addr);
return &nd_entry_data_default;
}
@@ -548,28 +367,29 @@ struct nd_entry_data *get_dest_mac_address_ipv6_port(uint8_t ipv6addr[],
ret_nd_data = retrieve_nd_entry(tmp_nd_key, DYNAMIC_ND);
if (ret_nd_data == NULL) {
if (NDIPV6_DEBUG) {
- printf("NDIPV6 no nd entry found for ip %x, port %d\n",
- ipv6addr[0], *phy_port);
+ printf("NDIPV6 no entry found for ip %x, port %d\n",
+ nhipv6[0], phy_port);
}
lib_nd_no_arp_entry_found++;
return NULL;
} else if (ret_nd_data->status == COMPLETE) {
rte_rwlock_write_lock(&ret_nd_data->queue_lock);
ether_addr_copy(&ret_nd_data->eth_addr, hw_addr);
- p_arp_data->nd_cache_hw_laddr_valid[*phy_port] = 1;
- index = p_arp_data->nd_local_cache[*phy_port].num_nhip;
- rte_mov16(&p_arp_data->nd_local_cache[*phy_port].nhip[index][0],
- &nhipv6[0]);
+ p_arp_data->nd_cache_hw_laddr_valid[phy_port] = 1;
+ index = p_arp_data->nd_local_cache[phy_port].num_nhip;
+ for (i=0; i<16; i++) {
+ p_arp_data->nd_local_cache[phy_port].nhip[index][i] = nhipv6[i];
+ }
ether_addr_copy(hw_addr,
- &p_arp_data->nd_local_cache[*phy_port].link_hw_laddr[index]);
- p_arp_data->nd_local_cache[*phy_port].num_nhip++;
+ &p_arp_data->nd_local_cache[phy_port].link_hw_laddr[index]);
+ p_arp_data->nd_local_cache[phy_port].num_nhip++;
lib_nd_nd_entry_found++;
rte_rwlock_write_unlock(&ret_nd_data->queue_lock);
}
if (ret_nd_data)
- p_arp_data->update_tsc[*phy_port] = rte_rdtsc();
+ p_arp_data->update_tsc[phy_port] = rte_rdtsc();
return ret_nd_data;
}
@@ -822,8 +642,7 @@ struct arp_entry_data *retrieve_arp_entry(struct arp_key_ipv4 arp_key, uint8_t m
(void **)&ret_arp_data);
if (ret < 0 && (mode == DYNAMIC_ARP)) {
if (ARPICMP_DEBUG)
- RTE_LOG(INFO, LIBARP, "ARP entry not found for ip 0x%x\n",
- arp_key.ip);
+ RTE_LOG(INFO, LIBARP, "ARP entry not found for ip 0x%x\n",arp_key.ip);
/* add INCOMPLETE arp entry */
ret_arp_data = rte_malloc_socket(NULL, sizeof(struct arp_entry_data),
@@ -1045,10 +864,10 @@ void print_arp_table(void)
void *next_data;
uint32_t iter = 0;
- printf("------------------------ ARP CACHE ------------------------------------\n");
- printf("-----------------------------------------------------------------------\n");
+ printf ("------------------------ ARP CACHE -----------------------------------------\n");
+ printf ("----------------------------------------------------------------------------\n");
printf("\tport hw addr status ip addr\n");
- printf("-----------------------------------------------------------------------\n");
+ printf ("----------------------------------------------------------------------------\n");
while (rte_hash_iterate(arp_hash_handle, &next_key, &next_data, &iter)
>= 0) {
@@ -1057,9 +876,9 @@ void print_arp_table(void)
(struct arp_entry_data *)next_data;
struct arp_key_ipv4 tmp_arp_key;
memcpy(&tmp_arp_key, next_key, sizeof(struct arp_key_ipv4));
- printf("\t%4d %02X:%02X:%02X:%02X:%02X:%02X"
- " %10s %d.%d.%d.%d\n",
- tmp_arp_data->port, tmp_arp_data->eth_addr.addr_bytes[0],
+ printf("\t%4d %02X:%02X:%02X:%02X:%02X:%02X %10s %d.%d.%d.%d\n",
+ tmp_arp_data->port,
+ tmp_arp_data->eth_addr.addr_bytes[0],
tmp_arp_data->eth_addr.addr_bytes[1],
tmp_arp_data->eth_addr.addr_bytes[2],
tmp_arp_data->eth_addr.addr_bytes[3],
@@ -1073,22 +892,24 @@ void print_arp_table(void)
}
uint32_t i = 0;
- printf("\nARP routing table has %d entries\n", p_arp_data->lib_arp_route_ent_cnt);
- printf("\nIP_Address Mask Port NH_IP_Address\n");
- for (i = 0; i < p_arp_data->lib_arp_route_ent_cnt; i++) {
- printf("0x%x 0x%x %d 0x%x\n",
- p_arp_data->lib_arp_route_table[i].ip,
- p_arp_data->lib_arp_route_table[i].mask,
- p_arp_data->lib_arp_route_table[i].port,
- p_arp_data->lib_arp_route_table[i].nh);
+ uint32_t j = 0;
+
+ printf("\nARP routing table...\n");
+ printf("\nIP_Address \t Mask \t\t Port\n");
+ for (j = 0; j < gw_get_num_ports(); j++) {
+ for (i = 0; i < p_route_data[j]->route_ent_cnt; i++) {
+ printf("0x%08x \t 0x%08x \t %d\n",
+ p_route_data[j]->route_table[i].nh,
+ p_route_data[j]->route_table[i].mask,
+ p_route_data[j]->route_table[i].port);
+ }
}
-
- printf("\nARP Stats: Total Queries %u, ok_NH %u, no_NH %u, ok_Entry %u,"
- " no_Entry %u, PopulateCall %u, Del %u, Dup %u\n",
- lib_arp_get_mac_req, lib_arp_nh_found, lib_arp_no_nh_found,
- lib_arp_arp_entry_found, lib_arp_no_arp_entry_found,
- lib_arp_populate_called, lib_arp_delete_called,
- lib_arp_duplicate_found);
+ printf("\nARP Stats: Total Queries %u, ok_NH %u, no_NH %u, ok_Entry %u, "
+ "no_Entry %u, PopulateCall %u, Del %u, Dup %u\n",
+ lib_arp_get_mac_req, lib_arp_nh_found, lib_arp_no_nh_found,
+ lib_arp_arp_entry_found, lib_arp_no_arp_entry_found,
+ lib_arp_populate_called, lib_arp_delete_called,
+ lib_arp_duplicate_found);
printf("ARP table key len is %lu\n", sizeof(struct arp_key_ipv4));
}
@@ -1099,11 +920,13 @@ void print_nd_table(void)
const void *next_key;
void *next_data;
uint32_t iter = 0;
- uint8_t ii = 0, j = 0, k = 0;
- printf("-----------------------------------------------------------------------\n");
+ uint8_t ii = 0, k = 0;
+ printf
+ ("------------------------------------------------------------------------------------------------------\n");
printf("\tport hw addr status ip addr\n");
- printf("-----------------------------------------------------------------------\n");
+ printf
+ ("------------------------------------------------------------------------------------------------------\n");
while (rte_hash_iterate(nd_hash_handle, &next_key, &next_data, &iter) >=
0) {
@@ -1111,7 +934,7 @@ void print_nd_table(void)
(struct nd_entry_data *)next_data;
struct nd_key_ipv6 tmp_nd_key;
memcpy(&tmp_nd_key, next_key, sizeof(struct nd_key_ipv6));
- printf("\t%4d %02X:%02X:%02X:%02X:%02X:%02X %10s\n",
+ printf("\t%4d %02X:%02X:%02X:%02X:%02X:%02X %10s",
tmp_nd_data->port,
tmp_nd_data->eth_addr.addr_bytes[0],
tmp_nd_data->eth_addr.addr_bytes[1],
@@ -1120,7 +943,7 @@ void print_nd_table(void)
tmp_nd_data->eth_addr.addr_bytes[4],
tmp_nd_data->eth_addr.addr_bytes[5],
arp_status[tmp_nd_data->status]);
- printf("\t\t\t\t\t\t");
+ printf("\t");
for (ii = 0; ii < ND_IPV6_ADDR_SIZE; ii += 2) {
printf("%02X%02X ", tmp_nd_data->ipv6[ii],
tmp_nd_data->ipv6[ii + 1]);
@@ -1129,30 +952,24 @@ void print_nd_table(void)
}
uint32_t i = 0;
- printf("\n\nND IPV6 routing table has %d entries\n",
- nd_route_tbl_index);
- printf("\nIP_Address Depth");
- printf(" Port NH_IP_Address\n");
- for (i = 0; i < nd_route_tbl_index; i++) {
- printf("\n");
-
- for (j = 0; j < ND_IPV6_ADDR_SIZE; j += 2) {
- RTE_LOG(INFO, LIBARP, "%02X%02X ",
- lib_nd_route_table[i].ipv6[j],
- lib_nd_route_table[i].ipv6[j + 1]);
- }
+ printf("\n\nND IPV6 routing table ...\n");
+ printf ("\nNH_IP_Address Depth Port \n");
+ for(uint32_t p = 0; p < gw_get_num_ports(); p++ ) {
+ for (i = 0; i < p_nd_route_data[p]->nd_route_ent_cnt; i++) {
+ // printf("\n");
+
+ for (k = 0; k < ND_IPV6_ADDR_SIZE; k += 2) {
+ printf("%02X%02X ", p_nd_route_data[p]->nd_route_table[i].nhipv6[k],
+ p_nd_route_data[p]->nd_route_table[i].nhipv6[k + 1]);
+ }
- printf
- ("\n\t\t\t %d %d \n",
- lib_nd_route_table[i].depth, lib_nd_route_table[i].port);
- printf("\t\t\t\t\t\t\t\t\t");
- for (k = 0; k < ND_IPV6_ADDR_SIZE; k += 2) {
- printf("%02X%02X ", lib_nd_route_table[i].nhipv6[k],
- lib_nd_route_table[i].ipv6[k + 1]);
+ printf("\t%d %d \n",
+ p_nd_route_data[p]->nd_route_table[i].depth,
+ p_nd_route_data[p]->nd_route_table[i].port);
}
}
- printf("\nND IPV6 Stats: \nTotal Queries %u, ok_NH %u,"
- " no_NH %u, ok_Entry %u, no_Entry %u, PopulateCall %u, Del %u, Dup %u\n",
+ printf ("\nND IPV6 Stats: \nTotal Queries %u, ok_NH %u, no_NH %u, ok_Entry %u, "
+ "no_Entry %u, PopulateCall %u, Del %u, Dup %u\n",
lib_nd_get_mac_req, lib_nd_nh_found, lib_nd_no_nh_found,
lib_nd_nd_entry_found, lib_nd_no_arp_entry_found,
lib_nd_populate_called, lib_nd_delete_called,
@@ -1166,10 +983,13 @@ void remove_arp_entry(struct arp_entry_data *ret_arp_data, void *arg)
struct arp_timer_key *arp_key = (struct arp_timer_key *)arg;
lib_arp_delete_called++;
- rte_timer_stop(ret_arp_data->timer);
- rte_free(ret_arp_data->timer_key);
- rte_free(ret_arp_data->buf_pkts);
- ret_arp_data->buf_pkts = NULL;
+ if (ret_arp_data->timer) {
+ rte_timer_stop(ret_arp_data->timer);
+ rte_free(ret_arp_data->timer_key);
+ rte_free(ret_arp_data->buf_pkts);
+ ret_arp_data->buf_pkts = NULL;
+ }
+
if (ARPICMP_DEBUG) {
RTE_LOG(INFO, LIBARP,
"ARP Entry Deleted for IP :%d.%d.%d.%d , port %d\n",
@@ -1249,6 +1069,7 @@ arp_send_buffered_pkts(struct arp_entry_data *ret_arp_data,
tmp = pkt;
rte_pktmbuf_free(tmp);
}
+ printf("arp send buffered pkts = %d\n",ret_arp_data->num_pkts);
ret_arp_data->num_pkts = 0;
rte_rwlock_write_unlock(&ret_arp_data->queue_lock);
}
@@ -1346,7 +1167,7 @@ populate_arp_entry(const struct ether_addr *hw_addr, uint32_t ipaddr,
if (new_arp_data->status == STALE) {
new_arp_data->status = PROBE;
if (ifm_chk_port_ipv4_enabled
- (new_arp_data->port)) {
+ (new_arp_data->port) != IFM_FAILURE) {
request_arp(new_arp_data->port,
new_arp_data->ip);
} else {
@@ -1501,7 +1322,8 @@ void populate_nd_entry(const struct ether_addr *hw_addr, uint8_t ipv6[],
}
if (mode == DYNAMIC_ND) {
- if (new_nd_data && is_same_ether_addr(&new_nd_data->eth_addr, hw_addr)) {
+ if (new_nd_data
+ && is_same_ether_addr(&new_nd_data->eth_addr, hw_addr)) {
if (NDIPV6_DEBUG) {
RTE_LOG(INFO, LIBARP,
@@ -2075,7 +1897,7 @@ void process_arpicmp_pkt(struct rte_mbuf *pkt, l2_phy_interface_t *port)
* author:
* Paul Vixie, 1996.
*/
-static int my_inet_pton_ipv6(int af, const char *src, void *dst)
+int my_inet_pton_ipv6(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
@@ -2412,9 +2234,8 @@ static int arp_parse_args(struct pipeline_params *params)
/* arp_route_tbl */
if (strcmp(arg_name, "arp_route_tbl") == 0) {
arp_route_tbl_present = 1;
-
- uint32_t dest_ip = 0, mask = 0, tx_port = 0, nh_ip =
- 0, i = 0, j = 0, k = 0, l = 0;
+ uint32_t dest_ip = 0, mask = 0, tx_port = 0, nh_ip = 0,
+ i = 0, j = 0, k = 0;
uint32_t arp_route_tbl_str_max_len = 10;
char dest_ip_str[arp_route_tbl_str_max_len];
char mask_str[arp_route_tbl_str_max_len];
@@ -2425,11 +2246,11 @@ static int arp_parse_args(struct pipeline_params *params)
i = 0;
while ((i < (arp_route_tbl_str_max_len - 1))
&& (token[i] != ',')) {
- dest_ip_str[i] = token[i];
+ nh_ip_str[i] = token[i];
i++;
}
- dest_ip_str[i] = '\0';
- dest_ip = strtoul(dest_ip_str, NULL, 16);
+ nh_ip_str[i] = '\0';
+ nh_ip = strtoul(nh_ip_str, NULL, 16);
i++;
j = 0;
@@ -2452,19 +2273,11 @@ static int arp_parse_args(struct pipeline_params *params)
tx_port = strtoul(tx_port_str, NULL, 16); //atoi(tx_port_str);
k++;
- l = 0;
- while ((l < (arp_route_tbl_str_max_len - 1))
- && (token[i + j + k + l] != ')')) {
- nh_ip_str[l] = token[i + j + k + l];
- l++;
- }
- nh_ip_str[l] = '\0';
- nh_ip = strtoul(nh_ip_str, NULL, 16); //atoi(nh_ip_str);
if (1) {
RTE_LOG(INFO, LIBARP, "token: %s, "
"dest_ip_str: %s, dest_ip %u, "
- "mask_str: %s, mask %u, "
+ "mask_str: %s, mask %x, "
"tx_port_str: %s, tx_port %u, "
"nh_ip_str: %s, nh_ip %u\n",
token, dest_ip_str, dest_ip,
@@ -2480,15 +2293,15 @@ static int arp_parse_args(struct pipeline_params *params)
}
*/
//Populate the static arp_route_table
- struct lib_arp_route_table_entry *lentry =
- &p_arp_data->lib_arp_route_table
- [p_arp_data->lib_arp_route_ent_cnt];
- lentry->ip = dest_ip;
+
+ struct route_table_entry *lentry =
+ &p_route_data[tx_port]->route_table
+ [p_route_data[tx_port]->route_ent_cnt];
lentry->mask = mask;
lentry->port = tx_port;
lentry->nh = nh_ip;
lentry->nh_mask = nh_ip & mask;
- p_arp_data->lib_arp_route_ent_cnt++;
+ p_route_data[tx_port]->route_ent_cnt++;
token = strtok(NULL, "(");
}
@@ -2499,10 +2312,10 @@ static int arp_parse_args(struct pipeline_params *params)
if (strcmp(arg_name, "nd_route_tbl") == 0) {
nd_route_tbl_present = 1;
- uint8_t dest_ipv6[16], depth = 0, tx_port =
- 0, nh_ipv6[16], i = 0, j = 0, k = 0, l = 0;
+ uint8_t depth = 0, tx_port = 0, nh_ipv6[16];
+ uint8_t i = 0, j = 0, k = 0;
uint8_t nd_route_tbl_str_max_len = 128; //64;
- char dest_ipv6_str[nd_route_tbl_str_max_len];
+// char dest_ipv6_str[nd_route_tbl_str_max_len];
char depth_str[nd_route_tbl_str_max_len];
char tx_port_str[nd_route_tbl_str_max_len];
char nh_ipv6_str[nd_route_tbl_str_max_len];
@@ -2511,13 +2324,12 @@ static int arp_parse_args(struct pipeline_params *params)
i = 0;
while ((i < (nd_route_tbl_str_max_len - 1))
&& (token[i] != ',')) {
- dest_ipv6_str[i] = token[i];
+ nh_ipv6_str[i] = token[i];
i++;
}
- dest_ipv6_str[i] = '\0';
- my_inet_pton_ipv6(AF_INET6, dest_ipv6_str,
- &dest_ipv6);
-
+ nh_ipv6_str[i] = '\0';
+ my_inet_pton_ipv6(AF_INET6, nh_ipv6_str,
+ &nh_ipv6);
i++;
j = 0;
while ((j < (nd_route_tbl_str_max_len - 1))
@@ -2542,31 +2354,19 @@ static int arp_parse_args(struct pipeline_params *params)
tx_port = strtoul(tx_port_str, NULL, 16); //atoi(tx_port_str);
k++;
- l = 0;
- while ((l < (nd_route_tbl_str_max_len - 1))
- && (token[i + j + k + l] != ')')) {
- nh_ipv6_str[l] = token[i + j + k + l];
- l++;
- }
- nh_ipv6_str[l] = '\0';
- my_inet_pton_ipv6(AF_INET6, nh_ipv6_str,
- &nh_ipv6);
+ struct nd_route_table_entry *lentry =
+ &p_nd_route_data[tx_port]->nd_route_table
+ [p_nd_route_data[tx_port]->nd_route_ent_cnt];
//Populate the static arp_route_table
- for (i = 0; i < 16; i++) {
- lib_nd_route_table
- [nd_route_tbl_index].ipv6[i] =
- dest_ipv6[i];
- lib_nd_route_table
- [nd_route_tbl_index].nhipv6[i] =
- nh_ipv6[i];
- }
- lib_nd_route_table[nd_route_tbl_index].depth =
- depth;
- lib_nd_route_table[nd_route_tbl_index].port =
- tx_port;
+ for (i = 0; i < 16; i++)
+ lentry->nhipv6[i] = nh_ipv6[i];
+
+ lentry->depth = depth;
+ lentry->port = tx_port;
+
+ p_nd_route_data[tx_port]->nd_route_ent_cnt++;
- nd_route_tbl_index++;
token = strtok(NULL, "(");
}
@@ -2614,13 +2414,19 @@ struct ether_addr *get_nd_local_link_hw_addr(uint8_t out_port, uint8_t nhip[])
}
x = &p_arp_data->nd_local_cache[out_port].link_hw_laddr[i];
+
+ if(ARPICMP_DEBUG) {
+ for (j = 0; j < 6; j++)
+ printf("%d %d", x->addr_bytes[j],
+ p_arp_data->nd_local_cache[out_port].link_hw_laddr[i].addr_bytes[j]);
+ }
return x;
}
return x;
}
-struct ether_addr *get_local_link_hw_addr(uint8_t out_port, uint32_t nhip)
+struct ether_addr *get_local_cache_hw_addr(uint8_t out_port, uint32_t nhip)
{
int i, limit;
uint32_t tmp;
@@ -2642,7 +2448,7 @@ void lib_arp_init(struct pipeline_params *params,
int i;
uint32_t size;
- struct pipeline_cgnapt *p;
+ struct arp_data *p;
RTE_LOG(INFO, LIBARP, "ARP initialization ...\n");
@@ -2799,7 +2605,7 @@ void arp_timer_callback(struct rte_timer *timer, void *arg)
rte_rwlock_write_lock(&ret_arp_data->queue_lock);
if (ret_arp_data->status == PROBE ||
ret_arp_data->status == INCOMPLETE) {
- if (ret_arp_data->retry_count == 3) {
+ if (ret_arp_data->retry_count == ARP_RETRY_COUNT) {
remove_arp_entry(ret_arp_data, arg);
} else {
ret_arp_data->retry_count++;
@@ -2815,7 +2621,7 @@ void arp_timer_callback(struct rte_timer *timer, void *arg)
}
if (ifm_chk_port_ipv4_enabled
- (ret_arp_data->port)) {
+ (ret_arp_data->port) != IFM_FAILURE) {
request_arp(ret_arp_data->port,
ret_arp_data->ip);
} else {
@@ -2912,7 +2718,7 @@ void nd_timer_callback(struct rte_timer *timer, void *arg)
rte_rwlock_write_lock(&ret_nd_data->queue_lock);
if (ret_nd_data->status == PROBE ||
ret_nd_data->status == INCOMPLETE) {
- if (ret_nd_data->retry_count == 3) {
+ if (ret_nd_data->retry_count == ARP_RETRY_COUNT) {
remove_nd_entry_ipv6(ret_nd_data, arg);
} else {
ret_nd_data->retry_count++;
diff --git a/common/VIL/l2l3_stack/lib_arp.h b/common/VIL/l2l3_stack/lib_arp.h
index 9cb0205f..c635c94c 100644
--- a/common/VIL/l2l3_stack/lib_arp.h
+++ b/common/VIL/l2l3_stack/lib_arp.h
@@ -32,20 +32,9 @@
#define NUM_DESC (get_arp_buf())
#define ARP_BUF_DEFAULT 30000
#define PROBE_TIME 50
+#define ARP_RETRY_COUNT 100
#undef L3_STACK_SUPPORT
-/**
-* A structure for Route table entries of IPv4
-*/
-
-struct lib_arp_route_table_entry {
- uint32_t ip; /**< Ipv4 address*/
- uint32_t mask; /**< mask */
- uint32_t port; /**< Physical port */
- uint32_t nh; /**< next hop */
- uint32_t nh_mask;
-};
-
#define MAX_LOCAL_MAC_ADDRESS 32
#define MAX_PORTS 32
struct arp_cache {
@@ -60,28 +49,35 @@ struct nd_cache {
uint32_t num_nhip;
};
-/**
-* A structure for Route table entires of IPv6
-*
-*/
-struct lib_nd_route_table_entry {
- uint8_t ipv6[16]; /**< Ipv6 address */
- uint8_t depth; /**< Depth */
- uint32_t port; /**< Port */
- uint8_t nhipv6[16]; /**< next hop Ipv6 */
-};
-
uint8_t arp_cache_dest_mac_present(uint32_t out_port);
uint8_t nd_cache_dest_mac_present(uint32_t out_port);
-extern struct lib_nd_route_table_entry lib_nd_route_table[MAX_ND_RT_ENTRY];
-extern struct lib_arp_route_table_entry lib_arp_route_table[MAX_ARP_RT_ENTRY];
-extern struct ether_addr *get_local_link_hw_addr(uint8_t out_port, uint32_t nhip);
+extern struct ether_addr *get_local_cache_hw_addr(uint8_t out_port, uint32_t nhip);
extern struct ether_addr *get_nd_local_link_hw_addr(uint8_t out_port, uint8_t nhip[]);
extern struct arp_cache arp_local_cache[MAX_PORTS];
extern void prefetch(void);
extern void update_nhip_access(uint8_t);
uint32_t get_arp_buf(void);
uint32_t get_nd_buf(void);
+extern int my_inet_pton_ipv6(int af, const char *src, void *dst);
+extern struct rte_hash *arp_hash_handle;
+extern struct rte_hash *nd_hash_handle;
+extern uint32_t lib_arp_get_mac_req;
+extern uint32_t lib_arp_nh_found;
+extern uint32_t lib_arp_no_nh_found;
+extern uint32_t lib_arp_arp_entry_found;
+extern uint32_t lib_arp_no_arp_entry_found;
+extern uint32_t lib_arp_populate_called;
+extern uint32_t lib_arp_delete_called;
+extern uint32_t lib_arp_duplicate_found;
+extern uint32_t arp_route_tbl_index;
+extern uint32_t lib_nd_get_mac_req;
+extern uint32_t lib_nd_nh_found;
+extern uint32_t lib_nd_no_nh_found;
+extern uint32_t lib_nd_nd_entry_found;
+extern uint32_t lib_nd_no_arp_entry_found;
+extern uint32_t lib_nd_populate_called;
+extern uint32_t lib_nd_delete_called;
+extern uint32_t lib_nd_duplicate_found;
enum {
ARP_FOUND,
@@ -228,12 +224,6 @@ struct table_nd_entry_data {
} __attribute__ ((packed));
struct arp_data {
- struct lib_arp_route_table_entry
- lib_arp_route_table[MAX_ARP_RT_ENTRY];
- uint8_t lib_arp_route_ent_cnt;
- struct lib_nd_route_table_entry
- lib_nd_route_table[MAX_ARP_RT_ENTRY];
- uint8_t lib_nd_route_ent_cnt;
struct arp_cache arp_local_cache[MAX_PORTS];
struct nd_cache nd_local_cache[MAX_PORTS];
struct ether_addr link_hw_addr[MAX_LOCAL_MAC_ADDRESS];
@@ -257,7 +247,7 @@ struct arp_data {
* 0 if failure, and 1 if success
*/
struct arp_entry_data *get_dest_mac_addr_port(const uint32_t ipaddr,
- uint32_t *phy_port, struct ether_addr *hw_addr);
+ uint32_t phy_port, struct ether_addr *hw_addr);
/**
* To get the destination mac address for IPV6 address
@@ -272,10 +262,6 @@ struct arp_entry_data *get_dest_mac_addr_port(const uint32_t ipaddr,
* @return
* 0 if failure, 1 ifsuccess
*/
-
-struct nd_entry_data *get_dest_mac_address_ipv6_port(uint8_t ipv6addr[], uint32_t *phy_port,
- struct ether_addr *hw_addr,
- uint8_t nhipv6[]);
int arp_queue_unresolved_packet(struct arp_entry_data * arp_data,
struct rte_mbuf * m);
extern void arp_send_buffered_pkts(struct arp_entry_data *ret_arp_data,struct ether_addr *hw_addr, uint8_t port_id);
@@ -524,4 +510,10 @@ uint32_t get_nh(uint32_t, uint32_t *, struct ether_addr *addr);
* next hop ipv6
*/
void get_nh_ipv6(uint8_t ipv6[], uint32_t *port, uint8_t nhipv6[], struct ether_addr *hw_addr);
+
+struct arp_entry_data *get_dest_mac_addr_ipv4(const uint32_t nhip,
+ uint32_t phy_port, struct ether_addr *hw_addr);
+struct nd_entry_data *get_dest_mac_addr_ipv6(uint8_t nhipv6[],
+ uint32_t phy_port, struct ether_addr *hw_addr);
+
#endif
diff --git a/common/VIL/l2l3_stack/tsx.h b/common/VIL/l2l3_stack/tsx.h
index 8b748165..01bde702 100644
--- a/common/VIL/l2l3_stack/tsx.h
+++ b/common/VIL/l2l3_stack/tsx.h
@@ -16,8 +16,14 @@
#ifndef _TSX_H_
#define _RSX_H_
#include <rte_atomic.h>
+
+#ifndef TRUE
#define TRUE 1
+#endif
+
+#ifndef FALSE
#define FALSE 0
+#endif
volatile int mutex_val;
diff --git a/common/VIL/pipeline_arpicmp/pipeline_arpicmp.c b/common/VIL/pipeline_arpicmp/pipeline_arpicmp.c
index 6b42ad77..607d13d1 100644
--- a/common/VIL/pipeline_arpicmp/pipeline_arpicmp.c
+++ b/common/VIL/pipeline_arpicmp/pipeline_arpicmp.c
@@ -70,6 +70,14 @@ struct cmd_arp_add_result {
};
+uint16_t str2flowtype(char *string);
+int parse_flexbytes(const char *q_arg, uint8_t *flexbytes,
+ uint16_t max_num);
+enum rte_eth_input_set_field str2inset(char *string);
+int app_pipeline_arpicmp_entry_dbg(struct app_params *app,
+ uint32_t pipeline_id, uint8_t *msg);
+
+
static void
cmd_arp_add_parsed(void *parsed_result,
__rte_unused struct cmdline *cl, __rte_unused void *data)
@@ -952,8 +960,7 @@ cmdline_parse_inst_t cmd_set_fwd_mode = {
#if 1
-static uint16_t
-str2flowtype(char *string)
+uint16_t str2flowtype(char *string)
{
uint8_t i = 0;
static const struct {
@@ -983,7 +990,7 @@ str2flowtype(char *string)
return RTE_ETH_FLOW_UNKNOWN;
}
-static inline int
+int
parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
{
char s[256];
@@ -1442,7 +1449,7 @@ struct cmd_set_hash_input_set_result {
cmdline_fixed_string_t select;
};
-static enum rte_eth_input_set_field
+enum rte_eth_input_set_field
str2inset(char *string)
{
uint16_t i;
@@ -1966,7 +1973,7 @@ cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
};
#endif
-static int
+int
app_pipeline_arpicmp_entry_dbg(struct app_params *app,
uint32_t pipeline_id, uint8_t *msg)
{
diff --git a/common/VIL/pipeline_arpicmp/pipeline_arpicmp_be.c b/common/VIL/pipeline_arpicmp/pipeline_arpicmp_be.c
index 1dbf34a3..481f8521 100644
--- a/common/VIL/pipeline_arpicmp/pipeline_arpicmp_be.c
+++ b/common/VIL/pipeline_arpicmp/pipeline_arpicmp_be.c
@@ -50,6 +50,7 @@
#include "lib_arp.h"
#include "lib_icmpv6.h"
#include "interface.h"
+#include "gateway.h"
/* Shared among all VNFs including LB */
struct app_params *myApp;
@@ -811,7 +812,7 @@ static void *pipeline_arpicmp_init(struct pipeline_params *params,
p_arp->receivedPktCount = 0;
p_arp->droppedPktCount = 0;
-
+ gw_init(rte_eth_dev_count());
lib_arp_init(params, app);
/* Pipeline */
diff --git a/common/VIL/pipeline_common/pipeline_common_fe.c b/common/VIL/pipeline_common/pipeline_common_fe.c
index 5d6976b5..6fc6109c 100644
--- a/common/VIL/pipeline_common/pipeline_common_fe.c
+++ b/common/VIL/pipeline_common/pipeline_common_fe.c
@@ -33,6 +33,9 @@
#include "pipeline_common_fe.h"
#include "interface.h"
#include "lib_arp.h"
+#include "gateway.h"
+
+void app_run_file(cmdline_parse_ctx_t *ctx, const char *file_name);
int
app_pipeline_ping(struct app_params *app,
@@ -541,12 +544,12 @@ app_link_down(struct app_params *app,
*/
struct cmd_routeadd_config_result {
cmdline_fixed_string_t routeadd_string;
+ cmdline_fixed_string_t type_string;
uint32_t port_id;
cmdline_ipaddr_t ip;
cmdline_fixed_string_t depth;
};
-extern struct lib_nd_route_table_entry lib_nd_route_table[MAX_ND_RT_ENTRY];
extern struct arp_data *p_arp_data;
extern uint32_t nd_route_tbl_index;
@@ -556,25 +559,48 @@ extern uint32_t nd_route_tbl_index;
int app_routeadd_config_ipv4(__attribute__((unused)) struct app_params *app,
uint32_t port_id, uint32_t ip, uint32_t mask)
{
- if (port_id > MAX_PORTS) {
- printf("Max ports allowed is %d\n", MAX_PORTS);
+ uint32_t i = 0;
+ if (port_id >= gw_get_num_ports()) {
+ printf("Max ports allowed is %d\n", gw_get_num_ports());
return 1;
}
- printf("port id:%d ip: %x mask:%x", port_id, ip, mask);
+ printf("port id:%d ip: %x mask:%x\n", port_id, ip, mask);
+
+ struct route_table_entry *lentry = NULL;
+
+ /* Check for matching entry */
+ for(i = 0 ; i< p_route_data[port_id]->route_ent_cnt; i++) {
+
+ lentry = &p_route_data[port_id]->route_table[i];
+
+ /* Entry already exists? */
+ if(mask == 0) {
+ if(lentry->nh == ip)
+ return 1;
+ } else {
+ if( lentry->nh_mask == (ip & mask))
+ return 1;
+ }
+ }
+ if(i < MAX_ROUTE_ENTRY_SIZE) {
+
+ lentry = &p_route_data[port_id]->route_table[i];
- struct lib_arp_route_table_entry *lentry =
- &p_arp_data->lib_arp_route_table
- [port_id];
- if (!lentry->ip)
- p_arp_data->lib_arp_route_ent_cnt++;
- lentry->ip = ip;
+ p_route_data[port_id]->route_ent_cnt++;
lentry->mask = mask;
lentry->port = port_id;
lentry->nh = ip;
- lentry->nh_mask = ip & mask;
+ lentry->nh_mask = (ip & mask);
+ /* Set the VNF Gateway flag */
+ vnf_gateway = 1;
+ return 0;
+ } else {
+
+ printf("Error: Number of entries more than supported\n");
+ return 1;
+ }
- return 0;
}
/*
@@ -585,8 +611,8 @@ int app_routeadd_config_ipv6(__attribute__((unused)) struct app_params *app,
{
int i;
- if (port_id > MAX_ND_RT_ENTRY) {
- printf("Max ports allowed is %d\n", MAX_ND_RT_ENTRY);
+ if (port_id >= gw_get_num_ports()) {
+ printf("Max ports allowed is %d\n", gw_get_num_ports());
return 1;
}
@@ -594,25 +620,72 @@ int app_routeadd_config_ipv6(__attribute__((unused)) struct app_params *app,
nd_route_tbl_index++;
printf("port id:%d depth:%d\n", port_id, depth);
- printf("ipv6 address ");
- for (i = 0; i < 16; i++) {
- lib_nd_route_table[port_id].ipv6[i] = ipv6[i];
- lib_nd_route_table[port_id].nhipv6[i] = ipv6[i];
- printf("%x ", ipv6[i]);
- }
+ printf("ipv6 address: ");
+ for(i = 0; i < IPV6_ADD_SIZE; i++)
+ printf("%02x ", ipv6[i]);
printf("\n");
+ struct nd_route_table_entry *lentry = NULL;
+ int k;
+ uint8_t netmask_ipv6[16], netip_nd[16], netip_in[16];
+ uint8_t depthflags = 0, depthflags1 = 0;
- lib_nd_route_table[port_id].depth = depth;
- lib_nd_route_table[port_id].port = port_id;
+ i = 0;
- printf("num ports :%d\n", nd_route_tbl_index);
+ /* Check for matching entry */
+ for(i = 0 ; i< p_nd_route_data[port_id]->nd_route_ent_cnt; i++) {
- return 0;
+ lentry = &p_nd_route_data[port_id]->nd_route_table[i];
+
+ memset(netmask_ipv6, 0, sizeof(netmask_ipv6));
+ memset(netip_nd, 0, sizeof(netip_nd));
+ memset(netip_in, 0, sizeof(netip_in));
+
+ /* Create netmask from depth */
+ convert_prefixlen_to_netmask_ipv6(lentry->depth, netmask_ipv6);
+
+ for (k = 0; k < 16; k++) {
+ if (lentry->nhipv6[k] & netmask_ipv6[k]) {
+ depthflags++;
+ netip_nd[k] = lentry->nhipv6[k];
+ }
+
+ if (ipv6[k] & netmask_ipv6[k]) {
+ depthflags1++;
+ netip_in[k] = ipv6[k];
+ }
+ }
+
+ if ((depthflags == depthflags1)
+ && (memcmp(netip_nd, netip_in, sizeof(netip_nd)) == 0)) {
+ /* Route already exists */
+ printf("Route already exists \n");
+ return 1;
+ }
+ }
+
+ if(i < MAX_ND_ROUTE_ENTRY_SIZE) {
+
+ lentry = &p_nd_route_data[port_id]->nd_route_table[i];
+
+ rte_mov16(lentry->nhipv6, ipv6);
+
+ lentry->depth = depth;
+ lentry->port = port_id;
+ p_nd_route_data[port_id]->nd_route_ent_cnt++;
+ /* Set the VNF Gateway flag */
+ vnf_gateway = 1;
+
+ return 0;
+ } else {
+
+ printf("Error: Number of entries more than supported\n");
+ return 1;
+ }
}
/*
- * cmd handler for handling route add entry at runtime.
+ * cmd handler for handling route abj entry at runtime.
* the same handle takes care of both ipv4 & ipv6
*/
static void
@@ -629,15 +702,30 @@ cmd_routeadd_parsed(
uint32_t i, ip = 0, depth = 0, mask = 0;
uint8_t ipv6[16];
+ printf("Adding route for %s \n", params->type_string);
+
if (params->ip.family == AF_INET) {
ip = rte_bswap32((uint32_t) params->ip.addr.ipv4.s_addr);
- mask = strtoul(params->depth, NULL, 16);
- printf("ip:%x mask:%x port_id:%d\n", ip, mask, port_id);
+
+ if(strcmp(params->type_string, "net") == 0)
+ {
+ mask = strtoul(params->depth, NULL, 16);
+ } else {
+ mask = 0xffffffff;
+ }
+
+ printf("nhip:0x%08x mask:%x port_id:%d\n", ip, mask, port_id);
} else {
memcpy(ipv6, params->ip.addr.ipv6.s6_addr, 16);
- depth = atoi(params->depth);
- for (i=0;i<16;i++)
- printf("%d ", ipv6[i]);
+ if(strcmp(params->type_string, "net") == 0)
+ {
+ depth = atoi(params->depth);
+ } else {
+ depth = 64;
+ }
+
+ for (i=0; i < 16; i++)
+ printf("%02x ", ipv6[i]);
printf("\n port_id:%d depth:%d \n", port_id, depth);
}
@@ -657,6 +745,14 @@ cmdline_parse_token_string_t cmd_routeadd_config_string =
TOKEN_STRING_INITIALIZER(struct cmd_routeadd_config_result, routeadd_string,
"routeadd");
+cmdline_parse_token_string_t cmd_routeadd_net_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_routeadd_config_result, type_string,
+ "net");
+
+cmdline_parse_token_string_t cmd_routeadd_host_string =
+ TOKEN_STRING_INITIALIZER(struct cmd_routeadd_config_result, type_string,
+ "host");
+
cmdline_parse_token_num_t cmd_routeadd_config_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_routeadd_config_result, port_id, UINT32);
@@ -666,15 +762,29 @@ cmdline_parse_token_ipaddr_t cmd_routeadd_config_ip =
cmdline_parse_token_string_t cmd_routeadd_config_depth_string =
TOKEN_STRING_INITIALIZER(struct cmd_routeadd_config_result, depth, NULL);
-cmdline_parse_inst_t cmd_routeadd = {
+cmdline_parse_inst_t cmd_routeadd_net = {
.f = cmd_routeadd_parsed,
.data = NULL,
- .help_str = "Add Route entry",
+ .help_str = "Add Route entry for gateway",
.tokens = {
(void *) &cmd_routeadd_config_string,
+ (void *) &cmd_routeadd_net_string,
(void *) &cmd_routeadd_config_port_id,
- (void *) &cmd_routeadd_config_ip,
- (void *) &cmd_routeadd_config_depth_string,
+ (void *) &cmd_routeadd_config_ip,
+ (void *) &cmd_routeadd_config_depth_string,
+ NULL,
+ },
+};
+
+cmdline_parse_inst_t cmd_routeadd_host = {
+ .f = cmd_routeadd_parsed,
+ .data = NULL,
+ .help_str = "Add Route entry for host",
+ .tokens = {
+ (void *) &cmd_routeadd_config_string,
+ (void *) &cmd_routeadd_host_string,
+ (void *) &cmd_routeadd_config_port_id,
+ (void *) &cmd_routeadd_config_ip,
NULL,
},
};
@@ -1469,7 +1579,7 @@ static cmdline_parse_inst_t cmd_quit = {
* run
*/
-static void
+void
app_run_file(
cmdline_parse_ctx_t *ctx,
const char *file_name)
@@ -1525,7 +1635,8 @@ cmdline_parse_inst_t cmd_run = {
static cmdline_parse_ctx_t pipeline_common_cmds[] = {
(cmdline_parse_inst_t *) &cmd_quit,
(cmdline_parse_inst_t *) &cmd_run,
- (cmdline_parse_inst_t *) &cmd_routeadd,
+ (cmdline_parse_inst_t *) &cmd_routeadd_net,
+ (cmdline_parse_inst_t *) &cmd_routeadd_host,
(cmdline_parse_inst_t *) &cmd_link_config,
(cmdline_parse_inst_t *) &cmd_link_up,
diff --git a/common/VIL/pipeline_master/pipeline_master_be.c b/common/VIL/pipeline_master/pipeline_master_be.c
index 425e2334..cc50497e 100644
--- a/common/VIL/pipeline_master/pipeline_master_be.c
+++ b/common/VIL/pipeline_master/pipeline_master_be.c
@@ -28,6 +28,8 @@
#include "app.h"
#include "pipeline_master_be.h"
+struct cmdline *pipe_cl;
+
struct pipeline_master {
struct app_params *app;
struct cmdline *cl;
@@ -59,6 +61,7 @@ pipeline_init(__rte_unused struct pipeline_params *params, void *arg)
rte_free(p);
return NULL;
}
+ pipe_cl = p->cl;
p->script_file_done = 0;
if (app->script_file == NULL)
@@ -85,6 +88,7 @@ static int
pipeline_run(void *pipeline)
{
struct pipeline_master *p = (struct pipeline_master *) pipeline;
+
int status;
if (p->script_file_done == 0) {