From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BF2145B69; Fri, 18 Oct 2024 16:08:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA13840B95; Fri, 18 Oct 2024 16:06:53 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 2A93740A76 for ; Fri, 18 Oct 2024 16:06:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729260407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h7OIuzbNWVTwkEOBUNgFOtXCtMvCJK/OyRlpa5jVJPU=; b=e1WoHfYtl1udOGaJ+5jD+xTN0BSXmasy2YXDan1PQP0Qw8omT/SWsY4/QtILhk2ThaYKCP t/i5yo0wOFBSBKmc5kWf88mGGnkCkoemMVJj3e2q13LWU/8HRty1SCBIDBEC/cR/uTwwEe 3nbaNYwxEbPH5nM3U6CfLTubEO6B/3s= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-id5UqLtePWWOg-4FipbC8w-1; Fri, 18 Oct 2024 10:06:44 -0400 X-MC-Unique: id5UqLtePWWOg-4FipbC8w-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC8AD1977032; Fri, 18 Oct 2024 14:06:23 +0000 (UTC) Received: from ringo.redhat.com (unknown [10.39.208.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 78E3E19560A2; Fri, 18 Oct 2024 14:06:11 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Wisam Jaddo , Cristian Dumitrescu , Konstantin Ananyev , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin , Ajit Khaparde , Somnath Kotur , Chas Williams , "Min Hu (Connor)" , Potnuri Bharat Teja , Hemant Agrawal , Sachin Saxena , Ziyang Xuan , Xiaoyun Wang , Jie Hai , Yisen Zhuang , Jingjing Wu , Dariusz Sosnowski , Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad , Liron Himi , Chaoyong He , Devendra Singh Rawat , Alok Prasad , Andrew Rybchenko , Stephen Hemminger , Jiawen Wu , Jian Wang , Radu Nicolau , Akhil Goyal , Thomas Monjalon , Ferruh Yigit , Nithin Dabilpuram , Pavan Nikhilesh Subject: [PATCH dpdk v5 04/17] net: use IPv6 structure for packet headers Date: Fri, 18 Oct 2024 16:05:40 +0200 Message-ID: <20241018140553.79789-5-rjarry@redhat.com> In-Reply-To: <20241018140553.79789-1-rjarry@redhat.com> References: <20240821162516.610624-17-rjarry@redhat.com> <20241018140553.79789-1-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The rte_ipv6_hdr uses ad-hoc uint8_t[16] arrays to represent addresses. Replace these arrays with the newly added rte_ipv6_addr structure. Adapt all code accordingly. Signed-off-by: Robin Jarry --- 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 | 23 +++++++------- app/test/test_thash.c | 8 ++--- doc/guides/rel_notes/deprecation.rst | 2 -- doc/guides/rel_notes/release_24_11.rst | 6 ++++ drivers/net/bnxt/bnxt_flow.c | 12 ++++---- drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++-- 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/mvpp2/mrvl_flow.c | 16 ++++------ drivers/net/nfp/flower/nfp_flower_flow.c | 32 ++++++++++---------- 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 | 10 +++---- 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 | 33 ++++---------------- 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 +++++++-------- 53 files changed, 260 insertions(+), 310 deletions(-) diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c index 4ae72509d445..c740e1838ffb 100644 --- a/app/test-flow-perf/items_gen.c +++ b/app/test-flow-perf/items_gen.c @@ -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; diff --git a/app/test-pipeline/pipeline_hash.c b/app/test-pipeline/pipeline_hash.c index cab9c2098014..194e5c5dcc53 100644 --- a/app/test-pipeline/pipeline_hash.c +++ b/app/test-pipeline/pipeline_hash.c @@ -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; diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c index 867a88da0055..c9ff5257f070 100644 --- a/app/test/packet_burst_generator.c +++ b/app/test/packet_burst_generator.c @@ -148,8 +148,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)); } diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c index 8e4df220a214..18d672715729 100644 --- a/app/test/test_ipfrag.c +++ b/app/test/test_ipfrag.c @@ -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, 0x08, sizeof(hdr->src_addr)); + memset(&hdr->dst_addr, 0x04, sizeof(hdr->src_addr)); } static inline void diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c index 3912179022fc..15db19add917 100644 --- a/app/test/test_reassembly_perf.c +++ b/app/test/test_reassembly_perf.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ #define IP_DST_ADDR(x) ((198U << 24) | (18 << 16) | (1 << 15) | (x)) /* 2001:0200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180) */ -static uint8_t ip6_addr[16] = {32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static struct rte_ipv6_addr ip6_addr = RTE_IPV6(0x2001, 0x0200, 0, 0, 0, 0, 0, 0); #define IP6_VERSION 6 #define IP_DEFTTL 64 /* from RFC 1340. */ @@ -340,17 +341,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; + ip_hdr->src_addr = ip6_addr; + ip_hdr->dst_addr = ip6_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; diff --git a/app/test/test_thash.c b/app/test/test_thash.c index 65d42fd90085..952da6a52954 100644 --- a/app/test/test_thash.c +++ b/app/test/test_thash.c @@ -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; diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 20fcfedb7b89..830904203c38 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -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 diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index e68676caf029..de24705ef662 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -286,6 +286,12 @@ API Changes * drivers/net/ena: Removed ``enable_llq``, ``normal_llq_hdr`` and ``large_llq_hdr`` devargs and replaced it with a new shared devarg ``llq_policy`` that keeps the same logic. +* net: A new IPv6 address structure was introduced to replace ad-hoc ``uint8_t[16]`` arrays. + The following libraries and symbols were modified: + + net + - ``struct rte_ipv6_hdr`` + ABI Changes ----------- diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c index 03413e912149..c41403c753cf 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -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; } diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 34131f0e35f6..cda1c37124f4 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -689,10 +689,8 @@ ipv4_hash(struct rte_ipv4_hdr *ipv4_hdr) 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 *word_dst_addr = - (unaligned_uint32_t *)&(ipv6_hdr->dst_addr[0]); + unaligned_uint32_t *word_src_addr = (unaligned_uint32_t *)&ipv6_hdr->src_addr; + unaligned_uint32_t *word_dst_addr = (unaligned_uint32_t *)&ipv6_hdr->dst_addr; return (word_src_addr[0] ^ word_dst_addr[0]) ^ (word_src_addr[1] ^ word_dst_addr[1]) ^ diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c index 40d21e694409..b6d169097c1a 100644 --- a/drivers/net/cxgbe/cxgbe_flow.c +++ b/drivers/net/cxgbe/cxgbe_flow.c @@ -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,10 +918,8 @@ static struct chrte_fparse parseitem[] = { .fptr = ch_rte_parsetype_ipv6, .dmask = &(const struct rte_flow_item_ipv6) { .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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .vtc_flow = RTE_BE32(0xff000000), }, }, diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index 1b55d8dd173b..54b17e97c031 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -117,10 +117,8 @@ 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 = { 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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .proto = 0xff }, }; @@ -1478,16 +1476,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, @@ -1526,13 +1524,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; } @@ -1569,7 +1567,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, @@ -1616,13 +1614,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; } diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c index d1a564a16303..8fdd5a35be9f 100644 --- a/drivers/net/hinic/hinic_pmd_flow.c +++ b/drivers/net/hinic/hinic_pmd_flow.c @@ -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. diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c index f09b1a6e1ea6..22fb0bffafcc 100644 --- a/drivers/net/hinic/hinic_pmd_tx.c +++ b/drivers/net/hinic/hinic_pmd_tx.c @@ -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); diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 37eb2b4c3807..bf1eee506dde 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -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; diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index 92165c8422d5..c6857727e8be 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -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 == diff --git a/drivers/net/iavf/iavf_fdir.c b/drivers/net/iavf/iavf_fdir.c index 811a10287b70..321346425465 100644 --- a/drivers/net/iavf/iavf_fdir.c +++ b/drivers/net/iavf/iavf_fdir.c @@ -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); diff --git a/drivers/net/iavf/iavf_fsub.c b/drivers/net/iavf/iavf_fsub.c index 74e1e7099b8c..eb5a3feab189 100644 --- a/drivers/net/iavf/iavf_fsub.c +++ b/drivers/net/iavf/iavf_fsub.c @@ -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++; } diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c index 6fd45ff45f3d..89dd5af5500f 100644 --- a/drivers/net/iavf/iavf_ipsec_crypto.c +++ b/drivers/net/iavf/iavf_ipsec_crypto.c @@ -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); + ipv6->src_addr = item->hdr.src_addr; + ipv6->dst_addr = item->hdr.dst_addr; } 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); diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 741107f93939..406918fed547 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -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; diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index 122b87f625a7..28bc775a2c34 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -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++; } } diff --git a/drivers/net/igc/igc_flow.c b/drivers/net/igc/igc_flow.c index b677a0d61340..b778ac26135a 100644 --- a/drivers/net/igc/igc_flow.c +++ b/drivers/net/igc/igc_flow.c @@ -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"); diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c index 687341c6b8d3..1b35ed5faabe 100644 --- a/drivers/net/ixgbe/ixgbe_flow.c +++ b/drivers/net/ixgbe/ixgbe_flow.c @@ -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); } /** diff --git a/drivers/net/ixgbe/ixgbe_ipsec.c b/drivers/net/ixgbe/ixgbe_ipsec.c index 3a666ba15f59..778004cbe4d2 100644 --- a/drivers/net/ixgbe/ixgbe_ipsec.c +++ b/drivers/net/ixgbe/ixgbe_ipsec.c @@ -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; diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index 10b986d66bd7..a9fa5d06edcc 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -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; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index effc61cdc9da..7f8640b488b8 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2933,10 +2933,8 @@ 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 = { 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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .vtc_flow = RTE_BE32(0xffffffff), .proto = 0xff, }, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 5f71573a86d6..201e215e4bad 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7696,10 +7696,8 @@ const struct rte_flow_item_ipv4 nic_ipv4_mask = { const struct rte_flow_item_ipv6 nic_ipv6_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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .vtc_flow = RTE_BE32(0xffffffff), .proto = 0xff, .hop_limits = 0xff, @@ -9548,10 +9546,8 @@ 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 = { 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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .vtc_flow = RTE_BE32(0xffffffff), .proto = 0xff, .hop_limits = 0xff, @@ -9574,11 +9570,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); diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index c5ddd1d40433..0084f819804f 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -8301,10 +8301,8 @@ const struct rte_flow_item_ipv6 hws_nic_ipv6_mask = { .payload_len = RTE_BE16(0xffff), .proto = 0xff, .hop_limits = 0xff, - .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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, }, .has_frag_ext = 1, }; @@ -14741,10 +14739,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: diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index 3a4356c0f650..5b4a4eda3bbc 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -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); diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index e74a5f83f55b..098523ada653 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -536,27 +536,23 @@ mrvl_parse_ip6_addr(const struct rte_flow_item_ipv6 *spec, int parse_dst, struct rte_flow *flow) { struct pp2_cls_rule_key_field *key_field; - int size = sizeof(spec->hdr.dst_addr); - struct in6_addr k, m; + struct rte_ipv6_addr k, m; - memset(&k, 0, sizeof(k)); if (parse_dst) { - memcpy(k.s6_addr, spec->hdr.dst_addr, size); - memcpy(m.s6_addr, mask->hdr.dst_addr, size); - + k = spec->hdr.dst_addr; + m = mask->hdr.dst_addr; flow->table_key.proto_field[flow->rule.num_fields].field.ipv6 = MV_NET_IP6_F_DA; } else { - memcpy(k.s6_addr, spec->hdr.src_addr, size); - memcpy(m.s6_addr, mask->hdr.src_addr, size); - + k = spec->hdr.src_addr; + m = mask->hdr.src_addr; flow->table_key.proto_field[flow->rule.num_fields].field.ipv6 = MV_NET_IP6_F_SA; } key_field = &flow->rule.fields[flow->rule.num_fields]; mrvl_alloc_key_mask(key_field); - key_field->size = 16; + key_field->size = RTE_IPV6_ADDR_SIZE; inet_ntop(AF_INET6, &k, (char *)key_field->key, MRVL_CLS_STR_SIZE_MAX); inet_ntop(AF_INET6, &m, (char *)key_field->mask, MRVL_CLS_STR_SIZE_MAX); diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index e94c7e22e371..43574afea8ac 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -2066,18 +2066,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 { @@ -2100,8 +2100,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); @@ -2557,10 +2557,8 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { .vtc_flow = RTE_BE32(0x0ff00000), .proto = 0xff, .hop_limits = 0xff, - .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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, }, .has_frag_ext = 1, }, @@ -3363,8 +3361,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); @@ -3384,8 +3382,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; @@ -3612,7 +3610,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); @@ -3982,7 +3980,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); @@ -4059,7 +4057,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); diff --git a/drivers/net/nfp/nfp_net_flow.c b/drivers/net/nfp/nfp_net_flow.c index e9f0ce37109a..d72f6ce84c44 100644 --- a/drivers/net/nfp/nfp_net_flow.c +++ b/drivers/net/nfp/nfp_net_flow.c @@ -297,28 +297,28 @@ nfp_net_flow_merge_ipv6(struct rte_flow *nfp_flow, ipv6->l4_protocol_mask = mask->hdr.proto; for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) { - ipv6->src_ipv6_mask[i] = mask->hdr.src_addr[i + 3]; - ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr[i + 2]; - ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr[i + 1]; - ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr[i]; + ipv6->src_ipv6_mask[i] = mask->hdr.src_addr.a[i + 3]; + ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr.a[i + 2]; + ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr.a[i + 1]; + ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr.a[i]; - ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr[i + 3]; - ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr[i + 2]; - ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr[i + 1]; - ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr[i]; + ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr.a[i + 3]; + ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr.a[i + 2]; + ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr.a[i + 1]; + ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr.a[i]; } ipv6->l4_protocol = spec->hdr.proto; for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) { - ipv6->src_ipv6[i] = spec->hdr.src_addr[i + 3]; - ipv6->src_ipv6[i + 1] = spec->hdr.src_addr[i + 2]; - ipv6->src_ipv6[i + 2] = spec->hdr.src_addr[i + 1]; - ipv6->src_ipv6[i + 3] = spec->hdr.src_addr[i]; + ipv6->src_ipv6[i] = spec->hdr.src_addr.a[i + 3]; + ipv6->src_ipv6[i + 1] = spec->hdr.src_addr.a[i + 2]; + ipv6->src_ipv6[i + 2] = spec->hdr.src_addr.a[i + 1]; + ipv6->src_ipv6[i + 3] = spec->hdr.src_addr.a[i]; - ipv6->dst_ipv6[i] = spec->hdr.dst_addr[i + 3]; - ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr[i + 2]; - ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr[i + 1]; - ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr[i]; + ipv6->dst_ipv6[i] = spec->hdr.dst_addr.a[i + 3]; + ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr.a[i + 2]; + ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr.a[i + 1]; + ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr.a[i]; } return 0; @@ -406,10 +406,8 @@ static const struct nfp_net_flow_item_proc nfp_net_flow_item_proc_list[] = { .mask_support = &(const struct rte_flow_item_ipv6){ .hdr = { .proto = 0xff, - .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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, }, }, .mask_default = &rte_flow_item_ipv6_mask, diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c index d98266eac55c..14fb4338e9c7 100644 --- a/drivers/net/qede/qede_filter.c +++ b/drivers/net/qede/qede_filter.c @@ -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; } diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index 1b50aefe5c48..1006243539b5 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -575,14 +575,8 @@ 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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .proto = 0xff, } }; @@ -618,28 +612,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; } diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 5ae1faf9165d..51ec07eb5acd 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -209,10 +209,8 @@ static const struct tap_flow_items tap_flow_items[] = { RTE_FLOW_ITEM_TYPE_TCP), .mask = &(const struct rte_flow_item_ipv6){ .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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, .proto = -1, }, }, @@ -613,13 +611,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, diff --git a/drivers/net/txgbe/txgbe_flow.c b/drivers/net/txgbe/txgbe_flow.c index 7ef52d0b0fcd..5d2dd453687c 100644 --- a/drivers/net/txgbe/txgbe_flow.c +++ b/drivers/net/txgbe/txgbe_flow.c @@ -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); } /** diff --git a/drivers/net/txgbe/txgbe_ipsec.c b/drivers/net/txgbe/txgbe_ipsec.c index 4af49dd802d0..65b6c251c684 100644 --- a/drivers/net/txgbe/txgbe_ipsec.c +++ b/drivers/net/txgbe/txgbe_ipsec.c @@ -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; diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index 736eae6f05ee..4c0fa5054a2e 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -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; diff --git a/examples/ip_pipeline/pipeline.c b/examples/ip_pipeline/pipeline.c index 63352257c6e9..792aab0059e9 100644 --- a/examples/ip_pipeline/pipeline.c +++ b/examples/ip_pipeline/pipeline.c @@ -637,7 +637,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] = { @@ -645,7 +645,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] = { @@ -653,7 +653,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] = { @@ -661,7 +661,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) */ @@ -670,7 +670,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] = { @@ -678,7 +678,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] = { @@ -686,7 +686,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] = { @@ -694,7 +694,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 */ diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c index c7019078f7b4..4da692eb23e6 100644 --- a/examples/ip_reassembly/main.c +++ b/examples/ip_reassembly/main.c @@ -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; diff --git a/examples/ipsec-secgw/flow.c b/examples/ipsec-secgw/flow.c index 05a62c3020fa..3f7630f5fd53 100644 --- a/examples/ipsec-secgw/flow.c +++ b/examples/ipsec-secgw/flow.c @@ -83,29 +83,8 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token, static void ipv6_hdr_print(struct rte_ipv6_hdr *hdr) { - uint8_t *addr; - - addr = hdr->src_addr; - 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]), - (uint16_t)((addr[4] << 8) | addr[5]), - (uint16_t)((addr[6] << 8) | addr[7]), - (uint16_t)((addr[8] << 8) | addr[9]), - (uint16_t)((addr[10] << 8) | addr[11]), - (uint16_t)((addr[12] << 8) | addr[13]), - (uint16_t)((addr[14] << 8) | addr[15])); - - addr = hdr->dst_addr; - printf("dst: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx", - (uint16_t)((addr[0] << 8) | addr[1]), - (uint16_t)((addr[2] << 8) | addr[3]), - (uint16_t)((addr[4] << 8) | addr[5]), - (uint16_t)((addr[6] << 8) | addr[7]), - (uint16_t)((addr[8] << 8) | addr[9]), - (uint16_t)((addr[10] << 8) | addr[11]), - (uint16_t)((addr[12] << 8) | addr[13]), - (uint16_t)((addr[14] << 8) | addr[15])); + printf("src: " RTE_IPV6_ADDR_FMT " \t", RTE_IPV6_ADDR_SPLIT(&hdr->src_addr)); + printf("dst: " RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&hdr->dst_addr)); } static int @@ -196,8 +175,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 +184,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; } diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index b52b0ffc3d22..ebde28639c12 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -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; diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c index c4bac17cd77c..1a0afd2ed2e8 100644 --- a/examples/ipsec-secgw/sa.c +++ b/examples/ipsec-secgw/sa.c @@ -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); diff --git a/examples/ipsec-secgw/sad.h b/examples/ipsec-secgw/sad.h index 3224b6252c8d..fdb1d2ef1790 100644 --- a/examples/ipsec-secgw/sad.h +++ b/examples/ipsec-secgw/sad.h @@ -5,6 +5,8 @@ #ifndef __SAD_H__ #define __SAD_H__ +#include +#include #include #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]; diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c index 993e36cec235..85f862dd5b40 100644 --- a/examples/l3fwd/l3fwd_fib.c +++ b/examples/l3fwd/l3fwd_fib.c @@ -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)++; } diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index e8fd95aae9ce..422fdb70054d 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -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); } diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 22c5c147d0ea..e8baedcc79d8 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -1005,10 +1005,8 @@ struct rte_flow_item_ipv6 { #ifndef __cplusplus static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_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 = RTE_IPV6_MASK_FULL, + .dst_addr = RTE_IPV6_MASK_FULL, }, }; #endif diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index ec0c029402fc..eab753a06f3d 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -139,24 +139,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 + 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 + i)); } #endif } diff --git a/lib/ip_frag/rte_ipv6_reassembly.c b/lib/ip_frag/rte_ipv6_reassembly.c index 88863a98d1fe..9471ce5333d7 100644 --- a/lib/ip_frag/rte_ipv6_reassembly.c +++ b/lib/ip_frag/rte_ipv6_reassembly.c @@ -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; diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h index 2420339d1598..25a77277f050 100644 --- a/lib/net/rte_ip6.h +++ b/lib/net/rte_ip6.h @@ -256,8 +256,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. */ @@ -325,7 +325,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); diff --git a/lib/node/ip6_lookup.c b/lib/node/ip6_lookup.c index 309964f60fd6..6bbcf14e2aa8 100644 --- a/lib/node/ip6_lookup.c +++ b/lib/node/ip6_lookup.c @@ -112,28 +112,28 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node, sizeof(struct rte_ether_hdr)); /* Extract hop_limits as ipv6 hdr is in cache */ node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits; - rte_memcpy(ip_batch[0], ipv6_hdr->dst_addr, 16); + rte_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; diff --git a/lib/pipeline/rte_swx_ipsec.c b/lib/pipeline/rte_swx_ipsec.c index 73e8211b2818..0ed0ecd134c8 100644 --- a/lib/pipeline/rte_swx_ipsec.c +++ b/lib/pipeline/rte_swx_ipsec.c @@ -1386,13 +1386,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. */ diff --git a/lib/pipeline/rte_table_action.c b/lib/pipeline/rte_table_action.c index 87c3e0e2c935..c0be656536eb 100644 --- a/lib/pipeline/rte_table_action.c +++ b/lib/pipeline/rte_table_action.c @@ -871,10 +871,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)); @@ -906,10 +906,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)); @@ -1436,12 +1436,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 { @@ -1449,12 +1449,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; } @@ -1464,12 +1464,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 { @@ -1477,12 +1477,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, (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; } -- 2.47.0