Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Feb 2019 09:26:06 +0000 (UTC)
From:      Vincenzo Maffione <vmaffione@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r344047 - in stable/11/sys/dev: ixgbe netmap
Message-ID:  <201902120926.x1C9Q6jh005696@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vmaffione
Date: Tue Feb 12 09:26:05 2019
New Revision: 344047
URL: https://svnweb.freebsd.org/changeset/base/344047

Log:
  MFC r343772, r343867
  
  netmap: refactor logging macros and pipes
  
  Changelist:
      - Replace ND, D and RD macros with nm_prdis, nm_prinf, nm_prerr
        and nm_prlim, to avoid possible naming conflicts.
      - Add netmap_krings_mode_commit() helper function and use that
        to reduce code duplication.
      - Refactor pipes control code to export some functions that
        can be reused by the veth driver (on Linux) and epair(4).
      - Add check to reject API requests with version less than 11.
      - Small code refactoring for the null adapter.

Modified:
  stable/11/sys/dev/ixgbe/ixgbe_netmap.c
  stable/11/sys/dev/netmap/if_vtnet_netmap.h
  stable/11/sys/dev/netmap/netmap.c
  stable/11/sys/dev/netmap/netmap_bdg.c
  stable/11/sys/dev/netmap/netmap_freebsd.c
  stable/11/sys/dev/netmap/netmap_generic.c
  stable/11/sys/dev/netmap/netmap_kern.h
  stable/11/sys/dev/netmap/netmap_legacy.c
  stable/11/sys/dev/netmap/netmap_mem2.c
  stable/11/sys/dev/netmap/netmap_monitor.c
  stable/11/sys/dev/netmap/netmap_null.c
  stable/11/sys/dev/netmap/netmap_offloadings.c
  stable/11/sys/dev/netmap/netmap_pipe.c
  stable/11/sys/dev/netmap/netmap_vale.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/ixgbe/ixgbe_netmap.c
==============================================================================
--- stable/11/sys/dev/ixgbe/ixgbe_netmap.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/ixgbe/ixgbe_netmap.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -118,7 +118,7 @@ set_crcstrip(struct ixgbe_hw *hw, int onoff)
 	hl = IXGBE_READ_REG(hw, IXGBE_HLREG0);
 	rxc = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
 	if (netmap_verbose)
-		D("%s read  HLREG 0x%x rxc 0x%x",
+		nm_prinf("%s read  HLREG 0x%x rxc 0x%x",
 			onoff ? "enter" : "exit", hl, rxc);
 	/* hw requirements ... */
 	rxc &= ~IXGBE_RDRXCTL_RSCFRSTSIZE;
@@ -133,7 +133,7 @@ set_crcstrip(struct ixgbe_hw *hw, int onoff)
 		rxc |= IXGBE_RDRXCTL_CRCSTRIP;
 	}
 	if (netmap_verbose)
-		D("%s write HLREG 0x%x rxc 0x%x",
+		nm_prinf("%s write HLREG 0x%x rxc 0x%x",
 			onoff ? "enter" : "exit", hl, rxc);
 	IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hl);
 	IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rxc);
