From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A9899A04B5;
	Tue, 27 Oct 2020 22:04:35 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 004C24F96;
	Tue, 27 Oct 2020 22:02:10 +0100 (CET)
Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com
 [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id 217352BF4
 for <dev@dpdk.org>; Tue, 27 Oct 2020 22:02:06 +0100 (CET)
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id C1BAE5C00E2;
 Tue, 27 Oct 2020 17:02:05 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute2.internal (MEProxy); Tue, 27 Oct 2020 17:02:05 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h=
 from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding; s=fm2; bh=d1fFCseucXepU
 XOo5x5zp3KAoUipq++IKlig9YGnDR0=; b=KgJ4mkdd1yai3UpXmFRhwUzZ3RXvy
 lk/S4RYF/v+lu1kFrnphOQZknQ+sW+QdwhwiwzBXuNV96pgCNmYDK1QEVD2suzYA
 ZrLq0tmU3tq1pz5sD9fA4m9N6jSbFgmxRdPhFAB1qTXi74KjJ29xHyfCtR+V7ilW
 174tpazC1UQRXHH3wX9iolPptuhDyYicQ4AFSvySgedfYRTay0IMZyMeEVUe1Pnj
 ZTflVQPpybV1eX6jE6xl7WCnSvp4yTDTJ7gmSxZ5vnzbKB4GytEmhXoJleJpStGK
 Xr44EPe9cKoBKFsG+i2WYq/jAY31/IfhRmgKclZWeOW+EjhgYe9TYzTNQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:date:from
 :in-reply-to:message-id:mime-version:references:subject:to
 :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
 fm1; bh=d1fFCseucXepUXOo5x5zp3KAoUipq++IKlig9YGnDR0=; b=NIE/kkvQ
 UsM6c0dhD/otgm7n5HZ9o19DXkRbZ2uZpRRlcnqjJCbjgHbNet5eYHDci1Mn7Rzi
 /c5B+ii+p923Kq7f3QrxknWuRglWV18XxMwsUaY/T9EZtVh0Xavz3SNwSPe6X2js
 psv54lCVm9MQpwRZlWlsWKGIEHoU4l6C0r4tlNyi6KOhchM+uoK+m+eSybHuuuHb
 njFBt2M57X/qSOTVVjVCYNf3qOxLIUVHfNv0gUzKXsMeDk3SSb3SUzdNpbhJchaL
 nQVz3EJnJodRtHT2LgcC82l9pjqdAdjJIZ5aqGpov/RzI/uiuhbjcbu42rrlt0rm
 o2gPqYG8XA/FXg==
X-ME-Sender: <xms:zYqYX8TA_zH0obtnF5FeL8LaoDnWP6xrrK9l9ebS4wChOk5moJgS5Q>
 <xme:zYqYX5xHuwX5ED7OG7kMJ06TVE00hqxJm51ulnYbBRlRqM2HjihfmexmCT67sBSpL
 xgDfhsUPePUK6T5xQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrkeelgddugeegucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr
 shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg
 ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg
 uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf
 hiiigvpeeinecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl
 ohhnrdhnvght
X-ME-Proxy: <xmx:zYqYX539Q_Zgq2ytSD3DE-zS1LxE-zxBuLxRmqaWiO9fITl_d4_crQ>
 <xmx:zYqYXwB2bSjYgdCgTHbY8gXA0YAIozUlTQgYULwS5RO7TV1UMca1Mg>
 <xmx:zYqYX1gC45KK4jjUBoROHYhjX_ismK6MbrrMlqiv5tlga868asnx8g>
 <xmx:zYqYXzYHa3ZW1LskIltY_CWLRLPVGcWNLkBkizH9Mz7Tx-3TrF9v4w>
Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id A4CFD3280059;
 Tue, 27 Oct 2020 17:02:04 -0400 (EDT)
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, david.marchand@redhat.com,
 bruce.richardson@intel.com, olivier.matz@6wind.com,
 andrew.rybchenko@oktetlabs.ru, akhil.goyal@nxp.com,
 Yong Wang <yongwang@vmware.com>
Date: Tue, 27 Oct 2020 22:01:09 +0100
Message-Id: <20201027210115.2529025-10-thomas@monjalon.net>
X-Mailer: git-send-email 2.28.0
In-Reply-To: <20201027210115.2529025-1-thomas@monjalon.net>
References: <20201026052105.1561859-1-thomas@monjalon.net>
 <20201027210115.2529025-1-thomas@monjalon.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v3 09/15] net/vmxnet3: switch MSS hint to dynamic
	mbuf field
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

