Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/netmap/netmap_kern.h
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
#define GEN_TX_MBUF_IFP(m) ((m)->m_pkthdr.rcvif) | #define GEN_TX_MBUF_IFP(m) ((m)->m_pkthdr.rcvif) | ||||
#define NM_ATOMIC_T volatile int /* required by atomic/bitops.h */ | #define NM_ATOMIC_T volatile int /* required by atomic/bitops.h */ | ||||
/* atomic operations */ | /* atomic operations */ | ||||
#include <machine/atomic.h> | #include <machine/atomic.h> | ||||
#define NM_ATOMIC_TEST_AND_SET(p) (!atomic_cmpset_acq_int((p), 0, 1)) | #define NM_ATOMIC_TEST_AND_SET(p) (!atomic_cmpset_acq_int((p), 0, 1)) | ||||
#define NM_ATOMIC_CLEAR(p) atomic_store_rel_int((p), 0) | #define NM_ATOMIC_CLEAR(p) atomic_store_rel_int((p), 0) | ||||
#define WNA(_ifp) (_ifp)->if_netmap | #define WNA(_ifp) if_getnetmapadapter(_ifp) | ||||
struct netmap_adapter *netmap_getna(if_t ifp); | struct netmap_adapter *netmap_getna(if_t ifp); | ||||
#define MBUF_REFCNT(m) ((m)->m_ext.ext_count) | #define MBUF_REFCNT(m) ((m)->m_ext.ext_count) | ||||
#define SET_MBUF_REFCNT(m, x) (m)->m_ext.ext_count = x | #define SET_MBUF_REFCNT(m, x) (m)->m_ext.ext_count = x | ||||
#define MBUF_QUEUED(m) 1 | #define MBUF_QUEUED(m) 1 | ||||
Show All 25 Lines | #define MBUF_TRANSMIT(na, ifp, m) \ | ||||
({ \ | ({ \ | ||||
/* Avoid infinite recursion with generic. */ \ | /* Avoid infinite recursion with generic. */ \ | ||||
m->priority = NM_MAGIC_PRIORITY_TX; \ | m->priority = NM_MAGIC_PRIORITY_TX; \ | ||||
(((struct net_device_ops *)(na)->if_transmit)->ndo_start_xmit(m, ifp)); \ | (((struct net_device_ops *)(na)->if_transmit)->ndo_start_xmit(m, ifp)); \ | ||||
0; \ | 0; \ | ||||
}) | }) | ||||
/* See explanation in nm_os_generic_xmit_frame. */ | /* See explanation in nm_os_generic_xmit_frame. */ | ||||
#define GEN_TX_MBUF_IFP(m) ((struct ifnet *)skb_shinfo(m)->destructor_arg) | #define GEN_TX_MBUF_IFP(m) ((if_t)skb_shinfo(m)->destructor_arg) | ||||
#define NM_ATOMIC_T volatile long unsigned int | #define NM_ATOMIC_T volatile long unsigned int | ||||
#define NM_MTX_T struct mutex /* OS-specific sleepable lock */ | #define NM_MTX_T struct mutex /* OS-specific sleepable lock */ | ||||
#define NM_MTX_INIT(m) mutex_init(&(m)) | #define NM_MTX_INIT(m) mutex_init(&(m)) | ||||
#define NM_MTX_DESTROY(m) do { (void)(m); } while (0) | #define NM_MTX_DESTROY(m) do { (void)(m); } while (0) | ||||
#define NM_MTX_LOCK(m) mutex_lock(&(m)) | #define NM_MTX_LOCK(m) mutex_lock(&(m)) | ||||
#define NM_MTX_UNLOCK(m) mutex_unlock(&(m)) | #define NM_MTX_UNLOCK(m) mutex_unlock(&(m)) | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | |||||
void nm_os_selwakeup(NM_SELINFO_T *si); | void nm_os_selwakeup(NM_SELINFO_T *si); | ||||
void nm_os_selrecord(NM_SELRECORD_T *sr, NM_SELINFO_T *si); | void nm_os_selrecord(NM_SELRECORD_T *sr, NM_SELINFO_T *si); | ||||
int nm_os_ifnet_init(void); | int nm_os_ifnet_init(void); | ||||
void nm_os_ifnet_fini(void); | void nm_os_ifnet_fini(void); | ||||
void nm_os_ifnet_lock(void); | void nm_os_ifnet_lock(void); | ||||
void nm_os_ifnet_unlock(void); | void nm_os_ifnet_unlock(void); | ||||
unsigned nm_os_ifnet_mtu(struct ifnet *ifp); | unsigned nm_os_ifnet_mtu(if_t ifp); | ||||
void nm_os_get_module(void); | void nm_os_get_module(void); | ||||
void nm_os_put_module(void); | void nm_os_put_module(void); | ||||
void netmap_make_zombie(struct ifnet *); | void netmap_make_zombie(if_t); | ||||
void netmap_undo_zombie(struct ifnet *); | void netmap_undo_zombie(if_t); | ||||
/* os independent alloc/realloc/free */ | /* os independent alloc/realloc/free */ | ||||
void *nm_os_malloc(size_t); | void *nm_os_malloc(size_t); | ||||
void *nm_os_vmalloc(size_t); | void *nm_os_vmalloc(size_t); | ||||
void *nm_os_realloc(void *, size_t new_size, size_t old_size); | void *nm_os_realloc(void *, size_t new_size, size_t old_size); | ||||
void nm_os_free(void *); | void nm_os_free(void *); | ||||
void nm_os_vfree(void *); | void nm_os_vfree(void *); | ||||
/* os specific attach/detach enter/exit-netmap-mode routines */ | /* os specific attach/detach enter/exit-netmap-mode routines */ | ||||
void nm_os_onattach(struct ifnet *); | void nm_os_onattach(if_t); | ||||
void nm_os_ondetach(struct ifnet *); | void nm_os_ondetach(if_t); | ||||
void nm_os_onenter(struct ifnet *); | void nm_os_onenter(if_t); | ||||
void nm_os_onexit(struct ifnet *); | void nm_os_onexit(if_t); | ||||
/* passes a packet up to the host stack. | /* passes a packet up to the host stack. | ||||
* If the packet is sent (or dropped) immediately it returns NULL, | * If the packet is sent (or dropped) immediately it returns NULL, | ||||
* otherwise it links the packet to prev and returns m. | * otherwise it links the packet to prev and returns m. | ||||
* In this case, a final call with m=NULL and prev != NULL will send up | * In this case, a final call with m=NULL and prev != NULL will send up | ||||
* the entire chain to the host stack. | * the entire chain to the host stack. | ||||
*/ | */ | ||||
void *nm_os_send_up(struct ifnet *, struct mbuf *m, struct mbuf *prev); | void *nm_os_send_up(if_t, struct mbuf *m, struct mbuf *prev); | ||||
int nm_os_mbuf_has_seg_offld(struct mbuf *m); | int nm_os_mbuf_has_seg_offld(struct mbuf *m); | ||||
int nm_os_mbuf_has_csum_offld(struct mbuf *m); | int nm_os_mbuf_has_csum_offld(struct mbuf *m); | ||||
#include "netmap_mbq.h" | #include "netmap_mbq.h" | ||||
extern NMG_LOCK_T netmap_global_lock; | extern NMG_LOCK_T netmap_global_lock; | ||||
▲ Show 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | #define NAF_BUSY (1U<<31) /* the adapter is used internally and | ||||
/* count users of the global wait queues */ | /* count users of the global wait queues */ | ||||
int si_users[NR_TXRX]; | int si_users[NR_TXRX]; | ||||
void *pdev; /* used to store pci device */ | void *pdev; /* used to store pci device */ | ||||
/* copy of if_qflush and if_transmit pointers, to intercept | /* copy of if_qflush and if_transmit pointers, to intercept | ||||
* packets from the network stack when netmap is active. | * packets from the network stack when netmap is active. | ||||
*/ | */ | ||||
int (*if_transmit)(struct ifnet *, struct mbuf *); | int (*if_transmit)(if_t, struct mbuf *); | ||||
/* copy of if_input for netmap_send_up() */ | /* copy of if_input for netmap_send_up() */ | ||||
void (*if_input)(struct ifnet *, struct mbuf *); | void (*if_input)(if_t, struct mbuf *); | ||||
/* Back reference to the parent ifnet struct. Used for | /* Back reference to the parent ifnet struct. Used for | ||||
* hardware ports (emulated netmap included). */ | * hardware ports (emulated netmap included). */ | ||||
struct ifnet *ifp; /* adapter is ifp->if_softc */ | if_t ifp; /* adapter is if_getsoftc(ifp) */ | ||||
/*---- callbacks for this netmap adapter -----*/ | /*---- callbacks for this netmap adapter -----*/ | ||||
/* | /* | ||||
* nm_dtor() is the cleanup routine called when destroying | * nm_dtor() is the cleanup routine called when destroying | ||||
* the adapter. | * the adapter. | ||||
* Called with NMG_LOCK held. | * Called with NMG_LOCK held. | ||||
* | * | ||||
* nm_register() is called on NIOCREGIF and close() to enter | * nm_register() is called on NIOCREGIF and close() to enter | ||||
▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | struct netmap_generic_adapter { /* emulated device */ | ||||
/* Pointer to a previously used netmap adapter. */ | /* Pointer to a previously used netmap adapter. */ | ||||
struct netmap_adapter *prev; | struct netmap_adapter *prev; | ||||
/* Emulated netmap adapters support: | /* Emulated netmap adapters support: | ||||
* - save_if_input saves the if_input hook (FreeBSD); | * - save_if_input saves the if_input hook (FreeBSD); | ||||
* - mit implements rx interrupt mitigation; | * - mit implements rx interrupt mitigation; | ||||
*/ | */ | ||||
void (*save_if_input)(struct ifnet *, struct mbuf *); | void (*save_if_input)(if_t, struct mbuf *); | ||||
struct nm_generic_mit *mit; | struct nm_generic_mit *mit; | ||||
#ifdef linux | #ifdef linux | ||||
netdev_tx_t (*save_start_xmit)(struct mbuf *, struct ifnet *); | netdev_tx_t (*save_start_xmit)(struct mbuf *, if_t); | ||||
#endif | #endif | ||||
/* Is the adapter able to use multiple RX slots to scatter | /* Is the adapter able to use multiple RX slots to scatter | ||||
* each packet pushed up by the driver? */ | * each packet pushed up by the driver? */ | ||||
int rxsg; | int rxsg; | ||||
/* Is the transmission path controlled by a netmap-aware | /* Is the transmission path controlled by a netmap-aware | ||||
* device queue (i.e. qdisc on linux)? */ | * device queue (i.e. qdisc on linux)? */ | ||||
int txqdisc; | int txqdisc; | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | |||||
#define NM_PIPE_ROLE_MASTER 0x1 | #define NM_PIPE_ROLE_MASTER 0x1 | ||||
#define NM_PIPE_ROLE_SLAVE 0x2 | #define NM_PIPE_ROLE_SLAVE 0x2 | ||||
int role; /* either NM_PIPE_ROLE_MASTER or NM_PIPE_ROLE_SLAVE */ | int role; /* either NM_PIPE_ROLE_MASTER or NM_PIPE_ROLE_SLAVE */ | ||||
struct netmap_adapter *parent; /* adapter that owns the memory */ | struct netmap_adapter *parent; /* adapter that owns the memory */ | ||||
struct netmap_pipe_adapter *peer; /* the other end of the pipe */ | struct netmap_pipe_adapter *peer; /* the other end of the pipe */ | ||||
int peer_ref; /* 1 iff we are holding a ref to the peer */ | int peer_ref; /* 1 iff we are holding a ref to the peer */ | ||||
struct ifnet *parent_ifp; /* maybe null */ | if_t parent_ifp; /* maybe null */ | ||||
u_int parent_slot; /* index in the parent pipe array */ | u_int parent_slot; /* index in the parent pipe array */ | ||||
}; | }; | ||||
#endif /* WITH_PIPES */ | #endif /* WITH_PIPES */ | ||||
#ifdef WITH_NMNULL | #ifdef WITH_NMNULL | ||||
struct netmap_null_adapter { | struct netmap_null_adapter { | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | |||||
* the dmamap for a packet buffer | * the dmamap for a packet buffer | ||||
* | * | ||||
* netmap_reset() is a helper routine to be called in the hw driver | * netmap_reset() is a helper routine to be called in the hw driver | ||||
* when reinitializing a ring. It should not be called by | * when reinitializing a ring. It should not be called by | ||||
* virtual ports (vale, pipes, monitor) | * virtual ports (vale, pipes, monitor) | ||||
*/ | */ | ||||
int netmap_attach(struct netmap_adapter *); | int netmap_attach(struct netmap_adapter *); | ||||
int netmap_attach_ext(struct netmap_adapter *, size_t size, int override_reg); | int netmap_attach_ext(struct netmap_adapter *, size_t size, int override_reg); | ||||
void netmap_detach(struct ifnet *); | void netmap_detach(if_t); | ||||
int netmap_transmit(struct ifnet *, struct mbuf *); | int netmap_transmit(if_t, struct mbuf *); | ||||
struct netmap_slot *netmap_reset(struct netmap_adapter *na, | struct netmap_slot *netmap_reset(struct netmap_adapter *na, | ||||
enum txrx tx, u_int n, u_int new_cur); | enum txrx tx, u_int n, u_int new_cur); | ||||
int netmap_ring_reinit(struct netmap_kring *); | int netmap_ring_reinit(struct netmap_kring *); | ||||
int netmap_rings_config_get(struct netmap_adapter *, struct nm_config_info *); | int netmap_rings_config_get(struct netmap_adapter *, struct nm_config_info *); | ||||
/* Return codes for netmap_*x_irq. */ | /* Return codes for netmap_*x_irq. */ | ||||
enum { | enum { | ||||
/* Driver should do normal interrupt processing, e.g. because | /* Driver should do normal interrupt processing, e.g. because | ||||
* the interface is not in netmap mode. */ | * the interface is not in netmap mode. */ | ||||
NM_IRQ_PASS = 0, | NM_IRQ_PASS = 0, | ||||
/* Port is in netmap mode, and the interrupt work has been | /* Port is in netmap mode, and the interrupt work has been | ||||
* completed. The driver does not have to notify netmap | * completed. The driver does not have to notify netmap | ||||
* again before the next interrupt. */ | * again before the next interrupt. */ | ||||
NM_IRQ_COMPLETED = -1, | NM_IRQ_COMPLETED = -1, | ||||
/* Port is in netmap mode, but the interrupt work has not been | /* Port is in netmap mode, but the interrupt work has not been | ||||
* completed. The driver has to make sure netmap will be | * completed. The driver has to make sure netmap will be | ||||
* notified again soon, even if no more interrupts come (e.g. | * notified again soon, even if no more interrupts come (e.g. | ||||
* on Linux the driver should not call napi_complete()). */ | * on Linux the driver should not call napi_complete()). */ | ||||
NM_IRQ_RESCHED = -2, | NM_IRQ_RESCHED = -2, | ||||
}; | }; | ||||
/* default functions to handle rx/tx interrupts */ | /* default functions to handle rx/tx interrupts */ | ||||
int netmap_rx_irq(struct ifnet *, u_int, u_int *); | int netmap_rx_irq(if_t, u_int, u_int *); | ||||
#define netmap_tx_irq(_n, _q) netmap_rx_irq(_n, _q, NULL) | #define netmap_tx_irq(_n, _q) netmap_rx_irq(_n, _q, NULL) | ||||
int netmap_common_irq(struct netmap_adapter *, u_int, u_int *work_done); | int netmap_common_irq(struct netmap_adapter *, u_int, u_int *work_done); | ||||
#ifdef WITH_VALE | #ifdef WITH_VALE | ||||
/* functions used by external modules to interface with VALE */ | /* functions used by external modules to interface with VALE */ | ||||
#define netmap_vp_to_ifp(_vp) ((_vp)->up.ifp) | #define netmap_vp_to_ifp(_vp) ((_vp)->up.ifp) | ||||
#define netmap_ifp_to_vp(_ifp) (NA(_ifp)->na_vp) | #define netmap_ifp_to_vp(_ifp) (NA(_ifp)->na_vp) | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | |||||
* When stopping, they also wait for all current activity on the ring to | * When stopping, they also wait for all current activity on the ring to | ||||
* terminate. The status change is then notified using the na nm_notify | * terminate. The status change is then notified using the na nm_notify | ||||
* callback. | * callback. | ||||
*/ | */ | ||||
void netmap_set_ring(struct netmap_adapter *, u_int ring_id, enum txrx, int stopped); | void netmap_set_ring(struct netmap_adapter *, u_int ring_id, enum txrx, int stopped); | ||||
/* set the stopped/enabled status of all rings of the adapter. */ | /* set the stopped/enabled status of all rings of the adapter. */ | ||||
void netmap_set_all_rings(struct netmap_adapter *, int stopped); | void netmap_set_all_rings(struct netmap_adapter *, int stopped); | ||||
/* convenience wrappers for netmap_set_all_rings */ | /* convenience wrappers for netmap_set_all_rings */ | ||||
void netmap_disable_all_rings(struct ifnet *); | void netmap_disable_all_rings(if_t); | ||||
void netmap_enable_all_rings(struct ifnet *); | void netmap_enable_all_rings(if_t); | ||||
int netmap_buf_size_validate(const struct netmap_adapter *na, unsigned mtu); | int netmap_buf_size_validate(const struct netmap_adapter *na, unsigned mtu); | ||||
int netmap_do_regif(struct netmap_priv_d *priv, struct netmap_adapter *na, | int netmap_do_regif(struct netmap_priv_d *priv, struct netmap_adapter *na, | ||||
struct nmreq_header *); | struct nmreq_header *); | ||||
void netmap_do_unregif(struct netmap_priv_d *priv); | void netmap_do_unregif(struct netmap_priv_d *priv); | ||||
u_int nm_bound_var(u_int *v, u_int dflt, u_int lo, u_int hi, const char *msg); | u_int nm_bound_var(u_int *v, u_int dflt, u_int lo, u_int hi, const char *msg); | ||||
int netmap_get_na(struct nmreq_header *hdr, struct netmap_adapter **na, | int netmap_get_na(struct nmreq_header *hdr, struct netmap_adapter **na, | ||||
struct ifnet **ifp, struct netmap_mem_d *nmd, int create); | if_t *ifp, struct netmap_mem_d *nmd, int create); | ||||
void netmap_unget_na(struct netmap_adapter *na, struct ifnet *ifp); | void netmap_unget_na(struct netmap_adapter *na, if_t ifp); | ||||
int netmap_get_hw_na(struct ifnet *ifp, | int netmap_get_hw_na(if_t ifp, | ||||
struct netmap_mem_d *nmd, struct netmap_adapter **na); | struct netmap_mem_d *nmd, struct netmap_adapter **na); | ||||
void netmap_mem_restore(struct netmap_adapter *na); | void netmap_mem_restore(struct netmap_adapter *na); | ||||
#ifdef WITH_VALE | #ifdef WITH_VALE | ||||
uint32_t netmap_vale_learning(struct nm_bdg_fwd *ft, uint8_t *dst_ring, | uint32_t netmap_vale_learning(struct nm_bdg_fwd *ft, uint8_t *dst_ring, | ||||
struct netmap_vp_adapter *, void *private_data); | struct netmap_vp_adapter *, void *private_data); | ||||
/* these are redefined in case of no VALE support */ | /* these are redefined in case of no VALE support */ | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | |||||
* magic value. The capenable is within the struct netmap_adapter. | * magic value. The capenable is within the struct netmap_adapter. | ||||
*/ | */ | ||||
#define NETMAP_MAGIC 0x52697a7a | #define NETMAP_MAGIC 0x52697a7a | ||||
#define NM_NA_VALID(ifp) (NA(ifp) && \ | #define NM_NA_VALID(ifp) (NA(ifp) && \ | ||||
((uint32_t)(uintptr_t)NA(ifp) ^ NA(ifp)->magic) == NETMAP_MAGIC ) | ((uint32_t)(uintptr_t)NA(ifp) ^ NA(ifp)->magic) == NETMAP_MAGIC ) | ||||
#define NM_ATTACH_NA(ifp, na) do { \ | #define NM_ATTACH_NA(ifp, na) do { \ | ||||
WNA(ifp) = na; \ | if_setnetmapadapter(ifp, na); \ | ||||
if (NA(ifp)) \ | if (NA(ifp)) \ | ||||
NA(ifp)->magic = \ | NA(ifp)->magic = \ | ||||
((uint32_t)(uintptr_t)NA(ifp)) ^ NETMAP_MAGIC; \ | ((uint32_t)(uintptr_t)NA(ifp)) ^ NETMAP_MAGIC; \ | ||||
} while(0) | } while(0) | ||||
#define NM_RESTORE_NA(ifp, na) WNA(ifp) = na; | #define NM_RESTORE_NA(ifp, na) if_setnetmapadapter(ifp, na); | ||||
#define NM_DETACH_NA(ifp) do { WNA(ifp) = NULL; } while (0) | #define NM_DETACH_NA(ifp) do { if_setnetmapadapter(ifp, NULL); } while (0) | ||||
zlei: Style(9). | |||||
#define NM_NA_CLASH(ifp) (NA(ifp) && !NM_NA_VALID(ifp)) | #define NM_NA_CLASH(ifp) (NA(ifp) && !NM_NA_VALID(ifp)) | ||||
#endif /* !NM_ATTACH_NA */ | #endif /* !NM_ATTACH_NA */ | ||||
#define NM_IS_NATIVE(ifp) (NM_NA_VALID(ifp) && NA(ifp)->nm_dtor == netmap_hw_dtor) | #define NM_IS_NATIVE(ifp) (NM_NA_VALID(ifp) && NA(ifp)->nm_dtor == netmap_hw_dtor) | ||||
#if defined(__FreeBSD__) | #if defined(__FreeBSD__) | ||||
▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | |||||
* Read access to the structure is lock free, because ni_nifp once set | * Read access to the structure is lock free, because ni_nifp once set | ||||
* can only go to 0 when nobody is using the entry anymore. Readers | * can only go to 0 when nobody is using the entry anymore. Readers | ||||
* must check that np_nifp != NULL before using the other fields. | * must check that np_nifp != NULL before using the other fields. | ||||
*/ | */ | ||||
struct netmap_priv_d { | struct netmap_priv_d { | ||||
struct netmap_if * volatile np_nifp; /* netmap if descriptor. */ | struct netmap_if * volatile np_nifp; /* netmap if descriptor. */ | ||||
struct netmap_adapter *np_na; | struct netmap_adapter *np_na; | ||||
struct ifnet *np_ifp; | if_t np_ifp; | ||||
Done Inline ActionsSmall nits, align member np_ifp zlei: Small nits, align member `np_ifp` | |||||
uint32_t np_flags; /* from the ioctl */ | uint32_t np_flags; /* from the ioctl */ | ||||
u_int np_qfirst[NR_TXRX], | u_int np_qfirst[NR_TXRX], | ||||
np_qlast[NR_TXRX]; /* range of tx/rx rings to scan */ | np_qlast[NR_TXRX]; /* range of tx/rx rings to scan */ | ||||
uint16_t np_txpoll; | uint16_t np_txpoll; | ||||
uint16_t np_kloop_state; /* use with NMG_LOCK held */ | uint16_t np_kloop_state; /* use with NMG_LOCK held */ | ||||
#define NM_SYNC_KLOOP_RUNNING (1 << 0) | #define NM_SYNC_KLOOP_RUNNING (1 << 0) | ||||
#define NM_SYNC_KLOOP_STOPPING (1 << 1) | #define NM_SYNC_KLOOP_STOPPING (1 << 1) | ||||
int np_sync_flags; /* to be passed to nm_sync */ | int np_sync_flags; /* to be passed to nm_sync */ | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
#endif /* WITH_MONITOR */ | #endif /* WITH_MONITOR */ | ||||
#ifdef WITH_GENERIC | #ifdef WITH_GENERIC | ||||
/* | /* | ||||
* generic netmap emulation for devices that do not have | * generic netmap emulation for devices that do not have | ||||
* native netmap support. | * native netmap support. | ||||
*/ | */ | ||||
int generic_netmap_attach(struct ifnet *ifp); | int generic_netmap_attach(if_t ifp); | ||||
int generic_rx_handler(struct ifnet *ifp, struct mbuf *m); | int generic_rx_handler(if_t ifp, struct mbuf *m); | ||||
int nm_os_catch_rx(struct netmap_generic_adapter *gna, int intercept); | int nm_os_catch_rx(struct netmap_generic_adapter *gna, int intercept); | ||||
int nm_os_catch_tx(struct netmap_generic_adapter *gna, int intercept); | int nm_os_catch_tx(struct netmap_generic_adapter *gna, int intercept); | ||||
int na_is_generic(struct netmap_adapter *na); | int na_is_generic(struct netmap_adapter *na); | ||||
/* | /* | ||||
* the generic transmit routine is passed a structure to optionally | * the generic transmit routine is passed a structure to optionally | ||||
* build a queue of descriptors, in an OS-specific way. | * build a queue of descriptors, in an OS-specific way. | ||||
* The payload is at addr, if non-null, and the routine should send or queue | * The payload is at addr, if non-null, and the routine should send or queue | ||||
* the packet, returning 0 if successful, 1 on failure. | * the packet, returning 0 if successful, 1 on failure. | ||||
* | * | ||||
* At the end, if head is non-null, there will be an additional call | * At the end, if head is non-null, there will be an additional call | ||||
* to the function with addr = NULL; this should tell the OS-specific | * to the function with addr = NULL; this should tell the OS-specific | ||||
* routine to send the queue and free any resources. Failure is ignored. | * routine to send the queue and free any resources. Failure is ignored. | ||||
*/ | */ | ||||
struct nm_os_gen_arg { | struct nm_os_gen_arg { | ||||
struct ifnet *ifp; | if_t ifp; | ||||
void *m; /* os-specific mbuf-like object */ | void *m; /* os-specific mbuf-like object */ | ||||
void *head, *tail; /* tailq, if the OS-specific routine needs to build one */ | void *head, *tail; /* tailq, if the OS-specific routine needs to build one */ | ||||
void *addr; /* payload of current packet */ | void *addr; /* payload of current packet */ | ||||
u_int len; /* packet length */ | u_int len; /* packet length */ | ||||
u_int ring_nr; /* transmit ring index */ | u_int ring_nr; /* transmit ring index */ | ||||
u_int qevent; /* in txqdisc mode, place an event on this mbuf */ | u_int qevent; /* in txqdisc mode, place an event on this mbuf */ | ||||
}; | }; | ||||
int nm_os_generic_xmit_frame(struct nm_os_gen_arg *); | int nm_os_generic_xmit_frame(struct nm_os_gen_arg *); | ||||
int nm_os_generic_find_num_desc(struct ifnet *ifp, u_int *tx, u_int *rx); | int nm_os_generic_find_num_desc(if_t ifp, u_int *tx, u_int *rx); | ||||
void nm_os_generic_find_num_queues(struct ifnet *ifp, u_int *txq, u_int *rxq); | void nm_os_generic_find_num_queues(if_t ifp, u_int *txq, u_int *rxq); | ||||
void nm_os_generic_set_features(struct netmap_generic_adapter *gna); | void nm_os_generic_set_features(struct netmap_generic_adapter *gna); | ||||
static inline struct ifnet* | static inline if_t | ||||
netmap_generic_getifp(struct netmap_generic_adapter *gna) | netmap_generic_getifp(struct netmap_generic_adapter *gna) | ||||
{ | { | ||||
if (gna->prev) | if (gna->prev) | ||||
return gna->prev->ifp; | return gna->prev->ifp; | ||||
return gna->up.up.ifp; | return gna->up.up.ifp; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | |||||
void bdg_mismatch_datapath(struct netmap_vp_adapter *na, | void bdg_mismatch_datapath(struct netmap_vp_adapter *na, | ||||
struct netmap_vp_adapter *dst_na, | struct netmap_vp_adapter *dst_na, | ||||
const struct nm_bdg_fwd *ft_p, | const struct nm_bdg_fwd *ft_p, | ||||
struct netmap_ring *dst_ring, | struct netmap_ring *dst_ring, | ||||
u_int *j, u_int lim, u_int *howmany); | u_int *j, u_int lim, u_int *howmany); | ||||
/* persistent virtual port routines */ | /* persistent virtual port routines */ | ||||
int nm_os_vi_persist(const char *, struct ifnet **); | int nm_os_vi_persist(const char *, if_t *); | ||||
void nm_os_vi_detach(struct ifnet *); | void nm_os_vi_detach(if_t); | ||||
void nm_os_vi_init_index(void); | void nm_os_vi_init_index(void); | ||||
/* | /* | ||||
* kernel thread routines | * kernel thread routines | ||||
*/ | */ | ||||
struct nm_kctx; /* OS-specific kernel context - opaque */ | struct nm_kctx; /* OS-specific kernel context - opaque */ | ||||
typedef void (*nm_kctx_worker_fn_t)(void *data); | typedef void (*nm_kctx_worker_fn_t)(void *data); | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
static void void_mbuf_dtor(struct mbuf *m) { } | static void void_mbuf_dtor(struct mbuf *m) { } | ||||
#define SET_MBUF_DESTRUCTOR(m, fn) do { \ | #define SET_MBUF_DESTRUCTOR(m, fn) do { \ | ||||
(m)->m_ext.ext_free = (fn != NULL) ? \ | (m)->m_ext.ext_free = (fn != NULL) ? \ | ||||
(void *)fn : (void *)void_mbuf_dtor; \ | (void *)fn : (void *)void_mbuf_dtor; \ | ||||
} while (0) | } while (0) | ||||
static inline struct mbuf * | static inline struct mbuf * | ||||
nm_os_get_mbuf(struct ifnet *ifp, int len) | nm_os_get_mbuf(if_t ifp, int len) | ||||
{ | { | ||||
struct mbuf *m; | struct mbuf *m; | ||||
(void)ifp; | (void)ifp; | ||||
(void)len; | (void)len; | ||||
m = m_gethdr(M_NOWAIT, MT_DATA); | m = m_gethdr(M_NOWAIT, MT_DATA); | ||||
if (m == NULL) { | if (m == NULL) { | ||||
Show All 37 Lines |
Style(9).