2012-04-13 16:32:33 +00:00
|
|
|
/*
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
* Copyright (C) 2012-2014 Matteo Landi
|
|
|
|
* Copyright (C) 2012-2016 Luigi Rizzo
|
|
|
|
* Copyright (C) 2012-2016 Giuseppe Lettieri
|
|
|
|
* All rights reserved.
|
2012-04-13 16:32:33 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
2013-12-15 08:37:24 +00:00
|
|
|
* documentation and/or other materials provided with the distribution.
|
2012-04-13 16:32:33 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
#ifdef linux
|
|
|
|
#include "bsd_glue.h"
|
|
|
|
#endif /* linux */
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include "osx_glue.h"
|
|
|
|
#endif /* __APPLE__ */
|
|
|
|
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <sys/cdefs.h> /* prerequisite */
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/malloc.h>
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#include <sys/kernel.h> /* MALLOC_DEFINE */
|
2013-11-01 21:21:14 +00:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <vm/vm.h> /* vtophys */
|
|
|
|
#include <vm/pmap.h> /* vtophys */
|
|
|
|
#include <sys/socket.h> /* sockaddrs */
|
|
|
|
#include <sys/selinfo.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_var.h>
|
|
|
|
#include <net/vnet.h>
|
|
|
|
#include <machine/bus.h> /* bus_dmamap_* */
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
/* M_NETMAP only used in here */
|
|
|
|
MALLOC_DECLARE(M_NETMAP);
|
|
|
|
MALLOC_DEFINE(M_NETMAP, "netmap", "Network memory map");
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
#endif /* __FreeBSD__ */
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <win_glue.h>
|
|
|
|
#endif
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
#include <net/netmap.h>
|
|
|
|
#include <dev/netmap/netmap_kern.h>
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#include <net/netmap_virt.h>
|
2013-11-01 21:21:14 +00:00
|
|
|
#include "netmap_mem2.h"
|
2012-04-13 16:32:33 +00:00
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#ifdef _WIN32_USE_SMALL_GENERIC_DEVICES_MEMORY
|
|
|
|
#define NETMAP_BUF_MAX_NUM 8*4096 /* if too big takes too much time to allocate */
|
|
|
|
#else
|
|
|
|
#define NETMAP_BUF_MAX_NUM 20*4096*2 /* large machine */
|
|
|
|
#endif
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
|
|
|
|
#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;
|
|
|
|
};
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
#define NMA_LOCK_T NM_MTX_T
|
|
|
|
|
|
|
|
|
|
|
|
struct netmap_mem_ops {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
int (*nmd_get_lut)(struct netmap_mem_d *, struct netmap_lut*);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
int (*nmd_get_info)(struct netmap_mem_d *, u_int *size,
|
|
|
|
u_int *memflags, uint16_t *id);
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
vm_paddr_t (*nmd_ofstophys)(struct netmap_mem_d *, vm_ooffset_t);
|
|
|
|
int (*nmd_config)(struct netmap_mem_d *);
|
|
|
|
int (*nmd_finalize)(struct netmap_mem_d *);
|
|
|
|
void (*nmd_deref)(struct netmap_mem_d *);
|
|
|
|
ssize_t (*nmd_if_offset)(struct netmap_mem_d *, const void *vaddr);
|
|
|
|
void (*nmd_delete)(struct netmap_mem_d *);
|
|
|
|
|
|
|
|
struct netmap_if * (*nmd_if_new)(struct netmap_adapter *);
|
|
|
|
void (*nmd_if_delete)(struct netmap_adapter *, struct netmap_if *);
|
|
|
|
int (*nmd_rings_create)(struct netmap_adapter *);
|
|
|
|
void (*nmd_rings_delete)(struct netmap_adapter *);
|
|
|
|
};
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
|
|
|
|
typedef uint16_t nm_memid_t;
|
|
|
|
|
|
|
|
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 */
|
|
|
|
int lasterr; /* last error for curr config */
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
int active; /* active users */
|
|
|
|
int refcount;
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
/* the three allocators */
|
|
|
|
struct netmap_obj_pool pools[NETMAP_POOLS_NR];
|
|
|
|
|
|
|
|
nm_memid_t nm_id; /* allocator identifier */
|
|
|
|
int nm_grp; /* iommu groupd id */
|
|
|
|
|
|
|
|
/* list of all existing allocators, sorted by nm_id */
|
|
|
|
struct netmap_mem_d *prev, *next;
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
|
|
|
|
struct netmap_mem_ops *ops;
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
};
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
/*
|
|
|
|
* XXX need to fix the case of t0 == void
|
|
|
|
*/
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
#define NMD_DEFCB(t0, name) \
|
|
|
|
t0 \
|
|
|
|
netmap_mem_##name(struct netmap_mem_d *nmd) \
|
|
|
|
{ \
|
|
|
|
return nmd->ops->nmd_##name(nmd); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NMD_DEFCB1(t0, name, t1) \
|
|
|
|
t0 \
|
|
|
|
netmap_mem_##name(struct netmap_mem_d *nmd, t1 a1) \
|
|
|
|
{ \
|
|
|
|
return nmd->ops->nmd_##name(nmd, a1); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NMD_DEFCB3(t0, name, t1, t2, t3) \
|
|
|
|
t0 \
|
|
|
|
netmap_mem_##name(struct netmap_mem_d *nmd, t1 a1, t2 a2, t3 a3) \
|
|
|
|
{ \
|
|
|
|
return nmd->ops->nmd_##name(nmd, a1, a2, a3); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NMD_DEFNACB(t0, name) \
|
|
|
|
t0 \
|
|
|
|
netmap_mem_##name(struct netmap_adapter *na) \
|
|
|
|
{ \
|
|
|
|
return na->nm_mem->ops->nmd_##name(na); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NMD_DEFNACB1(t0, name, t1) \
|
|
|
|
t0 \
|
|
|
|
netmap_mem_##name(struct netmap_adapter *na, t1 a1) \
|
|
|
|
{ \
|
|
|
|
return na->nm_mem->ops->nmd_##name(na, a1); \
|
|
|
|
}
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
NMD_DEFCB1(int, get_lut, struct netmap_lut *);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
NMD_DEFCB3(int, get_info, u_int *, u_int *, uint16_t *);
|
|
|
|
NMD_DEFCB1(vm_paddr_t, ofstophys, vm_ooffset_t);
|
|
|
|
static int netmap_mem_config(struct netmap_mem_d *);
|
|
|
|
NMD_DEFCB(int, config);
|
|
|
|
NMD_DEFCB1(ssize_t, if_offset, const void *);
|
|
|
|
NMD_DEFCB(void, delete);
|
|
|
|
|
|
|
|
NMD_DEFNACB(struct netmap_if *, if_new);
|
|
|
|
NMD_DEFNACB1(void, if_delete, struct netmap_if *);
|
|
|
|
NMD_DEFNACB(int, rings_create);
|
|
|
|
NMD_DEFNACB(void, rings_delete);
|
|
|
|
|
|
|
|
static int netmap_mem_map(struct netmap_obj_pool *, struct netmap_adapter *);
|
|
|
|
static int netmap_mem_unmap(struct netmap_obj_pool *, struct netmap_adapter *);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
static int nm_mem_assign_group(struct netmap_mem_d *, struct device *);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
|
|
|
|
#define NMA_LOCK_INIT(n) NM_MTX_INIT((n)->nm_mtx)
|
|
|
|
#define NMA_LOCK_DESTROY(n) NM_MTX_DESTROY((n)->nm_mtx)
|
|
|
|
#define NMA_LOCK(n) NM_MTX_LOCK((n)->nm_mtx)
|
|
|
|
#define NMA_UNLOCK(n) NM_MTX_UNLOCK((n)->nm_mtx)
|
|
|
|
|
|
|
|
#ifdef NM_DEBUG_MEM_PUTGET
|
|
|
|
#define NM_DBG_REFC(nmd, func, line) \
|
|
|
|
printf("%s:%d mem[%d] -> %d\n", func, line, (nmd)->nm_id, (nmd)->refcount);
|
|
|
|
#else
|
|
|
|
#define NM_DBG_REFC(nmd, func, line)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NM_DEBUG_MEM_PUTGET
|
|
|
|
void __netmap_mem_get(struct netmap_mem_d *nmd, const char *func, int line)
|
|
|
|
#else
|
|
|
|
void netmap_mem_get(struct netmap_mem_d *nmd)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
nmd->refcount++;
|
|
|
|
NM_DBG_REFC(nmd, func, line);
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NM_DEBUG_MEM_PUTGET
|
|
|
|
void __netmap_mem_put(struct netmap_mem_d *nmd, const char *func, int line)
|
|
|
|
#else
|
|
|
|
void netmap_mem_put(struct netmap_mem_d *nmd)
|
|
|
|
#endif
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
int last;
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
last = (--nmd->refcount == 0);
|
|
|
|
NM_DBG_REFC(nmd, func, line);
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
if (last)
|
|
|
|
netmap_mem_delete(nmd);
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
int
|
|
|
|
netmap_mem_finalize(struct netmap_mem_d *nmd, struct netmap_adapter *na)
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
if (nm_mem_assign_group(nmd, na->pdev) < 0) {
|
|
|
|
return ENOMEM;
|
|
|
|
} else {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
NMA_LOCK(nmd);
|
|
|
|
nmd->lasterr = nmd->ops->nmd_finalize(nmd);
|
|
|
|
NMA_UNLOCK(nmd);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!nmd->lasterr && na->pdev)
|
|
|
|
netmap_mem_map(&nmd->pools[NETMAP_BUF_POOL], na);
|
|
|
|
|
|
|
|
return nmd->lasterr;
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
void
|
|
|
|
netmap_mem_deref(struct netmap_mem_d *nmd, struct netmap_adapter *na)
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
NMA_LOCK(nmd);
|
|
|
|
netmap_mem_unmap(&nmd->pools[NETMAP_BUF_POOL], na);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (nmd->active == 1) {
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the allocator when it falls out of use so that any
|
|
|
|
* pool resources leaked by unclean application exits are
|
|
|
|
* reclaimed.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
struct netmap_obj_pool *p;
|
|
|
|
u_int j;
|
|
|
|
|
|
|
|
p = &nmd->pools[i];
|
|
|
|
p->objfree = p->objtotal;
|
|
|
|
/*
|
|
|
|
* Reproduce the net effect of the M_ZERO malloc()
|
|
|
|
* and marking of free entries in the bitmap that
|
|
|
|
* occur in finalize_obj_allocator()
|
|
|
|
*/
|
|
|
|
memset(p->bitmap,
|
|
|
|
'\0',
|
|
|
|
sizeof(uint32_t) * ((p->objtotal + 31) / 32));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set all the bits in the bitmap that have
|
|
|
|
* corresponding buffers to 1 to indicate they are
|
|
|
|
* free.
|
|
|
|
*/
|
|
|
|
for (j = 0; j < p->objtotal; j++) {
|
|
|
|
if (p->lut[j].vaddr != NULL) {
|
|
|
|
p->bitmap[ (j>>5) ] |= ( 1 << (j & 31) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Per netmap_mem_finalize_all(),
|
|
|
|
* buffers 0 and 1 are reserved
|
|
|
|
*/
|
|
|
|
nmd->pools[NETMAP_BUF_POOL].objfree -= 2;
|
|
|
|
if (nmd->pools[NETMAP_BUF_POOL].bitmap) {
|
|
|
|
/* XXX This check is a workaround that prevents a
|
|
|
|
* NULL pointer crash which currently happens only
|
2016-10-27 09:46:22 +00:00
|
|
|
* with ptnetmap guests.
|
|
|
|
* Removed shared-info --> is the bug still there? */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
nmd->pools[NETMAP_BUF_POOL].bitmap[0] = ~3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nmd->ops->nmd_deref(nmd);
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
NMA_UNLOCK(nmd);
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
}
|
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
/* accessor functions */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
static int
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
netmap_mem2_get_lut(struct netmap_mem_d *nmd, struct netmap_lut *lut)
|
|
|
|
{
|
|
|
|
lut->lut = nmd->pools[NETMAP_BUF_POOL].lut;
|
|
|
|
lut->objtotal = nmd->pools[NETMAP_BUF_POOL].objtotal;
|
|
|
|
lut->objsize = nmd->pools[NETMAP_BUF_POOL]._objsize;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
|
|
|
return 0;
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
static struct netmap_obj_params netmap_params[NETMAP_POOLS_NR] = {
|
2012-10-19 04:13:12 +00:00
|
|
|
[NETMAP_IF_POOL] = {
|
|
|
|
.size = 1024,
|
|
|
|
.num = 100,
|
|
|
|
},
|
|
|
|
[NETMAP_RING_POOL] = {
|
|
|
|
.size = 9*PAGE_SIZE,
|
|
|
|
.num = 200,
|
|
|
|
},
|
|
|
|
[NETMAP_BUF_POOL] = {
|
|
|
|
.size = 2048,
|
|
|
|
.num = NETMAP_BUF_MAX_NUM,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
static struct netmap_obj_params netmap_min_priv_params[NETMAP_POOLS_NR] = {
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
[NETMAP_IF_POOL] = {
|
|
|
|
.size = 1024,
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
.num = 2,
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
},
|
|
|
|
[NETMAP_RING_POOL] = {
|
|
|
|
.size = 5*PAGE_SIZE,
|
|
|
|
.num = 4,
|
|
|
|
},
|
|
|
|
[NETMAP_BUF_POOL] = {
|
|
|
|
.size = 2048,
|
|
|
|
.num = 4098,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-04-19 21:08:21 +00:00
|
|
|
/*
|
|
|
|
* nm_mem is the memory allocator used for all physical interfaces
|
|
|
|
* running in netmap mode.
|
|
|
|
* Virtual (VALE) ports will have each its own allocator.
|
|
|
|
*/
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
extern struct netmap_mem_ops netmap_mem_global_ops; /* forward */
|
2013-11-01 21:21:14 +00:00
|
|
|
struct netmap_mem_d nm_mem = { /* Our memory allocator. */
|
2012-10-19 04:13:12 +00:00
|
|
|
.pools = {
|
|
|
|
[NETMAP_IF_POOL] = {
|
|
|
|
.name = "netmap_if",
|
|
|
|
.objminsize = sizeof(struct netmap_if),
|
|
|
|
.objmaxsize = 4096,
|
|
|
|
.nummin = 10, /* don't be stingy */
|
|
|
|
.nummax = 10000, /* XXX very large */
|
|
|
|
},
|
|
|
|
[NETMAP_RING_POOL] = {
|
|
|
|
.name = "netmap_ring",
|
|
|
|
.objminsize = sizeof(struct netmap_ring),
|
|
|
|
.objmaxsize = 32*PAGE_SIZE,
|
|
|
|
.nummin = 2,
|
|
|
|
.nummax = 1024,
|
|
|
|
},
|
|
|
|
[NETMAP_BUF_POOL] = {
|
|
|
|
.name = "netmap_buf",
|
|
|
|
.objminsize = 64,
|
|
|
|
.objmaxsize = 65536,
|
|
|
|
.nummin = 4,
|
|
|
|
.nummax = 1000000, /* one million! */
|
|
|
|
},
|
|
|
|
},
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
|
|
|
.nm_id = 1,
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
.nm_grp = -1,
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
|
|
|
.prev = &nm_mem,
|
|
|
|
.next = &nm_mem,
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
|
|
|
|
.ops = &netmap_mem_global_ops
|
2012-04-13 16:32:33 +00:00
|
|
|
};
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
static struct netmap_mem_d *netmap_last_mem_d = &nm_mem;
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
/* blueprint for the private memory allocators */
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
extern struct netmap_mem_ops netmap_mem_private_ops; /* forward */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
/* XXX clang is not happy about using name as a print format */
|
|
|
|
static const struct netmap_mem_d nm_blueprint = {
|
2013-11-01 21:21:14 +00:00
|
|
|
.pools = {
|
|
|
|
[NETMAP_IF_POOL] = {
|
|
|
|
.name = "%s_if",
|
|
|
|
.objminsize = sizeof(struct netmap_if),
|
|
|
|
.objmaxsize = 4096,
|
|
|
|
.nummin = 1,
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
.nummax = 100,
|
2013-11-01 21:21:14 +00:00
|
|
|
},
|
|
|
|
[NETMAP_RING_POOL] = {
|
|
|
|
.name = "%s_ring",
|
|
|
|
.objminsize = sizeof(struct netmap_ring),
|
|
|
|
.objmaxsize = 32*PAGE_SIZE,
|
|
|
|
.nummin = 2,
|
|
|
|
.nummax = 1024,
|
|
|
|
},
|
|
|
|
[NETMAP_BUF_POOL] = {
|
|
|
|
.name = "%s_buf",
|
|
|
|
.objminsize = 64,
|
|
|
|
.objmaxsize = 65536,
|
|
|
|
.nummin = 4,
|
|
|
|
.nummax = 1000000, /* one million! */
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
.flags = NETMAP_MEM_PRIVATE,
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
|
|
|
|
.ops = &netmap_mem_private_ops
|
2013-11-01 21:21:14 +00:00
|
|
|
};
|
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/* memory allocator related sysctls */
|
|
|
|
|
|
|
|
#define STRINGIFY(x) #x
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
#define DECLARE_SYSCTLS(id, name) \
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
SYSBEGIN(mem2_ ## name); \
|
2012-10-19 04:13:12 +00:00
|
|
|
SYSCTL_INT(_dev_netmap, OID_AUTO, name##_size, \
|
|
|
|
CTLFLAG_RW, &netmap_params[id].size, 0, "Requested size of netmap " STRINGIFY(name) "s"); \
|
2013-12-15 08:37:24 +00:00
|
|
|
SYSCTL_INT(_dev_netmap, OID_AUTO, name##_curr_size, \
|
|
|
|
CTLFLAG_RD, &nm_mem.pools[id]._objsize, 0, "Current size of netmap " STRINGIFY(name) "s"); \
|
|
|
|
SYSCTL_INT(_dev_netmap, OID_AUTO, name##_num, \
|
|
|
|
CTLFLAG_RW, &netmap_params[id].num, 0, "Requested number of netmap " STRINGIFY(name) "s"); \
|
|
|
|
SYSCTL_INT(_dev_netmap, OID_AUTO, name##_curr_num, \
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
CTLFLAG_RD, &nm_mem.pools[id].objtotal, 0, "Current number of netmap " STRINGIFY(name) "s"); \
|
|
|
|
SYSCTL_INT(_dev_netmap, OID_AUTO, priv_##name##_size, \
|
|
|
|
CTLFLAG_RW, &netmap_min_priv_params[id].size, 0, \
|
|
|
|
"Default size of private netmap " STRINGIFY(name) "s"); \
|
|
|
|
SYSCTL_INT(_dev_netmap, OID_AUTO, priv_##name##_num, \
|
|
|
|
CTLFLAG_RW, &netmap_min_priv_params[id].num, 0, \
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
"Default number of private netmap " STRINGIFY(name) "s"); \
|
|
|
|
SYSEND
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2016-10-21 13:51:47 +00:00
|
|
|
SYSCTL_DECL(_dev_netmap);
|
2012-10-19 04:13:12 +00:00
|
|
|
DECLARE_SYSCTLS(NETMAP_IF_POOL, if);
|
|
|
|
DECLARE_SYSCTLS(NETMAP_RING_POOL, ring);
|
|
|
|
DECLARE_SYSCTLS(NETMAP_BUF_POOL, buf);
|
2012-04-13 16:32:33 +00:00
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
/* call with NMA_LOCK(&nm_mem) held */
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
static int
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
nm_mem_assign_id_locked(struct netmap_mem_d *nmd)
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
{
|
|
|
|
nm_memid_t id;
|
|
|
|
struct netmap_mem_d *scan = netmap_last_mem_d;
|
|
|
|
int error = ENOMEM;
|
|
|
|
|
|
|
|
do {
|
|
|
|
/* we rely on unsigned wrap around */
|
|
|
|
id = scan->nm_id + 1;
|
|
|
|
if (id == 0) /* reserve 0 as error value */
|
|
|
|
id = 1;
|
|
|
|
scan = scan->next;
|
|
|
|
if (id != scan->nm_id) {
|
|
|
|
nmd->nm_id = id;
|
|
|
|
nmd->prev = scan->prev;
|
|
|
|
nmd->next = scan;
|
|
|
|
scan->prev->next = nmd;
|
|
|
|
scan->prev = nmd;
|
|
|
|
netmap_last_mem_d = nmd;
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (scan != netmap_last_mem_d);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
/* call with NMA_LOCK(&nm_mem) *not* held */
|
|
|
|
static int
|
|
|
|
nm_mem_assign_id(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
NMA_LOCK(&nm_mem);
|
|
|
|
ret = nm_mem_assign_id_locked(nmd);
|
|
|
|
NMA_UNLOCK(&nm_mem);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
static void
|
|
|
|
nm_mem_release_id(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
NMA_LOCK(&nm_mem);
|
|
|
|
|
|
|
|
nmd->prev->next = nmd->next;
|
|
|
|
nmd->next->prev = nmd->prev;
|
|
|
|
|
|
|
|
if (netmap_last_mem_d == nmd)
|
|
|
|
netmap_last_mem_d = nmd->prev;
|
|
|
|
|
|
|
|
nmd->prev = nmd->next = NULL;
|
|
|
|
|
|
|
|
NMA_UNLOCK(&nm_mem);
|
|
|
|
}
|
|
|
|
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
static int
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
nm_mem_assign_group(struct netmap_mem_d *nmd, struct device *dev)
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
{
|
|
|
|
int err = 0, id;
|
|
|
|
id = nm_iommu_group_id(dev);
|
|
|
|
if (netmap_verbose)
|
|
|
|
D("iommu_group %d", id);
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
|
|
|
|
if (nmd->nm_grp < 0)
|
|
|
|
nmd->nm_grp = id;
|
|
|
|
|
|
|
|
if (nmd->nm_grp != id)
|
|
|
|
nmd->lasterr = err = ENOMEM;
|
|
|
|
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
return err;
|
|
|
|
}
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
/*
|
2013-04-19 21:08:21 +00:00
|
|
|
* First, find the allocator that contains the requested offset,
|
|
|
|
* then locate the cluster through a lookup table.
|
2012-04-13 16:32:33 +00:00
|
|
|
*/
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static vm_paddr_t
|
|
|
|
netmap_mem2_ofstophys(struct netmap_mem_d* nmd, vm_ooffset_t offset)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
|
|
|
int i;
|
2013-11-01 21:21:14 +00:00
|
|
|
vm_ooffset_t o = offset;
|
|
|
|
vm_paddr_t pa;
|
|
|
|
struct netmap_obj_pool *p;
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
p = nmd->pools;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; offset -= p[i].memtotal, i++) {
|
|
|
|
if (offset >= p[i].memtotal)
|
2012-04-13 16:32:33 +00:00
|
|
|
continue;
|
2013-04-19 21:08:21 +00:00
|
|
|
// now lookup the cluster's address
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#ifndef _WIN32
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
pa = vtophys(p[i].lut[offset / p[i]._objsize].vaddr) +
|
2012-10-19 04:13:12 +00:00
|
|
|
offset % p[i]._objsize;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#else
|
|
|
|
pa = vtophys(p[i].lut[offset / p[i]._objsize].vaddr);
|
|
|
|
pa.QuadPart += offset % p[i]._objsize;
|
|
|
|
#endif
|
2013-11-01 21:21:14 +00:00
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
return pa;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
/* this is only in case of errors */
|
2012-04-14 16:44:18 +00:00
|
|
|
D("invalid ofs 0x%x out of 0x%x 0x%x 0x%x", (u_int)o,
|
2013-11-01 21:21:14 +00:00
|
|
|
p[NETMAP_IF_POOL].memtotal,
|
|
|
|
p[NETMAP_IF_POOL].memtotal
|
|
|
|
+ p[NETMAP_RING_POOL].memtotal,
|
|
|
|
p[NETMAP_IF_POOL].memtotal
|
|
|
|
+ p[NETMAP_RING_POOL].memtotal
|
|
|
|
+ p[NETMAP_BUF_POOL].memtotal);
|
|
|
|
NMA_UNLOCK(nmd);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#ifndef _WIN32
|
2012-04-13 16:32:33 +00:00
|
|
|
return 0; // XXX bad address
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#else
|
|
|
|
vm_paddr_t res;
|
|
|
|
res.QuadPart = 0;
|
|
|
|
return res;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
/*
|
|
|
|
* win32_build_virtual_memory_for_userspace
|
|
|
|
*
|
|
|
|
* This function get all the object making part of the pools and maps
|
|
|
|
* a contiguous virtual memory space for the userspace
|
|
|
|
* It works this way
|
|
|
|
* 1 - allocate a Memory Descriptor List wide as the sum
|
|
|
|
* of the memory needed for the pools
|
|
|
|
* 2 - cycle all the objects in every pool and for every object do
|
|
|
|
*
|
|
|
|
* 2a - cycle all the objects in every pool, get the list
|
|
|
|
* of the physical address descriptors
|
|
|
|
* 2b - calculate the offset in the array of pages desciptor in the
|
|
|
|
* main MDL
|
|
|
|
* 2c - copy the descriptors of the object in the main MDL
|
|
|
|
*
|
|
|
|
* 3 - return the resulting MDL that needs to be mapped in userland
|
|
|
|
*
|
|
|
|
* In this way we will have an MDL that describes all the memory for the
|
|
|
|
* objects in a single object
|
|
|
|
*/
|
|
|
|
|
|
|
|
PMDL
|
|
|
|
win32_build_user_vm_map(struct netmap_mem_d* nmd)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
u_int memsize, memflags, ofs = 0;
|
|
|
|
PMDL mainMdl, tempMdl;
|
|
|
|
|
|
|
|
if (netmap_mem_get_info(nmd, &memsize, &memflags, NULL)) {
|
|
|
|
D("memory not finalised yet");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mainMdl = IoAllocateMdl(NULL, memsize, FALSE, FALSE, NULL);
|
|
|
|
if (mainMdl == NULL) {
|
|
|
|
D("failed to allocate mdl");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
struct netmap_obj_pool *p = &nmd->pools[i];
|
|
|
|
int clsz = p->_clustsize;
|
|
|
|
int clobjs = p->_clustentries; /* objects per cluster */
|
|
|
|
int mdl_len = sizeof(PFN_NUMBER) * BYTES_TO_PAGES(clsz);
|
|
|
|
PPFN_NUMBER pSrc, pDst;
|
|
|
|
|
|
|
|
/* each pool has a different cluster size so we need to reallocate */
|
|
|
|
tempMdl = IoAllocateMdl(p->lut[0].vaddr, clsz, FALSE, FALSE, NULL);
|
|
|
|
if (tempMdl == NULL) {
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
D("fail to allocate tempMdl");
|
|
|
|
IoFreeMdl(mainMdl);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pSrc = MmGetMdlPfnArray(tempMdl);
|
|
|
|
/* create one entry per cluster, the lut[] has one entry per object */
|
|
|
|
for (j = 0; j < p->numclusters; j++, ofs += clsz) {
|
|
|
|
pDst = &MmGetMdlPfnArray(mainMdl)[BYTES_TO_PAGES(ofs)];
|
|
|
|
MmInitializeMdl(tempMdl, p->lut[j*clobjs].vaddr, clsz);
|
|
|
|
MmBuildMdlForNonPagedPool(tempMdl); /* compute physical page addresses */
|
|
|
|
RtlCopyMemory(pDst, pSrc, mdl_len); /* copy the page descriptors */
|
|
|
|
mainMdl->MdlFlags = tempMdl->MdlFlags; /* XXX what is in here ? */
|
|
|
|
}
|
|
|
|
IoFreeMdl(tempMdl);
|
|
|
|
}
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
return mainMdl;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* helper function for OS-specific mmap routines (currently only windows).
|
|
|
|
* Given an nmd and a pool index, returns the cluster size and number of clusters.
|
|
|
|
* Returns 0 if memory is finalised and the pool is valid, otherwise 1.
|
|
|
|
* It should be called under NMA_LOCK(nmd) otherwise the underlying info can change.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
netmap_mem2_get_pool_info(struct netmap_mem_d* nmd, u_int pool, u_int *clustsize, u_int *numclusters)
|
|
|
|
{
|
|
|
|
if (!nmd || !clustsize || !numclusters || pool >= NETMAP_POOLS_NR)
|
|
|
|
return 1; /* invalid arguments */
|
|
|
|
// NMA_LOCK_ASSERT(nmd);
|
|
|
|
if (!(nmd->flags & NETMAP_MEM_FINALIZED)) {
|
|
|
|
*clustsize = *numclusters = 0;
|
|
|
|
return 1; /* not ready yet */
|
|
|
|
}
|
|
|
|
*clustsize = nmd->pools[pool]._clustsize;
|
|
|
|
*numclusters = nmd->pools[pool].numclusters;
|
|
|
|
return 0; /* success */
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static int
|
|
|
|
netmap_mem2_get_info(struct netmap_mem_d* nmd, u_int* size, u_int *memflags,
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
nm_memid_t *id)
|
2013-11-01 21:21:14 +00:00
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
NMA_LOCK(nmd);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
error = netmap_mem_config(nmd);
|
2013-11-01 21:21:14 +00:00
|
|
|
if (error)
|
|
|
|
goto out;
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
if (size) {
|
|
|
|
if (nmd->flags & NETMAP_MEM_FINALIZED) {
|
|
|
|
*size = nmd->nm_totalsize;
|
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
*size = 0;
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
struct netmap_obj_pool *p = nmd->pools + i;
|
|
|
|
*size += (p->_numclusters * p->_clustsize);
|
|
|
|
}
|
2013-11-01 21:21:14 +00:00
|
|
|
}
|
|
|
|
}
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
if (memflags)
|
|
|
|
*memflags = nmd->flags;
|
|
|
|
if (id)
|
|
|
|
*id = nmd->nm_id;
|
2013-11-01 21:21:14 +00:00
|
|
|
out:
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
/*
|
|
|
|
* we store objects by kernel address, need to find the offset
|
|
|
|
* within the pool to export the value to userspace.
|
|
|
|
* Algorithm: scan until we find the cluster, then add the
|
|
|
|
* actual offset in the cluster
|
|
|
|
*/
|
2012-04-13 22:24:57 +00:00
|
|
|
static ssize_t
|
2012-04-13 16:32:33 +00:00
|
|
|
netmap_obj_offset(struct netmap_obj_pool *p, const void *vaddr)
|
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
int i, k = p->_clustentries, n = p->objtotal;
|
2012-04-13 16:32:33 +00:00
|
|
|
ssize_t ofs = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i += k, ofs += p->_clustsize) {
|
|
|
|
const char *base = p->lut[i].vaddr;
|
|
|
|
ssize_t relofs = (const char *) vaddr - base;
|
|
|
|
|
2013-04-15 11:49:16 +00:00
|
|
|
if (relofs < 0 || relofs >= p->_clustsize)
|
2012-04-13 16:32:33 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
ofs = ofs + relofs;
|
|
|
|
ND("%s: return offset %d (cluster %d) for pointer %p",
|
|
|
|
p->name, ofs, i, vaddr);
|
|
|
|
return ofs;
|
|
|
|
}
|
|
|
|
D("address %p is not contained inside any cluster (%s)",
|
|
|
|
vaddr, p->name);
|
|
|
|
return 0; /* An error occurred */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper functions which convert virtual addresses to offsets */
|
2013-11-01 21:21:14 +00:00
|
|
|
#define netmap_if_offset(n, v) \
|
|
|
|
netmap_obj_offset(&(n)->pools[NETMAP_IF_POOL], (v))
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
#define netmap_ring_offset(n, v) \
|
|
|
|
((n)->pools[NETMAP_IF_POOL].memtotal + \
|
|
|
|
netmap_obj_offset(&(n)->pools[NETMAP_RING_POOL], (v)))
|
2012-04-13 16:32:33 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static ssize_t
|
|
|
|
netmap_mem2_if_offset(struct netmap_mem_d *nmd, const void *addr)
|
2013-11-01 21:21:14 +00:00
|
|
|
{
|
|
|
|
ssize_t v;
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
v = netmap_if_offset(nmd, addr);
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/*
|
|
|
|
* report the index, and use start position as a hint,
|
|
|
|
* otherwise buffer allocation becomes terribly expensive.
|
|
|
|
*/
|
2012-04-13 16:32:33 +00:00
|
|
|
static void *
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_obj_malloc(struct netmap_obj_pool *p, u_int len, uint32_t *start, uint32_t *index)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
|
|
|
uint32_t i = 0; /* index in the bitmap */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
uint32_t mask, j = 0; /* slot counter */
|
2012-04-13 16:32:33 +00:00
|
|
|
void *vaddr = NULL;
|
|
|
|
|
|
|
|
if (len > p->_objsize) {
|
|
|
|
D("%s request size %d too large", p->name, len);
|
|
|
|
// XXX cannot reduce the size
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->objfree == 0) {
|
2013-12-15 08:37:24 +00:00
|
|
|
D("no more %s objects", p->name);
|
2012-04-13 16:32:33 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
if (start)
|
|
|
|
i = *start;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/* termination is guaranteed by p->free, but better check bounds on i */
|
|
|
|
while (vaddr == NULL && i < p->bitmap_slots) {
|
2012-04-13 16:32:33 +00:00
|
|
|
uint32_t cur = p->bitmap[i];
|
|
|
|
if (cur == 0) { /* bitmask is fully used */
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* locate a slot */
|
|
|
|
for (j = 0, mask = 1; (cur & mask) == 0; j++, mask <<= 1)
|
|
|
|
;
|
|
|
|
|
|
|
|
p->bitmap[i] &= ~mask; /* mark object as in use */
|
|
|
|
p->objfree--;
|
|
|
|
|
|
|
|
vaddr = p->lut[i * 32 + j].vaddr;
|
2012-10-19 04:13:12 +00:00
|
|
|
if (index)
|
|
|
|
*index = i * 32 + j;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
ND("%s allocator: allocated object @ [%d][%d]: vaddr %p",p->name, i, j, vaddr);
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
if (start)
|
|
|
|
*start = i;
|
2012-04-13 16:32:33 +00:00
|
|
|
return vaddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
* free by index, not by address.
|
|
|
|
* XXX should we also cleanup the content ?
|
2012-04-13 16:32:33 +00:00
|
|
|
*/
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
static int
|
2012-04-13 16:32:33 +00:00
|
|
|
netmap_obj_free(struct netmap_obj_pool *p, uint32_t j)
|
|
|
|
{
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
uint32_t *ptr, mask;
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
if (j >= p->objtotal) {
|
|
|
|
D("invalid index %u, max %u", j, p->objtotal);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
ptr = &p->bitmap[j / 32];
|
|
|
|
mask = (1 << (j % 32));
|
|
|
|
if (*ptr & mask) {
|
|
|
|
D("ouch, double free on buffer %d", j);
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
*ptr |= mask;
|
|
|
|
p->objfree++;
|
|
|
|
return 0;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
/*
|
|
|
|
* free by address. This is slow but is only used for a few
|
|
|
|
* objects (rings, nifp)
|
|
|
|
*/
|
2012-04-13 16:32:33 +00:00
|
|
|
static void
|
|
|
|
netmap_obj_free_va(struct netmap_obj_pool *p, void *vaddr)
|
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
u_int i, j, n = p->numclusters;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
for (i = 0, j = 0; i < n; i++, j += p->_clustentries) {
|
|
|
|
void *base = p->lut[i * p->_clustentries].vaddr;
|
2012-04-13 16:32:33 +00:00
|
|
|
ssize_t relofs = (ssize_t) vaddr - (ssize_t) base;
|
|
|
|
|
|
|
|
/* Given address, is out of the scope of the current cluster.*/
|
2013-05-10 08:46:10 +00:00
|
|
|
if (vaddr < base || relofs >= p->_clustsize)
|
2012-04-13 16:32:33 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
j = j + relofs / p->_objsize;
|
2013-11-01 21:21:14 +00:00
|
|
|
/* KASSERT(j != 0, ("Cannot free object 0")); */
|
2012-04-13 16:32:33 +00:00
|
|
|
netmap_obj_free(p, j);
|
|
|
|
return;
|
|
|
|
}
|
2013-01-23 03:51:47 +00:00
|
|
|
D("address %p is not contained inside any cluster (%s)",
|
2012-04-13 16:32:33 +00:00
|
|
|
vaddr, p->name);
|
|
|
|
}
|
|
|
|
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
#define netmap_mem_bufsize(n) \
|
|
|
|
((n)->pools[NETMAP_BUF_POOL]._objsize)
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
#define netmap_if_malloc(n, len) netmap_obj_malloc(&(n)->pools[NETMAP_IF_POOL], len, NULL, NULL)
|
|
|
|
#define netmap_if_free(n, v) netmap_obj_free_va(&(n)->pools[NETMAP_IF_POOL], (v))
|
|
|
|
#define netmap_ring_malloc(n, len) netmap_obj_malloc(&(n)->pools[NETMAP_RING_POOL], len, NULL, NULL)
|
|
|
|
#define netmap_ring_free(n, v) netmap_obj_free_va(&(n)->pools[NETMAP_RING_POOL], (v))
|
|
|
|
#define netmap_buf_malloc(n, _pos, _index) \
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
netmap_obj_malloc(&(n)->pools[NETMAP_BUF_POOL], netmap_mem_bufsize(n), _pos, _index)
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
#if 0 // XXX unused
|
2012-04-13 16:32:33 +00:00
|
|
|
/* Return the index associated to the given packet buffer */
|
2013-11-01 21:21:14 +00:00
|
|
|
#define netmap_buf_index(n, v) \
|
|
|
|
(netmap_obj_offset(&(n)->pools[NETMAP_BUF_POOL], (v)) / NETMAP_BDG_BUF_SIZE(n))
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* allocate extra buffers in a linked list.
|
|
|
|
* returns the actual number.
|
|
|
|
*/
|
|
|
|
uint32_t
|
|
|
|
netmap_extra_alloc(struct netmap_adapter *na, uint32_t *head, uint32_t n)
|
|
|
|
{
|
|
|
|
struct netmap_mem_d *nmd = na->nm_mem;
|
|
|
|
uint32_t i, pos = 0; /* opaque, scan position in the bitmap */
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
|
|
|
|
*head = 0; /* default, 'null' index ie empty list */
|
|
|
|
for (i = 0 ; i < n; i++) {
|
|
|
|
uint32_t cur = *head; /* save current head */
|
|
|
|
uint32_t *p = netmap_buf_malloc(nmd, &pos, head);
|
|
|
|
if (p == NULL) {
|
|
|
|
D("no more buffers after %d of %d", i, n);
|
|
|
|
*head = cur; /* restore */
|
|
|
|
break;
|
|
|
|
}
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
ND(5, "allocate buffer %d -> %d", *head, cur);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
*p = cur; /* link to previous head */
|
|
|
|
}
|
|
|
|
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_extra_free(struct netmap_adapter *na, uint32_t head)
|
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
struct lut_entry *lut = na->na_lut.lut;
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
struct netmap_mem_d *nmd = na->nm_mem;
|
|
|
|
struct netmap_obj_pool *p = &nmd->pools[NETMAP_BUF_POOL];
|
|
|
|
uint32_t i, cur, *buf;
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
ND("freeing the extra list");
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
for (i = 0; head >=2 && head < p->objtotal; i++) {
|
|
|
|
cur = head;
|
|
|
|
buf = lut[head].vaddr;
|
|
|
|
head = *buf;
|
|
|
|
*buf = 0;
|
|
|
|
if (netmap_obj_free(p, cur))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (head != 0)
|
|
|
|
D("breaking with head %d", head);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("freed %d buffers", i);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/* Return nonzero on error */
|
|
|
|
static int
|
2013-12-15 08:37:24 +00:00
|
|
|
netmap_new_bufs(struct netmap_mem_d *nmd, struct netmap_slot *slot, u_int n)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
struct netmap_obj_pool *p = &nmd->pools[NETMAP_BUF_POOL];
|
|
|
|
u_int i = 0; /* slot counter */
|
2012-10-19 04:13:12 +00:00
|
|
|
uint32_t pos = 0; /* slot in p->bitmap */
|
|
|
|
uint32_t index = 0; /* buffer index */
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2013-11-01 21:21:14 +00:00
|
|
|
void *vaddr = netmap_buf_malloc(nmd, &pos, &index);
|
2012-04-13 16:32:33 +00:00
|
|
|
if (vaddr == NULL) {
|
2013-12-15 08:37:24 +00:00
|
|
|
D("no more buffers after %d of %d", i, n);
|
2012-04-13 16:32:33 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
slot[i].buf_idx = index;
|
2012-04-13 16:32:33 +00:00
|
|
|
slot[i].len = p->_objsize;
|
2013-12-15 08:37:24 +00:00
|
|
|
slot[i].flags = 0;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
ND("allocated %d buffers, %d available, first at %d", n, p->objfree, pos);
|
|
|
|
return (0);
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
cleanup:
|
2012-10-17 18:21:14 +00:00
|
|
|
while (i > 0) {
|
|
|
|
i--;
|
2012-10-19 04:13:12 +00:00
|
|
|
netmap_obj_free(p, slot[i].buf_idx);
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
bzero(slot, n * sizeof(slot[0]));
|
|
|
|
return (ENOMEM);
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
static void
|
|
|
|
netmap_mem_set_ring(struct netmap_mem_d *nmd, struct netmap_slot *slot, u_int n, uint32_t index)
|
|
|
|
{
|
|
|
|
struct netmap_obj_pool *p = &nmd->pools[NETMAP_BUF_POOL];
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
slot[i].buf_idx = index;
|
|
|
|
slot[i].len = p->_objsize;
|
|
|
|
slot[i].flags = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
static void
|
2013-12-15 08:37:24 +00:00
|
|
|
netmap_free_buf(struct netmap_mem_d *nmd, uint32_t i)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
struct netmap_obj_pool *p = &nmd->pools[NETMAP_BUF_POOL];
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
if (i < 2 || i >= p->objtotal) {
|
|
|
|
D("Cannot free buf#%d: should be in [2, %d[", i, p->objtotal);
|
|
|
|
return;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
netmap_obj_free(p, i);
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_free_bufs(struct netmap_mem_d *nmd, struct netmap_slot *slot, u_int n)
|
|
|
|
{
|
|
|
|
u_int i;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
if (slot[i].buf_idx > 2)
|
|
|
|
netmap_free_buf(nmd, slot[i].buf_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
static void
|
2012-10-19 04:13:12 +00:00
|
|
|
netmap_reset_obj_allocator(struct netmap_obj_pool *p)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
if (p == NULL)
|
|
|
|
return;
|
|
|
|
if (p->bitmap)
|
|
|
|
free(p->bitmap, M_NETMAP);
|
2012-10-19 04:13:12 +00:00
|
|
|
p->bitmap = NULL;
|
2012-04-13 16:32:33 +00:00
|
|
|
if (p->lut) {
|
2013-11-01 21:21:14 +00:00
|
|
|
u_int i;
|
|
|
|
|
2015-05-15 15:36:57 +00:00
|
|
|
/*
|
|
|
|
* Free each cluster allocated in
|
|
|
|
* netmap_finalize_obj_allocator(). The cluster start
|
|
|
|
* addresses are stored at multiples of p->_clusterentries
|
|
|
|
* in the lut.
|
|
|
|
*/
|
2013-11-01 21:21:14 +00:00
|
|
|
for (i = 0; i < p->objtotal; i += p->_clustentries) {
|
2012-04-13 16:32:33 +00:00
|
|
|
if (p->lut[i].vaddr)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
contigfree(p->lut[i].vaddr, p->_clustsize, M_NETMAP);
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
bzero(p->lut, sizeof(struct lut_entry) * p->objtotal);
|
2012-10-19 04:13:12 +00:00
|
|
|
#ifdef linux
|
|
|
|
vfree(p->lut);
|
|
|
|
#else
|
2012-04-13 16:32:33 +00:00
|
|
|
free(p->lut, M_NETMAP);
|
2012-10-19 04:13:12 +00:00
|
|
|
#endif
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
p->lut = NULL;
|
2013-11-01 21:21:14 +00:00
|
|
|
p->objtotal = 0;
|
|
|
|
p->memtotal = 0;
|
|
|
|
p->numclusters = 0;
|
|
|
|
p->objfree = 0;
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free all resources related to an allocator.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
netmap_destroy_obj_allocator(struct netmap_obj_pool *p)
|
|
|
|
{
|
|
|
|
if (p == NULL)
|
|
|
|
return;
|
|
|
|
netmap_reset_obj_allocator(p);
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We receive a request for objtotal objects, of size objsize each.
|
|
|
|
* Internally we may round up both numbers, as we allocate objects
|
|
|
|
* in small clusters multiple of the page size.
|
2013-11-01 21:21:14 +00:00
|
|
|
* We need to keep track of objtotal and clustentries,
|
2012-04-13 16:32:33 +00:00
|
|
|
* as they are needed when freeing memory.
|
|
|
|
*
|
|
|
|
* XXX note -- userspace needs the buffers to be contiguous,
|
|
|
|
* so we cannot afford gaps at the end of a cluster.
|
|
|
|
*/
|
2012-10-19 04:13:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* call with NMA_LOCK held */
|
|
|
|
static int
|
|
|
|
netmap_config_obj_allocator(struct netmap_obj_pool *p, u_int objtotal, u_int objsize)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
int i;
|
2012-04-13 16:32:33 +00:00
|
|
|
u_int clustsize; /* the cluster size, multiple of page size */
|
|
|
|
u_int clustentries; /* how many objects per entry */
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
/* we store the current request, so we can
|
|
|
|
* detect configuration changes later */
|
|
|
|
p->r_objtotal = objtotal;
|
|
|
|
p->r_objsize = objsize;
|
|
|
|
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
#define MAX_CLUSTSIZE (1<<22) // 4 MB
|
It is 2014 and we have a new version of netmap.
Most relevant features:
- netmap emulation on any NIC, even those without native netmap support.
On the ixgbe we have measured about 4Mpps/core/queue in this mode,
which is still a lot more than with sockets/bpf.
- seamless interconnection of VALE switch, NICs and host stack.
If you disable accelerations on your NIC (say em0)
ifconfig em0 -txcsum -txcsum
you can use the VALE switch to connect the NIC and the host stack:
vale-ctl -h valeXX:em0
allowing sharing the NIC with other netmap clients.
- THE USER API HAS SLIGHTLY CHANGED (head/cur/tail pointers
instead of pointers/count as before). This was unavoidable to support,
in the future, multiple threads operating on the same rings.
Netmap clients require very small source code changes to compile again.
On the plus side, the new API should be easier to understand
and the internals are a lot simpler.
The manual page has been updated extensively to reflect the current
features and give some examples.
This is the result of work of several people including Giuseppe Lettieri,
Vincenzo Maffione, Michio Honda and myself, and has been financially
supported by EU projects CHANGE and OPENLAB, from NetApp University
Research Fund, NEC, and of course the Universita` di Pisa.
2014-01-06 12:53:15 +00:00
|
|
|
#define LINE_ROUND NM_CACHE_ALIGN // 64
|
2012-04-13 16:32:33 +00:00
|
|
|
if (objsize >= MAX_CLUSTSIZE) {
|
|
|
|
/* we could do it but there is no point */
|
|
|
|
D("unsupported allocation for %d bytes", objsize);
|
2013-11-01 21:21:14 +00:00
|
|
|
return EINVAL;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
/* make sure objsize is a multiple of LINE_ROUND */
|
|
|
|
i = (objsize & (LINE_ROUND - 1));
|
|
|
|
if (i) {
|
|
|
|
D("XXX aligning object by %d bytes", LINE_ROUND - i);
|
|
|
|
objsize += LINE_ROUND - i;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
if (objsize < p->objminsize || objsize > p->objmaxsize) {
|
2013-05-02 16:01:04 +00:00
|
|
|
D("requested objsize %d out of range [%d, %d]",
|
2012-10-19 04:13:12 +00:00
|
|
|
objsize, p->objminsize, p->objmaxsize);
|
2013-11-01 21:21:14 +00:00
|
|
|
return EINVAL;
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
|
|
|
if (objtotal < p->nummin || objtotal > p->nummax) {
|
2013-05-02 16:01:04 +00:00
|
|
|
D("requested objtotal %d out of range [%d, %d]",
|
2012-10-19 04:13:12 +00:00
|
|
|
objtotal, p->nummin, p->nummax);
|
2013-11-01 21:21:14 +00:00
|
|
|
return EINVAL;
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
/*
|
|
|
|
* Compute number of objects using a brute-force approach:
|
|
|
|
* given a max cluster size,
|
|
|
|
* we try to fill it with objects keeping track of the
|
|
|
|
* wasted space to the next page boundary.
|
|
|
|
*/
|
|
|
|
for (clustentries = 0, i = 1;; i++) {
|
|
|
|
u_int delta, used = i * objsize;
|
|
|
|
if (used > MAX_CLUSTSIZE)
|
|
|
|
break;
|
|
|
|
delta = used % PAGE_SIZE;
|
|
|
|
if (delta == 0) { // exact solution
|
|
|
|
clustentries = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
/* exact solution not found */
|
|
|
|
if (clustentries == 0) {
|
|
|
|
D("unsupported allocation for %d bytes", objsize);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
/* compute clustsize */
|
2012-04-13 16:32:33 +00:00
|
|
|
clustsize = clustentries * objsize;
|
2013-01-23 03:51:47 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("objsize %d clustsize %d objects %d",
|
|
|
|
objsize, clustsize, clustentries);
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The number of clusters is n = ceil(objtotal/clustentries)
|
|
|
|
* objtotal' = n * clustentries
|
|
|
|
*/
|
2013-11-01 21:21:14 +00:00
|
|
|
p->_clustentries = clustentries;
|
2012-04-13 16:32:33 +00:00
|
|
|
p->_clustsize = clustsize;
|
2013-11-01 21:21:14 +00:00
|
|
|
p->_numclusters = (objtotal + clustentries - 1) / clustentries;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
/* actual values (may be larger than requested) */
|
2012-10-19 04:13:12 +00:00
|
|
|
p->_objsize = objsize;
|
2013-11-01 21:21:14 +00:00
|
|
|
p->_objtotal = p->_numclusters * clustentries;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
return 0;
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
static struct lut_entry *
|
|
|
|
nm_alloc_lut(u_int nobj)
|
|
|
|
{
|
|
|
|
size_t n = sizeof(struct lut_entry) * nobj;
|
|
|
|
struct lut_entry *lut;
|
|
|
|
#ifdef linux
|
|
|
|
lut = vmalloc(n);
|
|
|
|
#else
|
|
|
|
lut = malloc(n, M_NETMAP, M_NOWAIT | M_ZERO);
|
|
|
|
#endif
|
|
|
|
return lut;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
|
|
|
|
/* call with NMA_LOCK held */
|
|
|
|
static int
|
|
|
|
netmap_finalize_obj_allocator(struct netmap_obj_pool *p)
|
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
int i; /* must be signed */
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
/* optimistically assume we have enough memory */
|
|
|
|
p->numclusters = p->_numclusters;
|
|
|
|
p->objtotal = p->_objtotal;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
p->lut = nm_alloc_lut(p->objtotal);
|
2012-04-13 16:32:33 +00:00
|
|
|
if (p->lut == NULL) {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
D("Unable to create lookup table for '%s'", p->name);
|
2012-04-13 16:32:33 +00:00
|
|
|
goto clean;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the bitmap */
|
|
|
|
n = (p->objtotal + 31) / 32;
|
2012-10-19 19:28:35 +00:00
|
|
|
p->bitmap = malloc(sizeof(uint32_t) * n, M_NETMAP, M_NOWAIT | M_ZERO);
|
2012-04-13 16:32:33 +00:00
|
|
|
if (p->bitmap == NULL) {
|
2013-11-01 21:21:14 +00:00
|
|
|
D("Unable to create bitmap (%d entries) for allocator '%s'", (int)n,
|
2012-10-19 04:13:12 +00:00
|
|
|
p->name);
|
2012-04-13 16:32:33 +00:00
|
|
|
goto clean;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
p->bitmap_slots = n;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate clusters, init pointers and bitmap
|
|
|
|
*/
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
n = p->_clustsize;
|
|
|
|
for (i = 0; i < (int)p->objtotal;) {
|
|
|
|
int lim = i + p->_clustentries;
|
2012-04-13 16:32:33 +00:00
|
|
|
char *clust;
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
/*
|
|
|
|
* XXX Note, we only need contigmalloc() for buffers attached
|
|
|
|
* to native interfaces. In all other cases (nifp, netmap rings
|
|
|
|
* and even buffers for VALE ports or emulated interfaces) we
|
|
|
|
* can live with standard malloc, because the hardware will not
|
|
|
|
* access the pages directly.
|
|
|
|
*/
|
2013-11-01 21:21:14 +00:00
|
|
|
clust = contigmalloc(n, M_NETMAP, M_NOWAIT | M_ZERO,
|
|
|
|
(size_t)0, -1UL, PAGE_SIZE, 0);
|
2012-04-13 16:32:33 +00:00
|
|
|
if (clust == NULL) {
|
|
|
|
/*
|
|
|
|
* If we get here, there is a severe memory shortage,
|
|
|
|
* so halve the allocated memory to reclaim some.
|
|
|
|
*/
|
|
|
|
D("Unable to create cluster at %d for '%s' allocator",
|
2012-10-19 04:13:12 +00:00
|
|
|
i, p->name);
|
2013-11-01 21:21:14 +00:00
|
|
|
if (i < 2) /* nothing to halve */
|
|
|
|
goto out;
|
2012-04-13 16:32:33 +00:00
|
|
|
lim = i / 2;
|
2012-10-19 04:13:12 +00:00
|
|
|
for (i--; i >= lim; i--) {
|
2012-04-13 16:32:33 +00:00
|
|
|
p->bitmap[ (i>>5) ] &= ~( 1 << (i & 31) );
|
2013-11-01 21:21:14 +00:00
|
|
|
if (i % p->_clustentries == 0 && p->lut[i].vaddr)
|
2012-04-13 16:32:33 +00:00
|
|
|
contigfree(p->lut[i].vaddr,
|
2013-11-01 21:21:14 +00:00
|
|
|
n, M_NETMAP);
|
2015-05-15 15:36:57 +00:00
|
|
|
p->lut[i].vaddr = NULL;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
2013-11-01 21:21:14 +00:00
|
|
|
out:
|
2012-04-13 16:32:33 +00:00
|
|
|
p->objtotal = i;
|
2013-11-01 21:21:14 +00:00
|
|
|
/* we may have stopped in the middle of a cluster */
|
|
|
|
p->numclusters = (i + p->_clustentries - 1) / p->_clustentries;
|
2012-04-13 16:32:33 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-05-15 15:36:57 +00:00
|
|
|
/*
|
|
|
|
* Set bitmap and lut state for all buffers in the current
|
|
|
|
* cluster.
|
|
|
|
*
|
|
|
|
* [i, lim) is the set of buffer indexes that cover the
|
|
|
|
* current cluster.
|
|
|
|
*
|
|
|
|
* 'clust' is really the address of the current buffer in
|
|
|
|
* the current cluster as we index through it with a stride
|
|
|
|
* of p->_objsize.
|
|
|
|
*/
|
2012-10-19 04:13:12 +00:00
|
|
|
for (; i < lim; i++, clust += p->_objsize) {
|
2012-04-13 16:32:33 +00:00
|
|
|
p->bitmap[ (i>>5) ] |= ( 1 << (i & 31) );
|
|
|
|
p->lut[i].vaddr = clust;
|
|
|
|
p->lut[i].paddr = vtophys(clust);
|
|
|
|
}
|
|
|
|
}
|
2013-11-01 21:21:14 +00:00
|
|
|
p->objfree = p->objtotal;
|
|
|
|
p->memtotal = p->numclusters * p->_clustsize;
|
|
|
|
if (p->objfree == 0)
|
|
|
|
goto clean;
|
2013-01-23 03:51:47 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("Pre-allocated %d clusters (%d/%dKB) for '%s'",
|
2013-11-01 21:21:14 +00:00
|
|
|
p->numclusters, p->_clustsize >> 10,
|
|
|
|
p->memtotal >> 10, p->name);
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
return 0;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
|
|
|
clean:
|
2012-10-19 04:13:12 +00:00
|
|
|
netmap_reset_obj_allocator(p);
|
|
|
|
return ENOMEM;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/* call with lock held */
|
2012-04-13 16:32:33 +00:00
|
|
|
static int
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_memory_config_changed(struct netmap_mem_d *nmd)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
2012-10-19 04:13:12 +00:00
|
|
|
int i;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
2013-11-01 21:21:14 +00:00
|
|
|
if (nmd->pools[i].r_objsize != netmap_params[i].size ||
|
|
|
|
nmd->pools[i].r_objtotal != netmap_params[i].num)
|
2012-10-19 04:13:12 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
static void
|
|
|
|
netmap_mem_reset_all(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
int i;
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
|
|
|
if (netmap_verbose)
|
|
|
|
D("resetting %p", nmd);
|
2013-11-01 21:21:14 +00:00
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
netmap_reset_obj_allocator(&nmd->pools[i]);
|
|
|
|
}
|
|
|
|
nmd->flags &= ~NETMAP_MEM_FINALIZED;
|
|
|
|
}
|
|
|
|
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
static int
|
|
|
|
netmap_mem_unmap(struct netmap_obj_pool *p, struct netmap_adapter *na)
|
|
|
|
{
|
|
|
|
int i, lim = p->_objtotal;
|
|
|
|
|
|
|
|
if (na->pdev == NULL)
|
|
|
|
return 0;
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#if defined(__FreeBSD__)
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
(void)i;
|
|
|
|
(void)lim;
|
|
|
|
D("unsupported on FreeBSD");
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
|
|
|
#elif defined(_WIN32)
|
|
|
|
(void)i;
|
|
|
|
(void)lim;
|
|
|
|
D("unsupported on Windows"); //XXX_ale, really?
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
#else /* linux */
|
|
|
|
for (i = 2; i < lim; i++) {
|
|
|
|
netmap_unload_map(na, (bus_dma_tag_t) na->pdev, &p->lut[i].paddr);
|
|
|
|
}
|
|
|
|
#endif /* linux */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_map(struct netmap_obj_pool *p, struct netmap_adapter *na)
|
|
|
|
{
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#if defined(__FreeBSD__)
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
D("unsupported on FreeBSD");
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
D("unsupported on Windows"); //XXX_ale, really?
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
#else /* linux */
|
|
|
|
int i, lim = p->_objtotal;
|
|
|
|
|
|
|
|
if (na->pdev == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 2; i < lim; i++) {
|
|
|
|
netmap_load_map(na, (bus_dma_tag_t) na->pdev, &p->lut[i].paddr,
|
|
|
|
p->lut[i].vaddr);
|
|
|
|
}
|
|
|
|
#endif /* linux */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
static int
|
|
|
|
netmap_mem_finalize_all(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (nmd->flags & NETMAP_MEM_FINALIZED)
|
|
|
|
return 0;
|
|
|
|
nmd->lasterr = 0;
|
|
|
|
nmd->nm_totalsize = 0;
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
nmd->lasterr = netmap_finalize_obj_allocator(&nmd->pools[i]);
|
|
|
|
if (nmd->lasterr)
|
|
|
|
goto error;
|
|
|
|
nmd->nm_totalsize += nmd->pools[i].memtotal;
|
|
|
|
}
|
|
|
|
/* buffers 0 and 1 are reserved */
|
|
|
|
nmd->pools[NETMAP_BUF_POOL].objfree -= 2;
|
|
|
|
nmd->pools[NETMAP_BUF_POOL].bitmap[0] = ~3;
|
|
|
|
nmd->flags |= NETMAP_MEM_FINALIZED;
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("interfaces %d KB, rings %d KB, buffers %d MB",
|
|
|
|
nmd->pools[NETMAP_IF_POOL].memtotal >> 10,
|
|
|
|
nmd->pools[NETMAP_RING_POOL].memtotal >> 10,
|
|
|
|
nmd->pools[NETMAP_BUF_POOL].memtotal >> 20);
|
2013-11-01 21:21:14 +00:00
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("Free buffers: %d", nmd->pools[NETMAP_BUF_POOL].objfree);
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
netmap_mem_reset_all(nmd);
|
|
|
|
return nmd->lasterr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static void
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_mem_private_delete(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
if (nmd == NULL)
|
|
|
|
return;
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("deleting %p", nmd);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
if (nmd->active > 0)
|
|
|
|
D("bug: deleting mem allocator with active=%d!", nmd->active);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
nm_mem_release_id(nmd);
|
|
|
|
if (netmap_verbose)
|
|
|
|
D("done deleting %p", nmd);
|
2013-11-01 21:21:14 +00:00
|
|
|
NMA_LOCK_DESTROY(nmd);
|
|
|
|
free(nmd, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_private_config(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
/* nothing to do, we are configured on creation
|
|
|
|
* and configuration never changes thereafter
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_private_finalize(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
err = netmap_mem_finalize_all(nmd);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (!err)
|
|
|
|
nmd->active++;
|
2013-11-01 21:21:14 +00:00
|
|
|
return err;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-15 08:37:24 +00:00
|
|
|
static void
|
|
|
|
netmap_mem_private_deref(struct netmap_mem_d *nmd)
|
2013-11-01 21:21:14 +00:00
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
if (--nmd->active <= 0)
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_mem_reset_all(nmd);
|
|
|
|
}
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* allocator for private memory
|
|
|
|
*/
|
2013-11-01 21:21:14 +00:00
|
|
|
struct netmap_mem_d *
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
netmap_mem_private_new(const char *name, u_int txr, u_int txd,
|
|
|
|
u_int rxr, u_int rxd, u_int extra_bufs, u_int npipes, int *perr)
|
2013-11-01 21:21:14 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_d *d = NULL;
|
|
|
|
struct netmap_obj_params p[NETMAP_POOLS_NR];
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
int i, err;
|
|
|
|
u_int v, maxd;
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
d = malloc(sizeof(struct netmap_mem_d),
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
M_DEVBUF, M_NOWAIT | M_ZERO);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (d == NULL) {
|
|
|
|
err = ENOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
*d = nm_blueprint;
|
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
err = nm_mem_assign_id(d);
|
|
|
|
if (err)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* account for the fake host rings */
|
2013-11-01 21:21:14 +00:00
|
|
|
txr++;
|
|
|
|
rxr++;
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
|
|
|
|
/* copy the min values */
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
p[i] = netmap_min_priv_params[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* possibly increase them to fit user request */
|
|
|
|
v = sizeof(struct netmap_if) + sizeof(ssize_t) * (txr + rxr);
|
|
|
|
if (p[NETMAP_IF_POOL].size < v)
|
|
|
|
p[NETMAP_IF_POOL].size = v;
|
|
|
|
v = 2 + 4 * npipes;
|
|
|
|
if (p[NETMAP_IF_POOL].num < v)
|
|
|
|
p[NETMAP_IF_POOL].num = v;
|
2013-11-01 21:21:14 +00:00
|
|
|
maxd = (txd > rxd) ? txd : rxd;
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
v = sizeof(struct netmap_ring) + sizeof(struct netmap_slot) * maxd;
|
|
|
|
if (p[NETMAP_RING_POOL].size < v)
|
|
|
|
p[NETMAP_RING_POOL].size = v;
|
|
|
|
/* each pipe endpoint needs two tx rings (1 normal + 1 host, fake)
|
|
|
|
* and two rx rings (again, 1 normal and 1 fake host)
|
|
|
|
*/
|
|
|
|
v = txr + rxr + 8 * npipes;
|
|
|
|
if (p[NETMAP_RING_POOL].num < v)
|
|
|
|
p[NETMAP_RING_POOL].num = v;
|
|
|
|
/* for each pipe we only need the buffers for the 4 "real" rings.
|
2014-06-05 21:12:41 +00:00
|
|
|
* On the other end, the pipe ring dimension may be different from
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
* the parent port ring dimension. As a compromise, we allocate twice the
|
|
|
|
* space actually needed if the pipe rings were the same size as the parent rings
|
|
|
|
*/
|
|
|
|
v = (4 * npipes + rxr) * rxd + (4 * npipes + txr) * txd + 2 + extra_bufs;
|
|
|
|
/* the +2 is for the tx and rx fake buffers (indices 0 and 1) */
|
|
|
|
if (p[NETMAP_BUF_POOL].num < v)
|
|
|
|
p[NETMAP_BUF_POOL].num = v;
|
2013-11-01 21:21:14 +00:00
|
|
|
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (netmap_verbose)
|
|
|
|
D("req if %d*%d ring %d*%d buf %d*%d",
|
2013-11-01 21:21:14 +00:00
|
|
|
p[NETMAP_IF_POOL].num,
|
|
|
|
p[NETMAP_IF_POOL].size,
|
|
|
|
p[NETMAP_RING_POOL].num,
|
|
|
|
p[NETMAP_RING_POOL].size,
|
|
|
|
p[NETMAP_BUF_POOL].num,
|
|
|
|
p[NETMAP_BUF_POOL].size);
|
|
|
|
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
snprintf(d->pools[i].name, NETMAP_POOL_MAX_NAMSZ,
|
|
|
|
nm_blueprint.pools[i].name,
|
|
|
|
name);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
err = netmap_config_obj_allocator(&d->pools[i],
|
|
|
|
p[i].num, p[i].size);
|
|
|
|
if (err)
|
2013-11-01 21:21:14 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->flags &= ~NETMAP_MEM_FINALIZED;
|
|
|
|
|
|
|
|
NMA_LOCK_INIT(d);
|
|
|
|
|
|
|
|
return d;
|
|
|
|
error:
|
|
|
|
netmap_mem_private_delete(d);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (perr)
|
|
|
|
*perr = err;
|
2013-11-01 21:21:14 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/* call with lock held */
|
|
|
|
static int
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_mem_global_config(struct netmap_mem_d *nmd)
|
2012-10-19 04:13:12 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
if (nmd->active)
|
2013-11-01 21:21:14 +00:00
|
|
|
/* already in use, we cannot change the configuration */
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!netmap_memory_config_changed(nmd))
|
2012-10-19 04:13:12 +00:00
|
|
|
goto out;
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
ND("reconfiguring");
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
if (nmd->flags & NETMAP_MEM_FINALIZED) {
|
2012-10-19 04:13:12 +00:00
|
|
|
/* reset previous allocation */
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_reset_obj_allocator(&nmd->pools[i]);
|
2013-05-02 16:01:04 +00:00
|
|
|
}
|
2013-11-01 21:21:14 +00:00
|
|
|
nmd->flags &= ~NETMAP_MEM_FINALIZED;
|
2013-12-15 08:37:24 +00:00
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
2013-11-01 21:21:14 +00:00
|
|
|
nmd->lasterr = netmap_config_obj_allocator(&nmd->pools[i],
|
2012-10-19 04:13:12 +00:00
|
|
|
netmap_params[i].num, netmap_params[i].size);
|
2013-11-01 21:21:14 +00:00
|
|
|
if (nmd->lasterr)
|
2012-10-19 04:13:12 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
out:
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
return nmd->lasterr;
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_mem_global_finalize(struct netmap_mem_d *nmd)
|
2012-10-19 04:13:12 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
int err;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
2012-10-19 04:13:12 +00:00
|
|
|
/* update configuration if changed */
|
2013-11-01 21:21:14 +00:00
|
|
|
if (netmap_mem_global_config(nmd))
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
return nmd->lasterr;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
nmd->active++;
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
if (nmd->flags & NETMAP_MEM_FINALIZED) {
|
2012-10-19 04:13:12 +00:00
|
|
|
/* may happen if config is not changed */
|
|
|
|
ND("nothing to do");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
if (netmap_mem_finalize_all(nmd))
|
|
|
|
goto out;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
nmd->lasterr = 0;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
|
|
|
out:
|
2013-11-01 21:21:14 +00:00
|
|
|
if (nmd->lasterr)
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
nmd->active--;
|
2013-11-01 21:21:14 +00:00
|
|
|
err = nmd->lasterr;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
return err;
|
2012-10-19 04:13:12 +00:00
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static void
|
|
|
|
netmap_mem_global_delete(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NETMAP_POOLS_NR; i++) {
|
|
|
|
netmap_destroy_obj_allocator(&nm_mem.pools[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
NMA_LOCK_DESTROY(&nm_mem);
|
|
|
|
}
|
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
int
|
|
|
|
netmap_mem_init(void)
|
2012-10-19 04:13:12 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
NMA_LOCK_INIT(&nm_mem);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
netmap_mem_get(&nm_mem);
|
2012-10-19 04:13:12 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
|
2013-11-01 21:21:14 +00:00
|
|
|
void
|
|
|
|
netmap_mem_fini(void)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
netmap_mem_put(&nm_mem);
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_free_rings(struct netmap_adapter *na)
|
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
enum txrx t;
|
|
|
|
|
|
|
|
for_rx_tx(t) {
|
|
|
|
u_int i;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
for (i = 0; i < nma_get_nrings(na, t) + 1; i++) {
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
struct netmap_kring *kring = &NMR(na, t)[i];
|
|
|
|
struct netmap_ring *ring = kring->ring;
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (ring == NULL || kring->users > 0 || (kring->nr_kflags & NKR_NEEDRING)) {
|
|
|
|
ND("skipping ring %s (ring %p, users %d)",
|
|
|
|
kring->name, ring, kring->users);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
continue;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
}
|
|
|
|
if (i != nma_get_nrings(na, t) || na->na_flags & NAF_HOST_RINGS)
|
|
|
|
netmap_free_bufs(na->nm_mem, ring->slot, kring->nkr_num_slots);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
netmap_ring_free(na->nm_mem, ring);
|
|
|
|
kring->ring = NULL;
|
|
|
|
}
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 08:37:24 +00:00
|
|
|
/* call with NMA_LOCK held *
|
2013-11-01 21:21:14 +00:00
|
|
|
*
|
2013-12-15 08:37:24 +00:00
|
|
|
* Allocate netmap rings and buffers for this card
|
|
|
|
* The rings are contiguous, but have variable size.
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
* The kring array must follow the layout described
|
|
|
|
* in netmap_krings_create().
|
2013-01-23 03:51:47 +00:00
|
|
|
*/
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static int
|
|
|
|
netmap_mem2_rings_create(struct netmap_adapter *na)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
enum txrx t;
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
NMA_LOCK(na->nm_mem);
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
for_rx_tx(t) {
|
|
|
|
u_int i;
|
2012-04-13 16:32:33 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
for (i = 0; i <= nma_get_nrings(na, t); i++) {
|
|
|
|
struct netmap_kring *kring = &NMR(na, t)[i];
|
|
|
|
struct netmap_ring *ring = kring->ring;
|
|
|
|
u_int len, ndesc;
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (ring || (!kring->users && !(kring->nr_kflags & NKR_NEEDRING))) {
|
|
|
|
/* uneeded, or already created by somebody else */
|
|
|
|
ND("skipping ring %s", kring->name);
|
|
|
|
continue;
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
}
|
|
|
|
ndesc = kring->nkr_num_slots;
|
|
|
|
len = sizeof(struct netmap_ring) +
|
|
|
|
ndesc * sizeof(struct netmap_slot);
|
|
|
|
ring = netmap_ring_malloc(na->nm_mem, len);
|
|
|
|
if (ring == NULL) {
|
|
|
|
D("Cannot allocate %s_ring", nm_txrx2str(t));
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
ND("txring at %p", ring);
|
|
|
|
kring->ring = ring;
|
|
|
|
*(uint32_t *)(uintptr_t)&ring->num_slots = ndesc;
|
|
|
|
*(int64_t *)(uintptr_t)&ring->buf_ofs =
|
|
|
|
(na->nm_mem->pools[NETMAP_IF_POOL].memtotal +
|
|
|
|
na->nm_mem->pools[NETMAP_RING_POOL].memtotal) -
|
|
|
|
netmap_ring_offset(na->nm_mem, ring);
|
|
|
|
|
|
|
|
/* copy values from kring */
|
|
|
|
ring->head = kring->rhead;
|
|
|
|
ring->cur = kring->rcur;
|
|
|
|
ring->tail = kring->rtail;
|
|
|
|
*(uint16_t *)(uintptr_t)&ring->nr_buf_size =
|
|
|
|
netmap_mem_bufsize(na->nm_mem);
|
|
|
|
ND("%s h %d c %d t %d", kring->name,
|
|
|
|
ring->head, ring->cur, ring->tail);
|
|
|
|
ND("initializing slots for %s_ring", nm_txrx2str(txrx));
|
|
|
|
if (i != nma_get_nrings(na, t) || (na->na_flags & NAF_HOST_RINGS)) {
|
|
|
|
/* this is a real ring */
|
|
|
|
if (netmap_new_bufs(na->nm_mem, ring->slot, ndesc)) {
|
|
|
|
D("Cannot allocate buffers for %s_ring", nm_txrx2str(t));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* this is a fake ring, set all indices to 0 */
|
|
|
|
netmap_mem_set_ring(na->nm_mem, ring->slot, ndesc, 0);
|
|
|
|
}
|
|
|
|
/* ring info */
|
|
|
|
*(uint16_t *)(uintptr_t)&ring->ringid = kring->ring_id;
|
|
|
|
*(uint16_t *)(uintptr_t)&ring->dir = kring->tx;
|
2012-10-19 04:13:12 +00:00
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
2013-12-15 08:37:24 +00:00
|
|
|
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
netmap_free_rings(na);
|
|
|
|
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static void
|
|
|
|
netmap_mem2_rings_delete(struct netmap_adapter *na)
|
2013-12-15 08:37:24 +00:00
|
|
|
{
|
|
|
|
/* last instance, release bufs and rings */
|
|
|
|
NMA_LOCK(na->nm_mem);
|
|
|
|
|
|
|
|
netmap_free_rings(na);
|
|
|
|
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* call with NMA_LOCK held */
|
|
|
|
/*
|
|
|
|
* Allocate the per-fd structure netmap_if.
|
|
|
|
*
|
|
|
|
* We assume that the configuration stored in na
|
|
|
|
* (number of tx/rx rings and descs) does not change while
|
|
|
|
* the interface is in netmap mode.
|
|
|
|
*/
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static struct netmap_if *
|
|
|
|
netmap_mem2_if_new(struct netmap_adapter *na)
|
2013-12-15 08:37:24 +00:00
|
|
|
{
|
|
|
|
struct netmap_if *nifp;
|
|
|
|
ssize_t base; /* handy for relative offsets between rings and nifp */
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
u_int i, len, n[NR_TXRX], ntot;
|
|
|
|
enum txrx t;
|
|
|
|
|
|
|
|
ntot = 0;
|
|
|
|
for_rx_tx(t) {
|
|
|
|
/* account for the (eventually fake) host rings */
|
|
|
|
n[t] = nma_get_nrings(na, t) + 1;
|
|
|
|
ntot += n[t];
|
|
|
|
}
|
2013-12-15 08:37:24 +00:00
|
|
|
/*
|
|
|
|
* the descriptor is followed inline by an array of offsets
|
|
|
|
* to the tx and rx rings in the shared memory region.
|
|
|
|
*/
|
|
|
|
|
|
|
|
NMA_LOCK(na->nm_mem);
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
len = sizeof(struct netmap_if) + (ntot * sizeof(ssize_t));
|
2013-12-15 08:37:24 +00:00
|
|
|
nifp = netmap_if_malloc(na->nm_mem, len);
|
|
|
|
if (nifp == NULL) {
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize base fields -- override const */
|
|
|
|
*(u_int *)(uintptr_t)&nifp->ni_tx_rings = na->num_tx_rings;
|
|
|
|
*(u_int *)(uintptr_t)&nifp->ni_rx_rings = na->num_rx_rings;
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
strncpy(nifp->ni_name, na->name, (size_t)IFNAMSIZ);
|
2013-12-15 08:37:24 +00:00
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
/*
|
|
|
|
* fill the slots for the rx and tx rings. They contain the offset
|
|
|
|
* between the ring and nifp, so the information is usable in
|
|
|
|
* userspace to reach the ring from the nifp.
|
|
|
|
*/
|
2013-11-01 21:21:14 +00:00
|
|
|
base = netmap_if_offset(na->nm_mem, nifp);
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
for (i = 0; i < n[NR_TX]; i++) {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (na->tx_rings[i].ring == NULL) {
|
|
|
|
// XXX maybe use the offset of an error ring,
|
|
|
|
// like we do for buffers?
|
|
|
|
*(ssize_t *)(uintptr_t)&nifp->ring_ofs[i] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2012-04-13 16:32:33 +00:00
|
|
|
*(ssize_t *)(uintptr_t)&nifp->ring_ofs[i] =
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_ring_offset(na->nm_mem, na->tx_rings[i].ring) - base;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
for (i = 0; i < n[NR_RX]; i++) {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (na->rx_rings[i].ring == NULL) {
|
|
|
|
// XXX maybe use the offset of an error ring,
|
|
|
|
// like we do for buffers?
|
|
|
|
*(ssize_t *)(uintptr_t)&nifp->ring_ofs[i+n[NR_TX]] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
*(ssize_t *)(uintptr_t)&nifp->ring_ofs[i+n[NR_TX]] =
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_ring_offset(na->nm_mem, na->rx_rings[i].ring) - base;
|
2012-04-13 16:32:33 +00:00
|
|
|
}
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
return (nifp);
|
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
static void
|
|
|
|
netmap_mem2_if_delete(struct netmap_adapter *na, struct netmap_if *nifp)
|
2013-11-01 21:21:14 +00:00
|
|
|
{
|
|
|
|
if (nifp == NULL)
|
|
|
|
/* nothing to do */
|
|
|
|
return;
|
|
|
|
NMA_LOCK(na->nm_mem);
|
This new version of netmap brings you the following:
- netmap pipes, providing bidirectional blocking I/O while moving
100+ Mpps between processes using shared memory channels
(no mistake: over one hundred million. But mind you, i said
*moving* not *processing*);
- kqueue support (BHyVe needs it);
- improved user library. Just the interface name lets you select a NIC,
host port, VALE switch port, netmap pipe, and individual queues.
The upcoming netmap-enabled libpcap will use this feature.
- optional extra buffers associated to netmap ports, for applications
that need to buffer data yet don't want to make copies.
- segmentation offloading for the VALE switch, useful between VMs.
and a number of bug fixes and performance improvements.
My colleagues Giuseppe Lettieri and Vincenzo Maffione did a substantial
amount of work on these features so we owe them a big thanks.
There are some external repositories that can be of interest:
https://code.google.com/p/netmap
our public repository for netmap/VALE code, including
linux versions and other stuff that does not belong here,
such as python bindings.
https://code.google.com/p/netmap-libpcap
a clone of the libpcap repository with netmap support.
With this any libpcap client has access to most netmap
feature with no recompilation. E.g. tcpdump can filter
packets at 10-15 Mpps.
https://code.google.com/p/netmap-ipfw
a userspace version of ipfw+dummynet which uses netmap
to send/receive packets. Speed is up in the 7-10 Mpps
range per core for simple rulesets.
Both netmap-libpcap and netmap-ipfw will be merged upstream at some
point, but while this happens it is useful to have access to them.
And yes, this code will be merged soon. It is infinitely better
than the version currently in 10 and 9.
MFC after: 3 days
2014-02-15 04:53:04 +00:00
|
|
|
if (nifp->ni_bufs_head)
|
|
|
|
netmap_extra_free(na, nifp->ni_bufs_head);
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_if_free(na->nm_mem, nifp);
|
|
|
|
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
}
|
|
|
|
|
2012-04-13 16:32:33 +00:00
|
|
|
static void
|
2013-11-01 21:21:14 +00:00
|
|
|
netmap_mem_global_deref(struct netmap_mem_d *nmd)
|
2012-04-13 16:32:33 +00:00
|
|
|
{
|
2013-11-01 21:21:14 +00:00
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
nmd->active--;
|
|
|
|
if (!nmd->active)
|
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.
2014-08-16 15:00:01 +00:00
|
|
|
nmd->nm_grp = -1;
|
2013-01-23 03:51:47 +00:00
|
|
|
if (netmap_verbose)
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
D("active = %d", nmd->active);
|
2013-11-01 21:21:14 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
Sync netmap sources with the version in our private tree.
This commit contains large contributions from Giuseppe Lettieri and
Stefano Garzarella, is partly supported by grants from Verisign and Cisco,
and brings in the following:
- fix zerocopy monitor ports and introduce copying monitor ports
(the latter are lower performance but give access to all traffic
in parallel with the application)
- exclusive open mode, useful to implement solutions that recover
from crashes of the main netmap client (suggested by Patrick Kelsey)
- revised memory allocator in preparation for the 'passthrough mode'
(ptnetmap) recently presented at bsdcan. ptnetmap is described in
S. Garzarella, G. Lettieri, L. Rizzo;
Virtual device passthrough for high speed VM networking,
ACM/IEEE ANCS 2015, Oakland (CA) May 2015
http://info.iet.unipi.it/~luigi/research.html
- fix rx CRC handing on ixl
- add module dependencies for netmap when building drivers as modules
- minor simplifications to device-specific routines (*txsync, *rxsync)
- general code cleanup (remove unused variables, introduce macros
to access rings and remove duplicate code,
Applications do not need to be recompiled, unless of course
they want to use the new features (monitors and exclusive open).
Those willing to try this code on stable/10 can just update the
sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
and apply the small patches to individual device drivers.
MFC after: 1 month
Sponsored by: (partly) Verisign, Cisco
2015-07-10 05:51:36 +00:00
|
|
|
struct netmap_mem_ops netmap_mem_global_ops = {
|
|
|
|
.nmd_get_lut = netmap_mem2_get_lut,
|
|
|
|
.nmd_get_info = netmap_mem2_get_info,
|
|
|
|
.nmd_ofstophys = netmap_mem2_ofstophys,
|
|
|
|
.nmd_config = netmap_mem_global_config,
|
|
|
|
.nmd_finalize = netmap_mem_global_finalize,
|
|
|
|
.nmd_deref = netmap_mem_global_deref,
|
|
|
|
.nmd_delete = netmap_mem_global_delete,
|
|
|
|
.nmd_if_offset = netmap_mem2_if_offset,
|
|
|
|
.nmd_if_new = netmap_mem2_if_new,
|
|
|
|
.nmd_if_delete = netmap_mem2_if_delete,
|
|
|
|
.nmd_rings_create = netmap_mem2_rings_create,
|
|
|
|
.nmd_rings_delete = netmap_mem2_rings_delete
|
|
|
|
};
|
|
|
|
struct netmap_mem_ops netmap_mem_private_ops = {
|
|
|
|
.nmd_get_lut = netmap_mem2_get_lut,
|
|
|
|
.nmd_get_info = netmap_mem2_get_info,
|
|
|
|
.nmd_ofstophys = netmap_mem2_ofstophys,
|
|
|
|
.nmd_config = netmap_mem_private_config,
|
|
|
|
.nmd_finalize = netmap_mem_private_finalize,
|
|
|
|
.nmd_deref = netmap_mem_private_deref,
|
|
|
|
.nmd_if_offset = netmap_mem2_if_offset,
|
|
|
|
.nmd_delete = netmap_mem_private_delete,
|
|
|
|
.nmd_if_new = netmap_mem2_if_new,
|
|
|
|
.nmd_if_delete = netmap_mem2_if_delete,
|
|
|
|
.nmd_rings_create = netmap_mem2_rings_create,
|
|
|
|
.nmd_rings_delete = netmap_mem2_rings_delete
|
|
|
|
};
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
2016-10-27 09:46:22 +00:00
|
|
|
int
|
|
|
|
netmap_mem_pools_info_get(struct nmreq *nmr, struct netmap_adapter *na)
|
|
|
|
{
|
|
|
|
uintptr_t *pp = (uintptr_t *)&nmr->nr_arg1;
|
|
|
|
struct netmap_pools_info *upi = (struct netmap_pools_info *)(*pp);
|
|
|
|
struct netmap_mem_d *nmd = na->nm_mem;
|
|
|
|
struct netmap_pools_info pi;
|
|
|
|
unsigned int memsize;
|
|
|
|
uint16_t memid;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!nmd) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = netmap_mem_get_info(nmd, &memsize, NULL, &memid);
|
|
|
|
if (ret) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
pi.memsize = memsize;
|
|
|
|
pi.memid = memid;
|
|
|
|
pi.if_pool_offset = 0;
|
|
|
|
pi.if_pool_objtotal = nmd->pools[NETMAP_IF_POOL].objtotal;
|
|
|
|
pi.if_pool_objsize = nmd->pools[NETMAP_IF_POOL]._objsize;
|
|
|
|
|
|
|
|
pi.ring_pool_offset = nmd->pools[NETMAP_IF_POOL].memtotal;
|
|
|
|
pi.ring_pool_objtotal = nmd->pools[NETMAP_RING_POOL].objtotal;
|
|
|
|
pi.ring_pool_objsize = nmd->pools[NETMAP_RING_POOL]._objsize;
|
|
|
|
|
|
|
|
pi.buf_pool_offset = nmd->pools[NETMAP_IF_POOL].memtotal +
|
|
|
|
nmd->pools[NETMAP_RING_POOL].memtotal;
|
|
|
|
pi.buf_pool_objtotal = nmd->pools[NETMAP_BUF_POOL].objtotal;
|
|
|
|
pi.buf_pool_objsize = nmd->pools[NETMAP_BUF_POOL]._objsize;
|
|
|
|
|
|
|
|
ret = copyout(&pi, upi, sizeof(pi));
|
|
|
|
if (ret) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
#ifdef WITH_PTNETMAP_GUEST
|
|
|
|
struct mem_pt_if {
|
|
|
|
struct mem_pt_if *next;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
unsigned int nifp_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Netmap allocator for ptnetmap guests. */
|
|
|
|
struct netmap_mem_ptg {
|
|
|
|
struct netmap_mem_d up;
|
|
|
|
|
|
|
|
vm_paddr_t nm_paddr; /* physical address in the guest */
|
|
|
|
void *nm_addr; /* virtual address in the guest */
|
|
|
|
struct netmap_lut buf_lut; /* lookup table for BUF pool in the guest */
|
2016-10-27 09:46:22 +00:00
|
|
|
nm_memid_t host_mem_id; /* allocator identifier in the host */
|
|
|
|
struct ptnetmap_memdev *ptn_dev;/* ptnetmap memdev */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
struct mem_pt_if *pt_ifs; /* list of interfaces in passthrough */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Link a passthrough interface to a passthrough netmap allocator. */
|
|
|
|
static int
|
|
|
|
netmap_mem_pt_guest_ifp_add(struct netmap_mem_d *nmd, struct ifnet *ifp,
|
2016-10-27 09:46:22 +00:00
|
|
|
unsigned int nifp_offset)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
struct mem_pt_if *ptif = malloc(sizeof(*ptif), M_NETMAP,
|
|
|
|
M_NOWAIT | M_ZERO);
|
|
|
|
|
|
|
|
if (!ptif) {
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
|
|
|
|
ptif->ifp = ifp;
|
|
|
|
ptif->nifp_offset = nifp_offset;
|
|
|
|
|
|
|
|
if (ptnmd->pt_ifs) {
|
|
|
|
ptif->next = ptnmd->pt_ifs;
|
|
|
|
}
|
|
|
|
ptnmd->pt_ifs = ptif;
|
|
|
|
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
|
|
|
|
D("added (ifp=%p,nifp_offset=%u)", ptif->ifp, ptif->nifp_offset);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called with NMA_LOCK(nmd) held. */
|
|
|
|
static struct mem_pt_if *
|
|
|
|
netmap_mem_pt_guest_ifp_lookup(struct netmap_mem_d *nmd, struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
struct mem_pt_if *curr;
|
|
|
|
|
|
|
|
for (curr = ptnmd->pt_ifs; curr; curr = curr->next) {
|
|
|
|
if (curr->ifp == ifp) {
|
|
|
|
return curr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlink a passthrough interface from a passthrough netmap allocator. */
|
|
|
|
int
|
|
|
|
netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *nmd, struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
struct mem_pt_if *prev = NULL;
|
|
|
|
struct mem_pt_if *curr;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
|
|
|
|
for (curr = ptnmd->pt_ifs; curr; curr = curr->next) {
|
|
|
|
if (curr->ifp == ifp) {
|
|
|
|
if (prev) {
|
|
|
|
prev->next = curr->next;
|
|
|
|
} else {
|
|
|
|
ptnmd->pt_ifs = curr->next;
|
|
|
|
}
|
|
|
|
D("removed (ifp=%p,nifp_offset=%u)",
|
|
|
|
curr->ifp, curr->nifp_offset);
|
|
|
|
free(curr, M_NETMAP);
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prev = curr;
|
|
|
|
}
|
|
|
|
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_pt_guest_get_lut(struct netmap_mem_d *nmd, struct netmap_lut *lut)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
|
|
|
|
if (!(nmd->flags & NETMAP_MEM_FINALIZED)) {
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*lut = ptnmd->buf_lut;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_pt_guest_get_info(struct netmap_mem_d *nmd, u_int *size,
|
|
|
|
u_int *memflags, uint16_t *id)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
NMA_LOCK(nmd);
|
|
|
|
|
|
|
|
error = nmd->ops->nmd_config(nmd);
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
*size = nmd->nm_totalsize;
|
|
|
|
if (memflags)
|
|
|
|
*memflags = nmd->flags;
|
|
|
|
if (id)
|
|
|
|
*id = nmd->nm_id;
|
|
|
|
|
|
|
|
out:
|
|
|
|
NMA_UNLOCK(nmd);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static vm_paddr_t
|
|
|
|
netmap_mem_pt_guest_ofstophys(struct netmap_mem_d *nmd, vm_ooffset_t off)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
vm_paddr_t paddr;
|
|
|
|
/* if the offset is valid, just return csb->base_addr + off */
|
|
|
|
paddr = (vm_paddr_t)(ptnmd->nm_paddr + off);
|
|
|
|
ND("off %lx padr %lx", off, (unsigned long)paddr);
|
|
|
|
return paddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_pt_guest_config(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
/* nothing to do, we are configured on creation
|
|
|
|
* and configuration never changes thereafter
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_pt_guest_finalize(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
2016-10-27 09:46:22 +00:00
|
|
|
uint64_t mem_size;
|
|
|
|
uint32_t bufsize;
|
|
|
|
uint32_t nbuffers;
|
|
|
|
uint32_t poolofs;
|
|
|
|
vm_paddr_t paddr;
|
|
|
|
char *vaddr;
|
|
|
|
int i;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
nmd->active++;
|
|
|
|
|
|
|
|
if (nmd->flags & NETMAP_MEM_FINALIZED)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (ptnmd->ptn_dev == NULL) {
|
|
|
|
D("ptnetmap memdev not attached");
|
|
|
|
error = ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
2016-10-27 09:46:22 +00:00
|
|
|
/* Map memory through ptnetmap-memdev BAR. */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
error = nm_os_pt_memdev_iomap(ptnmd->ptn_dev, &ptnmd->nm_paddr,
|
2016-10-27 09:46:22 +00:00
|
|
|
&ptnmd->nm_addr, &mem_size);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (error)
|
|
|
|
goto err;
|
|
|
|
|
2016-10-27 09:46:22 +00:00
|
|
|
/* Initialize the lut using the information contained in the
|
|
|
|
* ptnetmap memory device. */
|
|
|
|
bufsize = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
|
|
|
|
PTNET_MDEV_IO_BUF_POOL_OBJSZ);
|
|
|
|
nbuffers = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
|
|
|
|
PTNET_MDEV_IO_BUF_POOL_OBJNUM);
|
|
|
|
|
|
|
|
/* allocate the lut */
|
|
|
|
if (ptnmd->buf_lut.lut == NULL) {
|
|
|
|
D("allocating lut");
|
|
|
|
ptnmd->buf_lut.lut = nm_alloc_lut(nbuffers);
|
|
|
|
if (ptnmd->buf_lut.lut == NULL) {
|
|
|
|
D("lut allocation failed");
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we have physically contiguous memory mapped through PCI BAR */
|
|
|
|
poolofs = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
|
|
|
|
PTNET_MDEV_IO_BUF_POOL_OFS);
|
|
|
|
vaddr = (char *)(ptnmd->nm_addr) + poolofs;
|
|
|
|
paddr = ptnmd->nm_paddr + poolofs;
|
|
|
|
|
|
|
|
for (i = 0; i < nbuffers; i++) {
|
|
|
|
ptnmd->buf_lut.lut[i].vaddr = vaddr;
|
|
|
|
ptnmd->buf_lut.lut[i].paddr = paddr;
|
|
|
|
vaddr += bufsize;
|
|
|
|
paddr += bufsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptnmd->buf_lut.objtotal = nbuffers;
|
|
|
|
ptnmd->buf_lut.objsize = bufsize;
|
|
|
|
nmd->nm_totalsize = (unsigned int)mem_size;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
|
|
|
nmd->flags |= NETMAP_MEM_FINALIZED;
|
|
|
|
out:
|
|
|
|
return 0;
|
|
|
|
err:
|
|
|
|
nmd->active--;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_mem_pt_guest_deref(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
|
|
|
|
nmd->active--;
|
|
|
|
if (nmd->active <= 0 &&
|
|
|
|
(nmd->flags & NETMAP_MEM_FINALIZED)) {
|
|
|
|
nmd->flags &= ~NETMAP_MEM_FINALIZED;
|
|
|
|
/* unmap ptnetmap-memdev memory */
|
|
|
|
if (ptnmd->ptn_dev) {
|
|
|
|
nm_os_pt_memdev_iounmap(ptnmd->ptn_dev);
|
|
|
|
}
|
|
|
|
ptnmd->nm_addr = 0;
|
|
|
|
ptnmd->nm_paddr = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
netmap_mem_pt_guest_if_offset(struct netmap_mem_d *nmd, const void *vaddr)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
|
|
|
|
return (const char *)(vaddr) - (char *)(ptnmd->nm_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_mem_pt_guest_delete(struct netmap_mem_d *nmd)
|
|
|
|
{
|
|
|
|
if (nmd == NULL)
|
|
|
|
return;
|
|
|
|
if (netmap_verbose)
|
|
|
|
D("deleting %p", nmd);
|
|
|
|
if (nmd->active > 0)
|
|
|
|
D("bug: deleting mem allocator with active=%d!", nmd->active);
|
|
|
|
nm_mem_release_id(nmd);
|
|
|
|
if (netmap_verbose)
|
|
|
|
D("done deleting %p", nmd);
|
|
|
|
NMA_LOCK_DESTROY(nmd);
|
|
|
|
free(nmd, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct netmap_if *
|
|
|
|
netmap_mem_pt_guest_if_new(struct netmap_adapter *na)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)na->nm_mem;
|
|
|
|
struct mem_pt_if *ptif;
|
|
|
|
struct netmap_if *nifp = NULL;
|
|
|
|
|
|
|
|
NMA_LOCK(na->nm_mem);
|
|
|
|
|
|
|
|
ptif = netmap_mem_pt_guest_ifp_lookup(na->nm_mem, na->ifp);
|
|
|
|
if (ptif == NULL) {
|
|
|
|
D("Error: interface %p is not in passthrough", na->ifp);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
nifp = (struct netmap_if *)((char *)(ptnmd->nm_addr) +
|
|
|
|
ptif->nifp_offset);
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
out:
|
|
|
|
return nifp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_mem_pt_guest_if_delete(struct netmap_adapter *na, struct netmap_if *nifp)
|
|
|
|
{
|
|
|
|
struct mem_pt_if *ptif;
|
|
|
|
|
|
|
|
NMA_LOCK(na->nm_mem);
|
|
|
|
ptif = netmap_mem_pt_guest_ifp_lookup(na->nm_mem, na->ifp);
|
|
|
|
if (ptif == NULL) {
|
|
|
|
D("Error: interface %p is not in passthrough", na->ifp);
|
|
|
|
}
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
netmap_mem_pt_guest_rings_create(struct netmap_adapter *na)
|
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)na->nm_mem;
|
|
|
|
struct mem_pt_if *ptif;
|
|
|
|
struct netmap_if *nifp;
|
|
|
|
int i, error = -1;
|
|
|
|
|
|
|
|
NMA_LOCK(na->nm_mem);
|
|
|
|
|
|
|
|
ptif = netmap_mem_pt_guest_ifp_lookup(na->nm_mem, na->ifp);
|
|
|
|
if (ptif == NULL) {
|
|
|
|
D("Error: interface %p is not in passthrough", na->ifp);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* point each kring to the corresponding backend ring */
|
|
|
|
nifp = (struct netmap_if *)((char *)ptnmd->nm_addr + ptif->nifp_offset);
|
|
|
|
for (i = 0; i <= na->num_tx_rings; i++) {
|
|
|
|
struct netmap_kring *kring = na->tx_rings + i;
|
|
|
|
if (kring->ring)
|
|
|
|
continue;
|
|
|
|
kring->ring = (struct netmap_ring *)
|
|
|
|
((char *)nifp + nifp->ring_ofs[i]);
|
|
|
|
}
|
|
|
|
for (i = 0; i <= na->num_rx_rings; i++) {
|
|
|
|
struct netmap_kring *kring = na->rx_rings + i;
|
|
|
|
if (kring->ring)
|
|
|
|
continue;
|
|
|
|
kring->ring = (struct netmap_ring *)
|
|
|
|
((char *)nifp +
|
|
|
|
nifp->ring_ofs[i + na->num_tx_rings + 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
out:
|
|
|
|
NMA_UNLOCK(na->nm_mem);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
netmap_mem_pt_guest_rings_delete(struct netmap_adapter *na)
|
|
|
|
{
|
|
|
|
/* TODO: remove?? */
|
|
|
|
#if 0
|
|
|
|
struct netmap_mem_ptg *ptnmd = (struct netmap_mem_ptg *)na->nm_mem;
|
|
|
|
struct mem_pt_if *ptif = netmap_mem_pt_guest_ifp_lookup(na->nm_mem,
|
|
|
|
na->ifp);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct netmap_mem_ops netmap_mem_pt_guest_ops = {
|
|
|
|
.nmd_get_lut = netmap_mem_pt_guest_get_lut,
|
|
|
|
.nmd_get_info = netmap_mem_pt_guest_get_info,
|
|
|
|
.nmd_ofstophys = netmap_mem_pt_guest_ofstophys,
|
|
|
|
.nmd_config = netmap_mem_pt_guest_config,
|
|
|
|
.nmd_finalize = netmap_mem_pt_guest_finalize,
|
|
|
|
.nmd_deref = netmap_mem_pt_guest_deref,
|
|
|
|
.nmd_if_offset = netmap_mem_pt_guest_if_offset,
|
|
|
|
.nmd_delete = netmap_mem_pt_guest_delete,
|
|
|
|
.nmd_if_new = netmap_mem_pt_guest_if_new,
|
|
|
|
.nmd_if_delete = netmap_mem_pt_guest_if_delete,
|
|
|
|
.nmd_rings_create = netmap_mem_pt_guest_rings_create,
|
|
|
|
.nmd_rings_delete = netmap_mem_pt_guest_rings_delete
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Called with NMA_LOCK(&nm_mem) held. */
|
|
|
|
static struct netmap_mem_d *
|
2016-10-27 09:46:22 +00:00
|
|
|
netmap_mem_pt_guest_find_memid(nm_memid_t mem_id)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_d *mem = NULL;
|
|
|
|
struct netmap_mem_d *scan = netmap_last_mem_d;
|
|
|
|
|
|
|
|
do {
|
|
|
|
/* find ptnetmap allocator through host ID */
|
|
|
|
if (scan->ops->nmd_deref == netmap_mem_pt_guest_deref &&
|
2016-10-27 09:46:22 +00:00
|
|
|
((struct netmap_mem_ptg *)(scan))->host_mem_id == mem_id) {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
mem = scan;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
scan = scan->next;
|
|
|
|
} while (scan != netmap_last_mem_d);
|
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called with NMA_LOCK(&nm_mem) held. */
|
|
|
|
static struct netmap_mem_d *
|
2016-10-27 09:46:22 +00:00
|
|
|
netmap_mem_pt_guest_create(nm_memid_t mem_id)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_ptg *ptnmd;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
ptnmd = malloc(sizeof(struct netmap_mem_ptg),
|
|
|
|
M_DEVBUF, M_NOWAIT | M_ZERO);
|
|
|
|
if (ptnmd == NULL) {
|
|
|
|
err = ENOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptnmd->up.ops = &netmap_mem_pt_guest_ops;
|
2016-10-27 09:46:22 +00:00
|
|
|
ptnmd->host_mem_id = mem_id;
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
ptnmd->pt_ifs = NULL;
|
|
|
|
|
|
|
|
/* Assign new id in the guest (We have the lock) */
|
|
|
|
err = nm_mem_assign_id_locked(&ptnmd->up);
|
|
|
|
if (err)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ptnmd->up.flags &= ~NETMAP_MEM_FINALIZED;
|
|
|
|
ptnmd->up.flags |= NETMAP_MEM_IO;
|
|
|
|
|
|
|
|
NMA_LOCK_INIT(&ptnmd->up);
|
|
|
|
|
|
|
|
return &ptnmd->up;
|
|
|
|
error:
|
|
|
|
netmap_mem_pt_guest_delete(&ptnmd->up);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find host id in guest allocators and create guest allocator
|
|
|
|
* if it is not there
|
|
|
|
*/
|
|
|
|
static struct netmap_mem_d *
|
2016-10-27 09:46:22 +00:00
|
|
|
netmap_mem_pt_guest_get(nm_memid_t mem_id)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_d *nmd;
|
|
|
|
|
|
|
|
NMA_LOCK(&nm_mem);
|
2016-10-27 09:46:22 +00:00
|
|
|
nmd = netmap_mem_pt_guest_find_memid(mem_id);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
if (nmd == NULL) {
|
2016-10-27 09:46:22 +00:00
|
|
|
nmd = netmap_mem_pt_guest_create(mem_id);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
}
|
|
|
|
NMA_UNLOCK(&nm_mem);
|
|
|
|
|
|
|
|
return nmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The guest allocator can be created by ptnetmap_memdev (during the device
|
2016-10-27 09:46:22 +00:00
|
|
|
* attach) or by ptnetmap device (ptnet), during the netmap_attach.
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
*
|
|
|
|
* The order is not important (we have different order in LINUX and FreeBSD).
|
|
|
|
* The first one, creates the device, and the second one simply attaches it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Called when ptnetmap_memdev is attaching, to attach a new allocator in
|
|
|
|
* the guest */
|
|
|
|
struct netmap_mem_d *
|
2016-10-27 09:46:22 +00:00
|
|
|
netmap_mem_pt_guest_attach(struct ptnetmap_memdev *ptn_dev, nm_memid_t mem_id)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_d *nmd;
|
|
|
|
struct netmap_mem_ptg *ptnmd;
|
|
|
|
|
2016-10-27 09:46:22 +00:00
|
|
|
nmd = netmap_mem_pt_guest_get(mem_id);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
|
|
|
/* assign this device to the guest allocator */
|
|
|
|
if (nmd) {
|
|
|
|
ptnmd = (struct netmap_mem_ptg *)nmd;
|
|
|
|
ptnmd->ptn_dev = ptn_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nmd;
|
|
|
|
}
|
|
|
|
|
2016-10-27 09:46:22 +00:00
|
|
|
/* Called when ptnet device is attaching */
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
struct netmap_mem_d *
|
|
|
|
netmap_mem_pt_guest_new(struct ifnet *ifp,
|
|
|
|
unsigned int nifp_offset,
|
2016-10-27 09:46:22 +00:00
|
|
|
unsigned int memid)
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
{
|
|
|
|
struct netmap_mem_d *nmd;
|
|
|
|
|
2016-10-27 09:46:22 +00:00
|
|
|
if (ifp == NULL) {
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-10-27 09:46:22 +00:00
|
|
|
nmd = netmap_mem_pt_guest_get((nm_memid_t)memid);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
|
|
|
|
if (nmd) {
|
2016-10-27 09:46:22 +00:00
|
|
|
netmap_mem_pt_guest_ifp_add(nmd, ifp, nifp_offset);
|
Import the current version of netmap, aligned with the one on github.
This commit, long overdue, contains contributions in the last 2 years
from Stefano Garzarella, Giuseppe Lettieri, Vincenzo Maffione, including:
+ fixes on monitor ports
+ the 'ptnet' virtual device driver, and ptnetmap backend, for
high speed virtual passthrough on VMs (bhyve fixes in an upcoming commit)
+ improved emulated netmap mode
+ more robust error handling
+ removal of stale code
+ various fixes to code and documentation (some mixup between RX and TX
parameters, and private and public variables)
We also include an additional tool, nmreplay, which is functionally
equivalent to tcpreplay but operating on netmap ports.
2016-10-16 14:13:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* WITH_PTNETMAP_GUEST */
|