FreeBSD/sys/dev/netmap/netmap_vale.c
/* notify method for the bridge-->hwna direction */
notify method for the bridge-->hwna direction
notify method for the bridge -- > hwna direction
static int
netmap_bwrap_notify(struct netmap_kring *kring, int flags)
{
	struct netmap_adapter *na = kring->na;
	struct netmap_bwrap_adapter *bna = na->na_private;
	struct netmap_adapter *hwna = bna->hwna;
	u_int ring_n = kring->ring_id;
	u_int lim = kring->nkr_num_slots - 1;
	struct netmap_kring *hw_kring;
	int error = 0;
	ND("%s: na %s hwna %s", 
			(kring ? kring->name : "NULL!"),
			(na ? na->name : "NULL!"),
			(hwna ? hwna->name : "NULL!"));
	hw_kring = &hwna->tx_rings[ring_n];
	if (nm_kr_tryget(hw_kring))
		return 0;
	if (!nm_netmap_on(hwna))
		return 0;
	netmap_vp_rxsync(kring, flags);
	ND("%s[%d] PRE rx(c%3d t%3d l%3d) ring(h%3d c%3d t%3d) tx(c%3d ht%3d t%3d)",
		na->name, ring_n,
		kring->nr_hwcur, kring->nr_hwtail, kring->nkr_hwlease,
		ring->head, ring->cur, ring->tail,
		hw_kring->nr_hwcur, hw_kring->nr_hwtail, hw_ring->rtail);
	hw_kring->rhead = hw_kring->rcur = kring->nr_hwtail;
	error = hw_kring->nm_sync(hw_kring, flags);
	if (error)
		goto out;
	kring->rhead = kring->rcur = nm_next(hw_kring->nr_hwtail, lim); 
	netmap_vp_rxsync(kring, flags);
	ND("%s[%d] PST rx(c%3d t%3d l%3d) ring(h%3d c%3d t%3d) tx(c%3d ht%3d t%3d)",
		na->name, ring_n,
		kring->nr_hwcur, kring->nr_hwtail, kring->nkr_hwlease,
		ring->head, ring->cur, ring->tail,
		hw_kring->nr_hwcur, hw_kring->nr_hwtail, hw_kring->rtail);
out:
	nm_kr_put(hw_kring);
	return error;
}
static int netmap_bwrap_notify ( struct netmap_kring * kring , int flags ) { struct netmap_adapter * na = kring -> na ; struct netmap_bwrap_adapter * bna = na -> na_private ; struct netmap_adapter * hwna = bna -> hwna ; u_int ring_n = kring -> ring_id ; u_int lim = kring -> nkr_num_slots - 1 ; struct netmap_kring * hw_kring ; int error = 0 ; ND ( " " , ( kring ? kring -> name : " " ) , ( na ? na -> name : " " ) , ( hwna ? hwna -> name : " " ) ) ; hw_kring = & hwna -> tx_rings [ ring_n ] ; if ( nm_kr_tryget ( hw_kring ) ) return 0 ; if ( ! nm_netmap_on ( hwna ) ) return 0 ; netmap_vp_rxsync ( kring , flags ) ; ND ( " " , na -> name , ring_n , kring -> nr_hwcur , kring -> nr_hwtail , kring -> nkr_hwlease , ring -> head , ring -> cur , ring -> tail , hw_kring -> nr_hwcur , hw_kring -> nr_hwtail , hw_ring -> rtail ) ; hw_kring -> rhead = hw_kring -> rcur = kring -> nr_hwtail ; error = hw_kring -> nm_sync ( hw_kring , flags ) ; if ( error ) goto out ; kring -> rhead = kring -> rcur = nm_next ( hw_kring -> nr_hwtail , lim ) ; netmap_vp_rxsync ( kring , flags ) ; ND ( " " , na -> name , ring_n , kring -> nr_hwcur , kring -> nr_hwtail , kring -> nkr_hwlease , ring -> head , ring -> cur , ring -> tail , hw_kring -> nr_hwcur , hw_kring -> nr_hwtail , hw_kring -> rtail ) ; out : nm_kr_put ( hw_kring ) ; return error ; }
notify method for the bridge-->hwna direction
notify method for the bridge -- > hwna direction
/* first step: simulate a user wakeup on the rx ring */ /* second step: the new packets are sent on the tx ring
	 * (which is actually the same ring)
	 */ /* third step: now we are back the rx ring */ /* claim ownership on all hw owned bufs */ /* skip past reserved slot */ /* fourth step: the user goes to sleep again, causing another rxsync */