diff options
author | Vincenzo Maffione <vmaffione@FreeBSD.org> | 2018-04-12 07:20:50 +0000 |
---|---|---|
committer | Vincenzo Maffione <vmaffione@FreeBSD.org> | 2018-04-12 07:20:50 +0000 |
commit | 2ff91c175eca50b7d0d9da6b31eae4109c034137 (patch) | |
tree | 15a4f8847a8cabd782f67326125c48fed4fdd27b /sys/dev/netmap/netmap_monitor.c | |
parent | 66def52613043a86172a2ebe6feab214258fa2fa (diff) |
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)
Notes
Notes:
svn path=/head/; revision=332423
Diffstat (limited to 'sys/dev/netmap/netmap_monitor.c')
-rw-r--r-- | sys/dev/netmap/netmap_monitor.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/sys/dev/netmap/netmap_monitor.c b/sys/dev/netmap/netmap_monitor.c index e7cc05f5ab0f..f6b7c93adc76 100644 --- a/sys/dev/netmap/netmap_monitor.c +++ b/sys/dev/netmap/netmap_monitor.c @@ -167,8 +167,8 @@ netmap_monitor_krings_create(struct netmap_adapter *na) if (error) return error; /* override the host rings callbacks */ - na->tx_rings[na->num_tx_rings].nm_sync = netmap_monitor_txsync; - na->rx_rings[na->num_rx_rings].nm_sync = netmap_monitor_rxsync; + na->tx_rings[na->num_tx_rings]->nm_sync = netmap_monitor_txsync; + na->rx_rings[na->num_rx_rings]->nm_sync = netmap_monitor_rxsync; return 0; } @@ -390,7 +390,7 @@ netmap_monitor_stop(struct netmap_adapter *na) u_int i; for (i = 0; i < nma_get_nrings(na, t) + 1; i++) { - struct netmap_kring *kring = &NMR(na, t)[i]; + struct netmap_kring *kring = NMR(na, t)[i]; struct netmap_kring *zkring; u_int j; @@ -456,7 +456,7 @@ netmap_monitor_reg_common(struct netmap_adapter *na, int onoff, int zmon) } for_rx_tx(t) { for (i = 0; i < nma_get_nrings(na, t) + 1; i++) { - mkring = &NMR(na, t)[i]; + mkring = NMR(na, t)[i]; if (!nm_kring_pending_on(mkring)) continue; mkring->nr_mode = NKR_NETMAP_ON; @@ -466,7 +466,7 @@ netmap_monitor_reg_common(struct netmap_adapter *na, int onoff, int zmon) if (i > nma_get_nrings(pna, s)) continue; if (mna->flags & nm_txrx2flag(s)) { - kring = &NMR(pna, s)[i]; + kring = NMR(pna, s)[i]; netmap_monitor_add(mkring, kring, zmon); } } @@ -478,7 +478,7 @@ netmap_monitor_reg_common(struct netmap_adapter *na, int onoff, int zmon) na->na_flags &= ~NAF_NETMAP_ON; for_rx_tx(t) { for (i = 0; i < nma_get_nrings(na, t) + 1; i++) { - mkring = &NMR(na, t)[i]; + mkring = NMR(na, t)[i]; if (!nm_kring_pending_off(mkring)) continue; mkring->nr_mode = NKR_NETMAP_OFF; @@ -494,7 +494,7 @@ netmap_monitor_reg_common(struct netmap_adapter *na, int onoff, int zmon) if (i > nma_get_nrings(pna, s)) continue; if (mna->flags & nm_txrx2flag(s)) { - kring = &NMR(pna, s)[i]; + kring = NMR(pna, s)[i]; netmap_monitor_del(mkring, kring); } } @@ -824,38 +824,41 @@ netmap_monitor_dtor(struct netmap_adapter *na) } -/* check if nmr is a request for a monitor adapter that we can satisfy */ +/* check if req is a request for a monitor adapter that we can satisfy */ int -netmap_get_monitor_na(struct nmreq *nmr, struct netmap_adapter **na, - struct netmap_mem_d *nmd, int create) +netmap_get_monitor_na(struct nmreq_header *hdr, struct netmap_adapter **na, + struct netmap_mem_d *nmd, int create) { - struct nmreq pnmr; + struct nmreq_register *req = (struct nmreq_register *)hdr->nr_body; + struct nmreq_register preq; struct netmap_adapter *pna; /* parent adapter */ struct netmap_monitor_adapter *mna; struct ifnet *ifp = NULL; int error; - int zcopy = (nmr->nr_flags & NR_ZCOPY_MON); + int zcopy = (req->nr_flags & NR_ZCOPY_MON); char monsuff[10] = ""; if (zcopy) { - nmr->nr_flags |= (NR_MONITOR_TX | NR_MONITOR_RX); + req->nr_flags |= (NR_MONITOR_TX | NR_MONITOR_RX); } - if ((nmr->nr_flags & (NR_MONITOR_TX | NR_MONITOR_RX)) == 0) { + if ((req->nr_flags & (NR_MONITOR_TX | NR_MONITOR_RX)) == 0) { ND("not a monitor"); return 0; } /* this is a request for a monitor adapter */ - ND("flags %x", nmr->nr_flags); + ND("flags %lx", req->nr_flags); - /* first, try to find the adapter that we want to monitor - * We use the same nmr, after we have turned off the monitor flags. + /* First, try to find the adapter that we want to monitor. + * We use the same req, after we have turned off the monitor flags. * In this way we can potentially monitor everything netmap understands, * except other monitors. */ - memcpy(&pnmr, nmr, sizeof(pnmr)); - pnmr.nr_flags &= ~(NR_MONITOR_TX | NR_MONITOR_RX | NR_ZCOPY_MON); - error = netmap_get_na(&pnmr, &pna, &ifp, nmd, create); + memcpy(&preq, req, sizeof(preq)); + preq.nr_flags &= ~(NR_MONITOR_TX | NR_MONITOR_RX | NR_ZCOPY_MON); + hdr->nr_body = (uint64_t)&preq; + error = netmap_get_na(hdr, &pna, &ifp, nmd, create); + hdr->nr_body = (uint64_t)req; if (error) { D("parent lookup failed: %d", error); return error; @@ -881,7 +884,8 @@ netmap_get_monitor_na(struct nmreq *nmr, struct netmap_adapter **na, mna->priv.np_na = pna; /* grab all the rings we need in the parent */ - error = netmap_interp_ringid(&mna->priv, nmr->nr_ringid, nmr->nr_flags); + error = netmap_interp_ringid(&mna->priv, req->nr_mode, req->nr_ringid, + req->nr_flags); if (error) { D("ringid error"); goto free_out; @@ -892,8 +896,8 @@ netmap_get_monitor_na(struct nmreq *nmr, struct netmap_adapter **na, snprintf(mna->up.name, sizeof(mna->up.name), "%s%s/%s%s%s", pna->name, monsuff, zcopy ? "z" : "", - (nmr->nr_flags & NR_MONITOR_RX) ? "r" : "", - (nmr->nr_flags & NR_MONITOR_TX) ? "t" : ""); + (req->nr_flags & NR_MONITOR_RX) ? "r" : "", + (req->nr_flags & NR_MONITOR_TX) ? "t" : ""); /* the monitor supports the host rings iff the parent does */ mna->up.na_flags |= (pna->na_flags & NAF_HOST_RINGS); @@ -913,10 +917,10 @@ netmap_get_monitor_na(struct nmreq *nmr, struct netmap_adapter **na, * the parent rings, but the user may ask for a different * number */ - mna->up.num_tx_desc = nmr->nr_tx_slots; + mna->up.num_tx_desc = req->nr_tx_slots; nm_bound_var(&mna->up.num_tx_desc, pna->num_tx_desc, 1, NM_MONITOR_MAXSLOTS, NULL); - mna->up.num_rx_desc = nmr->nr_rx_slots; + mna->up.num_rx_desc = req->nr_rx_slots; nm_bound_var(&mna->up.num_rx_desc, pna->num_rx_desc, 1, NM_MONITOR_MAXSLOTS, NULL); if (zcopy) { @@ -950,7 +954,7 @@ netmap_get_monitor_na(struct nmreq *nmr, struct netmap_adapter **na, } /* remember the traffic directions we have to monitor */ - mna->flags = (nmr->nr_flags & (NR_MONITOR_TX | NR_MONITOR_RX | NR_ZCOPY_MON)); + mna->flags = (req->nr_flags & (NR_MONITOR_TX | NR_MONITOR_RX | NR_ZCOPY_MON)); *na = &mna->up; netmap_adapter_get(*na); |