From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by dpdk.org (Postfix) with ESMTP id ECB742716 for ; Tue, 23 Jun 2015 17:36:47 +0200 (CEST) Received: by wibdq8 with SMTP id dq8so20770213wib.1 for ; Tue, 23 Jun 2015 08:36:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=C5rzi41O4AipqISBfzgIlPub+3DuAMuLB6GW7PFSRRU=; b=hdCVs5XfEII/83AXjbm1Sd3URXdJrx+EHjjj5a/PZfP4vhSKhpEue4vJz6PeUMj9pK OY8gnDQ1NXJqhgg5GLJ1Z7NZo5V5vTpGI4Rm1r38OmQBNoUXn0m4YLTrQCZWHRxU8hn8 haCMPcl/nXg6Fv+3gk+4glY1AyPY/rnk7enZG4z7AF7n1ShnxJwzENCdhG8NmZNhG0ST HHLupeR4o9oVg7N3yADs2jwKr16arfbX59noGudnpNQ4MtMoI+QSHXzZOHxbP/TuIM8I MJgfgeYkd2nQCv1MpowmN4MlPXqbweO95p6rpYgww+Kr5C5SJg4YmrWpcUJeN10zggMj z9hw== X-Gm-Message-State: ALoCoQniGu/zsH0EHjB/tmthfm5TUCyoUahmyrD/bxclHA1n4exQjPf/eTdIc/EbO6VGiOF3oIPS X-Received: by 10.180.9.111 with SMTP id y15mr4620486wia.18.1435073807737; Tue, 23 Jun 2015 08:36:47 -0700 (PDT) Received: from [10.16.0.195] (6wind.net2.nerim.net. [213.41.151.210]) by mx.google.com with ESMTPSA id jy6sm31339563wjc.4.2015.06.23.08.36.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2015 08:36:47 -0700 (PDT) Message-ID: <55897D08.7090209@6wind.com> Date: Tue, 23 Jun 2015 17:36:40 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Cyril Chemparathy , dev@dpdk.org References: <1434998063-15739-1-git-send-email-cchemparathy@ezchip.com> In-Reply-To: <1434998063-15739-1-git-send-email-cchemparathy@ezchip.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 0/9] Improve cast alignment for strict aligned machines X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jun 2015 15:36:48 -0000 Hi Cyril, On 06/22/2015 08:34 PM, Cyril Chemparathy wrote: > 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. Series Acked-by: Olivier Matz > > Changes in this series: > v2: Fixes based on Olivier's comments. > v3: Extends unaligned fixes to new code introduced on master. > v4: Fixes based on Thomas' comments. > Extends unaligned fixes to new code introduced on master. > > Cyril Chemparathy (9): > mempool: silence -Wcast-align on pointer arithmetic > mbuf: silence -Wcast-align on pointer arithmetic > ethdev: silence -Wcast-align on pointer arithmetic > hash: silence -Wcast-align on pointer arithmetic > eal: add and use unaligned integer types > app/test-pmd: pack simple_gre_hdr > 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/icmpecho.c | 2 +- > 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_hash_functions.c | 2 +- > app/test/test_mbuf.c | 16 +++---- > config/common_bsdapp | 5 ++ > config/common_linuxapp | 5 ++ > drivers/net/bonding/rte_eth_bond_pmd.c | 12 +++-- > drivers/net/mlx4/mlx4.c | 9 ++-- > 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 | 32 +++++++++---- > lib/librte_mempool/rte_mempool.c | 2 +- > lib/librte_mempool/rte_mempool.h | 6 +-- > lib/librte_port/rte_port_ras.c | 6 +-- > lib/librte_vhost/vhost_rxtx.c | 6 +-- > scripts/cocci.sh | 64 +++++++++++++++++++++++++ > scripts/cocci/mtod-offset.cocci | 76 ++++++++++++++++++++++++++++++ > 34 files changed, 319 insertions(+), 152 deletions(-) > create mode 100755 scripts/cocci.sh > create mode 100644 scripts/cocci/mtod-offset.cocci >