FreeBSD/sys/dev/rt/if_rt.c
/*
 * rt_tx_eof - check for successful transmitted frames and mark their
 * descriptor as free.
 */
check for successful transmitted frames and mark their
descriptor as free.
check for successful transmitted frames and mark their descriptor as free .
static void
rt_tx_eof(struct rt_softc *sc, struct rt_softc_tx_ring *ring)
{
	struct ifnet *ifp;
	struct rt_txdesc *desc;
	struct rt_softc_tx_data *data;
	uint32_t index;
	int ndescs, nframes;
	ifp = sc->ifp;
	ndescs = 0;
	nframes = 0;
	for (;;) {
		index = RT_READ(sc, sc->tx_dtx_idx[ring->qid]);
		if (ring->desc_next == index)
			break;
		ndescs++;
		desc = &ring->desc[ring->desc_next];
		bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
			BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
		if (desc->sdl0 & htole16(RT_TXDESC_SDL0_LASTSEG) ||
			desc->sdl1 & htole16(RT_TXDESC_SDL1_LASTSEG)) {
			nframes++;
			data = &ring->data[ring->data_next];
			bus_dmamap_sync(ring->data_dma_tag, data->dma_map,
				BUS_DMASYNC_POSTWRITE);
			bus_dmamap_unload(ring->data_dma_tag, data->dma_map);
			m_freem(data->m);
			data->m = NULL;
			if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
			RT_SOFTC_TX_RING_LOCK(ring);
			ring->data_queued--;
			ring->data_next = (ring->data_next + 1) %
			    RT_SOFTC_TX_RING_DATA_COUNT;
			RT_SOFTC_TX_RING_UNLOCK(ring);
		}
		desc->sdl0 &= ~htole16(RT_TXDESC_SDL0_DDONE);
		bus_dmamap_sync(ring->desc_dma_tag, ring->desc_dma_map,
			BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
		RT_SOFTC_TX_RING_LOCK(ring);
		ring->desc_queued--;
		ring->desc_next = (ring->desc_next + 1) %
		    RT_SOFTC_TX_RING_DESC_COUNT;
		RT_SOFTC_TX_RING_UNLOCK(ring);
	}
	RT_DPRINTF(sc, RT_DEBUG_TX,
	    "Tx eof: qid=%d, ndescs=%d, nframes=%d\n", ring->qid, ndescs,
	    nframes);
}
static void rt_tx_eof ( struct rt_softc * sc , struct rt_softc_tx_ring * ring ) { struct ifnet * ifp ; struct rt_txdesc * desc ; struct rt_softc_tx_data * data ; uint32_t index ; int ndescs , nframes ; ifp = sc -> ifp ; ndescs = 0 ; nframes = 0 ; for ( ; ; ) { index = RT_READ ( sc , sc -> tx_dtx_idx [ ring -> qid ] ) ; if ( ring -> desc_next == index ) break ; ndescs ++ ; desc = & ring -> desc [ ring -> desc_next ] ; bus_dmamap_sync ( ring -> desc_dma_tag , ring -> desc_dma_map , BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE ) ; if ( desc -> sdl0 & htole16 ( RT_TXDESC_SDL0_LASTSEG ) || desc -> sdl1 & htole16 ( RT_TXDESC_SDL1_LASTSEG ) ) { nframes ++ ; data = & ring -> data [ ring -> data_next ] ; bus_dmamap_sync ( ring -> data_dma_tag , data -> dma_map , BUS_DMASYNC_POSTWRITE ) ; bus_dmamap_unload ( ring -> data_dma_tag , data -> dma_map ) ; m_freem ( data -> m ) ; data -> m = NULL ; if_inc_counter ( ifp , IFCOUNTER_OPACKETS , 1 ) ; RT_SOFTC_TX_RING_LOCK ( ring ) ; ring -> data_queued -- ; ring -> data_next = ( ring -> data_next + 1 ) % RT_SOFTC_TX_RING_DATA_COUNT ; RT_SOFTC_TX_RING_UNLOCK ( ring ) ; } desc -> sdl0 &= ~ htole16 ( RT_TXDESC_SDL0_DDONE ) ; bus_dmamap_sync ( ring -> desc_dma_tag , ring -> desc_dma_map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; RT_SOFTC_TX_RING_LOCK ( ring ) ; ring -> desc_queued -- ; ring -> desc_next = ( ring -> desc_next + 1 ) % RT_SOFTC_TX_RING_DESC_COUNT ; RT_SOFTC_TX_RING_UNLOCK ( ring ) ; } RT_DPRINTF ( sc , RT_DEBUG_TX , " \n " , ring -> qid , ndescs , nframes ) ; }
rt_tx_eof - check for successful transmitted frames and mark their
 descriptor as free.
rt_tx_eof - check for successful transmitted frames and mark their descriptor as free .