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 1FEB1A0542 for ; Fri, 7 Feb 2020 16:13:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1845B1C133; Fri, 7 Feb 2020 16:13:58 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id EF3BC1C124 for ; Fri, 7 Feb 2020 16:13:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581088436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jijzuZ2spcOn/2USk0E+8NzcPIWaFzheCu0ecqWRbT0=; b=gDqjt23olctFYCpEEhFi7m3zZpgNyJzO/zwjnRScgko6KtZVz1l0LoUunH7JF3VpJ28hyf RyTZ8t5AWRSLHIzeLWrWlDsd51TawpyburejZ1m7JnUOv1v3U1LrkRuT1KU84E1jIDqAol HKNBmPVrAqiPtHlOobCfEjYN8RDb1wk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-ASorS9ZuPWGPAmNc3sD4Bg-1; Fri, 07 Feb 2020 10:13:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 899141800D42; Fri, 7 Feb 2020 15:13:46 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.36.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42E4710016DA; Fri, 7 Feb 2020 15:13:45 +0000 (UTC) From: Kevin Traynor To: Xiaoyun Li Cc: Qi Zhang , Ciara Loftus , dpdk stable Date: Fri, 7 Feb 2020 15:12:34 +0000 Message-Id: <20200207151248.29804-22-ktraynor@redhat.com> In-Reply-To: <20200207151248.29804-1-ktraynor@redhat.com> References: <20200207151248.29804-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: ASorS9ZuPWGPAmNc3sD4Bg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] patch 'net/i40e: fix Tx when TSO is enabled' has been queued to LTS release 18.11.7 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 rebasi= ng (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/950dfee75576b7955b= 288833764c8c33c5406ba4 Thanks. Kevin. --- >From 950dfee75576b7955b288833764c8c33c5406ba4 Mon Sep 17 00:00:00 2001 From: Xiaoyun Li 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 Acked-by: Qi Zhang Tested-by: Ciara Loftus --- 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_t= x_offload tx_offload) } =20 +/* HW requires that Tx buffer size ranges from 1B up to (16K-1)B. */ +#define I40E_MAX_DATA_PER_TXD \ +=09(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) +{ +=09struct rte_mbuf *txd =3D tx_pkt; +=09uint16_t count =3D 0; + +=09while (txd !=3D NULL) { +=09=09count +=3D DIV_ROUND_UP(txd->data_len, I40E_MAX_DATA_PER_TXD); +=09=09txd =3D txd->next; +=09} + +=09return 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) =09=09 * a packet equals to the number of the segments of that =09=09 * packet plus 1 context descriptor if needed. +=09=09 * Recalculate the needed tx descs when TSO enabled in case +=09=09 * the mbuf data size exceeds max data size that hw allows +=09=09 * per tx desc. =09=09 */ -=09=09nb_used =3D (uint16_t)(tx_pkt->nb_segs + nb_ctx); +=09=09if (ol_flags & PKT_TX_TCP_SEG) +=09=09=09nb_used =3D (uint16_t)(i40e_calc_pkt_desc(tx_pkt) + +=09=09=09=09=09 nb_ctx); +=09=09else +=09=09=09nb_used =3D (uint16_t)(tx_pkt->nb_segs + nb_ctx); =09=09tx_last =3D (uint16_t)(tx_id + nb_used - 1); =20 @@ -1174,4 +1199,22 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_= pkts, uint16_t nb_pkts) =09=09=09buf_dma_addr =3D rte_mbuf_data_iova(m_seg); =20 +=09=09=09while ((ol_flags & PKT_TX_TCP_SEG) && +=09=09=09=09unlikely(slen > I40E_MAX_DATA_PER_TXD)) { +=09=09=09=09txd->buffer_addr =3D +=09=09=09=09=09rte_cpu_to_le_64(buf_dma_addr); +=09=09=09=09txd->cmd_type_offset_bsz =3D +=09=09=09=09=09i40e_build_ctob(td_cmd, +=09=09=09=09=09td_offset, I40E_MAX_DATA_PER_TXD, +=09=09=09=09=09td_tag); + +=09=09=09=09buf_dma_addr +=3D I40E_MAX_DATA_PER_TXD; +=09=09=09=09slen -=3D I40E_MAX_DATA_PER_TXD; + +=09=09=09=09txe->last_id =3D tx_last; +=09=09=09=09tx_id =3D txe->next_id; +=09=09=09=09txe =3D txn; +=09=09=09=09txd =3D &txr[tx_id]; +=09=09=09=09txn =3D &sw_ring[txe->next_id]; +=09=09=09} =09=09=09PMD_TX_LOG(DEBUG, "mbuf: %p, TDD[%u]:\n" =09=09=09=09"buf_dma_addr: %#"PRIx64";\n" --=20 2.21.1 --- Diff of the applied patch vs upstream commit (please double-check if non-= empty: --- --- -=092020-02-07 15:08:18.671087249 +0000 +++ 0022-net-i40e-fix-Tx-when-TSO-is-enabled.patch=092020-02-07 15:08:17.53= 4062684 +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)