Skip to content

Commit

Permalink
Update to the current version of netmap.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
luigi authored and luigi committed Aug 16, 2014
1 parent f01a1ba commit 3ab69a2
Show file tree
Hide file tree
Showing 29 changed files with 3,737 additions and 859 deletions.
1 change: 1 addition & 0 deletions sys/conf/files
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,7 @@ dev/netmap/netmap_freebsd.c optional netmap
dev/netmap/netmap_generic.c optional netmap
dev/netmap/netmap_mbq.c optional netmap
dev/netmap/netmap_mem2.c optional netmap
dev/netmap/netmap_monitor.c optional netmap
dev/netmap/netmap_offloadings.c optional netmap
dev/netmap/netmap_pipe.c optional netmap
dev/netmap/netmap_vale.c optional netmap
Expand Down
28 changes: 13 additions & 15 deletions sys/dev/cxgbe/t4_netmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,18 @@ cxgbe_netmap_on(struct adapter *sc, struct port_info *pi, struct ifnet *ifp,

hwb = &sc->sge.hw_buf_info[0];
for (i = 0; i < SGE_FLBUF_SIZES; i++, hwb++) {
if (hwb->size == NETMAP_BUF_SIZE)
if (hwb->size == NETMAP_BUF_SIZE(na))
break;
}
if (i >= SGE_FLBUF_SIZES) {
if_printf(ifp, "no hwidx for netmap buffer size %d.\n",
NETMAP_BUF_SIZE);
NETMAP_BUF_SIZE(na));
return (ENXIO);
}
hwidx = i;

/* Must set caps before calling netmap_reset */
na->na_flags |= (NAF_NATIVE_ON | NAF_NETMAP_ON);
ifp->if_capenable |= IFCAP_NETMAP;
nm_set_native_flags(na);

