svn commit: r361697 - head/sys/dev/netmap

Vincenzo Maffione vmaffione at FreeBSD.org
Mon Jun 1 16:12:10 UTC 2020


Author: vmaffione
Date: Mon Jun  1 16:12:09 2020
New Revision: 361697
URL: https://svnweb.freebsd.org/changeset/base/361697

Log:
  netmap: if_vtnet: replace vtnet_free_used()
  
  The functionality contained in this function is duplicated,
  as it is already available in vtnet_txq_free_mbufs()
  and vtnet_rxq_free_mbufs().
  
  MFC after:	1 week

Modified:
  head/sys/dev/netmap/if_vtnet_netmap.h

Modified: head/sys/dev/netmap/if_vtnet_netmap.h
==============================================================================
--- head/sys/dev/netmap/if_vtnet_netmap.h	Mon Jun  1 16:10:44 2020	(r361696)
+++ head/sys/dev/netmap/if_vtnet_netmap.h	Mon Jun  1 16:12:09 2020	(r361697)
@@ -52,37 +52,6 @@ vtnet_netmap_queue_on(struct vtnet_softc *sc, enum txr
 		na->tx_rings[idx]->nr_mode == NKR_NETMAP_ON);
 }
 
-static void
-vtnet_free_used(struct virtqueue *vq, int netmap_bufs, enum txrx t, int idx)
-{
-	void *cookie;
-	int deq = 0;
-
-	while ((cookie = virtqueue_dequeue(vq, NULL)) != NULL) {
-		if (netmap_bufs) {
-			/* These are netmap buffers: there is nothing to do. */
-		} else {
-			/* These are mbufs that we need to free. */
-			struct mbuf *m;
-
-			if (t == NR_TX) {
-				struct vtnet_tx_header *txhdr = cookie;
-				m = txhdr->vth_mbuf;
-				m_freem(m);
-				uma_zfree(vtnet_tx_header_zone, txhdr);
-			} else {
-				m = cookie;
-				m_freem(m);
-			}
-		}
-		deq++;
-	}
-
-	if (deq)
-		nm_prinf("%d sgs dequeued from %s-%d (netmap=%d)",
-			 deq, nm_txrx2str(t), idx, netmap_bufs);
-}
-
 /* Register and unregister. */
 static int
 vtnet_netmap_reg(struct netmap_adapter *na, int state)
@@ -113,18 +82,13 @@ vtnet_netmap_reg(struct netmap_adapter *na, int state)
 	for (i = 0; i < sc->vtnet_act_vq_pairs; i++) {
 		struct vtnet_txq *txq = &sc->vtnet_txqs[i];
 		struct vtnet_rxq *rxq = &sc->vtnet_rxqs[i];
-		struct netmap_kring *kring;
 
 		VTNET_TXQ_LOCK(txq);
-		kring = NMR(na, NR_TX)[i];
-		vtnet_free_used(txq->vtntx_vq,
-				kring->nr_mode == NKR_NETMAP_ON, NR_TX, i);
+		vtnet_txq_free_mbufs(txq);
 		VTNET_TXQ_UNLOCK(txq);
 
 		VTNET_RXQ_LOCK(rxq);
-		kring = NMR(na, NR_RX)[i];
-		vtnet_free_used(rxq->vtnrx_vq,
-				kring->nr_mode == NKR_NETMAP_ON, NR_RX, i);
+		vtnet_rxq_free_mbufs(rxq);
 		VTNET_RXQ_UNLOCK(rxq);
 	}
 	vtnet_init_locked(sc);


More information about the svn-src-head mailing list