From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 5CEFEA00E6 for ; Thu, 16 May 2019 17:55:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 649FF8E76; Thu, 16 May 2019 17:55:08 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 620C05F1C for ; Thu, 16 May 2019 17:55:05 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2019 08:55:05 -0700 X-ExtLoop1: 1 Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by orsmga005.jf.intel.com with ESMTP; 16 May 2019 08:55:03 -0700 From: Bruce Richardson To: Olivier Matz , Stephen Hemminger Cc: DPDK Dev List , Bruce Richardson Date: Thu, 16 May 2019 16:54:57 +0100 Message-Id: <20190516155457.4006-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] ether: mark ethernet addresses as being 2-byte aligned X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When including the rte_ether.h header in applications with warnings enabled, a warning was given because of the assumption of 2-byte alignment of ethernet addresses when processing them. .../include/rte_ether.h:149:2: warning: converting a packed ‘const struct ether_addr’ pointer (alignment 1) to a ‘unaligned_uint16_t’ {aka ‘const short unsigned int’} pointer (alignment 2) may result in an unaligned pointer value [-Waddress-of-packed-member] 149 | const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; | ^~~~~ Since ethernet addresses should always be aligned on a two-byte boundary, we can just inform the compiler of this assumption to remove the warnings and allow us to always access the addresses using 16-bit operations. Signed-off-by: Bruce Richardson --- Although this is an ABI break, the network structures are all being renamed in this release, and a deprecation notice was previously posted for it. --- lib/librte_net/rte_ether.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 3a87ff184..8090b7c01 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -55,7 +55,8 @@ extern "C" { * See http://standards.ieee.org/regauth/groupmac/tutorial.html */ struct ether_addr { - uint8_t addr_bytes[ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ + /** Addr bytes in tx order */ + uint8_t addr_bytes[ETHER_ADDR_LEN] __rte_aligned(2); } __attribute__((__packed__)); #define ETHER_LOCAL_ADMIN_ADDR 0x02 /**< Locally assigned Eth. address. */ -- 2.21.0