git: 6127ce9d91c8 - main - netmap: monitor: support offsets in copy mode

Vincenzo Maffione vmaffione at FreeBSD.org
Sun Sep 26 14:08:34 UTC 2021


The branch main has been updated by vmaffione:

URL: https://cgit.FreeBSD.org/src/commit/?id=6127ce9d91c81e3025aeb1d832750d827e28314f

commit 6127ce9d91c81e3025aeb1d832750d827e28314f
Author:     Vincenzo Maffione <vmaffione at FreeBSD.org>
AuthorDate: 2021-09-26 13:52:16 +0000
Commit:     Vincenzo Maffione <vmaffione at FreeBSD.org>
CommitDate: 2021-09-26 13:52:16 +0000

    netmap: monitor: support offsets in copy mode
---
 sys/dev/netmap/netmap_monitor.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sys/dev/netmap/netmap_monitor.c b/sys/dev/netmap/netmap_monitor.c
index 4827c2a7585f..e05313c1f792 100644
--- a/sys/dev/netmap/netmap_monitor.c
+++ b/sys/dev/netmap/netmap_monitor.c
@@ -737,8 +737,7 @@ netmap_monitor_parent_sync(struct netmap_kring *kring, u_int first_new, int new_
 		int free_slots, busy, sent = 0, m;
 		u_int lim = kring->nkr_num_slots - 1;
 		struct netmap_ring *ring = kring->ring, *mring = mkring->ring;
-		u_int max_len = NETMAP_BUF_SIZE(mkring->na);
-
+		u_int max_len;
 		mlim = mkring->nkr_num_slots - 1;
 
 		/* we need to lock the monitor receive ring, since it
@@ -770,9 +769,10 @@ netmap_monitor_parent_sync(struct netmap_kring *kring, u_int first_new, int new_
 			struct netmap_slot *s = &ring->slot[beg];
 			struct netmap_slot *ms = &mring->slot[i];
 			u_int copy_len = s->len;
-			char *src = NMB(kring->na, s),
-			     *dst = NMB(mkring->na, ms);
+			char *src = NMB_O(kring, s),
+			     *dst = NMB_O(mkring, ms);
 
+			max_len = NETMAP_BUF_SIZE(mkring->na) - nm_get_offset(mkring, ms);
 			if (unlikely(copy_len > max_len)) {
 				nm_prlim(5, "%s->%s: truncating %d to %d", kring->name,
 						mkring->name, copy_len, max_len);
@@ -966,7 +966,9 @@ netmap_get_monitor_na(struct nmreq_header *hdr, struct netmap_adapter **na,
 			pna->monitor_id++);
 
 	/* the monitor supports the host rings iff the parent does */
-	mna->up.na_flags |= (pna->na_flags & NAF_HOST_RINGS);
+	mna->up.na_flags |= (pna->na_flags & NAF_HOST_RINGS) & ~NAF_OFFSETS;
+	if (!zcopy)
+		mna->up.na_flags |= NAF_OFFSETS;
 	/* a do-nothing txsync: monitors cannot be used to inject packets */
 	mna->up.nm_txsync = netmap_monitor_txsync;
 	mna->up.nm_rxsync = netmap_monitor_rxsync;


More information about the dev-commits-src-all mailing list