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 E7B9EA051C for ; Tue, 11 Feb 2020 12:27:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C0AD32B9C; Tue, 11 Feb 2020 12:27:21 +0100 (CET) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id 97A192B9C for ; Tue, 11 Feb 2020 12:27:20 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id b17so3084146wmb.0 for ; Tue, 11 Feb 2020 03:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cZ30Lfv3fv4VT8b7+smDbyCebVxgx2uL7T7Sz4YP+Pc=; b=d989xKMSl2y5CMccObhlRxJMCYvn2Lv3x37rq2isciMhuVemdVkgGU6AwRiF7cmitW qRLzSTOlhSN4H1IZd5iCobw/lTejr8k9JjIxxMFHFvF+v3S7B9f9qPcDzmh/4BHaeung BWy0Vd9ciXKdj/wvuw6XcVTzKVAT2YXfLORHHx8JD+3c+7lNS8Oi7BUH2+KG3JmZFBvI NGH8lgZlN5+buVzhwp0GxdBnstCRnsb0siRF0RSba8XlRzgQA5qjRwr8pH/T0mF+Wi6l 9G8Tyra2h46t059N7txijLQngeVzy49BGEnkzRg2znkJXrmwp/dYcZ6wE4VpBcbEYv7A ewow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cZ30Lfv3fv4VT8b7+smDbyCebVxgx2uL7T7Sz4YP+Pc=; b=VGSpdYKO7Hbc/eXfmOaDGfslfHM2nTtZ0KcU5OaSjtGgSH9YzLE9kj9EacsCcBVY8E OPoZM5SX6Dpwrse8G1W3WyDpBU4DOiUmolUniVzDsxJbf1ZO4/SNlMD0SGdVlQGD1ikx nJS4/YvZDZisFEfsUhN6XjQCvkkAEUWjaDa4VbviV5d3MYW+Cnb3068OhTIIT6v9RqnD qnbwHGTYK2MVYEOOvXE3Gwh0rSLvOGm9Pls7wyvAhxRsojhld6XggAmIyk4y2w+hFob8 qToGbvafFVYkItw2YDZKWICgwtWFsYiUSMR5mw6/WjHrfxFB2+F/M6KjlZScEWp+N9Fa /g6g== X-Gm-Message-State: APjAAAVCf2q7XXb0Y+3rF19gcUsaq78eJkr1t/ar3N/Tow7+ADBD9QIG K9SK3ZN6PKB39ifuXsOI5X0= X-Google-Smtp-Source: APXvYqxJUkrqZpohsxsOgOYw5Ap7cICOfC/kSNzbNluZisfDP9TpCYXOMWCf7oKquq0L0pdaxdw14Q== X-Received: by 2002:a1c:4d18:: with SMTP id o24mr5056129wmh.35.1581420440304; Tue, 11 Feb 2020 03:27:20 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id n13sm3380203wmd.21.2020.02.11.03.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 03:27:19 -0800 (PST) From: luca.boccassi@gmail.com To: Xiaoyun Li Cc: Qi Zhang , Ciara Loftus , dpdk stable Date: Tue, 11 Feb 2020 11:19:55 +0000 Message-Id: <20200211112216.3929-49-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200211112216.3929-1-luca.boccassi@gmail.com> References: <20200211112216.3929-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/i40e: fix Tx when TSO is enabled' has been queued to stable release 19.11.1 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 stable release 19.11.1 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. Thanks. Luca Boccassi --- >From 41901086c9dd45e8dcdd78a3535a7887330e15b4 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 17dc8c78f7..bbdba39b3c 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -989,6 +989,24 @@ i40e_set_tso_ctx(struct rte_mbuf *mbuf, union i40e_tx_offload tx_offload) return ctx_desc; } +/* 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) { @@ -1046,8 +1064,15 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) * The number of descriptors that must be allocated for * 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); /* Circular ring */ @@ -1160,6 +1185,24 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) slen = m_seg->data_len; 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" "td_cmd: %#x;\n" -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-02-11 11:17:40.787230920 +0000 +++ 0049-net-i40e-fix-Tx-when-TSO-is-enabled.patch 2020-02-11 11:17:38.404001421 +0000 @@ -1,15 +1,16 @@ -From 29b2ba82c4c94df1975d0cb9c5c23feef99cf6a3 Mon Sep 17 00:00:00 2001 +From 41901086c9dd45e8dcdd78a3535a7887330e15b4 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") -Cc: stable@dpdk.org Signed-off-by: Xiaoyun Li Acked-by: Qi Zhang