FreeBSD/sys/dev/txp/if_txp.c
/*
 * Reclaim mbufs and entries from a transmit ring.
 */
Reclaim mbufs and entries from a transmit ring.
Reclaim mbufs and entries from a transmit ring .
static void
txp_tx_reclaim(struct txp_softc *sc, struct txp_tx_ring *r)
{
	struct ifnet *ifp;
	uint32_t idx;
	uint32_t cons, cnt;
	struct txp_tx_desc *txd;
	struct txp_swdesc *sd;
	TXP_LOCK_ASSERT(sc);
	bus_dmamap_sync(r->r_tag, r->r_map, BUS_DMASYNC_POSTREAD |
	    BUS_DMASYNC_POSTWRITE);
	ifp = sc->sc_ifp;
	idx = TXP_OFFSET2IDX(le32toh(*(r->r_off)));
	cons = r->r_cons;
	cnt = r->r_cnt;
	txd = r->r_desc + cons;
	sd = sc->sc_txd + cons;
	for (cnt = r->r_cnt; cons != idx && cnt > 0; cnt--) {
		if ((txd->tx_flags & TX_FLAGS_TYPE_M) == TX_FLAGS_TYPE_DATA) {
			if (sd->sd_mbuf != NULL) {
				bus_dmamap_sync(sc->sc_cdata.txp_tx_tag,
				    sd->sd_map, BUS_DMASYNC_POSTWRITE);
				bus_dmamap_unload(sc->sc_cdata.txp_tx_tag,
				    sd->sd_map);
				m_freem(sd->sd_mbuf);
				sd->sd_mbuf = NULL;
				txd->tx_addrlo = 0;
				txd->tx_addrhi = 0;
				txd->tx_flags = 0;
			}
		}
		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
		if (++cons == TX_ENTRIES) {
			txd = r->r_desc;
			cons = 0;
			sd = sc->sc_txd;
		} else {
			txd++;
			sd++;
		}
	}
	bus_dmamap_sync(r->r_tag, r->r_map, BUS_DMASYNC_PREREAD |
	    BUS_DMASYNC_PREWRITE);
	r->r_cons = cons;
	r->r_cnt = cnt;
	if (cnt == 0)
		sc->sc_watchdog_timer = 0;
}
static void txp_tx_reclaim ( struct txp_softc * sc , struct txp_tx_ring * r ) { struct ifnet * ifp ; uint32_t idx ; uint32_t cons , cnt ; struct txp_tx_desc * txd ; struct txp_swdesc * sd ; TXP_LOCK_ASSERT ( sc ) ; bus_dmamap_sync ( r -> r_tag , r -> r_map , BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE ) ; ifp = sc -> sc_ifp ; idx = TXP_OFFSET2IDX ( le32toh ( * ( r -> r_off ) ) ) ; cons = r -> r_cons ; cnt = r -> r_cnt ; txd = r -> r_desc + cons ; sd = sc -> sc_txd + cons ; for ( cnt = r -> r_cnt ; cons != idx && cnt > 0 ; cnt -- ) { if ( ( txd -> tx_flags & TX_FLAGS_TYPE_M ) == TX_FLAGS_TYPE_DATA ) { if ( sd -> sd_mbuf != NULL ) { bus_dmamap_sync ( sc -> sc_cdata . txp_tx_tag , sd -> sd_map , BUS_DMASYNC_POSTWRITE ) ; bus_dmamap_unload ( sc -> sc_cdata . txp_tx_tag , sd -> sd_map ) ; m_freem ( sd -> sd_mbuf ) ; sd -> sd_mbuf = NULL ; txd -> tx_addrlo = 0 ; txd -> tx_addrhi = 0 ; txd -> tx_flags = 0 ; } } ifp -> if_drv_flags &= ~ IFF_DRV_OACTIVE ; if ( ++ cons == TX_ENTRIES ) { txd = r -> r_desc ; cons = 0 ; sd = sc -> sc_txd ; } else { txd ++ ; sd ++ ; } } bus_dmamap_sync ( r -> r_tag , r -> r_map , BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE ) ; r -> r_cons = cons ; r -> r_cnt = cnt ; if ( cnt == 0 ) sc -> sc_watchdog_timer = 0 ; }
Reclaim mbufs and entries from a transmit ring.
Reclaim mbufs and entries from a transmit ring .