FreeBSD/sys/dev/cxgbe/t4_sge.c
/*
 * Reclaim 'n' descriptors approximately.
 */
Reclaim 'n' descriptors approximately.
Reclaim ' n ' descriptors approximately .
static u_int
reclaim_tx_descs(struct sge_txq *txq, u_int n)
{
	struct tx_sdesc *txsd;
	struct sge_eq *eq = &txq->eq;
	u_int can_reclaim, reclaimed;
	TXQ_LOCK_ASSERT_OWNED(txq);
	MPASS(n > 0);
	reclaimed = 0;
	can_reclaim = reclaimable_tx_desc(eq);
	while (can_reclaim && reclaimed < n) {
		int ndesc;
		struct mbuf *m, *nextpkt;
		txsd = &txq->sdesc[eq->cidx];
		ndesc = txsd->desc_used;
		KASSERT(can_reclaim >= ndesc,
		    ("%s: unexpected number of credits: %d, %d",
		    __func__, can_reclaim, ndesc));
		for (m = txsd->m; m != NULL; m = nextpkt) {
			nextpkt = m->m_nextpkt;
			m->m_nextpkt = NULL;
			m_freem(m);
		}
		reclaimed += ndesc;
		can_reclaim -= ndesc;
		IDXINCR(eq->cidx, ndesc, eq->sidx);
	}
	return (reclaimed);
}
static u_int reclaim_tx_descs ( struct sge_txq * txq , u_int n ) { struct tx_sdesc * txsd ; struct sge_eq * eq = & txq -> eq ; u_int can_reclaim , reclaimed ; TXQ_LOCK_ASSERT_OWNED ( txq ) ; MPASS ( n > 0 ) ; reclaimed = 0 ; can_reclaim = reclaimable_tx_desc ( eq ) ; while ( can_reclaim && reclaimed < n ) { int ndesc ; struct mbuf * m , * nextpkt ; txsd = & txq -> sdesc [ eq -> cidx ] ; ndesc = txsd -> desc_used ; KASSERT ( can_reclaim >= ndesc , ( " " , __func__ , can_reclaim , ndesc ) ) ; for ( m = txsd -> m ; m != NULL ; m = nextpkt ) { nextpkt = m -> m_nextpkt ; m -> m_nextpkt = NULL ; m_freem ( m ) ; } reclaimed += ndesc ; can_reclaim -= ndesc ; IDXINCR ( eq -> cidx , ndesc , eq -> sidx ) ; } return ( reclaimed ) ; }
Reclaim 'n' descriptors approximately.
Reclaim ' n ' descriptors approximately .
/* Firmware doesn't return "partial" credits. */