- txbd = &txr->tx_desc_ring[txr->tx_prod];
- txbd->opaque = txr->tx_prod;
- txbd->flags_type = tx_buf->nr_bds << TX_BD_LONG_FLAGS_BD_CNT_SFT;
+ /* Check if number of Tx descriptors is above HW limit */
+ if (unlikely(nr_bds > BNXT_MAX_TSO_SEGS)) {
+ PMD_DRV_LOG(ERR,
+ "Num descriptors %d exceeds HW limit\n", nr_bds);
+ return -ENOSPC;
+ }
+
+ /* If packet length is less than minimum packet size, pad it */
+ if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) < BNXT_MIN_PKT_SIZE)) {
+ uint8_t pad = BNXT_MIN_PKT_SIZE - rte_pktmbuf_pkt_len(tx_pkt);
+ char *seg = rte_pktmbuf_append(tx_pkt, pad);
+
+ if (!seg) {
+ PMD_DRV_LOG(ERR,
+ "Failed to pad mbuf by %d bytes\n",
+ pad);
+ return -ENOMEM;
+ }
+
+ /* Note: data_len, pkt len are updated in rte_pktmbuf_append */
+ memset(seg, 0, pad);
+ }
+
+ /* Check non zero data_len */
+ RTE_VERIFY(tx_pkt->data_len);
+
+ prod = RING_IDX(ring, txr->tx_raw_prod);
+ tx_buf = &txr->tx_buf_ring[prod];
+ *tx_buf = tx_pkt;
+
+ txbd = &txr->tx_desc_ring[prod];
+ txbd->opaque = *coal_pkts;
+ txbd->flags_type = nr_bds << TX_BD_LONG_FLAGS_BD_CNT_SFT;
+ txbd->flags_type |= TX_BD_SHORT_FLAGS_COAL_NOW;
+ txbd->flags_type |= TX_BD_LONG_FLAGS_NO_CMPL;