diff options
| author | yamaguchi <yamaguchi@NetBSD.org> | 2022-03-29 01:57:51 +0000 |
|---|---|---|
| committer | yamaguchi <yamaguchi@NetBSD.org> | 2022-03-29 01:57:51 +0000 |
| commit | 6817983d0f08290c5cb1f5fb5e71f4bc8ed3be53 (patch) | |
| tree | cb3c52b9de6b10aa1835b178b82a74c65d326837 /sys/dev | |
| parent | 9ff056d28219721402d59c158bc52c8990b0b62d (diff) | |
vioif(4): Added a comment about stopping packet processing
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pci/if_vioif.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/sys/dev/pci/if_vioif.c b/sys/dev/pci/if_vioif.c index 8d4c7ee860b..70b8c8f9cd4 100644 --- a/sys/dev/pci/if_vioif.c +++ b/sys/dev/pci/if_vioif.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vioif.c,v 1.75 2022/03/24 08:02:21 yamaguchi Exp $ */ +/* $NetBSD: if_vioif.c,v 1.76 2022/03/29 01:57:51 yamaguchi Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.75 2022/03/24 08:02:21 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.76 2022/03/29 01:57:51 yamaguchi Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -1211,6 +1211,34 @@ vioif_init(struct ifnet *ifp) } static void +vioif_stop_rendezvous(struct vioif_softc *sc) +{ + struct vioif_txqueue *txq; + struct vioif_rxqueue *rxq; + int i; + + /* + * stop all packet processing: + * 1. acquire a lock for queue to wait + * for finish of interrupt handler + * 2. stop workqueue for packet processing + */ + + for (i =0; i < sc->sc_act_nvq_pairs; i++) { + txq = &sc->sc_txq[i]; + rxq = &sc->sc_rxq[i]; + + mutex_enter(rxq->rxq_lock); + mutex_exit(rxq->rxq_lock); + vioif_work_wait(sc->sc_txrx_workqueue, &rxq->rxq_work); + + mutex_enter(txq->txq_lock); + mutex_exit(txq->txq_lock); + vioif_work_wait(sc->sc_txrx_workqueue, &txq->txq_work); + } +} + +static void vioif_stop(struct ifnet *ifp, int disable) { struct vioif_softc *sc = ifp->if_softc; @@ -1243,19 +1271,7 @@ vioif_stop(struct ifnet *ifp, int disable) /* only way to stop I/O and DMA is resetting... */ virtio_reset(vsc); - /* rendezvous for finish of handlers */ - for (i = 0; i < sc->sc_act_nvq_pairs; i++) { - txq = &sc->sc_txq[i]; - rxq = &sc->sc_rxq[i]; - - mutex_enter(rxq->rxq_lock); - mutex_exit(rxq->rxq_lock); - vioif_work_wait(sc->sc_txrx_workqueue, &rxq->rxq_work); - - mutex_enter(txq->txq_lock); - mutex_exit(txq->txq_lock); - vioif_work_wait(sc->sc_txrx_workqueue, &txq->txq_work); - } + vioif_stop_rendezvous(sc); for (i = 0; i < sc->sc_act_nvq_pairs; i++) { vioif_rx_queue_clear(&sc->sc_rxq[i]); |
