Skip to content

Commit 86ad80b

Browse files
don't poll sw rings if the user didn't ask for them
1 parent ea06c51 commit 86ad80b

1 file changed

Lines changed: 32 additions & 52 deletions

File tree

sys/dev/netmap/netmap.c

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,7 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint16_t ringid, uint32_t flags
17011701
struct netmap_adapter *na = priv->np_na;
17021702
u_int j, i = ringid & NETMAP_RING_MASK;
17031703
u_int reg = flags & NR_REG_MASK;
1704+
int excluded_direction[] = { NR_TX_RINGS_ONLY, NR_RX_RINGS_ONLY };
17041705
enum txrx t;
17051706

17061707
if (reg == NR_REG_DEFAULT) {
@@ -1714,72 +1715,51 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint16_t ringid, uint32_t flags
17141715
}
17151716
D("deprecated API, old ringid 0x%x -> ringid %x reg %d", ringid, i, reg);
17161717
}
1717-
switch (reg) {
1718-
case NR_REG_ALL_NIC:
1719-
case NR_REG_PIPE_MASTER:
1720-
case NR_REG_PIPE_SLAVE:
1721-
for_rx_tx(t) {
1722-
if ((t == NR_RX && (flags & NR_TX_RINGS_ONLY)) ||
1723-
(t == NR_TX && (flags & NR_RX_RINGS_ONLY))) {
1724-
priv->np_qfirst[t] = priv->np_qlast[t] = 0;
1725-
continue;
1726-
}
1727-
1718+
for_rx_tx(t) {
1719+
if (flags & excluded_direction[t]) {
1720+
priv->np_qfirst[t] = priv->np_qlast[t] = 0;
1721+
continue;
1722+
}
1723+
switch (reg) {
1724+
case NR_REG_ALL_NIC:
1725+
case NR_REG_PIPE_MASTER:
1726+
case NR_REG_PIPE_SLAVE:
17281727
priv->np_qfirst[t] = 0;
17291728
priv->np_qlast[t] = nma_get_nrings(na, t);
1730-
}
1731-
ND("%s %d %d", "ALL/PIPE",
1732-
priv->np_qfirst[NR_RX], priv->np_qlast[NR_RX]);
1733-
break;
1734-
case NR_REG_SW:
1735-
case NR_REG_NIC_SW:
1736-
if (!(na->na_flags & NAF_HOST_RINGS)) {
1737-
D("host rings not supported");
1738-
return EINVAL;
1739-
}
1740-
for_rx_tx(t) {
1741-
if ((t == NR_RX && (flags & NR_TX_RINGS_ONLY)) ||
1742-
(t == NR_TX && (flags & NR_RX_RINGS_ONLY))) {
1743-
/*
1744-
* NR_[TX|RX]_RINGS_ONLY affects only hw
1745-
* rings, so keep sw rings on in any
1746-
* case
1747-
*/
1748-
priv->np_qfirst[t] = nma_get_nrings(na, t);
1749-
priv->np_qlast[t] = nma_get_nrings(na, t) + 1;
1750-
continue;
1729+
ND("ALL/PIPE: %s %d %d", nm_txrx2str(t),
1730+
priv->np_qfirst[t], priv->np_qlast[t]);
1731+
break;
1732+
case NR_REG_SW:
1733+
case NR_REG_NIC_SW:
1734+
if (!(na->na_flags & NAF_HOST_RINGS)) {
1735+
D("host rings not supported");
1736+
return EINVAL;
17511737
}
1752-
17531738
priv->np_qfirst[t] = (reg == NR_REG_SW ?
17541739
nma_get_nrings(na, t) : 0);
17551740
priv->np_qlast[t] = nma_get_nrings(na, t) + 1;
1756-
}
1757-
ND("%s %d %d", reg == NR_REG_SW ? "SW" : "NIC+SW",
1758-
priv->np_qfirst[NR_RX], priv->np_qlast[NR_RX]);
1759-
break;
1760-
case NR_REG_ONE_NIC:
1761-
if (i >= na->num_tx_rings && i >= na->num_rx_rings) {
1762-
D("invalid ring id %d", i);
1763-
return EINVAL;
1764-
}
1765-
for_rx_tx(t) {
1766-
if ((t == NR_RX && (flags & NR_TX_RINGS_ONLY)) ||
1767-
(t == NR_TX && (flags & NR_RX_RINGS_ONLY))) {
1768-
priv->np_qfirst[t] = priv->np_qlast[t] = 0;
1769-
continue;
1741+
ND("%s: %s %d %d", reg == NR_REG_SW ? "SW" : "NIC+SW",
1742+
nm_txrx2str(t),
1743+
priv->np_qfirst[t], priv->np_qlast[t]);
1744+
break;
1745+
case NR_REG_ONE_NIC:
1746+
if (i >= na->num_tx_rings && i >= na->num_rx_rings) {
1747+
D("invalid ring id %d", i);
1748+
return EINVAL;
17701749
}
1771-
17721750
/* if not enough rings, use the first one */
17731751
j = i;
17741752
if (j >= nma_get_nrings(na, t))
17751753
j = 0;
17761754
priv->np_qfirst[t] = j;
17771755
priv->np_qlast[t] = j + 1;
1756+
ND("ONE_NIC: %s %d %d", nm_txrx2str(t),
1757+
priv->np_qfirst[t], priv->np_qlast[t]);
1758+
break;
1759+
default:
1760+
D("invalid regif type %d", reg);
1761+
return EINVAL;
17781762
}
1779-
break;
1780-
default:
1781-
D("invalid regif type %d", reg);
1782-
return EINVAL;
17831763
}
17841764
priv->np_flags = (flags & ~NR_REG_MASK) | reg;
17851765

0 commit comments

Comments
 (0)