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 34418A04C5; Sat, 5 Sep 2020 05:17:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 674651B9B7; Sat, 5 Sep 2020 05:17:36 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id B252E1B952 for ; Sat, 5 Sep 2020 05:17:34 +0200 (CEST) IronPort-SDR: U0MlrbeKKyztYVE9NKYgUpxXA2+z5WL1xokV8M9qULyqXIat8D6PqqzBCkTck3Wc54QtLVbaNX 6w97pjB9VQ4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9734"; a="155239840" X-IronPort-AV: E=Sophos;i="5.76,392,1592895600"; d="scan'208";a="155239840" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2020 20:17:33 -0700 IronPort-SDR: z2M+XOjioay1muGmFkZzYYaKvjODBj6fYCYiUX5TOfxNCbpW5TwEy1YxVOs6/2TNjGJPAijGFR xABDvTxitJmw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,392,1592895600"; d="scan'208";a="316080571" Received: from npg-dpdk-haiyue-3.sh.intel.com ([10.67.118.150]) by orsmga002.jf.intel.com with ESMTP; 04 Sep 2020 20:17:31 -0700 From: Haiyue Wang To: dev@dpdk.org Cc: stephen@networkplumber.org, ferruh.yigit@intel.com, Haiyue Wang , Olivier Matz Date: Sat, 5 Sep 2020 11:06:46 +0800 Message-Id: <20200905030646.374157-1-haiyue.wang@intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904054020.77648-1-haiyue.wang@intel.com> References: <20200904054020.77648-1-haiyue.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] net: adjust the header length parse size 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" Align to the rte_mbuf's design about Tx header length data size for the header length parse result. struct { uint64_t l2_len:7; /* 88: 0 8 */ uint64_t l3_len:9; /* 88: 7 8 */ uint64_t l4_len:8; /* 88:16 8 */ uint64_t tso_segsz:16; /* 88:24 8 */ uint64_t outer_l3_len:9; /* 88:40 8 */ uint64_t outer_l2_len:7; /* 88:49 8 */ }; Now the IPv6 can support bigger extension header. The below is the structure hole analysis result: Before: struct rte_net_hdr_lens { uint8_t l2_len; /* 0 1 */ uint8_t l3_len; /* 1 1 */ uint8_t l4_len; /* 2 1 */ uint8_t tunnel_len; /* 3 1 */ uint8_t inner_l2_len; /* 4 1 */ uint8_t inner_l3_len; /* 5 1 */ uint8_t inner_l4_len; /* 6 1 */ /* size: 7, cachelines: 1, members: 7 */ /* last cacheline: 7 bytes */ }; Now: struct rte_net_hdr_lens { uint64_t l2_len:7; /* 0: 0 8 */ uint64_t l3_len:9; /* 0: 7 8 */ uint64_t l4_len:8; /* 0:16 8 */ uint64_t tunnel_len:8; /* 0:24 8 */ uint64_t inner_l2_len:7; /* 0:32 8 */ uint64_t inner_l3_len:9; /* 0:39 8 */ uint64_t inner_l4_len:8; /* 0:48 8 */ /* size: 8, cachelines: 1, members: 7 */ /* bit_padding: 8 bits */ /* last cacheline: 8 bytes */ }; Signed-off-by: Haiyue Wang --- v2: use bit field to avoid creating a structure hole. --- lib/librte_net/rte_net.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h index 94b06d9ee..a14e3d814 100644 --- a/lib/librte_net/rte_net.h +++ b/lib/librte_net/rte_net.h @@ -18,14 +18,15 @@ extern "C" { * Structure containing header lengths associated to a packet, filled * by rte_net_get_ptype(). */ +__extension__ struct rte_net_hdr_lens { - uint8_t l2_len; - uint8_t l3_len; - uint8_t l4_len; - uint8_t tunnel_len; - uint8_t inner_l2_len; - uint8_t inner_l3_len; - uint8_t inner_l4_len; + uint64_t l2_len:7; + uint64_t l3_len:9; + uint64_t l4_len:8; + uint64_t tunnel_len:8; + uint64_t inner_l2_len:7; + uint64_t inner_l3_len:9; + uint64_t inner_l4_len:8; }; /** -- 2.28.0