[Midnightbsd-cvs] src [8126] trunk/sys/dev/netmap/netmap.c: cleanup locking
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Sep 16 17:43:31 EDT 2016
Revision: 8126
http://svnweb.midnightbsd.org/src/?rev=8126
Author: laffer1
Date: 2016-09-16 17:43:31 -0400 (Fri, 16 Sep 2016)
Log Message:
-----------
cleanup locking
Modified Paths:
--------------
trunk/sys/dev/netmap/netmap.c
Modified: trunk/sys/dev/netmap/netmap.c
===================================================================
--- trunk/sys/dev/netmap/netmap.c 2016-09-16 21:42:57 UTC (rev 8125)
+++ trunk/sys/dev/netmap/netmap.c 2016-09-16 21:43:31 UTC (rev 8126)
@@ -186,6 +186,8 @@
lim = na->tx_rings[i].nkr_num_slots;
for (j = 0; j < lim; j++)
netmap_free_buf(nifp, ring->slot[j].buf_idx);
+ /* knlist_destroy(&na->tx_rings[i].si.si_note); */
+ mtx_destroy(&na->tx_rings[i].q_lock);
}
for (i = 0; i < na->num_rx_rings + 1; i++) {
struct netmap_ring *ring = na->rx_rings[i].ring;
@@ -192,7 +194,12 @@
lim = na->rx_rings[i].nkr_num_slots;
for (j = 0; j < lim; j++)
netmap_free_buf(nifp, ring->slot[j].buf_idx);
+ /* knlist_destroy(&na->rx_rings[i].si.si_note); */
+ mtx_destroy(&na->rx_rings[i].q_lock);
}
+ /* XXX kqueue(9) needed; these will mirror knlist_init. */
+ /* knlist_destroy(&na->tx_si.si_note); */
+ /* knlist_destroy(&na->rx_si.si_note); */
NMA_UNLOCK();
netmap_free_rings(na);
wakeup(na);
@@ -593,6 +600,10 @@
/* Otherwise set the card in netmap mode
* and make it use the shared buffers.
*/
+ for (i = 0 ; i < na->num_tx_rings + 1; i++)
+ mtx_init(&na->tx_rings[i].q_lock, "nm_txq_lock", NULL, MTX_DEF);
+ for (i = 0 ; i < na->num_rx_rings + 1; i++)
+ mtx_init(&na->rx_rings[i].q_lock, "nm_rxq_lock", NULL, MTX_DEF);
error = na->nm_register(ifp, 1); /* mode on */
if (error)
netmap_dtor_locked(priv);
@@ -970,7 +981,7 @@
int
netmap_attach(struct netmap_adapter *na, int num_queues)
{
- int i, n, size;
+ int n, size;
void *buf;
struct ifnet *ifp = na->ifp;
@@ -999,13 +1010,14 @@
ifp->if_capabilities |= IFCAP_NETMAP;
na = buf;
- if (na->nm_lock == NULL)
+ /* Core lock initialized here. Others are initialized after
+ * netmap_if_new.
+ */
+ mtx_init(&na->core_lock, "netmap core lock", NULL, MTX_DEF);
+ if (na->nm_lock == NULL) {
+ ND("using default locks for %s", ifp->if_xname);
na->nm_lock = netmap_lock_wrapper;
- mtx_init(&na->core_lock, "netmap core lock", NULL, MTX_DEF);
- for (i = 0 ; i < na->num_tx_rings + 1; i++)
- mtx_init(&na->tx_rings[i].q_lock, "netmap txq lock", NULL, MTX_DEF);
- for (i = 0 ; i < na->num_rx_rings + 1; i++)
- mtx_init(&na->rx_rings[i].q_lock, "netmap rxq lock", NULL, MTX_DEF);
+ }
}
#ifdef linux
D("netdev_ops %p", ifp->netdev_ops);
@@ -1026,24 +1038,13 @@
void
netmap_detach(struct ifnet *ifp)
{
- u_int i;
struct netmap_adapter *na = NA(ifp);
if (!na)
return;
- for (i = 0; i < na->num_tx_rings + 1; i++) {
- /* knlist_destroy(&na->tx_rings[i].si.si_note); */
- mtx_destroy(&na->tx_rings[i].q_lock);
- }
- for (i = 0; i < na->num_rx_rings + 1; i++) {
- /* knlist_destroy(&na->rx_rings[i].si.si_note); */
- mtx_destroy(&na->rx_rings[i].q_lock);
- }
mtx_destroy(&na->core_lock);
- /* XXX kqueue(9) needed; these will mirror knlist_init. */
- /* knlist_destroy(&na->tx_si.si_note); */
- /* knlist_destroy(&na->rx_si.si_note); */
+
bzero(na, sizeof(*na));
WNA(ifp) = NULL;
free(na, M_DEVBUF);
More information about the Midnightbsd-cvs
mailing list