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
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Vincenzo Maffione, Luigi Rizzo. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <net/netmap.h>
|
|
|
|
#include <sys/selinfo.h>
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h> /* vtophys ? */
|
|
|
|
#include <dev/netmap/netmap_kern.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define SOFTC_T vtnet_softc
|
|
|
|
|
|
|
|
/* Free all the unused buffer in all the RX virtqueues.
|
|
|
|
* This function is called when entering and exiting netmap mode.
|
|
|
|
* - buffers queued by the virtio driver return skbuf/mbuf pointer
|
|
|
|
* and need to be freed;
|
|
|
|
* - buffers queued by netmap return the txq/rxq, and do not need work
|
|
|
|
*/
|
2014-08-17 10:25:27 +00:00
|
|
|
static void
|
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
|
|
|
vtnet_netmap_free_bufs(struct SOFTC_T* sc)
|
|
|
|
{
|
|
|
|
int i, nmb = 0, n = 0, last;
|
|
|
|
|
|
|
|
for (i = 0; i < sc->vtnet_max_vq_pairs; i++) {
|
|
|
|
struct vtnet_rxq *rxq = &sc->vtnet_rxqs[i];
|
|
|
|
struct virtqueue *vq;
|
|
|
|
struct mbuf *m;
|
|
|
|
struct vtnet_txq *txq = &sc->vtnet_txqs[i];
|
|
|
|
struct vtnet_tx_header *txhdr;
|
|
|
|
|
|
|
|
last = 0;
|
|
|
|
vq = rxq->vtnrx_vq;
|
|
|
|
while ((m = virtqueue_drain(vq, &last)) != NULL) {
|
|
|
|
n++;
|
|
|
|
if (m != (void *)rxq)
|
|
|
|
m_freem(m);
|
|
|
|
else
|
|
|
|
nmb++;
|
|
|
|
}
|
|
|
|
|
|
|
|
last = 0;
|
|
|
|
vq = txq->vtntx_vq;
|
|
|
|
while ((txhdr = virtqueue_drain(vq, &last)) != NULL) {
|
|
|
|
n++;
|
|
|
|
if (txhdr != (void *)txq) {
|
|
|
|
m_freem(txhdr->vth_mbuf);
|
|
|
|
uma_zfree(vtnet_tx_header_zone, txhdr);
|
|
|
|
} else
|
|
|
|
nmb++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
D("freed %d mbufs, %d netmap bufs on %d queues",
|
|
|
|
n - nmb, nmb, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register and unregister. */
|
2014-08-17 10:25:27 +00:00
|
|
|
static int
|
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
|
|
|
vtnet_netmap_reg(struct netmap_adapter *na, int onoff)
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = na->ifp;
|
|
|
|
struct SOFTC_T *sc = ifp->if_softc;
|
|
|
|
|
|
|
|
VTNET_CORE_LOCK(sc);
|
|
|
|
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
|
|
|
/* enable or disable flags and callbacks in na and ifp */
|
|
|
|
if (onoff) {
|
|
|
|
nm_set_native_flags(na);
|
|
|
|
} else {
|
|
|
|
nm_clear_native_flags(na);
|
|
|
|
}
|
|
|
|
/* drain queues so netmap and native drivers
|
|
|
|
* do not interfere with each other
|
|
|
|
*/
|
|
|
|
vtnet_netmap_free_bufs(sc);
|
|
|
|
vtnet_init_locked(sc); /* also enable intr */
|
|
|
|
VTNET_CORE_UNLOCK(sc);
|
|
|
|
return (ifp->if_drv_flags & IFF_DRV_RUNNING ? 0 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reconcile kernel and user view of the transmit ring. */
|
|
|
|
static int
|
|
|
|
vtnet_netmap_txsync(struct netmap_kring *kring, int flags)
|
|
|
|
{
|
|
|
|
struct netmap_adapter *na = kring->na;
|
|
|
|
struct ifnet *ifp = na->ifp;
|
|
|
|
struct netmap_ring *ring = kring->ring;
|
|
|
|
u_int ring_nr = kring->ring_id;
|
|
|
|
u_int nm_i; /* index into the netmap ring */
|
|
|
|
u_int nic_i; /* index into the NIC ring */
|
|
|
|
u_int n;
|
|
|
|
u_int const lim = kring->nkr_num_slots - 1;
|
|
|
|
u_int const head = kring->rhead;
|
|
|
|
|
|
|
|
/* device-specific */
|
|
|
|
struct SOFTC_T *sc = ifp->if_softc;
|
|
|
|
struct vtnet_txq *txq = &sc->vtnet_txqs[ring_nr];
|
|
|
|
struct virtqueue *vq = txq->vtntx_vq;
|
2018-04-09 09:24:26 +00:00
|
|
|
int interrupts = !(kring->nr_kflags & NKR_NOINTR);
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* First part: process new packets to send.
|
|
|
|
*/
|
|
|
|
rmb();
|
2016-10-18 15:41:57 +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
|
|
|
nm_i = kring->nr_hwcur;
|
|
|
|
if (nm_i != head) { /* we have new packets to send */
|
|
|
|
struct sglist *sg = txq->vtntx_sg;
|
|
|
|
|
|
|
|
nic_i = netmap_idx_k2n(kring, nm_i);
|
|
|
|
for (n = 0; nm_i != head; n++) {
|
|
|
|
/* we use an empty header here */
|
|
|
|
static struct virtio_net_hdr_mrg_rxbuf hdr;
|
|
|
|
struct netmap_slot *slot = &ring->slot[nm_i];
|
|
|
|
u_int len = slot->len;
|
|
|
|
uint64_t paddr;
|
|
|
|
void *addr = PNMB(na, slot, &paddr);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
NM_CHECK_ADDR_LEN(na, addr, len);
|
|
|
|
|
|
|
|
slot->flags &= ~(NS_REPORT | NS_BUF_CHANGED);
|
|
|
|
/* Initialize the scatterlist, expose it to the hypervisor,
|
|
|
|
* and kick the hypervisor (if necessary).
|
|
|
|
*/
|
|
|
|
sglist_reset(sg); // cheap
|
|
|
|
// if vtnet_hdr_size > 0 ...
|
|
|
|
err = sglist_append(sg, &hdr, sc->vtnet_hdr_size);
|
|
|
|
// XXX later, support multi segment
|
|
|
|
err = sglist_append_phys(sg, paddr, len);
|
|
|
|
/* use na as the cookie */
|
|
|
|
err = virtqueue_enqueue(vq, txq, sg, sg->sg_nseg, 0);
|
|
|
|
if (unlikely(err < 0)) {
|
|
|
|
D("virtqueue_enqueue failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nm_i = nm_next(nm_i, lim);
|
|
|
|
nic_i = nm_next(nic_i, lim);
|
|
|
|
}
|
|
|
|
/* Update hwcur depending on where we stopped. */
|
|
|
|
kring->nr_hwcur = nm_i; /* note we migth break early */
|
|
|
|
|
|
|
|
/* No more free TX slots? Ask the hypervisor for notifications,
|
|
|
|
* possibly only when a considerable amount of work has been
|
|
|
|
* done.
|
|
|
|
*/
|
|
|
|
ND(3,"sent %d packets, hwcur %d", n, nm_i);
|
|
|
|
virtqueue_disable_intr(vq);
|
|
|
|
virtqueue_notify(vq);
|
|
|
|
} else {
|
|
|
|
if (ring->head != ring->tail)
|
|
|
|
ND(5, "pure notify ? head %d tail %d nused %d %d",
|
|
|
|
ring->head, ring->tail, virtqueue_nused(vq),
|
|
|
|
(virtqueue_dump(vq), 1));
|
|
|
|
virtqueue_notify(vq);
|
2018-04-09 09:24:26 +00:00
|
|
|
if (interrupts) {
|
|
|
|
virtqueue_enable_intr(vq); // like postpone with 0
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2016-10-18 15:41:57 +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
|
|
|
/* Free used slots. We only consider our own used buffers, recognized
|
|
|
|
* by the token we passed to virtqueue_add_outbuf.
|
|
|
|
*/
|
|
|
|
n = 0;
|
|
|
|
for (;;) {
|
|
|
|
struct vtnet_tx_header *txhdr = virtqueue_dequeue(vq, NULL);
|
|
|
|
if (txhdr == NULL)
|
|
|
|
break;
|
|
|
|
if (likely(txhdr == (void *)txq)) {
|
|
|
|
n++;
|
|
|
|
if (virtqueue_nused(vq) < 32) { // XXX slow release
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else { /* leftover from previous transmission */
|
|
|
|
m_freem(txhdr->vth_mbuf);
|
|
|
|
uma_zfree(vtnet_tx_header_zone, txhdr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (n) {
|
|
|
|
kring->nr_hwtail += n;
|
|
|
|
if (kring->nr_hwtail > lim)
|
|
|
|
kring->nr_hwtail -= lim + 1;
|
|
|
|
}
|
|
|
|
if (nm_i != kring->nr_hwtail /* && vtnet_txq_below_threshold(txq) == 0*/) {
|
|
|
|
ND(3, "disable intr, hwcur %d", nm_i);
|
|
|
|
virtqueue_disable_intr(vq);
|
2018-04-09 09:24:26 +00:00
|
|
|
} else if (interrupts) {
|
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
|
|
|
ND(3, "enable intr, hwcur %d", nm_i);
|
|
|
|
virtqueue_postpone_intr(vq, VQ_POSTPONE_SHORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vtnet_refill_rxq(struct netmap_kring *kring, u_int nm_i, u_int head)
|
|
|
|
{
|
|
|
|
struct netmap_adapter *na = kring->na;
|
|
|
|
struct ifnet *ifp = na->ifp;
|
|
|
|
struct netmap_ring *ring = kring->ring;
|
|
|
|
u_int ring_nr = kring->ring_id;
|
|
|
|
u_int const lim = kring->nkr_num_slots - 1;
|
|
|
|
u_int n;
|
|
|
|
|
|
|
|
/* device-specific */
|
|
|
|
struct SOFTC_T *sc = ifp->if_softc;
|
|
|
|
struct vtnet_rxq *rxq = &sc->vtnet_rxqs[ring_nr];
|
|
|
|
struct virtqueue *vq = rxq->vtnrx_vq;
|
|
|
|
|
|
|
|
/* use a local sglist, default might be short */
|
|
|
|
struct sglist_seg ss[2];
|
2014-08-17 10:25:27 +00:00
|
|
|
struct sglist sg = { ss, 0, 0, 2 };
|
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
|
|
|
|
|
|
|
for (n = 0; nm_i != head; n++) {
|
|
|
|
static struct virtio_net_hdr_mrg_rxbuf hdr;
|
|
|
|
struct netmap_slot *slot = &ring->slot[nm_i];
|
|
|
|
uint64_t paddr;
|
|
|
|
void *addr = PNMB(na, slot, &paddr);
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (addr == NETMAP_BUF_BASE(na)) { /* bad buf */
|
|
|
|
if (netmap_ring_reinit(kring))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
slot->flags &= ~NS_BUF_CHANGED;
|
2014-08-17 10:25:27 +00:00
|
|
|
sglist_reset(&sg); // cheap
|
|
|
|
err = sglist_append(&sg, &hdr, sc->vtnet_hdr_size);
|
|
|
|
err = sglist_append_phys(&sg, paddr, NETMAP_BUF_SIZE(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
|
|
|
/* writable for the host */
|
2014-08-17 10:25:27 +00:00
|
|
|
err = virtqueue_enqueue(vq, rxq, &sg, 0, sg.sg_nseg);
|
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 (err < 0) {
|
|
|
|
D("virtqueue_enqueue failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nm_i = nm_next(nm_i, lim);
|
|
|
|
}
|
|
|
|
return nm_i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reconcile kernel and user view of the receive ring. */
|
|
|
|
static int
|
|
|
|
vtnet_netmap_rxsync(struct netmap_kring *kring, int flags)
|
|
|
|
{
|
|
|
|
struct netmap_adapter *na = kring->na;
|
|
|
|
struct ifnet *ifp = na->ifp;
|
|
|
|
struct netmap_ring *ring = kring->ring;
|
|
|
|
u_int ring_nr = kring->ring_id;
|
|
|
|
u_int nm_i; /* index into the netmap ring */
|
|
|
|
// u_int nic_i; /* index into the NIC ring */
|
|
|
|
u_int n;
|
|
|
|
u_int const lim = kring->nkr_num_slots - 1;
|
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 const head = kring->rhead;
|
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 force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR;
|
2018-04-09 09:24:26 +00:00
|
|
|
int interrupts = !(kring->nr_kflags & NKR_NOINTR);
|
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
|
|
|
|
|
|
|
/* device-specific */
|
|
|
|
struct SOFTC_T *sc = ifp->if_softc;
|
|
|
|
struct vtnet_rxq *rxq = &sc->vtnet_rxqs[ring_nr];
|
|
|
|
struct virtqueue *vq = rxq->vtnrx_vq;
|
|
|
|
|
|
|
|
/* XXX netif_carrier_ok ? */
|
|
|
|
|
|
|
|
if (head > lim)
|
|
|
|
return netmap_ring_reinit(kring);
|
|
|
|
|
|
|
|
rmb();
|
|
|
|
/*
|
|
|
|
* First part: import newly received packets.
|
|
|
|
* Only accept our
|
|
|
|
* own buffers (matching the token). We should only get
|
|
|
|
* matching buffers, because of vtnet_netmap_free_rx_unused_bufs()
|
|
|
|
* and vtnet_netmap_init_buffers().
|
|
|
|
*/
|
|
|
|
if (netmap_no_pendintr || force_update) {
|
|
|
|
struct netmap_adapter *token;
|
|
|
|
|
|
|
|
nm_i = kring->nr_hwtail;
|
|
|
|
n = 0;
|
|
|
|
for (;;) {
|
|
|
|
int len;
|
|
|
|
token = virtqueue_dequeue(vq, &len);
|
|
|
|
if (token == NULL)
|
|
|
|
break;
|
|
|
|
if (likely(token == (void *)rxq)) {
|
|
|
|
ring->slot[nm_i].len = len;
|
2018-04-09 09:24:26 +00:00
|
|
|
ring->slot[nm_i].flags = 0;
|
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_i = nm_next(nm_i, lim);
|
|
|
|
n++;
|
|
|
|
} else {
|
|
|
|
D("This should not happen");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
kring->nr_hwtail = nm_i;
|
|
|
|
kring->nr_kflags &= ~NKR_PENDINTR;
|
|
|
|
}
|
|
|
|
ND("[B] h %d c %d hwcur %d hwtail %d",
|
|
|
|
ring->head, ring->cur, kring->nr_hwcur,
|
|
|
|
kring->nr_hwtail);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Second part: skip past packets that userspace has released.
|
|
|
|
*/
|
|
|
|
nm_i = kring->nr_hwcur; /* netmap ring index */
|
|
|
|
if (nm_i != head) {
|
|
|
|
int err = vtnet_refill_rxq(kring, nm_i, head);
|
|
|
|
if (err < 0)
|
|
|
|
return 1;
|
|
|
|
kring->nr_hwcur = err;
|
|
|
|
virtqueue_notify(vq);
|
|
|
|
/* After draining the queue may need an intr from the hypervisor */
|
2018-04-09 09:24:26 +00:00
|
|
|
if (interrupts) {
|
|
|
|
vtnet_rxq_enable_intr(rxq);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
ND("[C] h %d c %d t %d hwcur %d hwtail %d",
|
|
|
|
ring->head, ring->cur, ring->tail,
|
|
|
|
kring->nr_hwcur, kring->nr_hwtail);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-09 09:24:26 +00:00
|
|
|
/* Enable/disable interrupts on all virtqueues. */
|
|
|
|
static void
|
|
|
|
vtnet_netmap_intr(struct netmap_adapter *na, int onoff)
|
|
|
|
{
|
|
|
|
struct SOFTC_T *sc = na->ifp->if_softc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sc->vtnet_max_vq_pairs; i++) {
|
|
|
|
struct vtnet_rxq *rxq = &sc->vtnet_rxqs[i];
|
|
|
|
struct vtnet_txq *txq = &sc->vtnet_txqs[i];
|
|
|
|
struct virtqueue *txvq = txq->vtntx_vq;
|
|
|
|
|
|
|
|
if (onoff) {
|
|
|
|
vtnet_rxq_enable_intr(rxq);
|
|
|
|
virtqueue_enable_intr(txvq);
|
|
|
|
} else {
|
|
|
|
vtnet_rxq_disable_intr(rxq);
|
|
|
|
virtqueue_disable_intr(txvq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* Make RX virtqueues buffers pointing to netmap buffers. */
|
|
|
|
static int
|
|
|
|
vtnet_netmap_init_rx_buffers(struct SOFTC_T *sc)
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = sc->vtnet_ifp;
|
|
|
|
struct netmap_adapter* na = NA(ifp);
|
|
|
|
unsigned int r;
|
|
|
|
|
|
|
|
if (!nm_native_on(na))
|
|
|
|
return 0;
|
|
|
|
for (r = 0; r < na->num_rx_rings; r++) {
|
netmap: align codebase to the current upstream (commit id 3fb001303718146)
Changelist:
- Turn tx_rings and rx_rings arrays into arrays of pointers to kring
structs. This patch includes fixes for ixv, ixl, ix, re, cxgbe, iflib,
vtnet and ptnet drivers to cope with the change.
- Generalize the nm_config() callback to accept a struct containing many
parameters.
- Introduce NKR_FAKERING to support buffers sharing (used for netmap
pipes)
- Improved API for external VALE modules.
- Various bug fixes and improvements to the netmap memory allocator,
including support for externally (userspace) allocated memory.
- Refactoring of netmap pipes: now linked rings share the same netmap
buffers, with a separate set of kring pointers (rhead, rcur, rtail).
Buffer swapping does not need to happen anymore.
- Large refactoring of the control API towards an extensible solution;
the goal is to allow the addition of more commands and extension of
existing ones (with new options) without the need of hacks or the
risk of running out of configuration space.
A new NIOCCTRL ioctl has been added to handle all the requests of the
new control API, which cover all the functionalities so far supported.
The netmap API bumps from 11 to 12 with this patch. Full backward
compatibility is provided for the old control command (NIOCREGIF), by
means of a new netmap_legacy module. Many parts of the old netmap.h
header has now been moved to netmap_legacy.h (included by netmap.h).
Approved by: hrs (mentor)
2018-04-12 07:20:50 +00:00
|
|
|
struct netmap_kring *kring = na->rx_rings[r];
|
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 vtnet_rxq *rxq = &sc->vtnet_rxqs[r];
|
|
|
|
struct virtqueue *vq = rxq->vtnrx_vq;
|
|
|
|
struct netmap_slot* slot;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
slot = netmap_reset(na, NR_RX, r, 0);
|
|
|
|
if (!slot) {
|
|
|
|
D("strange, null netmap ring %d", r);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Add up to na>-num_rx_desc-1 buffers to this RX virtqueue.
|
|
|
|
* It's important to leave one virtqueue slot free, otherwise
|
|
|
|
* we can run into ring->cur/ring->tail wraparounds.
|
|
|
|
*/
|
|
|
|
err = vtnet_refill_rxq(kring, 0, na->num_rx_desc-1);
|
|
|
|
if (err < 0)
|
|
|
|
return 0;
|
|
|
|
virtqueue_notify(vq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vtnet_netmap_attach(struct SOFTC_T *sc)
|
|
|
|
{
|
|
|
|
struct netmap_adapter na;
|
|
|
|
|
|
|
|
bzero(&na, sizeof(na));
|
|
|
|
|
|
|
|
na.ifp = sc->vtnet_ifp;
|
|
|
|
na.num_tx_desc = 1024;// sc->vtnet_rx_nmbufs;
|
|
|
|
na.num_rx_desc = 1024; // sc->vtnet_rx_nmbufs;
|
|
|
|
na.nm_register = vtnet_netmap_reg;
|
|
|
|
na.nm_txsync = vtnet_netmap_txsync;
|
|
|
|
na.nm_rxsync = vtnet_netmap_rxsync;
|
2018-04-09 09:24:26 +00:00
|
|
|
na.nm_intr = vtnet_netmap_intr;
|
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
|
|
|
na.num_tx_rings = na.num_rx_rings = sc->vtnet_max_vq_pairs;
|
|
|
|
D("max rings %d", sc->vtnet_max_vq_pairs);
|
|
|
|
netmap_attach(&na);
|
|
|
|
|
|
|
|
D("virtio attached txq=%d, txd=%d rxq=%d, rxd=%d",
|
|
|
|
na.num_tx_rings, na.num_tx_desc,
|
|
|
|
na.num_tx_rings, na.num_rx_desc);
|
|
|
|
}
|
|
|
|
/* end of file */
|