patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Xiaoyun Li <xiaoyun.li@intel.com>
Cc: Qi Zhang <qi.z.zhang@intel.com>,
	Ciara Loftus <ciara.loftus@intel.com>,
	dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'net/i40e: fix Tx when TSO is enabled' has been queued to LTS release 18.11.7
Date: Fri,  7 Feb 2020 15:12:34 +0000	[thread overview]
Message-ID: <20200207151248.29804-22-ktraynor@redhat.com> (raw)
In-Reply-To: <20200207151248.29804-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to LTS release 18.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/13/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/950dfee75576b7955b288833764c8c33c5406ba4

Thanks.

Kevin.

---
From 950dfee75576b7955b288833764c8c33c5406ba4 Mon Sep 17 00:00:00 2001
From: Xiaoyun Li <xiaoyun.li@intel.com>
Date: Thu, 26 Dec 2019 14:45:44 +0800
Subject: [PATCH] net/i40e: fix Tx when TSO is enabled

[ upstream commit 29b2ba82c4c94df1975d0cb9c5c23feef99cf6a3 ]

Hardware limits that max buffer size per tx descriptor should be
(16K-1)B. So when TSO enabled, the mbuf data size may exceed the
limit and cause malicious behavior to the NIC. This patch fixes
this issue by using more tx descs for this kind of large buffer.

Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Tested-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/i40e/i40e_rxtx.c | 45 +++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 9de88a9ccb..1642cf4948 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1003,4 +1003,22 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload)
 }
 
+/* HW requires that Tx buffer size ranges from 1B up to (16K-1)B. */
+#define I40E_MAX_DATA_PER_TXD \
+	(I40E_TXD_QW1_TX_BUF_SZ_MASK >> I40E_TXD_QW1_TX_BUF_SZ_SHIFT)
+/* Calculate the number of TX descriptors needed for each pkt */
+static inline uint16_t
+i40e_calc_pkt_desc(struct rte_mbuf *tx_pkt)
+{
+	struct rte_mbuf *txd = tx_pkt;
+	uint16_t count = 0;
+
+	while (txd != NULL) {
+		count += DIV_ROUND_UP(txd->data_len, I40E_MAX_DATA_PER_TXD);
+		txd = txd->next;
+	}
+
+	return count;
+}
+
 uint16_t
 i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
@@ -1060,6 +1078,13 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 		 * a packet equals to the number of the segments of that
 		 * packet plus 1 context descriptor if needed.
+		 * Recalculate the needed tx descs when TSO enabled in case
+		 * the mbuf data size exceeds max data size that hw allows
+		 * per tx desc.
 		 */
-		nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
+		if (ol_flags & PKT_TX_TCP_SEG)
+			nb_used = (uint16_t)(i40e_calc_pkt_desc(tx_pkt) +
+					     nb_ctx);
+		else
+			nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
 		tx_last = (uint16_t)(tx_id + nb_used - 1);
 
@@ -1174,4 +1199,22 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 			buf_dma_addr = rte_mbuf_data_iova(m_seg);
 
+			while ((ol_flags & PKT_TX_TCP_SEG) &&
+				unlikely(slen > I40E_MAX_DATA_PER_TXD)) {
+				txd->buffer_addr =
+					rte_cpu_to_le_64(buf_dma_addr);
+				txd->cmd_type_offset_bsz =
+					i40e_build_ctob(td_cmd,
+					td_offset, I40E_MAX_DATA_PER_TXD,
+					td_tag);
+
+				buf_dma_addr += I40E_MAX_DATA_PER_TXD;
+				slen -= I40E_MAX_DATA_PER_TXD;
+
+				txe->last_id = tx_last;
+				tx_id = txe->next_id;
+				txe = txn;
+				txd = &txr[tx_id];
+				txn = &sw_ring[txe->next_id];
+			}
 			PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]:\n"
 				"buf_dma_addr: %#"PRIx64";\n"
-- 
2.21.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-02-07 15:08:18.671087249 +0000
+++ 0022-net-i40e-fix-Tx-when-TSO-is-enabled.patch	2020-02-07 15:08:17.534062684 +0000
@@ -1 +1 @@
-From 29b2ba82c4c94df1975d0cb9c5c23feef99cf6a3 Mon Sep 17 00:00:00 2001
+From 950dfee75576b7955b288833764c8c33c5406ba4 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 29b2ba82c4c94df1975d0cb9c5c23feef99cf6a3 ]
+
@@ -12 +13,0 @@
-Cc: stable@dpdk.org
@@ -22 +23 @@
-index 17dc8c78f7..bbdba39b3c 100644
+index 9de88a9ccb..1642cf4948 100644
@@ -25 +26 @@
-@@ -990,4 +990,22 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload)
+@@ -1003,4 +1003,22 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload)
@@ -48 +49 @@
-@@ -1047,6 +1065,13 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+@@ -1060,6 +1078,13 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
@@ -63 +64 @@
-@@ -1161,4 +1186,22 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+@@ -1174,4 +1199,22 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)


  parent reply	other threads:[~2020-02-07 15:13 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 15:12 [dpdk-stable] patch 'eal/linux: fix uninitialized data valgrind warning' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'eal/linux: fix build error on RHEL 7.6' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'doc: fix build with python 3.8' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'build: explicitly enable sse4 for meson' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'kni: fix meson warning about console keyword' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'doc: fix warning with meson' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'doc: reduce whitespace in meson build file' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'doc: reduce indentation " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'event/dsw: flush buffers immediately on zero-sized enqueue' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'event/dsw: avoid credit leak on oversized enqueue bursts' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'bus/fslmc: remove conflicting memory barrier macro' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'examples/ipsec-secgw: fix crash on unsupported algo' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'app/testpmd: fix device mcast list error handling' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/fm10k: fix descriptor VLAN field filling in Tx' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/iavf: fix Rx total stats' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/iavf: add TSO offload use basic path' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/ixgbe: fix link status' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/ixgbe: fix link up in FreeBSD' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/iavf/base: fix command buffer memory leak' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/iavf/base: fix adminq return' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/iavf: fix virtual channel " Kevin Traynor
2020-02-07 15:12 ` Kevin Traynor [this message]
2020-02-07 15:12 ` [dpdk-stable] patch 'net/bnxt: fix link during port toggle' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'app/testpmd: call cleanup on exit' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/vhost: check creation failure' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/virtio-user: check file descriptor before closing' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'vhost: fix socket initial value' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/i40e/base: fix buffer address' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/i40e/base: fix error message' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/i40e/base: fix Tx descriptors number' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/i40e/base: fix retrying logic' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'ethdev: fix callback unregister with wildcard argument list' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/netvsc: fix crash in secondary process' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'net/cxgbe: announce Tx multi-segments offload' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'service: avoid false sharing on core state' " Kevin Traynor
2020-02-07 15:12 ` [dpdk-stable] patch 'service: don't walk out of bounds when checking services' " Kevin Traynor

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=20200207151248.29804-22-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=ciara.loftus@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=stable@dpdk.org \
    --cc=xiaoyun.li@intel.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).