Skip to content

Commit 676ac34

Browse files
committed
Add NR_TX/RX_RINGS_ONLY flags
Add NR_TX_RINGS_ONLY and NR_RX_RINGS_ONLY flags which allow to request only tx or rx hw rings.
1 parent 566ae40 commit 676ac34

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

sys/dev/netmap/netmap.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,12 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint16_t ringid, uint32_t flags
17301730
case NR_REG_PIPE_MASTER:
17311731
case NR_REG_PIPE_SLAVE:
17321732
for_rx_tx(t) {
1733+
if ((t == NR_RX && (flags & NR_TX_RINGS_ONLY)) ||
1734+
(t == NR_TX && (flags & NR_RX_RINGS_ONLY))) {
1735+
priv->np_qfirst[t] = priv->np_qlast[t] = 0;
1736+
continue;
1737+
}
1738+
17331739
priv->np_qfirst[t] = 0;
17341740
priv->np_qlast[t] = nma_get_nrings(na, t);
17351741
}
@@ -1743,6 +1749,18 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint16_t ringid, uint32_t flags
17431749
return EINVAL;
17441750
}
17451751
for_rx_tx(t) {
1752+
if ((t == NR_RX && (flags & NR_TX_RINGS_ONLY)) ||
1753+
(t == NR_TX && (flags & NR_RX_RINGS_ONLY))) {
1754+
/*
1755+
* NR_[TX|RX]_RINGS_ONLY affects only hw
1756+
* rings, so keep sw rings on in any
1757+
* case
1758+
*/
1759+
priv->np_qfirst[t] = nma_get_nrings(na, t);
1760+
priv->np_qlast[t] = nma_get_nrings(na, t) + 1;
1761+
continue;
1762+
}
1763+
17461764
priv->np_qfirst[t] = (reg == NR_REG_SW ?
17471765
nma_get_nrings(na, t) : 0);
17481766
priv->np_qlast[t] = nma_get_nrings(na, t) + 1;
@@ -1756,6 +1774,12 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint16_t ringid, uint32_t flags
17561774
return EINVAL;
17571775
}
17581776
for_rx_tx(t) {
1777+
if ((t == NR_RX && (flags & NR_TX_RINGS_ONLY)) ||
1778+
(t == NR_TX && (flags & NR_RX_RINGS_ONLY))) {
1779+
priv->np_qfirst[t] = priv->np_qlast[t] = 0;
1780+
continue;
1781+
}
1782+
17591783
/* if not enough rings, use the first one */
17601784
j = i;
17611785
if (j >= nma_get_nrings(na, t))

sys/net/netmap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ enum { NR_REG_DEFAULT = 0, /* backward compat, should not be used. */
532532
/* request ptnetmap host support */
533533
#define NR_PASSTHROUGH_HOST NR_PTNETMAP_HOST /* deprecated */
534534
#define NR_PTNETMAP_HOST 0x1000
535+
#define NR_RX_RINGS_ONLY 0x2000
536+
#define NR_TX_RINGS_ONLY 0x4000
535537

536538

537539
/*

sys/net/netmap_user.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ typedef void (*nm_cb_t)(u_char *, const struct nm_pkthdr *, const u_char *d);
313313
* z zero copy monitor
314314
* t monitor tx side
315315
* r monitor rx side
316+
* R bind only RX ring(s)
317+
* T bind only TX ring(s)
316318
*
317319
* req provides the initial values of nmreq before parsing ifname.
318320
* Remember that the ifname parsing will override the ring
@@ -701,6 +703,12 @@ nm_open(const char *ifname, const struct nmreq *req,
701703
case 'r':
702704
nr_flags |= NR_MONITOR_RX;
703705
break;
706+
case 'R':
707+
nr_flags |= NR_RX_RINGS_ONLY;
708+
break;
709+
case 'T':
710+
nr_flags |= NR_TX_RINGS_ONLY;
711+
break;
704712
default:
705713
snprintf(errmsg, MAXERRMSG, "unrecognized flag: '%c'", *port);
706714
goto fail;

0 commit comments

Comments
 (0)