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 C2163A00E6 for ; Thu, 16 May 2019 20:04:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3BBF8D195; Thu, 16 May 2019 20:04:40 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 3608FD16D for ; Thu, 16 May 2019 20:04:38 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id f97so2001780plb.5 for ; Thu, 16 May 2019 11:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lUUPGQiPXmD2nflMT0cY25tNA/8yBe9D8LYITGgxvy8=; b=XX0wHgbxfYTp0O7kG/Ryu3CK8DJ6ESBtDqGqjLPcuA5DCJUY2lkoQP/0bhSzNxmmMX H54JPjWzuuvqAZoEyjnpeGjRdvS5rgxDWAZn1FNJ6g3PfUQoUL9NUYTVKrgttz0kMqKT jI3kzxHbSpJ3/jhIF9LwCryy6RfiFUdq+RRPgvP0hc4h8YtJGw/KBULhe8LbC9PIUCMv Px7HnO574FBmeIELqxlf33kSiuj9+DAaMbelUGSZoDuh6N/Ho97BPy11ZH7v29wpBc8P 18vFu2rV1q8PTXRlj0j3TPrVQOou9oc2Iiz4NXLKzYQJvfelZy6hmMWM2H7kqfu2BNkh ZcAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lUUPGQiPXmD2nflMT0cY25tNA/8yBe9D8LYITGgxvy8=; b=VkwxKrfXHxXq0BaUqBkTB790ccH1ZwBwT97FyWMQfH05mp8um+uVxoXbSq1waN8/ll 8ZKGlVlDzR0qvP50O2Nbhu5q+VSZsatZxGn11soCySMgcpvUmMHgYgoS0TAhZ5szQl0+ wUfSwBdvLsjK3ZQ4H/aXIn3QzAcjl9SzGexDXv/44B8EkHsg3BsZ2DdZDyl7oYLdbNWC d22KXueA8313T6w3RxRFHYb3iOXbCjlMf7f211qlX2wlIWUNvLcTsKHbo0yumM4P49qH 7ScUgELhWin8+fDsy2Nh6pQ8IyjbCCjkm4oTS80IVcD8XfCFCss3XZUmiENTMAvunwh6 ksRA== X-Gm-Message-State: APjAAAUeD9ZuY20bVck9iQDr2PLaNUmcEr4ex1BdYAfbeu73/Wmr+RHe 5RsWdQyuJ/urxR1q0PvIE74YphBqeIM= X-Google-Smtp-Source: APXvYqx5zrGn6G1yBoYOZd6cHGSVs/y3B0QLZDl+naNj233MSHDMq2QRxi53c9YvTRHOs+JJZ23TFw== X-Received: by 2002:a17:902:184:: with SMTP id b4mr25506127plb.2.1558029877030; Thu, 16 May 2019 11:04:37 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d67sm9376657pfa.35.2019.05.16.11.04.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 11:04:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger Date: Thu, 16 May 2019 11:04:21 -0700 Message-Id: <20190516180427.17270-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190516180427.17270-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/7] 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" From: Bruce Richardson 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 Signed-off-by: Stephen Hemminger --- lib/librte_net/rte_ether.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 3a87ff184900..ac8897681aca 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. */ @@ -146,7 +147,7 @@ static inline int is_multicast_ether_addr(const struct ether_addr *ea) */ static inline int is_broadcast_ether_addr(const struct ether_addr *ea) { - const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; + const uint16_t *ea_words = (const uint16_t *)ea; return (ea_words[0] == 0xFFFF && ea_words[1] == 0xFFFF && ea_words[2] == 0xFFFF); -- 2.20.1