FreeBSD/sys/dev/e1000/if_em.c
/*********************************************************************
 *
 *  Free transmit ring related data structures.
 *
 **********************************************************************/
Free transmit ring related data structures.
Free transmit ring related data structures .
static void
em_free_transmit_buffers(struct tx_ring *txr)
{
	struct adapter		*adapter = txr->adapter;
	struct em_txbuffer	*txbuf;
	INIT_DEBUGOUT("free_transmit_ring: begin");
	if (txr->tx_buffers == NULL)
		return;
	for (int i = 0; i < adapter->num_tx_desc; i++) {
		txbuf = &txr->tx_buffers[i];
		if (txbuf->m_head != NULL) {
			bus_dmamap_sync(txr->txtag, txbuf->map,
			    BUS_DMASYNC_POSTWRITE);
			bus_dmamap_unload(txr->txtag,
			    txbuf->map);
			m_freem(txbuf->m_head);
			txbuf->m_head = NULL;
			if (txbuf->map != NULL) {
				bus_dmamap_destroy(txr->txtag,
				    txbuf->map);
				txbuf->map = NULL;
			}
		} else if (txbuf->map != NULL) {
			bus_dmamap_unload(txr->txtag,
			    txbuf->map);
			bus_dmamap_destroy(txr->txtag,
			    txbuf->map);
			txbuf->map = NULL;
		}
	}
#if __FreeBSD_version >= 800000
	if (txr->br != NULL)
		buf_ring_free(txr->br, M_DEVBUF);
#endif
	if (txr->tx_buffers != NULL) {
		free(txr->tx_buffers, M_DEVBUF);
		txr->tx_buffers = NULL;
	}
	if (txr->txtag != NULL) {
		bus_dma_tag_destroy(txr->txtag);
		txr->txtag = NULL;
	}
	return;
}
static void em_free_transmit_buffers ( struct tx_ring * txr ) { struct adapter * adapter = txr -> adapter ; struct em_txbuffer * txbuf ; INIT_DEBUGOUT ( " " ) ; if ( txr -> tx_buffers == NULL ) return ; for ( int i = 0 ; i < adapter -> num_tx_desc ; i ++ ) { txbuf = & txr -> tx_buffers [ i ] ; if ( txbuf -> m_head != NULL ) { bus_dmamap_sync ( txr -> txtag , txbuf -> map , BUS_DMASYNC_POSTWRITE ) ; bus_dmamap_unload ( txr -> txtag , txbuf -> map ) ; m_freem ( txbuf -> m_head ) ; txbuf -> m_head = NULL ; if ( txbuf -> map != NULL ) { bus_dmamap_destroy ( txr -> txtag , txbuf -> map ) ; txbuf -> map = NULL ; } } else if ( txbuf -> map != NULL ) { bus_dmamap_unload ( txr -> txtag , txbuf -> map ) ; bus_dmamap_destroy ( txr -> txtag , txbuf -> map ) ; txbuf -> map = NULL ; } } #if __FreeBSD_version >= 800000 if ( txr -> br != NULL ) buf_ring_free ( txr -> br , M_DEVBUF ) ; #endif if ( txr -> tx_buffers != NULL ) { free ( txr -> tx_buffers , M_DEVBUF ) ; txr -> tx_buffers = NULL ; } if ( txr -> txtag != NULL ) { bus_dma_tag_destroy ( txr -> txtag ) ; txr -> txtag = NULL ; } return ; }
Free transmit ring related data structures.
Free transmit ring related data structures .