aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/netmap
diff options
context:
space:
mode:
authorVincenzo Maffione <vmaffione@FreeBSD.org>2021-01-11 21:38:32 +0000
committerVincenzo Maffione <vmaffione@FreeBSD.org>2021-01-11 21:38:32 +0000
commit3005e10ddbfbec3ecf46a080607bb0d85986eee5 (patch)
tree6b3e0a9172ece80b654a1e6668bbcb4e9b36b3cb /sys/dev/netmap
parent21f749da82e755aafab127618affeffb86cff9a5 (diff)
Diffstat (limited to 'sys/dev/netmap')
-rw-r--r--sys/dev/netmap/if_vtnet_netmap.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/dev/netmap/if_vtnet_netmap.h b/sys/dev/netmap/if_vtnet_netmap.h
index f787bf573a28..cd652938bca5 100644
--- a/sys/dev/netmap/if_vtnet_netmap.h
+++ b/sys/dev/netmap/if_vtnet_netmap.h
@@ -213,20 +213,25 @@ vtnet_netmap_rxq_populate(struct vtnet_rxq *rxq)
struct netmap_kring *kring;
struct netmap_slot *slot;
int error;
+ int num;
slot = netmap_reset(na, NR_RX, rxq->vtnrx_id, 0);
if (slot == NULL)
return -1;
kring = na->rx_rings[rxq->vtnrx_id];
- /* Expose all the RX netmap buffers we can. In case of no indirect
+ /*
+ * Expose all the RX netmap buffers we can. In case of no indirect
* buffers, the number of netmap slots in the RX ring matches the
* maximum number of 2-elements sglist that the RX virtqueue can
- * accommodate. We need to start from kring->nr_hwcur, which is 0
- * on netmap register and may be different from 0 if a virtio
- * re-init happens while the device is in use by netmap. */
- rxq->vtnrx_nm_refill = kring->nr_hwcur;
- error = vtnet_netmap_kring_refill(kring, na->num_rx_desc - 1);
+ * accommodate. We need to start from kring->nr_hwtail, which is 0
+ * on the first netmap register and may be different from 0 if a
+ * virtio re-init (caused by a netma register or i.e., ifconfig)
+ * happens while the device is in use by netmap.
+ */
+ rxq->vtnrx_nm_refill = kring->nr_hwtail;
+ num = na->num_rx_desc - 1 - nm_kr_rxspace(kring);
+ error = vtnet_netmap_kring_refill(kring, num);
virtqueue_notify(rxq->vtnrx_vq);
return error;
@@ -256,7 +261,7 @@ vtnet_netmap_rxsync(struct netmap_kring *kring, int flags)
* First part: import newly received packets.
* Only accept our own buffers (matching the token). We should only get
* matching buffers. The hwtail should never overrun hwcur, because
- * we publish only N-1 receive buffers (and non N).
+ * we publish only N-1 receive buffers (and not N).
* In any case we must not leave this routine with the interrupts
* disabled, pending packets in the VQ and hwtail == (hwcur - 1),
* otherwise the pending packets could stall.