FreeBSD/sys/net/if_tap.c
/*
 * tapifstart
 *
 * queue packets from higher level ready to put out
 */
tapifstart
queue packets from higher level ready to put out
tapifstart queue packets from higher level ready to put out
static void
tapifstart(struct ifnet *ifp)
{
	struct tap_softc	*tp = ifp->if_softc;
	TAPDEBUG("%s starting\n", ifp->if_xname);
	mtx_lock(&tp->tap_mtx);
	if (((tp->tap_flags & TAP_VMNET) == 0) &&
	    ((tp->tap_flags & TAP_READY) != TAP_READY)) {
		struct mbuf *m;
		TAPDEBUG("%s not ready, tap_flags = 0x%x\n", ifp->if_xname, 
		    tp->tap_flags);
		for (;;) {
			IF_DEQUEUE(&ifp->if_snd, m);
			if (m != NULL) {
				m_freem(m);
				if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
			} else
				break;
		}
		mtx_unlock(&tp->tap_mtx);
		return;
	}
	ifp->if_drv_flags |= IFF_DRV_OACTIVE;
	if (!IFQ_IS_EMPTY(&ifp->if_snd)) {
		if (tp->tap_flags & TAP_RWAIT) {
			tp->tap_flags &= ~TAP_RWAIT;
			wakeup(tp);
		}
		if ((tp->tap_flags & TAP_ASYNC) && (tp->tap_sigio != NULL)) {
			mtx_unlock(&tp->tap_mtx);
			pgsigio(&tp->tap_sigio, SIGIO, 0);
			mtx_lock(&tp->tap_mtx);
		}
		selwakeuppri(&tp->tap_rsel, PZERO+1);
		KNOTE_LOCKED(&tp->tap_rsel.si_note, 0);
		if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); 
	}
	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
	mtx_unlock(&tp->tap_mtx);
}
static void tapifstart ( struct ifnet * ifp ) { struct tap_softc * tp = ifp -> if_softc ; TAPDEBUG ( " \n " , ifp -> if_xname ) ; mtx_lock ( & tp -> tap_mtx ) ; if ( ( ( tp -> tap_flags & TAP_VMNET ) == 0 ) && ( ( tp -> tap_flags & TAP_READY ) != TAP_READY ) ) { struct mbuf * m ; TAPDEBUG ( " \n " , ifp -> if_xname , tp -> tap_flags ) ; for ( ; ; ) { IF_DEQUEUE ( & ifp -> if_snd , m ) ; if ( m != NULL ) { m_freem ( m ) ; if_inc_counter ( ifp , IFCOUNTER_OERRORS , 1 ) ; } else break ; } mtx_unlock ( & tp -> tap_mtx ) ; return ; } ifp -> if_drv_flags |= IFF_DRV_OACTIVE ; if ( ! IFQ_IS_EMPTY ( & ifp -> if_snd ) ) { if ( tp -> tap_flags & TAP_RWAIT ) { tp -> tap_flags &= ~ TAP_RWAIT ; wakeup ( tp ) ; } if ( ( tp -> tap_flags & TAP_ASYNC ) && ( tp -> tap_sigio != NULL ) ) { mtx_unlock ( & tp -> tap_mtx ) ; pgsigio ( & tp -> tap_sigio , SIGIO , 0 ) ; mtx_lock ( & tp -> tap_mtx ) ; } selwakeuppri ( & tp -> tap_rsel , PZERO + 1 ) ; KNOTE_LOCKED ( & tp -> tap_rsel . si_note , 0 ) ; if_inc_counter ( ifp , IFCOUNTER_OPACKETS , 1 ) ; } ifp -> if_drv_flags &= ~ IFF_DRV_OACTIVE ; mtx_unlock ( & tp -> tap_mtx ) ; }
tapifstart
 queue packets from higher level ready to put out
tapifstart queue packets from higher level ready to put out
/*
	 * do not junk pending output if we are in VMnet mode.
	 * XXX: can this do any harm because of queue overflow?
	 */ /* Unlocked read. */ /* obytes are counted in ether_output */