for_each_nm_rxq(pi, i, nm_rxq) {
alloc_nm_rxq_hwq(pi, nm_rxq);
Expand All @@ -460,7 +459,7 @@ cxgbe_netmap_on(struct adapter *sc, struct port_info *pi, struct ifnet *ifp,
for (j = 0; j < nm_rxq->fl_sidx - 8; j++) {
uint64_t ba;

PNMB(&slot[j], &ba);
PNMB(na, &slot[j], &ba);
nm_rxq->fl_desc[j] = htobe64(ba | hwidx);
}
nm_rxq->fl_pidx = j;
Expand Down Expand Up @@ -512,8 +511,7 @@ cxgbe_netmap_off(struct adapter *sc, struct port_info *pi, struct ifnet *ifp,
rc = -t4_enable_vi(sc, sc->mbox, pi->nm_viid, false, false);
if (rc != 0)
if_printf(ifp, "netmap disable_vi failed: %d\n", rc);
na->na_flags &= ~(NAF_NATIVE_ON | NAF_NETMAP_ON);
ifp->if_capenable &= ~IFCAP_NETMAP;
nm_clear_native_flags(na);

/*
* XXXNM: We need to make sure that the tx queues are quiet and won't
Expand Down Expand Up @@ -669,7 +667,7 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_txq,

for (i = 0; i < n; i++) {
slot = &ring->slot[kring->nr_hwcur];
PNMB(slot, &ba);
PNMB(kring->na, slot, &ba);

cpl->ctrl0 = nm_txq->cpl_ctrl0;
cpl->pack = 0;
Expand Down Expand Up @@ -786,13 +784,13 @@ reclaim_nm_tx_desc(struct sge_nm_txq *nm_txq)
}

static int
cxgbe_netmap_txsync(struct netmap_adapter *na, u_int ring_nr, int flags)
cxgbe_netmap_txsync(struct netmap_kring *kring, int flags)
{
struct netmap_kring *kring = &na->tx_rings[ring_nr];
struct netmap_adapter *na = kring->na;
struct ifnet *ifp = na->ifp;
struct port_info *pi = ifp->if_softc;
struct adapter *sc = pi->adapter;
struct sge_nm_txq *nm_txq = &sc->sge.nm_txq[pi->first_nm_txq + ring_nr];
struct sge_nm_txq *nm_txq = &sc->sge.nm_txq[pi->first_nm_txq + kring->ring_id];
const u_int head = kring->rhead;
u_int reclaimed = 0;
int n, d, npkt_remaining, ndesc_remaining;
Expand Down Expand Up @@ -851,14 +849,14 @@ cxgbe_netmap_txsync(struct netmap_adapter *na, u_int ring_nr, int flags)
}

static int
cxgbe_netmap_rxsync(struct netmap_adapter *na, u_int ring_nr, int flags)
cxgbe_netmap_rxsync(struct netmap_kring *kring, int flags)
{
struct netmap_kring *kring = &na->rx_rings[ring_nr];
struct netmap_adapter *na = kring->na;
struct netmap_ring *ring = kring->ring;
struct ifnet *ifp = na->ifp;
struct port_info *pi = ifp->if_softc;
struct adapter *sc = pi->adapter;
struct sge_nm_rxq *nm_rxq = &sc->sge.nm_rxq[pi->first_nm_rxq + ring_nr];
struct sge_nm_rxq *nm_rxq = &sc->sge.nm_rxq[pi->first_nm_rxq + kring->ring_id];
u_int const head = nm_rxsync_prologue(kring);
u_int n;
int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR;
Expand Down Expand Up @@ -891,7 +889,7 @@ cxgbe_netmap_rxsync(struct netmap_adapter *na, u_int ring_nr, int flags)

while (n > 0) {
for (i = 0; i < 8; i++, fl_pidx++, slot++) {
PNMB(slot, &ba);
PNMB(na, slot, &ba);
nm_rxq->fl_desc[fl_pidx] = htobe64(ba | hwidx);
slot->flags &= ~NS_BUF_CHANGED;
MPASS(fl_pidx <= nm_rxq->fl_sidx);
Expand Down
8 changes: 4 additions & 4 deletions sys/dev/e1000/if_em.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,10 +3340,10 @@ em_setup_transmit_ring(struct tx_ring *txr)
uint64_t paddr;
void *addr;

addr = PNMB(slot + si, &paddr);
addr = PNMB(na, slot + si, &paddr);
txr->tx_base[i].buffer_addr = htole64(paddr);
/* reload the map for netmap mode */
netmap_load_map(txr->txtag, txbuf->map, addr);
netmap_load_map(na, txr->txtag, txbuf->map, addr);
}
#endif /* DEV_NETMAP */

Expand Down Expand Up @@ -4082,8 +4082,8 @@ em_setup_receive_ring(struct rx_ring *rxr)
uint64_t paddr;
void *addr;

addr = PNMB(slot + si, &paddr);
netmap_load_map(rxr->rxtag, rxbuf->map, addr);
addr = PNMB(na, slot + si, &paddr);
netmap_load_map(na, rxr->rxtag, rxbuf->map, addr);
/* Update descriptor */
rxr->rx_base[j].buffer_addr = htole64(paddr);
continue;
Expand Down
6 changes: 3 additions & 3 deletions sys/dev/e1000/if_igb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3629,7 +3629,7 @@ igb_setup_transmit_ring(struct tx_ring *txr)
if (slot) {
int si = netmap_idx_n2k(&na->tx_rings[txr->me], i);
/* no need to set the address */
netmap_load_map(txr->txtag, txbuf->map, NMB(slot + si));
netmap_load_map(na, txr->txtag, txbuf->map, NMB(na, slot + si));
}
#endif /* DEV_NETMAP */
/* clear the watch index */
Expand Down Expand Up @@ -4433,8 +4433,8 @@ igb_setup_receive_ring(struct rx_ring *rxr)
uint64_t paddr;
void *addr;

addr = PNMB(slot + sj, &paddr);
netmap_load_map(rxr->ptag, rxbuf->pmap, addr);
addr = PNMB(na, slot + sj, &paddr);
netmap_load_map(na, rxr->ptag, rxbuf->pmap, addr);
/* Update descriptor */
rxr->rx_base[j].read.pkt_addr = htole64(paddr);
continue;
Expand Down
Loading

0 comments on commit 3ab69a2

Please sign in to comment.