DPDK patches and discussions
 help / color / mirror / Atom feed
From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Sunil Kumar Kori <skori@marvell.com>,
	Rakesh Kudurumalla <rkudurumalla@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Zhirun Yan <yanzhirun_163@163.com>,
	Pavan Nikhilesh <pbhagavatula@marvell.com>
Subject: [PATCH dpdk v1 08/15] graph,node: use ipv6 addr struct and utils
Date: Wed, 21 Aug 2024 18:25:25 +0200	[thread overview]
Message-ID: <20240821162516.610624-25-rjarry@redhat.com> (raw)
In-Reply-To: <20240821162516.610624-17-rjarry@redhat.com>

Replace ad-hoc uint8_t[16] arrays with the previously introduced IPv6
address structure.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
 app/graph/ethdev.c          | 40 ++++++++++---------------------
 app/graph/ethdev.h          |  9 ++++---
 app/graph/ip6_route.c       | 47 +++++++++----------------------------
 app/graph/meson.build       |  2 +-
 app/graph/neigh.c           | 22 +++++++----------
 app/graph/neigh_priv.h      |  4 +++-
 app/graph/route.h           |  8 ++++---
 examples/l3fwd-graph/main.c | 30 +++++++++--------------
 lib/node/ip6_lookup.c       | 17 ++++++--------
 lib/node/rte_node_ip6_api.h |  3 ++-
 10 files changed, 65 insertions(+), 117 deletions(-)

diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c
index cfc1b1856910..19c5ab685464 100644
--- a/app/graph/ethdev.c
+++ b/app/graph/ethdev.c
@@ -124,30 +124,19 @@ ethdev_portid_by_ip4(uint32_t ip, uint32_t mask)
 }
 
 int16_t
-ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask)
+ethdev_portid_by_ip6(struct rte_ipv6_addr *ip, struct rte_ipv6_addr *mask)
 {
-	int portid = -EINVAL;
 	struct ethdev *port;
-	int j;
 
 	TAILQ_FOREACH(port, &eth_node, next) {
-		for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++) {
-			if (mask == NULL) {
-				if ((port->ip6_addr.ip[j] & port->ip6_addr.mask[j]) !=
-				    (ip[j] & port->ip6_addr.mask[j]))
-					break;
-
-			} else {
-				if ((port->ip6_addr.ip[j] & port->ip6_addr.mask[j]) !=
-				    (ip[j] & mask[j]))
-					break;
-			}
-		}
-		if (j == ETHDEV_IPV6_ADDR_LEN)
+		uint8_t depth = rte_ipv6_mask_depth(&port->ip6_addr.mask);
+		if (mask != NULL)
+			depth = RTE_MAX(depth, rte_ipv6_mask_depth(mask));
+		if (rte_ipv6_addr_eq_prefix(&port->ip6_addr.ip, ip, depth))
 			return port->config.port_id;
 	}
 
-	return portid;
+	return -EINVAL;
 }
 
 void
@@ -285,7 +274,7 @@ ethdev_ip6_addr_add(const char *name, struct ipv6_addr_config *config)
 {
 	struct ethdev *eth_hdl;
 	uint16_t portid = 0;
-	int rc, i;
+	int rc;
 
 	rc = rte_eth_dev_get_port_by_name(name, &portid);
 	if (rc < 0)
@@ -294,10 +283,8 @@ ethdev_ip6_addr_add(const char *name, struct ipv6_addr_config *config)
 	eth_hdl = ethdev_port_by_id(portid);
 
 	if (eth_hdl) {
-		for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) {
-			eth_hdl->ip6_addr.ip[i] = config->ip[i];
-			eth_hdl->ip6_addr.mask[i] = config->mask[i];
-		}
+		rte_ipv6_addr_cpy(&eth_hdl->ip6_addr.ip, &config->ip);
+		rte_ipv6_addr_cpy(&eth_hdl->ip6_addr.mask, &config->mask);
 		return 0;
 	}
 	rc = -EINVAL;
