FreeBSD/sys/dev/netmap/netmap_monitor.c
/* common functions for the nm_register() callbacks of both kind of
 * monitors.
 */
common functions for the nm_register() callbacks of both kind of
monitors.
common functions for the nm_register () callbacks of both kind of monitors .
static int
netmap_monitor_reg_common(struct netmap_adapter *na, int onoff, int zmon)
{
	struct netmap_monitor_adapter *mna =
		(struct netmap_monitor_adapter *)na;
	struct netmap_priv_d *priv = &mna->priv;
	struct netmap_adapter *pna = priv->np_na;
	struct netmap_kring *kring, *mkring;
	int i;
	enum txrx t;
	ND("%p: onoff %d", na, onoff);
	if (onoff) {
		if (pna == NULL) {
			D("%s: internal error", na->name);
			return ENXIO;
		}
		for_rx_tx(t) {
			if (mna->flags & nm_txrx2flag(t)) {
				for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) {
					kring = &NMR(pna, t)[i];
					mkring = &na->rx_rings[i];
					netmap_monitor_add(mkring, kring, zmon);
				}
			}
		}
		na->na_flags |= NAF_NETMAP_ON;
	} else {
		if (pna == NULL) {
			D("%s: parent left netmap mode, nothing to restore", na->name);
			return 0;
		}
		na->na_flags &= ~NAF_NETMAP_ON;
		for_rx_tx(t) {
			if (mna->flags & nm_txrx2flag(t)) {
				for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) {
					kring = &NMR(pna, t)[i];
					mkring = &na->rx_rings[i];
					netmap_monitor_del(mkring, kring);
				}
			}
		}
	}
	return 0;
}
static int netmap_monitor_reg_common ( struct netmap_adapter * na , int onoff , int zmon ) { struct netmap_monitor_adapter * mna = ( struct netmap_monitor_adapter * ) na ; struct netmap_priv_d * priv = & mna -> priv ; struct netmap_adapter * pna = priv -> np_na ; struct netmap_kring * kring , * mkring ; int i ; enum txrx t ; ND ( " " , na , onoff ) ; if ( onoff ) { if ( pna == NULL ) { D ( " " , na -> name ) ; return ENXIO ; } for_rx_tx ( t ) { if ( mna -> flags & nm_txrx2flag ( t ) ) { for ( i = priv -> np_qfirst [ t ] ; i < priv -> np_qlast [ t ] ; i ++ ) { kring = & NMR ( pna , t ) [ i ] ; mkring = & na -> rx_rings [ i ] ; netmap_monitor_add ( mkring , kring , zmon ) ; } } } na -> na_flags |= NAF_NETMAP_ON ; } else { if ( pna == NULL ) { D ( " " , na -> name ) ; return 0 ; } na -> na_flags &= ~ NAF_NETMAP_ON ; for_rx_tx ( t ) { if ( mna -> flags & nm_txrx2flag ( t ) ) { for ( i = priv -> np_qfirst [ t ] ; i < priv -> np_qlast [ t ] ; i ++ ) { kring = & NMR ( pna , t ) [ i ] ; mkring = & na -> rx_rings [ i ] ; netmap_monitor_del ( mkring , kring ) ; } } } } return 0 ; }
common functions for the nm_register() callbacks of both kind of
 monitors.
common functions for the nm_register () callbacks of both kind of monitors .
/* parent left netmap mode, fatal */