From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 92025A0471 for ; Fri, 21 Jun 2019 18:49:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8481A1D575; Fri, 21 Jun 2019 18:49:02 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id D94CA1D575 for ; Fri, 21 Jun 2019 18:49:00 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 493ED3DE0E; Fri, 21 Jun 2019 16:49:00 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-77.ams2.redhat.com [10.36.117.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3815160BE0; Fri, 21 Jun 2019 16:48:53 +0000 (UTC) From: Kevin Traynor To: Ajit Khaparde Cc: Somnath Kotur , Sriharsha Basavapatna , dpdk stable Date: Fri, 21 Jun 2019 17:45:55 +0100 Message-Id: <20190621164626.31219-11-ktraynor@redhat.com> In-Reply-To: <20190621164626.31219-1-ktraynor@redhat.com> References: <20190621164626.31219-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 21 Jun 2019 16:49:00 +0000 (UTC) Subject: [dpdk-stable] patch 'net/bnxt: check for error conditions in Tx path' has been queued to LTS release 18.11.3 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.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/26/19. 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/1bf3888a72382b1cdfa1cae2d3d7210b233bfb3e Thanks. Kevin Traynor --- >From 1bf3888a72382b1cdfa1cae2d3d7210b233bfb3e Mon Sep 17 00:00:00 2001 From: Ajit Khaparde Date: Wed, 15 May 2019 11:08:14 -0700 Subject: [PATCH] net/bnxt: check for error conditions in Tx path [ upstream commit 77942f509b09c934320e1226d82797b3c80eb968 ] The HW can have limits on the minimum packet size it can support, or the maximum number of segments it can support. Check for such possibilities. Also check if we are going to have a 0 length buffer. Fixes: 6eb3cc2294fd ("net/bnxt: add initial Tx code") Signed-off-by: Ajit Khaparde Reviewed-by: Somnath Kotur Signed-off-by: Sriharsha Basavapatna --- drivers/net/bnxt/bnxt_txr.c | 31 ++++++++++++++++++++++++++++++- drivers/net/bnxt/bnxt_txr.h | 2 ++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c index 6f55f3c53..da5742ccc 100644 --- a/drivers/net/bnxt/bnxt_txr.c +++ b/drivers/net/bnxt/bnxt_txr.c @@ -144,4 +144,31 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, tx_buf->nr_bds = long_bd + tx_pkt->nb_segs; + /* Check if number of Tx descriptors is above HW limit */ + if (unlikely(tx_buf->nr_bds > BNXT_MAX_TSO_SEGS)) { + PMD_DRV_LOG(ERR, + "Num descriptors %d exceeds HW limit\n", + tx_buf->nr_bds); + return -ENOSPC; + } + + /* If packet length is less than minimum packet size, pad it */ + if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) < BNXT_MIN_PKT_SIZE)) { + uint8_t pad = BNXT_MIN_PKT_SIZE - rte_pktmbuf_pkt_len(tx_pkt); + char *seg = rte_pktmbuf_append(tx_pkt, pad); + + if (!seg) { + PMD_DRV_LOG(ERR, + "Failed to pad mbuf by %d bytes\n", + pad); + return -ENOMEM; + } + + /* Note: data_len, pkt len are updated in rte_pktmbuf_append */ + memset(seg, 0, pad); + } + + /* Check non zero data_len */ + RTE_VERIFY(tx_pkt->data_len); + if (unlikely(bnxt_tx_avail(txr) < tx_buf->nr_bds)) return -ENOMEM; @@ -203,4 +230,5 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, txbd1->hdr_size = hdr_size >> 1; txbd1->mss = tx_pkt->tso_segsz; + RTE_VERIFY(txbd1->mss); } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_UDP_CKSUM) == @@ -285,6 +313,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, m_seg = tx_pkt->next; - /* i is set at the end of the if(long_bd) block */ while (m_seg) { + /* Check non zero data_len */ + RTE_VERIFY(m_seg->data_len); txr->tx_prod = RING_NEXT(txr->tx_ring_struct, txr->tx_prod); tx_buf = &txr->tx_buf_ring[txr->tx_prod]; diff --git a/drivers/net/bnxt/bnxt_txr.h b/drivers/net/bnxt/bnxt_txr.h index 7f3c7cdb0..f802d5080 100644 --- a/drivers/net/bnxt/bnxt_txr.h +++ b/drivers/net/bnxt/bnxt_txr.h @@ -11,4 +11,6 @@ #define MAX_TX_RINGS 16 #define BNXT_TX_PUSH_THRESH 92 +#define BNXT_MAX_TSO_SEGS 32 +#define BNXT_MIN_PKT_SIZE 52 #define B_TX_DB(db, prod) rte_write32((DB_KEY_TX | (prod)), db) -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-06-21 17:22:12.322438974 +0100 +++ 0011-net-bnxt-check-for-error-conditions-in-Tx-path.patch 2019-06-21 17:22:11.720519194 +0100 @@ -1 +1 @@ -From 77942f509b09c934320e1226d82797b3c80eb968 Mon Sep 17 00:00:00 2001 +From 1bf3888a72382b1cdfa1cae2d3d7210b233bfb3e Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 77942f509b09c934320e1226d82797b3c80eb968 ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index 3a0d73af2..9684fb177 100644 +index 6f55f3c53..da5742ccc 100644 @@ -57 +58 @@ -@@ -204,4 +231,5 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, +@@ -203,4 +230,5 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, @@ -63 +64 @@ -@@ -286,6 +314,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, +@@ -285,6 +313,7 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt,