FreeBSD/sys/dev/e1000/if_lem.c
/*********************************************************************
 *
 *  Free receive related data structures.
 *
 **********************************************************************/
Free receive related data structures.
Free receive related data structures .
static void
lem_free_receive_structures(struct adapter *adapter)
{
	struct em_buffer *rx_buffer;
	int i;
	INIT_DEBUGOUT("free_receive_structures: begin");
	if (adapter->rx_sparemap) {
		bus_dmamap_destroy(adapter->rxtag, adapter->rx_sparemap);
		adapter->rx_sparemap = NULL;
	}
	if (adapter->rx_buffer_area != NULL) {
		rx_buffer = adapter->rx_buffer_area;
		for (i = 0; i < adapter->num_rx_desc; i++, rx_buffer++) {
			if (rx_buffer->m_head != NULL) {
				bus_dmamap_sync(adapter->rxtag, rx_buffer->map,
				    BUS_DMASYNC_POSTREAD);
				bus_dmamap_unload(adapter->rxtag,
				    rx_buffer->map);
				m_freem(rx_buffer->m_head);
				rx_buffer->m_head = NULL;
			} else if (rx_buffer->map != NULL)
				bus_dmamap_unload(adapter->rxtag,
				    rx_buffer->map);
			if (rx_buffer->map != NULL) {
				bus_dmamap_destroy(adapter->rxtag,
				    rx_buffer->map);
				rx_buffer->map = NULL;
			}
		}
	}
	if (adapter->rx_buffer_area != NULL) {
		free(adapter->rx_buffer_area, M_DEVBUF);
		adapter->rx_buffer_area = NULL;
	}
	if (adapter->rxtag != NULL) {
		bus_dma_tag_destroy(adapter->rxtag);
		adapter->rxtag = NULL;
	}
}
static void lem_free_receive_structures ( struct adapter * adapter ) { struct em_buffer * rx_buffer ; int i ; INIT_DEBUGOUT ( " " ) ; if ( adapter -> rx_sparemap ) { bus_dmamap_destroy ( adapter -> rxtag , adapter -> rx_sparemap ) ; adapter -> rx_sparemap = NULL ; } if ( adapter -> rx_buffer_area != NULL ) { rx_buffer = adapter -> rx_buffer_area ; for ( i = 0 ; i < adapter -> num_rx_desc ; i ++ , rx_buffer ++ ) { if ( rx_buffer -> m_head != NULL ) { bus_dmamap_sync ( adapter -> rxtag , rx_buffer -> map , BUS_DMASYNC_POSTREAD ) ; bus_dmamap_unload ( adapter -> rxtag , rx_buffer -> map ) ; m_freem ( rx_buffer -> m_head ) ; rx_buffer -> m_head = NULL ; } else if ( rx_buffer -> map != NULL ) bus_dmamap_unload ( adapter -> rxtag , rx_buffer -> map ) ; if ( rx_buffer -> map != NULL ) { bus_dmamap_destroy ( adapter -> rxtag , rx_buffer -> map ) ; rx_buffer -> map = NULL ; } } } if ( adapter -> rx_buffer_area != NULL ) { free ( adapter -> rx_buffer_area , M_DEVBUF ) ; adapter -> rx_buffer_area = NULL ; } if ( adapter -> rxtag != NULL ) { bus_dma_tag_destroy ( adapter -> rxtag ) ; adapter -> rxtag = NULL ; } }
Free receive related data structures.
Free receive related data structures .
/* Cleanup any existing buffers */