FreeBSD/sys/dev/netmap/netmap_vale.c
/*
 * Intr callback for NICs connected to a bridge.
 * Simply ignore tx interrupts (maybe we could try to recover space ?)
 * and pass received packets from nic to the bridge.
 *
 * XXX TODO check locking: this is called from the interrupt
 * handler so we should make sure that the interface is not
 * disconnected while passing down an interrupt.
 *
 * Note, no user process can access this NIC or the host stack.
 * The only part of the ring that is significant are the slots,
 * and head/cur/tail are set from the kring as needed
 * (part as a receive ring, part as a transmit ring).
 *
 * callback that overwrites the hwna notify callback.
 * Packets come from the outside or from the host stack and are put on an hwna rx ring.
 * The bridge wrapper then sends the packets through the bridge.
 */
Intr callback for NICs connected to a bridge.
Simply ignore tx interrupts (maybe we could try to recover space ?)
and pass received packets from nic to the bridge.

XXX TODO check locking: this is called from the interrupt
handler so we should make sure that the interface is not
disconnected while passing down an interrupt.

Note, no user process can access this NIC or the host stack.
The only part of the ring that is significant are the slots,
and head/cur/tail are set from the kring as needed
(part as a receive ring, part as a transmit ring).

callback that overwrites the hwna notify callback.
Packets come from the outside or from the host stack and are put on an hwna rx ring.
The bridge wrapper then sends the packets through the bridge.
Intr callback for NICs connected to a bridge . Simply ignore tx interrupts ( maybe we could try to recover space ? ) and pass received packets from nic to the bridge . XXX TODO check locking : this is called from the interrupt handler so we should make sure that the interface is not disconnected while passing down an interrupt . Note no user process can access this NIC or the host stack . The only part of the ring that is significant are the slots and head / cur / tail are set from the kring as needed ( part as a receive ring part as a transmit ring ) . callback that overwrites the hwna notify callback . Packets come from the outside or from the host stack and are put on an hwna rx ring . The bridge wrapper then sends the packets through the bridge .
static int
netmap_bwrap_intr_notify(struct netmap_kring *kring, int flags)
{
	struct netmap_adapter *na = kring->na;
	struct netmap_bwrap_adapter *bna = na->na_private;
	struct netmap_kring *bkring;
	struct netmap_vp_adapter *vpna = &bna->up;
	u_int ring_nr = kring->ring_id;
	int error = 0;
	if (netmap_verbose)
	    D("%s %s 0x%x", na->name, kring->name, flags);
	if (!nm_netmap_on(na))
		return 0;
	bkring = &vpna->up.tx_rings[ring_nr];
	if (nm_kr_tryget(kring))
		return 0;
	if (netmap_verbose)
	    D("%s head %d cur %d tail %d",  na->name,
		kring->rhead, kring->rcur, kring->rtail);
	error = kring->nm_sync(kring, 0);
	if (error)
		goto put_out;
	if (kring->nr_hwcur == kring->nr_hwtail && netmap_verbose) {
		D("how strange, interrupt with no packets on %s",
			na->name);
		goto put_out;
	}
	bkring->rhead = bkring->rcur = kring->nr_hwtail;
	netmap_vp_txsync(bkring, flags);
	kring->rhead = kring->rcur = kring->rtail = kring->nr_hwtail;
	error = kring->nm_sync(kring, 0);
put_out:
	nm_kr_put(kring);
	return error;
}
static int netmap_bwrap_intr_notify ( struct netmap_kring * kring , int flags ) { struct netmap_adapter * na = kring -> na ; struct netmap_bwrap_adapter * bna = na -> na_private ; struct netmap_kring * bkring ; struct netmap_vp_adapter * vpna = & bna -> up ; u_int ring_nr = kring -> ring_id ; int error = 0 ; if ( netmap_verbose ) D ( " " , na -> name , kring -> name , flags ) ; if ( ! nm_netmap_on ( na ) ) return 0 ; bkring = & vpna -> up . tx_rings [ ring_nr ] ; if ( nm_kr_tryget ( kring ) ) return 0 ; if ( netmap_verbose ) D ( " " , na -> name , kring -> rhead , kring -> rcur , kring -> rtail ) ; error = kring -> nm_sync ( kring , 0 ) ; if ( error ) goto put_out ; if ( kring -> nr_hwcur == kring -> nr_hwtail && netmap_verbose ) { D ( " " , na -> name ) ; goto put_out ; } bkring -> rhead = bkring -> rcur = kring -> nr_hwtail ; netmap_vp_txsync ( bkring , flags ) ; kring -> rhead = kring -> rcur = kring -> rtail = kring -> nr_hwtail ; error = kring -> nm_sync ( kring , 0 ) ; put_out : nm_kr_put ( kring ) ; return error ; }
Intr callback for NICs connected to a bridge.
Intr callback for NICs connected to a bridge .
/* make sure the ring is not disabled */ /* simulate a user wakeup on the rx ring
	 * fetch packets that have arrived.
	 */ /* new packets are kring->rcur to kring->nr_hwtail, and the bkring
	 * had hwcur == bkring->rhead. So advance bkring->rhead to kring->nr_hwtail
	 * to push all packets out.
	 */ /* mark all buffers as released on this ring */ /* another call to actually release the buffers */