FreeBSD/sys/dev/e1000/if_lem.c
/*********************************************************************
 *
 *  (Re)initialize receive structures.
 *
 **********************************************************************/
(Re)initialize receive structures.
( Re ) initialize receive structures .
static int
lem_setup_receive_structures(struct adapter *adapter)
{
	struct em_buffer *rx_buffer;
	int i, error;
#ifdef DEV_NETMAP
	struct netmap_adapter *na = netmap_getna(adapter->ifp);
	struct netmap_slot *slot = netmap_reset(na, NR_RX, 0, 0);
#endif
	bzero(adapter->rx_desc_base,
	    (sizeof(struct e1000_rx_desc)) * adapter->num_rx_desc);
	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;
		}
        }
	for (i = 0; i < adapter->num_rx_desc; i++) {
#ifdef DEV_NETMAP
		if (slot) {
			int si = netmap_idx_n2k(&na->rx_rings[0], i);
			uint64_t paddr;
			void *addr;
			addr = PNMB(na, slot + si, &paddr);
			netmap_load_map(na, adapter->rxtag, rx_buffer->map, addr);
			adapter->rx_desc_base[i].buffer_addr = htole64(paddr);
			continue;
		}
#endif 
		error = lem_get_buf(adapter, i);
		if (error)
                        return (error);
	}
	adapter->next_rx_desc_to_check = 0;
	bus_dmamap_sync(adapter->rxdma.dma_tag, adapter->rxdma.dma_map,
	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
	return (0);
}
static int lem_setup_receive_structures ( struct adapter * adapter ) { struct em_buffer * rx_buffer ; int i , error ; #ifdef DEV_NETMAP struct netmap_adapter * na = netmap_getna ( adapter -> ifp ) ; struct netmap_slot * slot = netmap_reset ( na , NR_RX , 0 , 0 ) ; #endif bzero ( adapter -> rx_desc_base , ( sizeof ( struct e1000_rx_desc ) ) * adapter -> num_rx_desc ) ; 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 ; } } for ( i = 0 ; i < adapter -> num_rx_desc ; i ++ ) { #ifdef DEV_NETMAP if ( slot ) { int si = netmap_idx_n2k ( & na -> rx_rings [ 0 ] , i ) ; uint64_t paddr ; void * addr ; addr = PNMB ( na , slot + si , & paddr ) ; netmap_load_map ( na , adapter -> rxtag , rx_buffer -> map , addr ) ; adapter -> rx_desc_base [ i ] . buffer_addr = htole64 ( paddr ) ; continue ; } #endif error = lem_get_buf ( adapter , i ) ; if ( error ) return ( error ) ; } adapter -> next_rx_desc_to_check = 0 ; bus_dmamap_sync ( adapter -> rxdma . dma_tag , adapter -> rxdma . dma_map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; return ( 0 ) ; }
(Re)initialize receive structures.
( Re ) initialize receive structures .
/* we are already under lock */ /* Reset descriptor ring */ /* Free current RX buffers. */ /* Allocate new ones. */ /* the i-th NIC entry goes to slot si */ /* Update descriptor */ /* DEV_NETMAP */ /* Setup our descriptor pointers */