DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/10] Improve cast alignment for strict aligned machines
@ 2015-04-29 16:15 Cyril Chemparathy
  2015-04-29 16:15 ` [dpdk-dev] [PATCH 01/10] eal: add and use unaligned integer types Cyril Chemparathy
                   ` (10 more replies)
  0 siblings, 11 replies; 17+ messages in thread
From: Cyril Chemparathy @ 2015-04-29 16:15 UTC (permalink / raw)
  To: dev

This series contains a few improvements that allow the DPDK code base to build
properly on machines that enforce strict pointer cast alignment constraints.

When dealing with packet data which could be arbitrarily aligned, we get the
compiler to do the right thing by (a) making sure that header types are
packed, and (b) introducing and using unaligned_uint(16|32|64)_t types when
upcasting from byte pointers.

In a few other instances, we know apriori that the pointer cast cannot
possibly break alignment.  This applies to the changes in mempool, hash, mbuf,
and the ethdev stats code.  Here, we simply silence the compiler by casting
through (void *) using the RTE_PTR_(ADD|SUB) macros.

Finally, we introduce a new rte_pktmbuf_mtod_offset() helper to return a type
casted pointer to an offset within the packet data.  This replaces the
following commonly used pattern:
	(struct foo *)(rte_pktmbuf_mtod(m, char *) + offset)
with:
	rte_pktmbuf_mtod_offset(m, struct foo *, offset)
To ensure consistency, the above transform was applied throughout the code
base using the coccinelle semantic patching tool.

Cyril Chemparathy (10):
  eal: add and use unaligned integer types
  mempool: silence -Wcast-align on pointer arithmetic
  hash: silence -Wcast-align on pointer arithmetic
  mbuf: silence -Wcast-align on pointer arithmetic
  ethdev: silence -Wcast-align on pointer arithmetic
  app/test-pmd: pack simple_gre_hdr
  app/test: use struct ether_addr instead of a byte array cast
  librte_mbuf: Add rte_pktmbuf_mtod_offset()
  librte_mbuf: Add transform for rte_pktmbuf_mtod_offset()
  librte_mbuf: Apply mtod-offset.cocci transform

 app/test-pmd/csumonly.c                    |  2 +-
 app/test-pmd/flowgen.c                     |  4 +-
 app/test-pmd/ieee1588fwd.c                 |  4 +-
 app/test-pmd/rxonly.c                      | 21 +++++----
 app/test-pmd/txonly.c                      |  6 +--
 app/test/packet_burst_generator.c          |  9 ++--
 app/test/test_mbuf.c                       | 16 +++----
 app/test/test_pmd_perf.c                   | 10 ++--
 examples/dpdk_qat/crypto.c                 |  8 ++--
 examples/dpdk_qat/main.c                   |  5 +-
 examples/l3fwd-acl/main.c                  | 20 ++++----
 examples/l3fwd-power/main.c                |  8 ++--
 examples/l3fwd-vf/main.c                   |  4 +-
 examples/l3fwd/main.c                      | 71 ++++++++++++----------------
 examples/load_balancer/runtime.c           |  4 +-
 examples/vhost_xen/main.c                  |  4 +-
 lib/librte_eal/common/include/rte_common.h | 10 ++++
 lib/librte_ether/rte_ethdev.c              | 24 +++++-----
 lib/librte_ether/rte_ether.h               |  2 +-
 lib/librte_hash/rte_hash.c                 | 10 ++--
 lib/librte_ip_frag/rte_ipv4_reassembly.c   |  7 ++-
 lib/librte_ip_frag/rte_ipv6_reassembly.c   |  5 +-
 lib/librte_mbuf/rte_mbuf.h                 | 28 +++++++----
 lib/librte_mempool/rte_mempool.h           |  4 +-
 lib/librte_pmd_mlx4/mlx4.c                 |  9 ++--
 lib/librte_port/rte_port_ras.c             |  3 +-
 lib/librte_vhost/vhost_rxtx.c              |  4 +-
 scripts/cocci.sh                           | 64 +++++++++++++++++++++++++
 scripts/cocci/mtod-offset.cocci            | 76 ++++++++++++++++++++++++++++++
 29 files changed, 298 insertions(+), 144 deletions(-)
 create mode 100755 scripts/cocci.sh
 create mode 100644 scripts/cocci/mtod-offset.cocci

-- 
2.1.2

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-06-19 17:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29 16:15 [dpdk-dev] [PATCH 00/10] Improve cast alignment for strict aligned machines Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 01/10] eal: add and use unaligned integer types Cyril Chemparathy
2015-06-19 15:58   ` Olivier MATZ
2015-06-19 17:18     ` Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 02/10] mempool: silence -Wcast-align on pointer arithmetic Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 03/10] hash: " Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 04/10] mbuf: " Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 05/10] ethdev: " Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 06/10] app/test-pmd: pack simple_gre_hdr Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 07/10] app/test: use struct ether_addr instead of a byte array cast Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 08/10] librte_mbuf: Add rte_pktmbuf_mtod_offset() Cyril Chemparathy
2015-06-19 15:58   ` Olivier MATZ
2015-06-19 17:18     ` Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 09/10] librte_mbuf: Add transform for rte_pktmbuf_mtod_offset() Cyril Chemparathy
2015-04-29 16:15 ` [dpdk-dev] [PATCH 10/10] librte_mbuf: Apply mtod-offset.cocci transform Cyril Chemparathy
2015-05-04  9:50 ` [dpdk-dev] [PATCH 00/10] Improve cast alignment for strict aligned machines Olivier MATZ
2015-05-04 17:26   ` Cyril Chemparathy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).