From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C322A0093; Tue, 19 May 2020 21:57:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3109F1D37E; Tue, 19 May 2020 21:57:57 +0200 (CEST) Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) by dpdk.org (Postfix) with ESMTP id 635101D183 for ; Tue, 19 May 2020 21:57:56 +0200 (CEST) Received: by mail-lf1-f66.google.com with SMTP id a4so553959lfh.12 for ; Tue, 19 May 2020 12:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J7vA7jplebJsvMBqhdtrQSEBFNAQUfYCAAbz5MqqH98=; b=Ztm5PaQ+gHgtj7Nyx2BiKSrEY1M47v58jvsL8vym4tf1ULkD6/XiB63OifWCQ47mVH uTwk5aEmxB5U6COhRhf+5/7ahZF+LolJHLQNtVyAlmtETy55IF1LetWn63rFqtK7WPeg 8DfN/mJaKH/D59kcdveATUtVQERyW8Zgh50fk+zKAVa0+m60bXKKaiUqMCXE/K3myl7x vQ16OZQc2+lBg7e3EKqU08NY6raPFE9URLP66T7fPhc3bHei56q1gqOHH0eXj1gC1m9w q8ex1+w4zycSqqXDMDPe/M4e13X2+U2t4Py2S0SstYanuYILWlvgzwVVfEENul91UU4d YHEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J7vA7jplebJsvMBqhdtrQSEBFNAQUfYCAAbz5MqqH98=; b=mxuoljYO4Mxe4ajAb90XvbvMGLXIf6IU7Z97CYV/cS1OeopCmjSt79nTIR/7GpmY+s D1FWgDlRleK/xMWG9jj7jSce1uWoGNsItS7oXFbCR5nbBK+SobywpTdrmqrPt2kZcbTf pU49Kx4iO8PcMPYpVnaZdF/UlroP7lJrMXPyy8lPdyUzqH9HaYLCx5PXvon1fuT4oHbb Fz1gopc0oyyQdtyRQv8MNgF8JtNiXabPlARWm+J7d49YslvbrP+3xATQ7qrwCd3ln3PW vBxfkGOymPHldcG2mTaCvFMAc3xuupyEyiXkpdl2A68RKtMFcJqSUgJMSyZh1YEhf5Mb MvhA== X-Gm-Message-State: AOAM531BNwGAgnXP30OaMUQX4xIzU2hsKE/meJR5lZZQ7Fk9BwQ4juhK M9aqyc+ig3jVxyk7IYvgBgs= X-Google-Smtp-Source: ABdhPJz1mQJnRIDrIre5HXMe6Faa0Y/tHTuw4p+HOYTbjd3bJwaukkK5X4A5FMm0I+/weUSxivRwgQ== X-Received: by 2002:ac2:4293:: with SMTP id m19mr341816lfh.204.1589918275768; Tue, 19 May 2020 12:57:55 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id y130sm210651lfc.22.2020.05.19.12.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 12:57:54 -0700 (PDT) Date: Tue, 19 May 2020 22:57:53 +0300 From: Dmitry Kozlyuk To: Thomas Monjalon Cc: talshn@mellanox.com, dev@dpdk.org, pallavi.kadam@intel.com, ranjit.menon@intel.com, navasile@linux.microsoft.com, olivier.matz@6wind.com, harini.ramakrishnan@microsoft.com, ocardona@microsoft.com, david.marchand@redhat.com, arybchenko@solarflare.com, bruce.richardson@intel.com, jerinj@marvell.com, drc@linux.vnet.ibm.com, ruifeng.wang@arm.com, konstantin.ananyev@intel.com Message-ID: <20200519225753.56c663ac@sovereign> In-Reply-To: <3106438.CAdn2TfLgq@thomas> References: <20200519184111.4504-1-talshn@mellanox.com> <3106438.CAdn2TfLgq@thomas> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] mbuf: align rte_mbuf for Windows 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" On Tue, 19 May 2020 20:49:50 +0200 Thomas Monjalon wrote: > +Cc more maintainers > > 19/05/2020 20:41, talshn@mellanox.com: > > From: Tal Shnaiderman > > > > Using uint32_t type bit-fields in Windows will pads the > > 'L2/L3/L4 and tunnel information' union with additional bits. > > > > This padding causes rte_mbuf size misalignment and the total size > > increases to 3 cache-lines. > > > > Changed packet_type bit-fields types from uint32_t to uint8_t > > to allow unified 2 cache-line structure size. > > > > Added the __extension__ attribute over the modified struct to avoid > > the warning: > > > > type of bit-field ... is a GCC extension [-pedantic] > > > > Signed-off-by: Tal Shnaiderman > > --- > > lib/librte_mbuf/rte_mbuf_core.h | 11 ++++++----- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/lib/librte_mbuf/rte_mbuf_core.h > > b/lib/librte_mbuf/rte_mbuf_core.h index b9a59c879..82441555e 100644 > > --- a/lib/librte_mbuf/rte_mbuf_core.h > > +++ b/lib/librte_mbuf/rte_mbuf_core.h > > @@ -521,11 +521,12 @@ struct rte_mbuf { > > RTE_STD_C11 > > union { > > uint32_t packet_type; /**< L2/L3/L4 and tunnel > > information. */ > > + __extension__ > > struct { > > - uint32_t l2_type:4; /**< (Outer) L2 type. > > */ > > - uint32_t l3_type:4; /**< (Outer) L3 type. > > */ > > - uint32_t l4_type:4; /**< (Outer) L4 type. > > */ > > - uint32_t tun_type:4; /**< Tunnel type. */ > > + uint8_t l2_type:4; /**< (Outer) L2 type. */ > > + uint8_t l3_type:4; /**< (Outer) L3 type. */ > > + uint8_t l4_type:4; /**< (Outer) L4 type. */ > > + uint8_t tun_type:4; /**< Tunnel type. */ > > RTE_STD_C11 > > union { > > uint8_t inner_esp_next_proto; > > @@ -541,7 +542,7 @@ struct rte_mbuf { > > /**< Inner L3 type. */ > > }; > > }; > > - uint32_t inner_l4_type:4; /**< Inner L4 > > type. */ > > + uint8_t inner_l4_type:4; /**< Inner L4 > > type. */ }; > > }; > > > Such a clean and simple solution to what seemed to require compiler workaround or fix! All offsets are equal on Windows and Linux for the following toolchains, x86_64: * cross-compilation with MinGW-w64 6.0.0 GCC 9.3.0 * Windows native MinGW-w64 6.0.0 GCC 8.1.0 and Clang 9.0.1 Tested-by: Dmitry Kozlyuk -- Dmitry Kozlyuk