mana_tx_burst() skipped, using continue, a packet that exceeded the
segment limit or whose SGL could not be populated. rte_eth_tx_burst()
callers treat the return value as a contiguous prefix of consumed
packets, so later packets were posted while the caller considered them
unsent and freed them, and their completions then freed them again.
Drop such a packet instead: count it in stats.errors, free it and
include it in the returned count. Return early only when the ring is
full, since a packet that fails validation would fail again on every
retry and stall applications that loop until all packets are sent.
sgl.gdma_sgl[] holds MAX_SGL_ENTRIES_FOR_TRANSMIT entries, but
max_send_sge comes from the device and was not limited, so a packet with
more segments could write past the array. Reject such packets and limit
the advertised nb_seg_max and nb_mtu_seg_max to the same value.
Fixes: 7f322844f427 ("net/mana: send packets")
Fixes: d878cb09501d ("net/mana: report device info")
Cc: [email protected]
Signed-off-by: Tathagat Priyadarshi <[email protected]>
---
drivers/net/mana/mana.c | 4 ++--
drivers/net/mana/tx.c | 18 ++++++++++++++----
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c
index 30b0ce90d6..5ddbbdc3d0 100644
--- a/drivers/net/mana/mana.c
+++ b/drivers/net/mana/mana.c
@@ -410,9 +410,9 @@ mana_dev_info_get(struct rte_eth_dev *dev,
dev_info->tx_desc_lim.nb_max = RTE_MIN(priv->max_tx_desc, UINT16_MAX);
dev_info->tx_desc_lim.nb_align = MIN_BUFFERS_PER_QUEUE;
dev_info->tx_desc_lim.nb_seg_max =
- RTE_MIN(priv->max_send_sge, UINT16_MAX);
+ RTE_MIN(priv->max_send_sge, MAX_SGL_ENTRIES_FOR_TRANSMIT);
dev_info->tx_desc_lim.nb_mtu_seg_max =
- RTE_MIN(priv->max_send_sge, UINT16_MAX);
+ RTE_MIN(priv->max_send_sge, MAX_SGL_ENTRIES_FOR_TRANSMIT);
/* Speed */
dev_info->speed_capa = RTE_ETH_LINK_SPEED_100G;
diff --git a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c
index 10f2212b5d..16e63e89c9 100644
--- a/drivers/net/mana/tx.c
+++ b/drivers/net/mana/tx.c
@@ -192,6 +192,7 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
int ret;
void *db_page;
uint16_t pkt_sent = 0;
+ uint16_t nb_done = 0;
uint32_t num_comp, i;
uint32_t expected = 0;
#ifdef RTE_ARCH_32
@@ -278,10 +279,11 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
break;
/* Drop the packet if it exceeds max segments */
- if (m_pkt->nb_segs > priv->max_send_sge) {
+ if (unlikely(m_pkt->nb_segs > priv->max_send_sge ||
+ m_pkt->nb_segs > MAX_SGL_ENTRIES_FOR_TRANSMIT)) {
DP_LOG(ERR, "send packet segments %d exceeding max",
m_pkt->nb_segs);
- continue;
+ goto drop;
}
/* Fill in the oob */
@@ -432,7 +434,7 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
/* Skip this packet if we can't populate all segments */
if (seg_idx != m_pkt->nb_segs)
- continue;
+ goto drop;
/* If we can at least queue post two WQEs and there are at
* least two packets to send, use TX CQE suppression for the
@@ -477,6 +479,7 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
txq->desc_ring_len++;
pkt_sent++;
+ nb_done++;
DP_LOG(DEBUG, "nb_pkts %u pkt[%d] sent",
nb_pkts, pkt_idx);
@@ -499,6 +502,13 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
pkt_idx, ret);
break;
}
+
+ continue;
+
+drop:
+ txq->stats.errors++;
+ rte_pktmbuf_free(m_pkt);
+ nb_done++;
}
/* Ring hardware door bell */
@@ -523,5 +533,5 @@ mana_tx_burst(void *dpdk_txq, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
rte_atomic_fetch_and_explicit(&txq->burst_state, ~(uint32_t)1,
rte_memory_order_release);
- return pkt_sent;
+ return nb_done;
}
--
2.43.0