From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53C75A0548; Wed, 15 Jun 2022 16:57:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4282142B7D; Wed, 15 Jun 2022 16:57:45 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id D30C340F19 for ; Wed, 15 Jun 2022 16:57:42 +0200 (CEST) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 1CB1FC0000F3; Wed, 15 Jun 2022 07:57:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 1CB1FC0000F3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1655305062; bh=4OiFAsa33I+6ClAbDVwltLEXkQxZ8QQtoD3neHCmSYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=codVjPZ0f6MdIhE1yREDy0URdha3HAbsAbZIGs0xn98bHsp9SfJcyH285WBoQ81zY QPGm9rLVwdv3L1roDfxvrRRtqCa4qWx3HJn7JYTImDMBTv++vMb4ke8njJgzFA6TDm nfI63RQwRCsgkWytkJNfM4UVM6IbNcMLQAl4AO88= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@xilinx.com, ajit.khaparde@broadcom.com Subject: [dpdk-dev] [PATCH 1/8] net/bnxt: remove assert for zero data len in Tx path Date: Wed, 15 Jun 2022 20:26:56 +0530 Message-Id: <20220615145703.6613-2-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20220615145703.6613-1-kalesh-anakkur.purayil@broadcom.com> References: <20220615145703.6613-1-kalesh-anakkur.purayil@broadcom.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Somnath Kotur Currently the PMD tries to detect a potential 0 byte DMA by using RTE_VERIFY. But since RTE_VERIFY internally calls rte_panic() it is fatal to the application and some applications want to avoid that. So return an error from the bnxt xmit handler if such a bad pkt is encountered by logging an error message, dumping the pkt header and dump the current stack as well Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_txr.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c index 7a7196a..67e0167 100644 --- a/drivers/net/bnxt/bnxt_txr.c +++ b/drivers/net/bnxt/bnxt_txr.c @@ -123,6 +123,26 @@ bnxt_xmit_need_long_bd(struct rte_mbuf *tx_pkt, struct bnxt_tx_queue *txq) return false; } +static bool +bnxt_zero_data_len_tso_segsz(struct rte_mbuf *tx_pkt, uint8_t data_len_chk) +{ + const char *type_str = "Data len"; + uint16_t len_to_check = tx_pkt->data_len; + + if (data_len_chk == 0) { + type_str = "TSO Seg size"; + len_to_check = tx_pkt->tso_segsz; + } + + if (len_to_check == 0) { + PMD_DRV_LOG(ERR, "Error! Tx pkt %s == 0\n", type_str); + rte_pktmbuf_dump(stdout, tx_pkt, 64); + rte_dump_stack(); + return true; + } + return false; +} + static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, struct bnxt_tx_queue *txq, uint16_t *coal_pkts, @@ -179,7 +199,8 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, } /* Check non zero data_len */ - RTE_VERIFY(tx_pkt->data_len); + if (unlikely(bnxt_zero_data_len_tso_segsz(tx_pkt, 1))) + return -EIO; prod = RING_IDX(ring, txr->tx_raw_prod); tx_buf = &txr->tx_buf_ring[prod]; @@ -256,7 +277,8 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, */ txbd1->kid_or_ts_low_hdr_size = hdr_size >> 1; txbd1->kid_or_ts_high_mss = tx_pkt->tso_segsz; - RTE_VERIFY(txbd1->kid_or_ts_high_mss); + if (unlikely(bnxt_zero_data_len_tso_segsz(tx_pkt, 0))) + return -EIO; } else if ((tx_pkt->ol_flags & PKT_TX_OIP_IIP_TCP_UDP_CKSUM) == PKT_TX_OIP_IIP_TCP_UDP_CKSUM) { @@ -330,7 +352,8 @@ static uint16_t bnxt_start_xmit(struct rte_mbuf *tx_pkt, m_seg = tx_pkt->next; while (m_seg) { /* Check non zero data_len */ - RTE_VERIFY(m_seg->data_len); + if (unlikely(bnxt_zero_data_len_tso_segsz(m_seg, 1))) + return -EIO; txr->tx_raw_prod = RING_NEXT(txr->tx_raw_prod); prod = RING_IDX(ring, txr->tx_raw_prod); -- 2.10.1