netmap: get rid of save_if_input for emulated adapters
The save_if_input function pointer was meant to save the previous value of ifp->if_input before replacing it with the emulated adapter hook. However, the same pointer value is already stored in the if_input field of the netmap_adapter struct, to be used for host TX ring processing. Reuse the netmap_adapter if_input field to simplify the code and save some space. MFC after: 14 days
This commit is contained in:
parent
fb9480671b
commit
b0c1a8adbf
sys/dev/netmap
@ -327,9 +327,7 @@ freebsd_generic_rx_handler(if_t ifp, struct mbuf *m)
|
||||
|
||||
stolen = generic_rx_handler(ifp, m);
|
||||
if (!stolen) {
|
||||
struct netmap_generic_adapter *gna =
|
||||
(struct netmap_generic_adapter *)NA(ifp);
|
||||
gna->save_if_input(ifp, m);
|
||||
NA(ifp)->if_input(ifp, m);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,26 +344,12 @@ nm_os_catch_rx(struct netmap_generic_adapter *gna, int intercept)
|
||||
|
||||
nm_os_ifnet_lock();
|
||||
if (intercept) {
|
||||
if (gna->save_if_input) {
|
||||
nm_prerr("RX on %s already intercepted", na->name);
|
||||
ret = EBUSY; /* already set */
|
||||
goto out;
|
||||
}
|
||||
if_setcapenablebit(ifp, IFCAP_NETMAP, 0);
|
||||
gna->save_if_input = if_getinputfn(ifp);
|
||||
if_setinputfn(ifp, freebsd_generic_rx_handler);
|
||||
} else {
|
||||
if (!gna->save_if_input) {
|
||||
nm_prerr("Failed to undo RX intercept on %s",
|
||||
na->name);
|
||||
ret = EINVAL; /* not saved */
|
||||
goto out;
|
||||
}
|
||||
if_setcapenablebit(ifp, 0, IFCAP_NETMAP);
|
||||
if_setinputfn(ifp, gna->save_if_input);
|
||||
gna->save_if_input = NULL;
|
||||
if_setinputfn(ifp, na->if_input);
|
||||
}
|
||||
out:
|
||||
nm_os_ifnet_unlock();
|
||||
|
||||
return ret;
|
||||
|
@ -1042,11 +1042,8 @@ struct netmap_generic_adapter { /* emulated device */
|
||||
struct netmap_adapter *prev;
|
||||
|
||||
/* Emulated netmap adapters support:
|
||||
* - save_if_input saves the if_input hook (FreeBSD);
|
||||
* - mit implements rx interrupt mitigation;
|
||||
*/
|
||||
void (*save_if_input)(if_t, struct mbuf *);
|
||||
|
||||
struct nm_generic_mit *mit;
|
||||
#ifdef linux
|
||||
netdev_tx_t (*save_start_xmit)(struct mbuf *, if_t);
|
||||
|
Loading…
x
Reference in New Issue
Block a user