@@ -624,13 +611,10 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdl
 {
 	struct cmd_ethdev_dev_ip6_addr_add_result *res = parsed_result;
 	struct ipv6_addr_config config;
-	int rc = -EINVAL, i;
+	int rc = -EINVAL;
 
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.s6_addr[i];
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.s6_addr[i];
+	rte_memcpy(&config.ip, &res->ip.addr.ipv6, sizeof(config.ip));
+	rte_memcpy(&config.mask, &res->mask.addr.ipv6, sizeof(config.mask));
 
 	rc = ethdev_ip6_addr_add(res->dev, &config);
 	if (rc < 0)
diff --git a/app/graph/ethdev.h b/app/graph/ethdev.h
index d0de593fc743..046689ee5fc7 100644
--- a/app/graph/ethdev.h
+++ b/app/graph/ethdev.h
@@ -6,8 +6,7 @@
 #define APP_GRAPH_ETHDEV_H
 
 #include <cmdline_parse.h>
-
-#define ETHDEV_IPV6_ADDR_LEN	16
+#include <rte_ip6.h>
 
 struct ipv4_addr_config {
 	uint32_t ip;
@@ -15,8 +14,8 @@ struct ipv4_addr_config {
 };
 
 struct ipv6_addr_config {
-	uint8_t ip[ETHDEV_IPV6_ADDR_LEN];
-	uint8_t mask[ETHDEV_IPV6_ADDR_LEN];
+	struct rte_ipv6_addr ip;
+	struct rte_ipv6_addr mask;
 };
 
 extern uint32_t enabled_port_mask;
@@ -25,7 +24,7 @@ void ethdev_start(void);
 void ethdev_stop(void);
 void *ethdev_mempool_list_by_portid(uint16_t portid);
 int16_t ethdev_portid_by_ip4(uint32_t ip, uint32_t mask);
-int16_t ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask);
+int16_t ethdev_portid_by_ip6(struct rte_ipv6_addr *ip, struct rte_ipv6_addr *mask);
 int16_t ethdev_txport_by_rxport_get(uint16_t portid_rx);
 void ethdev_list_clean(void);
 
diff --git a/app/graph/ip6_route.c b/app/graph/ip6_route.c
index 834719ecaeb4..5460e5070b42 100644
--- a/app/graph/ip6_route.c
+++ b/app/graph/ip6_route.c
@@ -11,6 +11,7 @@
 #include <cmdline_socket.h>
 
 #include <rte_node_ip6_api.h>
+#include <rte_ip6.h>
 
 #include "module_api.h"
 #include "route_priv.h"
@@ -43,38 +44,20 @@ find_route6_entry(struct route_ipv6_config *route)
 	return NULL;
 }
 
