FreeBSD/sys/dev/rt/if_rt.c
/*
 * rt_free_rx_ring - free memory used by RX ring buffer
 */
free memory used by RX ring buffer
free memory used by RX ring buffer
static void
rt_free_rx_ring(struct rt_softc *sc, struct rt_softc_rx_ring *ring)
{
	struct rt_softc_rx_data *data;
	int i;
	if (ring->desc != NULL) {
		bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
			BUS_DMASYNC_POSTWRITE);
		bus_dmamap_unload(ring->desc_dma_tag, ring->desc_dma_map);
		bus_dmamem_free(ring->desc_dma_tag, ring->desc,
			ring->desc_dma_map);
	}
	if (ring->desc_dma_tag != NULL)
		bus_dma_tag_destroy(ring->desc_dma_tag);
	for (i = 0; i < RT_SOFTC_RX_RING_DATA_COUNT; i++) {
		data = &ring->data[i];
		if (data->m != NULL) {
			bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
				BUS_DMASYNC_POSTREAD);
			bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
			m_freem(data->m);
		}
		if (data->dma_map != NULL)
			bus_dmamap_destroy(ring->data_dma_tag, data->dma_map);
	}
	if (ring->spare_dma_map != NULL)
		bus_dmamap_destroy(ring->data_dma_tag, ring->spare_dma_map);
	if (ring->data_dma_tag != NULL)
		bus_dma_tag_destroy(ring->data_dma_tag);
}
static void rt_free_rx_ring ( struct rt_softc * sc , struct rt_softc_rx_ring * ring ) { struct rt_softc_rx_data * data ; int i ; if ( ring -> desc != NULL ) { bus_dmamap_sync ( ring -> desc_dma_tag , ring -> desc_dma_map , BUS_DMASYNC_POSTWRITE ) ; bus_dmamap_unload ( ring -> desc_dma_tag , ring -> desc_dma_map ) ; bus_dmamem_free ( ring -> desc_dma_tag , ring -> desc , ring -> desc_dma_map ) ; } if ( ring -> desc_dma_tag != NULL ) bus_dma_tag_destroy ( ring -> desc_dma_tag ) ; for ( i = 0 ; i < RT_SOFTC_RX_RING_DATA_COUNT ; i ++ ) { data = & ring -> data [ i ] ; if ( data -> m != NULL ) { bus_dmamap_sync ( ring -> data_dma_tag , data -> dma_map , BUS_DMASYNC_POSTREAD ) ; bus_dmamap_unload ( ring -> data_dma_tag , data -> dma_map ) ; m_freem ( data -> m ) ; } if ( data -> dma_map != NULL ) bus_dmamap_destroy ( ring -> data_dma_tag , data -> dma_map ) ; } if ( ring -> spare_dma_map != NULL ) bus_dmamap_destroy ( ring -> data_dma_tag , ring -> spare_dma_map ) ; if ( ring -> data_dma_tag != NULL ) bus_dma_tag_destroy ( ring -> data_dma_tag ) ; }
rt_free_rx_ring - free memory used by RX ring buffer
rt_free_rx_ring - free memory used by RX ring buffer