Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Added functions to set interrupt handler and index i...
details: https://anonhg.NetBSD.org/src/rev/0f2dcd939bb3
branches: trunk
changeset: 373975:0f2dcd939bb3
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Thu Mar 23 03:55:11 2023 +0000
description:
Added functions to set interrupt handler and index into virtqueue
diffstat:
sys/dev/pci/if_vioif.c | 23 ++--
sys/dev/pci/ld_virtio.c | 12 +-
sys/dev/pci/vio9p.c | 11 +-
sys/dev/pci/viomb.c | 18 ++-
sys/dev/pci/viornd.c | 8 +-
sys/dev/pci/vioscsi.c | 12 +-
sys/dev/pci/virtio.c | 227 +++++++++++++++++++++++++----------------------
sys/dev/pci/virtiovar.h | 16 +-
sys/dev/virtio/viocon.c | 16 +-
9 files changed, 183 insertions(+), 160 deletions(-)
diffs (truncated from 783 to 300 lines):
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/if_vioif.c
--- a/sys/dev/pci/if_vioif.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/if_vioif.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vioif.c,v 1.103 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: if_vioif.c,v 1.104 2023/03/23 03:55:11 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.103 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.104 2023/03/23 03:55:11 yamaguchi Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -596,8 +596,10 @@
* Allocating a virtqueue for control channel
*/
sc->sc_ctrlq.ctrlq_vq = &sc->sc_vqs[ctrlq_idx];
- r = virtio_alloc_vq(vsc, ctrlq->ctrlq_vq, ctrlq_idx,
- NBPG, 1, "control");
+ virtio_init_vq(vsc, ctrlq->ctrlq_vq, ctrlq_idx,
+ vioif_ctrl_intr, ctrlq);
+
+ r = virtio_alloc_vq(vsc, ctrlq->ctrlq_vq, NBPG, 1, "control");
if (r != 0) {
aprint_error_dev(self, "failed to allocate "
"a virtqueue for control channel, error code %d\n",
@@ -606,9 +608,6 @@
sc->sc_has_ctrl = false;
cv_destroy(&ctrlq->ctrlq_wait);
mutex_destroy(&ctrlq->ctrlq_wait_lock);
- } else {
- ctrlq->ctrlq_vq->vq_intrhand = vioif_ctrl_intr;
- ctrlq->ctrlq_vq->vq_intrhand_arg = (void *) ctrlq;
}
}
@@ -623,7 +622,7 @@
goto err;
r = virtio_child_attach_finish(vsc, sc->sc_vqs, nvqs,
- vioif_config_change, virtio_vq_intrhand, req_flags);
+ vioif_config_change, req_flags);
if (r != 0)
goto err;
@@ -1470,15 +1469,15 @@
"%s-%s", device_xname(sc->sc_dev), qname);
mutex_init(&netq->netq_lock, MUTEX_DEFAULT, IPL_NET);
- r = virtio_alloc_vq(vsc, vq, qid,
+ virtio_init_vq(vsc, vq, qid, params[dir].intrhand, netq);
+
+ r = virtio_alloc_vq(vsc, vq,
params[dir].segsize + sc->sc_hdr_size,
params[dir].nsegs, qname);
if (r != 0)
goto err;
netq->netq_vq = vq;
- netq->netq_vq->vq_intrhand = params[dir].intrhand;
- netq->netq_vq->vq_intrhand_arg = netq;
netq->netq_softint = softint_establish(softint_flags,
params[dir].sihand, netq);
if (netq->netq_softint == NULL) {
@@ -1534,8 +1533,6 @@
softint_disestablish(netq->netq_softint);
netq->netq_softint = NULL;
}
- netq->netq_vq->vq_intrhand = NULL;
- netq->netq_vq->vq_intrhand_arg = NULL;
virtio_free_vq(vsc, vq);
mutex_destroy(&netq->netq_lock);
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/ld_virtio.c
--- a/sys/dev/pci/ld_virtio.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/ld_virtio.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_virtio.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: ld_virtio.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $ */
/*
* Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -332,15 +332,17 @@
/* 2 for the minimum size */
maxnsegs += VIRTIO_BLK_MIN_SEGMENTS;
- if (virtio_alloc_vq(vsc, &sc->sc_vq, 0, maxxfersize, maxnsegs,
+ virtio_init_vq_vqdone(vsc, &sc->sc_vq, 0,
+ ld_virtio_vq_done);
+
+ if (virtio_alloc_vq(vsc, &sc->sc_vq, maxxfersize, maxnsegs,
"I/O request") != 0) {
goto err;
}
qsize = sc->sc_vq.vq_num;
- sc->sc_vq.vq_done = ld_virtio_vq_done;
if (virtio_child_attach_finish(vsc, &sc->sc_vq, 1,
- NULL, virtio_vq_intr, VIRTIO_F_INTR_MSIX) != 0)
+ NULL, VIRTIO_F_INTR_MSIX) != 0)
goto err;
ld->sc_dv = self;
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/vio9p.c
--- a/sys/dev/pci/vio9p.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/vio9p.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vio9p.c,v 1.10 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: vio9p.c,v 1.11 2023/03/23 03:55:11 yamaguchi Exp $ */
/*
* Copyright (c) 2019 Internet Initiative Japan, Inc.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vio9p.c,v 1.10 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vio9p.c,v 1.11 2023/03/23 03:55:11 yamaguchi Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -507,13 +507,12 @@
if ((features & VIO9P_F_MOUNT_TAG) == 0)
goto err_none;
- error = virtio_alloc_vq(vsc, &sc->sc_vq[0], 0, VIO9P_MAX_REQLEN,
+ virtio_init_vq_vqdone(vsc, &sc->sc_vq[0], 0, vio9p_request_done);
+ error = virtio_alloc_vq(vsc, &sc->sc_vq[0], VIO9P_MAX_REQLEN,
VIO9P_N_SEGMENTS * 2, "vio9p");
if (error != 0)
goto err_none;
- sc->sc_vq[0].vq_done = vio9p_request_done;
-
sc->sc_buf_tx = kmem_alloc(VIO9P_MAX_REQLEN, KM_SLEEP);
sc->sc_buf_rx = kmem_alloc(VIO9P_MAX_REQLEN, KM_SLEEP);
@@ -555,7 +554,7 @@
aprint_normal_dev(self, "tagged as %s\n", sc->sc_tag);
error = virtio_child_attach_finish(vsc, sc->sc_vq,
- __arraycount(sc->sc_vq), NULL, virtio_vq_intr,
+ __arraycount(sc->sc_vq), NULL,
VIRTIO_F_INTR_MPSAFE | VIRTIO_F_INTR_SOFTINT);
if (error != 0)
goto err_mutex;
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/viomb.c
--- a/sys/dev/pci/viomb.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/viomb.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: viomb.c,v 1.14 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: viomb.c,v 1.15 2023/03/23 03:55:11 yamaguchi Exp $ */
/*
* Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.14 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viomb.c,v 1.15 2023/03/23 03:55:11 yamaguchi Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -163,18 +163,20 @@
mutex_init(&sc->sc_waitlock, MUTEX_DEFAULT, IPL_VM); /* spin */
cv_init(&sc->sc_wait, "balloon");
- if (virtio_alloc_vq(vsc, &sc->sc_vq[VQ_INFLATE], 0,
+ virtio_init_vq_vqdone(vsc, &sc->sc_vq[VQ_INFLATE], VQ_INFLATE,
+ inflateq_done);
+ virtio_init_vq_vqdone(vsc, &sc->sc_vq[VQ_DEFLATE], VQ_DEFLATE,
+ deflateq_done);
+
+ if (virtio_alloc_vq(vsc, &sc->sc_vq[VQ_INFLATE],
sizeof(uint32_t)*PGS_PER_REQ, 1,
"inflate") != 0)
goto err_mutex;
- if (virtio_alloc_vq(vsc, &sc->sc_vq[VQ_DEFLATE], 1,
+ if (virtio_alloc_vq(vsc, &sc->sc_vq[VQ_DEFLATE],
sizeof(uint32_t)*PGS_PER_REQ, 1,
"deflate") != 0)
goto err_vq0;
- sc->sc_vq[VQ_INFLATE].vq_done = inflateq_done;
- sc->sc_vq[VQ_DEFLATE].vq_done = deflateq_done;
-
if (bus_dmamap_create(virtio_dmat(vsc), sizeof(uint32_t)*PGS_PER_REQ,
1, sizeof(uint32_t)*PGS_PER_REQ, 0,
BUS_DMA_NOWAIT, &sc->sc_req.bl_dmamap)) {
@@ -190,7 +192,7 @@
}
if (virtio_child_attach_finish(vsc, sc->sc_vq, __arraycount(sc->sc_vq),
- viomb_config_change, virtio_vq_intr, 0) != 0)
+ viomb_config_change, 0) != 0)
goto err_out;
if (kthread_create(PRI_IDLE, KTHREAD_MPSAFE, NULL,
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/viornd.c
--- a/sys/dev/pci/viornd.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/viornd.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: viornd.c,v 1.19 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: viornd.c,v 1.20 2023/03/23 03:55:11 yamaguchi Exp $ */
/* $OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $ */
/*
@@ -179,7 +179,9 @@
virtio_child_attach_start(vsc, self, IPL_NET,
0, VIRTIO_COMMON_FLAG_BITS);
- error = virtio_alloc_vq(vsc, &sc->sc_vq, 0, VIORND_BUFSIZE, 1,
+ virtio_init_vq_vqdone(vsc, &sc->sc_vq, 0, viornd_vq_done);
+
+ error = virtio_alloc_vq(vsc, &sc->sc_vq, VIORND_BUFSIZE, 1,
"Entropy request");
if (error) {
aprint_error_dev(sc->sc_dev, "can't alloc virtqueue: %d\n",
@@ -189,7 +191,7 @@
sc->sc_vq.vq_done = viornd_vq_done;
error = virtio_child_attach_finish(vsc, &sc->sc_vq, 1,
- NULL, virtio_vq_intr, 0);
+ NULL, 0);
if (error) {
virtio_free_vq(vsc, &sc->sc_vq);
goto vio_failed;
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/vioscsi.c
--- a/sys/dev/pci/vioscsi.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/vioscsi.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vioscsi.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: vioscsi.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $ */
/* $OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $ */
/*
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.31 2023/03/23 03:27:48 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.32 2023/03/23 03:55:11 yamaguchi Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -148,7 +148,9 @@
sc->sc_seg_max = seg_max;
for(i=0; i < __arraycount(sc->sc_vqs); i++) {
- rv = virtio_alloc_vq(vsc, &sc->sc_vqs[i], i, MAXPHYS,
+ virtio_init_vq_vqdone(vsc, &sc->sc_vqs[i], i,
+ vioscsi_vq_done);
+ rv = virtio_alloc_vq(vsc, &sc->sc_vqs[i], MAXPHYS,
VIRTIO_SCSI_MIN_SEGMENTS + howmany(MAXPHYS, NBPG),
vioscsi_vq_names[i]);
if (rv) {
@@ -161,7 +163,6 @@
sc->sc_vqs[i].vq_done = vioscsi_vq_done;
}
- qsize = sc->sc_vqs[VIOSCSI_VQ_REQUEST].vq_num;
if (vioscsi_alloc_reqs(sc, vsc, qsize))
goto err;
@@ -171,8 +172,7 @@
cmd_per_lun, qsize, seg_max, max_target, max_lun);
if (virtio_child_attach_finish(vsc, sc->sc_vqs,
- __arraycount(sc->sc_vqs), NULL, virtio_vq_intr,
- VIRTIO_F_INTR_MSIX) != 0)
+ __arraycount(sc->sc_vqs), NULL, VIRTIO_F_INTR_MSIX) != 0)
goto err;
/*
diff -r 6301f20f96e4 -r 0f2dcd939bb3 sys/dev/pci/virtio.c
--- a/sys/dev/pci/virtio.c Thu Mar 23 03:44:28 2023 +0000
+++ b/sys/dev/pci/virtio.c Thu Mar 23 03:55:11 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio.c,v 1.66 2023/03/23 03:27:48 yamaguchi Exp $ */
+/* $NetBSD: virtio.c,v 1.67 2023/03/23 03:55:11 yamaguchi Exp $ */
/*
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
*/
Home |
Main Index |
Thread Index |
Old Index