-static uint8_t
-convert_ip6_netmask_to_depth(uint8_t *netmask)
-{
-	uint8_t setbits = 0;
-	uint8_t mask;
-	int i;
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) {
-		mask = netmask[i];
-		while (mask & 0x80) {
-			mask = mask << 1;
-			setbits++;
-		}
-	}
-
-	return setbits;
-}
-
 static int
 route6_rewirte_table_update(struct route_ipv6_config *ipv6route)
 {
 	uint8_t depth;
 	int portid;
 
-	portid = ethdev_portid_by_ip6(ipv6route->gateway, ipv6route->mask);
+	portid = ethdev_portid_by_ip6(&ipv6route->gateway, &ipv6route->mask);
 	if (portid < 0) {
 		printf("Invalid portid found to install the route\n");
 		return portid;
 	}
-	depth = convert_ip6_netmask_to_depth(ipv6route->mask);
+	depth = rte_ipv6_mask_depth(&ipv6route->mask);
 
-	return rte_node_ip6_route_add(ipv6route->ip, depth, portid,
+	return rte_node_ip6_route_add(&ipv6route->ip, depth, portid,
 			RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
 
 }
@@ -84,7 +67,6 @@ route_ip6_add(struct route_ipv6_config *route)
 {
 	struct route_ipv6_config *ipv6route;
 	int rc = -EINVAL;
-	int j;
 
 	ipv6route = find_route6_entry(route);
 	if (!ipv6route) {
@@ -95,11 +77,9 @@ route_ip6_add(struct route_ipv6_config *route)
 		return 0;
 	}
 
-	for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++) {
-		ipv6route->ip[j] = route->ip[j];
-		ipv6route->mask[j] = route->mask[j];
-		ipv6route->gateway[j] = route->gateway[j];
-	}
+	rte_ipv6_addr_cpy(&ipv6route->ip, &route->ip);
+	rte_ipv6_addr_cpy(&ipv6route->mask, &route->mask);
+	rte_ipv6_addr_cpy(&ipv6route->gateway, &route->gateway);
 	ipv6route->is_used = true;
 
 	if (!graph_status_get())
@@ -154,16 +134,11 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct c
 {
 	struct cmd_ipv6_lookup_route_add_ipv6_result *res = parsed_result;
 	struct route_ipv6_config config;
-	int rc = -EINVAL, i;
+	int rc = -EINVAL;
 
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.s6_addr[i];
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.s6_addr[i];
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.gateway[i] = res->via_ip.addr.ipv6.s6_addr[i];
+	rte_memcpy(&config.ip, &res->ip.addr.ipv6, sizeof(config.ip));
+	rte_memcpy(&config.mask, &res->mask.addr.ipv6, sizeof(config.mask));
+	rte_memcpy(&config.gateway, &res->via_ip.addr.ipv6, sizeof(config.gateway));
 
 	rc = route_ip6_add(&config);
 	if (rc)
diff --git a/app/graph/meson.build b/app/graph/meson.build
index 6dc54d5ee63f..344e4a418fc0 100644
--- a/app/graph/meson.build
+++ b/app/graph/meson.build
@@ -9,7 +9,7 @@ if not build
     subdir_done()
 endif
 
-deps += ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline']
+deps += ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline', 'net']
 sources = files(
         'cli.c',
         'conn.c',
diff --git a/app/graph/neigh.c b/app/graph/neigh.c
index 79fd542c8948..0b35f4d6c294 100644
--- a/app/graph/neigh.c
+++ b/app/graph/neigh.c
@@ -62,12 +62,12 @@ find_neigh4_entry(uint32_t ip, uint64_t mac)
 }
 
 static struct neigh_ipv6_config *
-find_neigh6_entry(uint8_t *ip, uint64_t mac)
+find_neigh6_entry(struct rte_ipv6_addr *ip, uint64_t mac)
 {
 	struct neigh_ipv6_config *v6_config;
 
 	TAILQ_FOREACH(v6_config, &neigh6, next) {
-		if (!(memcmp(v6_config->ip, ip, 16)) && (v6_config->mac == mac))
+		if (rte_ipv6_addr_eq(&v6_config->ip, ip) && v6_config->mac == mac)
 			return v6_config;
 	}
 	return NULL;
@@ -82,7 +82,7 @@ ip6_rewrite_node_add(struct neigh_ipv6_config *v6_config)
 	int16_t portid = 0;
 	int rc;
 
-	portid = ethdev_portid_by_ip6(v6_config->ip, NULL);
+	portid = ethdev_portid_by_ip6(&v6_config->ip, NULL);
 	if (portid < 0) {
 		printf("Invalid portid found to add neigh\n");
 		return -EINVAL;
@@ -170,11 +170,10 @@ neigh_ip4_add(uint32_t ip, uint64_t mac)
 }
 
 static int
-neigh_ip6_add(uint8_t *ip, uint64_t mac)
+neigh_ip6_add(struct rte_ipv6_addr *ip, uint64_t mac)
 {
 	struct neigh_ipv6_config *v6_config;
 	int rc = -EINVAL;
-	int j;
 
 	v6_config = find_neigh6_entry(ip, mac);
 
@@ -184,9 +183,7 @@ neigh_ip6_add(uint8_t *ip, uint64_t mac)
 			return -ENOMEM;
 	}
 
-	for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++)
-		v6_config->ip[j] = ip[j];
-
+	rte_ipv6_addr_cpy(&v6_config->ip, ip);
 	v6_config->mac = mac;
 	v6_config->is_used = true;
 
@@ -261,19 +258,18 @@ cmd_neigh_add_ipv6_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
 			  void *data __rte_unused)
 {
 	struct cmd_neigh_add_ipv6_result *res = parsed_result;
-	uint8_t ip[ETHDEV_IPV6_ADDR_LEN];
-	int rc = -EINVAL, i;
+	struct rte_ipv6_addr ip;
+	int rc = -EINVAL;
 	uint64_t mac;
 
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		ip[i] = res->ip.addr.ipv6.s6_addr[i];
+	rte_memcpy(&ip, &res->ip.addr.ipv6, sizeof(ip));
 
 	if (parser_mac_read(&mac, res->mac)) {
 		printf(MSG_ARG_INVALID, "mac");
 		return;
 	}
 
-	rc = neigh_ip6_add(ip, mac);
+	rc = neigh_ip6_add(&ip, mac);
 	if (rc < 0)
 		printf(MSG_CMD_FAIL, res->neigh);
 }
diff --git a/app/graph/neigh_priv.h b/app/graph/neigh_priv.h
index 1a7106c309bc..b2a7607e01bb 100644
--- a/app/graph/neigh_priv.h
+++ b/app/graph/neigh_priv.h
@@ -5,6 +5,8 @@
 #ifndef APP_GRAPH_NEIGH_PRIV_H
 #define APP_GRAPH_NEIGH_PRIV_H
 
+#include <rte_ip6.h>
+
 #define MAX_NEIGH_ENTRIES 32
 
 struct neigh_ipv4_config {
@@ -18,7 +20,7 @@ TAILQ_HEAD(neigh4_head, neigh_ipv4_config);
 
 struct neigh_ipv6_config {
 	TAILQ_ENTRY(neigh_ipv6_config) next;
-	uint8_t ip[16];
+	struct rte_ipv6_addr ip;
 	uint64_t mac;
 	bool is_used;
 };
diff --git a/app/graph/route.h b/app/graph/route.h
index 23a7951d2dad..455aab8634d4 100644
--- a/app/graph/route.h
+++ b/app/graph/route.h
@@ -5,6 +5,8 @@
 #ifndef APP_GRAPH_ROUTE_H
 #define APP_GRAPH_ROUTE_H
 
+#include <rte_ip6.h>
+
 #define MAX_ROUTE_ENTRIES 32
 
 struct route_ipv4_config {
@@ -19,9 +21,9 @@ TAILQ_HEAD(ip4_route, route_ipv4_config);
 
 struct route_ipv6_config {
 	TAILQ_ENTRY(route_ipv6_config) next;
-	uint8_t ip[16];
-	uint8_t mask[16];
-	uint8_t gateway[16];
+	struct rte_ipv6_addr ip;
+	struct rte_ipv6_addr mask;
+	struct rte_ipv6_addr gateway;
 	bool is_used;
 };
 
diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c
index a13dc011380d..c2067a05f3ef 100644
--- a/examples/l3fwd-graph/main.c
+++ b/examples/l3fwd-graph/main.c
@@ -151,7 +151,7 @@ struct ipv4_l3fwd_lpm_route {
 };
 
 struct ipv6_l3fwd_lpm_route {
-	uint8_t ip[RTE_LPM6_IPV6_ADDR_SIZE];
+	struct rte_ipv6_addr ip;
 	uint8_t depth;
 	uint8_t if_out;
 };
@@ -171,22 +171,14 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = {
 	(sizeof(ipv6_l3fwd_lpm_route_array) /                                  \
 	 sizeof(ipv6_l3fwd_lpm_route_array[0]))
 static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = {
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00}, 48, 0},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x01}, 48, 1},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x02}, 48, 2},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x03}, 48, 3},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x04}, 48, 4},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x05}, 48, 5},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x06}, 48, 6},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x02}, 48, 7},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}, 48, 0},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"}, 48, 1},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"}, 48, 2},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03"}, 48, 3},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04"}, 48, 4},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05"}, 48, 5},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06"}, 48, 6},
+	{{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"}, 48, 7},
 };
 
 static int
@@ -1371,14 +1363,14 @@ main(int argc, char **argv)
 
 		dst_port = ipv6_l3fwd_lpm_route_array[i].if_out;
 
-		memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_LPM6_IPV6_ADDR_SIZE);
+		memcpy(in6.s6_addr, &ipv6_l3fwd_lpm_route_array[i].ip, RTE_IPV6_ADDR_SIZE);
 		snprintf(route_str, sizeof(route_str), "%s / %d (%d)",
 			 inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf)),
 			 ipv6_l3fwd_lpm_route_array[i].depth,
 			 ipv6_l3fwd_lpm_route_array[i].if_out);
 
 		/* Use route index 'i' as next hop id */
