From 4bf50f18eb272037afaa212738f3d82d4098e782 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Sat, 16 Aug 2014 15:00:01 +0000 Subject: Update to the current version of netmap. Mostly bugfixes or features developed in the past 6 months, so this is a 10.1 candidate. Basically no user API changes (some bugfixes in sys/net/netmap_user.h). In detail: 1. netmap support for virtio-net, including in netmap mode. Under bhyve and with a netmap backend [2] we reach over 1Mpps with standard APIs (e.g. libpcap), and 5-8 Mpps in netmap mode. 2. (kernel) add support for multiple memory allocators, so we can better partition physical and virtual interfaces giving access to separate users. The most visible effect is one additional argument to the various kernel functions to compute buffer addresses. All netmap-supported drivers are affected, but changes are mechanical and trivial 3. (kernel) simplify the prototype for *txsync() and *rxsync() driver methods. All netmap drivers affected, changes mostly mechanical. 4. add support for netmap-monitor ports. Think of it as a mirroring port on a physical switch: a netmap monitor port replicates traffic present on the main port. Restrictions apply. Drive carefully. 5. if_lem.c: support for various paravirtualization features, experimental and disabled by default. Most of these are described in our ANCS'13 paper [1]. Paravirtualized support in netmap mode is new, and beats the numbers in the paper by a large factor (under qemu-kvm, we measured gues-host throughput up to 10-12 Mpps). A lot of refactoring and additional documentation in the files in sys/dev/netmap, but apart from #2 and #3 above, almost nothing of this stuff is visible to other kernel parts. Example programs in tools/tools/netmap have been updated with bugfixes and to support more of the existing features. This is meant to go into 10.1 so we plan an MFC before the Aug.22 deadline. A lot of this code has been contributed by my colleagues at UNIPI, including Giuseppe Lettieri, Vincenzo Maffione, Stefano Garzarella. MFC after: 3 days. --- sys/dev/netmap/netmap_mem2.h | 98 ++++---------------------------------------- 1 file changed, 8 insertions(+), 90 deletions(-) (limited to 'sys/dev/netmap/netmap_mem2.h') diff --git a/sys/dev/netmap/netmap_mem2.h b/sys/dev/netmap/netmap_mem2.h index e83616a5195f5..4c620bd4a780b 100644 --- a/sys/dev/netmap/netmap_mem2.h +++ b/sys/dev/netmap/netmap_mem2.h @@ -97,70 +97,6 @@ #define _NET_NETMAP_MEM2_H_ -#define NETMAP_BUF_MAX_NUM 20*4096*2 /* large machine */ - -#define NETMAP_POOL_MAX_NAMSZ 32 - - -enum { - NETMAP_IF_POOL = 0, - NETMAP_RING_POOL, - NETMAP_BUF_POOL, - NETMAP_POOLS_NR -}; - - -struct netmap_obj_params { - u_int size; - u_int num; -}; -struct netmap_obj_pool { - char name[NETMAP_POOL_MAX_NAMSZ]; /* name of the allocator */ - - /* ---------------------------------------------------*/ - /* these are only meaningful if the pool is finalized */ - /* (see 'finalized' field in netmap_mem_d) */ - u_int objtotal; /* actual total number of objects. */ - u_int memtotal; /* actual total memory space */ - u_int numclusters; /* actual number of clusters */ - - u_int objfree; /* number of free objects. */ - - struct lut_entry *lut; /* virt,phys addresses, objtotal entries */ - uint32_t *bitmap; /* one bit per buffer, 1 means free */ - uint32_t bitmap_slots; /* number of uint32 entries in bitmap */ - /* ---------------------------------------------------*/ - - /* limits */ - u_int objminsize; /* minimum object size */ - u_int objmaxsize; /* maximum object size */ - u_int nummin; /* minimum number of objects */ - u_int nummax; /* maximum number of objects */ - - /* these are changed only by config */ - u_int _objtotal; /* total number of objects */ - u_int _objsize; /* object size */ - u_int _clustsize; /* cluster size */ - u_int _clustentries; /* objects per cluster */ - u_int _numclusters; /* number of clusters */ - - /* requested values */ - u_int r_objtotal; - u_int r_objsize; -}; - -#ifdef linux -// XXX a mtx would suffice here 20130415 lr -#define NMA_LOCK_T struct semaphore -#else /* !linux */ -#define NMA_LOCK_T struct mtx -#endif /* linux */ - -typedef int (*netmap_mem_config_t)(struct netmap_mem_d*); -typedef int (*netmap_mem_finalize_t)(struct netmap_mem_d*); -typedef void (*netmap_mem_deref_t)(struct netmap_mem_d*); - -typedef uint16_t nm_memid_t; /* We implement two kinds of netmap_mem_d structures: * @@ -178,40 +114,21 @@ typedef uint16_t nm_memid_t; * are no active users. By 'active user' we mean an existing netmap_priv * structure holding a reference to the allocator. */ -struct netmap_mem_d { - NMA_LOCK_T nm_mtx; /* protect the allocator */ - u_int nm_totalsize; /* shorthand */ - - u_int flags; -#define NETMAP_MEM_FINALIZED 0x1 /* preallocation done */ -#define NETMAP_MEM_PRIVATE 0x2 /* uses private address space */ - int lasterr; /* last error for curr config */ - int refcount; /* existing priv structures */ - /* the three allocators */ - struct netmap_obj_pool pools[NETMAP_POOLS_NR]; - - netmap_mem_config_t config; - netmap_mem_finalize_t finalize; - netmap_mem_deref_t deref; - - nm_memid_t nm_id; /* allocator identifier */ - - /* list of all existing allocators, sorted by nm_id */ - struct netmap_mem_d *prev, *next; -}; extern struct netmap_mem_d nm_mem; +struct lut_entry* netmap_mem_get_lut(struct netmap_mem_d *); +u_int netmap_mem_get_buftotal(struct netmap_mem_d *); +size_t netmap_mem_get_bufsize(struct netmap_mem_d *); vm_paddr_t netmap_mem_ofstophys(struct netmap_mem_d *, vm_ooffset_t); -int netmap_mem_finalize(struct netmap_mem_d *); +int netmap_mem_finalize(struct netmap_mem_d *, struct netmap_adapter *); int netmap_mem_init(void); void netmap_mem_fini(void); -struct netmap_if * - netmap_mem_if_new(const char *, struct netmap_adapter *); +struct netmap_if * netmap_mem_if_new(struct netmap_adapter *); void netmap_mem_if_delete(struct netmap_adapter *, struct netmap_if *); int netmap_mem_rings_create(struct netmap_adapter *); void netmap_mem_rings_delete(struct netmap_adapter *); -void netmap_mem_deref(struct netmap_mem_d *); +void netmap_mem_deref(struct netmap_mem_d *, struct netmap_adapter *); int netmap_mem_get_info(struct netmap_mem_d *, u_int *size, u_int *memflags, uint16_t *id); ssize_t netmap_mem_if_offset(struct netmap_mem_d *, const void *vaddr); struct netmap_mem_d* netmap_mem_private_new(const char *name, @@ -219,7 +136,8 @@ struct netmap_mem_d* netmap_mem_private_new(const char *name, int* error); void netmap_mem_private_delete(struct netmap_mem_d *); -#define NETMAP_BDG_BUF_SIZE(n) ((n)->pools[NETMAP_BUF_POOL]._objsize) +#define NETMAP_MEM_PRIVATE 0x2 /* allocator uses private address space */ +#define NETMAP_MEM_IO 0x4 /* the underlying memory is mmapped I/O */ uint32_t netmap_extra_alloc(struct netmap_adapter *, uint32_t *, uint32_t n); -- cgit v1.3