git: 6c9fe357435d - main - netmap: get rid of save_if_input for emulated adapters
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Mar 2023 22:04:44 UTC
The branch main has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=6c9fe357435db6408ec6b01221b9ff9e7e9b0ff1 commit 6c9fe357435db6408ec6b01221b9ff9e7e9b0ff1 Author: Vincenzo Maffione <vmaffione@FreeBSD.org> AuthorDate: 2023-03-14 21:59:23 +0000 Commit: Vincenzo Maffione <vmaffione@FreeBSD.org> CommitDate: 2023-03-14 22:04:23 +0000 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 --- sys/dev/netmap/netmap_freebsd.c | 20 ++------------------ sys/dev/netmap/netmap_kern.h | 3 --- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c index 296c37576407..4b3b1a6edacd 100644 --- a/sys/dev/netmap/netmap_freebsd.c +++ b/sys/dev/netmap/netmap_freebsd.c @@ -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; diff --git a/sys/dev/netmap/netmap_kern.h b/sys/dev/netmap/netmap_kern.h index c34733f912fd..7c68c79c61ef 100644 --- a/sys/dev/netmap/netmap_kern.h +++ b/sys/dev/netmap/netmap_kern.h @@ -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);