@@ -340,8 +340,8 @@ ixgbe_netmap_txsync(struct netmap_kring *kring, int fl
 		 * good way.
 		 */
 		nic_i = IXGBE_READ_REG(&adapter->hw, IXGBE_TDH(kring->ring_id));
-		if (nic_i >= kring->nkr_num_slots) { /* XXX can it happen ? */
-			D("TDH wrap %d", nic_i);
+		if (unlikely(nic_i >= kring->nkr_num_slots)) {
+			nm_prinf("TDH wrap %d", nic_i);
 			nic_i -= kring->nkr_num_slots;
 		}
 		if (nic_i != txr->next_to_clean) {

Modified: stable/11/sys/dev/netmap/if_vtnet_netmap.h
==============================================================================
--- stable/11/sys/dev/netmap/if_vtnet_netmap.h	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/if_vtnet_netmap.h	Tue Feb 12 09:26:05 2019	(r344047)
@@ -90,7 +90,6 @@ vtnet_netmap_reg(struct netmap_adapter *na, int state)
 	struct ifnet *ifp = na->ifp;
 	struct vtnet_softc *sc = ifp->if_softc;
 	int success;
-	enum txrx t;
 	int i;
 
 	/* Drain the taskqueues to make sure that there are no worker threads
@@ -132,44 +131,11 @@ vtnet_netmap_reg(struct netmap_adapter *na, int state)
 	success = (ifp->if_drv_flags & IFF_DRV_RUNNING) ? 0 : ENXIO;
 
 	if (state) {
-		for_rx_tx(t) {
-			/* Hardware rings. */
-			for (i = 0; i < nma_get_nrings(na, t); i++) {
-				struct netmap_kring *kring = NMR(na, t)[i];
-
-				if (nm_kring_pending_on(kring))
-					kring->nr_mode = NKR_NETMAP_ON;
-			}
-
-			/* Host rings. */
-			for (i = 0; i < nma_get_host_nrings(na, t); i++) {
-				struct netmap_kring *kring =
-					NMR(na, t)[nma_get_nrings(na, t) + i];
-
-				if (nm_kring_pending_on(kring))
-					kring->nr_mode = NKR_NETMAP_ON;
-			}
-		}
+		netmap_krings_mode_commit(na, state);
+		nm_set_native_flags(na);
 	} else {
 		nm_clear_native_flags(na);
-		for_rx_tx(t) {
-			/* Hardware rings. */
-			for (i = 0; i < nma_get_nrings(na, t); i++) {
-				struct netmap_kring *kring = NMR(na, t)[i];
-
-				if (nm_kring_pending_off(kring))
-					kring->nr_mode = NKR_NETMAP_OFF;
-			}
-
-			/* Host rings. */
-			for (i = 0; i < nma_get_host_nrings(na, t); i++) {
-				struct netmap_kring *kring =
-					NMR(na, t)[nma_get_nrings(na, t) + i];
-
-				if (nm_kring_pending_off(kring))
-					kring->nr_mode = NKR_NETMAP_OFF;
-			}
-		}
+		netmap_krings_mode_commit(na, state);
 	}
 
 	VTNET_CORE_UNLOCK(sc);
@@ -396,7 +362,7 @@ vtnet_netmap_rxsync(struct netmap_kring *kring, int fl
 				/* Skip the virtio-net header. */
 				len -= sc->vtnet_hdr_size;
 				if (unlikely(len < 0)) {
-					RD(1, "Truncated virtio-net-header, "
+					nm_prlim(1, "Truncated virtio-net-header, "
 						"missing %d bytes", -len);
 					len = 0;
 				}
@@ -408,7 +374,7 @@ vtnet_netmap_rxsync(struct netmap_kring *kring, int fl
 		kring->nr_hwtail = nm_i;
 		kring->nr_kflags &= ~NKR_PENDINTR;
 	}
-	ND("[B] h %d c %d hwcur %d hwtail %d", ring->head, ring->cur,
+	nm_prdis("[B] h %d c %d hwcur %d hwtail %d", ring->head, ring->cur,
 				kring->nr_hwcur, kring->nr_hwtail);
 
 	/*
@@ -423,7 +389,7 @@ vtnet_netmap_rxsync(struct netmap_kring *kring, int fl
 		virtqueue_notify(vq);
 	}
 
-	ND("[C] h %d c %d t %d hwcur %d hwtail %d", ring->head, ring->cur,
+	nm_prdis("[C] h %d c %d t %d hwcur %d hwtail %d", ring->head, ring->cur,
 		ring->tail, kring->nr_hwcur, kring->nr_hwtail);
 
 	return 0;

Modified: stable/11/sys/dev/netmap/netmap.c
==============================================================================
--- stable/11/sys/dev/netmap/netmap.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -894,7 +894,7 @@ netmap_krings_create(struct netmap_adapter *na, u_int 
 			kring->rtail = kring->nr_hwtail = (t == NR_TX ? ndesc - 1 : 0);
 			snprintf(kring->name, sizeof(kring->name) - 1, "%s %s%d", na->name,
 					nm_txrx2str(t), i);
-			ND("ktx %s h %d c %d t %d",
+			nm_prdis("ktx %s h %d c %d t %d",
 				kring->name, kring->rhead, kring->rcur, kring->rtail);
 			mtx_init(&kring->q_lock, (t == NR_TX ? "nm_txq_lock" : "nm_rxq_lock"), NULL, MTX_DEF);
 			nm_os_selinfo_init(&kring->si);
@@ -947,7 +947,7 @@ netmap_hw_krings_delete(struct netmap_adapter *na)
 
 	for (i = nma_get_nrings(na, NR_RX); i < lim; i++) {
 		struct mbq *q = &NMR(na, NR_RX)[i]->rx_queue;
-		ND("destroy sw mbq with len %d", mbq_len(q));
+		nm_prdis("destroy sw mbq with len %d", mbq_len(q));
 		mbq_purge(q);
 		mbq_safe_fini(q);
 	}
@@ -1168,7 +1168,7 @@ netmap_grab_packets(struct netmap_kring *kring, struct
 		if ((slot->flags & NS_FORWARD) == 0 && !force)
 			continue;
 		if (slot->len < 14 || slot->len > NETMAP_BUF_SIZE(na)) {
-			RD(5, "bad pkt at %d len %d", n, slot->len);
+			nm_prlim(5, "bad pkt at %d len %d", n, slot->len);
 			continue;
 		}
 		slot->flags &= ~NS_FORWARD; // XXX needed ?
@@ -1282,7 +1282,7 @@ netmap_txsync_to_host(struct netmap_kring *kring, int 
 	 */
 	mbq_init(&q);
 	netmap_grab_packets(kring, &q, 1 /* force */);
-	ND("have %d pkts in queue", mbq_len(&q));
+	nm_prdis("have %d pkts in queue", mbq_len(&q));
 	kring->nr_hwcur = head;
 	kring->nr_hwtail = head + lim;
 	if (kring->nr_hwtail > lim)
@@ -1330,7 +1330,7 @@ netmap_rxsync_from_host(struct netmap_kring *kring, in
 			struct netmap_slot *slot = &ring->slot[nm_i];
 
 			m_copydata(m, 0, len, NMB(na, slot));
-			ND("nm %d len %d", nm_i, len);
+			nm_prdis("nm %d len %d", nm_i, len);
 			if (netmap_debug & NM_DEBUG_HOST)
 				nm_prinf("%s", nm_dump_buf(NMB(na, slot),len, 128, NULL));
 
@@ -1595,7 +1595,7 @@ netmap_unget_na(struct netmap_adapter *na, struct ifne
 
 #define NM_FAIL_ON(t) do {						\
 	if (unlikely(t)) {						\
-		RD(5, "%s: fail '" #t "' "				\
+		nm_prlim(5, "%s: fail '" #t "' "				\
 			"h %d c %d t %d "				\
 			"rh %d rc %d rt %d "				\
 			"hc %d ht %d",					\
@@ -1627,7 +1627,7 @@ nm_txsync_prologue(struct netmap_kring *kring, struct 
 	u_int cur = ring->cur; /* read only once */
 	u_int n = kring->nkr_num_slots;
 
-	ND(5, "%s kcur %d ktail %d head %d cur %d tail %d",
+	nm_prdis(5, "%s kcur %d ktail %d head %d cur %d tail %d",
 		kring->name,
 		kring->nr_hwcur, kring->nr_hwtail,
 		ring->head, ring->cur, ring->tail);
@@ -1663,7 +1663,7 @@ nm_txsync_prologue(struct netmap_kring *kring, struct 
 		}
 	}
 	if (ring->tail != kring->rtail) {
-		RD(5, "%s tail overwritten was %d need %d", kring->name,
+		nm_prlim(5, "%s tail overwritten was %d need %d", kring->name,
 			ring->tail, kring->rtail);
 		ring->tail = kring->rtail;
 	}
@@ -1690,7 +1690,7 @@ nm_rxsync_prologue(struct netmap_kring *kring, struct 
 	uint32_t const n = kring->nkr_num_slots;
 	uint32_t head, cur;
 
-	ND(5,"%s kc %d kt %d h %d c %d t %d",
+	nm_prdis(5,"%s kc %d kt %d h %d c %d t %d",
 		kring->name,
 		kring->nr_hwcur, kring->nr_hwtail,
 		ring->head, ring->cur, ring->tail);
@@ -1725,7 +1725,7 @@ nm_rxsync_prologue(struct netmap_kring *kring, struct 
 		}
 	}
 	if (ring->tail != kring->rtail) {
-		RD(5, "%s tail overwritten was %d need %d",
+		nm_prlim(5, "%s tail overwritten was %d need %d",
 			kring->name,
 			ring->tail, kring->rtail);
 		ring->tail = kring->rtail;
@@ -1754,7 +1754,7 @@ netmap_ring_reinit(struct netmap_kring *kring)
 	int errors = 0;
 
 	// XXX KASSERT nm_kr_tryget
-	RD(10, "called for %s", kring->name);
+	nm_prlim(10, "called for %s", kring->name);
 	// XXX probably wrong to trust userspace
 	kring->rhead = ring->head;
 	kring->rcur  = ring->cur;
@@ -1770,17 +1770,17 @@ netmap_ring_reinit(struct netmap_kring *kring)
 		u_int idx = ring->slot[i].buf_idx;
 		u_int len = ring->slot[i].len;
 		if (idx < 2 || idx >= kring->na->na_lut.objtotal) {
-			RD(5, "bad index at slot %d idx %d len %d ", i, idx, len);
+			nm_prlim(5, "bad index at slot %d idx %d len %d ", i, idx, len);
 			ring->slot[i].buf_idx = 0;
 			ring->slot[i].len = 0;
 		} else if (len > NETMAP_BUF_SIZE(kring->na)) {
 			ring->slot[i].len = 0;
-			RD(5, "bad len at slot %d idx %d len %d", i, idx, len);
+			nm_prlim(5, "bad len at slot %d idx %d len %d", i, idx, len);
 		}
 	}
 	if (errors) {
-		RD(10, "total %d errors", errors);
-		RD(10, "%s reinit, cur %d -> %d tail %d -> %d",
+		nm_prlim(10, "total %d errors", errors);
+		nm_prlim(10, "%s reinit, cur %d -> %d tail %d -> %d",
 			kring->name,
 			ring->cur, kring->nr_hwcur,
 			ring->tail, kring->nr_hwtail);
@@ -1817,7 +1817,7 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint3
 		case NR_REG_NULL:
 			priv->np_qfirst[t] = 0;
 			priv->np_qlast[t] = nma_get_nrings(na, t);
-			ND("ALL/PIPE: %s %d %d", nm_txrx2str(t),
+			nm_prdis("ALL/PIPE: %s %d %d", nm_txrx2str(t),
 				priv->np_qfirst[t], priv->np_qlast[t]);
 			break;
 		case NR_REG_SW:
@@ -1829,7 +1829,7 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint3
 			priv->np_qfirst[t] = (nr_mode == NR_REG_SW ?
 				nma_get_nrings(na, t) : 0);
 			priv->np_qlast[t] = netmap_all_rings(na, t);
-			ND("%s: %s %d %d", nr_mode == NR_REG_SW ? "SW" : "NIC+SW",
+			nm_prdis("%s: %s %d %d", nr_mode == NR_REG_SW ? "SW" : "NIC+SW",
 				nm_txrx2str(t),
 				priv->np_qfirst[t], priv->np_qlast[t]);
 			break;
@@ -1845,7 +1845,7 @@ netmap_interp_ringid(struct netmap_priv_d *priv, uint3
 				j = 0;
 			priv->np_qfirst[t] = j;
 			priv->np_qlast[t] = j + 1;
-			ND("ONE_NIC: %s %d %d", nm_txrx2str(t),
+			nm_prdis("ONE_NIC: %s %d %d", nm_txrx2str(t),
 				priv->np_qfirst[t], priv->np_qlast[t]);
 			break;
 		default:
@@ -1954,7 +1954,7 @@ netmap_krings_get(struct netmap_priv_d *priv)
 			if ((kring->nr_kflags & NKR_EXCLUSIVE) ||
 			    (kring->users && excl))
 			{
-				ND("ring %s busy", kring->name);
+				nm_prdis("ring %s busy", kring->name);
 				return EBUSY;
 			}
 		}
@@ -1989,7 +1989,7 @@ netmap_krings_put(struct netmap_priv_d *priv)
 	int excl = (priv->np_flags & NR_EXCLUSIVE);
 	enum txrx t;
 
-	ND("%s: releasing tx [%d, %d) rx [%d, %d)",
+	nm_prdis("%s: releasing tx [%d, %d) rx [%d, %d)",
 			na->name,
 			priv->np_qfirst[NR_TX],
 			priv->np_qlast[NR_TX],
@@ -2254,7 +2254,7 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
 		error = netmap_mem_get_lut(na->nm_mem, &na->na_lut);
 		if (error)
 			goto err_drop_mem;
-		ND("lut %p bufs %u size %u", na->na_lut.lut, na->na_lut.objtotal,
+		nm_prdis("lut %p bufs %u size %u", na->na_lut.lut, na->na_lut.objtotal,
 					    na->na_lut.objsize);
 
 		/* ring configuration may have changed, fetch from the card */
@@ -2276,7 +2276,7 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
 			/* This netmap adapter is attached to an ifnet. */
 			unsigned mtu = nm_os_ifnet_mtu(na->ifp);
 
-			ND("%s: mtu %d rx_buf_maxsize %d netmap_buf_size %d",
+			nm_prdis("%s: mtu %d rx_buf_maxsize %d netmap_buf_size %d",
 				na->name, mtu, na->rx_buf_maxsize, NETMAP_BUF_SIZE(na));
 
 			if (na->rx_buf_maxsize == 0) {
@@ -2373,7 +2373,7 @@ nm_sync_finalize(struct netmap_kring *kring)
 	 */
 	kring->ring->tail = kring->rtail = kring->nr_hwtail;
 
-	ND(5, "%s now hwcur %d hwtail %d head %d cur %d tail %d",
+	nm_prdis(5, "%s now hwcur %d hwtail %d head %d cur %d tail %d",
 		kring->name, kring->nr_hwcur, kring->nr_hwtail,
 		kring->rhead, kring->rcur, kring->rtail);
 }
@@ -3771,7 +3771,7 @@ netmap_hw_krings_create(struct netmap_adapter *na)
 		for (i = na->num_rx_rings; i < lim; i++) {
 			mbq_safe_init(&NMR(na, NR_RX)[i]->rx_queue);
 		}
-		ND("initialized sw rx queue %d", na->num_rx_rings);
+		nm_prdis("initialized sw rx queue %d", na->num_rx_rings);
 	}
 	return ret;
 }
@@ -3872,13 +3872,13 @@ netmap_transmit(struct ifnet *ifp, struct mbuf *m)
 
 	if (!netmap_generic_hwcsum) {
 		if (nm_os_mbuf_has_csum_offld(m)) {
-			RD(1, "%s drop mbuf that needs checksum offload", na->name);
+			nm_prlim(1, "%s drop mbuf that needs checksum offload", na->name);
 			goto done;
 		}
 	}
 
 	if (nm_os_mbuf_has_seg_offld(m)) {
-		RD(1, "%s drop mbuf that needs generic segmentation offload", na->name);
+		nm_prlim(1, "%s drop mbuf that needs generic segmentation offload", na->name);
 		goto done;
 	}
 
@@ -3898,11 +3898,11 @@ netmap_transmit(struct ifnet *ifp, struct mbuf *m)
 	if (busy < 0)
 		busy += kring->nkr_num_slots;
 	if (busy + mbq_len(q) >= kring->nkr_num_slots - 1) {
-		RD(2, "%s full hwcur %d hwtail %d qlen %d", na->name,
+		nm_prlim(2, "%s full hwcur %d hwtail %d qlen %d", na->name,
 			kring->nr_hwcur, kring->nr_hwtail, mbq_len(q));
 	} else {
 		mbq_enqueue(q, m);
-		ND(2, "%s %d bufs in queue", na->name, mbq_len(q));
+		nm_prdis(2, "%s %d bufs in queue", na->name, mbq_len(q));
 		/* notify outside the lock */
 		m = NULL;
 		error = 0;
@@ -3938,7 +3938,7 @@ netmap_reset(struct netmap_adapter *na, enum txrx tx, 
 	int new_hwofs, lim;
 
 	if (!nm_native_on(na)) {
-		ND("interface not in native netmap mode");
+		nm_prdis("interface not in native netmap mode");
 		return NULL;	/* nothing to reinitialize */
 	}
 
@@ -4080,7 +4080,7 @@ netmap_rx_irq(struct ifnet *ifp, u_int q, u_int *work_
 		return NM_IRQ_PASS;
 
 	if (na->na_flags & NAF_SKIP_INTR) {
-		ND("use regular interrupt");
+		nm_prdis("use regular interrupt");
 		return NM_IRQ_PASS;
 	}
 
@@ -4119,6 +4119,25 @@ nm_clear_native_flags(struct netmap_adapter *na)
 	nm_os_onexit(ifp);
 
 	na->na_flags &= ~NAF_NETMAP_ON;
+}
+
+void
+netmap_krings_mode_commit(struct netmap_adapter *na, int onoff)
+{
+	enum txrx t;
+
+	for_rx_tx(t) {
+		int i;
+
+		for (i = 0; i < netmap_real_rings(na, t); i++) {
+			struct netmap_kring *kring = NMR(na, t)[i];
+
+			if (onoff && nm_kring_pending_on(kring))
+				kring->nr_mode = NKR_NETMAP_ON;
+			else if (!onoff && nm_kring_pending_off(kring))
+				kring->nr_mode = NKR_NETMAP_OFF;
+		}
+	}
 }
 
 /*

Modified: stable/11/sys/dev/netmap/netmap_bdg.c
==============================================================================
--- stable/11/sys/dev/netmap/netmap_bdg.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap_bdg.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -203,14 +203,14 @@ nm_find_bridge(const char *name, int create, struct ne
 		} else if (x->bdg_namelen != namelen) {
 			continue;
 		} else if (strncmp(name, x->bdg_basename, namelen) == 0) {
-			ND("found '%.*s' at %d", namelen, name, i);
+			nm_prdis("found '%.*s' at %d", namelen, name, i);
 			b = x;
 			break;
 		}
 	}
 	if (i == num_bridges && b) { /* name not found, can create entry */
 		/* initialize the bridge */
-		ND("create new bridge %s with ports %d", b->bdg_basename,
+		nm_prdis("create new bridge %s with ports %d", b->bdg_basename,
 			b->bdg_active_ports);
 		b->ht = nm_os_malloc(sizeof(struct nm_hash_ent) * NM_BDG_HASH);
 		if (b->ht == NULL) {
@@ -239,7 +239,7 @@ netmap_bdg_free(struct nm_bridge *b)
 		return EBUSY;
 	}
 
-	ND("marking bridge %s as free", b->bdg_basename);
+	nm_prdis("marking bridge %s as free", b->bdg_basename);
 	nm_os_free(b->ht);
 	memset(&b->bdg_ops, 0, sizeof(b->bdg_ops));
 	memset(&b->bdg_saved_ops, 0, sizeof(b->bdg_saved_ops));
@@ -312,13 +312,13 @@ netmap_bdg_detach_common(struct nm_bridge *b, int hw, 
 	memcpy(b->tmp_bdg_port_index, b->bdg_port_index, sizeof(b->tmp_bdg_port_index));
 	for (i = 0; (hw >= 0 || sw >= 0) && i < lim; ) {
 		if (hw >= 0 && tmp[i] == hw) {
-			ND("detach hw %d at %d", hw, i);
+			nm_prdis("detach hw %d at %d", hw, i);
 			lim--; /* point to last active port */
 			tmp[i] = tmp[lim]; /* swap with i */
 			tmp[lim] = hw;	/* now this is inactive */
 			hw = -1;
 		} else if (sw >= 0 && tmp[i] == sw) {
-			ND("detach sw %d at %d", sw, i);
+			nm_prdis("detach sw %d at %d", sw, i);
 			lim--;
 			tmp[i] = tmp[lim];
 			tmp[lim] = sw;
@@ -342,7 +342,7 @@ netmap_bdg_detach_common(struct nm_bridge *b, int hw, 
 	b->bdg_active_ports = lim;
 	BDG_WUNLOCK(b);
 
-	ND("now %d active ports", lim);
+	nm_prdis("now %d active ports", lim);
 	netmap_bdg_free(b);
 }
 
@@ -408,7 +408,7 @@ netmap_get_bdg_na(struct nmreq_header *hdr, struct net
 
 	b = nm_find_bridge(nr_name, create, ops);
 	if (b == NULL) {
-		ND("no bridges available for '%s'", nr_name);
+		nm_prdis("no bridges available for '%s'", nr_name);
 		return (create ? ENOMEM : ENXIO);
 	}
 	if (strlen(nr_name) < b->bdg_namelen) /* impossible */
@@ -425,10 +425,10 @@ netmap_get_bdg_na(struct nmreq_header *hdr, struct net
 	for (j = 0; j < b->bdg_active_ports; j++) {
 		i = b->bdg_port_index[j];
 		vpna = b->bdg_ports[i];
-		ND("checking %s", vpna->up.name);
+		nm_prdis("checking %s", vpna->up.name);
 		if (!strcmp(vpna->up.name, nr_name)) {
 			netmap_adapter_get(&vpna->up);
-			ND("found existing if %s refs %d", nr_name)
+			nm_prdis("found existing if %s refs %d", nr_name)
 			*na = &vpna->up;
 			return 0;
 		}
@@ -445,7 +445,7 @@ netmap_get_bdg_na(struct nmreq_header *hdr, struct net
 	/* record the next two ports available, but do not allocate yet */
 	cand = b->bdg_port_index[b->bdg_active_ports];
 	cand2 = b->bdg_port_index[b->bdg_active_ports + 1];
-	ND("+++ bridge %s port %s used %d avail %d %d",
+	nm_prdis("+++ bridge %s port %s used %d avail %d %d",
 		b->bdg_basename, ifname, b->bdg_active_ports, cand, cand2);
 
 	/*
@@ -515,7 +515,7 @@ netmap_get_bdg_na(struct nmreq_header *hdr, struct net
 
 	BDG_WLOCK(b);
 	vpna->bdg_port = cand;
-	ND("NIC  %p to bridge port %d", vpna, cand);
+	nm_prdis("NIC  %p to bridge port %d", vpna, cand);
 	/* bind the port to the bridge (virtual ports are not active) */
 	b->bdg_ports[cand] = vpna;
 	vpna->na_bdg = b;
@@ -526,9 +526,9 @@ netmap_get_bdg_na(struct nmreq_header *hdr, struct net
 		hostna->bdg_port = cand2;
 		hostna->na_bdg = b;
 		b->bdg_active_ports++;
-		ND("host %p to bridge port %d", hostna, cand2);
+		nm_prdis("host %p to bridge port %d", hostna, cand2);
 	}
-	ND("if %s refs %d", ifname, vpna->up.na_refcount);
+	nm_prdis("if %s refs %d", ifname, vpna->up.na_refcount);
 	BDG_WUNLOCK(b);
 	*na = &vpna->up;
 	netmap_adapter_get(*na);
@@ -920,8 +920,6 @@ netmap_vp_reg(struct netmap_adapter *na, int onoff)
 {
 	struct netmap_vp_adapter *vpna =
 		(struct netmap_vp_adapter*)na;
-	enum txrx t;
-	int i;
 
 	/* persistent ports may be put in netmap mode
 	 * before being attached to a bridge
@@ -929,14 +927,7 @@ netmap_vp_reg(struct netmap_adapter *na, int onoff)
 	if (vpna->na_bdg)
 		BDG_WLOCK(vpna->na_bdg);
 	if (onoff) {
-		for_rx_tx(t) {
-			for (i = 0; i < netmap_real_rings(na, t); i++) {
-				struct netmap_kring *kring = NMR(na, t)[i];
-
-				if (nm_kring_pending_on(kring))
-					kring->nr_mode = NKR_NETMAP_ON;
-			}
-		}
+		netmap_krings_mode_commit(na, onoff);
 		if (na->active_fds == 0)
 			na->na_flags |= NAF_NETMAP_ON;
 		 /* XXX on FreeBSD, persistent VALE ports should also
@@ -945,14 +936,7 @@ netmap_vp_reg(struct netmap_adapter *na, int onoff)
 	} else {
 		if (na->active_fds == 0)
 			na->na_flags &= ~NAF_NETMAP_ON;
-		for_rx_tx(t) {
-			for (i = 0; i < netmap_real_rings(na, t); i++) {
-				struct netmap_kring *kring = NMR(na, t)[i];
-
-				if (nm_kring_pending_off(kring))
-					kring->nr_mode = NKR_NETMAP_OFF;
-			}
-		}
+		netmap_krings_mode_commit(na, onoff);
 	}
 	if (vpna->na_bdg)
 		BDG_WUNLOCK(vpna->na_bdg);
@@ -1077,7 +1061,7 @@ netmap_bwrap_dtor(struct netmap_adapter *na)
 			    (bh ? bna->host.bdg_port : -1));
 	}
 
-	ND("na %p", na);
+	nm_prdis("na %p", na);
 	na->ifp = NULL;
 	bna->host.up.ifp = NULL;
 	hwna->na_vp = bna->saved_na_vp;
@@ -1182,7 +1166,7 @@ netmap_bwrap_reg(struct netmap_adapter *na, int onoff)
 	int error, i;
 	enum txrx t;
 
-	ND("%s %s", na->name, onoff ? "on" : "off");
+	nm_prdis("%s %s", na->name, onoff ? "on" : "off");
 
 	if (onoff) {
 		/* netmap_do_regif has been called on the bwrap na.
@@ -1387,7 +1371,7 @@ netmap_bwrap_krings_delete_common(struct netmap_adapte
 	enum txrx t;
 	int i;
 
-	ND("%s", na->name);
+	nm_prdis("%s", na->name);
 
 	/* decrement the usage counter for all the hwna krings */
 	for_rx_tx(t) {
@@ -1414,7 +1398,7 @@ netmap_bwrap_notify(struct netmap_kring *kring, int fl
 	struct netmap_kring *hw_kring;
 	int error;
 
-	ND("%s: na %s hwna %s",
+	nm_prdis("%s: na %s hwna %s",
 			(kring ? kring->name : "NULL!"),
 			(na ? na->name : "NULL!"),
 			(hwna ? hwna->name : "NULL!"));
@@ -1426,7 +1410,7 @@ netmap_bwrap_notify(struct netmap_kring *kring, int fl
 
 	/* first step: simulate a user wakeup on the rx ring */
 	netmap_vp_rxsync(kring, flags);
-	ND("%s[%d] PRE rx(c%3d t%3d l%3d) ring(h%3d c%3d t%3d) tx(c%3d ht%3d t%3d)",
+	nm_prdis("%s[%d] PRE rx(c%3d t%3d l%3d) ring(h%3d c%3d t%3d) tx(c%3d ht%3d t%3d)",
 		na->name, ring_n,
 		kring->nr_hwcur, kring->nr_hwtail, kring->nkr_hwlease,
 		kring->rhead, kring->rcur, kring->rtail,
@@ -1445,7 +1429,7 @@ netmap_bwrap_notify(struct netmap_kring *kring, int fl
 
 	/* fourth step: the user goes to sleep again, causing another rxsync */
 	netmap_vp_rxsync(kring, flags);
-	ND("%s[%d] PST rx(c%3d t%3d l%3d) ring(h%3d c%3d t%3d) tx(c%3d ht%3d t%3d)",
+	nm_prdis("%s[%d] PST rx(c%3d t%3d l%3d) ring(h%3d c%3d t%3d) tx(c%3d ht%3d t%3d)",
 		na->name, ring_n,
 		kring->nr_hwcur, kring->nr_hwtail, kring->nkr_hwlease,
 		kring->rhead, kring->rcur, kring->rtail,
@@ -1595,7 +1579,7 @@ netmap_bwrap_attach_common(struct netmap_adapter *na,
 	if (hwna->na_flags & NAF_MOREFRAG)
 		na->na_flags |= NAF_MOREFRAG;
 
-	ND("%s<->%s txr %d txd %d rxr %d rxd %d",
+	nm_prdis("%s<->%s txr %d txd %d rxr %d rxd %d",
 		na->name, ifp->if_xname,
 		na->num_tx_rings, na->num_tx_desc,
 		na->num_rx_rings, na->num_rx_desc);

Modified: stable/11/sys/dev/netmap/netmap_freebsd.c
==============================================================================
--- stable/11/sys/dev/netmap/netmap_freebsd.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap_freebsd.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -1310,8 +1310,6 @@ nm_os_kctx_destroy(struct nm_kctx *nmk)
 void
 nm_os_selwakeup(struct nm_selinfo *si)
 {
-	if (netmap_verbose)
-		nm_prinf("on knote %p", &si->si.si_note);
 	selwakeuppri(&si->si, PI_NET);
 	/* We use a non-zero hint to distinguish this notification call
 	 * from the call done in kqueue_scan(), which uses hint=0.

Modified: stable/11/sys/dev/netmap/netmap_generic.c
==============================================================================
--- stable/11/sys/dev/netmap/netmap_generic.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap_generic.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -235,18 +235,7 @@ generic_netmap_unregister(struct netmap_adapter *na)
 		nm_os_catch_tx(gna, 0);
 	}
 
-	for_each_rx_kring_h(r, kring, na) {
-		if (nm_kring_pending_off(kring)) {
-			nm_prinf("Emulated adapter: ring '%s' deactivated", kring->name);
-			kring->nr_mode = NKR_NETMAP_OFF;
-		}
-	}
-	for_each_tx_kring_h(r, kring, na) {
-		if (nm_kring_pending_off(kring)) {
-			kring->nr_mode = NKR_NETMAP_OFF;
-			nm_prinf("Emulated adapter: ring '%s' deactivated", kring->name);
-		}
-	}
+	netmap_krings_mode_commit(na, /*onoff=*/0);
 
 	for_each_rx_kring(r, kring, na) {
 		/* Free the mbufs still pending in the RX queues,
@@ -369,19 +358,7 @@ generic_netmap_register(struct netmap_adapter *na, int
 		}
 	}
 
-	for_each_rx_kring_h(r, kring, na) {
-		if (nm_kring_pending_on(kring)) {
-			nm_prinf("Emulated adapter: ring '%s' activated", kring->name);
-			kring->nr_mode = NKR_NETMAP_ON;
-		}
-
-	}
-	for_each_tx_kring_h(r, kring, na) {
-		if (nm_kring_pending_on(kring)) {
-			nm_prinf("Emulated adapter: ring '%s' activated", kring->name);
-			kring->nr_mode = NKR_NETMAP_ON;
-		}
-	}
+	netmap_krings_mode_commit(na, /*onoff=*/1);
 
 	for_each_tx_kring(r, kring, na) {
 		/* Initialize tx_pool and tx_event. */

Modified: stable/11/sys/dev/netmap/netmap_kern.h
==============================================================================
--- stable/11/sys/dev/netmap/netmap_kern.h	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap_kern.h	Tue Feb 12 09:26:05 2019	(r344047)
@@ -266,7 +266,7 @@ typedef struct hrtimer{
 		__LINE__, __FUNCTION__, ##__VA_ARGS__);		\
 	} while (0)
 
-/* Disabled printf (used to be ND). */
+/* Disabled printf (used to be nm_prdis). */
 #define nm_prdis(format, ...)
 
 /* Rate limited, lps indicates how many per second. */
@@ -281,11 +281,6 @@ typedef struct hrtimer{
 			nm_prinf(format, ##__VA_ARGS__);	\
 	} while (0)
 
-/* Old macros. */
-#define ND	nm_prdis
-#define D	nm_prerr
-#define RD	nm_prlim
-
 struct netmap_adapter;
 struct nm_bdg_fwd;
 struct nm_bridge;
@@ -1144,7 +1139,7 @@ nm_kr_rxspace(struct netmap_kring *k)
 	int space = k->nr_hwtail - k->nr_hwcur;
 	if (space < 0)
 		space += k->nkr_num_slots;
-	ND("preserving %d rx slots %d -> %d", space, k->nr_hwcur, k->nr_hwtail);
+	nm_prdis("preserving %d rx slots %d -> %d", space, k->nr_hwcur, k->nr_hwtail);
 
 	return space;
 }
@@ -1370,6 +1365,8 @@ nm_update_hostrings_mode(struct netmap_adapter *na)
 void nm_set_native_flags(struct netmap_adapter *);
 void nm_clear_native_flags(struct netmap_adapter *);
 
+void netmap_krings_mode_commit(struct netmap_adapter *na, int onoff);
+
 /*
  * nm_*sync_prologue() functions are used in ioctl/poll and ptnetmap
  * kthreads.
@@ -1397,7 +1394,7 @@ uint32_t nm_rxsync_prologue(struct netmap_kring *, str
 #if 1 /* debug version */
 #define	NM_CHECK_ADDR_LEN(_na, _a, _l)	do {				\
 	if (_a == NETMAP_BUF_BASE(_na) || _l > NETMAP_BUF_SIZE(_na)) {	\
-		RD(5, "bad addr/len ring %d slot %d idx %d len %d",	\
+		nm_prlim(5, "bad addr/len ring %d slot %d idx %d len %d",	\
 			kring->ring_id, nm_i, slot->buf_idx, len);	\
 		if (_l > NETMAP_BUF_SIZE(_na))				\
 			_l = NETMAP_BUF_SIZE(_na);			\
@@ -1559,7 +1556,7 @@ void __netmap_adapter_get(struct netmap_adapter *na);
 #define netmap_adapter_get(na) 				\
 	do {						\
 		struct netmap_adapter *__na = na;	\
-		D("getting %p:%s (%d)", __na, (__na)->name, (__na)->na_refcount);	\
+		nm_prinf("getting %p:%s (%d)", __na, (__na)->name, (__na)->na_refcount);	\
 		__netmap_adapter_get(__na);		\
 	} while (0)
 
@@ -1568,7 +1565,7 @@ int __netmap_adapter_put(struct netmap_adapter *na);
 #define netmap_adapter_put(na)				\
 	({						\
 		struct netmap_adapter *__na = na;	\
-		D("putting %p:%s (%d)", __na, (__na)->name, (__na)->na_refcount);	\
+		nm_prinf("putting %p:%s (%d)", __na, (__na)->name, (__na)->na_refcount);	\
 		__netmap_adapter_put(__na);		\
 	})
 
@@ -1730,7 +1727,7 @@ int nm_iommu_group_id(bus_dma_tag_t dev);
 			addr, NETMAP_BUF_SIZE, DMA_TO_DEVICE);
 
 	if (dma_mapping_error(&adapter->pdev->dev, buffer_info->dma)) {
-		D("dma mapping error");
+		nm_prerr("dma mapping error");
 		/* goto dma_error; See e1000_put_txbuf() */
 		/* XXX reset */
 	}
@@ -1989,6 +1986,12 @@ nm_si_user(struct netmap_priv_d *priv, enum txrx t)
 #ifdef WITH_PIPES
 int netmap_pipe_txsync(struct netmap_kring *txkring, int flags);
 int netmap_pipe_rxsync(struct netmap_kring *rxkring, int flags);
+int netmap_pipe_krings_create_both(struct netmap_adapter *na,
+				  struct netmap_adapter *ona);
+void netmap_pipe_krings_delete_both(struct netmap_adapter *na,
+				    struct netmap_adapter *ona);
+int netmap_pipe_reg_both(struct netmap_adapter *na,
+			 struct netmap_adapter *ona);
 #endif /* WITH_PIPES */
 
 #ifdef WITH_MONITOR
@@ -2323,7 +2326,7 @@ nm_os_get_mbuf(struct ifnet *ifp, int len)
 		m->m_ext.ext_arg1 = m->m_ext.ext_buf; // XXX save
 		m->m_ext.ext_free = (void *)void_mbuf_dtor;
 		m->m_ext.ext_type = EXT_EXTREF;
-		ND(5, "create m %p refcnt %d", m, MBUF_REFCNT(m));
+		nm_prdis(5, "create m %p refcnt %d", m, MBUF_REFCNT(m));
 	}
 	return m;
 }

Modified: stable/11/sys/dev/netmap/netmap_legacy.c
==============================================================================
--- stable/11/sys/dev/netmap/netmap_legacy.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap_legacy.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -362,7 +362,14 @@ netmap_ioctl_legacy(struct netmap_priv_d *priv, u_long
 		/* Request for the legacy control API. Convert it to a
 		 * NIOCCTRL request. */
 		struct nmreq *nmr = (struct nmreq *) data;
-		struct nmreq_header *hdr = nmreq_from_legacy(nmr, cmd);
+		struct nmreq_header *hdr;
+
+		if (nmr->nr_version < 11) {
+			nm_prerr("Minimum supported API is 11 (requested %u)",
+			    nmr->nr_version);
+			return EINVAL;
+		}
+		hdr = nmreq_from_legacy(nmr, cmd);
 		if (hdr == NULL) { /* out of memory */
 			return ENOMEM;
 		}
@@ -387,14 +394,14 @@ netmap_ioctl_legacy(struct netmap_priv_d *priv, u_long
 #ifdef __FreeBSD__
 	case FIONBIO:
 	case FIOASYNC:
-		ND("FIONBIO/FIOASYNC are no-ops");
+		/* FIONBIO/FIOASYNC are no-ops. */
 		break;
 
 	case BIOCIMMEDIATE:
 	case BIOCGHDRCMPLT:
 	case BIOCSHDRCMPLT:
 	case BIOCSSEESENT:
-		D("ignore BIOCIMMEDIATE/BIOCSHDRCMPLT/BIOCSHDRCMPLT/BIOCSSEESENT");
+		/* Ignore these commands. */
 		break;
 
 	default:	/* allow device-specific ioctls */

Modified: stable/11/sys/dev/netmap/netmap_mem2.c
==============================================================================
--- stable/11/sys/dev/netmap/netmap_mem2.c	Tue Feb 12 09:07:46 2019	(r344046)
+++ stable/11/sys/dev/netmap/netmap_mem2.c	Tue Feb 12 09:26:05 2019	(r344047)
@@ -977,7 +977,7 @@ netmap_obj_offset(struct netmap_obj_pool *p, const voi
 			continue;
 
 		ofs = ofs + relofs;
-		ND("%s: return offset %d (cluster %d) for pointer %p",
+		nm_prdis("%s: return offset %d (cluster %d) for pointer %p",
 		    p->name, ofs, i, vaddr);
 		return ofs;
 	}
@@ -1041,7 +1041,7 @@ netmap_obj_malloc(struct netmap_obj_pool *p, u_int len
 		if (index)
 			*index = i * 32 + j;
 	}
-	ND("%s allocator: allocated object @ [%d][%d]: vaddr %p",p->name, i, j, vaddr);
+	nm_prdis("%s allocator: allocated object @ [%d][%d]: vaddr %p",p->name, i, j, vaddr);
 
 	if (start)
 		*start = i;
@@ -1141,7 +1141,7 @@ netmap_extra_alloc(struct netmap_adapter *na, uint32_t
 			*head = cur; /* restore */
 			break;
 		}
-		ND(5, "allocate buffer %d -> %d", *head, cur);
+		nm_prdis(5, "allocate buffer %d -> %d", *head, cur);
 		*p = cur; /* link to previous head */
 	}
 
@@ -1158,7 +1158,7 @@ netmap_extra_free(struct netmap_adapter *na, uint32_t 
 	struct netmap_obj_pool *p = &nmd->pools[NETMAP_BUF_POOL];
 	uint32_t i, cur, *buf;
 
-	ND("freeing the extra list");
+	nm_prdis("freeing the extra list");
 	for (i = 0; head >=2 && head < p->objtotal; i++) {
 		cur = head;
 		buf = lut[head].vaddr;
@@ -1195,7 +1195,7 @@ netmap_new_bufs(struct netmap_mem_d *nmd, struct netma
 		slot[i].ptr = 0;
 	}
 
-	ND("%s: allocated %d buffers, %d available, first at %d", p->name, n, p->objfree, pos);
+	nm_prdis("%s: allocated %d buffers, %d available, first at %d", p->name, n, p->objfree, pos);
 	return (0);
 
 cleanup:
@@ -1243,7 +1243,7 @@ netmap_free_bufs(struct netmap_mem_d *nmd, struct netm
 		if (slot[i].buf_idx > 1)
 			netmap_free_buf(nmd, slot[i].buf_idx);
 	}
-	ND("%s: released some buffers, available: %u",
+	nm_prdis("%s: released some buffers, available: %u",
 			p->name, p->objfree);
 }
 
@@ -1537,7 +1537,7 @@ netmap_mem_unmap(struct netmap_obj_pool *p, struct net
 	(void)lut;
 	nm_prerr("unsupported on Windows");
 #else /* linux */
-	ND("unmapping and freeing plut for %s", na->name);
+	nm_prdis("unmapping and freeing plut for %s", na->name);
 	if (lut->plut == NULL)
 		return 0;
 	for (i = 0; i < lim; i += p->_clustentries) {
@@ -1575,11 +1575,11 @@ netmap_mem_map(struct netmap_obj_pool *p, struct netma
 #else /* linux */
 
 	if (lut->plut != NULL) {
-		ND("plut already allocated for %s", na->name);
+		nm_prdis("plut already allocated for %s", na->name);
 		return 0;
 	}
 
-	ND("allocating physical lut for %s", na->name);
+	nm_prdis("allocating physical lut for %s", na->name);
 	lut->plut = nm_alloc_plut(lim);
 	if (lut->plut == NULL) {
 		nm_prerr("Failed to allocate physical lut for %s", na->name);
@@ -1773,7 +1773,7 @@ netmap_mem2_config(struct netmap_mem_d *nmd)
 	if (!netmap_mem_params_changed(nmd->params))
 		goto out;
 
-	ND("reconfiguring");
+	nm_prdis("reconfiguring");
 
 	if (nmd->flags & NETMAP_MEM_FINALIZED) {
 		/* reset previous allocation */
@@ -1868,10 +1868,10 @@ netmap_free_rings(struct netmap_adapter *na)
 			if (netmap_debug & NM_DEBUG_MEM)
 				nm_prinf("deleting ring %s", kring->name);
 			if (!(kring->nr_kflags & NKR_FAKERING)) {
-				ND("freeing bufs for %s", kring->name);
+				nm_prdis("freeing bufs for %s", kring->name);
 				netmap_free_bufs(na->nm_mem, ring->slot, kring->nkr_num_slots);
 			} else {
-				ND("NOT freeing bufs for %s", kring->name);
+				nm_prdis("NOT freeing bufs for %s", kring->name);
 			}
 			netmap_ring_free(na->nm_mem, ring);
 			kring->ring = NULL;
@@ -1916,7 +1916,7 @@ netmap_mem2_rings_create(struct netmap_adapter *na)
 				nm_prerr("Cannot allocate %s_ring", nm_txrx2str(t));
 				goto cleanup;
 			}
-			ND("txring at %p", ring);
+			nm_prdis("txring at %p", ring);
 			kring->ring = ring;
 			*(uint32_t *)(uintptr_t)&ring->num_slots = ndesc;
 			*(int64_t *)(uintptr_t)&ring->buf_ofs =
@@ -1930,9 +1930,9 @@ netmap_mem2_rings_create(struct netmap_adapter *na)
 			ring->tail = kring->rtail;
 			*(uint32_t *)(uintptr_t)&ring->nr_buf_size =
 				netmap_mem_bufsize(na->nm_mem);
-			ND("%s h %d c %d t %d", kring->name,
+			nm_prdis("%s h %d c %d t %d", kring->name,
 				ring->head, ring->cur, ring->tail);
-			ND("initializing slots for %s_ring", nm_txrx2str(t));
+			nm_prdis("initializing slots for %s_ring", nm_txrx2str(t));
 			if (!(kring->nr_kflags & NKR_FAKERING)) {
 				/* this is a real ring */
 				if (netmap_debug & NM_DEBUG_MEM)
@@ -2304,19 +2304,19 @@ netmap_mem_ext_create(uint64_t usrptr, struct nmreq_po
 #if !defined(linux) && !defined(_WIN32)
 			p->lut[j].paddr = vtophys(p->lut[j].vaddr);
 #endif
-			ND("%s %d at %p", p->name, j, p->lut[j].vaddr);
+			nm_prdis("%s %d at %p", p->name, j, p->lut[j].vaddr);
 			noff = off + p->_objsize;
 			if (noff < PAGE_SIZE) {
 				off = noff;
 				continue;
 			}
-			ND("too big, recomputing offset...");
+			nm_prdis("too big, recomputing offset...");
 			while (noff >= PAGE_SIZE) {
 				char *old_clust = clust;
 				noff -= PAGE_SIZE;
 				clust = nm_os_extmem_nextpage(nme->os);
 				nr_pages--;
-				ND("noff %zu page %p nr_pages %d", noff,
+				nm_prdis("noff %zu page %p nr_pages %d", noff,
 						page_to_virt(*pages), nr_pages);
 				if (noff > 0 && !nm_isset(p->invalid_bitmap, j) &&
 					(nr_pages == 0 ||
@@ -2326,7 +2326,7 @@ netmap_mem_ext_create(uint64_t usrptr, struct nmreq_po
 					 * drop this object
 					 * */
 					p->invalid_bitmap[ (j>>5) ] |= 1U << (j & 31U);
-					ND("non contiguous at off %zu, drop", noff);
+					nm_prdis("non contiguous at off %zu, drop", noff);
 				}
 				if (nr_pages == 0)
 					break;
@@ -2336,7 +2336,7 @@ netmap_mem_ext_create(uint64_t usrptr, struct nmreq_po
 		p->objtotal = j;
 		p->numclusters = p->objtotal;
 		p->memtotal = j * p->_objsize;
-		ND("%d memtotal %u", j, p->memtotal);
+		nm_prdis("%d memtotal %u", j, p->memtotal);
 	}
 
 	netmap_mem_ext_register(nme);
@@ -2440,7 +2440,7 @@ netmap_mem_pt_guest_ifp_del(struct netmap_mem_d *nmd, 
 			} else {
 				ptnmd->pt_ifs = curr->next;
 			}
-			D("removed (ifp=%p,nifp_offset=%u)",
+			nm_prinf("removed (ifp=%p,nifp_offset=%u)",
 			  curr->ifp, curr->nifp_offset);
 			nm_os_free(curr);
 			ret = 0;
@@ -2496,7 +2496,7 @@ netmap_mem_pt_guest_ofstophys(struct netmap_mem_d *nmd
 	vm_paddr_t paddr;
 	/* if the offset is valid, just return csb->base_addr + off */
 	paddr = (vm_paddr_t)(ptnmd->nm_paddr + off);
-	ND("off %lx padr %lx", off, (unsigned long)paddr);
+	nm_prdis("off %lx padr %lx", off, (unsigned long)paddr);
 	return paddr;
 }
 
@@ -2526,7 +2526,7 @@ netmap_mem_pt_guest_finalize(struct netmap_mem_d *nmd)
 		goto out;
 
 	if (ptnmd->ptn_dev == NULL) {
-		D("ptnetmap memdev not attached");
+		nm_prerr("ptnetmap memdev not attached");
 		error = ENOMEM;
 		goto out;
 	}
@@ -2545,10 +2545,10 @@ netmap_mem_pt_guest_finalize(struct netmap_mem_d *nmd)
 
 	/* allocate the lut */
 	if (ptnmd->buf_lut.lut == NULL) {
-		D("allocating lut");
+		nm_prinf("allocating lut");
 		ptnmd->buf_lut.lut = nm_alloc_lut(nbuffers);
 		if (ptnmd->buf_lut.lut == NULL) {
-			D("lut allocation failed");
+			nm_prerr("lut allocation failed");
 			return ENOMEM;
 		}
 	}
@@ -2613,11 +2613,11 @@ netmap_mem_pt_guest_delete(struct netmap_mem_d *nmd)
 	if (nmd == NULL)
 		return;
 	if (netmap_verbose)
-		D("deleting %p", nmd);
+		nm_prinf("deleting %p", nmd);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902120926.x1C9Q6jh005696>