Skip to contentSkip to conversation

IPv6 APIs overhaul

PATCH Superseded Robin Jarry 7 participants 127 messages Aug 21, 2024 – Jul 24 Page 1 of 3

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover IPv6 APIs overhaul

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Thanks!

Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Bruce Richardson <[email protected]>

Robin Jarry (15):
net: split raw checksum functions in separate header
net: split ipv6 symbols in separate header
net: add structure for ipv6 addresses
net: use ipv6 structure for header addresses fib6,rib6,lpm6: use ipv6 addr struct
net: add ipv6 address utilities fib6,rib6,lpm6: use ipv6 utils
graph,node: use ipv6 addr struct and utils
pipeline: use ipv6 addr struct
ipsec: use ipv6 addr struct
thash: use ipv6 addr struct
gro: use ipv6 addr struct
rte_flow: use ipv6 addr struct rib6,fib6,lpm6: remove duplicate constants
net: add utilities for well known ipv6 address types

 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 +-
 app/test-fib/main.c                         |   51 +-
 app/test-flow-perf/actions_gen.c            |    4 +-
 app/test-flow-perf/items_gen.c              |    4 +-
 app/test-pipeline/pipeline_hash.c           |    4 +-
 app/test-pipeline/pipeline_lpm_ipv6.c       |   10 +-
 app/test-sad/main.c                         |   24 +-
 app/test/meson.build                        |    1 +
 app/test/packet_burst_generator.c           |    5 +-
 app/test/test_cryptodev_security_ipsec.c    |    1 +
 app/test/test_fib6.c                        |   93 +-
 app/test/test_fib6_perf.c                   |    8 +-
 app/test/test_ipfrag.c                      |    4 +-
 app/test/test_ipsec_sad.c                   |   44 +-
 app/test/test_lpm6.c                        |  523 ++---
 app/test/test_lpm6_data.h                   | 2025 ++++++++++---------
 app/test/test_lpm6_perf.c                   |   10 +-
 app/test/test_net_ipv6.c                    |  203 ++
 app/test/test_reassembly_perf.c             |   20 +-
 app/test/test_rib6.c                        |   65 +-
 app/test/test_table_combined.c              |    2 +-
 app/test/test_table_tables.c                |    8 +-
 app/test/test_thash.c                       |   46 +-
 drivers/common/cnxk/cnxk_security.c         |    1 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |    1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |    1 +
 drivers/net/bnxt/bnxt_flow.c                |   12 +-
 drivers/net/bonding/rte_eth_bond_pmd.c      |    4 +-
 drivers/net/cxgbe/cxgbe_flow.c              |   18 +-
 drivers/net/dpaa2/dpaa2_flow.c              |   22 +-
 drivers/net/hinic/hinic_pmd_flow.c          |    6 +-
 drivers/net/hinic/hinic_pmd_tx.c            |    2 +-
 drivers/net/hns3/hns3_flow.c                |    8 +-
 drivers/net/i40e/i40e_flow.c                |   12 +-
 drivers/net/iavf/iavf_fdir.c                |    8 +-
 drivers/net/iavf/iavf_fsub.c                |    8 +-
 drivers/net/iavf/iavf_ipsec_crypto.c        |    6 +-
 drivers/net/ice/ice_fdir_filter.c           |   12 +-
 drivers/net/ice/ice_switch_filter.c         |   16 +-
 drivers/net/igc/igc_flow.c                  |    4 +-
 drivers/net/ixgbe/ixgbe_flow.c              |   12 +-
 drivers/net/ixgbe/ixgbe_ipsec.c             |    4 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c       |   36 +-
 drivers/net/mlx5/mlx5_flow.c                |    6 +-
 drivers/net/mlx5/mlx5_flow_dv.c             |   16 +-
 drivers/net/mlx5/mlx5_flow_hw.c             |   10 +-
 drivers/net/mlx5/mlx5_flow_verbs.c          |    8 +-
 drivers/net/nfp/flower/nfp_flower_flow.c    |   36 +-
 drivers/net/nfp/nfp_net_flow.c              |   44 +-
 drivers/net/qede/qede_filter.c              |    4 +-
 drivers/net/sfc/sfc_flow.c                  |   28 +-
 drivers/net/tap/tap_flow.c                  |    8 +-
 drivers/net/txgbe/txgbe_flow.c              |   12 +-
 drivers/net/txgbe/txgbe_ipsec.c             |    4 +-
 examples/ip_fragmentation/main.c            |   24 +-
 examples/ip_pipeline/cli.c                  |   12 +-
 examples/ip_pipeline/pipeline.c             |   17 +-
 examples/ip_pipeline/thread.c               |    2 +-
 examples/ip_reassembly/main.c               |   24 +-
 examples/ipsec-secgw/flow.c                 |   12 +-
 examples/ipsec-secgw/ipsec.c                |    8 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h       |    7 +-
 examples/ipsec-secgw/ipsec_worker.c         |    6 +-
 examples/ipsec-secgw/ipsec_worker.h         |    4 +-
 examples/ipsec-secgw/rt.c                   |   22 +-
 examples/ipsec-secgw/sa.c                   |    4 +-
 examples/ipsec-secgw/sad.h                  |   12 +-
 examples/l3fwd-graph/main.c                 |   30 +-
 examples/l3fwd/l3fwd_fib.c                  |   39 +-
 examples/l3fwd/l3fwd_lpm.c                  |    8 +-
 examples/l3fwd/l3fwd_route.h                |    7 +-
 examples/l3fwd/lpm_route_parse.c            |    6 +-
 lib/ethdev/rte_flow.h                       |   23 +-
 lib/fib/meson.build                         |    4 +-
 lib/fib/rte_fib6.c                          |   19 +-
 lib/fib/rte_fib6.h                          |   15 +-
 lib/fib/trie.c                              |  117 +-
 lib/fib/trie.h                              |   18 +-
 lib/fib/trie_avx512.c                       |   38 +-
 lib/fib/trie_avx512.h                       |   10 +-
 lib/gro/gro_tcp6.c                          |    8 +-
 lib/gro/gro_tcp6.h                          |    6 +-
 lib/hash/rte_thash.h                        |   29 +-
 lib/ip_frag/rte_ip_frag.h                   |    1 +
 lib/ip_frag/rte_ipv6_reassembly.c           |    4 +-
 lib/ipsec/iph.h                             |    1 +
 lib/ipsec/rte_ipsec_sad.h                   |    7 +-
 lib/lpm/meson.build                         |    1 +
 lib/lpm/rte_lpm6.c                          |  147 +-
 lib/lpm/rte_lpm6.h                          |   17 +-
 lib/net/meson.build                         |    2 +
 lib/net/rte_cksum.h                         |  189 ++
 lib/net/rte_ip.h                            |  467 +----
 lib/net/rte_ip6.h                           |  580 ++++++
 lib/net/rte_net.c                           |    1 +
 lib/net/rte_net.h                           |    1 +
 lib/node/ip6_lookup.c                       |   21 +-
 lib/node/rte_node_ip6_api.h                 |    3 +-
 lib/pipeline/rte_swx_ipsec.c                |    7 +-
 lib/pipeline/rte_table_action.c             |   45 +-
 lib/pipeline/rte_table_action.h             |    7 +-
 lib/rib/meson.build                         |    2 +-
 lib/rib/rte_rib6.c                          |  112 +-
 lib/rib/rte_rib6.h                          |   27 +-
 lib/table/rte_table_lpm_ipv6.c              |   12 +-
 lib/table/rte_table_lpm_ipv6.h              |    4 +-
 lib/vhost/virtio_net.c                      |    1 +
 113 files changed, 3147 insertions(+), 2699 deletions(-)
 create mode 100644 app/test/test_net_ipv6.c
 create mode 100644 lib/net/rte_cksum.h
 create mode 100644 lib/net/rte_ip6.h
Signature · 1 line
2.46.0
#1 lore raw

PATCH 1/15 net: split raw checksum functions in separate header

The checksum functions are used by both ipv4 and ipv6 functions. In preparation of moving ipv6 symbols to a new header, move the checksum related symbols to another dedicated header.

---
 lib/net/meson.build |   1 +
 lib/net/rte_cksum.h | 189 ++++++++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip.h    | 148 +---------------------------------
 3 files changed, 191 insertions(+), 147 deletions(-)
 create mode 100644 lib/net/rte_cksum.h
lib/net/meson.build +1 -0
index 0b691389495a..2e65bd19b7d4 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
         'rte_tls.h',
lib/net/rte_cksum.h new file +189 -0

189 lines not on this page · raw message

lib/net/rte_ip.h +1 -147

160 lines not on this page · raw message

Signature · 1 line
2.46.0
#2 lore raw

PATCH 2/15 net: split ipv6 symbols in separate header

In reply to Robin Jarry

Move all ipv6 related symbols to a dedicated header. Update all code accordingly.

---
 app/test/packet_burst_generator.c           |   1 +
 app/test/test_cryptodev_security_ipsec.c    |   1 +
 drivers/common/cnxk/cnxk_security.c         |   1 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |   1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |   1 +
 examples/ip_pipeline/pipeline.c             |   1 +
 lib/ethdev/rte_flow.h                       |   1 +
 lib/hash/rte_thash.h                        |   1 +
 lib/ip_frag/rte_ip_frag.h                   |   1 +
 lib/ipsec/iph.h                             |   1 +
 lib/net/meson.build                         |   1 +
 lib/net/rte_ip.h                            | 319 ------------------
 lib/net/{rte_ip.h => rte_ip6.h}             | 352 +-------------------
 lib/net/rte_net.c                           |   1 +
 lib/net/rte_net.h                           |   1 +
 lib/pipeline/rte_swx_ipsec.c                |   1 +
 lib/pipeline/rte_table_action.c             |   1 +
 lib/vhost/virtio_net.c                      |   1 +
 18 files changed, 22 insertions(+), 665 deletions(-)
 copy lib/net/{rte_ip.h => rte_ip6.h} (50%)
app/test/packet_burst_generator.c +1 -0
index 867a88da0055..2cd34abc1a65 100644
@@ -5,6 +5,7 @@
 #include <rte_byteorder.h>
 #include <rte_mbuf.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_os_shim.h>
 
 #include "packet_burst_generator.h"
app/test/test_cryptodev_security_ipsec.c +1 -0
index 1aba1ad9934b..9ac4a6e599b0 100644
@@ -6,6 +6,7 @@
 #include <rte_cryptodev.h>
 #include <rte_esp.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_security.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
drivers/common/cnxk/cnxk_security.c +1 -0
index 15b0bedf43e2..e275d6cad3ea 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <rte_ip6.h>
 #include <rte_udp.h>
 
 #include "cnxk_security.h"
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -0
index f443cb9563ec..a3c737ef40f7 100644
@@ -6,6 +6,7 @@
 #include <cryptodev_pmd.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_vect.h>
 
 #include "roc_cpt.h"
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +1 -0
index c1f7181d5587..5bf690e3d82a 100644
@@ -10,6 +10,7 @@
 #include <unistd.h>
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_udp.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
examples/ip_pipeline/pipeline.c +1 -0
index 63352257c6e9..301c52d061be 100644
@@ -7,6 +7,7 @@
 
 #include <rte_common.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 
 #include <rte_string_fns.h>
lib/ethdev/rte_flow.h +1 -0
index f864578f806b..3a3ab781c494 100644
@@ -23,6 +23,7 @@
 #include <rte_arp.h>
 #include <rte_icmp.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_sctp.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
lib/hash/rte_thash.h +1 -0
index 30b657e67a7d..af40afd2d475 100644
@@ -23,6 +23,7 @@ extern "C" {
 
 #include <rte_byteorder.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_common.h>
 #include <rte_thash_gfni.h>
 
lib/ip_frag/rte_ip_frag.h +1 -0
index 2ad318096b7b..cb06d5f5977a 100644
@@ -23,6 +23,7 @@ extern "C" {
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_byteorder.h>
 
 struct rte_mbuf;
lib/ipsec/iph.h +1 -0
index 861f16905ad0..815a3c90d76b 100644
@@ -6,6 +6,7 @@
 #define _IPH_H_
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 
 /**
  * @file iph.h
lib/net/meson.build +1 -0
index 2e65bd19b7d4..35ac334a18cf 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_ip6.h',
         'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
lib/net/rte_ip.h +0 -319

325 lines not on this page · raw message

lib/net/rte_ip6.h renamed from lib/net/rte_ip.h +6 -346

385 lines not on this page · raw message

lib/net/rte_net.c +1 -0
index d680accc1631..13aef6147ab0 100644
@@ -9,6 +9,7 @@
 #include <rte_byteorder.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_sctp.h>
lib/net/rte_net.h +1 -0
index cdc6cf956df2..a47beb60adf0 100644
@@ -10,6 +10,7 @@ extern "C" {
 #endif
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_udp.h>
 #include <rte_tcp.h>
 
lib/pipeline/rte_swx_ipsec.c +1 -0
index 73e8211b2818..56a401d0fa63 100644
@@ -11,6 +11,7 @@
 #include <rte_common.h>
 #include <rte_random.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tailq.h>
 #include <rte_eal_memconfig.h>
 #include <rte_ring.h>
lib/pipeline/rte_table_action.c +1 -0
index 87c3e0e2c935..ebbdd3f4cebe 100644
@@ -11,6 +11,7 @@
 #include <rte_memcpy.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_vxlan.h>
lib/vhost/virtio_net.c +1 -0
index 370402d84903..d4dcc811c55f 100644
@@ -11,6 +11,7 @@
 #include <rte_net.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_dmadev.h>
 #include <rte_vhost.h>
 #include <rte_tcp.h>
Signature · 1 line
2.46.0
#3 lore raw

PATCH 3/15 net: add structure for ipv6 addresses

In reply to Robin Jarry

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements without any union. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

---
 lib/net/rte_ip6.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/net/rte_ip6.h +10 -0
index 9ed737d5eb81..f948f95db7ca 100644
@@ -35,6 +35,16 @@
 extern "C" {
 #endif
 
+#define RTE_IPV6_ADDR_SIZE 16
+#define RTE_IPV6_MAX_DEPTH 128
+
+/**
+ * IPv6 Address
+ */
+struct rte_ipv6_addr {
+	unsigned char a[RTE_IPV6_ADDR_SIZE];
+};
+
 /**
  * IPv6 Header
  */
Signature · 1 line
2.46.0
#4 lore raw

PATCH 4/15 net: use ipv6 structure for header addresses

In reply to Robin Jarry

The rte_ipv6_hdr uses ad-hoc uint8_t[16] arrays to represent addresses. Replace these arrays with the previously introduced rte_ipv6_addr structure. Adapt all code accordingly.

---
 app/test-flow-perf/items_gen.c           |  4 +--
 app/test-pipeline/pipeline_hash.c        |  4 +--
 app/test/packet_burst_generator.c        |  4 +--
 app/test/test_ipfrag.c                   |  4 +--
 app/test/test_reassembly_perf.c          | 20 +++++------
 app/test/test_thash.c                    |  8 ++---
 drivers/net/bnxt/bnxt_flow.c             | 12 +++----
 drivers/net/bonding/rte_eth_bond_pmd.c   |  4 +--
 drivers/net/cxgbe/cxgbe_flow.c           | 14 ++++----
 drivers/net/dpaa2/dpaa2_flow.c           | 22 ++++++------
 drivers/net/hinic/hinic_pmd_flow.c       |  6 ++--
 drivers/net/hinic/hinic_pmd_tx.c         |  2 +-
 drivers/net/hns3/hns3_flow.c             |  8 ++---
 drivers/net/i40e/i40e_flow.c             | 12 +++----
 drivers/net/iavf/iavf_fdir.c             |  8 ++---
 drivers/net/iavf/iavf_fsub.c             |  8 ++---
 drivers/net/iavf/iavf_ipsec_crypto.c     |  6 ++--
 drivers/net/ice/ice_fdir_filter.c        | 12 +++----
 drivers/net/ice/ice_switch_filter.c      | 16 ++++-----
 drivers/net/igc/igc_flow.c               |  4 +--
 drivers/net/ixgbe/ixgbe_flow.c           | 12 +++----
 drivers/net/ixgbe/ixgbe_ipsec.c          |  4 +--
 drivers/net/mlx5/hws/mlx5dr_definer.c    | 36 +++++++++----------
 drivers/net/mlx5/mlx5_flow.c             |  6 ++--
 drivers/net/mlx5/mlx5_flow_dv.c          | 16 +++++----
 drivers/net/mlx5/mlx5_flow_hw.c          | 10 +++---
 drivers/net/mlx5/mlx5_flow_verbs.c       |  8 ++---
 drivers/net/nfp/flower/nfp_flower_flow.c | 34 ++++++++++--------
 drivers/net/nfp/nfp_net_flow.c           | 44 +++++++++++++-----------
 drivers/net/qede/qede_filter.c           |  4 +--
 drivers/net/sfc/sfc_flow.c               | 28 +++++++--------
 drivers/net/tap/tap_flow.c               |  8 ++---
 drivers/net/txgbe/txgbe_flow.c           | 12 +++----
 drivers/net/txgbe/txgbe_ipsec.c          |  4 +--
 examples/ip_fragmentation/main.c         |  2 +-
 examples/ip_pipeline/pipeline.c          | 16 ++++-----
 examples/ip_reassembly/main.c            |  2 +-
 examples/ipsec-secgw/flow.c              | 12 +++----
 examples/ipsec-secgw/ipsec.c             |  8 ++---
 examples/ipsec-secgw/sa.c                |  4 +--
 examples/ipsec-secgw/sad.h               | 10 +++---
 examples/l3fwd/l3fwd_fib.c               |  2 +-
 examples/l3fwd/l3fwd_lpm.c               |  4 +--
 lib/ethdev/rte_flow.h                    |  6 ++--
 lib/hash/rte_thash.h                     | 12 +++----
 lib/ip_frag/rte_ipv6_reassembly.c        |  4 +--
 lib/net/rte_ip6.h                        |  6 ++--
 lib/node/ip6_lookup.c                    | 10 +++---
 lib/pipeline/rte_swx_ipsec.c             |  6 ++--
 lib/pipeline/rte_table_action.c          | 24 ++++++-------
 50 files changed, 276 insertions(+), 256 deletions(-)
app/test-flow-perf/items_gen.c +2 -2
index 4ae72509d445..c740e1838ffb 100644
@@ -78,8 +78,8 @@ add_ipv6(struct rte_flow_item *items,
 	for (i = 0; i < 16; i++) {
 		/* Currently src_ip is limited to 32 bit */
 		if (i < 4)
-			ipv6_specs[ti].hdr.src_addr[15 - i] = para.src_ip >> (i * 8);
-		ipv6_masks[ti].hdr.src_addr[15 - i] = 0xff;
+			ipv6_specs[ti].hdr.src_addr.a[15 - i] = para.src_ip >> (i * 8);
+		ipv6_masks[ti].hdr.src_addr.a[15 - i] = 0xff;
 	}
 
 	items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV6;
app/test-pipeline/pipeline_hash.c +1 -3
index cab9c2098014..194e5c5dcc53 100644
@@ -432,7 +432,6 @@ app_main_loop_rx_metadata(void) {
 				struct rte_ipv4_hdr *ip_hdr;
 				struct rte_ipv6_hdr *ipv6_hdr;
 				uint32_t ip_dst;
-				uint8_t *ipv6_dst;
 				uint32_t *signature, *k32;
 
 				m = app.mbuf_rx.array[j];
@@ -452,9 +451,8 @@ app_main_loop_rx_metadata(void) {
 				} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
 					ipv6_hdr = (struct rte_ipv6_hdr *)
 						&m_data[sizeof(struct rte_ether_hdr)];
-					ipv6_dst = ipv6_hdr->dst_addr;
 
-					memcpy(key, ipv6_dst, 16);
+					memcpy(key, &ipv6_hdr->dst_addr, 16);
 				} else
 					continue;
 
app/test/packet_burst_generator.c +2 -2
index 2cd34abc1a65..76a409a56452 100644
@@ -149,8 +149,8 @@ initialize_ipv6_header(struct rte_ipv6_hdr *ip_hdr, uint8_t *src_addr,
 	ip_hdr->proto = IPPROTO_UDP;
 	ip_hdr->hop_limits = IP_DEFTTL;
 
-	rte_memcpy(ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
-	rte_memcpy(ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
+	rte_memcpy(&ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
+	rte_memcpy(&ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
 
 	return (uint16_t) (pkt_data_len + sizeof(struct rte_ipv6_hdr));
 }
app/test/test_ipfrag.c +2 -2
index 8e4df220a214..4053bd9f0f79 100644
@@ -238,8 +238,8 @@ v6_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, uint8_t ttl,
 	hdr->proto = proto;
 	hdr->hop_limits = ttl;
 
-	memset(hdr->src_addr, 0x08, sizeof(hdr->src_addr));
-	memset(hdr->dst_addr, 0x04, sizeof(hdr->src_addr));
+	memset(hdr->src_addr.a, 0x08, sizeof(hdr->src_addr));
+	memset(hdr->dst_addr.a, 0x04, sizeof(hdr->src_addr));
 }
 
 static inline void
app/test/test_reassembly_perf.c +10 -10
index 3912179022fc..70112c1f62da 100644
@@ -340,17 +340,17 @@ ipv6_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id,
 			rte_cpu_to_be_16(pkt_len - sizeof(struct rte_ipv6_hdr));
 		ip_hdr->proto = IPPROTO_FRAGMENT;
 		ip_hdr->hop_limits = IP_DEFTTL;
-		memcpy(ip_hdr->src_addr, ip6_addr, sizeof(ip_hdr->src_addr));
-		memcpy(ip_hdr->dst_addr, ip6_addr, sizeof(ip_hdr->dst_addr));
-		ip_hdr->src_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->src_addr[7] |= 0x10;
-		ip_hdr->src_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->src_addr[9] = flow_id & 0xff;
+		memcpy(&ip_hdr->src_addr, ip6_addr, sizeof(ip_hdr->src_addr));
+		memcpy(&ip_hdr->dst_addr, ip6_addr, sizeof(ip_hdr->dst_addr));
+		ip_hdr->src_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->src_addr.a[7] |= 0x10;
+		ip_hdr->src_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->src_addr.a[9] = flow_id & 0xff;
 
-		ip_hdr->dst_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->dst_addr[7] |= 0x20;
-		ip_hdr->dst_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->dst_addr[9] = flow_id & 0xff;
+		ip_hdr->dst_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->dst_addr.a[7] |= 0x20;
+		ip_hdr->dst_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->dst_addr.a[9] = flow_id & 0xff;
 
 		frag_hdr->next_header = IPPROTO_UDP;
 		frag_hdr->reserved = 0;
app/test/test_thash.c +4 -4
index 65d42fd90085..952da6a52954 100644
@@ -145,10 +145,10 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr); j++)
-			ipv6_hdr.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr); j++)
-			ipv6_hdr.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
+			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
+			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
drivers/net/bnxt/bnxt_flow.c +6 -6
index f25bc6ff78c7..bdc47ee78755 100644
@@ -424,22 +424,22 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 					EM_FLOW_ALLOC_INPUT_EN_DST_IPADDR;
 
 			rte_memcpy(filter->src_ipaddr,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(filter->dst_ipaddr,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr.a,
 						   16)) {
 				rte_memcpy(filter->src_ipaddr_mask,
-					   ipv6_mask->hdr.src_addr, 16);
+					   &ipv6_mask->hdr.src_addr, 16);
 				en |= !use_ntuple ? 0 :
 				    NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_IPADDR_MASK;
 			}
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr.a,
 						   16)) {
 				rte_memcpy(filter->dst_ipaddr_mask,
-					   ipv6_mask->hdr.dst_addr, 16);
+					   &ipv6_mask->hdr.dst_addr, 16);
 				en |= !use_ntuple ? 0 :
 				     NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK;
 			}
drivers/net/bonding/rte_eth_bond_pmd.c +2 -2
index c40d18d128b6..b89732f4a28a 100644
@@ -690,9 +690,9 @@ static inline uint32_t
 ipv6_hash(struct rte_ipv6_hdr *ipv6_hdr)
 {
 	unaligned_uint32_t *word_src_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->src_addr[0]);
+		(unaligned_uint32_t *)&ipv6_hdr->src_addr;
 	unaligned_uint32_t *word_dst_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->dst_addr[0]);
+		(unaligned_uint32_t *)&ipv6_hdr->dst_addr;
 
 	return (word_src_addr[0] ^ word_dst_addr[0]) ^
 			(word_src_addr[1] ^ word_dst_addr[1]) ^
drivers/net/cxgbe/cxgbe_flow.c +8 -6
index f5787c247f1f..37c566b131e9 100644
@@ -411,15 +411,15 @@ ch_rte_parsetype_ipv6(const void *dmask, const struct rte_flow_item *item,
 			      RTE_IPV6_HDR_TC_SHIFT,
 			      tos);
 
-	if (memcmp(val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
+	if (memcmp(&val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
+	     memcmp(&umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr,
 				     lip);
 
-	if (memcmp(val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
+	if (memcmp(&val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
+	     memcmp(&umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr,
 				     fip);
 
@@ -918,12 +918,14 @@ static struct chrte_fparse parseitem[] = {
 		.fptr  = ch_rte_parsetype_ipv6,
 		.dmask = &(const struct rte_flow_item_ipv6) {
 			.hdr = {
-				.src_addr =
+				.src_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr =
+				},
+				.dst_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				},
 				.vtc_flow = RTE_BE32(0xff000000),
 			},
 		},
drivers/net/dpaa2/dpaa2_flow.c +12 -10
index 6c7bac4d483a..5f762d319477 100644
@@ -117,12 +117,14 @@ static const struct rte_flow_item_ipv4 dpaa2_flow_item_ipv4_mask = {
 
 static const struct rte_flow_item_ipv6 dpaa2_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr =
+		.src_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 		.proto = 0xff
 	},
 };
@@ -1480,16 +1482,16 @@ dpaa2_configure_flow_generic_ip(
 		mask_ipv4->hdr.dst_addr)) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV4_ADDR;
 	} else if (mask_ipv6 &&
-		(memcmp((const char *)mask_ipv6->hdr.src_addr,
+		(memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE) ||
-		memcmp((const char *)mask_ipv6->hdr.dst_addr,
+		memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV6_ADDR;
 	}
 
 	if ((mask_ipv4 && mask_ipv4->hdr.src_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.src_addr,
+			memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1528,13 +1530,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.src_addr;
 		else
-			key = &spec_ipv6->hdr.src_addr[0];
+			key = &spec_ipv6->hdr.src_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.src_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.src_addr[0];
+			mask = &mask_ipv6->hdr.src_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
@@ -1571,7 +1573,7 @@ dpaa2_configure_flow_generic_ip(
 
 	if ((mask_ipv4 && mask_ipv4->hdr.dst_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.dst_addr,
+			memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1618,13 +1620,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.dst_addr;
 		else
-			key = spec_ipv6->hdr.dst_addr;
+			key = &spec_ipv6->hdr.dst_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.dst_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.dst_addr[0];
+			mask = &mask_ipv6->hdr.dst_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
drivers/net/hinic/hinic_pmd_flow.c +3 -3
index d1a564a16303..8fdd5a35be9f 100644
@@ -962,7 +962,7 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 
 		/* check ipv6 src addr mask, ipv6 src addr is 16 bytes */
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.src_addr[i] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[i] == UINT8_MAX) {
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM, item,
 					"Not supported by fdir filter, do not support src ipv6");
@@ -978,13 +978,13 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 		}
 
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.dst_addr[i] == UINT8_MAX)
+			if (ipv6_mask->hdr.dst_addr.a[i] == UINT8_MAX)
 				rule->mask.dst_ipv6_mask |= 1 << i;
 		}
 
 		ipv6_spec = (const struct rte_flow_item_ipv6 *)item->spec;
 		rte_memcpy(rule->hinic_fdir.dst_ipv6,
-			   ipv6_spec->hdr.dst_addr, 16);
+			   &ipv6_spec->hdr.dst_addr, 16);
 
 		/*
 		 * Check if the next not void item is TCP or UDP or ICMP.
drivers/net/hinic/hinic_pmd_tx.c +1 -1
index f09b1a6e1ea6..22fb0bffafcc 100644
@@ -743,7 +743,7 @@ hinic_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr), 0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
 	return __rte_raw_cksum_reduce(sum);
drivers/net/hns3/hns3_flow.c +4 -4
index 37eb2b4c3807..bf1eee506dde 100644
@@ -822,10 +822,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 						  "Only support src & dst ip,proto in IPV6");
 		}
 		net_addr_to_host(rule->key_conf.mask.src_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.src_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.src_addr,
 				 IP_ADDR_LEN);
 		net_addr_to_host(rule->key_conf.mask.dst_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.dst_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.dst_addr,
 				 IP_ADDR_LEN);
 		rule->key_conf.mask.ip_proto = ipv6_mask->hdr.proto;
 		if (rule->key_conf.mask.src_ip[IP_ADDR_KEY_ID])
@@ -838,10 +838,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 
 	ipv6_spec = item->spec;
 	net_addr_to_host(rule->key_conf.spec.src_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.src_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.src_addr,
 			 IP_ADDR_LEN);
 	net_addr_to_host(rule->key_conf.spec.dst_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.dst_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.dst_addr,
 			 IP_ADDR_LEN);
 	rule->key_conf.spec.ip_proto = ipv6_spec->hdr.proto;
 
drivers/net/i40e/i40e_flow.c +6 -6
index 92165c8422d5..c6857727e8be 100644
@@ -1953,13 +1953,13 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 
-				if (!memcmp(ipv6_mask->hdr.src_addr,
+				if (!memcmp(&ipv6_mask->hdr.src_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.src_addr)))
+					    sizeof(ipv6_mask->hdr.src_addr)))
 					input_set |= I40E_INSET_IPV6_SRC;
-				if (!memcmp(ipv6_mask->hdr.dst_addr,
+				if (!memcmp(&ipv6_mask->hdr.dst_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+					    sizeof(ipv6_mask->hdr.dst_addr)))
 					input_set |= I40E_INSET_IPV6_DST;
 
 				if ((ipv6_mask->hdr.vtc_flow &
@@ -1987,9 +1987,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					I40E_FDIR_IPTYPE_IPV6;
 
 				rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
-					   ipv6_spec->hdr.src_addr, 16);
+					   &ipv6_spec->hdr.src_addr, 16);
 				rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
-					   ipv6_spec->hdr.dst_addr, 16);
+					   &ipv6_spec->hdr.dst_addr, 16);
 
 				/* Check if it is fragment. */
 				if (ipv6_spec->hdr.proto ==
drivers/net/iavf/iavf_fdir.c +4 -4
index 811a10287b70..321346425465 100644
@@ -1048,14 +1048,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 								 HOP_LIMIT);
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr))) {
 				input_set |= IAVF_INSET_IPV6_SRC;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 SRC);
 			}
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr))) {
 				input_set |= IAVF_INSET_IPV6_DST;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 DST);
drivers/net/iavf/iavf_fsub.c +4 -4
index 74e1e7099b8c..eb5a3feab189 100644
@@ -354,23 +354,23 @@ iavf_fsub_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_DST;
 						break;
 					}
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j])
+					if (ipv6_mask->hdr.src_addr.a[j])
 						input_set_byte++;
 
-					if (ipv6_mask->hdr.dst_addr[j])
+					if (ipv6_mask->hdr.dst_addr.a[j])
 						input_set_byte++;
 				}
 
drivers/net/iavf/iavf_ipsec_crypto.c +3 -3
index 6fd45ff45f3d..17bea5880aa3 100644
@@ -1738,8 +1738,8 @@ static void
 parse_ipv6_item(const struct rte_flow_item_ipv6 *item,
 		struct rte_ipv6_hdr *ipv6)
 {
-	memcpy(ipv6->src_addr, item->hdr.src_addr, 16);
-	memcpy(ipv6->dst_addr, item->hdr.dst_addr, 16);
+	memcpy(&ipv6->src_addr, &item->hdr.src_addr, 16);
+	memcpy(&ipv6->dst_addr, &item->hdr.dst_addr, 16);
 }
 
 static void
@@ -1904,7 +1904,7 @@ iavf_ipsec_flow_create(struct iavf_adapter *ad,
 			ipsec_flow->spi,
 			0,
 			0,
-			ipsec_flow->ipv6_hdr.dst_addr,
+			ipsec_flow->ipv6_hdr.dst_addr.a,
 			0,
 			ipsec_flow->is_udp,
 			ipsec_flow->udp_hdr.dst_port);
drivers/net/ice/ice_fdir_filter.c +6 -6
index edd8cc8f1ab4..8c85779b5401 100644
@@ -2097,11 +2097,11 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr)))
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr)))
 				*input_set |= ICE_INSET_IPV6_SRC;
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr)))
 				*input_set |= ICE_INSET_IPV6_DST;
 
 			if ((ipv6_mask->hdr.vtc_flow &
@@ -2113,8 +2113,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
 				*input_set |= ICE_INSET_IPV6_HOP_LIMIT;
 
-			rte_memcpy(&p_v6->dst_ip, ipv6_spec->hdr.dst_addr, 16);
-			rte_memcpy(&p_v6->src_ip, ipv6_spec->hdr.src_addr, 16);
+			rte_memcpy(&p_v6->dst_ip, &ipv6_spec->hdr.dst_addr, 16);
+			rte_memcpy(&p_v6->src_ip, &ipv6_spec->hdr.src_addr, 16);
 			vtc_flow_cpu = rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
 			p_v6->tc = (uint8_t)(vtc_flow_cpu >> ICE_FDIR_IPV6_TC_OFFSET);
 			p_v6->proto = ipv6_spec->hdr.proto;
drivers/net/ice/ice_switch_filter.c +8 -8
index 122b87f625a7..28bc775a2c34 100644
@@ -665,13 +665,13 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_DST;
 						break;
 					}
@@ -691,18 +691,18 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				f = &list[t].h_u.ipv6_hdr;
 				s = &list[t].m_u.ipv6_hdr;
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						f->src_addr[j] =
-						ipv6_spec->hdr.src_addr[j];
+						ipv6_spec->hdr.src_addr.a[j];
 						s->src_addr[j] =
-						ipv6_mask->hdr.src_addr[j];
+						ipv6_mask->hdr.src_addr.a[j];
 						input_set_byte++;
 					}
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						f->dst_addr[j] =
-						ipv6_spec->hdr.dst_addr[j];
+						ipv6_spec->hdr.dst_addr.a[j];
 						s->dst_addr[j] =
-						ipv6_mask->hdr.dst_addr[j];
+						ipv6_mask->hdr.dst_addr.a[j];
 						input_set_byte++;
 					}
 				}
drivers/net/igc/igc_flow.c +2 -2
index b677a0d61340..b778ac26135a 100644
@@ -435,8 +435,8 @@ igc_parse_pattern_ipv6(const struct rte_flow_item *item,
 	if (mask->hdr.vtc_flow ||
 		mask->hdr.payload_len ||
 		mask->hdr.hop_limits ||
-		!igc_is_zero_ipv6_addr(mask->hdr.src_addr) ||
-		!igc_is_zero_ipv6_addr(mask->hdr.dst_addr))
+		!igc_is_zero_ipv6_addr(&mask->hdr.src_addr) ||
+		!igc_is_zero_ipv6_addr(&mask->hdr.dst_addr))
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ITEM, item,
 				"IPv6 only support protocol");
drivers/net/ixgbe/ixgbe_flow.c +6 -6
index 687341c6b8d3..1b35ed5faabe 100644
@@ -1917,9 +1917,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == 0) {
+			if (ipv6_mask->hdr.src_addr.a[j] == 0) {
 				rule->mask.src_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.src_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1930,9 +1930,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == 0) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == 0) {
 				rule->mask.dst_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.dst_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1945,9 +1945,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->ixgbe_fdir.formatted.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->ixgbe_fdir.formatted.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/ixgbe/ixgbe_ipsec.c +2 -2
index d3313085560d..7615a19911ba 100644
@@ -681,9 +681,9 @@ ixgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
drivers/net/mlx5/hws/mlx5dr_definer.c +18 -18
index 51a3f7be4b75..7326d2cf42a5 100644
@@ -176,14 +176,14 @@ struct mlx5dr_definer_conv_data {
 	X(SET,		ipv6_proto,		v->hdr.proto,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_routing_hdr,	IPPROTO_ROUTING,	rte_flow_item_ipv6) \
 	X(SET,		ipv6_hop_limits,	v->hdr.hop_limits,	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr[12],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr.a[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr.a[12],	rte_flow_item_ipv6) \
 	X(SET,		ipv6_version,		STE_IPV6,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_frag,		v->has_frag_ext,	rte_flow_item_ipv6) \
 	X(SET,		icmp_protocol,		STE_ICMP,		rte_flow_item_icmp) \
@@ -1161,8 +1161,8 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 	    m->has_esp_ext || m->has_dest_ext || m->has_mobil_ext ||
 	    m->has_hip_ext || m->has_shim6_ext ||
 	    (l && (l->has_frag_ext || l->hdr.vtc_flow || l->hdr.proto ||
-		   !is_mem_zero(l->hdr.src_addr, 16) ||
-		   !is_mem_zero(l->hdr.dst_addr, 16)))) {
+		   !is_mem_zero(l->hdr.src_addr.a, 16) ||
+		   !is_mem_zero(l->hdr.dst_addr.a, 16)))) {
 		rte_errno = ENOTSUP;
 		return rte_errno;
 	}
@@ -1219,56 +1219,56 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 		DR_CALC_SET(fc, eth_l3, time_to_live_hop_limit, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_31_0_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_31_0, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_31_0_set;
drivers/net/mlx5/mlx5_flow.c +4 -2
index 72fb3a55baf4..ba03a246fc84 100644
@@ -2933,12 +2933,14 @@ mlx5_flow_validate_item_ipv6(const struct rte_eth_dev *dev,
 	const struct rte_flow_item_ipv6 *spec = item->spec;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr =
+			.src_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
-			.dst_addr =
+			},
+			.dst_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 		},
drivers/net/mlx5/mlx5_flow_dv.c +10 -6
index 89057edbcfc2..30b9dd898ffc 100644
@@ -7697,12 +7697,14 @@ const struct rte_flow_item_ipv4 nic_ipv4_mask = {
 
 const struct rte_flow_item_ipv6 nic_ipv6_mask = {
 	.hdr = {
-		.src_addr =
+		.src_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 		.vtc_flow = RTE_BE32(0xffffffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
@@ -9549,12 +9551,14 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	const struct rte_flow_item_ipv6 *ipv6_v;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr =
+			.src_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
-			.dst_addr =
+			},
+			.dst_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 			.hop_limits = 0xff,
@@ -9577,11 +9581,11 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.dst_addr[i] & ipv6_v->hdr.dst_addr[i];
+		l24_v[i] = ipv6_m->hdr.dst_addr.a[i] & ipv6_v->hdr.dst_addr.a[i];
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     src_ipv4_src_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.src_addr[i] & ipv6_v->hdr.src_addr[i];
+		l24_v[i] = ipv6_m->hdr.src_addr.a[i] & ipv6_v->hdr.src_addr.a[i];
 	/* TOS. */
 	vtc_v = rte_be_to_cpu_32(ipv6_m->hdr.vtc_flow & ipv6_v->hdr.vtc_flow);
 	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, vtc_v >> 20);
drivers/net/mlx5/mlx5_flow_hw.c +6 -4
index d243b59b71cd..1b6c79a3f332 100644
@@ -8250,12 +8250,14 @@ const struct rte_flow_item_ipv6 hws_nic_ipv6_mask = {
 		.payload_len = RTE_BE16(0xffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
-		.src_addr =
+		.src_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 	},
 	.has_frag_ext = 1,
 };
@@ -14645,10 +14647,10 @@ flow_hw_calc_encap_hash(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			memcpy(data.dst.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
 			       sizeof(data.dst.ipv6_addr));
 			memcpy(data.src.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
 			       sizeof(data.src.ipv6_addr));
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
drivers/net/mlx5/mlx5_flow_verbs.c +4 -4
index 3a4356c0f650..5b4a4eda3bbc 100644
@@ -600,13 +600,13 @@ flow_verbs_translate_item_ipv6(struct mlx5_flow *dev_flow,
 		uint32_t vtc_flow_val;
 		uint32_t vtc_flow_mask;
 
-		memcpy(&ipv6.val.src_ip, spec->hdr.src_addr,
+		memcpy(&ipv6.val.src_ip, &spec->hdr.src_addr,
 		       RTE_DIM(ipv6.val.src_ip));
-		memcpy(&ipv6.val.dst_ip, spec->hdr.dst_addr,
+		memcpy(&ipv6.val.dst_ip, &spec->hdr.dst_addr,
 		       RTE_DIM(ipv6.val.dst_ip));
-		memcpy(&ipv6.mask.src_ip, mask->hdr.src_addr,
+		memcpy(&ipv6.mask.src_ip, &mask->hdr.src_addr,
 		       RTE_DIM(ipv6.mask.src_ip));
-		memcpy(&ipv6.mask.dst_ip, mask->hdr.dst_addr,
+		memcpy(&ipv6.mask.dst_ip, &mask->hdr.dst_addr,
 		       RTE_DIM(ipv6.mask.dst_ip));
 		vtc_flow_val = rte_be_to_cpu_32(spec->hdr.vtc_flow);
 		vtc_flow_mask = rte_be_to_cpu_32(mask->hdr.vtc_flow);
drivers/net/nfp/flower/nfp_flower_flow.c +19 -15
index 0078455658ac..3f597d394b24 100644
@@ -2027,18 +2027,18 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 
 			ipv6_gre_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_gre_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_gre_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_src));
-			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_dst));
 		} else {
 			ipv6_udp_tun = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
 
 			ipv6_udp_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_udp_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_udp_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_src));
-			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_dst));
 		}
 	} else {
@@ -2061,8 +2061,8 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 		ipv6->ip_ext.tos   = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 		ipv6->ip_ext.proto = hdr->proto;
 		ipv6->ip_ext.ttl   = hdr->hop_limits;
-		memcpy(ipv6->ipv6_src, hdr->src_addr, sizeof(ipv6->ipv6_src));
-		memcpy(ipv6->ipv6_dst, hdr->dst_addr, sizeof(ipv6->ipv6_dst));
+		memcpy(ipv6->ipv6_src, &hdr->src_addr, sizeof(ipv6->ipv6_src));
+		memcpy(ipv6->ipv6_dst, &hdr->dst_addr, sizeof(ipv6->ipv6_dst));
 
 ipv6_end:
 		*param->mbuf_off += sizeof(struct nfp_flower_ipv6);
@@ -2518,10 +2518,14 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
 				.vtc_flow   = RTE_BE32(0x0ff00000),
 				.proto      = 0xff,
 				.hop_limits = 0xff,
-				.src_addr   = "\xff\xff\xff\xff\xff\xff\xff\xff"
+				.src_addr   = { .a =
+					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr   = "\xff\xff\xff\xff\xff\xff\xff\xff"
+				},
+				.dst_addr   = { .a =
+					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				},
 			},
 			.has_frag_ext = 1,
 		},
@@ -3324,8 +3328,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 	struct nfp_flower_cmsg_tun_neigh_v6 payload;
 
 	tun->payload.v6_flag = 1;
-	memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
-	memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
+	memcpy(tun->payload.dst.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
+	memcpy(tun->payload.src.src_ipv6, &ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
 	memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 
@@ -3345,8 +3349,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 			sizeof(struct nfp_flower_meta_tci));
 
 	memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6));
-	memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
-	memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
+	memcpy(payload.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
+	memcpy(payload.src_ipv6, &ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
 	memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	payload.common.port_id = port->in_port;
@@ -3573,7 +3577,7 @@ nfp_flow_action_vxlan_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -3944,7 +3948,7 @@ nfp_flow_action_geneve_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -4021,7 +4025,7 @@ nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
drivers/net/nfp/nfp_net_flow.c +24 -20

62 lines not on this page · raw message

drivers/net/qede/qede_filter.c +2 -2
index d98266eac55c..14fb4338e9c7 100644
@@ -794,9 +794,9 @@ qede_flow_parse_pattern(__rte_unused struct rte_eth_dev *dev,
 
 				spec = pattern->spec;
 				memcpy(flow->entry.tuple.src_ipv6,
-				       spec->hdr.src_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.src_addr, IPV6_ADDR_LEN);
 				memcpy(flow->entry.tuple.dst_ipv6,
-				       spec->hdr.dst_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.dst_addr, IPV6_ADDR_LEN);
 				flow->entry.tuple.eth_proto =
 					RTE_ETHER_TYPE_IPV6;
 			}
drivers/net/sfc/sfc_flow.c +14 -14
index 1b50aefe5c48..0a812d9928ab 100644
@@ -575,14 +575,14 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	const uint16_t ether_type_ipv6 = rte_cpu_to_le_16(EFX_ETHER_TYPE_IPV6);
 	const struct rte_flow_item_ipv6 supp_mask = {
 		.hdr = {
-			.src_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
-			.dst_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
+			.src_addr = { .a =
+				"\xff\xff\xff\xff\xff\xff\xff\xff"
+				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
+			.dst_addr = { .a =
+				"\xff\xff\xff\xff\xff\xff\xff\xff"
+				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
 			.proto = 0xff,
 		}
 	};
@@ -618,28 +618,28 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	 * IPv6 addresses are in big-endian byte order in item and in
 	 * efx_spec
 	 */
-	if (memcmp(mask->hdr.src_addr, supp_mask.hdr.src_addr,
+	if (memcmp(&mask->hdr.src_addr, &supp_mask.hdr.src_addr,
 		   sizeof(mask->hdr.src_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_rem_host) !=
 				 sizeof(spec->hdr.src_addr));
-		rte_memcpy(&efx_spec->efs_rem_host, spec->hdr.src_addr,
+		rte_memcpy(&efx_spec->efs_rem_host, &spec->hdr.src_addr,
 			   sizeof(efx_spec->efs_rem_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.src_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.src_addr.a,
 				     sizeof(mask->hdr.src_addr))) {
 		goto fail_bad_mask;
 	}
 
-	if (memcmp(mask->hdr.dst_addr, supp_mask.hdr.dst_addr,
+	if (memcmp(&mask->hdr.dst_addr, &supp_mask.hdr.dst_addr,
 		   sizeof(mask->hdr.dst_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_loc_host) !=
 				 sizeof(spec->hdr.dst_addr));
-		rte_memcpy(&efx_spec->efs_loc_host, spec->hdr.dst_addr,
+		rte_memcpy(&efx_spec->efs_loc_host, &spec->hdr.dst_addr,
 			   sizeof(efx_spec->efs_loc_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr.a,
 				     sizeof(mask->hdr.dst_addr))) {
 		goto fail_bad_mask;
 	}
drivers/net/tap/tap_flow.c +4 -4
index 0a90c0487b46..8f5a8d64587b 100644
@@ -209,11 +209,11 @@ static const struct tap_flow_items tap_flow_items[] = {
 			       RTE_FLOW_ITEM_TYPE_TCP),
 		.mask = &(const struct rte_flow_item_ipv6){
 			.hdr = {
-				.src_addr = {
+				.src_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
 				},
-				.dst_addr = {
+				.dst_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
 				},
@@ -617,13 +617,13 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data)
 		info->eth_type = htons(ETH_P_IPV6);
 	if (!spec)
 		return 0;
-	if (memcmp(mask->hdr.dst_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.dst_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST,
 			   sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK,
 			   sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr);
 	}
-	if (memcmp(mask->hdr.src_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.src_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC,
 			   sizeof(spec->hdr.src_addr), &spec->hdr.src_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK,
drivers/net/txgbe/txgbe_flow.c +6 -6
index 7ef52d0b0fcd..5d2dd453687c 100644
@@ -1807,9 +1807,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[j] == UINT8_MAX) {
 				rule->mask.src_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.src_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1820,9 +1820,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == UINT8_MAX) {
 				rule->mask.dst_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.dst_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1835,9 +1835,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->input.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->input.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/txgbe/txgbe_ipsec.c +2 -2
index f9f8108fb894..4bad7fc76d42 100644
@@ -659,9 +659,9 @@ txgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
examples/ip_fragmentation/main.c +1 -1
index 736eae6f05ee..4c0fa5054a2e 100644
@@ -311,7 +311,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
 		ip_hdr = rte_pktmbuf_mtod(m, struct rte_ipv6_hdr *);
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			port_out = next_hop;
examples/ip_pipeline/pipeline.c +8 -8
index 301c52d061be..d08f8c24c80f 100644
@@ -638,7 +638,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 1,
 		.input_index = 1,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[0]),
 	},
 
 	[2] = {
@@ -646,7 +646,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 2,
 		.input_index = 2,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[4]),
 	},
 
 	[3] = {
@@ -654,7 +654,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 3,
 		.input_index = 3,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[8]),
 	},
 
 	[4] = {
@@ -662,7 +662,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 4,
 		.input_index = 4,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[12]),
 	},
 
 	/* Destination IP address (IPv6) */
@@ -671,7 +671,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 5,
 		.input_index = 5,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[0]),
 	},
 
 	[6] = {
@@ -679,7 +679,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 6,
 		.input_index = 6,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[4]),
 	},
 
 	[7] = {
@@ -687,7 +687,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 7,
 		.input_index = 7,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[8]),
 	},
 
 	[8] = {
@@ -695,7 +695,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 8,
 		.input_index = 8,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[12]),
 	},
 
 	/* Source Port */
examples/ip_reassembly/main.c +1 -1
index c7019078f7b4..4da692eb23e6 100644
@@ -400,7 +400,7 @@ reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queue,
 		}
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			dst_port = next_hop;
examples/ipsec-secgw/flow.c +6 -6
index 05a62c3020fa..8a0c79e1510a 100644
@@ -85,7 +85,7 @@ ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 {
 	uint8_t *addr;
 
-	addr = hdr->src_addr;
+	addr = hdr->src_addr.a;
 	printf("src: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx \t",
 	       (uint16_t)((addr[0] << 8) | addr[1]),
 	       (uint16_t)((addr[2] << 8) | addr[3]),
@@ -96,7 +96,7 @@ ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 	       (uint16_t)((addr[12] << 8) | addr[13]),
 	       (uint16_t)((addr[14] << 8) | addr[15]));
 
-	addr = hdr->dst_addr;
+	addr = hdr->dst_addr.a;
 	printf("dst: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx",
 	       (uint16_t)((addr[0] << 8) | addr[1]),
 	       (uint16_t)((addr[2] << 8) | addr[3]),
@@ -196,8 +196,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr,
-						  rule->ipv6.mask.hdr.src_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr.a,
+						  rule->ipv6.mask.hdr.src_addr.a,
 						  tokens[ti], status))
 					return;
 			}
@@ -205,8 +205,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr,
-						  rule->ipv6.mask.hdr.dst_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr.a,
+						  rule->ipv6.mask.hdr.dst_addr.a,
 						  tokens[ti], status))
 					return;
 			}
examples/ipsec-secgw/ipsec.c +4 -4
index b52b0ffc3d22..ebde28639c12 100644
@@ -529,9 +529,9 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 			sa->pattern[1].spec = &sa->ipv6_spec;
 
-			memcpy(sa->ipv6_spec.hdr.dst_addr,
+			memcpy(&sa->ipv6_spec.hdr.dst_addr,
 				sa->dst.ip.ip6.ip6_b, 16);
-			memcpy(sa->ipv6_spec.hdr.src_addr,
+			memcpy(&sa->ipv6_spec.hdr.src_addr,
 			       sa->src.ip.ip6.ip6_b, 16);
 		} else if (IS_IP4(sa->flags)) {
 			sa->pattern[1].mask = &rte_flow_item_ipv4_mask;
@@ -735,9 +735,9 @@ create_ipsec_esp_flow(struct ipsec_sa *sa)
 		sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 		sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 		sa->pattern[1].spec = &sa->ipv6_spec;
-		memcpy(sa->ipv6_spec.hdr.dst_addr,
+		memcpy(&sa->ipv6_spec.hdr.dst_addr,
 			sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b));
-		memcpy(sa->ipv6_spec.hdr.src_addr,
+		memcpy(&sa->ipv6_spec.hdr.src_addr,
 			sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b));
 		sa->pattern[2].type = RTE_FLOW_ITEM_TYPE_ESP;
 		sa->pattern[2].spec = &sa->esp_spec;
examples/ipsec-secgw/sa.c +2 -2
index c4bac17cd77c..1a0afd2ed2e8 100644
@@ -1571,8 +1571,8 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-		memcpy(v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
-		memcpy(v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
+		memcpy(&v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
+		memcpy(&v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
 	}
 
 	rc = fill_ipsec_sa_prm(&prm, lsa, &v4, &v6);
examples/ipsec-secgw/sad.h +6 -4
index 3224b6252c8d..fdb1d2ef1790 100644
@@ -5,6 +5,8 @@
 #ifndef __SAD_H__
 #define __SAD_H__
 
+#include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
 #define SA_CACHE_SZ	128
@@ -37,8 +39,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, ipv6->dst_addr, 16))))
+			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
+			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
 		return 1;
 
 	return 0;
@@ -128,9 +130,9 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, ipv6->dst_addr,
+			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
 					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, ipv6->src_addr,
+			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
 					sizeof(ipv6->src_addr));
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
examples/l3fwd/l3fwd_fib.c +1 -1
index f38b19af3f57..4a9534e9dbef 100644
@@ -65,7 +65,7 @@ fib_parse_packet(struct rte_mbuf *mbuf,
 	/* IPv6 */
 	else {
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-		rte_mov16(ipv6, (const uint8_t *)ipv6_hdr->dst_addr);
+		rte_mov16(ipv6, ipv6_hdr->dst_addr.a);
 		*ip_type = 0;
 		(*ipv6_cnt)++;
 	}
examples/l3fwd/l3fwd_lpm.c +2 -2
index e8fd95aae9ce..422fdb70054d 100644
@@ -62,7 +62,7 @@ lpm_get_ipv6_dst_port(const struct rte_ipv6_hdr *ipv6_hdr,
 		      uint16_t portid,
 		      struct rte_lpm6 *ipv6_l3fwd_lookup_struct)
 {
-	const uint8_t *dst_ip = ipv6_hdr->dst_addr;
+	const uint8_t *dst_ip = ipv6_hdr->dst_addr.a;
 	uint32_t next_hop;
 
 	if (rte_lpm6_lookup(ipv6_l3fwd_lookup_struct, dst_ip, &next_hop) == 0)
@@ -122,7 +122,7 @@ lpm_get_dst_port_with_ipv4(const struct lcore_conf *qconf, struct rte_mbuf *pkt,
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
 
 		return (uint16_t) ((rte_lpm6_lookup(qconf->ipv6_lookup_struct,
-				ipv6_hdr->dst_addr, &next_hop) == 0)
+				ipv6_hdr->dst_addr.a, &next_hop) == 0)
 				? next_hop : portid);
 
 	}
lib/ethdev/rte_flow.h +4 -2
index 3a3ab781c494..b3ede7ccdaef 100644
@@ -1006,12 +1006,14 @@ struct rte_flow_item_ipv6 {
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr =
+		.src_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 	},
 };
 #endif
lib/hash/rte_thash.h +6 -6
index af40afd2d475..9aaaacfd5fa4 100644
@@ -140,24 +140,24 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 			union rte_thash_tuple *targ)
 {
 #ifdef RTE_ARCH_X86
-	__m128i ipv6 = _mm_loadu_si128((const __m128i *)orig->src_addr);
+	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
 	*(__m128i *)targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
-	ipv6 = _mm_loadu_si128((const __m128i *)orig->dst_addr);
+	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
 	*(__m128i *)targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)orig->src_addr);
+	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
 	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)orig->dst_addr);
+	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
 	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
 		*((uint32_t *)targ->v6.src_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr.a + i));
 		*((uint32_t *)targ->v6.dst_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr.a + i));
 	}
 #endif
 }
lib/ip_frag/rte_ipv6_reassembly.c +2 -2
index 88863a98d1fe..9471ce5333d7 100644
@@ -143,8 +143,8 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	int32_t ip_len;
 	int32_t trim;
 
-	rte_memcpy(&key.src_dst[0], ip_hdr->src_addr, 16);
-	rte_memcpy(&key.src_dst[2], ip_hdr->dst_addr, 16);
+	rte_memcpy(&key.src_dst[0], &ip_hdr->src_addr, 16);
+	rte_memcpy(&key.src_dst[2], &ip_hdr->dst_addr, 16);
 
 	key.id = frag_hdr->id;
 	key.key_len = IPV6_KEYLEN;
lib/net/rte_ip6.h +3 -3
index f948f95db7ca..58cab86895eb 100644
@@ -53,8 +53,8 @@ struct rte_ipv6_hdr {
 	rte_be16_t payload_len;	/**< IP payload size, including ext. headers */
 	uint8_t  proto;		/**< Protocol, next header. */
 	uint8_t  hop_limits;	/**< Hop limits. */
-	uint8_t  src_addr[16];	/**< IP address of source host. */
-	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
+	struct rte_ipv6_addr src_addr;	/**< IP address of source host. */
+	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
 /* IPv6 routing extension type definition. */
@@ -122,7 +122,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr),
 		0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
lib/node/ip6_lookup.c +5 -5
index 309964f60fd6..6bbcf14e2aa8 100644
@@ -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_memcpy(ip_batch[0], &ipv6_hdr->dst_addr, 16);
 
 		/* 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_memcpy(ip_batch[1], &ipv6_hdr->dst_addr, 16);
 
 		/* 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_memcpy(ip_batch[2], &ipv6_hdr->dst_addr, 16);
 
 		/* 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_memcpy(ip_batch[3], &ipv6_hdr->dst_addr, 16);
 
 		rte_lpm6_lookup_bulk_func(lpm6, ip_batch, next_hop, 4);
 
@@ -223,7 +223,7 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 		/* Extract TTL as IPv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
 
-		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr, &next_hop);
+		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr.a, &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
 
 		node_mbuf_priv1(mbuf0, dyn)->nh = (uint16_t)next_hop;
lib/pipeline/rte_swx_ipsec.c +2 -4
index 56a401d0fa63..5920178f38e5 100644
@@ -1387,13 +1387,11 @@ tunnel_ipv6_header_set(struct rte_ipv6_hdr *h, struct rte_swx_ipsec_sa_params *p
 		.payload_len = 0, /* Cannot be pre-computed. */
 		.proto = IPPROTO_ESP,
 		.hop_limits = 64,
-		.src_addr = {0},
-		.dst_addr = {0},
 	};
 
 	memcpy(h, &ipv6_hdr, sizeof(ipv6_hdr));
-	memcpy(h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
-	memcpy(h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
+	memcpy(&h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
+	memcpy(&h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
 }
 
 /* IPsec library SA parameters. */
lib/pipeline/rte_table_action.c +12 -12
index ebbdd3f4cebe..a04d5121e1f0 100644
@@ -872,10 +872,10 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(d->ipv6.src_addr,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -907,10 +907,10 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(d->ipv6.src_addr,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -1437,12 +1437,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				tcp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1450,12 +1450,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				udp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1465,12 +1465,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr,
 				(uint16_t *)data->addr,
 				tcp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1478,12 +1478,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr.a,
 				(uint16_t *)data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
Signature · 1 line
2.46.0
#5 lore raw

PATCH 5/15 fib6,rib6,lpm6: use ipv6 addr struct

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] array types in the API of rte_fib6, rte_rib6 and rte_lpm6. Update all code accordingly.

Unfortunately, these three libraries are strongly intertwined, it is not possible to split this change in separate commits.

---
 app/test-fib/main.c                   |   51 +-
 app/test-pipeline/pipeline_lpm_ipv6.c |   10 +-
 app/test/test_fib6.c                  |   52 +-
 app/test/test_fib6_perf.c             |    8 +-
 app/test/test_lpm6.c                  |  523 +++----
 app/test/test_lpm6_data.h             | 2025 +++++++++++++------------
 app/test/test_lpm6_perf.c             |   10 +-
 app/test/test_rib6.c                  |   65 +-
 app/test/test_table_combined.c        |    2 +-
 app/test/test_table_tables.c          |    8 +-
 examples/ip_fragmentation/main.c      |   24 +-
 examples/ip_pipeline/thread.c         |    2 +-
 examples/ip_reassembly/main.c         |   24 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h |    7 +-
 examples/ipsec-secgw/ipsec_worker.c   |    6 +-
 examples/ipsec-secgw/ipsec_worker.h   |    4 +-
 examples/ipsec-secgw/rt.c             |   22 +-
 examples/l3fwd/l3fwd_fib.c            |   39 +-
 examples/l3fwd/l3fwd_lpm.c            |    8 +-
 examples/l3fwd/l3fwd_route.h          |    7 +-
 examples/l3fwd/lpm_route_parse.c      |    6 +-
 lib/fib/meson.build                   |    4 +-
 lib/fib/rte_fib6.c                    |   13 +-
 lib/fib/rte_fib6.h                    |   11 +-
 lib/fib/trie.c                        |   99 +-
 lib/fib/trie.h                        |   16 +-
 lib/fib/trie_avx512.c                 |   38 +-
 lib/fib/trie_avx512.h                 |   10 +-
 lib/lpm/meson.build                   |    1 +
 lib/lpm/rte_lpm6.c                    |  106 +-
 lib/lpm/rte_lpm6.h                    |   14 +-
 lib/node/ip6_lookup.c                 |   16 +-
 lib/rib/meson.build                   |    2 +-
 lib/rib/rte_rib6.c                    |   74 +-
 lib/rib/rte_rib6.h                    |   13 +-
 lib/table/rte_table_lpm_ipv6.c        |   12 +-
 lib/table/rte_table_lpm_ipv6.h        |    4 +-
 37 files changed, 1681 insertions(+), 1655 deletions(-)
app/test-fib/main.c +25 -26
index c49bfe8bcec3..a43a0ae4df5d 100644
@@ -123,7 +123,7 @@ struct rt_rule_4 {
 };
 
 struct rt_rule_6 {
-	uint8_t		addr[16];
+	struct rte_ipv6_addr addr;
 	uint8_t		depth;
 	uint64_t	nh;
 };
@@ -306,15 +306,15 @@ shuffle_rt_6(struct rt_rule_6 *rt, int n)
 
 	for (i = 0; i < n; i++) {
 		j = rte_rand() % n;
-		memcpy(tmp.addr, rt[i].addr, 16);
+		memcpy(&tmp.addr, &rt[i].addr, 16);
 		tmp.depth = rt[i].depth;
 		tmp.nh = rt[i].nh;
 
-		memcpy(rt[i].addr, rt[j].addr, 16);
+		memcpy(&rt[i].addr, &rt[j].addr, 16);
 		rt[i].depth = rt[j].depth;
 		rt[i].nh = rt[j].nh;
 
-		memcpy(rt[j].addr, tmp.addr, 16);
+		memcpy(&rt[j].addr, &tmp.addr, 16);
 		rt[j].depth = tmp.depth;
 		rt[j].nh = tmp.nh;
 	}
@@ -364,7 +364,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 	uint32_t a, i, j, k = 0;
 
 	if (config.nb_routes_per_depth[0] != 0) {
-		memset(rt[k].addr, 0, 16);
+		memset(&rt[k].addr, 0, 16);
 		rt[k].depth = 0;
 		rt[k++].nh = rte_rand() & get_max_nh(nh_sz);
 	}
@@ -380,7 +380,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 				uint64_t rnd_val = get_rnd_rng((uint64_t)edge,
 					(uint64_t)(edge + step));
 				rnd = rte_cpu_to_be_32(rnd_val << (32 - i));
-				complete_v6_addr((uint32_t *)rt[k].addr,
+				complete_v6_addr((uint32_t *)&rt[k].addr,
 					rnd, a);
 				rt[k].depth = (a * 32) + i;
 				rt[k].nh = rte_rand() & get_max_nh(nh_sz);
@@ -390,19 +390,19 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 }
 
 static inline void
-set_rnd_ipv6(uint8_t *addr, uint8_t *route, int depth)
+set_rnd_ipv6(struct rte_ipv6_addr *addr, struct rte_ipv6_addr *route, int depth)
 {
 	int i;
 
 	for (i = 0; i < 16; i++)
-		addr[i] = rte_rand();
+		addr->a[i] = rte_rand();
 
 	for (i = 0; i < 16; i++) {
 		if (depth >= 8)
-			addr[i] = route[i];
+			addr->a[i] = route->a[i];
 		else if (depth > 0) {
-			addr[i] &= (uint16_t)UINT8_MAX >> depth;
-			addr[i] |= route[i] & UINT8_MAX << (8 - depth);
+			addr->a[i] &= (uint16_t)UINT8_MAX >> depth;
+			addr->a[i] |= route->a[i] & UINT8_MAX << (8 - depth);
 		} else
 			return;
 		depth -= 8;
@@ -413,7 +413,7 @@ static void
 gen_rnd_lookup_tbl(int af)
 {
 	uint32_t *tbl4 = config.lookup_tbl;
-	uint8_t *tbl6 = config.lookup_tbl;
+	struct rte_ipv6_addr *tbl6 = config.lookup_tbl;
 	struct rt_rule_4 *rt4 = (struct rt_rule_4 *)config.rt;
 	struct rt_rule_6 *rt6 = (struct rt_rule_6 *)config.rt;
 	uint32_t i, j;
@@ -432,11 +432,10 @@ gen_rnd_lookup_tbl(int af)
 		for (i = 0, j = 0; i < config.nb_lookup_ips;
 				i++, j = (j + 1) % config.nb_routes) {
 			if ((rte_rand() % 100) < config.rnd_lookup_ips_ratio) {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr, 0);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, 0);
 				config.nb_lookup_ips_rnd++;
 			} else {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr,
-					rt6[j].depth);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, rt6[j].depth);
 			}
 		}
 	}
@@ -522,7 +521,7 @@ parse_rt_6(FILE *f)
 			s = NULL;
 		}
 
-		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], rt[j].addr);
+		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], &rt[j].addr);
 		if (ret < 0)
 			return ret;
 
@@ -1023,7 +1022,7 @@ dump_rt_6(struct rt_rule_6 *rt)
 	}
 
 	for (i = 0; i < config.nb_routes; i++) {
-		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(rt[i].addr),
+		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(&rt[i].addr),
 			rt[i].depth, rt[i].nh);
 
 	}
@@ -1043,7 +1042,7 @@ run_v6(void)
 	int ret = 0;
 	struct rte_lpm6	*lpm = NULL;
 	struct rte_lpm6_config lpm_conf;
-	uint8_t *tbl6;
+	struct rte_ipv6_addr *tbl6;
 	uint64_t fib_nh[BURST_SZ];
 	int32_t lpm_nh[BURST_SZ];
 
@@ -1094,7 +1093,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
-			ret = rte_fib6_add(fib, rt[i + j].addr,
+			ret = rte_fib6_add(fib, &rt[i + j].addr,
 				rt[i + j].depth, rt[i + j].nh);
 			if (unlikely(ret != 0)) {
 				printf("Can not add a route to FIB, err %d\n",
@@ -1120,7 +1119,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++) {
-				ret = rte_lpm6_add(lpm, rt[i + j].addr,
+				ret = rte_lpm6_add(lpm, &rt[i + j].addr,
 					rt[i + j].depth, rt[i + j].nh);
 				if (ret != 0) {
 					if (rt[i + j].depth == 0)
@@ -1139,7 +1138,7 @@ run_v6(void)
 	acc = 0;
 	for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 		start = rte_rdtsc_precise();
-		ret = rte_fib6_lookup_bulk(fib, (uint8_t (*)[16])(tbl6 + i*16),
+		ret = rte_fib6_lookup_bulk(fib, &tbl6[i],
 			fib_nh, BURST_SZ);
 		acc += rte_rdtsc_precise() - start;
 		if (ret != 0) {
@@ -1154,7 +1153,7 @@ run_v6(void)
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			start = rte_rdtsc_precise();
 			ret = rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			acc += rte_rdtsc_precise() - start;
 			if (ret != 0) {
@@ -1166,10 +1165,10 @@ run_v6(void)
 
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			rte_fib6_lookup_bulk(fib,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				fib_nh, BURST_SZ);
 			rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			for (j = 0; j < BURST_SZ; j++) {
 				if ((fib_nh[j] != (uint32_t)lpm_nh[j]) &&
@@ -1186,7 +1185,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++)
-			rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth);
+			rte_fib6_delete(fib, &rt[i + j].addr, rt[i + j].depth);
 
 		printf("AVG FIB delete %"PRIu64"\n",
 			(rte_rdtsc_precise() - start) / j);
@@ -1197,7 +1196,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++)
-				rte_lpm6_delete(lpm, rt[i + j].addr,
+				rte_lpm6_delete(lpm, &rt[i + j].addr,
 					rt[i + j].depth);
 
 			printf("AVG LPM delete %"PRIu64"\n",
app/test-pipeline/pipeline_lpm_ipv6.c +5 -5
index 207ffbeff00f..cfebfbbc81ca 100644
@@ -127,16 +127,16 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) {
 
 		ip = rte_bswap32(i << (24 -
 			rte_popcount32(app.n_ports - 1)));
-		memcpy(key.ip, &ip, sizeof(uint32_t));
+		memcpy(&key.ip, &ip, sizeof(uint32_t));
 
 		printf("Adding rule to IPv6 LPM table (IPv6 destination = "
 			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:"
 			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x/%u => "
 			"port out = %u)\n",
-			key.ip[0], key.ip[1], key.ip[2], key.ip[3],
-			key.ip[4], key.ip[5], key.ip[6], key.ip[7],
-			key.ip[8], key.ip[9], key.ip[10], key.ip[11],
-			key.ip[12], key.ip[13], key.ip[14], key.ip[15],
+			key.ip.a[0], key.ip.a[1], key.ip.a[2], key.ip.a[3],
+			key.ip.a[4], key.ip.a[5], key.ip.a[6], key.ip.a[7],
+			key.ip.a[8], key.ip.a[9], key.ip.a[10], key.ip.a[11],
+			key.ip.a[12], key.ip.a[13], key.ip.a[14], key.ip.a[15],
 			key.depth, i);
 
 		status = rte_pipeline_table_entry_add(p, table_id, &key, &entry,
app/test/test_fib6.c +26 -26

134 lines not on this page · raw message

app/test/test_fib6_perf.c +4 -4
index fe713e7094e5..d51bbdbdd6fa 100644
@@ -73,7 +73,7 @@ test_fib6_perf(void)
 	uint64_t next_hop_add;
 	int status = 0;
 	int64_t count = 0;
-	uint8_t ip_batch[NUM_IPS_ENTRIES][16];
+	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
 	uint64_t next_hops[NUM_IPS_ENTRIES];
 
 	conf.type = RTE_FIB6_TRIE;
@@ -101,7 +101,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		next_hop_add = (i & ((1 << 14) - 1)) + 1;
-		if (rte_fib6_add(fib, large_route_table[i].ip,
+		if (rte_fib6_add(fib, &large_route_table[i].ip,
 				large_route_table[i].depth, next_hop_add) == 0)
 			status++;
 	}
@@ -117,7 +117,7 @@ test_fib6_perf(void)
 	count = 0;
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
-		memcpy(ip_batch[i], large_ips_table[i].ip, 16);
+		memcpy(&ip_batch[i], &large_ips_table[i].ip, 16);
 
 	for (i = 0; i < ITERATIONS; i++) {
 
@@ -140,7 +140,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		/* rte_fib_delete(fib, ip, depth) */
-		status += rte_fib6_delete(fib, large_route_table[i].ip,
+		status += rte_fib6_delete(fib, &large_route_table[i].ip,
 				large_route_table[i].depth);
 	}
 
app/test/test_lpm6.c +269 -254

1,292 lines not on this page · raw message

app/test/test_lpm6_data.h +1013 -1012

1,350 lines not on this page · raw message

app/test/test_lpm6_perf.c +5 -5
index c847dcb18375..0f9e3698c4da 100644

Lines of this file are not shown. View the raw message.

app/test/test_rib6.c +35 -30

65 lines not on this page · raw message

app/test/test_table_combined.c +1 -1
index 1c2efe649ded..04503baa5180 100644

Lines of this file are not shown. View the raw message.

app/test/test_table_tables.c +4 -4
index 26908e6112fc..920aa555cbd2 100644

Lines of this file are not shown. View the raw message.

examples/ip_fragmentation/main.c +12 -12
index 4c0fa5054a2e..611b5818d88c 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/thread.c +1 -1
index 8a912dc1b392..9d8082b73080 100644

Lines of this file are not shown. View the raw message.

examples/ip_reassembly/main.c +12 -12
index 4da692eb23e6..06383cc36289 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_lpm_neon.h +4 -3
index 9573f53ae957..865b9624a86e 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.c +3 -3
index c9c43ebd2b99..3a83b7c0bf4b 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.h +2 -2
index 8f6a1c06aa7f..8f9616129362 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/rt.c +11 -11
index ce854ccb6018..059fc0c8f28c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_fib.c +18 -21
index 4a9534e9dbef..046aa1027b5c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_lpm.c +4 -4
index 422fdb70054d..fc4f5878fcd8 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_route.h +3 -4
index 467c4d285915..ceabf4fa8e3c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/lpm_route_parse.c +3 -3
index f2028d79e180..d553ebdbcc5c 100644

Lines of this file are not shown. View the raw message.

lib/fib/meson.build +2 -2
index 6795f41a0ad2..268007ef6c93 100644

Lines of this file are not shown. View the raw message.

lib/fib/rte_fib6.c +7 -6
index 9ad990724a8b..d95cac79cbb5 100644

Lines of this file are not shown. View the raw message.

lib/fib/rte_fib6.h +6 -5
index 2eb8b8267647..d26a0c7c0b77 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie.c +48 -51

99 lines not on this page · raw message

lib/fib/trie.h +9 -7
index 2c20184a26a3..6e235edaf89c 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie_avx512.c +19 -19
index d4d70d84bf60..f49482a95dfa 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie_avx512.h +7 -3
index ef8c7f0e3474..1028a4899fc7 100644

Lines of this file are not shown. View the raw message.

lib/lpm/meson.build +1 -0
index ae30f80b69c8..fae4f79fb938 100644

Lines of this file are not shown. View the raw message.

lib/lpm/rte_lpm6.c +53 -53

106 lines not on this page · raw message

lib/lpm/rte_lpm6.h +8 -6
index c93683e6240c..87392194237c 100644

Lines of this file are not shown. View the raw message.

lib/node/ip6_lookup.c +8 -8
index 6bbcf14e2aa8..1ad6e3fd18f2 100644

Lines of this file are not shown. View the raw message.

lib/rib/meson.build +1 -1
index 7bacbb453592..e98f70848189 100644

Lines of this file are not shown. View the raw message.

lib/rib/rte_rib6.c +37 -37

74 lines not on this page · raw message

lib/rib/rte_rib6.h +7 -6
index 775286f965f2..47dcb6d15183 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.c +6 -6
index c1a7412f92cf..dea11130d3d5 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.h +2 -2
index 96ddbd32c20e..d96ce1179954 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.46.0

Part of the diff is not shown here. View the raw message.

#6 lore raw

PATCH 6/15 net: add ipv6 address utilities

In reply to Robin Jarry

Add utility functions that use the previously introduced IPv6 address structure. Add basic unit tests to ensure everything works as expected.

These functions will be used in the next commits to replace private and/or duplicated functions.

---
 app/test/meson.build     |   1 +
 app/test/test_net_ipv6.c | 129 +++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip6.h        | 112 +++++++++++++++++++++++++++++++++
 3 files changed, 242 insertions(+)
 create mode 100644 app/test/test_net_ipv6.c
app/test/meson.build +1 -0
index e29258e6ec05..f5276e28c3b9 100644
@@ -130,6 +130,7 @@ source_file_deps = {
     'test_metrics.c': ['metrics'],
     'test_mp_secondary.c': ['hash'],
     'test_net_ether.c': ['net'],
+    'test_net_ipv6.c': ['net'],
     'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'],
     'test_pdcp.c': ['eventdev', 'pdcp', 'net', 'timer', 'security'],
     'test_pdump.c': ['pdump'] + sample_packet_forward_deps,
app/test/test_net_ipv6.c new file +129 -0

129 lines not on this page · raw message

lib/net/rte_ip6.h +112 -0

130 lines not on this page · raw message

Signature · 1 line
2.46.0
#7 lore raw

PATCH 7/15 fib6,rib6,lpm6: use ipv6 utils

In reply to Robin Jarry

Replace duplicated and/or private functions by some of the previously introduced utility functions.

Mark rib6 functions that deal with ipv6 addresses as deprecated.

---
 app/test/test_fib6.c                  |  9 +++--
 app/test/test_rib6.c                  |  2 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h |  2 +-
 lib/fib/trie.c                        | 30 ++++++--------
 lib/lpm/rte_lpm6.c                    | 51 +++++-------------------
 lib/rib/rte_rib6.c                    | 57 +++++++++------------------
 lib/rib/rte_rib6.h                    |  8 ++++
 7 files changed, 56 insertions(+), 103 deletions(-)
app/test/test_fib6.c +6 -3
index c3b947d789bb..7134c4d335cd 100644
@@ -279,9 +279,12 @@ check_fib(struct rte_fib6 *fib)
 	int ret;
 
 	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
-		for (j = 0; j < RTE_FIB6_IPV6_ADDR_SIZE; j++) {
-			ip_arr[i].a[j] = ip_add.a[j] |
-				~get_msk_part(RTE_FIB6_MAXDEPTH - i, j);
+		rte_ipv6_addr_cpy(&ip_arr[i], &ip_add);
+		j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT;
+		if (j < RTE_FIB6_IPV6_ADDR_SIZE) {
+			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT);
+			for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++)
+				ip_arr[i].a[j] = 0xff;
 		}
 	}
 
app/test/test_rib6.c +1 -1
index f3b6f1474348..33288f9c26d6 100644
@@ -217,7 +217,7 @@ test_get_fn(void)
 
 	/* check the return values */
 	ret = rte_rib6_get_ip(node, &ip_ret);
-	RTE_TEST_ASSERT((ret == 0) && (rte_rib6_is_equal(ip_ret.a, ip.a)),
+	RTE_TEST_ASSERT((ret == 0) && (rte_ipv6_addr_eq(&ip_ret, &ip)),
 		"Failed to get proper node ip\n");
 	ret = rte_rib6_get_depth(node, &depth_ret);
 	RTE_TEST_ASSERT((ret == 0) && (depth_ret == depth),
examples/ipsec-secgw/ipsec_lpm_neon.h +1 -1
index 865b9624a86e..62b4260843a3 100644
@@ -144,7 +144,7 @@ route6_pkts_neon(struct rt_ctx *rt_ctx, struct rte_mbuf **pkts, int nb_rx)
 			 * required to get the hop
 			 */
 			ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-			memcpy(&dst_ip6[lpm_pkts], &ipv6_hdr->dst_addr, 16);
+			rte_ipv6_addr_cpy(&dst_ip6[lpm_pkts], &ipv6_hdr->dst_addr);
 			lpm_pkts++;
 		}
 	}
lib/fib/trie.c +11 -19
index bd0c7ec63b7f..8a69702eabb2 100644
@@ -367,7 +367,7 @@ install_to_dp(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ledge,
 	struct rte_ipv6_addr redge;
 
 	/* decrement redge by 1*/
-	rte_rib6_copy_addr(redge.a, r->a);
+	rte_ipv6_addr_cpy(&redge, r);
 	for (i = 15; i >= 0; i--) {
 		redge.a[i]--;
 		if (redge.a[i] != 0xff)
@@ -451,14 +451,6 @@ get_nxt_net(struct rte_ipv6_addr *ip, uint8_t depth)
 	}
 }
 
-static int
-v6_addr_is_zero(const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE])
-{
-	uint8_t ip_addr[RTE_FIB6_IPV6_ADDR_SIZE] = {0};
-
-	return rte_rib6_is_equal(ip, ip_addr);
-}
-
 static int
 modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 	const struct rte_ipv6_addr *ip,
@@ -472,7 +464,7 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 	if (next_hop > get_max_nh(dp->nh_sz))
 		return -EINVAL;
 
-	rte_rib6_copy_addr(ledge.a, ip->a);
+	rte_ipv6_addr_cpy(&ledge, ip);
 	do {
 		tmp = rte_rib6_get_nxt(rib, ip, depth, tmp,
 			RTE_RIB6_GET_NXT_COVER);
@@ -481,7 +473,7 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 			if (tmp_depth == depth)
 				continue;
 			rte_rib6_get_ip(tmp, &redge);
-			if (rte_rib6_is_equal(ledge.a, redge.a)) {
+			if (rte_ipv6_addr_eq(&ledge, &redge)) {
 				get_nxt_net(&ledge, tmp_depth);
 				continue;
 			}
@@ -489,18 +481,18 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 			if (ret != 0)
 				return ret;
 			get_nxt_net(&redge, tmp_depth);
-			rte_rib6_copy_addr(ledge.a, redge.a);
+			rte_ipv6_addr_cpy(&ledge, &redge);
 			/*
 			 * we got to the end of address space
 			 * and wrapped around
 			 */
-			if (v6_addr_is_zero(ledge.a))
+			if (rte_ipv6_addr_is_unspec(&ledge))
 				break;
 		} else {
-			rte_rib6_copy_addr(redge.a, ip->a);
+			rte_ipv6_addr_cpy(&redge, ip);
 			get_nxt_net(&redge, depth);
-			if (rte_rib6_is_equal(ledge.a, redge.a) &&
-					!v6_addr_is_zero(ledge.a))
+			if (rte_ipv6_addr_eq(&ledge, &redge) &&
+					!rte_ipv6_addr_is_unspec(&ledge))
 				break;
 
 			ret = install_to_dp(dp, &ledge, &redge, next_hop);
@@ -522,7 +514,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	struct rte_rib6_node *node;
 	struct rte_rib6_node *parent;
 	struct rte_ipv6_addr ip_masked;
-	int i, ret = 0;
+	int ret = 0;
 	uint64_t par_nh, node_nh;
 	uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
 
@@ -534,8 +526,8 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	rib = rte_fib6_get_rib(fib);
 	RTE_ASSERT(rib);
 
-	for (i = 0; i < RTE_FIB6_IPV6_ADDR_SIZE; i++)
-		ip_masked.a[i] = ip->a[i] & get_msk_part(depth, i);
+	rte_ipv6_addr_cpy(&ip_masked, ip);
+	rte_ipv6_addr_mask(&ip_masked, depth);
 
 	if (depth > 24) {
 		tmp = rte_rib6_get_nxt(rib, &ip_masked,
lib/lpm/rte_lpm6.c +10 -41

93 lines not on this page · raw message

lib/rib/rte_rib6.c +19 -38

154 lines not on this page · raw message

lib/rib/rte_rib6.h +8 -0
index 47dcb6d15183..fcf4169ca790 100644
@@ -57,6 +57,9 @@ struct rte_rib6_conf {
  * @param src
  *  pointer from where to copy
  */
+static inline void rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
+	__rte_deprecated_msg("replaced by rte_ipv6_addr_cpy");
+
 static inline void
 rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
@@ -77,6 +80,9 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
  *  1 if equal
  *  0 otherwise
  */
+static inline int rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2)
+	__rte_deprecated_msg("replaced by rte_ipv6_addr_eq");
+
 static inline int
 rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 	int i;
@@ -101,6 +107,8 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
  * @return
  *  8-bit chunk of the 128-bit IPv6 mask
  */
+static inline uint8_t get_msk_part(uint8_t depth, int byte) __rte_deprecated;
+
 static inline uint8_t
 get_msk_part(uint8_t depth, int byte) {
 	uint8_t part;
Signature · 1 line
2.46.0
#8 lore raw

PATCH 8/15 graph,node: use ipv6 addr struct and utils

In reply to Robin Jarry

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

---
 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(-)
app/graph/ethdev.c +12 -28
index cfc1b1856910..19c5ab685464 100644
@@ -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)
app/graph/ethdev.h +4 -5
index d0de593fc743..046689ee5fc7 100644
@@ -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);
 
app/graph/ip6_route.c +11 -36

89 lines not on this page · raw message

app/graph/meson.build +1 -1
index 6dc54d5ee63f..344e4a418fc0 100644
@@ -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',
app/graph/neigh.c +9 -13
index 79fd542c8948..0b35f4d6c294 100644
@@ -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);
 }
app/graph/neigh_priv.h +3 -1
index 1a7106c309bc..b2a7607e01bb 100644
@@ -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;
 };
app/graph/route.h +5 -3
index 23a7951d2dad..455aab8634d4 100644
@@ -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;
 };
 
examples/l3fwd-graph/main.c +11 -19
index a13dc011380d..c2067a05f3ef 100644
@@ -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);
 
lib/node/ip6_lookup.c +7 -10
index 1ad6e3fd18f2..0806500d86cf 100644
@@ -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 "
lib/node/rte_node_ip6_api.h +2 -1
index a538dc2ea701..dc8c86184afe 100644
@@ -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);
 
 /**
Signature · 1 line
2.46.0
#9 lore raw

PATCH 9/15 pipeline: use ipv6 addr struct

In reply to Robin Jarry

Update rte_table_action_ipv6_header and rte_table_action_nat_params to use the recently added IPv6 address structure instead of uint8_t[16] arrays.

---
 examples/ip_pipeline/cli.c      | 12 +++++------
 lib/pipeline/rte_table_action.c | 36 +++++++++++++--------------------
 lib/pipeline/rte_table_action.h |  7 ++++---
 3 files changed, 24 insertions(+), 31 deletions(-)
examples/ip_pipeline/cli.c +6 -6
index e8269ea90c11..66fdeac8f501 100644
@@ -3540,8 +3540,8 @@ parse_table_action_encap(char **tokens,
 				parser_read_uint8(&hop_limit, tokens[5]))
 				return 0;
 
-			memcpy(a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
-			memcpy(a->encap.vxlan.ipv6.da, da.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.da, da.s6_addr, 16);
 			a->encap.vxlan.ipv6.flow_label = flow_label;
 			a->encap.vxlan.ipv6.dscp = dscp;
 			a->encap.vxlan.ipv6.hop_limit = hop_limit;
@@ -3615,7 +3615,7 @@ parse_table_action_nat(char **tokens,
 			return 0;
 
 		a->nat.ip_version = 0;
-		memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
+		memcpy(&a->nat.addr.ipv6, addr.s6_addr, 16);
 		a->nat.port = port;
 		a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
 		return 4;
@@ -4956,9 +4956,9 @@ table_rule_show(const char *pipeline_name,
 						(uint32_t)a->encap.vxlan.ipv4.ttl);
 				} else {
 					fprintf(f, " ipv6 ");
-					ipv6_addr_show(f, a->encap.vxlan.ipv6.sa);
+					ipv6_addr_show(f, a->encap.vxlan.ipv6.sa.a);
 					fprintf(f, " ");
-					ipv6_addr_show(f, a->encap.vxlan.ipv6.da);
+					ipv6_addr_show(f, a->encap.vxlan.ipv6.da.a);
 					fprintf(f, " %u %u %u ",
 						a->encap.vxlan.ipv6.flow_label,
 						(uint32_t)a->encap.vxlan.ipv6.dscp,
@@ -4980,7 +4980,7 @@ table_rule_show(const char *pipeline_name,
 			if (a->nat.ip_version)
 				ipv4_addr_show(f, a->nat.addr.ipv4);
 			else
-				ipv6_addr_show(f, a->nat.addr.ipv6);
+				ipv6_addr_show(f, a->nat.addr.ipv6.a);
 			fprintf(f, " %u ", (uint32_t)(a->nat.port));
 		}
 
lib/pipeline/rte_table_action.c +14 -22
index a04d5121e1f0..8479f984e4ea 100644
@@ -872,12 +872,8 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(&d->ipv6.src_addr,
-				p->vxlan.ipv6.sa,
-				sizeof(p->vxlan.ipv6.sa));
-			memcpy(&d->ipv6.dst_addr,
-				p->vxlan.ipv6.da,
-				sizeof(p->vxlan.ipv6.da));
+			rte_ipv6_addr_cpy(&d->ipv6.src_addr, &p->vxlan.ipv6.sa);
+			rte_ipv6_addr_cpy(&d->ipv6.dst_addr, &p->vxlan.ipv6.da);
 
 			/* UDP */
 			d->udp.src_port = rte_htons(p->vxlan.udp.sp);
@@ -907,12 +903,8 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(&d->ipv6.src_addr,
-				p->vxlan.ipv6.sa,
-				sizeof(p->vxlan.ipv6.sa));
-			memcpy(&d->ipv6.dst_addr,
-				p->vxlan.ipv6.da,
-				sizeof(p->vxlan.ipv6.da));
+			rte_ipv6_addr_cpy(&d->ipv6.src_addr, &p->vxlan.ipv6.sa);
+			rte_ipv6_addr_cpy(&d->ipv6.dst_addr, &p->vxlan.ipv6.da);
 
 			/* UDP */
 			d->udp.src_port = rte_htons(p->vxlan.udp.sp);
@@ -1211,7 +1203,7 @@ struct nat_ipv4_data {
 } __rte_packed;
 
 struct nat_ipv6_data {
-	uint8_t addr[16];
+	struct rte_ipv6_addr addr;
 	uint16_t port;
 } __rte_packed;
 
@@ -1258,7 +1250,7 @@ nat_apply(void *data,
 	} else {
 		struct nat_ipv6_data *d = data;
 
-		memcpy(d->addr, p->addr.ipv6, sizeof(d->addr));
+		rte_ipv6_addr_cpy(&d->addr, &p->addr.ipv6);
 		d->port = rte_htons(p->port);
 	}
 
@@ -1438,11 +1430,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
 				(uint16_t *)&ip->src_addr,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				tcp->src_port,
 				data->port);
 
-			rte_memcpy(&ip->src_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->src_addr, &data->addr);
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1451,11 +1443,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
 				(uint16_t *)&ip->src_addr,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				udp->src_port,
 				data->port);
 
-			rte_memcpy(&ip->src_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->src_addr, &data->addr);
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1466,11 +1458,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
 				(uint16_t *)&ip->dst_addr,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				tcp->dst_port,
 				data->port);
 
-			rte_memcpy(&ip->dst_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->dst_addr, &data->addr);
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1479,11 +1471,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
 				(uint16_t *)&ip->dst_addr.a,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(&ip->dst_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->dst_addr, &data->addr);
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
lib/pipeline/rte_table_action.h +4 -3
index 5dffbeb70031..b119ac03dc6e 100644
@@ -60,6 +60,7 @@ extern "C" {
 
 #include <rte_compat.h>
 #include <rte_ether.h>
+#include <rte_ip6.h>
 #include <rte_meter.h>
 #include <rte_table_hash.h>
 
@@ -419,8 +420,8 @@ struct rte_table_action_ipv4_header {
 
 /** Pre-computed IPv6 header fields for encapsulation action. */
 struct rte_table_action_ipv6_header {
-	uint8_t sa[16]; /**< Source address. */
-	uint8_t da[16]; /**< Destination address. */
+	struct rte_ipv6_addr sa; /**< Source address. */
+	struct rte_ipv6_addr da; /**< Destination address. */
 	uint32_t flow_label; /**< Flow label. */
 	uint8_t dscp; /**< DiffServ Code Point (DSCP). */
 	uint8_t hop_limit; /**< Hop Limit (HL). */
@@ -597,7 +598,7 @@ struct rte_table_action_nat_params {
 		uint32_t ipv4;
 
 		/** IPv6 address; only valid when *ip_version* is set to 0. */
-		uint8_t ipv6[16];
+		struct rte_ipv6_addr ipv6;
 	} addr;
 
 	/** Port. */
Signature · 1 line
2.46.0
#10 lore raw

PATCH 10/15 ipsec: use ipv6 addr struct

In reply to Robin Jarry

Update rte_ipsec_sadv6_key to use the recently introduced IPv6 address structure instead of ad-hoc uint8_t[16] arrays.

---
 app/test-sad/main.c        | 24 ++++++++++-----------
 app/test/test_ipsec_sad.c  | 44 +++++++++++++++++++-------------------
 examples/ipsec-secgw/sad.h | 10 +++++----
 lib/ipsec/rte_ipsec_sad.h  |  7 +++---
 4 files changed, 44 insertions(+), 41 deletions(-)
app/test-sad/main.c +12 -12
index addfc0714521..7253f6488dce 100644
@@ -248,8 +248,8 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 						(uint64_t)(edge + step));
 			if (config.ipv6) {
 				for (j = 0; j < 16; j++) {
-					tbl[i].tuple.v6.dip[j] = rte_rand();
-					tbl[i].tuple.v6.sip[j] = rte_rand();
+					tbl[i].tuple.v6.dip.a[j] = rte_rand();
+					tbl[i].tuple.v6.sip.a[j] = rte_rand();
 				}
 			} else {
 				tbl[i].tuple.v4.dip = rte_rand();
@@ -274,9 +274,9 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					(uint64_t)(edge + step));
 				if (config.ipv6) {
 					for (j = 0; j < 16; j++) {
-						tbl[i].tuple.v6.dip[j] =
+						tbl[i].tuple.v6.dip.a[j] =
 								rte_rand();
-						tbl[i].tuple.v6.sip[j] =
+						tbl[i].tuple.v6.sip.a[j] =
 								rte_rand();
 					}
 				} else {
@@ -289,11 +289,11 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					config.nb_rules].tuple.v4.spi;
 				if (config.ipv6) {
 					int r_idx = i % config.nb_rules;
-					memcpy(tbl[i].tuple.v6.dip,
-						rules_tbl[r_idx].tuple.v6.dip,
+					memcpy(&tbl[i].tuple.v6.dip,
+						&rules_tbl[r_idx].tuple.v6.dip,
 						sizeof(tbl[i].tuple.v6.dip));
-					memcpy(tbl[i].tuple.v6.sip,
-						rules_tbl[r_idx].tuple.v6.sip,
+					memcpy(&tbl[i].tuple.v6.sip,
+						&rules_tbl[r_idx].tuple.v6.sip,
 						sizeof(tbl[i].tuple.v6.sip));
 				} else {
 					tbl[i].tuple.v4.dip = rules_tbl[i %
@@ -472,8 +472,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &key->v4;
 	v6 = &key->v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 
 	if (res == NULL) {
 		printf("TUPLE: ");
@@ -500,8 +500,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &rule->tuple.v4;
 	v6 = &rule->tuple.v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 	printf("\n\tpoints to RULE ID %zu ",
 		RTE_PTR_DIFF(res, rules_tbl)/sizeof(struct rule));
 	print_tuple(af, spi, dip, sip);
app/test/test_ipsec_sad.c +22 -22

80 lines not on this page · raw message

examples/ipsec-secgw/sad.h +6 -4
index fdb1d2ef1790..4108abb9e698 100644
@@ -9,6 +9,8 @@
 #include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
+#include "ipsec.h"
+
 #define SA_CACHE_SZ	128
 #define SPI2IDX(spi, mask)	((spi) & (mask))
 
@@ -39,8 +41,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
+			(!memcmp(&sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
+			(!memcmp(&sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
 		return 1;
 
 	return 0;
@@ -130,9 +132,9 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
+			memcpy(&v6[nb_v6].dip, &ipv6->dst_addr,
 					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
+			memcpy(&v6[nb_v6].sip, &ipv6->src_addr,
 					sizeof(ipv6->src_addr));
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
lib/ipsec/rte_ipsec_sad.h +4 -3
index 0adf89d9310c..035ae4f3b3eb 100644
@@ -6,8 +6,9 @@
 #ifndef _RTE_IPSEC_SAD_H_
 #define _RTE_IPSEC_SAD_H_
 
-#include <stdint.h>
+#include <rte_ip6.h>
 
+#include <stdint.h>
 
 /**
  * @file rte_ipsec_sad.h
@@ -38,8 +39,8 @@ struct rte_ipsec_sadv4_key {
 
 struct rte_ipsec_sadv6_key {
 	uint32_t spi;
-	uint8_t dip[16];
-	uint8_t sip[16];
+	struct rte_ipv6_addr dip;
+	struct rte_ipv6_addr sip;
 };
 
 union rte_ipsec_sad_key {
Signature · 1 line
2.46.0
#11 lore raw

PATCH 11/15 thash: use ipv6 addr struct

In reply to Robin Jarry

Update rte_ipv6_tuple to use the recently added IPv6 address structure instead of uint8_t[16] arrays.

---
 app/test/test_thash.c | 46 ++++++++++++++++---------------------------
 lib/hash/rte_thash.h  | 20 +++++++++----------
 2 files changed, 27 insertions(+), 39 deletions(-)
app/test/test_thash.c +17 -29
index 952da6a52954..262f84433461 100644
@@ -25,8 +25,8 @@ struct test_thash_v4 {
 };
 
 struct test_thash_v6 {
-	uint8_t		dst_ip[16];
-	uint8_t		src_ip[16];
+	struct rte_ipv6_addr dst_ip;
+	struct rte_ipv6_addr src_ip;
 	uint16_t	dst_port;
 	uint16_t	src_port;
 	uint32_t	hash_l3;
@@ -49,25 +49,19 @@ struct test_thash_v4 v4_tbl[] = {
 
 struct test_thash_v6 v6_tbl[] = {
 /*3ffe:2501:200:3::1*/
-{{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x00, 0x03,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{{.a = "\x3f\xfe\x25\x01\x02\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01"},
 /*3ffe:2501:200:1fff::7*/
-{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x1f, 0xff,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,},
+{.a = "\x3f\xfe\x25\x01\x02\x00\x1f\xff\x00\x00\x00\x00\x00\x00\x00\x07"},
 1766, 2794, 0x2cc18cd5, 0x40207d3d},
 /*ff02::1*/
-{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{{.a = "\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"},
 /*3ffe:501:8::260:97ff:fe40:efab*/
-{0x3f, 0xfe, 0x05, 0x01, 0x00, 0x08, 0x00, 0x00,
-0x02, 0x60, 0x97, 0xff, 0xfe, 0x40, 0xef, 0xab,},
+{.a = "\x3f\xfe\x05\x01\x00\x08\x00\x00\x02\x60\x97\xff\xfe\x40\xef\xab"},
 4739, 14230, 0x0f0c461c, 0xdde51bbf},
 /*fe80::200:f8ff:fe21:67cf*/
-{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+{{.a = "\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x00\xf8\xff\xfe\x21\x67\xcf"},
 /*3ffe:1900:4545:3:200:f8ff:fe21:67cf*/
-{0x3f, 0xfe, 0x19, 0x00, 0x45, 0x45, 0x00, 0x03,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+{.a = "\x3f\xfe\x19\x00\x45\x45\x00\x03\x02\x00\xf8\xff\xfe\x21\x67\xcf"},
 38024, 44251, 0x4b61e985, 0x02d1feef},
 };
 
@@ -110,7 +104,7 @@ static const uint8_t big_rss_key[] = {
 static int
 test_toeplitz_hash_calc(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint8_t rss_key_be[RTE_DIM(default_rss_key)];
@@ -145,10 +139,8 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
-			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
-			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
+		rte_ipv6_addr_cpy(&ipv6_hdr.src_addr, &v6_tbl[i].src_ip);
+		rte_ipv6_addr_cpy(&ipv6_hdr.dst_addr, &v6_tbl[i].dst_ip);
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
@@ -176,7 +168,7 @@ test_toeplitz_hash_calc(void)
 static int
 test_toeplitz_hash_gfni(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint64_t rss_key_matrixes[RTE_DIM(default_rss_key)];
@@ -204,10 +196,8 @@ test_toeplitz_hash_gfni(void)
 	}
 
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
-		for (j = 0; j < RTE_DIM(tuple.v6.src_addr); j++)
-			tuple.v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple.v6.dst_addr); j++)
-			tuple.v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		rte_ipv6_addr_cpy(&tuple.v6.src_addr, &v6_tbl[i].src_ip);
+		rte_ipv6_addr_cpy(&tuple.v6.dst_addr, &v6_tbl[i].dst_ip);
 		tuple.v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple.v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rss_l3 = rte_thash_gfni(rss_key_matrixes, (uint8_t *)&tuple,
@@ -299,7 +289,7 @@ enum {
 static int
 test_toeplitz_hash_gfni_bulk(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple[2];
 	uint8_t *tuples[2];
 	uint32_t rss[2] = { 0 };
@@ -328,10 +318,8 @@ test_toeplitz_hash_gfni_bulk(void)
 		rte_memcpy(tuples[0], &tuple[0], RTE_THASH_V4_L4_LEN * 4);
 
 		/*Load IPv6 headers and copy it into the corresponding tuple*/
-		for (j = 0; j < RTE_DIM(tuple[1].v6.src_addr); j++)
-			tuple[1].v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple[1].v6.dst_addr); j++)
-			tuple[1].v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		rte_ipv6_addr_cpy(&tuple[1].v6.src_addr, &v6_tbl[i].src_ip);
+		rte_ipv6_addr_cpy(&tuple[1].v6.dst_addr, &v6_tbl[i].dst_ip);
 		tuple[1].v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple[1].v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rte_memcpy(tuples[1], &tuple[1], RTE_THASH_V6_L4_LEN * 4);
lib/hash/rte_thash.h +10 -10
index 9aaaacfd5fa4..ddc4e345097d 100644
@@ -89,8 +89,8 @@ struct rte_ipv4_tuple {
  * ports/sctp_tag have to be CPU byte order
  */
 struct rte_ipv6_tuple {
-	uint8_t		src_addr[16];
-	uint8_t		dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	union {
 		struct {
 			uint16_t dport;
@@ -141,22 +141,22 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 {
 #ifdef RTE_ARCH_X86
 	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
-	*(__m128i *)targ->v6.src_addr =
+	*(__m128i *)&targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
-	*(__m128i *)targ->v6.dst_addr =
+	*(__m128i *)&targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
-	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
-	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
+	uint8x16_t ipv6 = vld1q_u8(orig->src_addr.a);
+	vst1q_u8(targ->v6.src_addr.a, vrev32q_u8(ipv6));
+	ipv6 = vld1q_u8(orig->dst_addr.a);
+	vst1q_u8(targ->v6.dst_addr.a, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
-		*((uint32_t *)targ->v6.src_addr + i) =
+		*((uint32_t *)targ->v6.src_addr.a + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr.a + i));
-		*((uint32_t *)targ->v6.dst_addr + i) =
+		*((uint32_t *)targ->v6.dst_addr.a + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr.a + i));
 	}
 #endif
Signature · 1 line
2.46.0
#12 lore raw

PATCH 12/15 gro: use ipv6 addr struct

In reply to Robin Jarry

Update tcp6_flow_key to use the recently introduced IPv6 address structure instead of uint8_t[16] arrays.

---
 lib/gro/gro_tcp6.c | 8 ++++----
 lib/gro/gro_tcp6.h | 6 ++++--
 2 files changed, 8 insertions(+), 6 deletions(-)
lib/gro/gro_tcp6.c +4 -4
index 6edfb6045cf6..0c6adbf2ecdb 100644
@@ -99,8 +99,8 @@ insert_new_flow(struct gro_tcp6_tbl *tbl,
 	dst = &(tbl->flows[flow_idx].key);
 
 	ASSIGN_COMMON_TCP_KEY((&src->cmn_key), (&dst->cmn_key));
-	memcpy(&dst->src_addr[0], &src->src_addr[0], sizeof(dst->src_addr));
-	memcpy(&dst->dst_addr[0], &src->dst_addr[0], sizeof(dst->dst_addr));
+	rte_ipv6_addr_cpy(&dst->src_addr, &src->src_addr);
+	rte_ipv6_addr_cpy(&dst->dst_addr, &src->dst_addr);
 	dst->vtc_flow = src->vtc_flow;
 
 	tbl->flows[flow_idx].start_index = item_idx;
@@ -168,8 +168,8 @@ gro_tcp6_reassemble(struct rte_mbuf *pkt,
 
 	rte_ether_addr_copy(&(eth_hdr->src_addr), &(key.cmn_key.eth_saddr));
 	rte_ether_addr_copy(&(eth_hdr->dst_addr), &(key.cmn_key.eth_daddr));
-	memcpy(&key.src_addr[0], &ipv6_hdr->src_addr, sizeof(key.src_addr));
-	memcpy(&key.dst_addr[0], &ipv6_hdr->dst_addr, sizeof(key.dst_addr));
+	rte_ipv6_addr_cpy(&key.src_addr, &ipv6_hdr->src_addr);
+	rte_ipv6_addr_cpy(&key.dst_addr, &ipv6_hdr->dst_addr);
 	key.cmn_key.src_port = tcp_hdr->src_port;
 	key.cmn_key.dst_port = tcp_hdr->dst_port;
 	key.cmn_key.recv_ack = tcp_hdr->recv_ack;
lib/gro/gro_tcp6.h +4 -2
index 073122f0ec84..acf3971bb6e9 100644
@@ -5,6 +5,8 @@
 #ifndef _GRO_TCP6_H_
 #define _GRO_TCP6_H_
 
+#include <rte_ip6.h>
+
 #include "gro_tcp.h"
 
 #define GRO_TCP6_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
@@ -12,8 +14,8 @@
 /* Header fields representing a TCP/IPv6 flow */
 struct tcp6_flow_key {
 	struct cmn_tcp_key cmn_key;
-	uint8_t  src_addr[16];
-	uint8_t  dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	rte_be32_t vtc_flow;
 };
 
Signature · 1 line
2.46.0
#13 lore raw

PATCH 13/15 rte_flow: use ipv6 addr struct

In reply to Robin Jarry

Update rte_flow_tunnel, rte_flow_action_set_ipv6, rte_flow_item_icmp6_nd_na and rte_flow_item_icmp6_nd_ns to use the recently introduced IPv6 address structure instead of uint8_t[16] arrays.

Update all code accordingly.

---
 app/test-flow-perf/actions_gen.c         |  4 ++--
 drivers/net/cxgbe/cxgbe_flow.c           |  4 ++--
 drivers/net/nfp/flower/nfp_flower_flow.c |  2 +-
 lib/ethdev/rte_flow.h                    | 16 +++++++++-------
 4 files changed, 14 insertions(+), 12 deletions(-)
app/test-flow-perf/actions_gen.c +2 -2
index b5336e83ff9f..54fcbacb98ce 100644
@@ -304,7 +304,7 @@ add_set_src_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
@@ -327,7 +327,7 @@ add_set_dst_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
drivers/net/cxgbe/cxgbe_flow.c +2 -2
index 37c566b131e9..00c55af4bcc6 100644
@@ -680,7 +680,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_fip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_fip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 0;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
@@ -693,7 +693,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_lip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_lip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 1;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
drivers/net/nfp/flower/nfp_flower_flow.c +1 -1
index 3f597d394b24..6db1fb141d3e 100644
@@ -2978,7 +2978,7 @@ nfp_flow_action_set_ipv6(char *act_data,
 	set_ip->reserved = 0;
 
 	for (i = 0; i < 4; i++) {
-		rte_memcpy(&tmp, &set_ipv6->ipv6_addr[i * 4], 4);
+		rte_memcpy(&tmp, &set_ipv6->ipv6_addr.a[i * 4], 4);
 		set_ip->ipv6[i].exact = tmp;
 		set_ip->ipv6[i].mask = RTE_BE32(0xffffffff);
 	}
lib/ethdev/rte_flow.h +9 -7
index b3ede7ccdaef..628292c1df07 100644
@@ -1505,16 +1505,17 @@ struct rte_flow_item_icmp6_nd_ns {
 	uint8_t code; /**< ICMPv6 code, normally 0. */
 	rte_be16_t checksum; /**< ICMPv6 checksum. */
 	rte_be32_t reserved; /**< Reserved, normally 0. */
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
-	.target_addr =
+	.target_addr = {
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+	}
 };
 #endif
 
@@ -1532,16 +1533,17 @@ struct rte_flow_item_icmp6_nd_na {
 	 * reserved (29b).
 	 */
 	rte_be32_t rso_reserved;
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
-	.target_addr =
+	.target_addr = {
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+	}
 };
 #endif
 
@@ -3812,7 +3814,7 @@ struct rte_flow_action_set_ipv4 {
  * specified outermost IPv6 header.
  */
 struct rte_flow_action_set_ipv6 {
-	uint8_t ipv6_addr[16];
+	struct rte_ipv6_addr ipv6_addr;
 };
 
 /**
@@ -5196,8 +5198,8 @@ struct rte_flow_tunnel {
 			rte_be32_t dst_addr; /**< IPv4 destination address. */
 		} ipv4;
 		struct {
-			uint8_t src_addr[16]; /**< IPv6 source address. */
-			uint8_t dst_addr[16]; /**< IPv6 destination address. */
+			struct rte_ipv6_addr src_addr; /**< IPv6 source address. */
+			struct rte_ipv6_addr dst_addr; /**< IPv6 destination address. */
 		} ipv6;
 	};
 	rte_be16_t tp_src; /**< Tunnel port source. */
Signature · 1 line
2.46.0
#14 lore raw

PATCH 14/15 rib6,fib6,lpm6: remove duplicate constants

In reply to Robin Jarry

Replace all address size and max depth macros with common ones from rte_ip6.h.

---
 app/test/test_fib6.c | 50 ++++++++++++++++++++++----------------------
 lib/fib/rte_fib6.c   |  6 +++---
 lib/fib/rte_fib6.h   |  4 ----
 lib/fib/trie.c       |  6 +++---
 lib/fib/trie.h       |  2 --
 lib/lpm/rte_lpm6.c   | 10 ++++-----
 lib/lpm/rte_lpm6.h   |  3 ---
 lib/rib/rte_rib6.c   | 11 +++++-----
 lib/rib/rte_rib6.h   |  6 ++----
 9 files changed, 43 insertions(+), 55 deletions(-)
app/test/test_fib6.c +25 -25
index 7134c4d335cd..812da01d6e33 100644
@@ -170,13 +170,13 @@ test_add_del_invalid(void)
 	fib = rte_fib6_create(__func__, SOCKET_ID_ANY, &config);
 	RTE_TEST_ASSERT(fib != NULL, "Failed to create FIB\n");
 
-	/* rte_fib6_add: depth > RTE_FIB6_MAXDEPTH */
-	ret = rte_fib6_add(fib, &ip, RTE_FIB6_MAXDEPTH + 1, nh);
+	/* rte_fib6_add: depth > RTE_IPV6_MAX_DEPTH */
+	ret = rte_fib6_add(fib, &ip, RTE_IPV6_MAX_DEPTH + 1, nh);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 
-	/* rte_fib6_delete: depth > RTE_FIB6_MAXDEPTH */
-	ret = rte_fib6_delete(fib, &ip, RTE_FIB6_MAXDEPTH + 1);
+	/* rte_fib6_delete: depth > RTE_IPV6_MAX_DEPTH */
+	ret = rte_fib6_delete(fib, &ip, RTE_IPV6_MAX_DEPTH + 1);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 
@@ -216,18 +216,18 @@ lookup_and_check_asc(struct rte_fib6 *fib,
 	struct rte_ipv6_addr *ip_missing, uint64_t def_nh,
 	uint32_t n)
 {
-	uint64_t nh_arr[RTE_FIB6_MAXDEPTH];
+	uint64_t nh_arr[RTE_IPV6_MAX_DEPTH];
 	int ret;
 	uint32_t i = 0;
 
-	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH);
+	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH);
 	RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n");
 
-	for (; i <= RTE_FIB6_MAXDEPTH - n; i++)
+	for (; i <= RTE_IPV6_MAX_DEPTH - n; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == n,
 			"Failed to get proper nexthop\n");
 
-	for (; i < RTE_FIB6_MAXDEPTH; i++)
+	for (; i < RTE_IPV6_MAX_DEPTH; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == --n,
 			"Failed to get proper nexthop\n");
 
@@ -244,18 +244,18 @@ lookup_and_check_desc(struct rte_fib6 *fib,
 	struct rte_ipv6_addr *ip_missing, uint64_t def_nh,
 	uint32_t n)
 {
-	uint64_t nh_arr[RTE_FIB6_MAXDEPTH];
+	uint64_t nh_arr[RTE_IPV6_MAX_DEPTH];
 	int ret;
 	uint32_t i = 0;
 
-	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH);
+	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH);
 	RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n");
 
 	for (; i < n; i++)
-		RTE_TEST_ASSERT(nh_arr[i] == RTE_FIB6_MAXDEPTH - i,
+		RTE_TEST_ASSERT(nh_arr[i] == RTE_IPV6_MAX_DEPTH - i,
 			"Failed to get proper nexthop\n");
 
-	for (; i < RTE_FIB6_MAXDEPTH; i++)
+	for (; i < RTE_IPV6_MAX_DEPTH; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == def_nh,
 			"Failed to get proper nexthop\n");
 
@@ -270,7 +270,7 @@ static int
 check_fib(struct rte_fib6 *fib)
 {
 	uint64_t def_nh = 100;
-	struct rte_ipv6_addr ip_arr[RTE_FIB6_MAXDEPTH];
+	struct rte_ipv6_addr ip_arr[RTE_IPV6_MAX_DEPTH];
 	struct rte_ipv6_addr ip_add = {.a = {[0] = 128}};
 	struct rte_ipv6_addr ip_missing = {
 		.a = {[0] = 127, [1 ... 15] = 255},
@@ -278,12 +278,12 @@ check_fib(struct rte_fib6 *fib)
 	uint32_t i, j;
 	int ret;
 
-	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) {
 		rte_ipv6_addr_cpy(&ip_arr[i], &ip_add);
-		j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT;
-		if (j < RTE_FIB6_IPV6_ADDR_SIZE) {
-			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT);
-			for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++)
+		j = (RTE_IPV6_MAX_DEPTH - i) / CHAR_BIT;
+		if (j < RTE_IPV6_ADDR_SIZE) {
+			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_IPV6_MAX_DEPTH - i) % CHAR_BIT);
+			for (j++; j < RTE_IPV6_ADDR_SIZE; j++)
 				ip_arr[i].a[j] = 0xff;
 		}
 	}
@@ -291,7 +291,7 @@ check_fib(struct rte_fib6 *fib)
 	ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh, 0);
 	RTE_TEST_ASSERT(ret == TEST_SUCCESS, "Lookup and check fails\n");
 
-	for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) {
 		ret = rte_fib6_add(fib, &ip_add, i, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n");
 		ret = lookup_and_check_asc(fib, ip_arr, &ip_missing, def_nh, i);
@@ -299,7 +299,7 @@ check_fib(struct rte_fib6 *fib)
 			"Lookup and check fails\n");
 	}
 
-	for (i = RTE_FIB6_MAXDEPTH; i > 1; i--) {
+	for (i = RTE_IPV6_MAX_DEPTH; i > 1; i--) {
 		ret = rte_fib6_delete(fib, &ip_add, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n");
 		ret = lookup_and_check_asc(fib, ip_arr, &ip_missing,
@@ -314,9 +314,9 @@ check_fib(struct rte_fib6 *fib)
 	RTE_TEST_ASSERT(ret == TEST_SUCCESS,
 		"Lookup and check fails\n");
 
-	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
-		ret = rte_fib6_add(fib, &ip_add, RTE_FIB6_MAXDEPTH - i,
-			RTE_FIB6_MAXDEPTH - i);
+	for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) {
+		ret = rte_fib6_add(fib, &ip_add, RTE_IPV6_MAX_DEPTH - i,
+			RTE_IPV6_MAX_DEPTH - i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n");
 		ret = lookup_and_check_desc(fib, ip_arr, &ip_missing,
 			def_nh, i + 1);
@@ -324,11 +324,11 @@ check_fib(struct rte_fib6 *fib)
 			"Lookup and check fails\n");
 	}
 
-	for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) {
 		ret = rte_fib6_delete(fib, &ip_add, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n");
 		ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh,
-			RTE_FIB6_MAXDEPTH - i);
+			RTE_IPV6_MAX_DEPTH - i);
 		RTE_TEST_ASSERT(ret == TEST_SUCCESS,
 			"Lookup and check fails\n");
 	}
lib/fib/rte_fib6.c +3 -3
index d95cac79cbb5..9c7d4fde433a 100644
@@ -71,7 +71,7 @@ dummy_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop, int op)
 {
 	struct rte_rib6_node *node;
-	if ((fib == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	node = rte_rib6_lookup_exact(fib->rib, ip, depth);
@@ -123,7 +123,7 @@ rte_fib6_add(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, next_hop, RTE_FIB6_ADD);
 }
@@ -133,7 +133,7 @@ rte_fib6_delete(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, 0, RTE_FIB6_DEL);
 }
lib/fib/rte_fib6.h +0 -4
index d26a0c7c0b77..2e3636b3bd29 100644
@@ -23,10 +23,6 @@
 extern "C" {
 #endif
 
-#define RTE_FIB6_IPV6_ADDR_SIZE		16
-/** Maximum depth value possible for IPv6 FIB. */
-#define RTE_FIB6_MAXDEPTH       128
-
 struct rte_fib6;
 struct rte_rib6;
 
lib/fib/trie.c +3 -3
index 8a69702eabb2..7c0af20625c1 100644
@@ -350,9 +350,9 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
 	return ret;
 }
 
-#define IPV6_MAX_IDX	(RTE_FIB6_IPV6_ADDR_SIZE - 1)
+#define IPV6_MAX_IDX	(RTE_IPV6_ADDR_SIZE - 1)
 #define TBL24_BYTES	3
-#define TBL8_LEN	(RTE_FIB6_IPV6_ADDR_SIZE - TBL24_BYTES)
+#define TBL8_LEN	(RTE_IPV6_ADDR_SIZE - TBL24_BYTES)
 
 static int
 install_to_dp(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ledge,
@@ -518,7 +518,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint64_t par_nh, node_nh;
 	uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
 
-	if ((fib == NULL) || (ip == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (ip == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	dp = rte_fib6_get_dp(fib);
lib/fib/trie.h +0 -2
index 6e235edaf89c..77f1d95f4316 100644
@@ -17,8 +17,6 @@
 
 /* @internal Total number of tbl24 entries. */
 #define TRIE_TBL24_NUM_ENT	(1 << 24)
-/* Maximum depth value possible for IPv6 LPM. */
-#define TRIE_MAX_DEPTH		128
 /* @internal Number of entries in a tbl8 group. */
 #define TRIE_TBL8_GRP_NUM_ENT	256ULL
 /* @internal Total number of tbl8 groups in the tbl8. */
lib/lpm/rte_lpm6.c +5 -5
index 642b02b32cc2..c54726483a1a 100644
@@ -802,7 +802,7 @@ simulate_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *masked_ip, uint8_
 	 * Inspect one by one the rest of the bytes until
 	 * the process is completed.
 	 */
-	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) {
+	for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && ret == 1; i++) {
 		tbl = tbl_next;
 		ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
 			(uint8_t)(i + 1), depth, &need_tbl_nb);
@@ -832,7 +832,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 	int i;
 
 	/* Check user arguments. */
-	if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+	if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
@@ -861,7 +861,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 	 * Inspect one by one the rest of the bytes until
 	 * the process is completed.
 	 */
-	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && status == 1; i++) {
+	for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && status == 1; i++) {
 		tbl = tbl_next;
 		status = add_step(lpm, tbl, tbl_next_num, &tbl_next,
 			&tbl_next_num, &masked_ip, 1, (uint8_t)(i + 1),
@@ -993,7 +993,7 @@ rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, u
 
 	/* Check user arguments. */
 	if ((lpm == NULL) || next_hop == NULL || ip == NULL ||
-			(depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+			(depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
@@ -1267,7 +1267,7 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t de
 	struct rte_lpm6_tbl_entry *from, *to;
 
 	/* Check input arguments. */
-	if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+	if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
lib/lpm/rte_lpm6.h +0 -3
index 87392194237c..19b498a78d5d 100644
@@ -17,9 +17,6 @@
 extern "C" {
 #endif
 
-
-#define RTE_LPM6_MAX_DEPTH               128
-#define RTE_LPM6_IPV6_ADDR_SIZE           16
 /** Max number of characters in LPM name. */
 #define RTE_LPM6_NAMESIZE                 32
 
lib/rib/rte_rib6.c +5 -6
index ec46c865ddf7..207ece0507dd 100644
@@ -20,7 +20,6 @@
 #include "rib_log.h"
 
 #define RTE_RIB_VALID_NODE	1
-#define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
 #define RTE_RIB6_NAMESIZE	64
 
@@ -89,7 +88,7 @@ static inline struct rte_rib6_node *
 get_nxt_node(struct rte_rib6_node *node,
 	const struct rte_ipv6_addr *ip)
 {
-	if (node->depth == RIB6_MAXDEPTH)
+	if (node->depth == RTE_IPV6_MAX_DEPTH)
 		return NULL;
 
 	return (get_dir(ip, node->depth)) ? node->right : node->left;
@@ -158,7 +157,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib,
 	struct rte_rib6_node *cur;
 	struct rte_ipv6_addr tmp_ip;
 
-	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -196,7 +195,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib,
 	struct rte_rib6_node *tmp, *prev = NULL;
 	struct rte_ipv6_addr tmp_ip;
 
-	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -279,7 +278,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 	int i, d;
 	uint8_t common_depth, ip_xor;
 
-	if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) {
+	if (unlikely((rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH))) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -341,7 +340,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 
 	/* closest node found, new_node should be inserted in the middle */
 	common_depth = RTE_MIN(depth, (*tmp)->depth);
-	for (i = 0, d = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0, d = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		ip_xor = tmp_ip.a[i] ^ (*tmp)->ip.a[i];
 		if (ip_xor == 0)
 			d += 8;
lib/rib/rte_rib6.h +2 -4
index fcf4169ca790..0e72766876ed 100644
@@ -22,8 +22,6 @@
 extern "C" {
 #endif
 
-#define RTE_RIB6_IPV6_ADDR_SIZE	16
-
 /**
  * rte_rib6_get_nxt() flags
  */
@@ -65,7 +63,7 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
 	if ((dst == NULL) || (src == NULL))
 		return;
-	rte_memcpy(dst, src, RTE_RIB6_IPV6_ADDR_SIZE);
+	rte_memcpy(dst, src, RTE_IPV6_ADDR_SIZE);
 }
 
 /**
@@ -89,7 +87,7 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 
 	if ((ip1 == NULL) || (ip2 == NULL))
 		return 0;
-	for (i = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		if (ip1[i] != ip2[i])
 			return 0;
 	}
Signature · 1 line
2.46.0
#15 lore raw

PATCH 15/15 net: add utilities for well known ipv6 address types

In reply to Robin Jarry

Add more utilities to work with IPv6 addresses. These functions will be required in order to help building IPv6 routing applications.

---
 app/test/test_net_ipv6.c | 74 ++++++++++++++++++++++++++++++
 lib/net/rte_ip6.h        | 98 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+)
app/test/test_net_ipv6.c +74 -0
index c2b42d67285e..b087b5c60d73 100644
@@ -93,26 +93,97 @@ static int
 test_ipv6_addr_kind(void)
 {
 	TEST_ASSERT(rte_ipv6_addr_is_unspec(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&zero_addr), "");
 
 	struct rte_ipv6_addr ucast = {
 		"\x2a\x01\xcb\x00\x02\x54\x33\x00\x62\x39\xe1\xf4\x7a\x0b\x23\x71"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&ucast), "");
 
 	struct rte_ipv6_addr mcast = {
 		"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&mcast), "");
+	TEST_ASSERT(rte_ipv6_addr_is_mcast(&mcast), "");
 
 	struct rte_ipv6_addr lo = {
 		"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&lo), "");
+	TEST_ASSERT(rte_ipv6_addr_is_loopback(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&lo), "");
 
 	struct rte_ipv6_addr local = {
 		"\xfe\x80\x00\x00\x00\x00\x00\x00\x5a\x84\xc5\x2c\x6a\xef\x46\x39"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&local), "");
+	TEST_ASSERT(rte_ipv6_addr_is_linklocal(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&local), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_llocal_from_ethernet(void)
+{
+	const struct rte_ether_addr local_mac = { "\x04\x7b\xcb\x5c\x08\x44" };
+	const struct rte_ipv6_addr local_ip = {
+		"\xfe\x80\x00\x00\x00\x00\x00\x00\x04\x7b\xcb\xff\xfe\x5c\x08\x44"
+	};
+	struct rte_ipv6_addr ip;
+
+	rte_ipv6_llocal_from_ethernet(&ip, &local_mac);
+	TEST_ASSERT(rte_ipv6_addr_eq(&ip, &local_ip), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_solnode_from_addr(void)
+{
+	struct rte_ipv6_addr sol;
+
+	const struct rte_ipv6_addr llocal = {
+		"\xfe\x80\x00\x00\x00\x00\x00\x00\x04\x7b\xcb\xff\xfe\x5c\x08\x44"
+	};
+	const struct rte_ipv6_addr llocal_sol = {
+		"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x5c\x08\x44"
+	};
+	rte_ipv6_solnode_from_addr(&sol, &llocal);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &llocal_sol), "");
+
+	const struct rte_ipv6_addr ucast = {
+		"\x2a\x01\xcb\x00\x02\x54\x33\x00\x1b\x9f\x80\x71\x67\xcd\xbf\x20"
+	};
+	const struct rte_ipv6_addr ucast_sol = {
+		"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\xcd\xbf\x20"
+	};
+	rte_ipv6_solnode_from_addr(&sol, &ucast);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &ucast_sol), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ether_mcast_from_ipv6(void)
+{
+	const struct rte_ether_addr mcast_mac = { "\x33\x33\xd3\x00\x02\x01" };
+	const struct rte_ipv6_addr mcast_ip = {
+		"\xff\x02\x00\x00\x00\x00\x02\x01\x00\x00\x00\x00\xd3\x00\x02\x01"
+	};
+	struct rte_ether_addr mac;
+
+	rte_ether_mcast_from_ipv6(&mac, &mcast_ip);
+	TEST_ASSERT(rte_is_same_ether_addr(&mac, &mcast_mac), "");
 
 	return TEST_SUCCESS;
 }
@@ -123,6 +194,9 @@ test_net_ipv6(void)
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_llocal_from_ethernet(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_solnode_from_addr(), "");
+	TEST_ASSERT_SUCCESS(test_ether_mcast_from_ipv6(), "");
 	return TEST_SUCCESS;
 }
 
lib/net/rte_ip6.h +98 -0

110 lines not on this page · raw message

Signature · 1 line
2.46.0
Acked-by on the v1 series
#16 lore raw
In reply to Robin Jarry
Quoted 32 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Wednesday, 21 August 2024 18.25

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The
API change was announced before the 24.07 release [2]. This series is intended
for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2]
https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1
b5764

I tried to keep the patches as small as possible; unfortunately some of them
are quite big and cannot be broken down if we want to preserve a bisectable
tree.

Let me know what you think.

Thanks!

Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Bruce Richardson <[email protected]>
Quoted 16 lines

Robin Jarry (15):
net: split raw checksum functions in separate header
net: split ipv6 symbols in separate header
net: add structure for ipv6 addresses
net: use ipv6 structure for header addresses fib6,rib6,lpm6: use ipv6 addr struct
net: add ipv6 address utilities fib6,rib6,lpm6: use ipv6 utils
graph,node: use ipv6 addr struct and utils
pipeline: use ipv6 addr struct
ipsec: use ipv6 addr struct
thash: use ipv6 addr struct
gro: use ipv6 addr struct
rte_flow: use ipv6 addr struct rib6,fib6,lpm6: remove duplicate constants
net: add utilities for well known ipv6 address types

LGTM.

For the series,

#17 lore raw
In reply to Robin Jarry
Quoted 6 lines · On Wed, 21 Aug 2024 18:25:17 +0200 Robin Jarry <[email protected]> wrote:

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

Quoted 8 lines

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Let me ask a couple of questions about this.

Why does DPDK need to have its own definitions of IPv4 and IPv6 addresses? The structures in_addr and in6_addr exist on Linux, BSD, and Windows. It creates lots of code reimplementation (see inet_ntop etc).

What advantage is there to having our own definitions?

#18 lore raw
Quoted 23 lines

From: Stephen Hemminger [mailto:[email protected]]

Quoted 3 lines · On Wed, 21 Aug 2024 18:25:17 +0200 Robin Jarry <[email protected]> wrote:

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework.

The

Quoted 1 line

API change was announced before the 24.07 release [2]. This series is

intended

Quoted 4 lines

for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2]

https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

Quoted 6 lines

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Quoted 8 lines

Let me ask a couple of questions about this.

Why does DPDK need to have its own definitions of IPv4 and IPv6 addresses? The structures in_addr and in6_addr exist on Linux, BSD, and Windows. It creates lots of code reimplementation (see inet_ntop etc).

What advantage is there to having our own definitions?

The types seem to be different in the Windows API (than in Linux/BSD):
https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.14393.0/shared/in6addr.h#L25
https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/inaddr.h#L25

Furthermore, but less important:
The existing in the Linux/BSD/Windows IPv6 address type are 2-byte aligned.
In the RFC discussion, we agreed to omit any alignment requirements for the DPDK IPv6 address, for tunneling purposes. We could introduce 2-byte alignment later, using a union and an array of uint16_t, if beneficial.

Which makes me think...
Maybe the 'a' field in the DPDK IPv6 address structure should be named 'b' for "byte" instead, to prepare it for adding a union with a 'w' (for "word") field if we want to introduce 2-byte alignment.

#19 lore raw

Morten Brørup, Aug 22, 2024 at 17:13:

Quoted 6 lines

The types seem to be different in the Windows API (than in Linux/BSD):
https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.14393.0/shared/in6addr.h#L25
https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/shared/inaddr.h#L25

Furthermore, but less important:
The existing in the Linux/BSD/Windows IPv6 address type are 2-byte aligned.

At least BSD is 4 bytes aligned.

https://github.com/freebsd/freebsd-src/blob/498286d4e807d6b9e4caad22b96ebca7f16e9b18/sys/netinet6/in6.h#L91-L100

And on Linux, it depends on the libc implementation?

https://github.com/torvalds/linux/blob/872cf28b8df9c5c3a1e71a88ee750df7c2513971/include/uapi/linux/in6.h#L33

Quoted 5 lines

In the RFC discussion, we agreed to omit any alignment requirements for the DPDK IPv6 address, for tunneling purposes. We could introduce 2-byte alignment later, using a union and an array of uint16_t, if beneficial.

Which makes me think...
Maybe the 'a' field in the DPDK IPv6 address structure should be named 'b' for "byte" instead, to prepare it for adding a union with a 'w' (for "word") field if we want to introduce 2-byte alignment.

My idea was to name the field a16 instead of w which would be confusing. Also, how would you name a 32 bit array field if it presented itself?

#20 lore raw
Quoted 10 lines

From: Robin Jarry [mailto:[email protected]]

Morten Brørup, Aug 22, 2024 at 17:13:

Quoted 1 line

Maybe the 'a' field in the DPDK IPv6 address structure should be named

'b' for "byte" instead, to prepare it for adding a union with a 'w' (for "word") field if we want to introduce 2-byte alignment.

My idea was to name the field a16 instead of w which would be confusing. Also, how would you name a 32 bit array field if it presented itself?

Good question, I have no obvious suggestion for this. Which again goes to show that naming is hard.

Perhaps we should lean on the names of types and functions using 32 for 32 bit versions and 64 for 64 bit variants. Then the union fields could be named a8[16], a16[8] and a32[4].

Other projects follow a convention of including the type in the variable/parameter names, e.g. the Win32 API. But DPDK doesn't, so it seems strange doing it here.

#21 lore raw
In reply to Stephen Hemminger

Stephen Hemminger, Aug 22, 2024 at 16:13:

Quoted 7 lines

Let me ask a couple of questions about this.

Why does DPDK need to have its own definitions of IPv4 and IPv6 addresses? The structures in_addr and in6_addr exist on Linux, BSD, and Windows. It creates lots of code reimplementation (see inet_ntop etc).

What advantage is there to having our own definitions?

If I'm not mistaken, in6_addr is aligned on 4 bytes. Is it guaranteed that IPv6 headers will *always* be starting on a 4 bytes boundary? If not then, in6_addr cannot be mapped on unaligned packet memory.

#22 lore raw
In reply to Stephen Hemminger

Stephen Hemminger, Aug 22, 2024 at 16:13:

Quoted 3 lines

Why does DPDK need to have its own definitions of IPv4 and IPv6 addresses? The structures in_addr and in6_addr exist on Linux, BSD, and Windows. It creates lots of code reimplementation (see inet_ntop etc).

By the way, you can call inet_ntop(AF_INET6) with the rte_ipv6_addr type I introduce here. It works fine.

#23 lore raw

v2 cover IPv6 APIs overhaul

In reply to Robin Jarry

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Thanks!

Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Bruce Richardson <[email protected]>

Changelog:

v2:

- added RTE_IPV6_ADDR helper macro
- added more multicast address utils
- updated 24.11 changelog
- added ipv6 header version check function

Robin Jarry (16):
net: split raw checksum functions in separate header
net: split ipv6 symbols in separate header
net: add structure for ipv6 addresses
net: use ipv6 structure for header addresses fib6,rib6,lpm6: use ipv6 addr struct
net: add ipv6 address utilities fib6,rib6,lpm6: use ipv6 utils
graph,node: use ipv6 addr struct and utils
pipeline: use ipv6 addr struct
ipsec: use ipv6 addr struct
thash: use ipv6 addr struct
gro: use ipv6 addr struct
rte_flow: use ipv6 addr struct rib6,fib6,lpm6: remove duplicate constants
net: add utilities for well known ipv6 address types
ipv6: add function to check ipv6 version

 MAINTAINERS                                 |    1 +
 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 +-
 app/test-fib/main.c                         |   51 +-
 app/test-flow-perf/actions_gen.c            |    4 +-
 app/test-flow-perf/items_gen.c              |    4 +-
 app/test-pipeline/pipeline_hash.c           |    4 +-
 app/test-pipeline/pipeline_lpm_ipv6.c       |   10 +-
 app/test-sad/main.c                         |   24 +-
 app/test/meson.build                        |    1 +
 app/test/packet_burst_generator.c           |    5 +-
 app/test/test_cryptodev_security_ipsec.c    |    1 +
 app/test/test_fib6.c                        |   93 +-
 app/test/test_fib6_perf.c                   |    8 +-
 app/test/test_ipfrag.c                      |    4 +-
 app/test/test_ipsec_sad.c                   |   44 +-
 app/test/test_lpm6.c                        |  523 ++---
 app/test/test_lpm6_data.h                   | 2025 ++++++++++---------
 app/test/test_lpm6_perf.c                   |   10 +-
 app/test/test_net_ipv6.c                    |  219 ++
 app/test/test_reassembly_perf.c             |   20 +-
 app/test/test_rib6.c                        |   65 +-
 app/test/test_table_combined.c              |    2 +-
 app/test/test_table_tables.c                |    8 +-
 app/test/test_thash.c                       |   46 +-
 doc/guides/rel_notes/deprecation.rst        |   42 -
 doc/guides/rel_notes/release_24_11.rst      |   17 +
 drivers/common/cnxk/cnxk_security.c         |    1 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |    1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |    1 +
 drivers/net/bnxt/bnxt_flow.c                |   12 +-
 drivers/net/bonding/rte_eth_bond_pmd.c      |    4 +-
 drivers/net/cxgbe/cxgbe_flow.c              |   18 +-
 drivers/net/dpaa2/dpaa2_flow.c              |   22 +-
 drivers/net/hinic/hinic_pmd_flow.c          |    6 +-
 drivers/net/hinic/hinic_pmd_tx.c            |    2 +-
 drivers/net/hns3/hns3_flow.c                |    8 +-
 drivers/net/i40e/i40e_flow.c                |   12 +-
 drivers/net/iavf/iavf_fdir.c                |    8 +-
 drivers/net/iavf/iavf_fsub.c                |    8 +-
 drivers/net/iavf/iavf_ipsec_crypto.c        |    6 +-
 drivers/net/ice/ice_fdir_filter.c           |   12 +-
 drivers/net/ice/ice_switch_filter.c         |   16 +-
 drivers/net/igc/igc_flow.c                  |    4 +-
 drivers/net/ixgbe/ixgbe_flow.c              |   12 +-
 drivers/net/ixgbe/ixgbe_ipsec.c             |    4 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c       |   36 +-
 drivers/net/mlx5/mlx5_flow.c                |    6 +-
 drivers/net/mlx5/mlx5_flow_dv.c             |   16 +-
 drivers/net/mlx5/mlx5_flow_hw.c             |   10 +-
 drivers/net/mlx5/mlx5_flow_verbs.c          |    8 +-
 drivers/net/nfp/flower/nfp_flower_flow.c    |   36 +-
 drivers/net/nfp/nfp_net_flow.c              |   44 +-
 drivers/net/qede/qede_filter.c              |    4 +-
 drivers/net/sfc/sfc_flow.c                  |   28 +-
 drivers/net/tap/tap_flow.c                  |    8 +-
 drivers/net/txgbe/txgbe_flow.c              |   12 +-
 drivers/net/txgbe/txgbe_ipsec.c             |    4 +-
 examples/ip_fragmentation/main.c            |   24 +-
 examples/ip_pipeline/cli.c                  |   12 +-
 examples/ip_pipeline/pipeline.c             |   17 +-
 examples/ip_pipeline/thread.c               |    2 +-
 examples/ip_reassembly/main.c               |   24 +-
 examples/ipsec-secgw/flow.c                 |   12 +-
 examples/ipsec-secgw/ipsec.c                |    8 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h       |    7 +-
 examples/ipsec-secgw/ipsec_worker.c         |    6 +-
 examples/ipsec-secgw/ipsec_worker.h         |    4 +-
 examples/ipsec-secgw/rt.c                   |   22 +-
 examples/ipsec-secgw/sa.c                   |    4 +-
 examples/ipsec-secgw/sad.h                  |   12 +-
 examples/l3fwd-graph/main.c                 |   30 +-
 examples/l3fwd/l3fwd_fib.c                  |   39 +-
 examples/l3fwd/l3fwd_lpm.c                  |    8 +-
 examples/l3fwd/l3fwd_route.h                |    7 +-
 examples/l3fwd/lpm_route_parse.c            |    6 +-
 lib/ethdev/rte_flow.h                       |   23 +-
 lib/fib/meson.build                         |    4 +-
 lib/fib/rte_fib6.c                          |   19 +-
 lib/fib/rte_fib6.h                          |   15 +-
 lib/fib/trie.c                              |  117 +-
 lib/fib/trie.h                              |   18 +-
 lib/fib/trie_avx512.c                       |   38 +-
 lib/fib/trie_avx512.h                       |   10 +-
 lib/gro/gro_tcp6.c                          |    8 +-
 lib/gro/gro_tcp6.h                          |    6 +-
 lib/hash/rte_thash.h                        |   29 +-
 lib/ip_frag/rte_ip_frag.h                   |    1 +
 lib/ip_frag/rte_ipv6_reassembly.c           |    4 +-
 lib/ipsec/iph.h                             |    1 +
 lib/ipsec/rte_ipsec_sad.h                   |    7 +-
 lib/lpm/meson.build                         |    1 +
 lib/lpm/rte_lpm6.c                          |  147 +-
 lib/lpm/rte_lpm6.h                          |   17 +-
 lib/net/meson.build                         |    2 +
 lib/net/rte_cksum.h                         |  180 ++
 lib/net/rte_ip.h                            |  467 +----
 lib/net/rte_ip6.h                           |  654 ++++++
 lib/net/rte_net.c                           |    1 +
 lib/net/rte_net.h                           |    1 +
 lib/node/ip6_lookup.c                       |   21 +-
 lib/node/rte_node_ip6_api.h                 |    3 +-
 lib/pipeline/rte_swx_ipsec.c                |    7 +-
 lib/pipeline/rte_table_action.c             |   45 +-
 lib/pipeline/rte_table_action.h             |    7 +-
 lib/rib/meson.build                         |    2 +-
 lib/rib/rte_rib6.c                          |  112 +-
 lib/rib/rte_rib6.h                          |   27 +-
 lib/table/rte_table_lpm_ipv6.c              |   12 +-
 lib/table/rte_table_lpm_ipv6.h              |    4 +-
 lib/vhost/virtio_net.c                      |    1 +
 116 files changed, 3246 insertions(+), 2741 deletions(-)
 create mode 100644 app/test/test_net_ipv6.c
 create mode 100644 lib/net/rte_cksum.h
 create mode 100644 lib/net/rte_ip6.h
Signature · 1 line
2.46.1
#24 lore raw

PATCH v2 1/16 net: split raw checksum functions in separate header

The checksum functions are used by both ipv4 and ipv6 functions. In preparation of moving ipv6 symbols to a new header, move the checksum related symbols to another dedicated header.

---

Notes:
v2: cleaned up includes

 lib/net/meson.build |   1 +
 lib/net/rte_cksum.h | 180 ++++++++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip.h    | 148 +-----------------------------------
 3 files changed, 182 insertions(+), 147 deletions(-)
 create mode 100644 lib/net/rte_cksum.h
lib/net/meson.build +1 -0
index 0b691389495a..2e65bd19b7d4 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
         'rte_tls.h',
lib/net/rte_cksum.h new file +180 -0

180 lines not on this page · raw message

lib/net/rte_ip.h +1 -147

160 lines not on this page · raw message

Signature · 1 line
2.46.1
Acked-by on v2 1/16
#25 lore raw

Re: [PATCH dpdk v2 01/16] net: split raw checksum functions in separate header

Quoted 6 lines · On Tue, 1 Oct 2024 10:17:13 +0200 Robin Jarry <[email protected]> wrote:

The checksum functions are used by both ipv4 and ipv6 functions. In preparation of moving ipv6 symbols to a new header, move the checksum related symbols to another dedicated header.

---

#26 lore raw

PATCH v2 2/16 net: split ipv6 symbols in separate header

In reply to Robin Jarry

Move all ipv6 related symbols to a dedicated header. Update all code accordingly.

---
 app/test/packet_burst_generator.c           |   1 +
 app/test/test_cryptodev_security_ipsec.c    |   1 +
 doc/guides/rel_notes/release_24_11.rst      |   1 +
 drivers/common/cnxk/cnxk_security.c         |   1 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |   1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |   1 +
 examples/ip_pipeline/pipeline.c             |   1 +
 lib/ethdev/rte_flow.h                       |   1 +
 lib/hash/rte_thash.h                        |   1 +
 lib/ip_frag/rte_ip_frag.h                   |   1 +
 lib/ipsec/iph.h                             |   1 +
 lib/net/meson.build                         |   1 +
 lib/net/rte_ip.h                            | 319 ------------------
 lib/net/{rte_ip.h => rte_ip6.h}             | 347 +-------------------
 lib/net/rte_net.c                           |   1 +
 lib/net/rte_net.h                           |   1 +
 lib/pipeline/rte_swx_ipsec.c                |   1 +
 lib/pipeline/rte_table_action.c             |   1 +
 lib/vhost/virtio_net.c                      |   1 +
 19 files changed, 21 insertions(+), 662 deletions(-)
 copy lib/net/{rte_ip.h => rte_ip6.h} (50%)
app/test/packet_burst_generator.c +1 -0
index 867a88da0055..2cd34abc1a65 100644
@@ -5,6 +5,7 @@
 #include <rte_byteorder.h>
 #include <rte_mbuf.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_os_shim.h>
 
 #include "packet_burst_generator.h"
app/test/test_cryptodev_security_ipsec.c +1 -0
index 1aba1ad9934b..9ac4a6e599b0 100644
@@ -6,6 +6,7 @@
 #include <rte_cryptodev.h>
 #include <rte_esp.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_security.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
doc/guides/rel_notes/release_24_11.rst +1 -0
index 0ff70d90578e..95b9809f4145 100644
@@ -84,6 +84,7 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net: IPv6 related symbols were moved from ``<rte_ip.h>`` to the new ``<rte_ip6.h>`` header.
 
 ABI Changes
 -----------
drivers/common/cnxk/cnxk_security.c +1 -0
index 15b0bedf43e2..e275d6cad3ea 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <rte_ip6.h>
 #include <rte_udp.h>
 
 #include "cnxk_security.h"
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -0
index f443cb9563ec..a3c737ef40f7 100644
@@ -6,6 +6,7 @@
 #include <cryptodev_pmd.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_vect.h>
 
 #include "roc_cpt.h"
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +1 -0
index c1f7181d5587..5bf690e3d82a 100644
@@ -10,6 +10,7 @@
 #include <unistd.h>
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_udp.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
examples/ip_pipeline/pipeline.c +1 -0
index 63352257c6e9..301c52d061be 100644
@@ -7,6 +7,7 @@
 
 #include <rte_common.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 
 #include <rte_string_fns.h>
lib/ethdev/rte_flow.h +1 -0
index f864578f806b..3a3ab781c494 100644
@@ -23,6 +23,7 @@
 #include <rte_arp.h>
 #include <rte_icmp.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_sctp.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
lib/hash/rte_thash.h +1 -0
index 30b657e67a7d..af40afd2d475 100644
@@ -23,6 +23,7 @@ extern "C" {
 
 #include <rte_byteorder.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_common.h>
 #include <rte_thash_gfni.h>
 
lib/ip_frag/rte_ip_frag.h +1 -0
index 2ad318096b7b..cb06d5f5977a 100644
@@ -23,6 +23,7 @@ extern "C" {
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_byteorder.h>
 
 struct rte_mbuf;
lib/ipsec/iph.h +1 -0
index 861f16905ad0..815a3c90d76b 100644
@@ -6,6 +6,7 @@
 #define _IPH_H_
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 
 /**
  * @file iph.h
lib/net/meson.build +1 -0
index 2e65bd19b7d4..35ac334a18cf 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_ip6.h',
         'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
lib/net/rte_ip.h +0 -319

325 lines not on this page · raw message

lib/net/rte_ip6.h renamed from lib/net/rte_ip.h +4 -343

372 lines not on this page · raw message

lib/net/rte_net.c +1 -0
index d680accc1631..13aef6147ab0 100644
@@ -9,6 +9,7 @@
 #include <rte_byteorder.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_sctp.h>
lib/net/rte_net.h +1 -0
index cdc6cf956df2..a47beb60adf0 100644
@@ -10,6 +10,7 @@ extern "C" {
 #endif
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_udp.h>
 #include <rte_tcp.h>
 
lib/pipeline/rte_swx_ipsec.c +1 -0
index 73e8211b2818..56a401d0fa63 100644
@@ -11,6 +11,7 @@
 #include <rte_common.h>
 #include <rte_random.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tailq.h>
 #include <rte_eal_memconfig.h>
 #include <rte_ring.h>
lib/pipeline/rte_table_action.c +1 -0
index 87c3e0e2c935..ebbdd3f4cebe 100644
@@ -11,6 +11,7 @@
 #include <rte_memcpy.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_vxlan.h>
lib/vhost/virtio_net.c +1 -0
index 370402d84903..d4dcc811c55f 100644
@@ -11,6 +11,7 @@
 #include <rte_net.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_dmadev.h>
 #include <rte_vhost.h>
 #include <rte_tcp.h>
Signature · 1 line
2.46.1
Acked-by on v2 2/16
#27 lore raw

Re: [PATCH dpdk v2 02/16] net: split ipv6 symbols in separate header

Quoted 4 lines · On Tue, 1 Oct 2024 10:17:14 +0200 Robin Jarry <[email protected]> wrote:

Move all ipv6 related symbols to a dedicated header. Update all code accordingly.

Makes sense to me.
There maybe IETF folks that argue that IP is always IPv6 and IPv4 is legacy IP, but that is being dogmatic.

#28 lore raw

PATCH v2 3/16 net: add structure for ipv6 addresses

In reply to Robin Jarry

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements without any union. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

---
 lib/net/rte_ip6.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/net/rte_ip6.h +10 -0
index 5ad1dd25db08..52c41088681e 100644
@@ -35,6 +35,16 @@
 extern "C" {
 #endif
 
+#define RTE_IPV6_ADDR_SIZE 16
+#define RTE_IPV6_MAX_DEPTH 128
+
+/**
+ * IPv6 Address
+ */
+struct rte_ipv6_addr {
+	unsigned char a[RTE_IPV6_ADDR_SIZE];
+};
+
 /**
  * IPv6 Header
  */
Signature · 1 line
2.46.1
#29 lore raw

Re: [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses

Quoted 18 lines · On Tue, 1 Oct 2024 10:17:15 +0200 Robin Jarry <[email protected]> wrote:

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements without any union. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

---
 lib/net/rte_ip6.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/net/rte_ip6.h +0 -0
index 5ad1dd25db08..52c41088681e 100644
@@ -35,6 +35,16 @@
 extern "C" {
 #endif
 

lib/net/rte_ip6.h line 47

Quoted 10 lines
lib/net/rte_ip6.h +10 -0
+#define RTE_IPV6_ADDR_SIZE 16
+#define RTE_IPV6_MAX_DEPTH 128
+
+/**
+ * IPv6 Address
+ */
+struct rte_ipv6_addr {
+	unsigned char a[RTE_IPV6_ADDR_SIZE];
+};
+

Why is RTE_IPV6_MAX_DEPTH here, it is not really a property of the address itself.

Not sure if using a union (like struct in6_addr does) might be better to encourage compiler alignment and allow simpler faster comparison.

#30 lore raw

Re: [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses

Stephen Hemminger, Oct 04, 2024 at 01:18:

Quoted 21 lines
Quoted 18 lines · On Tue, 1 Oct 2024 10:17:15 +0200 Robin Jarry <[email protected]> wrote:

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements without any union. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

---
 lib/net/rte_ip6.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/net/rte_ip6.h +0 -0
index 5ad1dd25db08..52c41088681e 100644
@@ -35,6 +35,16 @@
 extern "C" {
 #endif
 
Quoted 13 lines

lib/net/rte_ip6.h line 47

Quoted 10 lines
lib/net/rte_ip6.h +10 -0
+#define RTE_IPV6_ADDR_SIZE 16
+#define RTE_IPV6_MAX_DEPTH 128
+
+/**
+ * IPv6 Address
+ */
+struct rte_ipv6_addr {
+	unsigned char a[RTE_IPV6_ADDR_SIZE];
+};
+

Why is RTE_IPV6_MAX_DEPTH here, it is not really a property of the address itself.

It is used in the next commits. I will move it where it belongs.

Quoted 2 lines

Not sure if using a union (like struct in6_addr does) might be better to encourage compiler alignment and allow simpler faster comparison.

I didn't use a union to ensure the type is 1 byte aligned. This is the very reason why I didn't re-use in6_addr which would have been more elegant (and shorter).

#31 lore raw

RE: [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses

In reply to Robin Jarry

+to: Various CPU architecture maintainers
+to: Stephen (already participating in this discussion) +cc: x86 CPU architecture maintainers

Quoted 22 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 1 October 2024 10.17

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements without any union. The
idea is to ensure this structure alignment is 1 so that it can be mapped
directly on unaligned packet memory.

---
 lib/net/rte_ip6.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/net/rte_ip6.h +0 -0
index 5ad1dd25db08..52c41088681e 100644
@@ -35,6 +35,16 @@
 extern "C" {
 #endif

lib/net/rte_ip6.h line 46

Quoted 10 lines
lib/net/rte_ip6.h +9 -0
 
+#define RTE_IPV6_ADDR_SIZE 16
+#define RTE_IPV6_MAX_DEPTH 128
+
+/**
+ * IPv6 Address
+ */
+struct rte_ipv6_addr {
+	unsigned char a[RTE_IPV6_ADDR_SIZE];
+};

This has been discussed before, but I want to double check...

If - sometime in the future - we want to add a union to offer a 2-byte access variant and make the structure to 2-byte aligned (which is the common case in Ethernet packets), it will break both API and ABI. This seems unlikely to get accepted at a later time, so I think we are - right now - in a situation where it's now or never:

struct rte_ipv6_addr {
	__extension__
	union {
		unsigned char a[RTE_IPV6_ADDR_SIZE];
		uint16_t      w[RTE_IPV6_ADDR_SIZE / 2];
	};
};

Unless some of the CPU folks want the 2-byte aligned variant, stick with what you offered.

#32 lore raw

Re: [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses

Morten Brørup, Oct 06, 2024 at 10:18:

Quoted 13 lines

This has been discussed before, but I want to double check...

If - sometime in the future - we want to add a union to offer a 2-byte access variant and make the structure to 2-byte aligned (which is the common case in Ethernet packets), it will break both API and ABI. This seems unlikely to get accepted at a later time, so I think we are
- right now - in a situation where it's now or never:

struct rte_ipv6_addr {
	__extension__
	union {
		unsigned char a[RTE_IPV6_ADDR_SIZE];
		uint16_t      w[RTE_IPV6_ADDR_SIZE / 2];
	};
};
Quoted 1 line

Unless some of the CPU folks want the 2-byte aligned variant, stick with what you offered.

I was also thinking the same. I could have added an unnamed union which only contains one field.

However, it does not make much sense if we never want to change the default alignment.

Important note: DPDK is compiled with the following C flags:

-Wno-address-of-packed-member

Added in 2017 https://git.dpdk.org/dpdk/commit/?id=95cd37070af44

If we had struct rte_ipv6_addr aligned on 2 bytes (or more), applications that do not silence that warning would have a hard time. Example in grout:

../modules/ip6/datapath/ip6_input.c:99:54: error: taking address of packed member of ‘struct rte_ipv6_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
99 | nh = ip6_route_lookup(iface->vrf_id, &ip->dst_addr);
| ^~~~~~~~~~~~~

I'd say that it is better to keep it simple :)

#33 lore raw

RE: [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses

Quoted 41 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Thursday, 10 October 2024 22.08

Morten Brørup, Oct 06, 2024 at 10:18:

Quoted 3 lines

This has been discussed before, but I want to double check...

If - sometime in the future - we want to add a union to offer a 2-

byte

Quoted 2 lines

access variant and make the structure to 2-byte aligned (which is the common case in Ethernet packets), it will break both API and ABI.

This

Quoted 11 lines

seems unlikely to get accepted at a later time, so I think we are
- right now - in a situation where it's now or never:

struct rte_ipv6_addr {
	__extension__
	union {
		unsigned char a[RTE_IPV6_ADDR_SIZE];
		uint16_t      w[RTE_IPV6_ADDR_SIZE / 2];
	};
};
Quoted 2 lines

Unless some of the CPU folks want the 2-byte aligned variant, stick with what you offered.

I was also thinking the same. I could have added an unnamed union which only contains one field.

However, it does not make much sense if we never want to change the default alignment.

Important note: DPDK is compiled with the following C flags:

-Wno-address-of-packed-member

Added in 2017 https://git.dpdk.org/dpdk/commit/?id=95cd37070af44

If we had struct rte_ipv6_addr aligned on 2 bytes (or more), applications that do not silence that warning would have a hard time. Example in grout:

Quoted 7 lines

../modules/ip6/datapath/ip6_input.c:99:54: error: taking address of packed member of ‘struct rte_ipv6_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
99 | nh = ip6_route_lookup(iface->vrf_id, &ip-

Quoted 1 line

dst_addr);

      |

^~~~~~~~~~~~~

I don't understand the choice of packing for these types...

Why are the IPv4 [ipv4h] and IPv6 header [ipv6h] types packed? Is it so they can be stored on unaligned addresses?

E.g. the IPv4 header's natural alignment is 4 byte (due to the rte_be32_t src_addr, dst_addr fields). The IPv4 header is most often 2 byte aligned, being located after an Ethernet header.

Maybe they should be 2-byte aligned, like the Ethernet address type [etha] and the Ethernet header type [ethh].

The VLAN tag type [vlanh] is packed. Why?

I wonder if the compiler would spit out the same warnings if the above types were __rte_aligned(2) instead of __rte_packed.

Quoted 2 lines

I'd say that it is better to keep it simple :)

Yes, I don't see the CPU folks screaming about performance for this patch, so let's remain ignorant about the reasons for packing and make the safe choice: Keep the IPv6 addr type as you suggested, and do not make it 2-byte aligned by adding the unnamed union with the uint16_t field.

Also, I think we are too close to the 24.11 deadline to go deep enough into this to make qualified decisions about changing it.

For educational purposes, sometime in the future, I would like to learn about the choices of packing and 2-byte alignment questioned above.

[ipv4h] https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L41
[ipv6h]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ip.h#L526
[etha]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ether.h#L74
[ethh]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ether.h#L293
[vlanh]: https://elixir.bootlin.com/dpdk/v24.07/source/lib/net/rte_ether.h#L304

#34 lore raw

Re: [PATCH dpdk v2 03/16] net: add structure for ipv6 addresses

Quoted 53 lines · On Fri, 11 Oct 2024 14:37:35 +0200 Morten Brørup <[email protected]>…
Quoted 41 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Thursday, 10 October 2024 22.08

Morten Brørup, Oct 06, 2024 at 10:18:

Quoted 3 lines

This has been discussed before, but I want to double check...

If - sometime in the future - we want to add a union to offer a 2-

byte

Quoted 2 lines

access variant and make the structure to 2-byte aligned (which is the common case in Ethernet packets), it will break both API and ABI.

This

Quoted 11 lines

seems unlikely to get accepted at a later time, so I think we are
- right now - in a situation where it's now or never:

struct rte_ipv6_addr {
	__extension__
	union {
		unsigned char a[RTE_IPV6_ADDR_SIZE];
		uint16_t      w[RTE_IPV6_ADDR_SIZE / 2];
	};
};
Quoted 2 lines

Unless some of the CPU folks want the 2-byte aligned variant, stick with what you offered.

I was also thinking the same. I could have added an unnamed union which only contains one field.

However, it does not make much sense if we never want to change the default alignment.

Important note: DPDK is compiled with the following C flags:

-Wno-address-of-packed-member

Added in 2017 https://git.dpdk.org/dpdk/commit/?id=95cd37070af44

If we had struct rte_ipv6_addr aligned on 2 bytes (or more), applications that do not silence that warning would have a hard time. Example in grout:

Quoted 7 lines

../modules/ip6/datapath/ip6_input.c:99:54: error: taking address of packed member of ‘struct rte_ipv6_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
99 | nh = ip6_route_lookup(iface->vrf_id, &ip-

Quoted 1 line

dst_addr);

      |

^~~~~~~~~~~~~

I don't understand the choice of packing for these types...

Why are the IPv4 [ipv4h] and IPv6 header [ipv6h] types packed? Is it so they can be stored on unaligned addresses?

Quoted 7 lines

E.g. the IPv4 header's natural alignment is 4 byte (due to the rte_be32_t src_addr, dst_addr fields). The IPv4 header is most often 2 byte aligned, being located after an Ethernet header.

Maybe they should be 2-byte aligned, like the Ethernet address type [etha] and the Ethernet header type [ethh].

The VLAN tag type [vlanh] is packed. Why?

I wonder if the compiler would spit out the same warnings if the above types were __rte_aligned(2) instead of __rte_packed.

I am in the never use packed camp for network headers. The Linux, BSD and glibc headers avoid use of packed. Windows seems to love using it.

#35 lore raw

PATCH v2 4/16 net: use ipv6 structure for header addresses

In reply to Robin Jarry

The rte_ipv6_hdr uses ad-hoc uint8_t[16] arrays to represent addresses. Replace these arrays with the previously introduced rte_ipv6_addr structure. Adapt all code accordingly.

---

Notes:
v2: updated changelog for 24.11

 app/test-flow-perf/items_gen.c           |  4 +--
 app/test-pipeline/pipeline_hash.c        |  4 +--
 app/test/packet_burst_generator.c        |  4 +--
 app/test/test_ipfrag.c                   |  4 +--
 app/test/test_reassembly_perf.c          | 20 +++++------
 app/test/test_thash.c                    |  8 ++---
 doc/guides/rel_notes/deprecation.rst     |  2 --
 doc/guides/rel_notes/release_24_11.rst   |  2 ++
 drivers/net/bnxt/bnxt_flow.c             | 12 +++----
 drivers/net/bonding/rte_eth_bond_pmd.c   |  4 +--
 drivers/net/cxgbe/cxgbe_flow.c           | 14 ++++----
 drivers/net/dpaa2/dpaa2_flow.c           | 22 ++++++------
 drivers/net/hinic/hinic_pmd_flow.c       |  6 ++--
 drivers/net/hinic/hinic_pmd_tx.c         |  2 +-
 drivers/net/hns3/hns3_flow.c             |  8 ++---
 drivers/net/i40e/i40e_flow.c             | 12 +++----
 drivers/net/iavf/iavf_fdir.c             |  8 ++---
 drivers/net/iavf/iavf_fsub.c             |  8 ++---
 drivers/net/iavf/iavf_ipsec_crypto.c     |  6 ++--
 drivers/net/ice/ice_fdir_filter.c        | 12 +++----
 drivers/net/ice/ice_switch_filter.c      | 16 ++++-----
 drivers/net/igc/igc_flow.c               |  4 +--
 drivers/net/ixgbe/ixgbe_flow.c           | 12 +++----
 drivers/net/ixgbe/ixgbe_ipsec.c          |  4 +--
 drivers/net/mlx5/hws/mlx5dr_definer.c    | 36 +++++++++----------
 drivers/net/mlx5/mlx5_flow.c             |  6 ++--
 drivers/net/mlx5/mlx5_flow_dv.c          | 16 +++++----
 drivers/net/mlx5/mlx5_flow_hw.c          | 10 +++---
 drivers/net/mlx5/mlx5_flow_verbs.c       |  8 ++---
 drivers/net/nfp/flower/nfp_flower_flow.c | 34 ++++++++++--------
 drivers/net/nfp/nfp_net_flow.c           | 44 +++++++++++++-----------
 drivers/net/qede/qede_filter.c           |  4 +--
 drivers/net/sfc/sfc_flow.c               | 28 +++++++--------
 drivers/net/tap/tap_flow.c               |  8 ++---
 drivers/net/txgbe/txgbe_flow.c           | 12 +++----
 drivers/net/txgbe/txgbe_ipsec.c          |  4 +--
 examples/ip_fragmentation/main.c         |  2 +-
 examples/ip_pipeline/pipeline.c          | 16 ++++-----
 examples/ip_reassembly/main.c            |  2 +-
 examples/ipsec-secgw/flow.c              | 12 +++----
 examples/ipsec-secgw/ipsec.c             |  8 ++---
 examples/ipsec-secgw/sa.c                |  4 +--
 examples/ipsec-secgw/sad.h               | 10 +++---
 examples/l3fwd/l3fwd_fib.c               |  2 +-
 examples/l3fwd/l3fwd_lpm.c               |  4 +--
 lib/ethdev/rte_flow.h                    |  6 ++--
 lib/hash/rte_thash.h                     | 12 +++----
 lib/ip_frag/rte_ipv6_reassembly.c        |  4 +--
 lib/net/rte_ip6.h                        |  6 ++--
 lib/node/ip6_lookup.c                    | 10 +++---
 lib/pipeline/rte_swx_ipsec.c             |  6 ++--
 lib/pipeline/rte_table_action.c          | 24 ++++++-------
 52 files changed, 278 insertions(+), 258 deletions(-)
app/test-flow-perf/items_gen.c +2 -2
index 4ae72509d445..c740e1838ffb 100644
@@ -78,8 +78,8 @@ add_ipv6(struct rte_flow_item *items,
 	for (i = 0; i < 16; i++) {
 		/* Currently src_ip is limited to 32 bit */
 		if (i < 4)
-			ipv6_specs[ti].hdr.src_addr[15 - i] = para.src_ip >> (i * 8);
-		ipv6_masks[ti].hdr.src_addr[15 - i] = 0xff;
+			ipv6_specs[ti].hdr.src_addr.a[15 - i] = para.src_ip >> (i * 8);
+		ipv6_masks[ti].hdr.src_addr.a[15 - i] = 0xff;
 	}
 
 	items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV6;
app/test-pipeline/pipeline_hash.c +1 -3
index cab9c2098014..194e5c5dcc53 100644
@@ -432,7 +432,6 @@ app_main_loop_rx_metadata(void) {
 				struct rte_ipv4_hdr *ip_hdr;
 				struct rte_ipv6_hdr *ipv6_hdr;
 				uint32_t ip_dst;
-				uint8_t *ipv6_dst;
 				uint32_t *signature, *k32;
 
 				m = app.mbuf_rx.array[j];
@@ -452,9 +451,8 @@ app_main_loop_rx_metadata(void) {
 				} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
 					ipv6_hdr = (struct rte_ipv6_hdr *)
 						&m_data[sizeof(struct rte_ether_hdr)];
-					ipv6_dst = ipv6_hdr->dst_addr;
 
-					memcpy(key, ipv6_dst, 16);
+					memcpy(key, &ipv6_hdr->dst_addr, 16);
 				} else
 					continue;
 
app/test/packet_burst_generator.c +2 -2
index 2cd34abc1a65..76a409a56452 100644
@@ -149,8 +149,8 @@ initialize_ipv6_header(struct rte_ipv6_hdr *ip_hdr, uint8_t *src_addr,
 	ip_hdr->proto = IPPROTO_UDP;
 	ip_hdr->hop_limits = IP_DEFTTL;
 
-	rte_memcpy(ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
-	rte_memcpy(ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
+	rte_memcpy(&ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
+	rte_memcpy(&ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
 
 	return (uint16_t) (pkt_data_len + sizeof(struct rte_ipv6_hdr));
 }
app/test/test_ipfrag.c +2 -2
index 8e4df220a214..4053bd9f0f79 100644
@@ -238,8 +238,8 @@ v6_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, uint8_t ttl,
 	hdr->proto = proto;
 	hdr->hop_limits = ttl;
 
-	memset(hdr->src_addr, 0x08, sizeof(hdr->src_addr));
-	memset(hdr->dst_addr, 0x04, sizeof(hdr->src_addr));
+	memset(hdr->src_addr.a, 0x08, sizeof(hdr->src_addr));
+	memset(hdr->dst_addr.a, 0x04, sizeof(hdr->src_addr));
 }
 
 static inline void
app/test/test_reassembly_perf.c +10 -10
index 3912179022fc..70112c1f62da 100644
@@ -340,17 +340,17 @@ ipv6_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id,
 			rte_cpu_to_be_16(pkt_len - sizeof(struct rte_ipv6_hdr));
 		ip_hdr->proto = IPPROTO_FRAGMENT;
 		ip_hdr->hop_limits = IP_DEFTTL;
-		memcpy(ip_hdr->src_addr, ip6_addr, sizeof(ip_hdr->src_addr));
-		memcpy(ip_hdr->dst_addr, ip6_addr, sizeof(ip_hdr->dst_addr));
-		ip_hdr->src_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->src_addr[7] |= 0x10;
-		ip_hdr->src_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->src_addr[9] = flow_id & 0xff;
+		memcpy(&ip_hdr->src_addr, ip6_addr, sizeof(ip_hdr->src_addr));
+		memcpy(&ip_hdr->dst_addr, ip6_addr, sizeof(ip_hdr->dst_addr));
+		ip_hdr->src_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->src_addr.a[7] |= 0x10;
+		ip_hdr->src_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->src_addr.a[9] = flow_id & 0xff;
 
-		ip_hdr->dst_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->dst_addr[7] |= 0x20;
-		ip_hdr->dst_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->dst_addr[9] = flow_id & 0xff;
+		ip_hdr->dst_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->dst_addr.a[7] |= 0x20;
+		ip_hdr->dst_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->dst_addr.a[9] = flow_id & 0xff;
 
 		frag_hdr->next_header = IPPROTO_UDP;
 		frag_hdr->reserved = 0;
app/test/test_thash.c +4 -4
index 65d42fd90085..952da6a52954 100644
@@ -145,10 +145,10 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr); j++)
-			ipv6_hdr.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr); j++)
-			ipv6_hdr.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
+			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
+			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
doc/guides/rel_notes/deprecation.rst +0 -2
index 211f59fdc9a2..439867289cf3 100644
@@ -87,8 +87,6 @@ Deprecation Notices
     - ``rte_lpm6_delete_bulk_func()``
     - ``rte_lpm6_lookup()``
     - ``rte_lpm6_lookup_bulk_func()``
-  net
-    - ``struct rte_ipv6_hdr``
   node
     - ``rte_node_ip6_route_add()``
   pipeline
doc/guides/rel_notes/release_24_11.rst +2 -0
index 95b9809f4145..2d5b29b5a2d4 100644
@@ -85,6 +85,8 @@ API Changes
    =======================================================
 
 * net: IPv6 related symbols were moved from ``<rte_ip.h>`` to the new ``<rte_ip6.h>`` header.
+* net: The ``rte_ipv6_hdr`` structure was modified to use ``struct rte_ipv6_addr`` instead of
+  ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
drivers/net/bnxt/bnxt_flow.c +6 -6
index f25bc6ff78c7..bdc47ee78755 100644
@@ -424,22 +424,22 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 					EM_FLOW_ALLOC_INPUT_EN_DST_IPADDR;
 
 			rte_memcpy(filter->src_ipaddr,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(filter->dst_ipaddr,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr.a,
 						   16)) {
 				rte_memcpy(filter->src_ipaddr_mask,
-					   ipv6_mask->hdr.src_addr, 16);
+					   &ipv6_mask->hdr.src_addr, 16);
 				en |= !use_ntuple ? 0 :
 				    NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_IPADDR_MASK;
 			}
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr.a,
 						   16)) {
 				rte_memcpy(filter->dst_ipaddr_mask,
-					   ipv6_mask->hdr.dst_addr, 16);
+					   &ipv6_mask->hdr.dst_addr, 16);
 				en |= !use_ntuple ? 0 :
 				     NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK;
 			}
drivers/net/bonding/rte_eth_bond_pmd.c +2 -2
index c40d18d128b6..b89732f4a28a 100644
@@ -690,9 +690,9 @@ static inline uint32_t
 ipv6_hash(struct rte_ipv6_hdr *ipv6_hdr)
 {
 	unaligned_uint32_t *word_src_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->src_addr[0]);
+		(unaligned_uint32_t *)&ipv6_hdr->src_addr;
 	unaligned_uint32_t *word_dst_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->dst_addr[0]);
+		(unaligned_uint32_t *)&ipv6_hdr->dst_addr;
 
 	return (word_src_addr[0] ^ word_dst_addr[0]) ^
 			(word_src_addr[1] ^ word_dst_addr[1]) ^
drivers/net/cxgbe/cxgbe_flow.c +8 -6
index f5787c247f1f..37c566b131e9 100644
@@ -411,15 +411,15 @@ ch_rte_parsetype_ipv6(const void *dmask, const struct rte_flow_item *item,
 			      RTE_IPV6_HDR_TC_SHIFT,
 			      tos);
 
-	if (memcmp(val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
+	if (memcmp(&val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
+	     memcmp(&umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr,
 				     lip);
 
-	if (memcmp(val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
+	if (memcmp(&val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
+	     memcmp(&umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr,
 				     fip);
 
@@ -918,12 +918,14 @@ static struct chrte_fparse parseitem[] = {
 		.fptr  = ch_rte_parsetype_ipv6,
 		.dmask = &(const struct rte_flow_item_ipv6) {
 			.hdr = {
-				.src_addr =
+				.src_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr =
+				},
+				.dst_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				},
 				.vtc_flow = RTE_BE32(0xff000000),
 			},
 		},
drivers/net/dpaa2/dpaa2_flow.c +12 -10
index 6c7bac4d483a..5f762d319477 100644
@@ -117,12 +117,14 @@ static const struct rte_flow_item_ipv4 dpaa2_flow_item_ipv4_mask = {
 
 static const struct rte_flow_item_ipv6 dpaa2_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr =
+		.src_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 		.proto = 0xff
 	},
 };
@@ -1480,16 +1482,16 @@ dpaa2_configure_flow_generic_ip(
 		mask_ipv4->hdr.dst_addr)) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV4_ADDR;
 	} else if (mask_ipv6 &&
-		(memcmp((const char *)mask_ipv6->hdr.src_addr,
+		(memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE) ||
-		memcmp((const char *)mask_ipv6->hdr.dst_addr,
+		memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV6_ADDR;
 	}
 
 	if ((mask_ipv4 && mask_ipv4->hdr.src_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.src_addr,
+			memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1528,13 +1530,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.src_addr;
 		else
-			key = &spec_ipv6->hdr.src_addr[0];
+			key = &spec_ipv6->hdr.src_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.src_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.src_addr[0];
+			mask = &mask_ipv6->hdr.src_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
@@ -1571,7 +1573,7 @@ dpaa2_configure_flow_generic_ip(
 
 	if ((mask_ipv4 && mask_ipv4->hdr.dst_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.dst_addr,
+			memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1618,13 +1620,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.dst_addr;
 		else
-			key = spec_ipv6->hdr.dst_addr;
+			key = &spec_ipv6->hdr.dst_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.dst_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.dst_addr[0];
+			mask = &mask_ipv6->hdr.dst_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
drivers/net/hinic/hinic_pmd_flow.c +3 -3
index d1a564a16303..8fdd5a35be9f 100644
@@ -962,7 +962,7 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 
 		/* check ipv6 src addr mask, ipv6 src addr is 16 bytes */
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.src_addr[i] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[i] == UINT8_MAX) {
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM, item,
 					"Not supported by fdir filter, do not support src ipv6");
@@ -978,13 +978,13 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 		}
 
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.dst_addr[i] == UINT8_MAX)
+			if (ipv6_mask->hdr.dst_addr.a[i] == UINT8_MAX)
 				rule->mask.dst_ipv6_mask |= 1 << i;
 		}
 
 		ipv6_spec = (const struct rte_flow_item_ipv6 *)item->spec;
 		rte_memcpy(rule->hinic_fdir.dst_ipv6,
-			   ipv6_spec->hdr.dst_addr, 16);
+			   &ipv6_spec->hdr.dst_addr, 16);
 
 		/*
 		 * Check if the next not void item is TCP or UDP or ICMP.
drivers/net/hinic/hinic_pmd_tx.c +1 -1
index f09b1a6e1ea6..22fb0bffafcc 100644
@@ -743,7 +743,7 @@ hinic_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr), 0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
 	return __rte_raw_cksum_reduce(sum);
drivers/net/hns3/hns3_flow.c +4 -4
index 37eb2b4c3807..bf1eee506dde 100644
@@ -822,10 +822,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 						  "Only support src & dst ip,proto in IPV6");
 		}
 		net_addr_to_host(rule->key_conf.mask.src_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.src_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.src_addr,
 				 IP_ADDR_LEN);
 		net_addr_to_host(rule->key_conf.mask.dst_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.dst_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.dst_addr,
 				 IP_ADDR_LEN);
 		rule->key_conf.mask.ip_proto = ipv6_mask->hdr.proto;
 		if (rule->key_conf.mask.src_ip[IP_ADDR_KEY_ID])
@@ -838,10 +838,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 
 	ipv6_spec = item->spec;
 	net_addr_to_host(rule->key_conf.spec.src_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.src_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.src_addr,
 			 IP_ADDR_LEN);
 	net_addr_to_host(rule->key_conf.spec.dst_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.dst_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.dst_addr,
 			 IP_ADDR_LEN);
 	rule->key_conf.spec.ip_proto = ipv6_spec->hdr.proto;
 
drivers/net/i40e/i40e_flow.c +6 -6
index 92165c8422d5..c6857727e8be 100644
@@ -1953,13 +1953,13 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 
-				if (!memcmp(ipv6_mask->hdr.src_addr,
+				if (!memcmp(&ipv6_mask->hdr.src_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.src_addr)))
+					    sizeof(ipv6_mask->hdr.src_addr)))
 					input_set |= I40E_INSET_IPV6_SRC;
-				if (!memcmp(ipv6_mask->hdr.dst_addr,
+				if (!memcmp(&ipv6_mask->hdr.dst_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+					    sizeof(ipv6_mask->hdr.dst_addr)))
 					input_set |= I40E_INSET_IPV6_DST;
 
 				if ((ipv6_mask->hdr.vtc_flow &
@@ -1987,9 +1987,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					I40E_FDIR_IPTYPE_IPV6;
 
 				rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
-					   ipv6_spec->hdr.src_addr, 16);
+					   &ipv6_spec->hdr.src_addr, 16);
 				rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
-					   ipv6_spec->hdr.dst_addr, 16);
+					   &ipv6_spec->hdr.dst_addr, 16);
 
 				/* Check if it is fragment. */
 				if (ipv6_spec->hdr.proto ==
drivers/net/iavf/iavf_fdir.c +4 -4
index 811a10287b70..321346425465 100644
@@ -1048,14 +1048,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 								 HOP_LIMIT);
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr))) {
 				input_set |= IAVF_INSET_IPV6_SRC;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 SRC);
 			}
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr))) {
 				input_set |= IAVF_INSET_IPV6_DST;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 DST);
drivers/net/iavf/iavf_fsub.c +4 -4
index 74e1e7099b8c..eb5a3feab189 100644
@@ -354,23 +354,23 @@ iavf_fsub_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_DST;
 						break;
 					}
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j])
+					if (ipv6_mask->hdr.src_addr.a[j])
 						input_set_byte++;
 
-					if (ipv6_mask->hdr.dst_addr[j])
+					if (ipv6_mask->hdr.dst_addr.a[j])
 						input_set_byte++;
 				}
 
drivers/net/iavf/iavf_ipsec_crypto.c +3 -3
index 6fd45ff45f3d..17bea5880aa3 100644
@@ -1738,8 +1738,8 @@ static void
 parse_ipv6_item(const struct rte_flow_item_ipv6 *item,
 		struct rte_ipv6_hdr *ipv6)
 {
-	memcpy(ipv6->src_addr, item->hdr.src_addr, 16);
-	memcpy(ipv6->dst_addr, item->hdr.dst_addr, 16);
+	memcpy(&ipv6->src_addr, &item->hdr.src_addr, 16);
+	memcpy(&ipv6->dst_addr, &item->hdr.dst_addr, 16);
 }
 
 static void
@@ -1904,7 +1904,7 @@ iavf_ipsec_flow_create(struct iavf_adapter *ad,
 			ipsec_flow->spi,
 			0,
 			0,
-			ipsec_flow->ipv6_hdr.dst_addr,
+			ipsec_flow->ipv6_hdr.dst_addr.a,
 			0,
 			ipsec_flow->is_udp,
 			ipsec_flow->udp_hdr.dst_port);
drivers/net/ice/ice_fdir_filter.c +6 -6
index edd8cc8f1ab4..8c85779b5401 100644
@@ -2097,11 +2097,11 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr)))
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr)))
 				*input_set |= ICE_INSET_IPV6_SRC;
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr)))
 				*input_set |= ICE_INSET_IPV6_DST;
 
 			if ((ipv6_mask->hdr.vtc_flow &
@@ -2113,8 +2113,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
 				*input_set |= ICE_INSET_IPV6_HOP_LIMIT;
 
-			rte_memcpy(&p_v6->dst_ip, ipv6_spec->hdr.dst_addr, 16);
-			rte_memcpy(&p_v6->src_ip, ipv6_spec->hdr.src_addr, 16);
+			rte_memcpy(&p_v6->dst_ip, &ipv6_spec->hdr.dst_addr, 16);
+			rte_memcpy(&p_v6->src_ip, &ipv6_spec->hdr.src_addr, 16);
 			vtc_flow_cpu = rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
 			p_v6->tc = (uint8_t)(vtc_flow_cpu >> ICE_FDIR_IPV6_TC_OFFSET);
 			p_v6->proto = ipv6_spec->hdr.proto;
drivers/net/ice/ice_switch_filter.c +8 -8
index 122b87f625a7..28bc775a2c34 100644
@@ -665,13 +665,13 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_DST;
 						break;
 					}
@@ -691,18 +691,18 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				f = &list[t].h_u.ipv6_hdr;
 				s = &list[t].m_u.ipv6_hdr;
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						f->src_addr[j] =
-						ipv6_spec->hdr.src_addr[j];
+						ipv6_spec->hdr.src_addr.a[j];
 						s->src_addr[j] =
-						ipv6_mask->hdr.src_addr[j];
+						ipv6_mask->hdr.src_addr.a[j];
 						input_set_byte++;
 					}
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						f->dst_addr[j] =
-						ipv6_spec->hdr.dst_addr[j];
+						ipv6_spec->hdr.dst_addr.a[j];
 						s->dst_addr[j] =
-						ipv6_mask->hdr.dst_addr[j];
+						ipv6_mask->hdr.dst_addr.a[j];
 						input_set_byte++;
 					}
 				}
drivers/net/igc/igc_flow.c +2 -2
index b677a0d61340..b778ac26135a 100644
@@ -435,8 +435,8 @@ igc_parse_pattern_ipv6(const struct rte_flow_item *item,
 	if (mask->hdr.vtc_flow ||
 		mask->hdr.payload_len ||
 		mask->hdr.hop_limits ||
-		!igc_is_zero_ipv6_addr(mask->hdr.src_addr) ||
-		!igc_is_zero_ipv6_addr(mask->hdr.dst_addr))
+		!igc_is_zero_ipv6_addr(&mask->hdr.src_addr) ||
+		!igc_is_zero_ipv6_addr(&mask->hdr.dst_addr))
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ITEM, item,
 				"IPv6 only support protocol");
drivers/net/ixgbe/ixgbe_flow.c +6 -6
index 687341c6b8d3..1b35ed5faabe 100644
@@ -1917,9 +1917,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == 0) {
+			if (ipv6_mask->hdr.src_addr.a[j] == 0) {
 				rule->mask.src_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.src_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1930,9 +1930,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == 0) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == 0) {
 				rule->mask.dst_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.dst_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1945,9 +1945,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->ixgbe_fdir.formatted.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->ixgbe_fdir.formatted.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/ixgbe/ixgbe_ipsec.c +2 -2
index d3313085560d..7615a19911ba 100644
@@ -681,9 +681,9 @@ ixgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
drivers/net/mlx5/hws/mlx5dr_definer.c +18 -18
index 51a3f7be4b75..7326d2cf42a5 100644
@@ -176,14 +176,14 @@ struct mlx5dr_definer_conv_data {
 	X(SET,		ipv6_proto,		v->hdr.proto,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_routing_hdr,	IPPROTO_ROUTING,	rte_flow_item_ipv6) \
 	X(SET,		ipv6_hop_limits,	v->hdr.hop_limits,	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr[12],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr.a[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr.a[12],	rte_flow_item_ipv6) \
 	X(SET,		ipv6_version,		STE_IPV6,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_frag,		v->has_frag_ext,	rte_flow_item_ipv6) \
 	X(SET,		icmp_protocol,		STE_ICMP,		rte_flow_item_icmp) \
@@ -1161,8 +1161,8 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 	    m->has_esp_ext || m->has_dest_ext || m->has_mobil_ext ||
 	    m->has_hip_ext || m->has_shim6_ext ||
 	    (l && (l->has_frag_ext || l->hdr.vtc_flow || l->hdr.proto ||
-		   !is_mem_zero(l->hdr.src_addr, 16) ||
-		   !is_mem_zero(l->hdr.dst_addr, 16)))) {
+		   !is_mem_zero(l->hdr.src_addr.a, 16) ||
+		   !is_mem_zero(l->hdr.dst_addr.a, 16)))) {
 		rte_errno = ENOTSUP;
 		return rte_errno;
 	}
@@ -1219,56 +1219,56 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 		DR_CALC_SET(fc, eth_l3, time_to_live_hop_limit, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_31_0_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_31_0, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_31_0_set;
drivers/net/mlx5/mlx5_flow.c +4 -2
index 72fb3a55baf4..ba03a246fc84 100644
@@ -2933,12 +2933,14 @@ mlx5_flow_validate_item_ipv6(const struct rte_eth_dev *dev,
 	const struct rte_flow_item_ipv6 *spec = item->spec;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr =
+			.src_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
-			.dst_addr =
+			},
+			.dst_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 		},
drivers/net/mlx5/mlx5_flow_dv.c +10 -6
index 89057edbcfc2..30b9dd898ffc 100644
@@ -7697,12 +7697,14 @@ const struct rte_flow_item_ipv4 nic_ipv4_mask = {
 
 const struct rte_flow_item_ipv6 nic_ipv6_mask = {
 	.hdr = {
-		.src_addr =
+		.src_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 		.vtc_flow = RTE_BE32(0xffffffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
@@ -9549,12 +9551,14 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	const struct rte_flow_item_ipv6 *ipv6_v;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr =
+			.src_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
-			.dst_addr =
+			},
+			.dst_addr = { .a =
 				"\xff\xff\xff\xff\xff\xff\xff\xff"
 				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 			.hop_limits = 0xff,
@@ -9577,11 +9581,11 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.dst_addr[i] & ipv6_v->hdr.dst_addr[i];
+		l24_v[i] = ipv6_m->hdr.dst_addr.a[i] & ipv6_v->hdr.dst_addr.a[i];
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     src_ipv4_src_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.src_addr[i] & ipv6_v->hdr.src_addr[i];
+		l24_v[i] = ipv6_m->hdr.src_addr.a[i] & ipv6_v->hdr.src_addr.a[i];
 	/* TOS. */
 	vtc_v = rte_be_to_cpu_32(ipv6_m->hdr.vtc_flow & ipv6_v->hdr.vtc_flow);
 	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, vtc_v >> 20);
drivers/net/mlx5/mlx5_flow_hw.c +6 -4
index d243b59b71cd..1b6c79a3f332 100644
@@ -8250,12 +8250,14 @@ const struct rte_flow_item_ipv6 hws_nic_ipv6_mask = {
 		.payload_len = RTE_BE16(0xffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
-		.src_addr =
+		.src_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 	},
 	.has_frag_ext = 1,
 };
@@ -14645,10 +14647,10 @@ flow_hw_calc_encap_hash(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			memcpy(data.dst.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
 			       sizeof(data.dst.ipv6_addr));
 			memcpy(data.src.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
 			       sizeof(data.src.ipv6_addr));
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
drivers/net/mlx5/mlx5_flow_verbs.c +4 -4
index 3a4356c0f650..5b4a4eda3bbc 100644
@@ -600,13 +600,13 @@ flow_verbs_translate_item_ipv6(struct mlx5_flow *dev_flow,
 		uint32_t vtc_flow_val;
 		uint32_t vtc_flow_mask;
 
-		memcpy(&ipv6.val.src_ip, spec->hdr.src_addr,
+		memcpy(&ipv6.val.src_ip, &spec->hdr.src_addr,
 		       RTE_DIM(ipv6.val.src_ip));
-		memcpy(&ipv6.val.dst_ip, spec->hdr.dst_addr,
+		memcpy(&ipv6.val.dst_ip, &spec->hdr.dst_addr,
 		       RTE_DIM(ipv6.val.dst_ip));
-		memcpy(&ipv6.mask.src_ip, mask->hdr.src_addr,
+		memcpy(&ipv6.mask.src_ip, &mask->hdr.src_addr,
 		       RTE_DIM(ipv6.mask.src_ip));
-		memcpy(&ipv6.mask.dst_ip, mask->hdr.dst_addr,
+		memcpy(&ipv6.mask.dst_ip, &mask->hdr.dst_addr,
 		       RTE_DIM(ipv6.mask.dst_ip));
 		vtc_flow_val = rte_be_to_cpu_32(spec->hdr.vtc_flow);
 		vtc_flow_mask = rte_be_to_cpu_32(mask->hdr.vtc_flow);
drivers/net/nfp/flower/nfp_flower_flow.c +19 -15
index 0078455658ac..3f597d394b24 100644
@@ -2027,18 +2027,18 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 
 			ipv6_gre_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_gre_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_gre_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_src));
-			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_dst));
 		} else {
 			ipv6_udp_tun = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
 
 			ipv6_udp_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_udp_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_udp_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_src));
-			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_dst));
 		}
 	} else {
@@ -2061,8 +2061,8 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 		ipv6->ip_ext.tos   = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 		ipv6->ip_ext.proto = hdr->proto;
 		ipv6->ip_ext.ttl   = hdr->hop_limits;
-		memcpy(ipv6->ipv6_src, hdr->src_addr, sizeof(ipv6->ipv6_src));
-		memcpy(ipv6->ipv6_dst, hdr->dst_addr, sizeof(ipv6->ipv6_dst));
+		memcpy(ipv6->ipv6_src, &hdr->src_addr, sizeof(ipv6->ipv6_src));
+		memcpy(ipv6->ipv6_dst, &hdr->dst_addr, sizeof(ipv6->ipv6_dst));
 
 ipv6_end:
 		*param->mbuf_off += sizeof(struct nfp_flower_ipv6);
@@ -2518,10 +2518,14 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
 				.vtc_flow   = RTE_BE32(0x0ff00000),
 				.proto      = 0xff,
 				.hop_limits = 0xff,
-				.src_addr   = "\xff\xff\xff\xff\xff\xff\xff\xff"
+				.src_addr   = { .a =
+					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr   = "\xff\xff\xff\xff\xff\xff\xff\xff"
+				},
+				.dst_addr   = { .a =
+					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				},
 			},
 			.has_frag_ext = 1,
 		},
@@ -3324,8 +3328,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 	struct nfp_flower_cmsg_tun_neigh_v6 payload;
 
 	tun->payload.v6_flag = 1;
-	memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
-	memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
+	memcpy(tun->payload.dst.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
+	memcpy(tun->payload.src.src_ipv6, &ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
 	memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 
@@ -3345,8 +3349,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 			sizeof(struct nfp_flower_meta_tci));
 
 	memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6));
-	memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
-	memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
+	memcpy(payload.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
+	memcpy(payload.src_ipv6, &ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
 	memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	payload.common.port_id = port->in_port;
@@ -3573,7 +3577,7 @@ nfp_flow_action_vxlan_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -3944,7 +3948,7 @@ nfp_flow_action_geneve_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -4021,7 +4025,7 @@ nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
drivers/net/nfp/nfp_net_flow.c +24 -20

62 lines not on this page · raw message

drivers/net/qede/qede_filter.c +2 -2
index d98266eac55c..14fb4338e9c7 100644
@@ -794,9 +794,9 @@ qede_flow_parse_pattern(__rte_unused struct rte_eth_dev *dev,
 
 				spec = pattern->spec;
 				memcpy(flow->entry.tuple.src_ipv6,
-				       spec->hdr.src_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.src_addr, IPV6_ADDR_LEN);
 				memcpy(flow->entry.tuple.dst_ipv6,
-				       spec->hdr.dst_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.dst_addr, IPV6_ADDR_LEN);
 				flow->entry.tuple.eth_proto =
 					RTE_ETHER_TYPE_IPV6;
 			}
drivers/net/sfc/sfc_flow.c +14 -14
index 1b50aefe5c48..0a812d9928ab 100644
@@ -575,14 +575,14 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	const uint16_t ether_type_ipv6 = rte_cpu_to_le_16(EFX_ETHER_TYPE_IPV6);
 	const struct rte_flow_item_ipv6 supp_mask = {
 		.hdr = {
-			.src_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
-			.dst_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
+			.src_addr = { .a =
+				"\xff\xff\xff\xff\xff\xff\xff\xff"
+				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
+			.dst_addr = { .a =
+				"\xff\xff\xff\xff\xff\xff\xff\xff"
+				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			},
 			.proto = 0xff,
 		}
 	};
@@ -618,28 +618,28 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	 * IPv6 addresses are in big-endian byte order in item and in
 	 * efx_spec
 	 */
-	if (memcmp(mask->hdr.src_addr, supp_mask.hdr.src_addr,
+	if (memcmp(&mask->hdr.src_addr, &supp_mask.hdr.src_addr,
 		   sizeof(mask->hdr.src_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_rem_host) !=
 				 sizeof(spec->hdr.src_addr));
-		rte_memcpy(&efx_spec->efs_rem_host, spec->hdr.src_addr,
+		rte_memcpy(&efx_spec->efs_rem_host, &spec->hdr.src_addr,
 			   sizeof(efx_spec->efs_rem_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.src_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.src_addr.a,
 				     sizeof(mask->hdr.src_addr))) {
 		goto fail_bad_mask;
 	}
 
-	if (memcmp(mask->hdr.dst_addr, supp_mask.hdr.dst_addr,
+	if (memcmp(&mask->hdr.dst_addr, &supp_mask.hdr.dst_addr,
 		   sizeof(mask->hdr.dst_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_loc_host) !=
 				 sizeof(spec->hdr.dst_addr));
-		rte_memcpy(&efx_spec->efs_loc_host, spec->hdr.dst_addr,
+		rte_memcpy(&efx_spec->efs_loc_host, &spec->hdr.dst_addr,
 			   sizeof(efx_spec->efs_loc_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr.a,
 				     sizeof(mask->hdr.dst_addr))) {
 		goto fail_bad_mask;
 	}
drivers/net/tap/tap_flow.c +4 -4
index 0a90c0487b46..8f5a8d64587b 100644
@@ -209,11 +209,11 @@ static const struct tap_flow_items tap_flow_items[] = {
 			       RTE_FLOW_ITEM_TYPE_TCP),
 		.mask = &(const struct rte_flow_item_ipv6){
 			.hdr = {
-				.src_addr = {
+				.src_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
 				},
-				.dst_addr = {
+				.dst_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
 				},
@@ -617,13 +617,13 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data)
 		info->eth_type = htons(ETH_P_IPV6);
 	if (!spec)
 		return 0;
-	if (memcmp(mask->hdr.dst_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.dst_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST,
 			   sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK,
 			   sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr);
 	}
-	if (memcmp(mask->hdr.src_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.src_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC,
 			   sizeof(spec->hdr.src_addr), &spec->hdr.src_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK,
drivers/net/txgbe/txgbe_flow.c +6 -6
index 7ef52d0b0fcd..5d2dd453687c 100644
@@ -1807,9 +1807,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[j] == UINT8_MAX) {
 				rule->mask.src_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.src_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1820,9 +1820,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == UINT8_MAX) {
 				rule->mask.dst_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.dst_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1835,9 +1835,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->input.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->input.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/txgbe/txgbe_ipsec.c +2 -2
index f9f8108fb894..4bad7fc76d42 100644
@@ -659,9 +659,9 @@ txgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
examples/ip_fragmentation/main.c +1 -1
index 736eae6f05ee..4c0fa5054a2e 100644
@@ -311,7 +311,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
 		ip_hdr = rte_pktmbuf_mtod(m, struct rte_ipv6_hdr *);
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			port_out = next_hop;
examples/ip_pipeline/pipeline.c +8 -8
index 301c52d061be..d08f8c24c80f 100644
@@ -638,7 +638,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 1,
 		.input_index = 1,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[0]),
 	},
 
 	[2] = {
@@ -646,7 +646,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 2,
 		.input_index = 2,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[4]),
 	},
 
 	[3] = {
@@ -654,7 +654,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 3,
 		.input_index = 3,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[8]),
 	},
 
 	[4] = {
@@ -662,7 +662,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 4,
 		.input_index = 4,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[12]),
 	},
 
 	/* Destination IP address (IPv6) */
@@ -671,7 +671,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 5,
 		.input_index = 5,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[0]),
 	},
 
 	[6] = {
@@ -679,7 +679,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 6,
 		.input_index = 6,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[4]),
 	},
 
 	[7] = {
@@ -687,7 +687,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 7,
 		.input_index = 7,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[8]),
 	},
 
 	[8] = {
@@ -695,7 +695,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 8,
 		.input_index = 8,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[12]),
 	},
 
 	/* Source Port */
examples/ip_reassembly/main.c +1 -1
index c7019078f7b4..4da692eb23e6 100644
@@ -400,7 +400,7 @@ reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queue,
 		}
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			dst_port = next_hop;
examples/ipsec-secgw/flow.c +6 -6
index 05a62c3020fa..8a0c79e1510a 100644
@@ -85,7 +85,7 @@ ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 {
 	uint8_t *addr;
 
-	addr = hdr->src_addr;
+	addr = hdr->src_addr.a;
 	printf("src: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx \t",
 	       (uint16_t)((addr[0] << 8) | addr[1]),
 	       (uint16_t)((addr[2] << 8) | addr[3]),
@@ -96,7 +96,7 @@ ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 	       (uint16_t)((addr[12] << 8) | addr[13]),
 	       (uint16_t)((addr[14] << 8) | addr[15]));
 
-	addr = hdr->dst_addr;
+	addr = hdr->dst_addr.a;
 	printf("dst: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx",
 	       (uint16_t)((addr[0] << 8) | addr[1]),
 	       (uint16_t)((addr[2] << 8) | addr[3]),
@@ -196,8 +196,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr,
-						  rule->ipv6.mask.hdr.src_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr.a,
+						  rule->ipv6.mask.hdr.src_addr.a,
 						  tokens[ti], status))
 					return;
 			}
@@ -205,8 +205,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr,
-						  rule->ipv6.mask.hdr.dst_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr.a,
+						  rule->ipv6.mask.hdr.dst_addr.a,
 						  tokens[ti], status))
 					return;
 			}
examples/ipsec-secgw/ipsec.c +4 -4
index b52b0ffc3d22..ebde28639c12 100644
@@ -529,9 +529,9 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 			sa->pattern[1].spec = &sa->ipv6_spec;
 
-			memcpy(sa->ipv6_spec.hdr.dst_addr,
+			memcpy(&sa->ipv6_spec.hdr.dst_addr,
 				sa->dst.ip.ip6.ip6_b, 16);
-			memcpy(sa->ipv6_spec.hdr.src_addr,
+			memcpy(&sa->ipv6_spec.hdr.src_addr,
 			       sa->src.ip.ip6.ip6_b, 16);
 		} else if (IS_IP4(sa->flags)) {
 			sa->pattern[1].mask = &rte_flow_item_ipv4_mask;
@@ -735,9 +735,9 @@ create_ipsec_esp_flow(struct ipsec_sa *sa)
 		sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 		sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 		sa->pattern[1].spec = &sa->ipv6_spec;
-		memcpy(sa->ipv6_spec.hdr.dst_addr,
+		memcpy(&sa->ipv6_spec.hdr.dst_addr,
 			sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b));
-		memcpy(sa->ipv6_spec.hdr.src_addr,
+		memcpy(&sa->ipv6_spec.hdr.src_addr,
 			sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b));
 		sa->pattern[2].type = RTE_FLOW_ITEM_TYPE_ESP;
 		sa->pattern[2].spec = &sa->esp_spec;
examples/ipsec-secgw/sa.c +2 -2
index c4bac17cd77c..1a0afd2ed2e8 100644
@@ -1571,8 +1571,8 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-		memcpy(v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
-		memcpy(v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
+		memcpy(&v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
+		memcpy(&v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
 	}
 
 	rc = fill_ipsec_sa_prm(&prm, lsa, &v4, &v6);
examples/ipsec-secgw/sad.h +6 -4
index 3224b6252c8d..fdb1d2ef1790 100644
@@ -5,6 +5,8 @@
 #ifndef __SAD_H__
 #define __SAD_H__
 
+#include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
 #define SA_CACHE_SZ	128
@@ -37,8 +39,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, ipv6->dst_addr, 16))))
+			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
+			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
 		return 1;
 
 	return 0;
@@ -128,9 +130,9 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, ipv6->dst_addr,
+			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
 					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, ipv6->src_addr,
+			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
 					sizeof(ipv6->src_addr));
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
examples/l3fwd/l3fwd_fib.c +1 -1
index f38b19af3f57..4a9534e9dbef 100644
@@ -65,7 +65,7 @@ fib_parse_packet(struct rte_mbuf *mbuf,
 	/* IPv6 */
 	else {
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-		rte_mov16(ipv6, (const uint8_t *)ipv6_hdr->dst_addr);
+		rte_mov16(ipv6, ipv6_hdr->dst_addr.a);
 		*ip_type = 0;
 		(*ipv6_cnt)++;
 	}
examples/l3fwd/l3fwd_lpm.c +2 -2
index e8fd95aae9ce..422fdb70054d 100644
@@ -62,7 +62,7 @@ lpm_get_ipv6_dst_port(const struct rte_ipv6_hdr *ipv6_hdr,
 		      uint16_t portid,
 		      struct rte_lpm6 *ipv6_l3fwd_lookup_struct)
 {
-	const uint8_t *dst_ip = ipv6_hdr->dst_addr;
+	const uint8_t *dst_ip = ipv6_hdr->dst_addr.a;
 	uint32_t next_hop;
 
 	if (rte_lpm6_lookup(ipv6_l3fwd_lookup_struct, dst_ip, &next_hop) == 0)
@@ -122,7 +122,7 @@ lpm_get_dst_port_with_ipv4(const struct lcore_conf *qconf, struct rte_mbuf *pkt,
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
 
 		return (uint16_t) ((rte_lpm6_lookup(qconf->ipv6_lookup_struct,
-				ipv6_hdr->dst_addr, &next_hop) == 0)
+				ipv6_hdr->dst_addr.a, &next_hop) == 0)
 				? next_hop : portid);
 
 	}
lib/ethdev/rte_flow.h +4 -2
index 3a3ab781c494..b3ede7ccdaef 100644
@@ -1006,12 +1006,14 @@ struct rte_flow_item_ipv6 {
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr =
+		.src_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
+		},
+		.dst_addr = { .a =
 			"\xff\xff\xff\xff\xff\xff\xff\xff"
 			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		},
 	},
 };
 #endif
lib/hash/rte_thash.h +6 -6
index af40afd2d475..9aaaacfd5fa4 100644
@@ -140,24 +140,24 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 			union rte_thash_tuple *targ)
 {
 #ifdef RTE_ARCH_X86
-	__m128i ipv6 = _mm_loadu_si128((const __m128i *)orig->src_addr);
+	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
 	*(__m128i *)targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
-	ipv6 = _mm_loadu_si128((const __m128i *)orig->dst_addr);
+	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
 	*(__m128i *)targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)orig->src_addr);
+	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
 	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)orig->dst_addr);
+	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
 	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
 		*((uint32_t *)targ->v6.src_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr.a + i));
 		*((uint32_t *)targ->v6.dst_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr.a + i));
 	}
 #endif
 }
lib/ip_frag/rte_ipv6_reassembly.c +2 -2
index 88863a98d1fe..9471ce5333d7 100644
@@ -143,8 +143,8 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	int32_t ip_len;
 	int32_t trim;
 
-	rte_memcpy(&key.src_dst[0], ip_hdr->src_addr, 16);
-	rte_memcpy(&key.src_dst[2], ip_hdr->dst_addr, 16);
+	rte_memcpy(&key.src_dst[0], &ip_hdr->src_addr, 16);
+	rte_memcpy(&key.src_dst[2], &ip_hdr->dst_addr, 16);
 
 	key.id = frag_hdr->id;
 	key.key_len = IPV6_KEYLEN;
lib/net/rte_ip6.h +3 -3
index 52c41088681e..5354a2bd42b4 100644
@@ -53,8 +53,8 @@ struct rte_ipv6_hdr {
 	rte_be16_t payload_len;	/**< IP payload size, including ext. headers */
 	uint8_t  proto;		/**< Protocol, next header. */
 	uint8_t  hop_limits;	/**< Hop limits. */
-	uint8_t  src_addr[16];	/**< IP address of source host. */
-	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
+	struct rte_ipv6_addr src_addr;	/**< IP address of source host. */
+	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
 /* IPv6 routing extension type definition. */
@@ -123,7 +123,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 		psd_hdr.len = ipv6_hdr->payload_len;
 	}
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr),
 		0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
lib/node/ip6_lookup.c +5 -5
index 309964f60fd6..6bbcf14e2aa8 100644
@@ -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_memcpy(ip_batch[0], &ipv6_hdr->dst_addr, 16);
 
 		/* 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_memcpy(ip_batch[1], &ipv6_hdr->dst_addr, 16);
 
 		/* 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_memcpy(ip_batch[2], &ipv6_hdr->dst_addr, 16);
 
 		/* 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_memcpy(ip_batch[3], &ipv6_hdr->dst_addr, 16);
 
 		rte_lpm6_lookup_bulk_func(lpm6, ip_batch, next_hop, 4);
 
@@ -223,7 +223,7 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 		/* Extract TTL as IPv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
 
-		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr, &next_hop);
+		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr.a, &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
 
 		node_mbuf_priv1(mbuf0, dyn)->nh = (uint16_t)next_hop;
lib/pipeline/rte_swx_ipsec.c +2 -4
index 56a401d0fa63..5920178f38e5 100644
@@ -1387,13 +1387,11 @@ tunnel_ipv6_header_set(struct rte_ipv6_hdr *h, struct rte_swx_ipsec_sa_params *p
 		.payload_len = 0, /* Cannot be pre-computed. */
 		.proto = IPPROTO_ESP,
 		.hop_limits = 64,
-		.src_addr = {0},
-		.dst_addr = {0},
 	};
 
 	memcpy(h, &ipv6_hdr, sizeof(ipv6_hdr));
-	memcpy(h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
-	memcpy(h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
+	memcpy(&h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
+	memcpy(&h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
 }
 
 /* IPsec library SA parameters. */
lib/pipeline/rte_table_action.c +12 -12
index ebbdd3f4cebe..a04d5121e1f0 100644
@@ -872,10 +872,10 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(d->ipv6.src_addr,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -907,10 +907,10 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(d->ipv6.src_addr,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -1437,12 +1437,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				tcp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1450,12 +1450,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				udp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1465,12 +1465,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr,
 				(uint16_t *)data->addr,
 				tcp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1478,12 +1478,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr.a,
 				(uint16_t *)data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
Signature · 1 line
2.46.1
#36 lore raw

Re: [PATCH dpdk v2 04/16] net: use ipv6 structure for header addresses

app/test/packet_burst_generator.c initialize_ipv6_header(struct rte_ipv6_hdr *ip_hdr, uint8_t *src_addr, · line 153

Quoted 12 lines · On Tue, 1 Oct 2024 10:17:16 +0200 Robin Jarry <[email protected]> wrote:
app/test/packet_burst_generator.c +2 -2
index 2cd34abc1a65..76a409a56452 100644
@@ -149,8 +149,8 @@ initialize_ipv6_header(struct rte_ipv6_hdr *ip_hdr, uint8_t *src_addr,
 	ip_hdr->proto = IPPROTO_UDP;
 	ip_hdr->hop_limits = IP_DEFTTL;
 
-	rte_memcpy(ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
-	rte_memcpy(ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
+	rte_memcpy(&ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
+	rte_memcpy(&ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));

please replace with structure assignment if possible.

#37 lore raw

Re: [PATCH dpdk v2 04/16] net: use ipv6 structure for header addresses

In reply to Robin Jarry
Quoted 5 lines · Robin Jarry
drivers/net/cxgbe/cxgbe_flow.c +0 -1
@@ -918,12 +918,14 @@ static struct chrte_fparse parseitem[] = {
 		.fptr  = ch_rte_parsetype_ipv6,
 		.dmask = &(const struct rte_flow_item_ipv6) {
 			.hdr = {
-				.src_addr =

drivers/net/cxgbe/cxgbe_flow.c static struct chrte_fparse parseitem[] = { · line 929

Quoted 10 lines
drivers/net/cxgbe/cxgbe_flow.c +4 -1
+				.src_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr =
+				},
+				.dst_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				},
 

Hi Robin,

gcc 15 complains about the string initialization [1], can we change these initializers?

[1]
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

#38 lore raw

Re: [PATCH dpdk v2 04/16] net: use ipv6 structure for header addresses

Ferruh Yigit, Oct 04, 2024 at 20:01:

Quoted 19 lines · Robin Jarry
Quoted 5 lines
drivers/net/cxgbe/cxgbe_flow.c +0 -1
@@ -918,12 +918,14 @@ static struct chrte_fparse parseitem[] = {
 		.fptr  = ch_rte_parsetype_ipv6,
 		.dmask = &(const struct rte_flow_item_ipv6) {
 			.hdr = {
-				.src_addr =

drivers/net/cxgbe/cxgbe_flow.c static struct chrte_fparse parseitem[] = { · line 929

Quoted 10 lines
drivers/net/cxgbe/cxgbe_flow.c +4 -1
+				.src_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr =
+				},
+				.dst_addr = { .a =
 					"\xff\xff\xff\xff\xff\xff\xff\xff"
 					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				},
 

Hi Robin,

Quoted 2 lines

gcc 15 complains about the string initialization [1], can we change these initializers?

Hi Ferruh,

yes of course I can change that. I may do it in a separate commit though. If that is ok.

#39 lore raw

Re: [PATCH dpdk v2 04/16] net: use ipv6 structure for header addresses

Quoted 20 lines · Robin Jarry

Ferruh Yigit, Oct 04, 2024 at 20:01:

Quoted 19 lines · Robin Jarry
Quoted 6 lines
drivers/net/cxgbe/cxgbe_flow.c +1 -1
@@ -918,12 +918,14 @@ static struct chrte_fparse parseitem[] = {
          .fptr  = ch_rte_parsetype_ipv6,
          .dmask = &(const struct rte_flow_item_ipv6) {
              .hdr = {
-                .src_addr =
+                .src_addr = { .a =
Quoted 9 lines

                     "\xff\xff\xff\xff\xff\xff\xff\xff" "\xff\xff\xff\xff\xff\xff\xff\xff", -                .dst_addr =
+                },
+                .dst_addr = { .a = "\xff\xff\xff\xff\xff\xff\xff\xff" "\xff\xff\xff\xff\xff\xff\xff\xff", +                },

Hi Robin,

Quoted 8 lines
Quoted 2 lines

gcc 15 complains about the string initialization [1], can we change these initializers?

Hi Ferruh,

yes of course I can change that. I may do it in a separate commit though. If that is ok.

I think OK to add it as a separate commit, thanks.

#40 lore raw

PATCH v2 5/16 fib6,rib6,lpm6: use ipv6 addr struct

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] array types in the API of rte_fib6, rte_rib6 and rte_lpm6. Update all code accordingly.

Unfortunately, these three libraries are strongly intertwined, it is not possible to split this change in separate commits.

---

Notes:
v2: updated changelog for 24.11

 app/test-fib/main.c                    |   51 +-
 app/test-pipeline/pipeline_lpm_ipv6.c  |   10 +-
 app/test/test_fib6.c                   |   52 +-
 app/test/test_fib6_perf.c              |    8 +-
 app/test/test_lpm6.c                   |  523 +++---
 app/test/test_lpm6_data.h              | 2025 ++++++++++++------------
 app/test/test_lpm6_perf.c              |   10 +-
 app/test/test_rib6.c                   |   65 +-
 app/test/test_table_combined.c         |    2 +-
 app/test/test_table_tables.c           |    8 +-
 doc/guides/rel_notes/deprecation.rst   |   20 -
 doc/guides/rel_notes/release_24_11.rst |    2 +
 examples/ip_fragmentation/main.c       |   24 +-
 examples/ip_pipeline/thread.c          |    2 +-
 examples/ip_reassembly/main.c          |   24 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h  |    7 +-
 examples/ipsec-secgw/ipsec_worker.c    |    6 +-
 examples/ipsec-secgw/ipsec_worker.h    |    4 +-
 examples/ipsec-secgw/rt.c              |   22 +-
 examples/l3fwd/l3fwd_fib.c             |   39 +-
 examples/l3fwd/l3fwd_lpm.c             |    8 +-
 examples/l3fwd/l3fwd_route.h           |    7 +-
 examples/l3fwd/lpm_route_parse.c       |    6 +-
 lib/fib/meson.build                    |    4 +-
 lib/fib/rte_fib6.c                     |   13 +-
 lib/fib/rte_fib6.h                     |   11 +-
 lib/fib/trie.c                         |   99 +-
 lib/fib/trie.h                         |   16 +-
 lib/fib/trie_avx512.c                  |   38 +-
 lib/fib/trie_avx512.h                  |   10 +-
 lib/lpm/meson.build                    |    1 +
 lib/lpm/rte_lpm6.c                     |  106 +-
 lib/lpm/rte_lpm6.h                     |   14 +-
 lib/node/ip6_lookup.c                  |   16 +-
 lib/rib/meson.build                    |    2 +-
 lib/rib/rte_rib6.c                     |   74 +-
 lib/rib/rte_rib6.h                     |   13 +-
 lib/table/rte_table_lpm_ipv6.c         |   12 +-
 lib/table/rte_table_lpm_ipv6.h         |    4 +-
 39 files changed, 1683 insertions(+), 1675 deletions(-)
app/test-fib/main.c +25 -26
index c49bfe8bcec3..a43a0ae4df5d 100644
@@ -123,7 +123,7 @@ struct rt_rule_4 {
 };
 
 struct rt_rule_6 {
-	uint8_t		addr[16];
+	struct rte_ipv6_addr addr;
 	uint8_t		depth;
 	uint64_t	nh;
 };
@@ -306,15 +306,15 @@ shuffle_rt_6(struct rt_rule_6 *rt, int n)
 
 	for (i = 0; i < n; i++) {
 		j = rte_rand() % n;
-		memcpy(tmp.addr, rt[i].addr, 16);
+		memcpy(&tmp.addr, &rt[i].addr, 16);
 		tmp.depth = rt[i].depth;
 		tmp.nh = rt[i].nh;
 
-		memcpy(rt[i].addr, rt[j].addr, 16);
+		memcpy(&rt[i].addr, &rt[j].addr, 16);
 		rt[i].depth = rt[j].depth;
 		rt[i].nh = rt[j].nh;
 
-		memcpy(rt[j].addr, tmp.addr, 16);
+		memcpy(&rt[j].addr, &tmp.addr, 16);
 		rt[j].depth = tmp.depth;
 		rt[j].nh = tmp.nh;
 	}
@@ -364,7 +364,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 	uint32_t a, i, j, k = 0;
 
 	if (config.nb_routes_per_depth[0] != 0) {
-		memset(rt[k].addr, 0, 16);
+		memset(&rt[k].addr, 0, 16);
 		rt[k].depth = 0;
 		rt[k++].nh = rte_rand() & get_max_nh(nh_sz);
 	}
@@ -380,7 +380,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 				uint64_t rnd_val = get_rnd_rng((uint64_t)edge,
 					(uint64_t)(edge + step));
 				rnd = rte_cpu_to_be_32(rnd_val << (32 - i));
-				complete_v6_addr((uint32_t *)rt[k].addr,
+				complete_v6_addr((uint32_t *)&rt[k].addr,
 					rnd, a);
 				rt[k].depth = (a * 32) + i;
 				rt[k].nh = rte_rand() & get_max_nh(nh_sz);
@@ -390,19 +390,19 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 }
 
 static inline void
-set_rnd_ipv6(uint8_t *addr, uint8_t *route, int depth)
+set_rnd_ipv6(struct rte_ipv6_addr *addr, struct rte_ipv6_addr *route, int depth)
 {
 	int i;
 
 	for (i = 0; i < 16; i++)
-		addr[i] = rte_rand();
+		addr->a[i] = rte_rand();
 
 	for (i = 0; i < 16; i++) {
 		if (depth >= 8)
-			addr[i] = route[i];
+			addr->a[i] = route->a[i];
 		else if (depth > 0) {
-			addr[i] &= (uint16_t)UINT8_MAX >> depth;
-			addr[i] |= route[i] & UINT8_MAX << (8 - depth);
+			addr->a[i] &= (uint16_t)UINT8_MAX >> depth;
+			addr->a[i] |= route->a[i] & UINT8_MAX << (8 - depth);
 		} else
 			return;
 		depth -= 8;
@@ -413,7 +413,7 @@ static void
 gen_rnd_lookup_tbl(int af)
 {
 	uint32_t *tbl4 = config.lookup_tbl;
-	uint8_t *tbl6 = config.lookup_tbl;
+	struct rte_ipv6_addr *tbl6 = config.lookup_tbl;
 	struct rt_rule_4 *rt4 = (struct rt_rule_4 *)config.rt;
 	struct rt_rule_6 *rt6 = (struct rt_rule_6 *)config.rt;
 	uint32_t i, j;
@@ -432,11 +432,10 @@ gen_rnd_lookup_tbl(int af)
 		for (i = 0, j = 0; i < config.nb_lookup_ips;
 				i++, j = (j + 1) % config.nb_routes) {
 			if ((rte_rand() % 100) < config.rnd_lookup_ips_ratio) {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr, 0);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, 0);
 				config.nb_lookup_ips_rnd++;
 			} else {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr,
-					rt6[j].depth);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, rt6[j].depth);
 			}
 		}
 	}
@@ -522,7 +521,7 @@ parse_rt_6(FILE *f)
 			s = NULL;
 		}
 
-		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], rt[j].addr);
+		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], &rt[j].addr);
 		if (ret < 0)
 			return ret;
 
@@ -1023,7 +1022,7 @@ dump_rt_6(struct rt_rule_6 *rt)
 	}
 
 	for (i = 0; i < config.nb_routes; i++) {
-		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(rt[i].addr),
+		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(&rt[i].addr),
 			rt[i].depth, rt[i].nh);
 
 	}
@@ -1043,7 +1042,7 @@ run_v6(void)
 	int ret = 0;
 	struct rte_lpm6	*lpm = NULL;
 	struct rte_lpm6_config lpm_conf;
-	uint8_t *tbl6;
+	struct rte_ipv6_addr *tbl6;
 	uint64_t fib_nh[BURST_SZ];
 	int32_t lpm_nh[BURST_SZ];
 
@@ -1094,7 +1093,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
-			ret = rte_fib6_add(fib, rt[i + j].addr,
+			ret = rte_fib6_add(fib, &rt[i + j].addr,
 				rt[i + j].depth, rt[i + j].nh);
 			if (unlikely(ret != 0)) {
 				printf("Can not add a route to FIB, err %d\n",
@@ -1120,7 +1119,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++) {
-				ret = rte_lpm6_add(lpm, rt[i + j].addr,
+				ret = rte_lpm6_add(lpm, &rt[i + j].addr,
 					rt[i + j].depth, rt[i + j].nh);
 				if (ret != 0) {
 					if (rt[i + j].depth == 0)
@@ -1139,7 +1138,7 @@ run_v6(void)
 	acc = 0;
 	for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 		start = rte_rdtsc_precise();
-		ret = rte_fib6_lookup_bulk(fib, (uint8_t (*)[16])(tbl6 + i*16),
+		ret = rte_fib6_lookup_bulk(fib, &tbl6[i],
 			fib_nh, BURST_SZ);
 		acc += rte_rdtsc_precise() - start;
 		if (ret != 0) {
@@ -1154,7 +1153,7 @@ run_v6(void)
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			start = rte_rdtsc_precise();
 			ret = rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			acc += rte_rdtsc_precise() - start;
 			if (ret != 0) {
@@ -1166,10 +1165,10 @@ run_v6(void)
 
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			rte_fib6_lookup_bulk(fib,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				fib_nh, BURST_SZ);
 			rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			for (j = 0; j < BURST_SZ; j++) {
 				if ((fib_nh[j] != (uint32_t)lpm_nh[j]) &&
@@ -1186,7 +1185,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++)
-			rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth);
+			rte_fib6_delete(fib, &rt[i + j].addr, rt[i + j].depth);
 
 		printf("AVG FIB delete %"PRIu64"\n",
 			(rte_rdtsc_precise() - start) / j);
@@ -1197,7 +1196,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++)
-				rte_lpm6_delete(lpm, rt[i + j].addr,
+				rte_lpm6_delete(lpm, &rt[i + j].addr,
 					rt[i + j].depth);
 
 			printf("AVG LPM delete %"PRIu64"\n",
app/test-pipeline/pipeline_lpm_ipv6.c +5 -5
index 207ffbeff00f..cfebfbbc81ca 100644
@@ -127,16 +127,16 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) {
 
 		ip = rte_bswap32(i << (24 -
 			rte_popcount32(app.n_ports - 1)));
-		memcpy(key.ip, &ip, sizeof(uint32_t));
+		memcpy(&key.ip, &ip, sizeof(uint32_t));
 
 		printf("Adding rule to IPv6 LPM table (IPv6 destination = "
 			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:"
 			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x/%u => "
 			"port out = %u)\n",
-			key.ip[0], key.ip[1], key.ip[2], key.ip[3],
-			key.ip[4], key.ip[5], key.ip[6], key.ip[7],
-			key.ip[8], key.ip[9], key.ip[10], key.ip[11],
-			key.ip[12], key.ip[13], key.ip[14], key.ip[15],
+			key.ip.a[0], key.ip.a[1], key.ip.a[2], key.ip.a[3],
+			key.ip.a[4], key.ip.a[5], key.ip.a[6], key.ip.a[7],
+			key.ip.a[8], key.ip.a[9], key.ip.a[10], key.ip.a[11],
+			key.ip.a[12], key.ip.a[13], key.ip.a[14], key.ip.a[15],
 			key.depth, i);
 
 		status = rte_pipeline_table_entry_add(p, table_id, &key, &entry,
app/test/test_fib6.c +26 -26

134 lines not on this page · raw message

app/test/test_fib6_perf.c +4 -4
index fe713e7094e5..d51bbdbdd6fa 100644
@@ -73,7 +73,7 @@ test_fib6_perf(void)
 	uint64_t next_hop_add;
 	int status = 0;
 	int64_t count = 0;
-	uint8_t ip_batch[NUM_IPS_ENTRIES][16];
+	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
 	uint64_t next_hops[NUM_IPS_ENTRIES];
 
 	conf.type = RTE_FIB6_TRIE;
@@ -101,7 +101,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		next_hop_add = (i & ((1 << 14) - 1)) + 1;
-		if (rte_fib6_add(fib, large_route_table[i].ip,
+		if (rte_fib6_add(fib, &large_route_table[i].ip,
 				large_route_table[i].depth, next_hop_add) == 0)
 			status++;
 	}
@@ -117,7 +117,7 @@ test_fib6_perf(void)
 	count = 0;
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
-		memcpy(ip_batch[i], large_ips_table[i].ip, 16);
+		memcpy(&ip_batch[i], &large_ips_table[i].ip, 16);
 
 	for (i = 0; i < ITERATIONS; i++) {
 
@@ -140,7 +140,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		/* rte_fib_delete(fib, ip, depth) */
-		status += rte_fib6_delete(fib, large_route_table[i].ip,
+		status += rte_fib6_delete(fib, &large_route_table[i].ip,
 				large_route_table[i].depth);
 	}
 
app/test/test_lpm6.c +269 -254

1,292 lines not on this page · raw message

app/test/test_lpm6_data.h +1013 -1012

1,350 lines not on this page · raw message

app/test/test_lpm6_perf.c +5 -5
index c847dcb18375..0f9e3698c4da 100644

Lines of this file are not shown. View the raw message.

app/test/test_rib6.c +35 -30

65 lines not on this page · raw message

app/test/test_table_combined.c +1 -1
index 1c2efe649ded..04503baa5180 100644

Lines of this file are not shown. View the raw message.

app/test/test_table_tables.c +4 -4
index 26908e6112fc..920aa555cbd2 100644

Lines of this file are not shown. View the raw message.

doc/guides/rel_notes/deprecation.rst +0 -20
index 439867289cf3..ee958c689b3a 100644

Lines of this file are not shown. View the raw message.

doc/guides/rel_notes/release_24_11.rst +2 -0
index 2d5b29b5a2d4..984ef5e35fb9 100644

Lines of this file are not shown. View the raw message.

examples/ip_fragmentation/main.c +12 -12
index 4c0fa5054a2e..611b5818d88c 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/thread.c +1 -1
index 8a912dc1b392..9d8082b73080 100644

Lines of this file are not shown. View the raw message.

examples/ip_reassembly/main.c +12 -12
index 4da692eb23e6..06383cc36289 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_lpm_neon.h +4 -3
index 9573f53ae957..865b9624a86e 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.c +3 -3
index c9c43ebd2b99..3a83b7c0bf4b 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.h +2 -2
index 8f6a1c06aa7f..8f9616129362 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/rt.c +11 -11
index ce854ccb6018..059fc0c8f28c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_fib.c +18 -21
index 4a9534e9dbef..046aa1027b5c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_lpm.c +4 -4
index 422fdb70054d..fc4f5878fcd8 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_route.h +3 -4
index 467c4d285915..ceabf4fa8e3c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/lpm_route_parse.c +3 -3
index f2028d79e180..d553ebdbcc5c 100644

Lines of this file are not shown. View the raw message.

lib/fib/meson.build +2 -2
index 6795f41a0ad2..268007ef6c93 100644

Lines of this file are not shown. View the raw message.

lib/fib/rte_fib6.c +7 -6
index 9ad990724a8b..d95cac79cbb5 100644

Lines of this file are not shown. View the raw message.

lib/fib/rte_fib6.h +6 -5
index 2eb8b8267647..d26a0c7c0b77 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie.c +48 -51

99 lines not on this page · raw message

lib/fib/trie.h +9 -7
index 2c20184a26a3..6e235edaf89c 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie_avx512.c +19 -19
index d4d70d84bf60..f49482a95dfa 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie_avx512.h +7 -3
index ef8c7f0e3474..1028a4899fc7 100644

Lines of this file are not shown. View the raw message.

lib/lpm/meson.build +1 -0
index ae30f80b69c8..fae4f79fb938 100644

Lines of this file are not shown. View the raw message.

lib/lpm/rte_lpm6.c +53 -53

106 lines not on this page · raw message

lib/lpm/rte_lpm6.h +8 -6
index c93683e6240c..87392194237c 100644

Lines of this file are not shown. View the raw message.

lib/node/ip6_lookup.c +8 -8
index 6bbcf14e2aa8..1ad6e3fd18f2 100644

Lines of this file are not shown. View the raw message.

lib/rib/meson.build +1 -1
index 7bacbb453592..e98f70848189 100644

Lines of this file are not shown. View the raw message.

lib/rib/rte_rib6.c +37 -37

74 lines not on this page · raw message

lib/rib/rte_rib6.h +7 -6
index 775286f965f2..47dcb6d15183 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.c +6 -6
index c1a7412f92cf..dea11130d3d5 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.h +2 -2
index 96ddbd32c20e..d96ce1179954 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.46.1

Part of the diff is not shown here. View the raw message.

#41 lore raw

Re: [PATCH dpdk v2 05/16] fib6,rib6,lpm6: use ipv6 addr struct

Quoted 67 lines · On Tue, 1 Oct 2024 10:17:17 +0200 Robin Jarry <[email protected]> wrote:

Replace ad-hoc uint8_t[16] array types in the API of rte_fib6, rte_rib6 and rte_lpm6. Update all code accordingly.

Unfortunately, these three libraries are strongly intertwined, it is not possible to split this change in separate commits.

---

Notes:
v2: updated changelog for 24.11

 app/test-fib/main.c                    |   51 +-
 app/test-pipeline/pipeline_lpm_ipv6.c  |   10 +-
 app/test/test_fib6.c                   |   52 +-
 app/test/test_fib6_perf.c              |    8 +-
 app/test/test_lpm6.c                   |  523 +++---
 app/test/test_lpm6_data.h              | 2025 ++++++++++++------------
 app/test/test_lpm6_perf.c              |   10 +-
 app/test/test_rib6.c                   |   65 +-
 app/test/test_table_combined.c         |    2 +-
 app/test/test_table_tables.c           |    8 +-
 doc/guides/rel_notes/deprecation.rst   |   20 -
 doc/guides/rel_notes/release_24_11.rst |    2 +
 examples/ip_fragmentation/main.c       |   24 +-
 examples/ip_pipeline/thread.c          |    2 +-
 examples/ip_reassembly/main.c          |   24 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h  |    7 +-
 examples/ipsec-secgw/ipsec_worker.c    |    6 +-
 examples/ipsec-secgw/ipsec_worker.h    |    4 +-
 examples/ipsec-secgw/rt.c              |   22 +-
 examples/l3fwd/l3fwd_fib.c             |   39 +-
 examples/l3fwd/l3fwd_lpm.c             |    8 +-
 examples/l3fwd/l3fwd_route.h           |    7 +-
 examples/l3fwd/lpm_route_parse.c       |    6 +-
 lib/fib/meson.build                    |    4 +-
 lib/fib/rte_fib6.c                     |   13 +-
 lib/fib/rte_fib6.h                     |   11 +-
 lib/fib/trie.c                         |   99 +-
 lib/fib/trie.h                         |   16 +-
 lib/fib/trie_avx512.c                  |   38 +-
 lib/fib/trie_avx512.h                  |   10 +-
 lib/lpm/meson.build                    |    1 +
 lib/lpm/rte_lpm6.c                     |  106 +-
 lib/lpm/rte_lpm6.h                     |   14 +-
 lib/node/ip6_lookup.c                  |   16 +-
 lib/rib/meson.build                    |    2 +-
 lib/rib/rte_rib6.c                     |   74 +-
 lib/rib/rte_rib6.h                     |   13 +-
 lib/table/rte_table_lpm_ipv6.c         |   12 +-
 lib/table/rte_table_lpm_ipv6.h         |    4 +-
 39 files changed, 1683 insertions(+), 1675 deletions(-)
app/test-fib/main.c +1 -1
index c49bfe8bcec3..a43a0ae4df5d 100644
@@ -123,7 +123,7 @@ struct rt_rule_4 {
 };
 
 struct rt_rule_6 {
-	uint8_t		addr[16];
+	struct rte_ipv6_addr addr;
 	uint8_t		depth;
 	uint64_t	nh;
 };

app/test-fib/main.c shuffle_rt_6(struct rt_rule_6 *rt, int n) · line 309

Quoted 5 lines
app/test-fib/main.c +1 -1
@@ -306,15 +306,15 @@ shuffle_rt_6(struct rt_rule_6 *rt, int n)
 
 	for (i = 0; i < n; i++) {
 		j = rte_rand() % n;
-		memcpy(tmp.addr, rt[i].addr, 16);
+		memcpy(&tmp.addr, &rt[i].addr, 16);

Yet more places where memcpy should be replaced by assignment.

#42 lore raw

PATCH v2 6/16 net: add ipv6 address utilities

In reply to Robin Jarry

Add utility functions that use the previously introduced IPv6 address structure. Add basic unit tests to ensure everything works as expected.

These functions will be used in the next commits to replace private and/or duplicated functions.

---

Notes:
v2:

- added RTE_IPV6_ADDR() helper macro
- added app/test/test_net_ipv6.c in MAINTAINERS

 MAINTAINERS              |   1 +
 app/test/meson.build     |   1 +
 app/test/test_net_ipv6.c | 129 +++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip6.h        | 117 +++++++++++++++++++++++++++++++++++
 4 files changed, 248 insertions(+)
 create mode 100644 app/test/test_net_ipv6.c
MAINTAINERS +1 -0
index af2620bf0a4d..c1c16a443c33 100644
@@ -1520,6 +1520,7 @@ F: lib/net/
 F: app/test/test_cksum.c
 F: app/test/test_cksum_perf.c
 F: app/test/test_net_ether.c
+F: app/test/test_net_ip6.c
 
 Packet CRC
 M: Jasvinder Singh <[email protected]>
app/test/meson.build +1 -0
index e29258e6ec05..f5276e28c3b9 100644
@@ -130,6 +130,7 @@ source_file_deps = {
     'test_metrics.c': ['metrics'],
     'test_mp_secondary.c': ['hash'],
     'test_net_ether.c': ['net'],
+    'test_net_ipv6.c': ['net'],
     'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'],
     'test_pdcp.c': ['eventdev', 'pdcp', 'net', 'timer', 'security'],
     'test_pdump.c': ['pdump'] + sample_packet_forward_deps,
app/test/test_net_ipv6.c new file +129 -0

129 lines not on this page · raw message

lib/net/rte_ip6.h +117 -0

135 lines not on this page · raw message

Signature · 1 line
2.46.1
#43 lore raw

Re: [PATCH dpdk v2 06/16] net: add ipv6 address utilities

Quoted 8 lines · On Tue, 1 Oct 2024 10:17:18 +0200 Robin Jarry <[email protected]> wrote:
lib/net/rte_ip6.h +8 -0
+/** Shorthand to initialize IPv6 address values */
+#define RTE_IPV6_ADDR(...) ((struct rte_ipv6_addr){.a = {__VA_ARGS__}})
+
+/**
+ * Copy an IPv6 address into another one.
+ *
+ * @param dst
+ *   The address into which to copy data.

lib/net/rte_ip6.h struct rte_ipv6_addr { · line 67

Quoted 10 lines
lib/net/rte_ip6.h +10 -0
+ * @param src
+ *   The address from which to copy.
+ */
+static inline void
+rte_ipv6_addr_cpy(struct rte_ipv6_addr *dst, const struct rte_ipv6_addr *src)
+{
+	rte_memcpy(dst, src, sizeof(*dst));
+}
+
+/**

Please do not introduce more rte_memcpy() there is no reason not to just use structure assignment, which makes the whole need for this function go away.

#44 lore raw

Re: [PATCH dpdk v2 06/16] net: add ipv6 address utilities

In reply to Robin Jarry

lib/net/rte_ip6.h struct rte_ipv6_addr { · line 65

Quoted 13 lines · On Tue, 1 Oct 2024 10:17:18 +0200 Robin Jarry <[email protected]> wrote:
lib/net/rte_ip6.h +13 -0
+/**
+ * Copy an IPv6 address into another one.
+ *
+ * @param dst
+ *   The address into which to copy data.
+ * @param src
+ *   The address from which to copy.
+ */
+static inline void
+rte_ipv6_addr_cpy(struct rte_ipv6_addr *dst, const struct rte_ipv6_addr *src)
+{
+	rte_memcpy(dst, src, sizeof(*dst));
+}

No should be structure assignment.

#45 lore raw

PATCH v2 7/16 fib6,rib6,lpm6: use ipv6 utils

In reply to Robin Jarry

Replace duplicated and/or private functions by some of the previously introduced utility functions.

Mark rib6 functions that deal with ipv6 addresses as deprecated.

---
 app/test/test_fib6.c                  |  9 +++--
 app/test/test_rib6.c                  |  2 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h |  2 +-
 lib/fib/trie.c                        | 30 ++++++--------
 lib/lpm/rte_lpm6.c                    | 51 +++++-------------------
 lib/rib/rte_rib6.c                    | 57 +++++++++------------------
 lib/rib/rte_rib6.h                    |  8 ++++
 7 files changed, 56 insertions(+), 103 deletions(-)
app/test/test_fib6.c +6 -3
index c3b947d789bb..7134c4d335cd 100644
@@ -279,9 +279,12 @@ check_fib(struct rte_fib6 *fib)
 	int ret;
 
 	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
-		for (j = 0; j < RTE_FIB6_IPV6_ADDR_SIZE; j++) {
-			ip_arr[i].a[j] = ip_add.a[j] |
-				~get_msk_part(RTE_FIB6_MAXDEPTH - i, j);
+		rte_ipv6_addr_cpy(&ip_arr[i], &ip_add);
+		j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT;
+		if (j < RTE_FIB6_IPV6_ADDR_SIZE) {
+			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT);
+			for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++)
+				ip_arr[i].a[j] = 0xff;
 		}
 	}
 
app/test/test_rib6.c +1 -1
index f3b6f1474348..33288f9c26d6 100644
@@ -217,7 +217,7 @@ test_get_fn(void)
 
 	/* check the return values */
 	ret = rte_rib6_get_ip(node, &ip_ret);
-	RTE_TEST_ASSERT((ret == 0) && (rte_rib6_is_equal(ip_ret.a, ip.a)),
+	RTE_TEST_ASSERT((ret == 0) && (rte_ipv6_addr_eq(&ip_ret, &ip)),
 		"Failed to get proper node ip\n");
 	ret = rte_rib6_get_depth(node, &depth_ret);
 	RTE_TEST_ASSERT((ret == 0) && (depth_ret == depth),
examples/ipsec-secgw/ipsec_lpm_neon.h +1 -1
index 865b9624a86e..62b4260843a3 100644
@@ -144,7 +144,7 @@ route6_pkts_neon(struct rt_ctx *rt_ctx, struct rte_mbuf **pkts, int nb_rx)
 			 * required to get the hop
 			 */
 			ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-			memcpy(&dst_ip6[lpm_pkts], &ipv6_hdr->dst_addr, 16);
+			rte_ipv6_addr_cpy(&dst_ip6[lpm_pkts], &ipv6_hdr->dst_addr);
 			lpm_pkts++;
 		}
 	}
lib/fib/trie.c +11 -19
index bd0c7ec63b7f..8a69702eabb2 100644
@@ -367,7 +367,7 @@ install_to_dp(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ledge,
 	struct rte_ipv6_addr redge;
 
 	/* decrement redge by 1*/
-	rte_rib6_copy_addr(redge.a, r->a);
+	rte_ipv6_addr_cpy(&redge, r);
 	for (i = 15; i >= 0; i--) {
 		redge.a[i]--;
 		if (redge.a[i] != 0xff)
@@ -451,14 +451,6 @@ get_nxt_net(struct rte_ipv6_addr *ip, uint8_t depth)
 	}
 }
 
-static int
-v6_addr_is_zero(const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE])
-{
-	uint8_t ip_addr[RTE_FIB6_IPV6_ADDR_SIZE] = {0};
-
-	return rte_rib6_is_equal(ip, ip_addr);
-}
-
 static int
 modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 	const struct rte_ipv6_addr *ip,
@@ -472,7 +464,7 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 	if (next_hop > get_max_nh(dp->nh_sz))
 		return -EINVAL;
 
-	rte_rib6_copy_addr(ledge.a, ip->a);
+	rte_ipv6_addr_cpy(&ledge, ip);
 	do {
 		tmp = rte_rib6_get_nxt(rib, ip, depth, tmp,
 			RTE_RIB6_GET_NXT_COVER);
@@ -481,7 +473,7 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 			if (tmp_depth == depth)
 				continue;
 			rte_rib6_get_ip(tmp, &redge);
-			if (rte_rib6_is_equal(ledge.a, redge.a)) {
+			if (rte_ipv6_addr_eq(&ledge, &redge)) {
 				get_nxt_net(&ledge, tmp_depth);
 				continue;
 			}
@@ -489,18 +481,18 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 			if (ret != 0)
 				return ret;
 			get_nxt_net(&redge, tmp_depth);
-			rte_rib6_copy_addr(ledge.a, redge.a);
+			rte_ipv6_addr_cpy(&ledge, &redge);
 			/*
 			 * we got to the end of address space
 			 * and wrapped around
 			 */
-			if (v6_addr_is_zero(ledge.a))
+			if (rte_ipv6_addr_is_unspec(&ledge))
 				break;
 		} else {
-			rte_rib6_copy_addr(redge.a, ip->a);
+			rte_ipv6_addr_cpy(&redge, ip);
 			get_nxt_net(&redge, depth);
-			if (rte_rib6_is_equal(ledge.a, redge.a) &&
-					!v6_addr_is_zero(ledge.a))
+			if (rte_ipv6_addr_eq(&ledge, &redge) &&
+					!rte_ipv6_addr_is_unspec(&ledge))
 				break;
 
 			ret = install_to_dp(dp, &ledge, &redge, next_hop);
@@ -522,7 +514,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	struct rte_rib6_node *node;
 	struct rte_rib6_node *parent;
 	struct rte_ipv6_addr ip_masked;
-	int i, ret = 0;
+	int ret = 0;
 	uint64_t par_nh, node_nh;
 	uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
 
@@ -534,8 +526,8 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	rib = rte_fib6_get_rib(fib);
 	RTE_ASSERT(rib);
 
-	for (i = 0; i < RTE_FIB6_IPV6_ADDR_SIZE; i++)
-		ip_masked.a[i] = ip->a[i] & get_msk_part(depth, i);
+	rte_ipv6_addr_cpy(&ip_masked, ip);
+	rte_ipv6_addr_mask(&ip_masked, depth);
 
 	if (depth > 24) {
 		tmp = rte_rib6_get_nxt(rib, &ip_masked,
lib/lpm/rte_lpm6.c +10 -41

93 lines not on this page · raw message

lib/rib/rte_rib6.c +19 -38

154 lines not on this page · raw message

lib/rib/rte_rib6.h +8 -0
index 47dcb6d15183..fcf4169ca790 100644
@@ -57,6 +57,9 @@ struct rte_rib6_conf {
  * @param src
  *  pointer from where to copy
  */
+static inline void rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
+	__rte_deprecated_msg("replaced by rte_ipv6_addr_cpy");
+
 static inline void
 rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
@@ -77,6 +80,9 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
  *  1 if equal
  *  0 otherwise
  */
+static inline int rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2)
+	__rte_deprecated_msg("replaced by rte_ipv6_addr_eq");
+
 static inline int
 rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 	int i;
@@ -101,6 +107,8 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
  * @return
  *  8-bit chunk of the 128-bit IPv6 mask
  */
+static inline uint8_t get_msk_part(uint8_t depth, int byte) __rte_deprecated;
+
 static inline uint8_t
 get_msk_part(uint8_t depth, int byte) {
 	uint8_t part;
Signature · 1 line
2.46.1
#46 lore raw

PATCH v2 8/16 graph,node: use ipv6 addr struct and utils

In reply to Robin Jarry

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

---

Notes:
v2: updated changelog for 24.11

 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 +++--
 doc/guides/rel_notes/deprecation.rst   |  2 --
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 examples/l3fwd-graph/main.c            | 30 ++++++----------
 lib/node/ip6_lookup.c                  | 17 ++++------
 lib/node/rte_node_ip6_api.h            |  3 +-
 12 files changed, 67 insertions(+), 119 deletions(-)
app/graph/ethdev.c +12 -28
index cfc1b1856910..19c5ab685464 100644
@@ -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)
app/graph/ethdev.h +4 -5
index d0de593fc743..046689ee5fc7 100644
@@ -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);
 
app/graph/ip6_route.c +11 -36

89 lines not on this page · raw message

app/graph/meson.build +1 -1
index 6dc54d5ee63f..344e4a418fc0 100644
@@ -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',
app/graph/neigh.c +9 -13
index 79fd542c8948..0b35f4d6c294 100644
@@ -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);
 }
app/graph/neigh_priv.h +3 -1
index 1a7106c309bc..b2a7607e01bb 100644
@@ -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;
 };
app/graph/route.h +5 -3
index 23a7951d2dad..455aab8634d4 100644
@@ -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;
 };
 
doc/guides/rel_notes/deprecation.rst +0 -2
index ee958c689b3a..c268c497834c 100644
@@ -76,8 +76,6 @@ Deprecation Notices
     - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
-  node
-    - ``rte_node_ip6_route_add()``
   pipeline
     - ``struct rte_table_action_ipv6_header``
 
doc/guides/rel_notes/release_24_11.rst +2 -0
index 984ef5e35fb9..1d272982810c 100644
@@ -89,6 +89,8 @@ API Changes
   ``uint8_t[16]`` fields.
 * rib6,fib6,lpm6: All public API functions were modified to use ``struct rte_ipv6_addr`` instead of
   ``uint8_t[16]`` parameters.
+* node: ``rte_node_ip6_route_add()`` was modified to use a ``struct rte_ipv6_addr`` instead of
+  ``uint8_t[16]`` parameter.
 
 ABI Changes
 -----------
examples/l3fwd-graph/main.c +11 -19
index a13dc011380d..c2067a05f3ef 100644
@@ -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);
 
lib/node/ip6_lookup.c +7 -10
index 1ad6e3fd18f2..0806500d86cf 100644
@@ -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 "
lib/node/rte_node_ip6_api.h +2 -1
index a538dc2ea701..dc8c86184afe 100644
@@ -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);
 
 /**
Signature · 1 line
2.46.1
#47 lore raw

PATCH v2 9/16 pipeline: use ipv6 addr struct

In reply to Robin Jarry

Update rte_table_action_ipv6_header and rte_table_action_nat_params to use the recently added IPv6 address structure instead of uint8_t[16] arrays.

---

Notes:
v2: updated changelog for 24.11

 doc/guides/rel_notes/deprecation.rst   |  2 --
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 examples/ip_pipeline/cli.c             | 12 ++++-----
 lib/pipeline/rte_table_action.c        | 36 ++++++++++----------------
 lib/pipeline/rte_table_action.h        |  7 ++---
 5 files changed, 26 insertions(+), 33 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -2
index c268c497834c..fcccb22593d8 100644
@@ -76,8 +76,6 @@ Deprecation Notices
     - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
-  pipeline
-    - ``struct rte_table_action_ipv6_header``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index 1d272982810c..3eb43ba8520f 100644
@@ -91,6 +91,8 @@ API Changes
   ``uint8_t[16]`` parameters.
 * node: ``rte_node_ip6_route_add()`` was modified to use a ``struct rte_ipv6_addr`` instead of
   ``uint8_t[16]`` parameter.
+* pipeline: ``rte_table_action_ipv6_header`` and ``rte_table_action_nat_params`` were modified to
+  use ``rte_ipv6_addr`` structures instead of ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
examples/ip_pipeline/cli.c +6 -6
index e8269ea90c11..66fdeac8f501 100644
@@ -3540,8 +3540,8 @@ parse_table_action_encap(char **tokens,
 				parser_read_uint8(&hop_limit, tokens[5]))
 				return 0;
 
-			memcpy(a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
-			memcpy(a->encap.vxlan.ipv6.da, da.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.da, da.s6_addr, 16);
 			a->encap.vxlan.ipv6.flow_label = flow_label;
 			a->encap.vxlan.ipv6.dscp = dscp;
 			a->encap.vxlan.ipv6.hop_limit = hop_limit;
@@ -3615,7 +3615,7 @@ parse_table_action_nat(char **tokens,
 			return 0;
 
 		a->nat.ip_version = 0;
-		memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
+		memcpy(&a->nat.addr.ipv6, addr.s6_addr, 16);
 		a->nat.port = port;
 		a->action_mask |= 1 << RTE_TABLE_ACTION_NAT;
 		return 4;
@@ -4956,9 +4956,9 @@ table_rule_show(const char *pipeline_name,
 						(uint32_t)a->encap.vxlan.ipv4.ttl);
 				} else {
 					fprintf(f, " ipv6 ");
-					ipv6_addr_show(f, a->encap.vxlan.ipv6.sa);
+					ipv6_addr_show(f, a->encap.vxlan.ipv6.sa.a);
 					fprintf(f, " ");
-					ipv6_addr_show(f, a->encap.vxlan.ipv6.da);
+					ipv6_addr_show(f, a->encap.vxlan.ipv6.da.a);
 					fprintf(f, " %u %u %u ",
 						a->encap.vxlan.ipv6.flow_label,
 						(uint32_t)a->encap.vxlan.ipv6.dscp,
@@ -4980,7 +4980,7 @@ table_rule_show(const char *pipeline_name,
 			if (a->nat.ip_version)
 				ipv4_addr_show(f, a->nat.addr.ipv4);
 			else
-				ipv6_addr_show(f, a->nat.addr.ipv6);
+				ipv6_addr_show(f, a->nat.addr.ipv6.a);
 			fprintf(f, " %u ", (uint32_t)(a->nat.port));
 		}
 
lib/pipeline/rte_table_action.c +14 -22
index a04d5121e1f0..8479f984e4ea 100644
@@ -872,12 +872,8 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(&d->ipv6.src_addr,
-				p->vxlan.ipv6.sa,
-				sizeof(p->vxlan.ipv6.sa));
-			memcpy(&d->ipv6.dst_addr,
-				p->vxlan.ipv6.da,
-				sizeof(p->vxlan.ipv6.da));
+			rte_ipv6_addr_cpy(&d->ipv6.src_addr, &p->vxlan.ipv6.sa);
+			rte_ipv6_addr_cpy(&d->ipv6.dst_addr, &p->vxlan.ipv6.da);
 
 			/* UDP */
 			d->udp.src_port = rte_htons(p->vxlan.udp.sp);
@@ -907,12 +903,8 @@ encap_vxlan_apply(void *data,
 			d->ipv6.payload_len = 0; /* not pre-computed */
 			d->ipv6.proto = IP_PROTO_UDP;
 			d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit;
-			memcpy(&d->ipv6.src_addr,
-				p->vxlan.ipv6.sa,
-				sizeof(p->vxlan.ipv6.sa));
-			memcpy(&d->ipv6.dst_addr,
-				p->vxlan.ipv6.da,
-				sizeof(p->vxlan.ipv6.da));
+			rte_ipv6_addr_cpy(&d->ipv6.src_addr, &p->vxlan.ipv6.sa);
+			rte_ipv6_addr_cpy(&d->ipv6.dst_addr, &p->vxlan.ipv6.da);
 
 			/* UDP */
 			d->udp.src_port = rte_htons(p->vxlan.udp.sp);
@@ -1211,7 +1203,7 @@ struct nat_ipv4_data {
 } __rte_packed;
 
 struct nat_ipv6_data {
-	uint8_t addr[16];
+	struct rte_ipv6_addr addr;
 	uint16_t port;
 } __rte_packed;
 
@@ -1258,7 +1250,7 @@ nat_apply(void *data,
 	} else {
 		struct nat_ipv6_data *d = data;
 
-		memcpy(d->addr, p->addr.ipv6, sizeof(d->addr));
+		rte_ipv6_addr_cpy(&d->addr, &p->addr.ipv6);
 		d->port = rte_htons(p->port);
 	}
 
@@ -1438,11 +1430,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
 				(uint16_t *)&ip->src_addr,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				tcp->src_port,
 				data->port);
 
-			rte_memcpy(&ip->src_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->src_addr, &data->addr);
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1451,11 +1443,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
 				(uint16_t *)&ip->src_addr,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				udp->src_port,
 				data->port);
 
-			rte_memcpy(&ip->src_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->src_addr, &data->addr);
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1466,11 +1458,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
 				(uint16_t *)&ip->dst_addr,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				tcp->dst_port,
 				data->port);
 
-			rte_memcpy(&ip->dst_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->dst_addr, &data->addr);
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1479,11 +1471,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
 				(uint16_t *)&ip->dst_addr.a,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(&ip->dst_addr, data->addr, 16);
+			rte_ipv6_addr_cpy(&ip->dst_addr, &data->addr);
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
lib/pipeline/rte_table_action.h +4 -3
index 5dffbeb70031..b119ac03dc6e 100644
@@ -60,6 +60,7 @@ extern "C" {
 
 #include <rte_compat.h>
 #include <rte_ether.h>
+#include <rte_ip6.h>
 #include <rte_meter.h>
 #include <rte_table_hash.h>
 
@@ -419,8 +420,8 @@ struct rte_table_action_ipv4_header {
 
 /** Pre-computed IPv6 header fields for encapsulation action. */
 struct rte_table_action_ipv6_header {
-	uint8_t sa[16]; /**< Source address. */
-	uint8_t da[16]; /**< Destination address. */
+	struct rte_ipv6_addr sa; /**< Source address. */
+	struct rte_ipv6_addr da; /**< Destination address. */
 	uint32_t flow_label; /**< Flow label. */
 	uint8_t dscp; /**< DiffServ Code Point (DSCP). */
 	uint8_t hop_limit; /**< Hop Limit (HL). */
@@ -597,7 +598,7 @@ struct rte_table_action_nat_params {
 		uint32_t ipv4;
 
 		/** IPv6 address; only valid when *ip_version* is set to 0. */
-		uint8_t ipv6[16];
+		struct rte_ipv6_addr ipv6;
 	} addr;
 
 	/** Port. */
Signature · 1 line
2.46.1
#48 lore raw

Re: [PATCH dpdk v2 09/16] pipeline: use ipv6 addr struct

Quoted 16 lines · On Tue, 1 Oct 2024 10:17:21 +0200 Robin Jarry <[email protected]> wrote:
examples/ip_pipeline/cli.c +2 -2
index e8269ea90c11..66fdeac8f501 100644
@@ -3540,8 +3540,8 @@ parse_table_action_encap(char **tokens,
 				parser_read_uint8(&hop_limit, tokens[5]))
 				return 0;
 
-			memcpy(a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
-			memcpy(a->encap.vxlan.ipv6.da, da.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.da, da.s6_addr, 16);
 			a->encap.vxlan.ipv6.flow_label = flow_label;
 			a->encap.vxlan.ipv6.dscp = dscp;
 			a->encap.vxlan.ipv6.hop_limit = hop_limit;

examples/ip_pipeline/cli.c parse_table_action_nat(char **tokens, · line 3618

Quoted 5 lines
examples/ip_pipeline/cli.c +1 -1
@@ -3615,7 +3615,7 @@ parse_table_action_nat(char **tokens,
 			return 0;
 
 		a->nat.ip_version = 0;
-		memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
+		memcpy(&a->nat.addr.ipv6, addr.s6_addr, 16);

Why keep the memcpy when you just introduced an address copy routine? Or use assignment here.

#49 lore raw

Re: [PATCH dpdk v2 09/16] pipeline: use ipv6 addr struct

Stephen Hemminger, Oct 04, 2024 at 01:23:

Quoted 21 lines
Quoted 18 lines · On Tue, 1 Oct 2024 10:17:21 +0200 Robin Jarry <[email protected]> wrote:
examples/ip_pipeline/cli.c +2 -2
index e8269ea90c11..66fdeac8f501 100644
@@ -3540,8 +3540,8 @@ parse_table_action_encap(char **tokens,
 				parser_read_uint8(&hop_limit, tokens[5]))
 				return 0;
 
-			memcpy(a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
-			memcpy(a->encap.vxlan.ipv6.da, da.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.sa, sa.s6_addr, 16);
+			memcpy(&a->encap.vxlan.ipv6.da, da.s6_addr, 16);
 			a->encap.vxlan.ipv6.flow_label = flow_label;
 			a->encap.vxlan.ipv6.dscp = dscp;
 			a->encap.vxlan.ipv6.hop_limit = hop_limit;
@@ -3615,7 +3615,7 @@ parse_table_action_nat(char **tokens,
 			return 0;
 
Quoted 6 lines

examples/ip_pipeline/cli.c parse_table_action_nat(char **tokens, · line 3618

Quoted 3 lines
examples/ip_pipeline/cli.c +1 -1
 		a->nat.ip_version = 0;
-		memcpy(a->nat.addr.ipv6, addr.s6_addr, 16);
+		memcpy(&a->nat.addr.ipv6, addr.s6_addr, 16);

Why keep the memcpy when you just introduced an address copy routine? Or use assignment here.

These are two different types. The cmdline library uses POSIX struct in6_addr and I cannot assign them without risking alignment issues.

#50 lore raw

PATCH v2 10/16 ipsec: use ipv6 addr struct

In reply to Robin Jarry

Update rte_ipsec_sadv6_key to use the recently introduced IPv6 address structure instead of ad-hoc uint8_t[16] arrays.

---

Notes:
v2: updated changelog for 24.11

 app/test-sad/main.c                    | 24 +++++++-------
 app/test/test_ipsec_sad.c              | 44 +++++++++++++-------------
 doc/guides/rel_notes/deprecation.rst   |  2 --
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 examples/ipsec-secgw/sad.h             | 10 +++---
 lib/ipsec/rte_ipsec_sad.h              |  7 ++--
 6 files changed, 46 insertions(+), 43 deletions(-)
app/test-sad/main.c +12 -12
index addfc0714521..7253f6488dce 100644
@@ -248,8 +248,8 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 						(uint64_t)(edge + step));
 			if (config.ipv6) {
 				for (j = 0; j < 16; j++) {
-					tbl[i].tuple.v6.dip[j] = rte_rand();
-					tbl[i].tuple.v6.sip[j] = rte_rand();
+					tbl[i].tuple.v6.dip.a[j] = rte_rand();
+					tbl[i].tuple.v6.sip.a[j] = rte_rand();
 				}
 			} else {
 				tbl[i].tuple.v4.dip = rte_rand();
@@ -274,9 +274,9 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					(uint64_t)(edge + step));
 				if (config.ipv6) {
 					for (j = 0; j < 16; j++) {
-						tbl[i].tuple.v6.dip[j] =
+						tbl[i].tuple.v6.dip.a[j] =
 								rte_rand();
-						tbl[i].tuple.v6.sip[j] =
+						tbl[i].tuple.v6.sip.a[j] =
 								rte_rand();
 					}
 				} else {
@@ -289,11 +289,11 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					config.nb_rules].tuple.v4.spi;
 				if (config.ipv6) {
 					int r_idx = i % config.nb_rules;
-					memcpy(tbl[i].tuple.v6.dip,
-						rules_tbl[r_idx].tuple.v6.dip,
+					memcpy(&tbl[i].tuple.v6.dip,
+						&rules_tbl[r_idx].tuple.v6.dip,
 						sizeof(tbl[i].tuple.v6.dip));
-					memcpy(tbl[i].tuple.v6.sip,
-						rules_tbl[r_idx].tuple.v6.sip,
+					memcpy(&tbl[i].tuple.v6.sip,
+						&rules_tbl[r_idx].tuple.v6.sip,
 						sizeof(tbl[i].tuple.v6.sip));
 				} else {
 					tbl[i].tuple.v4.dip = rules_tbl[i %
@@ -472,8 +472,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &key->v4;
 	v6 = &key->v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 
 	if (res == NULL) {
 		printf("TUPLE: ");
@@ -500,8 +500,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &rule->tuple.v4;
 	v6 = &rule->tuple.v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 	printf("\n\tpoints to RULE ID %zu ",
 		RTE_PTR_DIFF(res, rules_tbl)/sizeof(struct rule));
 	print_tuple(af, spi, dip, sip);
app/test/test_ipsec_sad.c +22 -22

80 lines not on this page · raw message

doc/guides/rel_notes/deprecation.rst +0 -2
index fcccb22593d8..838e22b44444 100644
@@ -74,8 +74,6 @@ Deprecation Notices
     - ``struct tcp6_flow_key``
   hash
     - ``struct rte_ipv6_tuple``
-  ipsec
-    - ``struct rte_ipsec_sadv6_key``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index 3eb43ba8520f..debaf99e4a71 100644
@@ -93,6 +93,8 @@ API Changes
   ``uint8_t[16]`` parameter.
 * pipeline: ``rte_table_action_ipv6_header`` and ``rte_table_action_nat_params`` were modified to
   use ``rte_ipv6_addr`` structures instead of ``uint8_t[16]`` fields.
+* ipsec: ``rte_ipsec_sadv6_key`` was modified to use ``rte_ipv6_addr`` structures instead of
+  ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
examples/ipsec-secgw/sad.h +6 -4
index fdb1d2ef1790..4108abb9e698 100644
@@ -9,6 +9,8 @@
 #include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
+#include "ipsec.h"
+
 #define SA_CACHE_SZ	128
 #define SPI2IDX(spi, mask)	((spi) & (mask))
 
@@ -39,8 +41,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
+			(!memcmp(&sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
+			(!memcmp(&sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
 		return 1;
 
 	return 0;
@@ -130,9 +132,9 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
+			memcpy(&v6[nb_v6].dip, &ipv6->dst_addr,
 					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
+			memcpy(&v6[nb_v6].sip, &ipv6->src_addr,
 					sizeof(ipv6->src_addr));
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
lib/ipsec/rte_ipsec_sad.h +4 -3
index 0adf89d9310c..035ae4f3b3eb 100644
@@ -6,8 +6,9 @@
 #ifndef _RTE_IPSEC_SAD_H_
 #define _RTE_IPSEC_SAD_H_
 
-#include <stdint.h>
+#include <rte_ip6.h>
 
+#include <stdint.h>
 
 /**
  * @file rte_ipsec_sad.h
@@ -38,8 +39,8 @@ struct rte_ipsec_sadv4_key {
 
 struct rte_ipsec_sadv6_key {
 	uint32_t spi;
-	uint8_t dip[16];
-	uint8_t sip[16];
+	struct rte_ipv6_addr dip;
+	struct rte_ipv6_addr sip;
 };
 
 union rte_ipsec_sad_key {
Signature · 1 line
2.46.1
#51 lore raw

PATCH v2 11/16 thash: use ipv6 addr struct

In reply to Robin Jarry

Update rte_ipv6_tuple to use the recently added IPv6 address structure instead of uint8_t[16] arrays.

---

Notes:
v2: updated changelog for 24.11

 app/test/test_thash.c                  | 46 ++++++++++----------------
 doc/guides/rel_notes/deprecation.rst   |  2 --
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 lib/hash/rte_thash.h                   | 20 +++++------
 4 files changed, 29 insertions(+), 41 deletions(-)
app/test/test_thash.c +17 -29
index 952da6a52954..262f84433461 100644
@@ -25,8 +25,8 @@ struct test_thash_v4 {
 };
 
 struct test_thash_v6 {
-	uint8_t		dst_ip[16];
-	uint8_t		src_ip[16];
+	struct rte_ipv6_addr dst_ip;
+	struct rte_ipv6_addr src_ip;
 	uint16_t	dst_port;
 	uint16_t	src_port;
 	uint32_t	hash_l3;
@@ -49,25 +49,19 @@ struct test_thash_v4 v4_tbl[] = {
 
 struct test_thash_v6 v6_tbl[] = {
 /*3ffe:2501:200:3::1*/
-{{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x00, 0x03,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{{.a = "\x3f\xfe\x25\x01\x02\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x01"},
 /*3ffe:2501:200:1fff::7*/
-{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x1f, 0xff,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,},
+{.a = "\x3f\xfe\x25\x01\x02\x00\x1f\xff\x00\x00\x00\x00\x00\x00\x00\x07"},
 1766, 2794, 0x2cc18cd5, 0x40207d3d},
 /*ff02::1*/
-{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{{.a = "\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"},
 /*3ffe:501:8::260:97ff:fe40:efab*/
-{0x3f, 0xfe, 0x05, 0x01, 0x00, 0x08, 0x00, 0x00,
-0x02, 0x60, 0x97, 0xff, 0xfe, 0x40, 0xef, 0xab,},
+{.a = "\x3f\xfe\x05\x01\x00\x08\x00\x00\x02\x60\x97\xff\xfe\x40\xef\xab"},
 4739, 14230, 0x0f0c461c, 0xdde51bbf},
 /*fe80::200:f8ff:fe21:67cf*/
-{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+{{.a = "\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x00\xf8\xff\xfe\x21\x67\xcf"},
 /*3ffe:1900:4545:3:200:f8ff:fe21:67cf*/
-{0x3f, 0xfe, 0x19, 0x00, 0x45, 0x45, 0x00, 0x03,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+{.a = "\x3f\xfe\x19\x00\x45\x45\x00\x03\x02\x00\xf8\xff\xfe\x21\x67\xcf"},
 38024, 44251, 0x4b61e985, 0x02d1feef},
 };
 
@@ -110,7 +104,7 @@ static const uint8_t big_rss_key[] = {
 static int
 test_toeplitz_hash_calc(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint8_t rss_key_be[RTE_DIM(default_rss_key)];
@@ -145,10 +139,8 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
-			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
-			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
+		rte_ipv6_addr_cpy(&ipv6_hdr.src_addr, &v6_tbl[i].src_ip);
+		rte_ipv6_addr_cpy(&ipv6_hdr.dst_addr, &v6_tbl[i].dst_ip);
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
@@ -176,7 +168,7 @@ test_toeplitz_hash_calc(void)
 static int
 test_toeplitz_hash_gfni(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint64_t rss_key_matrixes[RTE_DIM(default_rss_key)];
@@ -204,10 +196,8 @@ test_toeplitz_hash_gfni(void)
 	}
 
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
-		for (j = 0; j < RTE_DIM(tuple.v6.src_addr); j++)
-			tuple.v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple.v6.dst_addr); j++)
-			tuple.v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		rte_ipv6_addr_cpy(&tuple.v6.src_addr, &v6_tbl[i].src_ip);
+		rte_ipv6_addr_cpy(&tuple.v6.dst_addr, &v6_tbl[i].dst_ip);
 		tuple.v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple.v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rss_l3 = rte_thash_gfni(rss_key_matrixes, (uint8_t *)&tuple,
@@ -299,7 +289,7 @@ enum {
 static int
 test_toeplitz_hash_gfni_bulk(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple[2];
 	uint8_t *tuples[2];
 	uint32_t rss[2] = { 0 };
@@ -328,10 +318,8 @@ test_toeplitz_hash_gfni_bulk(void)
 		rte_memcpy(tuples[0], &tuple[0], RTE_THASH_V4_L4_LEN * 4);
 
 		/*Load IPv6 headers and copy it into the corresponding tuple*/
-		for (j = 0; j < RTE_DIM(tuple[1].v6.src_addr); j++)
-			tuple[1].v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple[1].v6.dst_addr); j++)
-			tuple[1].v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		rte_ipv6_addr_cpy(&tuple[1].v6.src_addr, &v6_tbl[i].src_ip);
+		rte_ipv6_addr_cpy(&tuple[1].v6.dst_addr, &v6_tbl[i].dst_ip);
 		tuple[1].v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple[1].v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rte_memcpy(tuples[1], &tuple[1], RTE_THASH_V6_L4_LEN * 4);
doc/guides/rel_notes/deprecation.rst +0 -2
index 838e22b44444..dc0c6e4182ff 100644
@@ -72,8 +72,6 @@ Deprecation Notices
     - ``struct rte_flow_tunnel``
   gro
     - ``struct tcp6_flow_key``
-  hash
-    - ``struct rte_ipv6_tuple``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index debaf99e4a71..78d222be180e 100644
@@ -95,6 +95,8 @@ API Changes
   use ``rte_ipv6_addr`` structures instead of ``uint8_t[16]`` fields.
 * ipsec: ``rte_ipsec_sadv6_key`` was modified to use ``rte_ipv6_addr`` structures instead of
   ``uint8_t[16]`` fields.
+* hash: ``rte_ipv6_tuple`` was modified to use ``rte_ipv6_addr`` structures instead of
+  ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
lib/hash/rte_thash.h +10 -10
index 9aaaacfd5fa4..ddc4e345097d 100644
@@ -89,8 +89,8 @@ struct rte_ipv4_tuple {
  * ports/sctp_tag have to be CPU byte order
  */
 struct rte_ipv6_tuple {
-	uint8_t		src_addr[16];
-	uint8_t		dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	union {
 		struct {
 			uint16_t dport;
@@ -141,22 +141,22 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 {
 #ifdef RTE_ARCH_X86
 	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
-	*(__m128i *)targ->v6.src_addr =
+	*(__m128i *)&targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
-	*(__m128i *)targ->v6.dst_addr =
+	*(__m128i *)&targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
-	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
-	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
+	uint8x16_t ipv6 = vld1q_u8(orig->src_addr.a);
+	vst1q_u8(targ->v6.src_addr.a, vrev32q_u8(ipv6));
+	ipv6 = vld1q_u8(orig->dst_addr.a);
+	vst1q_u8(targ->v6.dst_addr.a, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
-		*((uint32_t *)targ->v6.src_addr + i) =
+		*((uint32_t *)targ->v6.src_addr.a + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr.a + i));
-		*((uint32_t *)targ->v6.dst_addr + i) =
+		*((uint32_t *)targ->v6.dst_addr.a + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr.a + i));
 	}
 #endif
Signature · 1 line
2.46.1
#52 lore raw

PATCH v2 12/16 gro: use ipv6 addr struct

In reply to Robin Jarry

Update tcp6_flow_key to use the recently introduced IPv6 address structure instead of uint8_t[16] arrays.

---

Notes:
v2: updated changelog for 24.11

 doc/guides/rel_notes/deprecation.rst   | 2 --
 doc/guides/rel_notes/release_24_11.rst | 2 ++
 lib/gro/gro_tcp6.c                     | 8 ++++----
 lib/gro/gro_tcp6.h                     | 6 ++++--
 4 files changed, 10 insertions(+), 8 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -2
index dc0c6e4182ff..f384a4b414c9 100644
@@ -70,8 +70,6 @@ Deprecation Notices
     - ``struct rte_flow_item_icmp6_nd_na``
     - ``struct rte_flow_action_set_ipv6``
     - ``struct rte_flow_tunnel``
-  gro
-    - ``struct tcp6_flow_key``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index 78d222be180e..d6d75033bf8f 100644
@@ -97,6 +97,8 @@ API Changes
   ``uint8_t[16]`` fields.
 * hash: ``rte_ipv6_tuple`` was modified to use ``rte_ipv6_addr`` structures instead of
   ``uint8_t[16]`` fields.
+* gro: ``tcp6_flow_key`` was modified to use ``rte_ipv6_addr`` structures instead of ``uint8_t[16]``
+  fields.
 
 ABI Changes
 -----------
lib/gro/gro_tcp6.c +4 -4
index 6edfb6045cf6..0c6adbf2ecdb 100644
@@ -99,8 +99,8 @@ insert_new_flow(struct gro_tcp6_tbl *tbl,
 	dst = &(tbl->flows[flow_idx].key);
 
 	ASSIGN_COMMON_TCP_KEY((&src->cmn_key), (&dst->cmn_key));
-	memcpy(&dst->src_addr[0], &src->src_addr[0], sizeof(dst->src_addr));
-	memcpy(&dst->dst_addr[0], &src->dst_addr[0], sizeof(dst->dst_addr));
+	rte_ipv6_addr_cpy(&dst->src_addr, &src->src_addr);
+	rte_ipv6_addr_cpy(&dst->dst_addr, &src->dst_addr);
 	dst->vtc_flow = src->vtc_flow;
 
 	tbl->flows[flow_idx].start_index = item_idx;
@@ -168,8 +168,8 @@ gro_tcp6_reassemble(struct rte_mbuf *pkt,
 
 	rte_ether_addr_copy(&(eth_hdr->src_addr), &(key.cmn_key.eth_saddr));
 	rte_ether_addr_copy(&(eth_hdr->dst_addr), &(key.cmn_key.eth_daddr));
-	memcpy(&key.src_addr[0], &ipv6_hdr->src_addr, sizeof(key.src_addr));
-	memcpy(&key.dst_addr[0], &ipv6_hdr->dst_addr, sizeof(key.dst_addr));
+	rte_ipv6_addr_cpy(&key.src_addr, &ipv6_hdr->src_addr);
+	rte_ipv6_addr_cpy(&key.dst_addr, &ipv6_hdr->dst_addr);
 	key.cmn_key.src_port = tcp_hdr->src_port;
 	key.cmn_key.dst_port = tcp_hdr->dst_port;
 	key.cmn_key.recv_ack = tcp_hdr->recv_ack;
lib/gro/gro_tcp6.h +4 -2
index 073122f0ec84..acf3971bb6e9 100644
@@ -5,6 +5,8 @@
 #ifndef _GRO_TCP6_H_
 #define _GRO_TCP6_H_
 
+#include <rte_ip6.h>
+
 #include "gro_tcp.h"
 
 #define GRO_TCP6_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
@@ -12,8 +14,8 @@
 /* Header fields representing a TCP/IPv6 flow */
 struct tcp6_flow_key {
 	struct cmn_tcp_key cmn_key;
-	uint8_t  src_addr[16];
-	uint8_t  dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	rte_be32_t vtc_flow;
 };
 
Signature · 1 line
2.46.1
#53 lore raw

PATCH v2 13/16 rte_flow: use ipv6 addr struct

In reply to Robin Jarry

Update rte_flow_tunnel, rte_flow_action_set_ipv6, rte_flow_item_icmp6_nd_na and rte_flow_item_icmp6_nd_ns to use the recently introduced IPv6 address structure instead of uint8_t[16] arrays.

Update all code accordingly.

---

Notes:
v2: updated changelog for 24.11

 app/test-flow-perf/actions_gen.c         |  4 ++--
 doc/guides/rel_notes/deprecation.rst     | 10 ----------
 doc/guides/rel_notes/release_24_11.rst   |  2 ++
 drivers/net/cxgbe/cxgbe_flow.c           |  4 ++--
 drivers/net/nfp/flower/nfp_flower_flow.c |  2 +-
 lib/ethdev/rte_flow.h                    | 16 +++++++++-------
 6 files changed, 16 insertions(+), 22 deletions(-)
app/test-flow-perf/actions_gen.c +2 -2
index b5336e83ff9f..54fcbacb98ce 100644
@@ -304,7 +304,7 @@ add_set_src_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
@@ -327,7 +327,7 @@ add_set_dst_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
doc/guides/rel_notes/deprecation.rst +0 -10
index f384a4b414c9..7b77987bffa2 100644
@@ -61,16 +61,6 @@ Deprecation Notices
   us extending existing enum/define.
   One solution can be using a fixed size array instead of ``.*MAX.*`` value.
 
-* net: A new IPv6 address structure will be introduced in DPDK 24.11.
-  It will replace all ad-hoc ``uint8_t[16]`` arrays in all public APIs and structures.
-  The following libraries and symbols are expected to be affected:
-
-  ethdev
-    - ``struct rte_flow_item_icmp6_nd_ns``
-    - ``struct rte_flow_item_icmp6_nd_na``
-    - ``struct rte_flow_action_set_ipv6``
-    - ``struct rte_flow_tunnel``
-
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
   The struct ``rte_flow_item_vxlan_gpe`` and its mask ``rte_flow_item_vxlan_gpe_mask``
doc/guides/rel_notes/release_24_11.rst +2 -0
index d6d75033bf8f..db9da2eb7ef8 100644
@@ -99,6 +99,8 @@ API Changes
   ``uint8_t[16]`` fields.
 * gro: ``tcp6_flow_key`` was modified to use ``rte_ipv6_addr`` structures instead of ``uint8_t[16]``
   fields.
+* ethdev: ``rte_flow_*`` structures were modified to use  ``rte_ipv6_addr`` structures instead of
+  ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
drivers/net/cxgbe/cxgbe_flow.c +2 -2
index 37c566b131e9..00c55af4bcc6 100644
@@ -680,7 +680,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_fip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_fip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 0;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
@@ -693,7 +693,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_lip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_lip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 1;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
drivers/net/nfp/flower/nfp_flower_flow.c +1 -1
index 3f597d394b24..6db1fb141d3e 100644
@@ -2978,7 +2978,7 @@ nfp_flow_action_set_ipv6(char *act_data,
 	set_ip->reserved = 0;
 
 	for (i = 0; i < 4; i++) {
-		rte_memcpy(&tmp, &set_ipv6->ipv6_addr[i * 4], 4);
+		rte_memcpy(&tmp, &set_ipv6->ipv6_addr.a[i * 4], 4);
 		set_ip->ipv6[i].exact = tmp;
 		set_ip->ipv6[i].mask = RTE_BE32(0xffffffff);
 	}
lib/ethdev/rte_flow.h +9 -7
index b3ede7ccdaef..628292c1df07 100644
@@ -1505,16 +1505,17 @@ struct rte_flow_item_icmp6_nd_ns {
 	uint8_t code; /**< ICMPv6 code, normally 0. */
 	rte_be16_t checksum; /**< ICMPv6 checksum. */
 	rte_be32_t reserved; /**< Reserved, normally 0. */
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
-	.target_addr =
+	.target_addr = {
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+	}
 };
 #endif
 
@@ -1532,16 +1533,17 @@ struct rte_flow_item_icmp6_nd_na {
 	 * reserved (29b).
 	 */
 	rte_be32_t rso_reserved;
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
-	.target_addr =
+	.target_addr = {
 		"\xff\xff\xff\xff\xff\xff\xff\xff"
 		"\xff\xff\xff\xff\xff\xff\xff\xff",
+	}
 };
 #endif
 
@@ -3812,7 +3814,7 @@ struct rte_flow_action_set_ipv4 {
  * specified outermost IPv6 header.
  */
 struct rte_flow_action_set_ipv6 {
-	uint8_t ipv6_addr[16];
+	struct rte_ipv6_addr ipv6_addr;
 };
 
 /**
@@ -5196,8 +5198,8 @@ struct rte_flow_tunnel {
 			rte_be32_t dst_addr; /**< IPv4 destination address. */
 		} ipv4;
 		struct {
-			uint8_t src_addr[16]; /**< IPv6 source address. */
-			uint8_t dst_addr[16]; /**< IPv6 destination address. */
+			struct rte_ipv6_addr src_addr; /**< IPv6 source address. */
+			struct rte_ipv6_addr dst_addr; /**< IPv6 destination address. */
 		} ipv6;
 	};
 	rte_be16_t tp_src; /**< Tunnel port source. */
Signature · 1 line
2.46.1
#54 lore raw

PATCH v2 14/16 rib6,fib6,lpm6: remove duplicate constants

In reply to Robin Jarry

Replace all address size and max depth macros with common ones from rte_ip6.h.

---
 app/test/test_fib6.c | 50 ++++++++++++++++++++++----------------------
 lib/fib/rte_fib6.c   |  6 +++---
 lib/fib/rte_fib6.h   |  4 ----
 lib/fib/trie.c       |  6 +++---
 lib/fib/trie.h       |  2 --
 lib/lpm/rte_lpm6.c   | 10 ++++-----
 lib/lpm/rte_lpm6.h   |  3 ---
 lib/rib/rte_rib6.c   | 11 +++++-----
 lib/rib/rte_rib6.h   |  6 ++----
 9 files changed, 43 insertions(+), 55 deletions(-)
app/test/test_fib6.c +25 -25
index 7134c4d335cd..812da01d6e33 100644
@@ -170,13 +170,13 @@ test_add_del_invalid(void)
 	fib = rte_fib6_create(__func__, SOCKET_ID_ANY, &config);
 	RTE_TEST_ASSERT(fib != NULL, "Failed to create FIB\n");
 
-	/* rte_fib6_add: depth > RTE_FIB6_MAXDEPTH */
-	ret = rte_fib6_add(fib, &ip, RTE_FIB6_MAXDEPTH + 1, nh);
+	/* rte_fib6_add: depth > RTE_IPV6_MAX_DEPTH */
+	ret = rte_fib6_add(fib, &ip, RTE_IPV6_MAX_DEPTH + 1, nh);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 
-	/* rte_fib6_delete: depth > RTE_FIB6_MAXDEPTH */
-	ret = rte_fib6_delete(fib, &ip, RTE_FIB6_MAXDEPTH + 1);
+	/* rte_fib6_delete: depth > RTE_IPV6_MAX_DEPTH */
+	ret = rte_fib6_delete(fib, &ip, RTE_IPV6_MAX_DEPTH + 1);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 
@@ -216,18 +216,18 @@ lookup_and_check_asc(struct rte_fib6 *fib,
 	struct rte_ipv6_addr *ip_missing, uint64_t def_nh,
 	uint32_t n)
 {
-	uint64_t nh_arr[RTE_FIB6_MAXDEPTH];
+	uint64_t nh_arr[RTE_IPV6_MAX_DEPTH];
 	int ret;
 	uint32_t i = 0;
 
-	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH);
+	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH);
 	RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n");
 
-	for (; i <= RTE_FIB6_MAXDEPTH - n; i++)
+	for (; i <= RTE_IPV6_MAX_DEPTH - n; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == n,
 			"Failed to get proper nexthop\n");
 
-	for (; i < RTE_FIB6_MAXDEPTH; i++)
+	for (; i < RTE_IPV6_MAX_DEPTH; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == --n,
 			"Failed to get proper nexthop\n");
 
@@ -244,18 +244,18 @@ lookup_and_check_desc(struct rte_fib6 *fib,
 	struct rte_ipv6_addr *ip_missing, uint64_t def_nh,
 	uint32_t n)
 {
-	uint64_t nh_arr[RTE_FIB6_MAXDEPTH];
+	uint64_t nh_arr[RTE_IPV6_MAX_DEPTH];
 	int ret;
 	uint32_t i = 0;
 
-	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH);
+	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH);
 	RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n");
 
 	for (; i < n; i++)
-		RTE_TEST_ASSERT(nh_arr[i] == RTE_FIB6_MAXDEPTH - i,
+		RTE_TEST_ASSERT(nh_arr[i] == RTE_IPV6_MAX_DEPTH - i,
 			"Failed to get proper nexthop\n");
 
-	for (; i < RTE_FIB6_MAXDEPTH; i++)
+	for (; i < RTE_IPV6_MAX_DEPTH; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == def_nh,
 			"Failed to get proper nexthop\n");
 
@@ -270,7 +270,7 @@ static int
 check_fib(struct rte_fib6 *fib)
 {
 	uint64_t def_nh = 100;
-	struct rte_ipv6_addr ip_arr[RTE_FIB6_MAXDEPTH];
+	struct rte_ipv6_addr ip_arr[RTE_IPV6_MAX_DEPTH];
 	struct rte_ipv6_addr ip_add = {.a = {[0] = 128}};
 	struct rte_ipv6_addr ip_missing = {
 		.a = {[0] = 127, [1 ... 15] = 255},
@@ -278,12 +278,12 @@ check_fib(struct rte_fib6 *fib)
 	uint32_t i, j;
 	int ret;
 
-	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) {
 		rte_ipv6_addr_cpy(&ip_arr[i], &ip_add);
-		j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT;
-		if (j < RTE_FIB6_IPV6_ADDR_SIZE) {
-			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT);
-			for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++)
+		j = (RTE_IPV6_MAX_DEPTH - i) / CHAR_BIT;
+		if (j < RTE_IPV6_ADDR_SIZE) {
+			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_IPV6_MAX_DEPTH - i) % CHAR_BIT);
+			for (j++; j < RTE_IPV6_ADDR_SIZE; j++)
 				ip_arr[i].a[j] = 0xff;
 		}
 	}
@@ -291,7 +291,7 @@ check_fib(struct rte_fib6 *fib)
 	ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh, 0);
 	RTE_TEST_ASSERT(ret == TEST_SUCCESS, "Lookup and check fails\n");
 
-	for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) {
 		ret = rte_fib6_add(fib, &ip_add, i, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n");
 		ret = lookup_and_check_asc(fib, ip_arr, &ip_missing, def_nh, i);
@@ -299,7 +299,7 @@ check_fib(struct rte_fib6 *fib)
 			"Lookup and check fails\n");
 	}
 
-	for (i = RTE_FIB6_MAXDEPTH; i > 1; i--) {
+	for (i = RTE_IPV6_MAX_DEPTH; i > 1; i--) {
 		ret = rte_fib6_delete(fib, &ip_add, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n");
 		ret = lookup_and_check_asc(fib, ip_arr, &ip_missing,
@@ -314,9 +314,9 @@ check_fib(struct rte_fib6 *fib)
 	RTE_TEST_ASSERT(ret == TEST_SUCCESS,
 		"Lookup and check fails\n");
 
-	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
-		ret = rte_fib6_add(fib, &ip_add, RTE_FIB6_MAXDEPTH - i,
-			RTE_FIB6_MAXDEPTH - i);
+	for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) {
+		ret = rte_fib6_add(fib, &ip_add, RTE_IPV6_MAX_DEPTH - i,
+			RTE_IPV6_MAX_DEPTH - i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n");
 		ret = lookup_and_check_desc(fib, ip_arr, &ip_missing,
 			def_nh, i + 1);
@@ -324,11 +324,11 @@ check_fib(struct rte_fib6 *fib)
 			"Lookup and check fails\n");
 	}
 
-	for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) {
 		ret = rte_fib6_delete(fib, &ip_add, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n");
 		ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh,
-			RTE_FIB6_MAXDEPTH - i);
+			RTE_IPV6_MAX_DEPTH - i);
 		RTE_TEST_ASSERT(ret == TEST_SUCCESS,
 			"Lookup and check fails\n");
 	}
lib/fib/rte_fib6.c +3 -3
index d95cac79cbb5..9c7d4fde433a 100644
@@ -71,7 +71,7 @@ dummy_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop, int op)
 {
 	struct rte_rib6_node *node;
-	if ((fib == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	node = rte_rib6_lookup_exact(fib->rib, ip, depth);
@@ -123,7 +123,7 @@ rte_fib6_add(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, next_hop, RTE_FIB6_ADD);
 }
@@ -133,7 +133,7 @@ rte_fib6_delete(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, 0, RTE_FIB6_DEL);
 }
lib/fib/rte_fib6.h +0 -4
index d26a0c7c0b77..2e3636b3bd29 100644
@@ -23,10 +23,6 @@
 extern "C" {
 #endif
 
-#define RTE_FIB6_IPV6_ADDR_SIZE		16
-/** Maximum depth value possible for IPv6 FIB. */
-#define RTE_FIB6_MAXDEPTH       128
-
 struct rte_fib6;
 struct rte_rib6;
 
lib/fib/trie.c +3 -3
index 8a69702eabb2..7c0af20625c1 100644
@@ -350,9 +350,9 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
 	return ret;
 }
 
-#define IPV6_MAX_IDX	(RTE_FIB6_IPV6_ADDR_SIZE - 1)
+#define IPV6_MAX_IDX	(RTE_IPV6_ADDR_SIZE - 1)
 #define TBL24_BYTES	3
-#define TBL8_LEN	(RTE_FIB6_IPV6_ADDR_SIZE - TBL24_BYTES)
+#define TBL8_LEN	(RTE_IPV6_ADDR_SIZE - TBL24_BYTES)
 
 static int
 install_to_dp(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ledge,
@@ -518,7 +518,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint64_t par_nh, node_nh;
 	uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
 
-	if ((fib == NULL) || (ip == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (ip == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	dp = rte_fib6_get_dp(fib);
lib/fib/trie.h +0 -2
index 6e235edaf89c..77f1d95f4316 100644
@@ -17,8 +17,6 @@
 
 /* @internal Total number of tbl24 entries. */
 #define TRIE_TBL24_NUM_ENT	(1 << 24)
-/* Maximum depth value possible for IPv6 LPM. */
-#define TRIE_MAX_DEPTH		128
 /* @internal Number of entries in a tbl8 group. */
 #define TRIE_TBL8_GRP_NUM_ENT	256ULL
 /* @internal Total number of tbl8 groups in the tbl8. */
lib/lpm/rte_lpm6.c +5 -5
index 642b02b32cc2..c54726483a1a 100644
@@ -802,7 +802,7 @@ simulate_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *masked_ip, uint8_
 	 * Inspect one by one the rest of the bytes until
 	 * the process is completed.
 	 */
-	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) {
+	for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && ret == 1; i++) {
 		tbl = tbl_next;
 		ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
 			(uint8_t)(i + 1), depth, &need_tbl_nb);
@@ -832,7 +832,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 	int i;
 
 	/* Check user arguments. */
-	if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+	if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
@@ -861,7 +861,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 	 * Inspect one by one the rest of the bytes until
 	 * the process is completed.
 	 */
-	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && status == 1; i++) {
+	for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && status == 1; i++) {
 		tbl = tbl_next;
 		status = add_step(lpm, tbl, tbl_next_num, &tbl_next,
 			&tbl_next_num, &masked_ip, 1, (uint8_t)(i + 1),
@@ -993,7 +993,7 @@ rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, u
 
 	/* Check user arguments. */
 	if ((lpm == NULL) || next_hop == NULL || ip == NULL ||
-			(depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+			(depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
@@ -1267,7 +1267,7 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t de
 	struct rte_lpm6_tbl_entry *from, *to;
 
 	/* Check input arguments. */
-	if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+	if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
lib/lpm/rte_lpm6.h +0 -3
index 87392194237c..19b498a78d5d 100644
@@ -17,9 +17,6 @@
 extern "C" {
 #endif
 
-
-#define RTE_LPM6_MAX_DEPTH               128
-#define RTE_LPM6_IPV6_ADDR_SIZE           16
 /** Max number of characters in LPM name. */
 #define RTE_LPM6_NAMESIZE                 32
 
lib/rib/rte_rib6.c +5 -6
index ec46c865ddf7..207ece0507dd 100644
@@ -20,7 +20,6 @@
 #include "rib_log.h"
 
 #define RTE_RIB_VALID_NODE	1
-#define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
 #define RTE_RIB6_NAMESIZE	64
 
@@ -89,7 +88,7 @@ static inline struct rte_rib6_node *
 get_nxt_node(struct rte_rib6_node *node,
 	const struct rte_ipv6_addr *ip)
 {
-	if (node->depth == RIB6_MAXDEPTH)
+	if (node->depth == RTE_IPV6_MAX_DEPTH)
 		return NULL;
 
 	return (get_dir(ip, node->depth)) ? node->right : node->left;
@@ -158,7 +157,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib,
 	struct rte_rib6_node *cur;
 	struct rte_ipv6_addr tmp_ip;
 
-	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -196,7 +195,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib,
 	struct rte_rib6_node *tmp, *prev = NULL;
 	struct rte_ipv6_addr tmp_ip;
 
-	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -279,7 +278,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 	int i, d;
 	uint8_t common_depth, ip_xor;
 
-	if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) {
+	if (unlikely((rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH))) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -341,7 +340,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 
 	/* closest node found, new_node should be inserted in the middle */
 	common_depth = RTE_MIN(depth, (*tmp)->depth);
-	for (i = 0, d = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0, d = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		ip_xor = tmp_ip.a[i] ^ (*tmp)->ip.a[i];
 		if (ip_xor == 0)
 			d += 8;
lib/rib/rte_rib6.h +2 -4
index fcf4169ca790..0e72766876ed 100644
@@ -22,8 +22,6 @@
 extern "C" {
 #endif
 
-#define RTE_RIB6_IPV6_ADDR_SIZE	16
-
 /**
  * rte_rib6_get_nxt() flags
  */
@@ -65,7 +63,7 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
 	if ((dst == NULL) || (src == NULL))
 		return;
-	rte_memcpy(dst, src, RTE_RIB6_IPV6_ADDR_SIZE);
+	rte_memcpy(dst, src, RTE_IPV6_ADDR_SIZE);
 }
 
 /**
@@ -89,7 +87,7 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 
 	if ((ip1 == NULL) || (ip2 == NULL))
 		return 0;
-	for (i = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		if (ip1[i] != ip2[i])
 			return 0;
 	}
Signature · 1 line
2.46.1
#55 lore raw

Re: [PATCH dpdk v2 14/16] rib6,fib6,lpm6: remove duplicate constants

Quoted 4 lines · On Tue, 1 Oct 2024 10:17:26 +0200 Robin Jarry <[email protected]> wrote:

Replace all address size and max depth macros with common ones from rte_ip6.h.

This looks good but since these #defines are in public headers you need to leave a copy (with __rte_deprecated) around for a couple of releases so that userspace is notified.

#56 lore raw

Re: [PATCH dpdk v2 14/16] rib6,fib6,lpm6: remove duplicate constants

Stephen Hemminger, Oct 04, 2024 at 01:12:

Quoted 11 lines
Quoted 4 lines · On Tue, 1 Oct 2024 10:17:26 +0200 Robin Jarry <[email protected]> wrote:

Replace all address size and max depth macros with common ones from rte_ip6.h.

This looks good but since these #defines are in public headers you need to leave a copy (with __rte_deprecated) around for a couple of releases so that userspace is notified.

I'm not sure how to indicate that a macro is deprecated. Do I need to change it to a variable?

#57 lore raw

Re: [PATCH dpdk v2 14/16] rib6,fib6,lpm6: remove duplicate constants

Quoted 7 lines · On Fri, 04 Oct 2024 13:54:42 +0200 "Robin Jarry" <[email protected]> wrote:

Stephen Hemminger, Oct 04, 2024 at 01:12:

Quoted 6 lines
Quoted 3 lines · On Tue, 1 Oct 2024 10:17:26 +0200 Robin Jarry <[email protected]> wrote:

Replace all address size and max depth macros with common ones from rte_ip6.h.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

This looks good but since these #defines are in public headers you need to leave a copy (with __rte_deprecated) around for a couple of releases so that userspace is notified.

I'm not sure how to indicate that a macro is deprecated. Do I need to change it to a variable?

You can do something like:

#define RTE_FIB6_MAXDEPTH RTE_DEPRECATED(RTE_FIB6_MAXDEPTH) RTE_IPV6_MAX_DEPTH

The part in the middle will cause warning if used.

#58 lore raw

PATCH v2 15/16 net: add utilities for well known ipv6 address types

In reply to Robin Jarry

Add more utilities to work with IPv6 addresses. These functions will be required in order to help building IPv6 routing applications.

---

Notes:
v2:

- added more multicast helpers
- fixed all routers well known multicast addresses

 app/test/test_net_ipv6.c |  74 +++++++++++++++++++
 lib/net/rte_ip6.h        | 149 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 223 insertions(+)
app/test/test_net_ipv6.c +74 -0
index c2b42d67285e..b087b5c60d73 100644
@@ -93,26 +93,97 @@ static int
 test_ipv6_addr_kind(void)
 {
 	TEST_ASSERT(rte_ipv6_addr_is_unspec(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&zero_addr), "");
 
 	struct rte_ipv6_addr ucast = {
 		"\x2a\x01\xcb\x00\x02\x54\x33\x00\x62\x39\xe1\xf4\x7a\x0b\x23\x71"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&ucast), "");
 
 	struct rte_ipv6_addr mcast = {
 		"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&mcast), "");
+	TEST_ASSERT(rte_ipv6_addr_is_mcast(&mcast), "");
 
 	struct rte_ipv6_addr lo = {
 		"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&lo), "");
+	TEST_ASSERT(rte_ipv6_addr_is_loopback(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&lo), "");
 
 	struct rte_ipv6_addr local = {
 		"\xfe\x80\x00\x00\x00\x00\x00\x00\x5a\x84\xc5\x2c\x6a\xef\x46\x39"
 	};
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&local), "");
+	TEST_ASSERT(rte_ipv6_addr_is_linklocal(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&local), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_llocal_from_ethernet(void)
+{
+	const struct rte_ether_addr local_mac = { "\x04\x7b\xcb\x5c\x08\x44" };
+	const struct rte_ipv6_addr local_ip = {
+		"\xfe\x80\x00\x00\x00\x00\x00\x00\x04\x7b\xcb\xff\xfe\x5c\x08\x44"
+	};
+	struct rte_ipv6_addr ip;
+
+	rte_ipv6_llocal_from_ethernet(&ip, &local_mac);
+	TEST_ASSERT(rte_ipv6_addr_eq(&ip, &local_ip), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_solnode_from_addr(void)
+{
+	struct rte_ipv6_addr sol;
+
+	const struct rte_ipv6_addr llocal = {
+		"\xfe\x80\x00\x00\x00\x00\x00\x00\x04\x7b\xcb\xff\xfe\x5c\x08\x44"
+	};
+	const struct rte_ipv6_addr llocal_sol = {
+		"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\x5c\x08\x44"
+	};
+	rte_ipv6_solnode_from_addr(&sol, &llocal);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &llocal_sol), "");
+
+	const struct rte_ipv6_addr ucast = {
+		"\x2a\x01\xcb\x00\x02\x54\x33\x00\x1b\x9f\x80\x71\x67\xcd\xbf\x20"
+	};
+	const struct rte_ipv6_addr ucast_sol = {
+		"\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\xcd\xbf\x20"
+	};
+	rte_ipv6_solnode_from_addr(&sol, &ucast);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &ucast_sol), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ether_mcast_from_ipv6(void)
+{
+	const struct rte_ether_addr mcast_mac = { "\x33\x33\xd3\x00\x02\x01" };
+	const struct rte_ipv6_addr mcast_ip = {
+		"\xff\x02\x00\x00\x00\x00\x02\x01\x00\x00\x00\x00\xd3\x00\x02\x01"
+	};
+	struct rte_ether_addr mac;
+
+	rte_ether_mcast_from_ipv6(&mac, &mcast_ip);
+	TEST_ASSERT(rte_is_same_ether_addr(&mac, &mcast_mac), "");
 
 	return TEST_SUCCESS;
 }
@@ -123,6 +194,9 @@ test_net_ipv6(void)
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_llocal_from_ethernet(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_solnode_from_addr(), "");
+	TEST_ASSERT_SUCCESS(test_ether_mcast_from_ipv6(), "");
 	return TEST_SUCCESS;
 }
 
lib/net/rte_ip6.h +149 -0

161 lines not on this page · raw message

Signature · 1 line
2.46.1
#60 lore raw

PATCH v2 16/16 ipv6: add function to check ipv6 version

In reply to Robin Jarry

This is a slow path version to verify the version field in IPv6 headers.

---

Notes:
v2: new patch

 app/test/test_net_ipv6.c | 16 ++++++++++++++++
 lib/net/rte_ip6.h        | 17 +++++++++++++++++
 2 files changed, 33 insertions(+)
app/test/test_net_ipv6.c +16 -0
index b087b5c60d73..79a43a2b5491 100644
@@ -11,6 +11,21 @@ static const struct rte_ipv6_addr bcast_addr = {
 };
 static const struct rte_ipv6_addr zero_addr = { 0 };
 
+static int
+test_ipv6_check_version(void)
+{
+	struct rte_ipv6_hdr h;
+
+	h.vtc_flow = 0;
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x7f00ba44);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x6badcaca);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), 0, "");
+
+	return 0;
+}
+
 static int
 test_ipv6_addr_mask(void)
 {
@@ -191,6 +206,7 @@ test_ether_mcast_from_ipv6(void)
 static int
 test_net_ipv6(void)
 {
+	TEST_ASSERT_SUCCESS(test_ipv6_check_version(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
lib/net/rte_ip6.h +17 -0
index c552fa54c095..de3ddc0348c5 100644
@@ -323,6 +323,23 @@ struct rte_ipv6_hdr {
 	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
+#define RTE_IPV6_VTC_FLOW_VERSION RTE_BE32(0x60000000)
+#define RTE_IPV6_VTC_FLOW_VERSION_MASK RTE_BE32(0xf0000000)
+
+/**
+ * Check that the IPv6 header version field is valid according to RFC 8200 section 3.
+ *
+ * @return
+ *   0 if the version field is valid. -EINVAL otherwise.
+ */
+static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)
+{
+	rte_be32_t v = ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK;
+	if (v != RTE_IPV6_VTC_FLOW_VERSION)
+		return -EINVAL;
+	return 0;
+}
+
 /* IPv6 routing extension type definition. */
 #define RTE_IPV6_SRCRT_TYPE_4 4
 
Signature · 1 line
2.46.1
#61 lore raw

RE: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version

Quoted 5 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 1 October 2024 10.17

This is a slow path version to verify the version field in IPv6 headers.

It doesn't look slow to me. No need to mention slow path here.

Quoted 66 lines

---

Notes:
v2: new patch

 app/test/test_net_ipv6.c | 16 ++++++++++++++++
 lib/net/rte_ip6.h        | 17 +++++++++++++++++
 2 files changed, 33 insertions(+)
app/test/test_net_ipv6.c +16 -0
index b087b5c60d73..79a43a2b5491 100644
@@ -11,6 +11,21 @@ static const struct rte_ipv6_addr bcast_addr = {
 };
 static const struct rte_ipv6_addr zero_addr = { 0 };
 
+static int
+test_ipv6_check_version(void)
+{
+	struct rte_ipv6_hdr h;
+
+	h.vtc_flow = 0;
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x7f00ba44);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x6badcaca);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), 0, "");
+
+	return 0;
+}
+
 static int
 test_ipv6_addr_mask(void)
 {
@@ -191,6 +206,7 @@ test_ether_mcast_from_ipv6(void)
 static int
 test_net_ipv6(void)
 {
+	TEST_ASSERT_SUCCESS(test_ipv6_check_version(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
lib/net/rte_ip6.h +0 -0
index c552fa54c095..de3ddc0348c5 100644
@@ -323,6 +323,23 @@ struct rte_ipv6_hdr {
 	struct rte_ipv6_addr dst_addr;	/**< IP address of

destination host(s). */
} __rte_packed;

lib/net/rte_ip6.h +5 -0
+#define RTE_IPV6_VTC_FLOW_VERSION RTE_BE32(0x60000000)
+#define RTE_IPV6_VTC_FLOW_VERSION_MASK RTE_BE32(0xf0000000)
+
+/**
+ * Check that the IPv6 header version field is valid according to RFC

8200 section 3.
+ *
+ * @return
+ * 0 if the version field is valid. -EINVAL otherwise.
+ */
+static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)

lib/net/rte_ip6.h struct rte_ipv6_hdr { · line 341

Quoted 6 lines
lib/net/rte_ip6.h +6 -0
+{
+	rte_be32_t v = ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK;
+	if (v != RTE_IPV6_VTC_FLOW_VERSION)
+		return -EINVAL;
+	return 0;
+}

Personally, I would prefer following the convention of rte_ether functions to return boolean (as int)...

static inline int rte_is_<zero/unicast/multicast/broadcast/universal/local_admin/valid_assigned>_ether_addr(const struct rte_ether_addr *ea)

static inline int rte_is_ipv6_version(const struct rte_ipv6_hdr *ip)

{
	return ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK == RTE_IPV6_VTC_FLOW_VERSION;
}

Or, at your preference, an optimized variant:
static inline int rte_is_version_ipv6(const struct rte_ipv6_hdr *ip)

{
	return *(const unsigned char *)ip & 0xf0 == 0x60;
}

The first nibble is also used for version in IPv4, so an IPv4 variant would look similar:
static inline int rte_is_version_ipv4(const struct rte_ip_hdr *ip)

{
	return *(const unsigned char *)ip & 0xf0 == 0x40;
}
#62 lore raw

Re: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version

Hi Morten,

Morten Brørup, Oct 06, 2024 at 11:02:

Quoted 3 lines

Personally, I would prefer following the convention of rte_ether functions to return boolean (as int)...

static inline int rte_is_<zero/unicast/multicast/broadcast/universal/local_admin/valid_assigned>_ether_addr(const struct rte_ether_addr *ea)

Sorry, I haven't followed your recommendation in v3, but I have a good reason :)

I find that functions following that naming scheme are impossible to find since they all start with the same "rte_is_" prefix regardless of the DPDK module in which they are defined. It it is particularly annoying when using code completion with clangd or similar tools.

rte_is_power_of_2                   <rte_bitops.h>
rte_is_aligned                      <rte_common.h>
rte_is_same_ether_addr              <rte_ether.h>
rte_is_zero_ether_addr              <rte_ether.h>
rte_is_unicast_ether_addr           <rte_ether.h>
rte_is_multicast_ether_addr         <rte_ether.h>
rte_is_broadcast_ether_addr         <rte_ether.h>
rte_is_universal_ether_addr         <rte_ether.h>
rte_is_local_admin_ether_addr       <rte_ether.h>
rte_is_valid_assigned_ether_addr    <rte_ether.h>

The ethernet address functions are even more extreme as they end all with the same suffix:

rte_<action>_<namespace>_<object>

All other public API seems to follow the inverse logic:

rte_<namespace>_<object>_<action>

It does not follow the natural English language but more of an inverse polish notation. However, it feels more user friendly and better discoverable.

rte_ipv6_addr_eq
rte_ipv6_addr_eq_prefix
rte_ipv6_addr_is_linklocal
rte_ipv6_addr_is_loopback
rte_ipv6_addr_is_mcast
rte_ipv6_addr_is_sitelocal
rte_ipv6_addr_is_unspec
rte_ipv6_addr_is_v4compat
rte_ipv6_addr_is_v4mapped
rte_ipv6_addr_mask
rte_ipv6_llocal_from_ethernet
rte_ipv6_mask_depth
rte_ipv6_mc_scope
rte_ipv6_solnode_from_addr

I hope I'm making sense :)

Quoted 11 lines

static inline int rte_is_ipv6_version(const struct rte_ipv6_hdr *ip)

{
	return ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK == RTE_IPV6_VTC_FLOW_VERSION;
}

Or, at your preference, an optimized variant:
static inline int rte_is_version_ipv6(const struct rte_ipv6_hdr *ip)

{
	return *(const unsigned char *)ip & 0xf0 == 0x60;
}
Quoted 5 lines

The first nibble is also used for version in IPv4, so an IPv4 variant would look similar:
static inline int rte_is_version_ipv4(const struct rte_ip_hdr *ip)

{
	return *(const unsigned char *)ip & 0xf0 == 0x40;
}

I had missed this in ipv4. I could rework it for v4 if there are other remarks.

Thanks for the review!

#63 lore raw

RE: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version

Quoted 60 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Thursday, 10 October 2024 22.01

Hi Morten,

Morten Brørup, Oct 06, 2024 at 11:02:

Quoted 1 line

Personally, I would prefer following the convention of rte_ether

functions to return boolean (as int)...

Quoted 2 lines

static inline int

rte_is_<zero/unicast/multicast/broadcast/universal/local_admin/valid_as signed>_ether_addr(const struct rte_ether_addr *ea)

Sorry, I haven't followed your recommendation in v3, but I have a good reason :)

I find that functions following that naming scheme are impossible to find since they all start with the same "rte_is_" prefix regardless of the DPDK module in which they are defined. It it is particularly annoying when using code completion with clangd or similar tools.

rte_is_power_of_2                   <rte_bitops.h>
rte_is_aligned                      <rte_common.h>
rte_is_same_ether_addr              <rte_ether.h>
rte_is_zero_ether_addr              <rte_ether.h>
rte_is_unicast_ether_addr           <rte_ether.h>
rte_is_multicast_ether_addr         <rte_ether.h>
rte_is_broadcast_ether_addr         <rte_ether.h>
rte_is_universal_ether_addr         <rte_ether.h>
rte_is_local_admin_ether_addr       <rte_ether.h>
rte_is_valid_assigned_ether_addr    <rte_ether.h>

The ethernet address functions are even more extreme as they end all with the same suffix:

    rte_<action>_<namespace>_<object>

All other public API seems to follow the inverse logic:

    rte_<namespace>_<object>_<action>

It does not follow the natural English language but more of an inverse polish notation. However, it feels more user friendly and better discoverable.

rte_ipv6_addr_eq
rte_ipv6_addr_eq_prefix
rte_ipv6_addr_is_linklocal
rte_ipv6_addr_is_loopback
rte_ipv6_addr_is_mcast
rte_ipv6_addr_is_sitelocal
rte_ipv6_addr_is_unspec
rte_ipv6_addr_is_v4compat
rte_ipv6_addr_is_v4mapped
rte_ipv6_addr_mask
rte_ipv6_llocal_from_ethernet
rte_ipv6_mask_depth
rte_ipv6_mc_scope
rte_ipv6_solnode_from_addr

Quoted 1 line

I hope I'm making sense :)

Excellent explanation.
You have convinced me, so I now agree with your decision.

Then, in some other future patch, the ether_addr functions should be renamed to follow this convention too. And for backwards compatibility, their old names can be preserved as macros/functions calling the new names.

Quoted 24 lines
Quoted 4 lines

static inline int rte_is_ipv6_version(const struct rte_ipv6_hdr *ip)

{
	return ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK ==

RTE_IPV6_VTC_FLOW_VERSION;

Quoted 9 lines

}

Or, at your preference, an optimized variant:
static inline int rte_is_version_ipv6(const struct rte_ipv6_hdr *ip)

{
	return *(const unsigned char *)ip & 0xf0 == 0x60;
}

The first nibble is also used for version in IPv4, so an IPv4 variant

would look similar:

Quoted 4 lines

static inline int rte_is_version_ipv4(const struct rte_ip_hdr *ip)

{
	return *(const unsigned char *)ip & 0xf0 == 0x40;
}

I had missed this in ipv4. I could rework it for v4 if there are other remarks.

Thanks for the review!

#64 lore raw

RE: [PATCH dpdk v2 16/16] ipv6: add function to check ipv6 version

In reply to Robin Jarry
Quoted 54 lines

This is a slow path version to verify the version field in IPv6 headers.

---

Notes:
v2: new patch

 app/test/test_net_ipv6.c | 16 ++++++++++++++++
 lib/net/rte_ip6.h        | 17 +++++++++++++++++
 2 files changed, 33 insertions(+)
app/test/test_net_ipv6.c +16 -0
index b087b5c60d73..79a43a2b5491 100644
@@ -11,6 +11,21 @@ static const struct rte_ipv6_addr bcast_addr = {
 };
 static const struct rte_ipv6_addr zero_addr = { 0 };
 
+static int
+test_ipv6_check_version(void)
+{
+	struct rte_ipv6_hdr h;
+
+	h.vtc_flow = 0;
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x7f00ba44);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x6badcaca);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), 0, "");
+
+	return 0;
+}
+
 static int
 test_ipv6_addr_mask(void)
 {
@@ -191,6 +206,7 @@ test_ether_mcast_from_ipv6(void)
 static int
 test_net_ipv6(void)
 {
+	TEST_ASSERT_SUCCESS(test_ipv6_check_version(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
lib/net/rte_ip6.h +0 -0
index c552fa54c095..de3ddc0348c5 100644
@@ -323,6 +323,23 @@ struct rte_ipv6_hdr {
 	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */

lib/net/rte_ip6.h struct rte_ipv6_hdr { · line 333

Quoted 10 lines
lib/net/rte_ip6.h +8 -0
 } __rte_packed;
 
+#define RTE_IPV6_VTC_FLOW_VERSION RTE_BE32(0x60000000)
+#define RTE_IPV6_VTC_FLOW_VERSION_MASK RTE_BE32(0xf0000000)
+
+/**
+ * Check that the IPv6 header version field is valid according to RFC 8200 section 3.
+ *
+ * @return
+ *   0 if the version field is valid. -EINVAL otherwise.

Probably 0/1 as return values will be nicer.

lib/net/rte_ip6.h struct rte_ipv6_hdr { · line 334

Quoted 1 line
lib/net/rte_ip6.h +1 -0
+ */

If it is a new one, then it probably needs to be rte_experimental.

Quoted 14 lines
lib/net/rte_ip6.h +8 -1
+static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)
+{
+	rte_be32_t v = ip->vtc_flow & RTE_IPV6_VTC_FLOW_VERSION_MASK;
+	if (v != RTE_IPV6_VTC_FLOW_VERSION)
+		return -EINVAL;
+	return 0;
+}
+
 /* IPv6 routing extension type definition. */
 #define RTE_IPV6_SRCRT_TYPE_4 4
 
--

2.46.1

#65 lore raw
In reply to Robin Jarry
Quoted 22 lines

From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 1 October 2024 10.17

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The
API change was announced before the 24.07 release [2]. This series is intended
for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2]
https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc
1b5764

I tried to keep the patches as small as possible; unfortunately some of them
are quite big and cannot be broken down if we want to preserve a bisectable
tree.

Quoted 3 lines

Let me know what you think.

Thanks!

Sorry about the late review. And thank you for this series!

In addition to my patch specific comments, here's some general feedback for the series.

Mixing ip6 and ipv6, and IP6 and IPV6 makes it hard to guess names.
Please use ipv6 and IPV6 everywhere, also in file names.
On the other hand... If file names use "6" postfix to indicate IP Version 6, e.g. rte_fib6.h, rte_ip6.h, then stick with that; just make sure it is consistent. My point is: Where possible, please be consistent in naming.
NB: For API/ABI compatibility, don't clean up existing names for consistency.

I recall seeing some other patch replacing hardcoded IPv6 addresses given as zero-terminated strings (which are, in fact, 17 byte in size) with arrays containing 16 hex integers, to fix some modern compiler warning about mixed sizes. If adding new hardcoded IPv6 addresses, please use { 0x12, 0x34, 0x56, ...} instead of "\x12\x34\x56...".

-Morten

#66 lore raw
In reply to Robin Jarry
Quoted 24 lines

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Thanks!

Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Bruce Richardson <[email protected]>
Quoted 10 lines

Changelog:

v2:

- added RTE_IPV6_ADDR helper macro
- added more multicast address utils
- updated 24.11 changelog
- added ipv6 header version check function

Quoted 3 lines

--
2.46.1

#67 lore raw

v3 cover IPv6 APIs overhaul

In reply to Robin Jarry

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Thanks!

Cc Bruce Richardson <[email protected]>
Cc Ferruh Yigit <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>

Changelog:

v3:

- replace *memcpy(ipv6) with direct struct assignments
- replace in6_addr with rte_ipv6_addr
- add more ipv6 utils to deal with addresses
- replace string initializers and RTE_IPV6_ADDR() with RTE_IPV6()
- restore deleted macro constants and mark them as RTE_DEPRECATED()

Robin Jarry (17):
net: split raw checksum functions in separate header
net: split ipv6 symbols in separate header
net: add structure for ipv6 addresses
net: add ipv6 address utilities
net: use struct rte_ipv6_addr for header addresses fib6,rib6,lpm6: use struct rte_ipv6_addr fib6,rib6,lpm6: use ipv6 utils rib6,fib6,lpm6: remove duplicate constants
cmdline: replace in6_addr with rte_ipv6_addr graph,node: use struct rte_ipv6_addr and utils
pipeline: use struct rte_ipv6_addr ipsec,security: use struct rte_ipv6_addr and utils
thash: use struct rte_ipv6_addr
gro: use struct rte_ipv6_addr
rte_flow: use struct rte_ipv6_addr
net: add utilities for well known ipv6 address types
ipv6: add function to check ipv6 version

 MAINTAINERS                                 |    1 +
 app/graph/ethdev.c                          |   44 +-
 app/graph/ethdev.h                          |    9 +-
 app/graph/ip6_route.c                       |   51 +-
 app/graph/meson.build                       |    2 +-
 app/graph/neigh.c                           |   21 +-
 app/graph/neigh_priv.h                      |    4 +-
 app/graph/route.h                           |    8 +-
 app/test-fib/main.c                         |   51 +-
 app/test-flow-perf/actions_gen.c            |    4 +-
 app/test-flow-perf/items_gen.c              |    4 +-
 app/test-pipeline/pipeline_hash.c           |    4 +-
 app/test-pipeline/pipeline_lpm_ipv6.c       |   11 +-
 app/test-pmd/cmdline.c                      |    4 +-
 app/test-pmd/cmdline_flow.c                 |   14 +-
 app/test-pmd/testpmd.h                      |   16 +-
 app/test-sad/main.c                         |   24 +-
 app/test/meson.build                        |    1 +
 app/test/packet_burst_generator.c           |    5 +-
 app/test/test_cmdline_ipaddr.c              |   49 +-
 app/test/test_cryptodev_security_ipsec.c    |    1 +
 app/test/test_fib6.c                        |   92 +-
 app/test/test_fib6_perf.c                   |    8 +-
 app/test/test_ipfrag.c                      |    4 +-
 app/test/test_ipsec_sad.c                   |   46 +-
 app/test/test_lpm6.c                        |  490 +++--
 app/test/test_lpm6_data.h                   | 2025 ++++++++++---------
 app/test/test_lpm6_perf.c                   |   10 +-
 app/test/test_net_ip6.c                     |  195 ++
 app/test/test_reassembly_perf.c             |   23 +-
 app/test/test_rib6.c                        |   55 +-
 app/test/test_table_combined.c              |    2 +-
 app/test/test_table_tables.c                |    8 +-
 app/test/test_thash.c                       |   46 +-
 doc/guides/prog_guide/ipsec_lib.rst         |    4 +-
 doc/guides/rel_notes/deprecation.rst        |   42 -
 doc/guides/rel_notes/release_24_11.rst      |   12 +
 drivers/common/cnxk/cnxk_security.c         |   15 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |    1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |    1 +
 drivers/net/bnxt/bnxt_flow.c                |   12 +-
 drivers/net/bonding/rte_eth_bond_pmd.c      |    6 +-
 drivers/net/cxgbe/cxgbe_flow.c              |   20 +-
 drivers/net/dpaa2/dpaa2_flow.c              |   24 +-
 drivers/net/hinic/hinic_pmd_flow.c          |    6 +-
 drivers/net/hinic/hinic_pmd_tx.c            |    2 +-
 drivers/net/hns3/hns3_flow.c                |    8 +-
 drivers/net/i40e/i40e_flow.c                |   12 +-
 drivers/net/iavf/iavf_fdir.c                |    8 +-
 drivers/net/iavf/iavf_fsub.c                |    8 +-
 drivers/net/iavf/iavf_ipsec_crypto.c        |    9 +-
 drivers/net/ice/ice_fdir_filter.c           |   12 +-
 drivers/net/ice/ice_switch_filter.c         |   16 +-
 drivers/net/igc/igc_flow.c                  |    4 +-
 drivers/net/ixgbe/ixgbe_flow.c              |   12 +-
 drivers/net/ixgbe/ixgbe_ipsec.c             |    4 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c       |   36 +-
 drivers/net/mlx5/mlx5_flow.c                |    8 +-
 drivers/net/mlx5/mlx5_flow_dv.c             |   20 +-
 drivers/net/mlx5/mlx5_flow_hw.c             |   12 +-
 drivers/net/mlx5/mlx5_flow_verbs.c          |    8 +-
 drivers/net/mvpp2/mrvl_flow.c               |   16 +-
 drivers/net/nfp/flower/nfp_flower_flow.c    |   34 +-
 drivers/net/nfp/nfp_ipsec.c                 |    4 +-
 drivers/net/nfp/nfp_net_flow.c              |   38 +-
 drivers/net/qede/qede_filter.c              |    4 +-
 drivers/net/sfc/sfc_flow.c                  |   22 +-
 drivers/net/tap/tap_flow.c                  |   14 +-
 drivers/net/txgbe/txgbe_flow.c              |   12 +-
 drivers/net/txgbe/txgbe_ipsec.c             |    4 +-
 examples/cmdline/commands.c                 |   30 +-
 examples/ip_fragmentation/main.c            |   23 +-
 examples/ip_pipeline/cli.c                  |   61 +-
 examples/ip_pipeline/parser.c               |    2 +-
 examples/ip_pipeline/parser.h               |    3 +-
 examples/ip_pipeline/pipeline.c             |   17 +-
 examples/ip_pipeline/pipeline.h             |    6 +-
 examples/ip_pipeline/thread.c               |   15 +-
 examples/ip_reassembly/main.c               |   23 +-
 examples/ipsec-secgw/flow.c                 |   45 +-
 examples/ipsec-secgw/ipsec.c                |   33 +-
 examples/ipsec-secgw/ipsec.h                |    5 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h       |    7 +-
 examples/ipsec-secgw/ipsec_worker.c         |   11 +-
 examples/ipsec-secgw/ipsec_worker.h         |    4 +-
 examples/ipsec-secgw/parser.c               |    2 +-
 examples/ipsec-secgw/parser.h               |    4 +-
 examples/ipsec-secgw/rt.c                   |   24 +-
 examples/ipsec-secgw/sa.c                   |   37 +-
 examples/ipsec-secgw/sad.h                  |   14 +-
 examples/ipsec-secgw/sp6.c                  |  154 +-
 examples/l3fwd-graph/main.c                 |   33 +-
 examples/l3fwd/l3fwd_fib.c                  |   39 +-
 examples/l3fwd/l3fwd_lpm.c                  |    8 +-
 examples/l3fwd/l3fwd_route.h                |    9 +-
 examples/l3fwd/lpm_route_parse.c            |    9 +-
 examples/l3fwd/main.c                       |   32 +-
 lib/cmdline/cmdline_parse_ipaddr.h          |    3 +-
 lib/ethdev/rte_flow.h                       |   27 +-
 lib/fib/meson.build                         |    4 +-
 lib/fib/rte_fib6.c                          |   19 +-
 lib/fib/rte_fib6.h                          |   16 +-
 lib/fib/trie.c                              |  117 +-
 lib/fib/trie.h                              |   19 +-
 lib/fib/trie_avx512.c                       |   38 +-
 lib/fib/trie_avx512.h                       |   10 +-
 lib/gro/gro_tcp6.c                          |    8 +-
 lib/gro/gro_tcp6.h                          |    6 +-
 lib/hash/rte_thash.h                        |   29 +-
 lib/ip_frag/rte_ip_frag.h                   |    1 +
 lib/ip_frag/rte_ipv6_reassembly.c           |    4 +-
 lib/ipsec/iph.h                             |    1 +
 lib/ipsec/rte_ipsec_sad.h                   |    5 +-
 lib/lpm/meson.build                         |    1 +
 lib/lpm/rte_lpm6.c                          |  148 +-
 lib/lpm/rte_lpm6.h                          |   19 +-
 lib/net/meson.build                         |    2 +
 lib/net/rte_cksum.h                         |  180 ++
 lib/net/rte_ip.h                            |  467 +----
 lib/net/rte_ip6.h                           |  691 +++++++
 lib/net/rte_net.c                           |    1 +
 lib/net/rte_net.h                           |    1 +
 lib/node/ip6_lookup.c                       |   21 +-
 lib/node/rte_node_ip6_api.h                 |    3 +-
 lib/pipeline/rte_swx_ipsec.c                |   11 +-
 lib/pipeline/rte_swx_ipsec.h                |    5 +-
 lib/pipeline/rte_table_action.c             |   45 +-
 lib/pipeline/rte_table_action.h             |    7 +-
 lib/rib/meson.build                         |    2 +-
 lib/rib/rte_rib6.c                          |  112 +-
 lib/rib/rte_rib6.h                          |   27 +-
 lib/security/rte_security.h                 |    5 +-
 lib/table/rte_table_lpm_ipv6.c              |   12 +-
 lib/table/rte_table_lpm_ipv6.h              |    7 +-
 lib/vhost/virtio_net.c                      |    1 +
 135 files changed, 3399 insertions(+), 3128 deletions(-)
 create mode 100644 app/test/test_net_ip6.c
 create mode 100644 lib/net/rte_cksum.h
 create mode 100644 lib/net/rte_ip6.h
Signature · 1 line
2.46.2
#68 lore raw

PATCH v3 1/17 net: split raw checksum functions in separate header

The checksum functions are used by both ipv4 and ipv6 functions. In preparation of moving ipv6 symbols to a new header, move the checksum related symbols to another dedicated header.

---
 lib/net/meson.build |   1 +
 lib/net/rte_cksum.h | 180 ++++++++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip.h    | 148 +-----------------------------------
 3 files changed, 182 insertions(+), 147 deletions(-)
 create mode 100644 lib/net/rte_cksum.h
lib/net/meson.build +1 -0
index 06da7338ba97..63d2fabbaf6c 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
         'rte_tls.h',
lib/net/rte_cksum.h new file +180 -0

180 lines not on this page · raw message

lib/net/rte_ip.h +1 -147

160 lines not on this page · raw message

Signature · 1 line
2.46.2
#69 lore raw

PATCH v3 2/17 net: split ipv6 symbols in separate header

In reply to Robin Jarry

Move all ipv6 related symbols to a dedicated header. Update all code accordingly.

---

Notes:
v3: strip braces to make checkpatch happy

 app/test/packet_burst_generator.c           |   1 +
 app/test/test_cryptodev_security_ipsec.c    |   1 +
 doc/guides/rel_notes/release_24_11.rst      |   1 +
 drivers/common/cnxk/cnxk_security.c         |   1 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |   1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |   1 +
 examples/ip_pipeline/pipeline.c             |   1 +
 lib/ethdev/rte_flow.h                       |   1 +
 lib/hash/rte_thash.h                        |   1 +
 lib/ip_frag/rte_ip_frag.h                   |   1 +
 lib/ipsec/iph.h                             |   1 +
 lib/net/meson.build                         |   1 +
 lib/net/rte_ip.h                            | 319 ------------------
 lib/net/{rte_ip.h => rte_ip6.h}             | 352 +-------------------
 lib/net/rte_net.c                           |   1 +
 lib/net/rte_net.h                           |   1 +
 lib/pipeline/rte_swx_ipsec.c                |   1 +
 lib/pipeline/rte_table_action.c             |   1 +
 lib/vhost/virtio_net.c                      |   1 +
 19 files changed, 23 insertions(+), 665 deletions(-)
 copy lib/net/{rte_ip.h => rte_ip6.h} (50%)
app/test/packet_burst_generator.c +1 -0
index 867a88da0055..2cd34abc1a65 100644
@@ -5,6 +5,7 @@
 #include <rte_byteorder.h>
 #include <rte_mbuf.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_os_shim.h>
 
 #include "packet_burst_generator.h"
app/test/test_cryptodev_security_ipsec.c +1 -0
index e6a81ca186ac..54355e31dd6a 100644
@@ -6,6 +6,7 @@
 #include <rte_cryptodev.h>
 #include <rte_esp.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_security.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
doc/guides/rel_notes/release_24_11.rst +1 -0
index 915065a6f95e..182e890aa8f2 100644
@@ -142,6 +142,7 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =======================================================
 
+* net: IPv6 related symbols were moved from ``<rte_ip.h>`` to the new ``<rte_ip6.h>`` header.
 
 ABI Changes
 -----------
drivers/common/cnxk/cnxk_security.c +1 -0
index e67c3f233187..41987299b6b3 100644
@@ -2,6 +2,7 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <rte_ip6.h>
 #include <rte_udp.h>
 
 #include "cnxk_security.h"
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +1 -0
index f443cb9563ec..a3c737ef40f7 100644
@@ -6,6 +6,7 @@
 #include <cryptodev_pmd.h>
 #include <rte_event_crypto_adapter.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_vect.h>
 
 #include "roc_cpt.h"
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c +1 -0
index b34183d594af..525cd4e654cb 100644
@@ -10,6 +10,7 @@
 #include <unistd.h>
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_udp.h>
 #include <rte_mbuf.h>
 #include <rte_cryptodev.h>
examples/ip_pipeline/pipeline.c +1 -0
index 63352257c6e9..301c52d061be 100644
@@ -7,6 +7,7 @@
 
 #include <rte_common.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 
 #include <rte_string_fns.h>
lib/ethdev/rte_flow.h +1 -0
index f864578f806b..3a3ab781c494 100644
@@ -23,6 +23,7 @@
 #include <rte_arp.h>
 #include <rte_icmp.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_sctp.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
lib/hash/rte_thash.h +1 -0
index ec0c029402fc..18adafbd99fc 100644
@@ -19,6 +19,7 @@
 
 #include <rte_byteorder.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_common.h>
 #include <rte_thash_gfni.h>
 
lib/ip_frag/rte_ip_frag.h +1 -0
index 84fd7179532b..d44e7bf91412 100644
@@ -19,6 +19,7 @@
 #include <rte_malloc.h>
 #include <rte_memory.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_byteorder.h>
 
 #ifdef __cplusplus
lib/ipsec/iph.h +1 -0
index 861f16905ad0..815a3c90d76b 100644
@@ -6,6 +6,7 @@
 #define _IPH_H_
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 
 /**
  * @file iph.h
lib/net/meson.build +1 -0
index 63d2fabbaf6c..df37f7ead962 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_ip6.h',
         'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
lib/net/rte_ip.h +0 -319

325 lines not on this page · raw message

lib/net/rte_ip6.h renamed from lib/net/rte_ip.h +6 -346

385 lines not on this page · raw message

lib/net/rte_net.c +1 -0
index d680accc1631..13aef6147ab0 100644
@@ -9,6 +9,7 @@
 #include <rte_byteorder.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_sctp.h>
lib/net/rte_net.h +1 -0
index 40ad6a71a10f..8b7c43cbe724 100644
@@ -6,6 +6,7 @@
 #define _RTE_NET_PTYPE_H_
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_udp.h>
 #include <rte_tcp.h>
 
lib/pipeline/rte_swx_ipsec.c +1 -0
index 73e8211b2818..56a401d0fa63 100644
@@ -11,6 +11,7 @@
 #include <rte_common.h>
 #include <rte_random.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tailq.h>
 #include <rte_eal_memconfig.h>
 #include <rte_ring.h>
lib/pipeline/rte_table_action.c +1 -0
index 87c3e0e2c935..ebbdd3f4cebe 100644
@@ -11,6 +11,7 @@
 #include <rte_memcpy.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
 #include <rte_vxlan.h>
lib/vhost/virtio_net.c +1 -0
index 370402d84903..d4dcc811c55f 100644
@@ -11,6 +11,7 @@
 #include <rte_net.h>
 #include <rte_ether.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_dmadev.h>
 #include <rte_vhost.h>
 #include <rte_tcp.h>
Signature · 1 line
2.46.2
#70 lore raw

PATCH v3 3/17 net: add structure for ipv6 addresses

In reply to Robin Jarry

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

---

Notes:
v3: move RTE_IPV6_MAX_DEPTH to next commit

 lib/net/rte_ip6.h | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/net/rte_ip6.h +9 -0
index 9ed737d5eb81..a5ebe065b61e 100644
@@ -35,6 +35,15 @@
 extern "C" {
 #endif
 
+#define RTE_IPV6_ADDR_SIZE 16
+
+/**
+ * IPv6 Address
+ */
+struct rte_ipv6_addr {
+	uint8_t a[RTE_IPV6_ADDR_SIZE];
+};
+
 /**
  * IPv6 Header
  */
Signature · 1 line
2.46.2
#71 lore raw

PATCH v3 4/17 net: add ipv6 address utilities

In reply to Robin Jarry

Add utility functions and macros that use the newly added rte_ipv6_addr structure. Add basic unit tests to ensure everything works as expected.

These functions will be used in the next commits to replace private and/or duplicated functions.

---

Notes:
v3:

- rename test_net_ipv6.c -> test_net_ip6.c to match rte_ip6.h
- remove rte_ipv6_addr_cpy()
- rename RTE_IPV6_ADDR(...) to RTE_IPV6() to match RTE_IPV4()
- add RTE_IPV6_ADDR_FMT and RTE_IPV6_ADDR_SPLIT()
- add RTE_IPV6_ADDR_LOOPBACK and RTE_IPV6_MASK_FULL

 MAINTAINERS             |   1 +
 app/test/meson.build    |   1 +
 app/test/test_net_ip6.c | 111 +++++++++++++++++++++++++++
 lib/net/rte_ip6.h       | 165 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 278 insertions(+)
 create mode 100644 app/test/test_net_ip6.c
MAINTAINERS +1 -0
index 812463fe9f90..0b09df757d6b 100644
@@ -1519,6 +1519,7 @@ F: lib/net/
 F: app/test/test_cksum.c
 F: app/test/test_cksum_perf.c
 F: app/test/test_net_ether.c
+F: app/test/test_net_ip6.c
 
 Packet CRC
 M: Jasvinder Singh <[email protected]>
app/test/meson.build +1 -0
index e29258e6ec05..c297dcdb13e0 100644
@@ -130,6 +130,7 @@ source_file_deps = {
     'test_metrics.c': ['metrics'],
     'test_mp_secondary.c': ['hash'],
     'test_net_ether.c': ['net'],
+    'test_net_ip6.c': ['net'],
     'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'],
     'test_pdcp.c': ['eventdev', 'pdcp', 'net', 'timer', 'security'],
     'test_pdump.c': ['pdump'] + sample_packet_forward_deps,
app/test/test_net_ip6.c new file +111 -0

111 lines not on this page · raw message

lib/net/rte_ip6.h +165 -0

183 lines not on this page · raw message

Signature · 1 line
2.46.2