From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Nir Soffer <nsoffer@redhat.com>, qemu-stable@nongnu.org
Subject: Re: [PATCH 6/6] virtio-scsi: move request-related items from .h to .c
Date: Fri, 29 Apr 2022 01:17:45 +0200 [thread overview]
Message-ID: <5690cb69-4220-68ea-0d26-24347e62d5ae@redhat.com> (raw)
In-Reply-To: <20220427143541.119567-7-stefanha@redhat.com>
On 4/27/22 16:35, Stefan Hajnoczi wrote:
> There is no longer a need to expose the request and related APIs in
> virtio-scsi.h since there are no callers outside virtio-scsi.c.
>
> Note the block comment in VirtIOSCSIReq has been adjusted to meet the
> coding style.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> include/hw/virtio/virtio-scsi.h | 40 -----------------------------
> hw/scsi/virtio-scsi.c | 45 ++++++++++++++++++++++++++++++---
> 2 files changed, 41 insertions(+), 44 deletions(-)
>
> diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
> index 2497530064..abdda2cbd0 100644
> --- a/include/hw/virtio/virtio-scsi.h
> +++ b/include/hw/virtio/virtio-scsi.h
> @@ -94,42 +94,6 @@ struct VirtIOSCSI {
> uint32_t host_features;
> };
>
> -typedef struct VirtIOSCSIReq {
> - /* Note:
> - * - fields up to resp_iov are initialized by virtio_scsi_init_req;
> - * - fields starting at vring are zeroed by virtio_scsi_init_req.
> - * */
> - VirtQueueElement elem;
> -
> - VirtIOSCSI *dev;
> - VirtQueue *vq;
> - QEMUSGList qsgl;
> - QEMUIOVector resp_iov;
> -
> - union {
> - /* Used for two-stage request submission */
> - QTAILQ_ENTRY(VirtIOSCSIReq) next;
> -
> - /* Used for cancellation of request during TMFs */
> - int remaining;
> - };
> -
> - SCSIRequest *sreq;
> - size_t resp_size;
> - enum SCSIXferMode mode;
> - union {
> - VirtIOSCSICmdResp cmd;
> - VirtIOSCSICtrlTMFResp tmf;
> - VirtIOSCSICtrlANResp an;
> - VirtIOSCSIEvent event;
> - } resp;
> - union {
> - VirtIOSCSICmdReq cmd;
> - VirtIOSCSICtrlTMFReq tmf;
> - VirtIOSCSICtrlANReq an;
> - } req;
> -} VirtIOSCSIReq;
> -
> static inline void virtio_scsi_acquire(VirtIOSCSI *s)
> {
> if (s->ctx) {
> @@ -151,10 +115,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
> Error **errp);
>
> void virtio_scsi_common_unrealize(DeviceState *dev);
> -void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
> -void virtio_scsi_free_req(VirtIOSCSIReq *req);
> -void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
> - uint32_t event, uint32_t reason);
>
> void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp);
> int virtio_scsi_dataplane_start(VirtIODevice *s);
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 12c6a21202..db54d104be 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -29,6 +29,43 @@
> #include "hw/virtio/virtio-access.h"
> #include "trace.h"
>
> +typedef struct VirtIOSCSIReq {
> + /*
> + * Note:
> + * - fields up to resp_iov are initialized by virtio_scsi_init_req;
> + * - fields starting at vring are zeroed by virtio_scsi_init_req.
> + */
> + VirtQueueElement elem;
> +
> + VirtIOSCSI *dev;
> + VirtQueue *vq;
> + QEMUSGList qsgl;
> + QEMUIOVector resp_iov;
> +
> + union {
> + /* Used for two-stage request submission */
> + QTAILQ_ENTRY(VirtIOSCSIReq) next;
> +
> + /* Used for cancellation of request during TMFs */
> + int remaining;
> + };
> +
> + SCSIRequest *sreq;
> + size_t resp_size;
> + enum SCSIXferMode mode;
> + union {
> + VirtIOSCSICmdResp cmd;
> + VirtIOSCSICtrlTMFResp tmf;
> + VirtIOSCSICtrlANResp an;
> + VirtIOSCSIEvent event;
> + } resp;
> + union {
> + VirtIOSCSICmdReq cmd;
> + VirtIOSCSICtrlTMFReq tmf;
> + VirtIOSCSICtrlANReq an;
> + } req;
> +} VirtIOSCSIReq;
> +
> static inline int virtio_scsi_get_lun(uint8_t *lun)
> {
> return ((lun[2] << 8) | lun[3]) & 0x3FFF;
> @@ -45,7 +82,7 @@ static inline SCSIDevice *virtio_scsi_device_get(VirtIOSCSI *s, uint8_t *lun)
> return scsi_device_get(&s->bus, 0, lun[1], virtio_scsi_get_lun(lun));
> }
>
> -void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
> +static void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
> {
> VirtIODevice *vdev = VIRTIO_DEVICE(s);
> const size_t zero_skip =
> @@ -58,7 +95,7 @@ void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
> memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
> }
>
> -void virtio_scsi_free_req(VirtIOSCSIReq *req)
> +static void virtio_scsi_free_req(VirtIOSCSIReq *req)
> {
> qemu_iovec_destroy(&req->resp_iov);
> qemu_sglist_destroy(&req->qsgl);
> @@ -801,8 +838,8 @@ static void virtio_scsi_reset(VirtIODevice *vdev)
> s->events_dropped = false;
> }
>
> -void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
> - uint32_t event, uint32_t reason)
> +static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
> + uint32_t event, uint32_t reason)
> {
> VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
> VirtIOSCSIReq *req;
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2022-04-28 23:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 14:35 [PATCH 0/6] virtio-scsi: fix 100% CPU consumption in IOThread Stefan Hajnoczi
2022-04-27 14:35 ` [PATCH 1/6] virtio-scsi: fix ctrl and event handler functions in dataplane mode Stefan Hajnoczi
2022-04-27 19:47 ` Michael Tokarev
2022-04-28 9:05 ` Stefan Hajnoczi
2022-04-28 23:18 ` Paolo Bonzini
2022-04-27 14:35 ` [PATCH 2/6] virtio-scsi: don't waste CPU polling the event virtqueue Stefan Hajnoczi
2022-04-27 20:12 ` Nir Soffer
2022-04-28 9:05 ` Stefan Hajnoczi
2022-04-28 23:17 ` Paolo Bonzini
2022-04-30 5:52 ` Stefan Hajnoczi
2022-04-27 14:35 ` [PATCH 3/6] virtio-scsi: clean up virtio_scsi_handle_event_vq() Stefan Hajnoczi
2022-04-28 23:17 ` Paolo Bonzini
2022-04-27 14:35 ` [PATCH 4/6] virtio-scsi: clean up virtio_scsi_handle_ctrl_vq() Stefan Hajnoczi
2022-04-28 23:17 ` Paolo Bonzini
2022-04-27 14:35 ` [PATCH 5/6] virtio-scsi: clean up virtio_scsi_handle_cmd_vq() Stefan Hajnoczi
2022-04-28 23:17 ` Paolo Bonzini
2022-04-27 14:35 ` [PATCH 6/6] virtio-scsi: move request-related items from .h to .c Stefan Hajnoczi
2022-04-28 23:17 ` Paolo Bonzini [this message]
2022-05-09 9:45 ` [PATCH 0/6] virtio-scsi: fix 100% CPU consumption in IOThread Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5690cb69-4220-68ea-0d26-24347e62d5ae@redhat.com \
--to=pbonzini@redhat.com \
--cc=nsoffer@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).