-		ret = rte_node_ip6_route_add(ipv6_l3fwd_lpm_route_array[i].ip,
+		ret = rte_node_ip6_route_add(&ipv6_l3fwd_lpm_route_array[i].ip,
 			ipv6_l3fwd_lpm_route_array[i].depth, i,
 			RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
 
diff --git a/lib/node/ip6_lookup.c b/lib/node/ip6_lookup.c
index 1ad6e3fd18f2..0806500d86cf 100644
--- a/lib/node/ip6_lookup.c
+++ b/lib/node/ip6_lookup.c
@@ -112,28 +112,28 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(&ip_batch[0], &ipv6_hdr->dst_addr, 16);
+		rte_ipv6_addr_cpy(&ip_batch[0], &ipv6_hdr->dst_addr);
 
 		/* Extract DIP of mbuf1 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf1, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf1, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(&ip_batch[1], &ipv6_hdr->dst_addr, 16);
+		rte_ipv6_addr_cpy(&ip_batch[1], &ipv6_hdr->dst_addr);
 
 		/* Extract DIP of mbuf2 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf2, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf2, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(&ip_batch[2], &ipv6_hdr->dst_addr, 16);
+		rte_ipv6_addr_cpy(&ip_batch[2], &ipv6_hdr->dst_addr);
 
 		/* Extract DIP of mbuf3 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf3, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf3, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(&ip_batch[3], &ipv6_hdr->dst_addr, 16);
+		rte_ipv6_addr_cpy(&ip_batch[3], &ipv6_hdr->dst_addr);
 
 		rte_lpm6_lookup_bulk_func(lpm6, ip_batch, next_hop, 4);
 
@@ -258,17 +258,15 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 }
 
 int
-rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
+rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop,
 		       enum rte_node_ip6_lookup_next next_node)
 {
 	char abuf[INET6_ADDRSTRLEN];
-	struct in6_addr in6;
 	uint8_t socket;
 	uint32_t val;
 	int ret;
 
-	memcpy(in6.s6_addr, ip, RTE_LPM6_IPV6_ADDR_SIZE);
-	inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf));
+	inet_ntop(AF_INET6, ip, abuf, sizeof(abuf));
 	/* Embedded next node id into 24 bit next hop */
 	val = ((next_node << 16) | next_hop) & ((1ull << 24) - 1);
 	node_dbg("ip6_lookup", "LPM: Adding route %s / %d nh (0x%x)", abuf,
@@ -278,8 +276,7 @@ rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
 		if (!ip6_lookup_nm.lpm_tbl[socket])
 			continue;
 
-		ret = rte_lpm6_add(ip6_lookup_nm.lpm_tbl[socket],
-				   (const struct rte_ipv6_addr *)ip, depth, val);
+		ret = rte_lpm6_add(ip6_lookup_nm.lpm_tbl[socket], ip, depth, val);
 		if (ret < 0) {
 			node_err("ip6_lookup",
 				 "Unable to add entry %s / %d nh (%x) to LPM "
diff --git a/lib/node/rte_node_ip6_api.h b/lib/node/rte_node_ip6_api.h
index a538dc2ea701..dc8c86184afe 100644
--- a/lib/node/rte_node_ip6_api.h
+++ b/lib/node/rte_node_ip6_api.h
@@ -21,6 +21,7 @@ extern "C" {
 
 #include <rte_common.h>
 #include <rte_compat.h>
+#include <rte_ip6.h>
 
 /**
  * IP6 lookup next nodes.
@@ -48,7 +49,7 @@ enum rte_node_ip6_lookup_next {
  *   0 on success, negative otherwise.
  */
 __rte_experimental
-int rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
+int rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop,
 			   enum rte_node_ip6_lookup_next next_node);
 
 /**
-- 
2.46.0


  parent reply	other threads:[~2024-08-21 16:27 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21 16:25 [PATCH dpdk v1 00/15] IPv6 APIs overhaul Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 01/15] net: split raw checksum functions in separate header Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 02/15] net: split ipv6 symbols " Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 03/15] net: add structure for ipv6 addresses Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 04/15] net: use ipv6 structure for header addresses Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 05/15] fib6,rib6,lpm6: use ipv6 addr struct Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 06/15] net: add ipv6 address utilities Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 07/15] fib6,rib6,lpm6: use ipv6 utils Robin Jarry
2024-08-21 16:25 ` Robin Jarry [this message]
2024-08-21 16:25 ` [PATCH dpdk v1 09/15] pipeline: use ipv6 addr struct Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 10/15] ipsec: " Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 11/15] thash: " Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 12/15] gro: " Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 13/15] rte_flow: " Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 14/15] rib6,fib6,lpm6: remove duplicate constants Robin Jarry
2024-08-21 16:25 ` [PATCH dpdk v1 15/15] net: add utilities for well known ipv6 address types Robin Jarry
2024-08-21 22:28 ` [PATCH dpdk v1 00/15] IPv6 APIs overhaul Morten Brørup
2024-08-22 14:13 ` Stephen Hemminger
2024-08-22 15:13   ` Morten Brørup
2024-08-22 15:27     ` Robin Jarry
2024-08-22 18:41       ` Morten Brørup
2024-08-22 15:14   ` Robin Jarry
2024-08-22 15:16   ` Robin Jarry
2024-10-01  8:17 ` [PATCH dpdk v2 00/16] " Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 01/16] net: split raw checksum functions in separate header Robin Jarry
2024-10-03 23:12     ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 02/16] net: split ipv6 symbols " Robin Jarry
2024-10-03 23:15     ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses Robin Jarry
2024-10-03 23:18     ` Stephen Hemminger
2024-10-04 11:59       ` Robin Jarry
2024-10-06  8:18     ` Morten Brørup
2024-10-10 20:08       ` Robin Jarry
2024-10-11 12:37         ` Morten Brørup
2024-10-11 17:02           ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 04/16] net: use ipv6 structure for header addresses Robin Jarry
2024-10-03 23:20     ` Stephen Hemminger
2024-10-04 18:01     ` Ferruh Yigit
2024-10-04 20:04       ` Robin Jarry
2024-10-06 21:03         ` Ferruh Yigit
2024-10-01  8:17   ` [PATCH dpdk v2 05/16] fib6,rib6,lpm6: use ipv6 addr struct Robin Jarry
2024-10-03 23:21     ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 06/16] net: add ipv6 address utilities Robin Jarry
2024-10-01 15:35     ` Stephen Hemminger
2024-10-03 23:22     ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 07/16] fib6,rib6,lpm6: use ipv6 utils Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 08/16] graph,node: use ipv6 addr struct and utils Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 09/16] pipeline: use ipv6 addr struct Robin Jarry
2024-10-03 23:23     ` Stephen Hemminger
2024-10-04 11:55       ` Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 10/16] ipsec: " Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 11/16] thash: " Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 12/16] gro: " Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 13/16] rte_flow: " Robin Jarry
2024-10-01  8:17   ` [PATCH dpdk v2 14/16] rib6,fib6,lpm6: remove duplicate constants Robin Jarry
2024-10-03 23:12     ` Stephen Hemminger
2024-10-04 11:54       ` Robin Jarry
2024-10-04 16:16         ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 15/16] net: add utilities for well known ipv6 address types Robin Jarry
2024-10-03 23:24     ` Stephen Hemminger
2024-10-01  8:17   ` [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version Robin Jarry
2024-10-06  9:02     ` Morten Brørup
2024-10-10 20:00       ` Robin Jarry
2024-10-11 12:05         ` Morten Brørup
2024-10-10 15:26     ` Konstantin Ananyev
2024-10-06  9:04   ` [PATCH dpdk v2 00/16] IPv6 APIs overhaul Morten Brørup
2024-10-10 15:27   ` Konstantin Ananyev
2024-10-10 19:41 ` [PATCH dpdk v3 00/17] " Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 01/17] net: split raw checksum functions in separate header Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 02/17] net: split ipv6 symbols " Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 03/17] net: add structure for ipv6 addresses Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 04/17] net: add ipv6 address utilities Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 05/17] net: use struct rte_ipv6_addr for header addresses Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 06/17] fib6,rib6,lpm6: use struct rte_ipv6_addr Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 07/17] fib6,rib6,lpm6: use ipv6 utils Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 08/17] rib6,fib6,lpm6: remove duplicate constants Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 09/17] cmdline: replace in6_addr with rte_ipv6_addr Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 10/17] graph,node: use struct rte_ipv6_addr and utils Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 11/17] pipeline: use struct rte_ipv6_addr Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 12/17] ipsec, security: use struct rte_ipv6_addr and utils Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 13/17] thash: use struct rte_ipv6_addr Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 14/17] gro: " Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 15/17] rte_flow: " Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 16/17] net: add utilities for well known ipv6 address types Robin Jarry
2024-10-10 19:41   ` [PATCH dpdk v3 17/17] ipv6: add function to check ipv6 version Robin Jarry
2024-10-15 17:12     ` Stephen Hemminger
2024-10-17 13:52   ` [PATCH dpdk v3 00/17] IPv6 APIs overhaul David Marchand
2024-10-17 18:03     ` Robin Jarry
2024-10-18  9:17 ` [PATCH dpdk v4 " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 01/17] net: split raw checksum functions in separate header Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 02/17] net: split IPv4 and IPv6 symbols in separate headers Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 03/17] net: add IPv6 address structure and utils Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 04/17] net: use IPv6 structure for packet headers Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 05/17] lpm6: use IPv6 address structure and utils Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 06/17] fib6: " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 07/17] rib6: " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 08/17] cmdline: use IPv6 address structure Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 09/17] node: use IPv6 address structure and utils Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 10/17] pipeline: use IPv6 structures Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 11/17] ipsec: use IPv6 address structure Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 12/17] security: " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 13/17] hash: " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 14/17] gro: " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 15/17] flow: " Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 16/17] net: add utilities for well known IPv6 address types Robin Jarry
2024-10-18  9:17   ` [PATCH dpdk v4 17/17] net: add function to check IPv6 version Robin Jarry
2024-10-18 14:05 ` [PATCH dpdk v5 00/17] IPv6 APIs overhaul Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 01/17] net: split raw checksum functions in separate header Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 02/17] net: split IPv4 and IPv6 symbols in separate headers Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 03/17] net: add IPv6 address structure and utils Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 04/17] net: use IPv6 structure for packet headers Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 05/17] lpm6: use IPv6 address structure and utils Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 06/17] fib6: " Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 07/17] rib6: " Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 08/17] cmdline: use IPv6 address structure Robin Jarry
2024-10-18 14:24     ` Bruce Richardson
2024-10-18 14:05   ` [PATCH dpdk v5 09/17] node: use IPv6 address structure and utils Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 10/17] pipeline: use IPv6 structures Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 11/17] ipsec: use IPv6 address structure Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 12/17] security: " Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 13/17] hash: " Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 14/17] gro: " Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 15/17] flow: " Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 16/17] net: add utilities for well known IPv6 address types Robin Jarry
2024-10-18 14:05   ` [PATCH dpdk v5 17/17] net: add function to check IPv6 version Robin Jarry
2024-10-18 16:06   ` [PATCH dpdk v5 00/17] IPv6 APIs overhaul David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240821162516.610624-25-rjarry@redhat.com \
    --to=rjarry@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=pbhagavatula@marvell.com \
    --cc=rkudurumalla@marvell.com \
    --cc=skori@marvell.com \
    --cc=yanzhirun_163@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).