DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Shahaf Shuler <shahafs@mellanox.com>,
	Yongseok Koh <yskoh@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Cc: dev@dpdk.org, Dekel Peled <dekelp@mellanox.com>
Subject: [dpdk-dev] [PATCH 04/11] net/mlx5: support mbuf headroom for LRO packet
Date: Mon, 29 Jul 2019 11:53:22 +0000	[thread overview]
Message-ID: <1564401209-18752-5-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1564401209-18752-1-git-send-email-matan@mellanox.com>

Patch [1] zeroes the mbuf headroom when the port is configured with LRO
because when working with more than one stride per packet the HW cannot
guaranty an headroom in the start stride of each packet.

Change the solution to support mbuf headroom by adding an empty buffer
as the first packet segment, scatter mode must be enabled to support it.

[1] http://patches.dpdk.org/patch/56912/

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 doc/guides/nics/mlx5.rst     |  3 +--
 drivers/net/mlx5/mlx5_rxq.c  | 24 ++++++++++++++++--------
 drivers/net/mlx5/mlx5_rxtx.c | 22 +++++++++++++++++++++-
 3 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 92f1b97..cd550f4 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -165,8 +165,7 @@ Limitations
 
 - LRO:
 
-  - No mbuf headroom space is created for RX packets when LRO is configured.
-  - ``scatter_fcs`` is disabled when LRO is configured.
+  - scatter_fcs is disabled when LRO is configured.
 
 Statistics
 ----------
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index bd26ee2..d10c5c1 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1599,12 +1599,7 @@ struct mlx5_rxq_ctrl *
 	unsigned int mb_len = rte_pktmbuf_data_room_size(mp);
 	unsigned int mprq_stride_size;
 	struct mlx5_dev_config *config = &priv->config;
-	/*
-	 * LRO packet may consume all the stride memory, hence we cannot
-	 * guaranty head-room. A new striding RQ feature may be added in CX6 DX
-	 * to allow head-room and tail-room for the LRO packets.
-	 */
-	unsigned int strd_headroom_en = mlx5_lro_on(dev) ? 0 : 1;
+	unsigned int strd_headroom_en;
 	/*
 	 * Always allocate extra slots, even if eventually
 	 * the vector Rx will not be used.
@@ -1645,6 +1640,21 @@ struct mlx5_rxq_ctrl *
 	if (dev->data->dev_conf.intr_conf.rxq)
 		tmpl->irq = 1;
 	/*
+	 * LRO packet may consume all the stride memory, hence we cannot
+	 * guaranty head-room near the packet memory in the stride.
+	 * In this case scatter is, for sure, enabled and an empty mbuf may be
+	 * added in the start for the head-room.
+	 */
+	if (mlx5_lro_on(dev) && RTE_PKTMBUF_HEADROOM > 0 &&
+	    non_scatter_min_mbuf_size > mb_len) {
+		strd_headroom_en = 0;
+		mprq_stride_size = RTE_MIN(max_rx_pkt_len,
+					1u << config->mprq.max_stride_size_n);
+	} else {
+		strd_headroom_en = 1;
+		mprq_stride_size = non_scatter_min_mbuf_size;
+	}
+	/*
 	 * This Rx queue can be configured as a Multi-Packet RQ if all of the
 	 * following conditions are met:
 	 *  - MPRQ is enabled.
@@ -1653,8 +1663,6 @@ struct mlx5_rxq_ctrl *
 	 *    stride.
 	 *  Otherwise, enable Rx scatter if necessary.
 	 */
-	mprq_stride_size = max_rx_pkt_len + RTE_PKTMBUF_HEADROOM *
-				strd_headroom_en;
 	if (mprq_en &&
 	    desc > (1U << config->mprq.stride_num_n) &&
 	    mprq_stride_size <= (1U << config->mprq.max_stride_size_n)) {
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index a7ec73d..003eefd 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -1639,6 +1639,7 @@ enum mlx5_txcmp_code {
 				continue;
 			}
 			rte_memcpy(rte_pktmbuf_mtod(pkt, void *), addr, len);
+			DATA_LEN(pkt) = len;
 		} else {
 			rte_iova_t buf_iova;
 			struct rte_mbuf_ext_shared_info *shinfo;
@@ -1679,6 +1680,26 @@ enum mlx5_txcmp_code {
 				++rxq->stats.idropped;
 				continue;
 			}
+			DATA_LEN(pkt) = len;
+			/*
+			 * LRO packet may consume all the stride memory, in this
+			 * case packet head-room space is not guaranteed so must
+			 * to add an empty mbuf for the head-room.
+			 */
+			if (!rxq->strd_headroom_en) {
+				struct rte_mbuf *headroom_mbuf =
+						rte_pktmbuf_alloc(rxq->mp);
+
+				if (unlikely(headroom_mbuf == NULL)) {
+					rte_pktmbuf_free_seg(pkt);
+					++rxq->stats.rx_nombuf;
+					break;
+				}
+				PORT(pkt) = rxq->port_id;
+				NEXT(headroom_mbuf) = pkt;
+				pkt = headroom_mbuf;
+				NB_SEGS(pkt) = 2;
+			}
 		}
 		rxq_cq_to_mbuf(rxq, pkt, cqe, rss_hash_res);
 		if (lro_num_seg > 1) {
@@ -1687,7 +1708,6 @@ enum mlx5_txcmp_code {
 			pkt->tso_segsz = strd_sz;
 		}
 		PKT_LEN(pkt) = len;
-		DATA_LEN(pkt) = len;
 		PORT(pkt) = rxq->port_id;
 #ifdef MLX5_PMD_SOFT_COUNTERS
 		/* Increment bytes counter. */
-- 
1.8.3.1


  parent reply	other threads:[~2019-07-29 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 11:53 [dpdk-dev] [PATCH 00/11] net/mlx5: LRO fixes and enhancements Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 01/11] net/mlx5: fix Rx scatter mode validation Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 02/11] net/mlx5: limit LRO size to the maximum Rx packet Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 03/11] net/mlx5: remove redundant offload flag reset Matan Azrad
2019-07-29 11:53 ` Matan Azrad [this message]
2019-07-29 11:53 ` [dpdk-dev] [PATCH 05/11] net/mlx5: fix DevX scattered Rx queue size Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 06/11] net/mlx5: fix DevX Rx queue type Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 07/11] net/mlx5: allow LRO in regular Rx queue Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 08/11] net/mlx5: fix DevX Rx queue memory alignment Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 09/11] net/mlx5: handle LRO packets in regular Rx queue Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 10/11] net/mlx5: allow implicit LRO flow Matan Azrad
2019-07-29 11:53 ` [dpdk-dev] [PATCH 11/11] net/mlx5: allow LRO per Rx queue Matan Azrad
2019-07-29 12:32 ` [dpdk-dev] [PATCH 00/11] net/mlx5: LRO fixes and enhancements Slava Ovsiienko
2019-07-29 14:37 ` Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1564401209-18752-5-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dekelp@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    --cc=viacheslavo@mellanox.com \
    --cc=yskoh@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).