[PATCH v3 2/3] net/i40e: enable direct rearm with separate API

Konstantin Ananyev konstantin.ananyev at huawei.com
Mon Feb 27 20:35:39 CET 2023



> > > +int
> > > +i40e_tx_fill_sw_ring(void *tx_queue,
> > > +		struct rte_eth_rxq_rearm_data *rxq_rearm_data) {
> > > +	struct i40e_tx_queue *txq = tx_queue;
> > > +	struct i40e_tx_entry *txep;
> > > +	void **rxep;
> > > +	struct rte_mbuf *m;
> > > +	int i, n;
> > > +	int nb_rearm = 0;
> > > +
> > > +	if (*rxq_rearm_data->rearm_nb < txq->tx_rs_thresh ||
> > > +			txq->nb_tx_free > txq->tx_free_thresh)
> > > +		return 0;
> > > +
> > > +	/* check DD bits on threshold descriptor */
> > > +	if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
> > > +			rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=
> > > +
> > 	rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE))
> > > +		return 0;
> > > +
> > > +	n = txq->tx_rs_thresh;
> > > +
> > > +	/* first buffer to free from S/W ring is at index
> > > +	 * tx_next_dd - (tx_rs_thresh-1)
> > > +	 */
> > > +	txep = &txq->sw_ring[txq->tx_next_dd - (n - 1)];
> > > +	rxep = rxq_rearm_data->rx_sw_ring;
> > > +	rxep += *rxq_rearm_data->rearm_start;
> > > +
> > > +	if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
> > > +		/* directly put mbufs from Tx to Rx */
> > > +		for (i = 0; i < n; i++, rxep++, txep++)
> > > +			*rxep = txep[0].mbuf;
> > > +	} else {
> > > +		for (i = 0; i < n; i++, rxep++) {
> > > +			m = rte_pktmbuf_prefree_seg(txep[i].mbuf);

One thing I forgot to ask:
What would happen if this mbuf belongs to different mempool
(not one that we specify at rx_queue_setup())?
Do we need to check it here?
Or would it be upper layer constraint? 
Or...?

> > > +			if (m != NULL) {
> > > +				*rxep = m;
> > > +				nb_rearm++;
> > > +			}
> > > +		}
> > > +		n = nb_rearm;
> > > +	}
> > > +
> > > +	/* update counters for Tx */
> > > +	txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
> > > +	txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
> > > +	if (txq->tx_next_dd >= txq->nb_tx_desc)
> > > +		txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
> > > +
> > > +	return n;
> > > +}
> > > +


More information about the dev mailing list