From: Ajit Khaparde <[email protected]>
Use buf_addr for mbufs from external pool instead of using iova
addresses. An inline helper bnxt_mbuf_buf_addr() computes the
buffer address as buf_addr + data_off and is used for both the
first segment and subsequent segments when the mbuf is marked
as RTE_MBUF_F_EXTERNAL.
Fixes: 42b883535804 ("net/bnxt: use new API to get IOVA address")
Cc: [email protected]
Signed-off-by: Ajit Khaparde <[email protected]>
Signed-off-by: Mohammad Shuab Siddique <[email protected]>
---
drivers/net/bnxt/bnxt_txr.c | 10 ++++++++--
drivers/net/bnxt/bnxt_txr.h | 6 ++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_txr.c b/drivers/net/bnxt/bnxt_txr.c
index fb5be224d9..51b886c1a6 100644
--- a/drivers/net/bnxt/bnxt_txr.c
+++ b/drivers/net/bnxt/bnxt_txr.c
@@ -325,7 +325,10 @@ static int bnxt_start_xmit(struct rte_mbuf *tx_pkt,
txbd->flags_type |= TX_BD_LONG_FLAGS_LHINT_GTE2K;
else
txbd->flags_type |= lhint_arr[tx_pkt->pkt_len >> 9];
- txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(tx_pkt));
+ if (tx_pkt->ol_flags & RTE_MBUF_F_EXTERNAL)
+ txbd->address = rte_cpu_to_le_64(bnxt_mbuf_buf_addr(tx_pkt));
+ else
+ txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(tx_pkt));
*last_txbd = txbd;
if (long_bd) {
@@ -482,7 +485,10 @@ static int bnxt_start_xmit(struct rte_mbuf *tx_pkt,
*tx_buf = m_seg;
txbd = &txr->tx_desc_ring[prod];
- txbd->address = rte_cpu_to_le_64(rte_mbuf_data_iova(m_seg));
+ if (m_seg->ol_flags & RTE_MBUF_F_EXTERNAL)
+ txbd->address =
rte_cpu_to_le_64(bnxt_mbuf_buf_addr(m_seg));
+ else
+ txbd->address =
rte_cpu_to_le_64(rte_mbuf_data_iova(m_seg));
txbd->flags_type = TX_BD_SHORT_TYPE_TX_BD_SHORT;
txbd->len = m_seg->data_len;
diff --git a/drivers/net/bnxt/bnxt_txr.h b/drivers/net/bnxt/bnxt_txr.h
index fd92a242c3..43c104c9eb 100644
--- a/drivers/net/bnxt/bnxt_txr.h
+++ b/drivers/net/bnxt/bnxt_txr.h
@@ -44,6 +44,12 @@ static inline uint32_t bnxt_tx_avail(struct bnxt_tx_queue
*txq)
bnxt_tx_bds_in_hw(txq)) - 1);
}
+static inline uint64_t
+bnxt_mbuf_buf_addr(const struct rte_mbuf *mb)
+{
+ return (uint64_t)mb->buf_addr + mb->data_off;
+}
+
void bnxt_free_tx_rings(struct bnxt *bp);
int bnxt_init_one_tx_ring(struct bnxt_tx_queue *txq);
int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int
socket_id);
--
2.47.3