[01/15] net/cnxk: resolve sefgault caused during transmit completion

Message ID 20230303081013.589868-1-ndabilpuram@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [01/15] net/cnxk: resolve sefgault caused during transmit completion |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Nithin Dabilpuram March 3, 2023, 8:09 a.m. UTC
  From: Rakesh Kudurumalla <rkudurumalla@marvell.com>

while sending external buffers from application
if tx_compl_ena is not provided as devargs, cq for
transmit completion is not initialized but the same
is accessed in driver resulting in segfault.
This patch fixes the same by calling callback handler
before the actual packet is transmitted

Signed-off-by: Rakesh Kudurumalla <rkudurumalla@marvell.com>
---

Depends-on: series-27133 ("common/cnxk: add cnf10ka A1 platform")

 drivers/net/cnxk/cn10k_tx.h | 4 ++++
 drivers/net/cnxk/cn9k_tx.h  | 4 ++++
 2 files changed, 8 insertions(+)
  

Patch

diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h
index 1c1ce9642a..d0f7bc22a4 100644
--- a/drivers/net/cnxk/cn10k_tx.h
+++ b/drivers/net/cnxk/cn10k_tx.h
@@ -650,6 +650,10 @@  cn10k_nix_prefree_seg(struct rte_mbuf *m, struct cn10k_eth_txq *txq,
 	uint32_t sqe_id;
 
 	if (RTE_MBUF_HAS_EXTBUF(m)) {
+		if (unlikely(txq->tx_compl.ena == 0)) {
+			rte_pktmbuf_free_seg(m);
+			return 1;
+		}
 		if (send_hdr->w0.pnc) {
 			txq->tx_compl.ptr[send_hdr->w1.sqe_id]->next = m;
 		} else {
diff --git a/drivers/net/cnxk/cn9k_tx.h b/drivers/net/cnxk/cn9k_tx.h
index b4ef45d65c..52661a624c 100644
--- a/drivers/net/cnxk/cn9k_tx.h
+++ b/drivers/net/cnxk/cn9k_tx.h
@@ -88,6 +88,10 @@  cn9k_nix_prefree_seg(struct rte_mbuf *m, struct cn9k_eth_txq *txq,
 	uint32_t sqe_id;
 
 	if (RTE_MBUF_HAS_EXTBUF(m)) {
+		if (unlikely(txq->tx_compl.ena == 0)) {
+			rte_pktmbuf_free_seg(m);
+			return 1;
+		}
 		if (send_hdr->w0.pnc) {
 			txq->tx_compl.ptr[send_hdr->w1.sqe_id]->next = m;
 		} else {