The segment count, used for MSS guess,
was stored in the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 drivers/net/vmxnet3/vmxnet3_ethdev.c | 15 +++++++++++++++
 drivers/net/vmxnet3/vmxnet3_ethdev.h |  6 ++++++
 drivers/net/vmxnet3/vmxnet3_rxtx.c   |  9 +++++----
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 6920ab568c..23a2ebbefa 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -59,6 +59,8 @@
 	 DEV_RX_OFFLOAD_JUMBO_FRAME |   \
 	 DEV_RX_OFFLOAD_RSS_HASH)
 
+int vmxnet3_segs_dynfield_offset = -1;
+
 static int eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev);
 static int vmxnet3_dev_configure(struct rte_eth_dev *dev);
@@ -233,6 +235,11 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
 	struct vmxnet3_hw *hw = eth_dev->data->dev_private;
 	uint32_t mac_hi, mac_lo, ver;
 	struct rte_eth_link link;
+	static const struct rte_mbuf_dynfield vmxnet3_segs_dynfield_desc = {
+		.name = VMXNET3_SEGS_DYNFIELD_NAME,
+		.size = sizeof(vmxnet3_segs_dynfield_t),
+		.align = __alignof__(vmxnet3_segs_dynfield_t),
+	};
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -242,6 +249,14 @@ eth_vmxnet3_dev_init(struct rte_eth_dev *eth_dev)
 	eth_dev->tx_pkt_prepare = vmxnet3_prep_pkts;
 	pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
 
+	/* extra mbuf field is required to guess MSS */
+	vmxnet3_segs_dynfield_offset =
+		rte_mbuf_dynfield_register(&vmxnet3_segs_dynfield_desc);
+	if (vmxnet3_segs_dynfield_offset < 0) {
+		PMD_INIT_LOG(ERR, "Cannot register mbuf field.");
+		return -rte_errno;
+	}
+
 	/*
 	 * for secondary processes, we don't initialize any further as primary
 	 * has already done this work.
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.h b/drivers/net/vmxnet3/vmxnet3_ethdev.h
index dd685b02b7..e19718ce64 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.h
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.h
@@ -193,4 +193,10 @@ uint16_t vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 uint16_t vmxnet3_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 			uint16_t nb_pkts);
 
+#define VMXNET3_SEGS_DYNFIELD_NAME "rte_net_vmxnet3_dynfield_segs"
+typedef uint8_t vmxnet3_segs_dynfield_t;
+extern int vmxnet3_segs_dynfield_offset;
+#define VMXNET3_SEGS_DYNFIELD(mbuf) (*RTE_MBUF_DYNFIELD(rxm, \
+		vmxnet3_segs_dynfield_offset, vmxnet3_segs_dynfield_t *))
+
 #endif /* _VMXNET3_ETHDEV_H_ */
diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c
index e10f9ee870..2b0e2e6f19 100644
--- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
+++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
@@ -674,6 +674,7 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
 	struct rte_ipv6_hdr *ipv6_hdr;
 	struct rte_tcp_hdr *tcp_hdr;
 	char *ptr;
+	uint8_t segs;
 
 	RTE_ASSERT(rcd->tcp);
 
@@ -710,9 +711,9 @@ vmxnet3_guess_mss(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
 	tcp_hdr = (struct rte_tcp_hdr *)(ptr + hlen);
 	hlen += (tcp_hdr->data_off & 0xf0) >> 2;
 
-	if (rxm->udata64 > 1)
-		return (rte_pktmbuf_pkt_len(rxm) - hlen +
-				rxm->udata64 - 1) / rxm->udata64;
+	segs = VMXNET3_SEGS_DYNFIELD(rxm);
+	if (segs > 1)
+		return (rte_pktmbuf_pkt_len(rxm) - hlen + segs - 1) / segs;
 	else
 		return hw->mtu - hlen + sizeof(struct rte_ether_hdr);
 }
@@ -737,7 +738,7 @@ vmxnet3_rx_offload(struct vmxnet3_hw *hw, const Vmxnet3_RxCompDesc *rcd,
 					(const Vmxnet3_RxCompDescExt *)rcd;
 
 			rxm->tso_segsz = rcde->mss;
-			rxm->udata64 = rcde->segCnt;
+			VMXNET3_SEGS_DYNFIELD(rxm) = rcde->segCnt;
 			ol_flags |= PKT_RX_LRO;
 		}
 	} else { /* Offloads set in eop */
-- 
2.28.0