From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 644D6C5B57D for ; Tue, 2 Jul 2019 22:13:40 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id EDD8D218FF for ; Tue, 2 Jul 2019 22:13:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="PGCX/9P4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDD8D218FF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 845091BE22; Wed, 3 Jul 2019 00:13:02 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 9706E1BE0E for ; Wed, 3 Jul 2019 00:12:58 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id t16so113288pfe.11 for ; Tue, 02 Jul 2019 15:12:58 -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=5jmpHlnhidg0ShQ7XItCpgaXpVK1xXtowoDpbYktXUk=; b=PGCX/9P4A3hho78zXtEEWnBoj1FAxMNsW/i3e4Owxt+66tpKd0HFDgh89DOqcUDxld G3JAeqXCbmNPnUliDtQZya+x/94vKZlCwVQK1olVkonUuE02hkehuLLH/TiTDpNTnWZn Bg4ush5+gDqN+JJDYe+ZjbD7NyZw5m9ydQlieMucZTGEYuORrIImIxxv84LiRZ4RRKqp HfXQ+rpTCgTvh+Y4ljKZKOeexqAEQgH+Fz/0OgjWwsk0enpD3CQlNXx09InbfpEQMe4U 7bySp6P1m+slounnjUpY4R/qPmNI6KW2v5VR1kwBiZve1TyvXveVCRqHQ+bhDM3ldz68 a5lw== 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=5jmpHlnhidg0ShQ7XItCpgaXpVK1xXtowoDpbYktXUk=; b=SAdz2fNGXAT+bwPmSo7XQIMggkuJJ8phQr/UbxPi6QZ8TgYpBf1F3UsSpz8S667Icm 8Fl/P/71YWn8k4LCYczpLbffGaPJlNuN4GCDXNfOvkJf2ZwBP+EXdiGaoiqsH8fp9piJ AJgCqOZnC9mMieA9u27VBpPTTf2RDc+HsIuHJ/S8JvfLUFhVx2WW7Z8GORJlfDagqh8w 0t/ZdUgQk4pTWJrmV6axdxmU73E4tdL+cw7nw1URWeKSGPhGadHF2gt2MitZj1ZURyrV tvfIdZpCvbAFREejRj6makLoYh1nXZ2hgNW3Qw4oT/gDhHWTIrn8XgQHbih9l0FtmFQ9 KYVA== X-Gm-Message-State: APjAAAWzjCKyCcR3jXc9Iyt+JGu3AO1/0FkoPCg/5da5bfm7pdCsRYYM yJ9PoCfLnDZPwUnp41vJiG8cbd+0q+U= X-Google-Smtp-Source: APXvYqxeHh39tCrxDmfnPBawAcKrZy/jEjbUXXkjCt8zNqJ1rau99EK4ACDvCJfF/+3UWT0ynFAJ3Q== X-Received: by 2002:a65:4844:: with SMTP id i4mr16113056pgs.113.1562105577229; Tue, 02 Jul 2019 15:12:57 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q4sm25035pjq.27.2019.07.02.15.12.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 15:12:56 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger , Andrew Rybchenko Date: Tue, 2 Jul 2019 15:12:40 -0700 Message-Id: <20190702221247.28391-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702221247.28391-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702221247.28391-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 05/12] net/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 Reviewed-by: Andrew Rybchenko --- lib/librte_net/rte_ether.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index feb35a33c94b..d7b76ddf63eb 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -58,7 +58,8 @@ extern "C" { * See http://standards.ieee.org/regauth/groupmac/tutorial.html */ struct rte_ether_addr { - uint8_t addr_bytes[RTE_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ + uint8_t addr_bytes[RTE_ETHER_ADDR_LEN] __rte_aligned(2); + /**< Addr bytes in tx order */ } __attribute__((__packed__)); #define RTE_ETHER_LOCAL_ADMIN_ADDR 0x02 /**< Locally assigned Eth. address. */ @@ -81,8 +82,8 @@ struct rte_ether_addr { static inline int rte_is_same_ether_addr(const struct rte_ether_addr *ea1, const struct rte_ether_addr *ea2) { - const unaligned_uint16_t *w1 = (const uint16_t *)ea1; - const unaligned_uint16_t *w2 = (const uint16_t *)ea2; + const uint16_t *w1 = (const uint16_t *)ea1; + const uint16_t *w2 = (const uint16_t *)ea2; return ((w1[0] ^ w2[0]) | (w1[1] ^ w2[1]) | (w1[2] ^ w2[2])) == 0; } @@ -99,7 +100,7 @@ static inline int rte_is_same_ether_addr(const struct rte_ether_addr *ea1, */ static inline int rte_is_zero_ether_addr(const struct rte_ether_addr *ea) { - const unaligned_uint16_t *w = (const uint16_t *)ea; + const uint16_t *w = (const uint16_t *)ea; return (w[0] | w[1] | w[2]) == 0; } @@ -146,7 +147,7 @@ static inline int rte_is_multicast_ether_addr(const struct rte_ether_addr *ea) */ static inline int rte_is_broadcast_ether_addr(const struct rte_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