Reduce scope address-of-packed-member warning
cover Reduce scope address-of-packed-member warning
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disabling
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip.h | 33 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 60 insertions(+), 154 deletions(-)
--
2.43.0
PATCH 1/6 ip_frag: remove use of unaligned variable
If compiling with -Waddress-of-packed-member, we get a warning about the use of the unaligned uint64_t value which is used to copy 8 bytes from ip_hdr to the key. Replace this unaligned assignment with an equivalent 8-byte constant-sized memcpy, allowing the compiler to choose optimal instructions to do the assignment.
--- lib/ip_frag/rte_ipv4_reassembly.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/ip_frag/rte_ipv4_reassembly.c +1 -3
@@ -101,7 +101,6 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, {struct ip_frag_pkt *fp;struct ip_frag_key key; -const unaligned_uint64_t *psd;uint16_t flag_offset, ip_ofs, ip_flag;int32_t ip_len;int32_t trim;
@@ -110,9 +109,8 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_ofs = (uint16_t )(flag_offset &RTE_IPV4_HDR_OFFSET_MASK ); ip_flag = (uint16_t )(flag_offset &RTE_IPV4_HDR_MF_FLAG ); - psd = (unaligned_uint64_t *)&ip_hdr->src_addr;/* use first 8 bytes only */ - key.src_dst[0 ] = psd[0 ]; +memcpy (&key.src_dst[0 ], &ip_hdr->src_addr,8 ); key.id = ip_hdr->packet_id; key.key_len =IPV4_KEYLEN ;
Signature · 1 line
2.43.0
Re: [PATCH 1/6] ip_frag: remove use of unaligned variable
Quoted 7 lines · On Thu, 17 Oct 2024 15:22:08 +0100 Bruce Richardson…
If compiling with -Waddress-of-packed-member, we get a warning about the use of the unaligned
uint64_tvalue which is used to copy 8 bytes fromip_hdrto the key. Replace this unaligned assignment with an equivalent 8-byte constant-sized memcpy, allowing the compiler to choose optimal instructions to do the assignment.Signed-off-by Bruce Richardson <[email protected]>
RE: [PATCH 1/6] ip_frag: remove use of unaligned variable
In reply to Bruce RichardsonQuoted 27 lines
If compiling with -Waddress-of-packed-member, we get a warning about the use of the unaligned
uint64_tvalue which is used to copy 8 bytes fromip_hdrto the key. Replace this unaligned assignment with an equivalent 8-byte constant-sized memcpy, allowing the compiler to choose optimal instructions to do the assignment.Signed-off-by Bruce Richardson <[email protected]>--- lib/ip_frag/rte_ipv4_reassembly.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)lib/ip_frag/rte_ipv4_reassembly.c +0
-1@@ -101,7 +101,6 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, {struct ip_frag_pkt *fp;struct ip_frag_key key; -const unaligned_uint64_t *psd;uint16_t flag_offset, ip_ofs, ip_flag;int32_t ip_len;int32_t trim;@@ -110,9 +109,8 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_ofs = (uint16_t )(flag_offset &RTE_IPV4_HDR_OFFSET_MASK );
lib/ip_frag/rte_ipv4_reassembly.c rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
Quoted 10 lines
lib/ip_frag/rte_ipv4_reassembly.c +1
-3ip_flag = (uint16_t )(flag_offset &RTE_IPV4_HDR_MF_FLAG ); - psd = (unaligned_uint64_t *)&ip_hdr->src_addr;/* use first 8 bytes only */ - key.src_dst[0 ] = psd[0 ]; +memcpy (&key.src_dst[0 ], &ip_hdr->src_addr,8 ); key.id = ip_hdr->packet_id; key.key_len =IPV4_KEYLEN ; --
As a small nit, might be better:memcpy(&key.src_dst[0], &ip_hdr->src_addr, sizeof(key.src_dst[0]));
Quoted 1 line
2.43.0
PATCH 2/6 efd: remove unnecessary packed attributes
In reply to Bruce RichardsonThe structure "efd_online_group_entry" only consists of values which are typedefs of "uint16_t", so packing the structure has no effect. The "efd_online_chunk" structure has a mix of "uint8_t" and the "efd_online_group_entry" struct, i.e. uint16_t values, but since the first, uint8_t, member array is of even size, the packed attribute does not affect the structure layout.
Removing these packed attributes allows the library to compile cleanly without "-Wno-address-of-packed-member" compiler flag.
--- lib/efd/rte_efd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/efd/rte_efd.c +2 -2
@@ -212,7 +212,7 @@ struct efd_offline_chunk_rules {struct efd_online_group_entry {efd_hashfunc_t hash_idx[RTE_EFD_VALUE_NUM_BITS ];efd_lookuptbl_t lookup_table[RTE_EFD_VALUE_NUM_BITS ]; -} __rte_packed; +};/** * A single chunk record, containing EFD_TARGET_CHUNK_NUM_RULES rules.
@@ -228,7 +228,7 @@ struct efd_online_chunk {struct efd_online_group_entry groups[EFD_CHUNK_NUM_GROUPS ];/**< Array of all the groups in the chunk. */ -} __rte_packed; +};/** * EFD table structure
Signature · 1 line
2.43.0
Re: [PATCH 2/6] efd: remove unnecessary packed attributes
Quoted 7 lines · On Thu, 17 Oct 2024 15:22:09 +0100 Bruce Richardson…
The structure "
efd_online_group_entry" only consists of values which are typedefs of "uint16_t", so packing the structure has no effect. The "efd_online_chunk" structure has a mix of "uint8_t" and the "efd_online_group_entry" struct, i.e.uint16_tvalues, but since the first,uint8_t, member array is of even size, the packed attribute does not affect the structure layout.
Quoted 5 lines
Removing these packed attributes allows the library to compile cleanly without "-Wno-address-of-packed-member" compiler flag.
Signed-off-by Bruce Richardson <[email protected]>---
PATCH 3/6 bus/ifpga: remove packed attribute
In reply to Bruce RichardsonThe struct rte_afu_device does not need to be packed, so remove the packed attribute from it.
--- drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/ifpga/bus_ifpga_driver.h +1 -1
@@ -77,7 +77,7 @@ struct rte_afu_device {struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_afu_driver *driver;/**< Associated driver */ char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; -} __rte_packed; +};/** * @internal
Signature · 1 line
2.43.0
RE: [PATCH 3/6] bus/ifpga: remove packed attribute
Hi,
Quoted 31 lines
-----Original Message-----
From: Richardson, Bruce <[email protected]>
Sent: Thursday, October 17, 2024 10:22 PM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Xu, Rosen <[email protected]>
Subject: [PATCH 3/6] bus/ifpga: remove packed attributeThe struct
rte_afu_devicedoes not need to be packed, so remove the packed attribute from it.Signed-off-by Bruce Richardson <[email protected]>--- drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/bus/ifpga/bus_ifpga_driver.h +1
-2@@ -77,7 +77,7 @@ struct rte_afu_device {struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_afu_driver *driver;/**< Associated driver */ char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; -} __rte_packed; +};/** * @internal --
Quoted 1 line
2.43.0
Re: [PATCH 3/6] bus/ifpga: remove packed attribute
In reply to Bruce RichardsonQuoted 4 lines · On Thu, 17 Oct 2024 15:22:10 +0100 Bruce Richardson…
The struct
rte_afu_devicedoes not need to be packed, so remove the packed attribute from it.Signed-off-by Bruce Richardson <[email protected]>
PATCH 4/6 pipeline: remove packed attribute
In reply to Bruce RichardsonThe rte_trtcm_data structure, and its substructures, only consist of uint64_t types. This makes packing unnecessary to remove the packed attribute from the structure.
--- lib/pipeline/rte_table_action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pipeline/rte_table_action.c +1 -1
@@ -109,7 +109,7 @@ mtr_cfg_check(struct rte_table_action_mtr_config *mtr)struct mtr_trtcm_data {struct rte_meter_trtcm trtcm;uint64_t stats[RTE_COLORS ]; -} __rte_packed; +};#define MTR_TRTCM_DATA_METER_PROFILE_ID_GET (data) \ (((data)->stats[RTE_COLOR_GREEN] & 0xF8LLU) >> 3)
Signature · 1 line
2.43.0
Re: [PATCH 4/6] pipeline: remove packed attribute
Quoted 2 lines · Bruce Richardson
The
rte_trtcm_datastructure, and its substructures, only consist ofuint64_ttypes. This makes packing unnecessary to remove the packed
s/to/, so/
Quoted 23 lines
attribute from the structure.
Signed-off-by Bruce Richardson <[email protected]>--- lib/pipeline/rte_table_action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/pipeline/rte_table_action.c +1
-1@@ -109,7 +109,7 @@ mtr_cfg_check(struct rte_table_action_mtr_config *mtr)struct mtr_trtcm_data {struct rte_meter_trtcm trtcm;uint64_t stats[RTE_COLORS ]; -} __rte_packed; +};#define MTR_TRTCM_DATA_METER_PROFILE_ID_GET (data) \ (((data)->stats[RTE_COLOR_GREEN] & 0xF8LLU) >> 3)Signature · 1 line
2.43.0
Re: [PATCH 4/6] pipeline: remove packed attribute
In reply to Bruce RichardsonQuoted 5 lines · On Thu, 17 Oct 2024 15:22:11 +0100 Bruce Richardson…
The
rte_trtcm_datastructure, and its substructures, only consist ofuint64_ttypes. This makes packing unnecessary to remove the packed attribute from the structure.Signed-off-by Bruce Richardson <[email protected]>
PATCH 5/6 net: add smaller IPv4 cksum function for simple cases
In reply to Bruce RichardsonThere are multiple instances in the DPDK app folder where we set up an IP header and then compute the checksum field by direct addition of nine uint16_t values in the header (20 bytes less the cksum field). The existing rte_ip.h checksum function is more general than necessary here and requires that the checksum field is already set to zero - rather than having it skipped.
Fix the code duplication present in the apps by creating a new rte_ipv4_cksum_simple function - taking the code from the existing testpmd icmpecho.c file - and using that in app/test, testpmd and testeventdev.
Within that new function, we can adjust slightly how the typecasting to uint16_t is done, and thereby ensure that the app can all be compiled without -Wno-address-of-packed-member compiler flag.
--- app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- lib/net/rte_ip.h | 33 ++++++++++++++++ 6 files changed, 39 insertions(+), 142 deletions(-)
app/test-eventdev/test_pipeline_common.c +1 -24
@@ -74,8 +74,6 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr, struct rte_udp_hdr *udp_hdr, uint16_t pkt_data_len, uint8_t port, uint8_t flow) { - uint16_t *ptr16; -uint32_t ip_cksum; uint16_t pkt_len;/*
@@ -104,28 +102,7 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr,/* * Compute IP header checksum. */ - ptr16 = (unaligned_uint16_t *)ip_hdr; - ip_cksum =0 ; - ip_cksum += ptr16[0 ]; - ip_cksum += ptr16[1 ]; - ip_cksum += ptr16[2 ]; - ip_cksum += ptr16[3 ]; - ip_cksum += ptr16[4 ]; - ip_cksum += ptr16[6 ]; - ip_cksum += ptr16[7 ]; - ip_cksum += ptr16[8 ]; - ip_cksum += ptr16[9 ]; - -/* -* Reduce 32 bit checksum to 16 bits and complement it. -*/ - ip_cksum = ((ip_cksum &0xFFFF0000 ) >>16 ) + (ip_cksum &0x0000FFFF ); -if (ip_cksum >65535 ) - ip_cksum -=65535 ; - ip_cksum = (~ip_cksum) &0x0000FFFF ; -if (ip_cksum ==0 ) - ip_cksum =0xFFFF ; - ip_hdr->hdr_checksum = (uint16_t )ip_cksum; + ip_hdr->hdr_checksum =rte_ipv4_cksum_simple (ip_hdr); } static void
app/test-pmd/icmpecho.c +1 -22
@@ -241,27 +241,6 @@ ipv4_addr_dump(const char *what, uint32_t be_ipv4_addr)printf ("%s" , buf); } -static uint16_t -ipv4_hdr_cksum (struct rte_ipv4_hdr *ip_h) -{ -uint16_t *v16_h; -uint32_t ip_cksum; - -/* -* Compute the sum of successive 16-bit words of the IPv4 header, -* skipping the checksum field of the header. -*/ - v16_h = (unaligned_uint16_t *) ip_h; - ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + - v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ]; - -/* reduce 32 bit checksum to 16 bits and complement it */ - ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); - ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); - ip_cksum = (~ip_cksum) &0x0000FFFF ; -return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum; -} -#define is_multicast_ipv4_addr (ipv4_addr) \ (((rte_be_to_cpu_32((ipv4_addr)) >> 24) & 0x000000FF) == 0xE0)
@@ -458,7 +437,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) ip_src = (ip_src &0xFFFFFFFC ) |0x00000001 ; ip_h->src_addr =rte_cpu_to_be_32 (ip_src); ip_h->dst_addr = ip_addr; - ip_h->hdr_checksum =ipv4_hdr_cksum (ip_h); + ip_h->hdr_checksum =rte_ipv4_cksum_simple (ip_h); }else { ip_h->src_addr = ip_h->dst_addr; ip_h->dst_addr = ip_addr;
app/test-pmd/txonly.c +1 -21
@@ -106,8 +106,6 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr, struct rte_udp_hdr *udp_hdr, uint16_t pkt_data_len) { - uint16_t *ptr16; -uint32_t ip_cksum;uint16_t pkt_len;/*
@@ -136,25 +134,7 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr,/* * Compute IP header checksum. */ - ptr16 = (unaligned_uint16_t *) ip_hdr; - ip_cksum =0 ; - ip_cksum += ptr16[0 ]; ip_cksum += ptr16[1 ]; - ip_cksum += ptr16[2 ]; ip_cksum += ptr16[3 ]; - ip_cksum += ptr16[4 ]; - ip_cksum += ptr16[6 ]; ip_cksum += ptr16[7 ]; - ip_cksum += ptr16[8 ]; ip_cksum += ptr16[9 ]; - -/* -* Reduce 32 bit checksum to 16 bits and complement it. -*/ - ip_cksum = ((ip_cksum &0xFFFF0000 ) >>16 ) + - (ip_cksum &0x0000FFFF ); -if (ip_cksum >65535 ) - ip_cksum -=65535 ; - ip_cksum = (~ip_cksum) &0x0000FFFF ; -if (ip_cksum ==0 ) - ip_cksum =0xFFFF ; - ip_hdr->hdr_checksum = (uint16_t ) ip_cksum; + ip_hdr->hdr_checksum =rte_ipv4_cksum_simple (ip_hdr); } static inline void
app/test/packet_burst_generator.c +2 -47
73 lines not on this page · raw message
app/test/test_reassembly_perf.c +1 -28
@@ -136,9 +136,7 @@ ipv4_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id,for (i =0 ; i < nb_frags; i++) {struct rte_mbuf *frag = mbuf[i];uint16_t frag_offset =0 ; -uint32_t ip_cksum;uint16_t pkt_len; -uint16_t *ptr16; frag_offset = i * (frag_len /8 );
@@ -189,32 +187,7 @@ ipv4_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id, ip_hdr->src_addr =rte_cpu_to_be_32 (IP_SRC_ADDR (flow_id)); ip_hdr->dst_addr =rte_cpu_to_be_32 (IP_DST_ADDR (flow_id)); -/* -* Compute IP header checksum. -*/ - ptr16 = (unaligned_uint16_t *)ip_hdr; - ip_cksum =0 ; - ip_cksum += ptr16[0 ]; - ip_cksum += ptr16[1 ]; - ip_cksum += ptr16[2 ]; - ip_cksum += ptr16[3 ]; - ip_cksum += ptr16[4 ]; - ip_cksum += ptr16[6 ]; - ip_cksum += ptr16[7 ]; - ip_cksum += ptr16[8 ]; - ip_cksum += ptr16[9 ]; - -/* -* Reduce 32 bit checksum to 16 bits and complement it. -*/ - ip_cksum = ((ip_cksum &0xFFFF0000 ) >>16 ) + - (ip_cksum &0x0000FFFF ); -if (ip_cksum >65535 ) - ip_cksum -=65535 ; - ip_cksum = (~ip_cksum) &0x0000FFFF ; -if (ip_cksum ==0 ) - ip_cksum =0xFFFF ; - ip_hdr->hdr_checksum = (uint16_t )ip_cksum; + ip_hdr->hdr_checksum = (uint16_t )rte_ipv4_cksum_simple (ip_hdr); frag->data_len =sizeof (struct rte_ether_hdr ) + pkt_len; frag->pkt_len = frag->data_len;
lib/net/rte_ip.h +33 -0
@@ -309,6 +309,39 @@ rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)return (uint16_t )~cksum; } +/** +* Process the IPv4 checksum of an IPv4 header without any extensions. +* +* The checksum field does NOT have to be set by the caller, the field +* is skipped by the calculation. +* +* @param ipv4_hdr +* The pointer to the contiguous IPv4 header. +* @return +* The complemented checksum to set in the IP packet. +*/ +__rte_experimental +static inline uint16_t +rte_ipv4_cksum_simple (const struct rte_ipv4_hdr *ipv4_hdr) +{ +const uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header, +* skipping the checksum field of the header. +*/ + v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ]; + +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (~ip_cksum) &0x0000FFFF ; +return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum; +} +/** * Process the pseudo-header checksum of an IPv4 header. *
Signature · 1 line
2.43.0
Re: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 12 lines · On Thu, 17 Oct 2024 15:22:12 +0100 Bruce Richardson…
There are multiple instances in the DPDK app folder where we set up an IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general than necessary here and requires that the checksum field is already set to zero - rather than having it skipped.Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.
Quoted 5 lines
Within that new function, we can adjust slightly how the typecasting to
uint16_tis done, and thereby ensure that the app can all be compiled without -Wno-address-of-packed-member compiler flag.Signed-off-by Bruce Richardson <[email protected]>
DPDK should use the same optimization as FreeBSD and Linux and use 32 bit add's here.
Re: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 15 lines · Stephen Hemminger
Quoted 12 lines · On Thu, 17 Oct 2024 15:22:12 +0100 Bruce Richardson…
There are multiple instances in the DPDK app folder where we set up an IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general than necessary here and requires that the checksum field is already set to zero - rather than having it skipped.Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.
Quoted 9 lines
Quoted 5 lines
Within that new function, we can adjust slightly how the typecasting to
uint16_tis done, and thereby ensure that the app can all be compiled without -Wno-address-of-packed-member compiler flag.Signed-off-by Bruce Richardson <[email protected]>DPDK should use the same optimization as FreeBSD and Linux and use 32 bit add's here.
Yep. And if we get this patch applied, there is only one place to optimize, not a dozen! :-)
RE: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
In reply to Bruce RichardsonQuoted 21 lines
lib/net/rte_ip.h +21
-0+/** +* Process the IPv4 checksum of an IPv4 header without any extensions. +* +* The checksum field does NOT have to be set by the caller, the field +* is skipped by the calculation. +* +* @param ipv4_hdr +* The pointer to the contiguous IPv4 header. +* @return +* The complemented checksum to set in the IP packet. +*/ +__rte_experimental +static inline uint16_t +rte_ipv4_cksum_simple (const struct rte_ipv4_hdr *ipv4_hdr) +{ +const uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header, +* skipping the checksum field of the header.
lib/net/rte_ip.h rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr) · line 342
Quoted 10 lines
lib/net/rte_ip.h +10
-0+*/ + v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ]; + +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (~ip_cksum) &0x0000FFFF ; +return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum;
The zero exception does not apply to the checksum stored in the IP header, only to the checksum in the UDP header.
Quoted 1 line
+}
Besides that, for the series,
Re: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 25 lines · Morten Brørup
Quoted 25 lines
lib/net/rte_ip.h +25
-0+/** +* Process the IPv4 checksum of an IPv4 header without any extensions. +* +* The checksum field does NOT have to be set by the caller, the field +* is skipped by the calculation. +* +* @param ipv4_hdr +* The pointer to the contiguous IPv4 header. +* @return +* The complemented checksum to set in the IP packet. +*/ +__rte_experimental +static inline uint16_t +rte_ipv4_cksum_simple (const struct rte_ipv4_hdr *ipv4_hdr) +{ +const uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header, +* skipping the checksum field of the header. +*/ + v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ];
Quoted 9 lines
lib/net/rte_ip.h rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr) · line 342
Quoted 6 lines
lib/net/rte_ip.h +6
-0+ +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (~ip_cksum) &0x0000FFFF ; +return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum;The zero exception does not apply to the checksum stored in the IP header, only to the checksum in the UDP header.
I was wondering about that, because I didn't see it mentioned anywhere in the RFCs I consulted, but on the other hand all the implementations in the code seemed to have the check for zero.
Quoted 3 lines
Quoted 1 line
+}
Besides that, for the series,
So, just to confirm, the zero check at the end of the new ip_cksum_simple function should be removed and we always return the computed value directly?
Quoted 2 lines
Acked-by Morten Brørup <[email protected]>
Re: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 40 lines · On Thu, 17 Oct 2024 20:03:13 +0100 Bruce Richardson…
Quoted 25 lines · Morten Brørup
Quoted 25 lines
lib/net/rte_ip.h +25
-0+/** +* Process the IPv4 checksum of an IPv4 header without any extensions. +* +* The checksum field does NOT have to be set by the caller, the field +* is skipped by the calculation. +* +* @param ipv4_hdr +* The pointer to the contiguous IPv4 header. +* @return +* The complemented checksum to set in the IP packet. +*/ +__rte_experimental +static inline uint16_t +rte_ipv4_cksum_simple (const struct rte_ipv4_hdr *ipv4_hdr) +{ +const uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header, +* skipping the checksum field of the header. +*/ + v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ];Quoted 9 lines
lib/net/rte_ip.h rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr) · line 342
Quoted 6 lines
lib/net/rte_ip.h +6
-0+ +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (~ip_cksum) &0x0000FFFF ; +return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum;The zero exception does not apply to the checksum stored in the IP header, only to the checksum in the UDP header.
I was wondering about that, because I didn't see it mentioned anywhere in the RFCs I consulted, but on the other hand all the implementations in the code seemed to have the check for zero.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
+}
Besides that, for the series,
So, just to confirm, the zero check at the end of the new
ip_cksum_simplefunction should be removed and we always return the computed value directly?
Depends on usage.
- if the computed value is zero, then 0xffff should be placed in the IP header.
- often code use ip checksum code to see if incoming checksum is good. in that case zero means the checksum is valid.
RE: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 43 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 17 October 2024 21.35Quoted 3 lines · On Thu, 17 Oct 2024 20:03:13 +0100 Bruce Richardson…
Quoted 2 lines · Morten Brørup
Quoted 2 lines
+/**
+ * Process the IPv4 checksum of an IPv4 header without anyextensions.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+ *
+ * The checksum field does NOT have to be set by the caller, thefield
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ * is skipped by the calculation.
+ *
+ * @paramipv4_hdr
+ * The pointer to the contiguous IPv4 header.
+ * @return
+ * The complemented checksum to set in the IP packet.
+ */
+__rte_experimentalQuoted 8 lines
Quoted 8 lines
lib/net/rte_ip.h rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)
Quoted 8 lines
lib/net/rte_ip.h +8
-0+static inline uint16_t +rte_ipv4_cksum_simple (const struct rte_ipv4_hdr *ipv4_hdr) +{ +const uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/net/rte_ip.h +5
-0+* skipping the checksum field of the header. +*/ + v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ];Quoted 8 lines
Quoted 8 lines
lib/net/rte_ip.h rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr) · line 342
Quoted 6 lines
lib/net/rte_ip.h +6
-0+ +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (~ip_cksum) &0x0000FFFF ; +return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum;The zero exception does not apply to the checksum stored in the IP
Quoted 8 lines
header, only to the checksum in the UDP header.
Quoted 3 lines
Quoted 1 line
I was wondering about that, because I didn't see it mentioned
anywhere in
Quoted 1 line
the RFCs I consulted, but on the other hand all the implementations
in the
Quoted 1 line
code seemed to have the check for zero.
Copy-pasted including the bug from the originating code.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
+}
Besides that, for the series,
So, just to confirm, the zero check at the end of the new
ip_cksum_simpleQuoted 2 lines
function should be removed and we always return the computed value directly?
Agree.
Quoted 4 lines
Depends on usage.
- if the computed value is zero, then0xffffshould be placed in the IP header.
Not for the IP header, no.
For the UDP header, yes.
The Linux kernel doesn't do it to the IP header:
https://elixir.bootlin.com/linux/v6.12-rc3/source/net/ipv4/ip_output.c#L96
https://elixir.bootlin.com/linux/v6.12-rc3/source/lib/checksum.c#L108
Quoted 3 lines
- often code use ip checksum code to see if incoming checksum is
good.
in that case zero means the checksum is valid.
I don't remember all the details, but when checking the checksum, there's something about adding 0xffff or 0x0000 yields the same result. E.g.
1 + 0xffff = 0x10000, and then 0x1 + 0x0000 = 0x0001. 1 + 0x0000 = 0x0001.
So, when checking, it doesn't matter if the header checksum field is 0xffff or 0x0000.
There are other rules for the UDP header's checksum field, because 0x0000 there has the special meaning that the UDP checksum is not present/valid. (And AFAIR, not for IPv6, because the checksum is not optional for IPv6 UDP packets.)
The above calculation is also the reason why it is safe to substitute 0x0000 by 0xffff in the UDP header; it will still yield the same result when checking the checksum.
PATCH 6/6 build: limit scope of packed member warning disabling
In reply to Bruce RichardsonThe flag '-Wno-address-of-packed-member' is a global warning flag in DPDK. Rather than disabling this warning globally, it is better to just have it enabled for components that may need it. This patch limits the scope of it in the following ways:
* limit the use of the flag to the drivers subfolder only - all libs and apps should be buildable without the warning.
* exception is made for the vhost library and the ipsec-secgw example for now, as making them buildable with the warning enabled is more complicated. This exception can hopefully be removed in future.
Limiting the scope further within the drivers directory is also left for future consideration. However, since HW drivers often have to use packed structures to align with hardware-implemented data layouts, it may be more practical to keep the warning disabled in the longer term.
--- config/meson.build | 1 - drivers/meson.build | 9 ++++++--- examples/ipsec-secgw/meson.build | 6 ++++++ lib/vhost/meson.build | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-)
config/meson.build +0 -1
@@ -325,7 +325,6 @@ warning_flags = [ '-Wwrite-strings', # globally disabled warnings - '-Wno-address-of-packed-member', '-Wno-packed-not-aligned', '-Wno-missing-field-initializers', ]
drivers/meson.build +6 -3
@@ -59,9 +59,12 @@ default_cflags = machine_args default_cflags += ['-DALLOW_EXPERIMENTAL_API'] default_cflags += ['-DALLOW_INTERNAL_API'] -if cc.has_argument('-Wno-format-truncation') - default_cflags += '-Wno-format-truncation' -endif +warning_disable_cflags = ['-Wno-format-truncation', '-Wno-address-of-packed-member'] +foreach cflag:warning_disable_cflags + if cc.has_argument(cflag) + default_cflags += cflag + endif +endforeach dpdk_drivers_build_dir = meson.current_build_dir()
examples/ipsec-secgw/meson.build +6 -0
@@ -23,3 +23,9 @@ sources = files( 'sp4.c', 'sp6.c', ) +app_cflags = ['-Wno-address-of-packed-member'] +foreach flag:app_cflags + if cc.has_argument(flag) + cflags += flag + endif +endforeach
lib/vhost/meson.build +4 -1
@@ -16,7 +16,10 @@ elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0')) cflags += '-DVHOST_ICC_UNROLL_PRAGMA' endif dpdk_conf.set('RTE_LIBRTE_VHOST_POSTCOPY', cc.has_header('linux/userfaultfd.h')) -cflags += '-fno-strict-aliasing' +cflags += [ + '-fno-strict-aliasing', + '-Wno-address-of-packed-member', +] sources = files( 'fd_man.c',
Signature · 1 line
2.43.0
Re: [PATCH 6/6] build: limit scope of packed member warning disabling
Quoted 16 lines · On Thu, 17 Oct 2024 15:22:13 +0100 Bruce Richardson…
The flag '-Wno-address-of-packed-member' is a global warning flag in DPDK. Rather than disabling this warning globally, it is better to just have it enabled for components that may need it. This patch limits the scope of it in the following ways:
* limit the use of the flag to the drivers subfolder only - all libs and apps should be buildable without the warning.
* exception is made for the vhost library and the ipsec-secgw example for now, as making them buildable with the warning enabled is more complicated. This exception can hopefully be removed in future.Limiting the scope further within the drivers directory is also left for future consideration. However, since HW drivers often have to use packed structures to align with hardware-implemented data layouts, it may be more practical to keep the warning disabled in the longer term.
Quoted 7 lines
Signed-off-by Bruce Richardson <[email protected]>--- config/meson.build | 1 - drivers/meson.build | 9 ++++++--- examples/ipsec-secgw/meson.build | 6 ++++++ lib/vhost/meson.build | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-)
Good first step, followups can fix ipsec and vhost later.
Quoted 19 lines · On Thu, 17 Oct 2024 15:22:07 +0100 Bruce Richardson…
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disabling
Quoted 15 lines
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip.h | 33 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 60 insertions(+), 154 deletions(-)
Any chance to just fix all the places and have it enabled globally?
Quoted 39 lines · Stephen Hemminger
Quoted 19 lines · On Thu, 17 Oct 2024 15:22:07 +0100 Bruce Richardson…
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disablingQuoted 15 lines
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip.h | 33 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 60 insertions(+), 154 deletions(-)
Quoted 1 line
Any chance to just fix all the places and have it enabled globally?
Not any time soon (at least for me). There are a huge number of drivers with lots of errors if we turn back on the warning. We should look at all our common structures first to ensure none of them are unnecessarily packed.
/Bruce
Quoted 20 lines · Bruce Richardson
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disabling
Quoted 15 lines
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip.h | 33 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 60 insertions(+), 154 deletions(-)
Recheck-request: rebase=main,iol-unit-amd64-testing,iol-unit-arm64-testing
Signature · 1 line
David Marchand
Quoted 39 lines · David Marchand
Quoted 20 lines · Bruce Richardson
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disablingQuoted 15 lines
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip.h | 33 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 60 insertions(+), 154 deletions(-)
Quoted 1 line
Recheck-request: rebase=main,iol-unit-amd64-testing,iol-unit-arm64-testing
Unfortunately, there is a small conflict and the CI can't retest this series. Bruce, can you send a v2 please?
Signature · 1 line
David Marchand
Quoted 41 lines · David Marchand
Quoted 39 lines · David Marchand
Quoted 35 lines · Bruce Richardson
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disablingapp/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip.h | 33 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 60 insertions(+), 154 deletions(-)
Quoted 5 lines
Quoted 1 line
Recheck-request: rebase=main,iol-unit-amd64-testing,iol-unit-arm64-testing
Unfortunately, there is a small conflict and the CI can't retest this series. Bruce, can you send a v2 please?
Done. V2 is rebased and also includes the checksum calc adjustment reported by Morten.
/Bruce
v2 cover Reduce scope address-of-packed-member warning
In reply to Bruce RichardsonThe warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
v2:
* rebase on latest main (rte_ip.h -> rte_ip4.h)
* remove unnecessary 0-check in IP checksum calc
Bruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disabling
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip4.h | 32 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 59 insertions(+), 154 deletions(-)
--
2.43.0
PATCH v2 1/6 ip_frag: remove use of unaligned variable
If compiling with -Waddress-of-packed-member, we get a warning about the use of the unaligned uint64_t value which is used to copy 8 bytes from ip_hdr to the key. Replace this unaligned assignment with an equivalent 8-byte constant-sized memcpy, allowing the compiler to choose optimal instructions to do the assignment.
--- lib/ip_frag/rte_ipv4_reassembly.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/ip_frag/rte_ipv4_reassembly.c +1 -3
@@ -101,7 +101,6 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, {struct ip_frag_pkt *fp;struct ip_frag_key key; -const unaligned_uint64_t *psd;uint16_t flag_offset, ip_ofs, ip_flag;int32_t ip_len;int32_t trim;
@@ -110,9 +109,8 @@ rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, ip_ofs = (uint16_t )(flag_offset &RTE_IPV4_HDR_OFFSET_MASK ); ip_flag = (uint16_t )(flag_offset &RTE_IPV4_HDR_MF_FLAG ); - psd = (unaligned_uint64_t *)&ip_hdr->src_addr;/* use first 8 bytes only */ - key.src_dst[0 ] = psd[0 ]; +memcpy (&key.src_dst[0 ], &ip_hdr->src_addr,8 ); key.id = ip_hdr->packet_id; key.key_len =IPV4_KEYLEN ;
Signature · 1 line
2.43.0
PATCH v2 2/6 efd: remove unnecessary packed attributes
In reply to Bruce RichardsonThe structure "efd_online_group_entry" only consists of values which are typedefs of "uint16_t", so packing the structure has no effect. The "efd_online_chunk" structure has a mix of "uint8_t" and the "efd_online_group_entry" struct, i.e. uint16_t values, but since the first, uint8_t, member array is of even size, the packed attribute does not affect the structure layout.
Removing these packed attributes allows the library to compile cleanly without "-Wno-address-of-packed-member" compiler flag.
--- lib/efd/rte_efd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/efd/rte_efd.c +2 -2
@@ -212,7 +212,7 @@ struct efd_offline_chunk_rules {struct efd_online_group_entry {efd_hashfunc_t hash_idx[RTE_EFD_VALUE_NUM_BITS ];efd_lookuptbl_t lookup_table[RTE_EFD_VALUE_NUM_BITS ]; -} __rte_packed; +};/** * A single chunk record, containing EFD_TARGET_CHUNK_NUM_RULES rules.
@@ -228,7 +228,7 @@ struct efd_online_chunk {struct efd_online_group_entry groups[EFD_CHUNK_NUM_GROUPS ];/**< Array of all the groups in the chunk. */ -} __rte_packed; +};/** * EFD table structure
Signature · 1 line
2.43.0
PATCH v2 3/6 bus/ifpga: remove packed attribute
In reply to Bruce RichardsonThe struct rte_afu_device does not need to be packed, so remove the packed attribute from it.
--- drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/ifpga/bus_ifpga_driver.h +1 -1
@@ -77,7 +77,7 @@ struct rte_afu_device {struct rte_intr_handle *intr_handle;/**< Interrupt handle */ struct rte_afu_driver *driver;/**< Associated driver */ char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; -} __rte_packed; +};/** * @internal
Signature · 1 line
2.43.0
PATCH v2 4/6 pipeline: remove packed attribute
In reply to Bruce RichardsonThe rte_trtcm_data structure, and its substructures, only consist of uint64_t types. This makes packing unnecessary to remove the packed attribute from the structure.
--- lib/pipeline/rte_table_action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/pipeline/rte_table_action.c +1 -1
@@ -109,7 +109,7 @@ mtr_cfg_check(struct rte_table_action_mtr_config *mtr)struct mtr_trtcm_data {struct rte_meter_trtcm trtcm;uint64_t stats[RTE_COLORS ]; -} __rte_packed; +};#define MTR_TRTCM_DATA_METER_PROFILE_ID_GET (data) \ (((data)->stats[RTE_COLOR_GREEN] & 0xF8LLU) >> 3)
Signature · 1 line
2.43.0
PATCH v2 5/6 net: add smaller IPv4 cksum function for simple cases
In reply to Bruce RichardsonThere are multiple instances in the DPDK app folder where we set up an IP header and then compute the checksum field by direct addition of nine uint16_t values in the header (20 bytes less the cksum field). The existing rte_ip.h checksum function is more general than necessary here and requires that the checksum field is already set to zero - rather than having it skipped.
Fix the code duplication present in the apps by creating a new rte_ipv4_cksum_simple function - taking the code from the existing testpmd icmpecho.c file - and using that in app/test, testpmd and testeventdev.
Within that new function, we can adjust slightly how the typecasting to uint16_t is done, and thereby ensure that the app can all be compiled without -Wno-address-of-packed-member compiler flag.
--- app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- lib/net/rte_ip4.h | 32 ++++++++++++++++ 6 files changed, 38 insertions(+), 142 deletions(-)
app/test-eventdev/test_pipeline_common.c +1 -24
@@ -74,8 +74,6 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr, struct rte_udp_hdr *udp_hdr, uint16_t pkt_data_len, uint8_t port, uint8_t flow) { - uint16_t *ptr16; -uint32_t ip_cksum; uint16_t pkt_len;/*
@@ -104,28 +102,7 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr,/* * Compute IP header checksum. */ - ptr16 = (unaligned_uint16_t *)ip_hdr; - ip_cksum =0 ; - ip_cksum += ptr16[0 ]; - ip_cksum += ptr16[1 ]; - ip_cksum += ptr16[2 ]; - ip_cksum += ptr16[3 ]; - ip_cksum += ptr16[4 ]; - ip_cksum += ptr16[6 ]; - ip_cksum += ptr16[7 ]; - ip_cksum += ptr16[8 ]; - ip_cksum += ptr16[9 ]; - -/* -* Reduce 32 bit checksum to 16 bits and complement it. -*/ - ip_cksum = ((ip_cksum &0xFFFF0000 ) >>16 ) + (ip_cksum &0x0000FFFF ); -if (ip_cksum >65535 ) - ip_cksum -=65535 ; - ip_cksum = (~ip_cksum) &0x0000FFFF ; -if (ip_cksum ==0 ) - ip_cksum =0xFFFF ; - ip_hdr->hdr_checksum = (uint16_t )ip_cksum; + ip_hdr->hdr_checksum =rte_ipv4_cksum_simple (ip_hdr); } static void
app/test-pmd/icmpecho.c +1 -22
@@ -241,27 +241,6 @@ ipv4_addr_dump(const char *what, uint32_t be_ipv4_addr)printf ("%s" , buf); } -static uint16_t -ipv4_hdr_cksum (struct rte_ipv4_hdr *ip_h) -{ -uint16_t *v16_h; -uint32_t ip_cksum; - -/* -* Compute the sum of successive 16-bit words of the IPv4 header, -* skipping the checksum field of the header. -*/ - v16_h = (unaligned_uint16_t *) ip_h; - ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + - v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ]; - -/* reduce 32 bit checksum to 16 bits and complement it */ - ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); - ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); - ip_cksum = (~ip_cksum) &0x0000FFFF ; -return (ip_cksum ==0 ) ?0xFFFF : (uint16_t ) ip_cksum; -} -#define is_multicast_ipv4_addr (ipv4_addr) \ (((rte_be_to_cpu_32((ipv4_addr)) >> 24) & 0x000000FF) == 0xE0)
@@ -458,7 +437,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) ip_src = (ip_src &0xFFFFFFFC ) |0x00000001 ; ip_h->src_addr =rte_cpu_to_be_32 (ip_src); ip_h->dst_addr = ip_addr; - ip_h->hdr_checksum =ipv4_hdr_cksum (ip_h); + ip_h->hdr_checksum =rte_ipv4_cksum_simple (ip_h); }else { ip_h->src_addr = ip_h->dst_addr; ip_h->dst_addr = ip_addr;
app/test-pmd/txonly.c +1 -21
@@ -106,8 +106,6 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr, struct rte_udp_hdr *udp_hdr, uint16_t pkt_data_len) { - uint16_t *ptr16; -uint32_t ip_cksum;uint16_t pkt_len;/*
@@ -136,25 +134,7 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr,/* * Compute IP header checksum. */ - ptr16 = (unaligned_uint16_t *) ip_hdr; - ip_cksum =0 ; - ip_cksum += ptr16[0 ]; ip_cksum += ptr16[1 ]; - ip_cksum += ptr16[2 ]; ip_cksum += ptr16[3 ]; - ip_cksum += ptr16[4 ]; - ip_cksum += ptr16[6 ]; ip_cksum += ptr16[7 ]; - ip_cksum += ptr16[8 ]; ip_cksum += ptr16[9 ]; - -/* -* Reduce 32 bit checksum to 16 bits and complement it. -*/ - ip_cksum = ((ip_cksum &0xFFFF0000 ) >>16 ) + - (ip_cksum &0x0000FFFF ); -if (ip_cksum >65535 ) - ip_cksum -=65535 ; - ip_cksum = (~ip_cksum) &0x0000FFFF ; -if (ip_cksum ==0 ) - ip_cksum =0xFFFF ; - ip_hdr->hdr_checksum = (uint16_t ) ip_cksum; + ip_hdr->hdr_checksum =rte_ipv4_cksum_simple (ip_hdr); } static inline void
app/test/packet_burst_generator.c +2 -47
73 lines not on this page · raw message
app/test/test_reassembly_perf.c +1 -28
@@ -136,9 +136,7 @@ ipv4_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id,for (i =0 ; i < nb_frags; i++) {struct rte_mbuf *frag = mbuf[i];uint16_t frag_offset =0 ; -uint32_t ip_cksum;uint16_t pkt_len; -uint16_t *ptr16; frag_offset = i * (frag_len /8 );
@@ -189,32 +187,7 @@ ipv4_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id, ip_hdr->src_addr =rte_cpu_to_be_32 (IP_SRC_ADDR (flow_id)); ip_hdr->dst_addr =rte_cpu_to_be_32 (IP_DST_ADDR (flow_id)); -/* -* Compute IP header checksum. -*/ - ptr16 = (unaligned_uint16_t *)ip_hdr; - ip_cksum =0 ; - ip_cksum += ptr16[0 ]; - ip_cksum += ptr16[1 ]; - ip_cksum += ptr16[2 ]; - ip_cksum += ptr16[3 ]; - ip_cksum += ptr16[4 ]; - ip_cksum += ptr16[6 ]; - ip_cksum += ptr16[7 ]; - ip_cksum += ptr16[8 ]; - ip_cksum += ptr16[9 ]; - -/* -* Reduce 32 bit checksum to 16 bits and complement it. -*/ - ip_cksum = ((ip_cksum &0xFFFF0000 ) >>16 ) + - (ip_cksum &0x0000FFFF ); -if (ip_cksum >65535 ) - ip_cksum -=65535 ; - ip_cksum = (~ip_cksum) &0x0000FFFF ; -if (ip_cksum ==0 ) - ip_cksum =0xFFFF ; - ip_hdr->hdr_checksum = (uint16_t )ip_cksum; + ip_hdr->hdr_checksum = (uint16_t )rte_ipv4_cksum_simple (ip_hdr); frag->data_len =sizeof (struct rte_ether_hdr ) + pkt_len; frag->pkt_len = frag->data_len;
lib/net/rte_ip4.h +32 -0
@@ -163,6 +163,38 @@ rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)return (uint16_t )~cksum; } +/** +* Process the IPv4 checksum of an IPv4 header without any extensions. +* +* The checksum field does NOT have to be set by the caller, the field +* is skipped by the calculation. +* +* @param ipv4_hdr +* The pointer to the contiguous IPv4 header. +* @return +* The complemented checksum to set in the IP packet. +*/ +__rte_experimental +static inline uint16_t +rte_ipv4_cksum_simple (const struct rte_ipv4_hdr *ipv4_hdr) +{ +const uint16_t *v16_h; +uint32_t ip_cksum; + +/* +* Compute the sum of successive 16-bit words of the IPv4 header, +* skipping the checksum field of the header. +*/ + v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ]; + +/* reduce 32 bit checksum to 16 bits and complement it */ + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); + ip_cksum = (ip_cksum &0xffff ) + (ip_cksum >>16 ); +return (uint16_t )(~ip_cksum); +} +/** * Process the pseudo-header checksum of an IPv4 header. *
Signature · 1 line
2.43.0
Re: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
Hello Bruce,
Quoted 13 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we set up an IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general than necessary here and requires that the checksum field is already set to zero - rather than having it skipped.Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.
Quoted 7 lines
Within that new function, we can adjust slightly how the typecasting to
uint16_tis done, and thereby ensure that the app can all be compiled without -Wno-address-of-packed-member compiler flag.Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>
This added function triggers a build error with OVS because of -Wcast-align:
https://github.com/david-marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514
libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I ./include/sparse -I ./include -m64 -I /usr/local/include -I /usr/include/x86_64-linux-gnu " cgcc -target=x86_64 -target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h -mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/ofp-protocol.lo -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -o lib/ofp-protocol.o
In file included from /home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip.h:9, from /home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, from lib/netdev-dpdk.h:30,
from lib/dp-packet.h:30,
from lib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error:
cast increases required alignment of target type [-Werror=cast-align] 191 | v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; | ^
cc1: all warnings being treated as errors
make[1]: *** [Makefile:4736: lib/ofp-packet.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[1]: *** [Makefile:4736: lib/ofp-print.lo] Error 1
make[1]: Leaving directory '/home/runner/work/ovs/ovs'
make: *** [Makefile:3110: all] Error 2
Signature · 1 line
David Marchand
Re: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 49 lines · David Marchand
Hello Bruce,
Quoted 13 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we set up an IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general than necessary here and requires that the checksum field is already set to zero - rather than having it skipped.Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.Quoted 7 lines
Within that new function, we can adjust slightly how the typecasting to
uint16_tis done, and thereby ensure that the app can all be compiled without -Wno-address-of-packed-member compiler flag.Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>This added function triggers a build error with OVS because of -Wcast-align:
https://github.com/david-marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
./include/sparse-I ./include -m64 -I/usr/local/include-I/usr/include/x86_64-linux-gnu" cgcc -target=x86_64(quoted diff) +0
-14-target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h -mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/ofp-protocol.lo -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -o
lib/ofp-protocol.o
In file included from/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip.h:9, from/home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, fromlib/netdev-dpdk.h:30,
Quoted 8 lines
from
lib/dp-packet.h:30,
fromlib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error:
cast increases required alignment of target type [-Werror=cast-align] 191 |v16_h= (constunaligned_uint16_t*)&ipv4_hdr->version_ihl; | ^
Ok, I'll see if I can rework it to avoid issues.
/Bruce
RE: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 68 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 12.28Quoted 6 lines · David Marchand
Hello Bruce,
Quoted 2 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we set up
an
Quoted 3 lines
Quoted 3 lines
IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general thannecessary
Quoted 9 lines
Quoted 9 lines
here and requires that the checksum field is already set to zero - rather than having it skipped.
Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.Within that new function, we can adjust slightly how the
typecasting to
Quoted 1 line
Quoted 1 line
uint16_tis done, and thereby ensure that the app can all becompiled
Quoted 7 lines
Quoted 5 lines
without -Wno-address-of-packed-member compiler flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>This added function triggers a build error with OVS because of -
Wcast-align:
Quoted 1 line
marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514
Quoted 18 lines
libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
./include/sparse-I ./include -m64 -I/usr/local/include-I/usr/include/x86_64-linux-gnu" cgcc -target=x86_64(quoted diff) +0
-14-target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h -mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/ofp-protocol.lo -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -oQuoted 2 lines
lib/ofp-protocol.o
In file included from/home/runner/work/ovs/ovs/dpdk-
dir/include/rte_ip.h:9,Quoted 10 lines
from
/home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, fromlib/netdev-dpdk.h:30,
fromlib/dp-packet.h:30,
fromlib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error:
cast increases required alignment of target type [-Werror=cast-align] 191 |v16_h= (constunaligned_uint16_t*)&ipv4_hdr->version_ihl; | ^
Quoted 1 line
Ok, I'll see if I can rework it to avoid issues.
Would be easier if IP(v4/v6) headers were 2-byte aligned, like the Ethernet header. Just saying. ;-)
Re: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 68 lines · Morten Brørup
Quoted 68 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 12.28Quoted 6 lines · David Marchand
Hello Bruce,
Quoted 2 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we set up
an
Quoted 3 lines
Quoted 3 lines
IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general thannecessary
Quoted 9 lines
Quoted 9 lines
here and requires that the checksum field is already set to zero - rather than having it skipped.
Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.Within that new function, we can adjust slightly how the
typecasting to
Quoted 1 line
Quoted 1 line
uint16_tis done, and thereby ensure that the app can all becompiled
Quoted 7 lines
Quoted 5 lines
without -Wno-address-of-packed-member compiler flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>This added function triggers a build error with OVS because of -
Wcast-align:
Quoted 1 line
marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514
Quoted 18 lines
libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
./include/sparse-I ./include -m64 -I/usr/local/include-I/usr/include/x86_64-linux-gnu" cgcc -target=x86_64(quoted diff) +0
-14-target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h -mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/ofp-protocol.lo -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -oQuoted 2 lines
lib/ofp-protocol.o
In file included from/home/runner/work/ovs/ovs/dpdk-
dir/include/rte_ip.h:9,Quoted 10 lines
from
/home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, fromlib/netdev-dpdk.h:30,
fromlib/dp-packet.h:30,
fromlib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error:
cast increases required alignment of target type [-Werror=cast-align] 191 |v16_h= (constunaligned_uint16_t*)&ipv4_hdr->version_ihl; | ^
Quoted 5 lines
Quoted 1 line
Ok, I'll see if I can rework it to avoid issues.
Would be easier if IP(v4/v6) headers were 2-byte aligned, like the Ethernet header. Just saying. ;-)
I agree. Would adding that alignment constraint cause us any issues, does anyone know?
/Bruce
RE: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 85 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 13.28Quoted 10 lines · Morten Brørup
Quoted 10 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 12.28Quoted 6 lines · David Marchand
Hello Bruce,
Quoted 2 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we
set up
Quoted 2 lines
Quoted 2 lines
an
Quoted 1 line
Quoted 1 line
IP header and then compute the checksum field by direct
addition of
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
nine
uint16_tvalues in the header (20 bytes less the cksumfield).
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
The existing
rte_ip.hchecksum function is more general thannecessary
Quoted 1 line
Quoted 1 line
here and requires that the checksum field is already set to
zero -
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
rather than having it skipped.
Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from theexisting
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
testpmd
icmpecho.cfile - and using that in app/test, testpmdand
Quoted 17 lines
Quoted 17 lines
Quoted 3 lines
Quoted 3 lines
testeventdev.
Within that new function, we can adjust slightly how the
typecasting to
Quoted 1 line
Quoted 1 line
uint16_tis done, and thereby ensure that the app can all becompiled
Quoted 7 lines
Quoted 5 lines
without -Wno-address-of-packed-member compiler flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>This added function triggers a build error with OVS because of -
Wcast-align:
Quoted 1 line
marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
./include/sparse-I ./include -m64 -I/usr/local/include-I/usr/include/x86_64-linux-gnu" cgcc -target=x86_64(quoted diff) +0
-4-target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
(quoted diff) +0
-8-Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include
rte_config.hQuoted 1 line
Quoted 1 line
Quoted 1 line
-mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT
lib/ofp-protocol.lo
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
-MD -MP -MF
lib/.deps/ofp-protocol.Tpo-clib/ofp-protocol.c-olib/ofp-protocol.o
In file included from/home/runner/work/ovs/ovs/dpdk-
dir/include/rte_ip.h:9,Quoted 7 lines
from
/home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, fromlib/netdev-dpdk.h:30,
fromlib/dp-packet.h:30,
fromlib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17:error:
Quoted 1 line
Quoted 1 line
Quoted 1 line
cast increases required alignment of target type [-Werror=cast-
align]
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines
191 |
v16_h= (constunaligned_uint16_t*)&ipv4_hdr->version_ihl; | ^Ok, I'll see if I can rework it to avoid issues.
Quoted 7 lines
Quoted 1 line
Would be easier if IP(v4/v6) headers were 2-byte aligned, like the
Ethernet header.
Quoted 2 lines
Just saying. ;-)
I agree. Would adding that alignment constraint cause us any issues, does
anyone know?
No issues according to the CI:
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
The single failure is not related to the patch.
Re: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
In reply to Morten BrørupQuoted 69 lines · Morten Brørup
Quoted 69 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 12.28Quoted 6 lines · David Marchand
Hello Bruce,
Quoted 2 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we set up
an
Quoted 3 lines
Quoted 3 lines
IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general thannecessary
Quoted 9 lines
Quoted 9 lines
here and requires that the checksum field is already set to zero - rather than having it skipped.
Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.Within that new function, we can adjust slightly how the
typecasting to
Quoted 1 line
Quoted 1 line
uint16_tis done, and thereby ensure that the app can all becompiled
Quoted 7 lines
Quoted 5 lines
without -Wno-address-of-packed-member compiler flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>This added function triggers a build error with OVS because of -
Wcast-align:
Quoted 1 line
marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514
Quoted 18 lines
libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
./include/sparse-I ./include -m64 -I/usr/local/include-I/usr/include/x86_64-linux-gnu" cgcc -target=x86_64(quoted diff) +0
-14-target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h -mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/ofp-protocol.lo -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -oQuoted 2 lines
lib/ofp-protocol.o
In file included from/home/runner/work/ovs/ovs/dpdk-
dir/include/rte_ip.h:9,Quoted 10 lines
from
/home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, fromlib/netdev-dpdk.h:30,
fromlib/dp-packet.h:30,
fromlib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error:
cast increases required alignment of target type [-Werror=cast-align] 191 |v16_h= (constunaligned_uint16_t*)&ipv4_hdr->version_ihl; | ^
Quoted 4 lines
Quoted 1 line
Ok, I'll see if I can rework it to avoid issues.
Would be easier if IP(v4/v6) headers were 2-byte aligned, like the Ethernet header. Just saying. ;-)
Aligning rte_ipv4_hdr is not enough.
Pointing at a uint8_t triggers a warning (with clang at least).
I guess we need something like:
lib/net/rte_ip4.h +2 -2
@@ -39,7 +39,7 @@ extern "C" {/** * IPv4 Header */ -struct rte_ipv4_hdr { +struct __rte_aligned(2) rte_ipv4_hdr { __extension__ union { uint8_t version_ihl; /**< version and header length */
@@ -188,7 +188,7 @@ rte_ipv4_cksum_simple(const struct rte_ipv4_hdr *ipv4_hdr)* Compute the sum of successive 16-bit words of the IPv4 header, * skipping the checksum field of the header. */ - v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + v16_h = (const uint16_t *)ipv4_hdr; ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ];
Signature · 1 line
David Marchand
Re: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases
Quoted 95 lines · David Marchand
Quoted 69 lines · Morten Brørup
Quoted 69 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Wednesday, 30 October 2024 12.28Quoted 6 lines · David Marchand
Hello Bruce,
Quoted 2 lines · Bruce Richardson
There are multiple instances in the DPDK app folder where we set up
an
Quoted 3 lines
Quoted 3 lines
IP header and then compute the checksum field by direct addition of nine
uint16_tvalues in the header (20 bytes less the cksum field). The existingrte_ip.hchecksum function is more general thannecessary
Quoted 9 lines
Quoted 9 lines
here and requires that the checksum field is already set to zero - rather than having it skipped.
Fix the code duplication present in the apps by creating a new
rte_ipv4_cksum_simplefunction - taking the code from the existing testpmdicmpecho.cfile - and using that in app/test, testpmd and testeventdev.Within that new function, we can adjust slightly how the
typecasting to
Quoted 1 line
Quoted 1 line
uint16_tis done, and thereby ensure that the app can all becompiled
Quoted 7 lines
Quoted 5 lines
without -Wno-address-of-packed-member compiler flag.
Signed-off-by Bruce Richardson <[email protected]>Acked-by Morten Brørup <[email protected]>This added function triggers a build error with OVS because of -
Wcast-align:
Quoted 1 line
marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514
Quoted 18 lines
libtool: compile: env REAL_CC=gcc "CHECK=sparse -Wsparse-error -I
./include/sparse-I ./include -m64 -I/usr/local/include-I/usr/include/x86_64-linux-gnu" cgcc -target=x86_64(quoted diff) +0
-14-target=host_os_specs -D__MMX__=1 -D__MMX_WITH_SSE__=1 -D__SSE2_MATH__=1 -D__SSE_MATH__=1 -D__SSE__=1 -D__SSE2__=1 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare -Wshift-negative-value -Wduplicated-cond -Wshadow -Wmultistatement-macros -Wcast-align=strict -mssse3 -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h -mrtm -Werror -D_FILE_OFFSET_BITS=64 -g -O2 -MT lib/ofp-protocol.lo -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -oQuoted 2 lines
lib/ofp-protocol.o
In file included from/home/runner/work/ovs/ovs/dpdk-
dir/include/rte_ip.h:9,Quoted 10 lines
from
/home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, fromlib/netdev-dpdk.h:30,
fromlib/dp-packet.h:30,
fromlib/ofp-print.c:34:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function ‘rte_ipv4_cksum_simple’:/home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error:
cast increases required alignment of target type [-Werror=cast-align] 191 |v16_h= (constunaligned_uint16_t*)&ipv4_hdr->version_ihl; | ^Quoted 4 lines
Quoted 1 line
Ok, I'll see if I can rework it to avoid issues.
Would be easier if IP(v4/v6) headers were 2-byte aligned, like the Ethernet header. Just saying. ;-)
Aligning
rte_ipv4_hdris not enough.
Pointing at auint8_ttriggers a warning (with clang at least).I guess we need something like:
lib/net/rte_ip4.h +1
-1@@ -39,7 +39,7 @@ extern "C" {/** * IPv4 Header */ -struct rte_ipv4_hdr { +struct __rte_aligned(2) rte_ipv4_hdr { __extension__ union { uint8_t version_ihl; /**< version and header length */
lib/net/rte_ip4.h rte_ipv4_cksum_simple(const struct rte_ipv4_hdr *ipv4_hdr) · line 194
Quoted 8 lines
lib/net/rte_ip4.h +1
-1@@ -188,7 +188,7 @@ rte_ipv4_cksum_simple(const struct rte_ipv4_hdr *ipv4_hdr)* Compute the sum of successive 16-bit words of the IPv4 header, * skipping the checksum field of the header. */ - v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + v16_h = (const uint16_t *)ipv4_hdr; ip_cksum = v16_h[0 ] + v16_h[1 ] + v16_h[2 ] + v16_h[3 ] + v16_h[4 ] + v16_h[6 ] + v16_h[7 ] + v16_h[8 ] + v16_h[9 ];
Yes.
For the latter assignment part, the original code use ipv4_hdr, but that triggered other warnings in DPDK build. With properly aligning the structure, I think it should be fine. Therefore, what you have above looks the best solution to me.
/Bruce
PATCH v2 6/6 build: limit scope of packed member warning disabling
In reply to Bruce RichardsonThe flag '-Wno-address-of-packed-member' is a global warning flag in DPDK. Rather than disabling this warning globally, it is better to just have it enabled for components that may need it. This patch limits the scope of it in the following ways:
* limit the use of the flag to the drivers subfolder only - all libs and apps should be buildable without the warning.
* exception is made for the vhost library and the ipsec-secgw example for now, as making them buildable with the warning enabled is more complicated. This exception can hopefully be removed in future.
Limiting the scope further within the drivers directory is also left for future consideration. However, since HW drivers often have to use packed structures to align with hardware-implemented data layouts, it may be more practical to keep the warning disabled in the longer term.
--- config/meson.build | 1 - drivers/meson.build | 9 ++++++--- examples/ipsec-secgw/meson.build | 6 ++++++ lib/vhost/meson.build | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-)
config/meson.build +0 -1
@@ -325,7 +325,6 @@ warning_flags = [ '-Wwrite-strings', # globally disabled warnings - '-Wno-address-of-packed-member', '-Wno-packed-not-aligned', '-Wno-missing-field-initializers', ]
drivers/meson.build +6 -3
@@ -59,9 +59,12 @@ default_cflags = machine_args default_cflags += ['-DALLOW_EXPERIMENTAL_API'] default_cflags += ['-DALLOW_INTERNAL_API'] -if cc.has_argument('-Wno-format-truncation') - default_cflags += '-Wno-format-truncation' -endif +warning_disable_cflags = ['-Wno-format-truncation', '-Wno-address-of-packed-member'] +foreach cflag:warning_disable_cflags + if cc.has_argument(cflag) + default_cflags += cflag + endif +endforeach dpdk_drivers_build_dir = meson.current_build_dir()
examples/ipsec-secgw/meson.build +6 -0
@@ -23,3 +23,9 @@ sources = files( 'sp4.c', 'sp6.c', ) +app_cflags = ['-Wno-address-of-packed-member'] +foreach flag:app_cflags + if cc.has_argument(flag) + cflags += flag + endif +endforeach
lib/vhost/meson.build +4 -1
@@ -16,7 +16,10 @@ elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0')) cflags += '-DVHOST_ICC_UNROLL_PRAGMA' endif dpdk_conf.set('RTE_LIBRTE_VHOST_POSTCOPY', cc.has_header('linux/userfaultfd.h')) -cflags += '-fno-strict-aliasing' +cflags += [ + '-fno-strict-aliasing', + '-Wno-address-of-packed-member', +] sources = files( 'fd_man.c',
Signature · 1 line
2.43.0
LGTM
Quoted 42 lines · Bruce Richardson
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
v2:
* rebase on latest main (rte_ip.h->rte_ip4.h)
* remove unnecessary 0-check in IP checksum calcBruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disablingapp/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip4.h | 32 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 59 insertions(+), 154 deletions(-)--
2.43.0
Quoted 24 lines · Bruce Richardson
The warning for address-of-packed-member was being disabled globally in DPDK. While for drivers which need to access hardware-defined data-structures the use of packed may make sense, for normal libs and applications the use of packed data should be generally avoided.
This patchset initially applies some fixes for cases where we are unnecessarily causing the warning to trigger. Thereafter the 6th patch removes the global enabling of the warning and replaces it with more selective disabling for drivers and for a couple of other components which have not yet been fixed.
v2:
* rebase on latest main (rte_ip.h->rte_ip4.h)
* remove unnecessary 0-check in IP checksum calcBruce Richardson (6):
ip_frag: remove use of unaligned variable
efd: remove unnecessary packed attributes bus/ifpga: remove packed attribute
pipeline: remove packed attribute
net: add smaller IPv4 cksum function for simple cases
build: limit scope of packed member warning disabling
Quoted 15 lines
app/test-eventdev/test_pipeline_common.c | 25 +----------- app/test-pmd/icmpecho.c | 23 +---------- app/test-pmd/txonly.c | 22 +---------- app/test/packet_burst_generator.c | 49 +----------------------- app/test/test_reassembly_perf.c | 29 +------------- config/meson.build | 1 - drivers/bus/ifpga/bus_ifpga_driver.h | 2 +- drivers/meson.build | 9 +++-- examples/ipsec-secgw/meson.build | 6 +++ lib/efd/rte_efd.c | 4 +- lib/ip_frag/rte_ipv4_reassembly.c | 4 +- lib/net/rte_ip4.h | 32 ++++++++++++++++ lib/pipeline/rte_table_action.c | 2 +- lib/vhost/meson.build | 5 ++- 14 files changed, 59 insertions(+), 154 deletions(-)
Series applied, thanks Bruce.
Signature · 1 line
David Marchand