FreeBSD/sys/dev/rt/if_rt.c
/*
 * rt_tx_done_task - check for pending TX task in all queues
 */
check for pending TX task in all queues
check for pending TX task in all queues
static void
rt_tx_done_task(void *context, int pending)
{
	struct rt_softc *sc;
	struct ifnet *ifp;
	uint32_t intr_mask;
	int i;
	sc = context;
	ifp = sc->ifp;
	RT_DPRINTF(sc, RT_DEBUG_TX, "Tx done task\n");
	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
		return;
	for (i = RT_SOFTC_TX_RING_COUNT - 1; i >= 0; i--) {
		if (sc->intr_pending_mask & (sc->int_tx_done_mask << i)) {
			sc->intr_pending_mask &= ~(sc->int_tx_done_mask << i);
			rt_tx_eof(sc, &sc->tx_ring[i]);
		}
	}
	sc->tx_timer = 0;
	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
	if(sc->rt_chipid == RT_CHIPID_RT5350 ||
	   sc->rt_chipid == RT_CHIPID_MT7620 ||
	   sc->rt_chipid == RT_CHIPID_MT7621)
	  intr_mask = (
		RT5350_INT_TXQ3_DONE |
		RT5350_INT_TXQ2_DONE |
		RT5350_INT_TXQ1_DONE |
		RT5350_INT_TXQ0_DONE);
	else
	  intr_mask = (
		INT_TXQ3_DONE |
		INT_TXQ2_DONE |
		INT_TXQ1_DONE |
		INT_TXQ0_DONE);
	RT_SOFTC_LOCK(sc);
	rt_intr_enable(sc, ~sc->intr_pending_mask &
	    (sc->intr_disable_mask & intr_mask));
	if (sc->intr_pending_mask & intr_mask) {
		RT_DPRINTF(sc, RT_DEBUG_TX,
		    "Tx done task: scheduling again\n");
		taskqueue_enqueue(sc->taskqueue, &sc->tx_done_task);
	}
	RT_SOFTC_UNLOCK(sc);
	if (!IFQ_IS_EMPTY(&ifp->if_snd))
		rt_start(ifp);
}
static void rt_tx_done_task ( void * context , int pending ) { struct rt_softc * sc ; struct ifnet * ifp ; uint32_t intr_mask ; int i ; sc = context ; ifp = sc -> ifp ; RT_DPRINTF ( sc , RT_DEBUG_TX , " \n " ) ; if ( ! ( ifp -> if_drv_flags & IFF_DRV_RUNNING ) ) return ; for ( i = RT_SOFTC_TX_RING_COUNT - 1 ; i >= 0 ; i -- ) { if ( sc -> intr_pending_mask & ( sc -> int_tx_done_mask << i ) ) { sc -> intr_pending_mask &= ~ ( sc -> int_tx_done_mask << i ) ; rt_tx_eof ( sc , & sc -> tx_ring [ i ] ) ; } } sc -> tx_timer = 0 ; ifp -> if_drv_flags &= ~ IFF_DRV_OACTIVE ; if ( sc -> rt_chipid == RT_CHIPID_RT5350 || sc -> rt_chipid == RT_CHIPID_MT7620 || sc -> rt_chipid == RT_CHIPID_MT7621 ) intr_mask = ( RT5350_INT_TXQ3_DONE | RT5350_INT_TXQ2_DONE | RT5350_INT_TXQ1_DONE | RT5350_INT_TXQ0_DONE ) ; else intr_mask = ( INT_TXQ3_DONE | INT_TXQ2_DONE | INT_TXQ1_DONE | INT_TXQ0_DONE ) ; RT_SOFTC_LOCK ( sc ) ; rt_intr_enable ( sc , ~ sc -> intr_pending_mask & ( sc -> intr_disable_mask & intr_mask ) ) ; if ( sc -> intr_pending_mask & intr_mask ) { RT_DPRINTF ( sc , RT_DEBUG_TX , " \n " ) ; taskqueue_enqueue ( sc -> taskqueue , & sc -> tx_done_task ) ; } RT_SOFTC_UNLOCK ( sc ) ; if ( ! IFQ_IS_EMPTY ( & ifp -> if_snd ) ) rt_start ( ifp ) ; }
rt_tx_done_task - check for pending TX task in all queues
rt_tx_done_task - check for pending TX task in all queues