FreeBSD/sys/dev/ixl/ixl_txrx.c
/*********************************************************************
 *
 *  (Re)Initialize a queue transmit ring.
 *	- called by init, it clears the descriptor ring,
 *	  and frees any stale mbufs 
 *
 **********************************************************************/
(Re)Initialize a queue transmit ring.
- called by init, it clears the descriptor ring,
and frees any stale mbufs
( Re ) Initialize a queue transmit ring . - called by init it clears the descriptor ring and frees any stale mbufs
void
ixl_init_tx_ring(struct ixl_queue *que)
{
#ifdef DEV_NETMAP
	struct netmap_adapter *na = NA(que->vsi->ifp);
	struct netmap_slot *slot;
#endif 
	struct tx_ring		*txr = &que->txr;
	struct ixl_tx_buf	*buf;
	IXL_TX_LOCK(txr);
#ifdef DEV_NETMAP
	slot = netmap_reset(na, NR_TX, que->me, 0);
#endif 
	bzero((void *)txr->base,
	      (sizeof(struct i40e_tx_desc)) * que->num_desc);
	txr->next_avail = 0;
	txr->next_to_clean = 0;
#ifdef IXL_FDIR
	txr->atr_rate = ixl_atr_rate;
	txr->atr_count = 0;
#endif
        buf = txr->buffers;
	for (int i = 0; i < que->num_desc; i++, buf++) {
		if (buf->m_head != NULL) {
			bus_dmamap_sync(buf->tag, buf->map,
			    BUS_DMASYNC_POSTWRITE);
			bus_dmamap_unload(buf->tag, buf->map);
			m_freem(buf->m_head);
			buf->m_head = NULL;
		}
#ifdef DEV_NETMAP
		if (slot) {
			int si = netmap_idx_n2k(&na->tx_rings[que->me], i);
			netmap_load_map(na, buf->tag, buf->map, NMB(na, slot + si));
		}
#endif 
		buf->eop_index = -1;
        }
	txr->avail = que->num_desc;
	bus_dmamap_sync(txr->dma.tag, txr->dma.map,
	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
	IXL_TX_UNLOCK(txr);
}
void ixl_init_tx_ring ( struct ixl_queue * que ) { #ifdef DEV_NETMAP struct netmap_adapter * na = NA ( que -> vsi -> ifp ) ; struct netmap_slot * slot ; #endif struct tx_ring * txr = & que -> txr ; struct ixl_tx_buf * buf ; IXL_TX_LOCK ( txr ) ; #ifdef DEV_NETMAP slot = netmap_reset ( na , NR_TX , que -> me , 0 ) ; #endif bzero ( ( void * ) txr -> base , ( sizeof ( struct i40e_tx_desc ) ) * que -> num_desc ) ; txr -> next_avail = 0 ; txr -> next_to_clean = 0 ; #ifdef IXL_FDIR txr -> atr_rate = ixl_atr_rate ; txr -> atr_count = 0 ; #endif buf = txr -> buffers ; for ( int i = 0 ; i < que -> num_desc ; i ++ , buf ++ ) { if ( buf -> m_head != NULL ) { bus_dmamap_sync ( buf -> tag , buf -> map , BUS_DMASYNC_POSTWRITE ) ; bus_dmamap_unload ( buf -> tag , buf -> map ) ; m_freem ( buf -> m_head ) ; buf -> m_head = NULL ; } #ifdef DEV_NETMAP if ( slot ) { int si = netmap_idx_n2k ( & na -> tx_rings [ que -> me ] , i ) ; netmap_load_map ( na , buf -> tag , buf -> map , NMB ( na , slot + si ) ) ; } #endif buf -> eop_index = -1 ; } txr -> avail = que -> num_desc ; bus_dmamap_sync ( txr -> dma . tag , txr -> dma . map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; IXL_TX_UNLOCK ( txr ) ; }
(Re)Initialize a queue transmit ring.
( Re ) Initialize a queue transmit ring .
/* DEV_NETMAP */ /* Clear the old ring contents */ /*
	 * (under lock): if in netmap mode, do some consistency
	 * checks and set slot to entry 0 of the netmap ring.
	 */ /* DEV_NETMAP */ /* Reset indices */ /* Initialize flow director */ /* Free any existing tx mbufs. */ /*
		 * In netmap mode, set the map for the packet buffer.
		 * NOTE: Some drivers (not this one) also need to set
		 * the physical buffer address in the NIC ring.
		 * netmap_idx_n2k() maps a nic index, i, into the corresponding
		 * netmap slot index, si
		 */ /* DEV_NETMAP */ /* Clear the EOP index */ /* Set number of descriptors available */