FreeBSD/sys/dev/e1000/if_lem.c
/*********************************************************************
 *
 *  (Re)Initialize transmit structures.
 *
 **********************************************************************/
(Re)Initialize transmit structures.
( Re ) Initialize transmit structures .
static void
lem_setup_transmit_structures(struct adapter *adapter)
{
	struct em_buffer *tx_buffer;
#ifdef DEV_NETMAP
	struct netmap_adapter *na = netmap_getna(adapter->ifp);
	struct netmap_slot *slot = netmap_reset(na, NR_TX, 0, 0);
#endif 
	bzero(adapter->tx_desc_base,
	    (sizeof(struct e1000_tx_desc)) * adapter->num_tx_desc);
	for (int i = 0; i < adapter->num_tx_desc; i++, tx_buffer++) {
		tx_buffer = &adapter->tx_buffer_area[i];
		bus_dmamap_sync(adapter->txtag, tx_buffer->map,
		    BUS_DMASYNC_POSTWRITE);
		bus_dmamap_unload(adapter->txtag, tx_buffer->map);
		m_freem(tx_buffer->m_head);
		tx_buffer->m_head = NULL;
#ifdef DEV_NETMAP
		if (slot) {
			int si = netmap_idx_n2k(&na->tx_rings[0], i);
			uint64_t paddr;
			void *addr;
			addr = PNMB(na, slot + si, &paddr);
			adapter->tx_desc_base[i].buffer_addr = htole64(paddr);
			netmap_load_map(na, adapter->txtag, tx_buffer->map, addr);
		}
#endif 
		tx_buffer->next_eop = -1;
	}
	adapter->last_hw_offload = 0;
	adapter->next_avail_tx_desc = 0;
	adapter->next_tx_to_clean = 0;
	adapter->num_tx_desc_avail = adapter->num_tx_desc;
	bus_dmamap_sync(adapter->txdma.dma_tag, adapter->txdma.dma_map,
	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
	return;
}
static void lem_setup_transmit_structures ( struct adapter * adapter ) { struct em_buffer * tx_buffer ; #ifdef DEV_NETMAP struct netmap_adapter * na = netmap_getna ( adapter -> ifp ) ; struct netmap_slot * slot = netmap_reset ( na , NR_TX , 0 , 0 ) ; #endif bzero ( adapter -> tx_desc_base , ( sizeof ( struct e1000_tx_desc ) ) * adapter -> num_tx_desc ) ; for ( int i = 0 ; i < adapter -> num_tx_desc ; i ++ , tx_buffer ++ ) { tx_buffer = & adapter -> tx_buffer_area [ i ] ; bus_dmamap_sync ( adapter -> txtag , tx_buffer -> map , BUS_DMASYNC_POSTWRITE ) ; bus_dmamap_unload ( adapter -> txtag , tx_buffer -> map ) ; m_freem ( tx_buffer -> m_head ) ; tx_buffer -> m_head = NULL ; #ifdef DEV_NETMAP if ( slot ) { int si = netmap_idx_n2k ( & na -> tx_rings [ 0 ] , i ) ; uint64_t paddr ; void * addr ; addr = PNMB ( na , slot + si , & paddr ) ; adapter -> tx_desc_base [ i ] . buffer_addr = htole64 ( paddr ) ; netmap_load_map ( na , adapter -> txtag , tx_buffer -> map , addr ) ; } #endif tx_buffer -> next_eop = -1 ; } adapter -> last_hw_offload = 0 ; adapter -> next_avail_tx_desc = 0 ; adapter -> next_tx_to_clean = 0 ; adapter -> num_tx_desc_avail = adapter -> num_tx_desc ; bus_dmamap_sync ( adapter -> txdma . dma_tag , adapter -> txdma . dma_map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; return ; }
(Re)Initialize transmit structures.
( Re ) Initialize transmit structures .
/* we are already locked */ /* DEV_NETMAP */ /* Clear the old ring contents */ /* Free any existing TX buffers */ /* the i-th NIC entry goes to slot si */ /* reload the map for netmap mode */ /* DEV_NETMAP */ /* Reset state */