Malformed packets (e.g., pkt_len == 0 or nb_segs == 0) should never be passed down to the PMD by the upper layers. The current handling of such abnormal packets in the Tx datapath not only introduces unnecessary branch overhead but can also lead to unexpected behaviors.
To adhere to DPDK's high-performance design principles, we should not penalize the datapath to cover up upper-layer errors. Therefore, this patch removes the runtime 'if' conditions for these anomalies. Instead, RTE_ASSERT is introduced to help catch such issues during debugging. Signed-off-by: Howard Wang <[email protected]> --- drivers/net/r8169/r8169_rxtx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/r8169/r8169_rxtx.c b/drivers/net/r8169/r8169_rxtx.c index a2e9139ec6..e0154b7741 100644 --- a/drivers/net/r8169/r8169_rxtx.c +++ b/drivers/net/r8169/r8169_rxtx.c @@ -1621,8 +1621,7 @@ rtl_xmit_pkt(struct rtl_hw *hw, struct rtl_tx_queue *txq, len = m_seg->data_len; - if (len == 0) - break; + RTE_ASSERT(len > 0); txd = &txq->hw_ring[tail]; @@ -1971,10 +1970,7 @@ rtl_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) if (txq->tx_free < tx_pkt->nb_segs) break; - /* Check mbuf is valid */ - if (tx_pkt->nb_segs == 0 || tx_pkt->pkt_len == 0 || - (tx_pkt->nb_segs > 1 && tx_pkt->next == NULL)) - break; + RTE_ASSERT(tx_pkt->pkt_len > 0); rtl_xmit_pkt(hw, txq, tx_pkt); } -- 2.43.0

