aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/netmap/netmap.c
diff options
context:
space:
mode:
authorVincenzo Maffione <vmaffione@FreeBSD.org>2018-12-22 16:23:42 +0000
committerVincenzo Maffione <vmaffione@FreeBSD.org>2018-12-22 16:23:42 +0000
commit58e185425a74f0588e13cd7663f4ba950f84af77 (patch)
tree9cda8ae5313eb26237a104996ebe3dd16aa0fb2a /sys/dev/netmap/netmap.c
parente1ed1fbdea19659120d372dcdc7c13060c823e2b (diff)
Notes
Diffstat (limited to 'sys/dev/netmap/netmap.c')
-rw-r--r--sys/dev/netmap/netmap.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/sys/dev/netmap/netmap.c b/sys/dev/netmap/netmap.c
index b51c0300493d0..2d3db72f5773f 100644
--- a/sys/dev/netmap/netmap.c
+++ b/sys/dev/netmap/netmap.c
@@ -3292,31 +3292,38 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
* that we must call nm_os_selrecord() unconditionally.
*/
if (want_tx) {
- enum txrx t = NR_TX;
- for (i = priv->np_qfirst[t]; want[t] && i < priv->np_qlast[t]; i++) {
+ const enum txrx t = NR_TX;
+ for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) {
kring = NMR(na, t)[i];
- /* XXX compare ring->cur and kring->tail */
- if (!nm_ring_empty(kring->ring)) {
+ if (kring->ring->cur != kring->ring->tail) {
+ /* Some unseen TX space is available, so what
+ * we don't need to run txsync. */
revents |= want[t];
- want[t] = 0; /* also breaks the loop */
+ want[t] = 0;
+ break;
}
}
}
if (want_rx) {
- enum txrx t = NR_RX;
+ const enum txrx t = NR_RX;
int rxsync_needed = 0;
- /* look for a reason to run the handlers */
for (i = priv->np_qfirst[t]; i < priv->np_qlast[t]; i++) {
kring = NMR(na, t)[i];
- if (kring->ring->cur == kring->ring->tail /* try fetch new buffers */
- || kring->rhead != kring->ring->head /* release buffers */) {
+ if (kring->ring->cur == kring->ring->tail
+ || kring->rhead != kring->ring->head) {
+ /* There are no unseen packets on this ring,
+ * or there are some buffers to be returned
+ * to the netmap port. We therefore go ahead
+ * and run rxsync. */
rxsync_needed = 1;
break;
}
}
- if (!rxsync_needed)
- revents |= want_rx; /* we have data */
+ if (!rxsync_needed) {
+ revents |= want_rx;
+ want_rx = 0;
+ }
}
#endif