All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>
Cc: Alexander Graf <agraf@suse.de>,
	Farhan Ali <alifm@linux.vnet.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>,
	Alexey Kardashevskiy <aik@ozlabs.ru>
Subject: [Qemu-devel] [PATCH v3 06/10] pc-bios/s390-ccw: Add code for virtio feature negotiation
Date: Mon, 10 Jul 2017 17:32:36 +0200	[thread overview]
Message-ID: <1499700760-4777-7-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1499700760-4777-1-git-send-email-thuth@redhat.com>

The upcoming virtio-net driver needs to negotiate some features,
so we need the possibility to do this in the core virtio code.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 pc-bios/s390-ccw/s390-ccw.h      |  2 ++
 pc-bios/s390-ccw/virtio-blkdev.c |  3 ++-
 pc-bios/s390-ccw/virtio.c        | 25 ++++++++++++++++++-------
 pc-bios/s390-ccw/virtio.h        |  2 +-
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
index 6fdc858..25d4d21 100644
--- a/pc-bios/s390-ccw/s390-ccw.h
+++ b/pc-bios/s390-ccw/s390-ccw.h
@@ -44,6 +44,8 @@ typedef unsigned long long __u64;
                             ((b) == 0 ? (a) : (MIN(a, b))))
 #endif
 
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
 #include "cio.h"
 #include "iplb.h"
 
diff --git a/pc-bios/s390-ccw/virtio-blkdev.c b/pc-bios/s390-ccw/virtio-blkdev.c
index 6cb77bc..ed4026f 100644
--- a/pc-bios/s390-ccw/virtio-blkdev.c
+++ b/pc-bios/s390-ccw/virtio-blkdev.c
@@ -266,9 +266,10 @@ uint64_t virtio_get_blocks(void)
 void virtio_blk_setup_device(SubChannelId schid)
 {
     VDev *vdev = virtio_get_device();
+    uint32_t guestfeats[2] = { 0, 0 };
 
     vdev->schid = schid;
-    virtio_setup_ccw(vdev);
+    virtio_setup_ccw(vdev, guestfeats);
 
     switch (vdev->senseid.cu_model) {
     case VIRTIO_ID_BLOCK:
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 09ab291..e3dcfd3 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -12,6 +12,7 @@
 #include "s390-ccw.h"
 #include "virtio.h"
 #include "virtio-scsi.h"
+#include "bswap.h"
 
 #define VRING_WAIT_REPLY_TIMEOUT 3
 
@@ -247,10 +248,14 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)
     return 0;
 }
 
-void virtio_setup_ccw(VDev *vdev)
+void virtio_setup_ccw(VDev *vdev, uint32_t guestfeats[2])
 {
-    int i, cfg_size = 0;
+    int i, rc, cfg_size = 0;
     unsigned char status = VIRTIO_CONFIG_S_DRIVER_OK;
+    struct VirtioFeatureDesc {
+        uint32_t features;
+        uint8_t index;
+    } __attribute__((packed)) feats;
 
     IPL_assert(virtio_is_supported(vdev->schid), "PE");
     /* device ID has been established now */
@@ -277,11 +282,17 @@ void virtio_setup_ccw(VDev *vdev)
     IPL_assert(run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size) == 0,
                "Could not get block device configuration");
 
-    /*
-     * Skipping CCW_CMD_READ_FEAT. We're not doing anything fancy, and
-     * we'll just stop dead anyway if anything does not work like we
-     * expect it.
-     */
+    /* Feature negotiation */
+    for (i = 0; i < ARRAY_SIZE(guestfeats); i++) {
+        feats.features = 0;
+        feats.index = i;
+        rc = run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats));
+        IPL_assert(rc == 0, "Could not get features bits");
+        guestfeats[i] &= bswap32(feats.features);
+        feats.features = bswap32(guestfeats[i]);
+        rc = run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats));
+        IPL_assert(rc == 0, "Could not set features bits");
+    }
 
     for (i = 0; i < vdev->nr_vqs; i++) {
         VqInfo info = {
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index d743919..e3d7150 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -295,6 +295,6 @@ int drain_irqs(SubChannelId schid);
 void vring_send_buf(VRing *vr, void *p, int len, int flags);
 int vring_wait_reply(void);
 int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd);
-void virtio_setup_ccw(VDev *vdev);
+void virtio_setup_ccw(VDev *vdev, uint32_t guestfeats[2]);
 
 #endif /* VIRTIO_H */
-- 
1.8.3.1

  parent reply	other threads:[~2017-07-10 15:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 15:32 [Qemu-devel] [PATCH v3 00/10] Implement network booting directly into the s390-ccw BIOS Thomas Huth
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 01/10] pc-bios/s390-ccw: Move libc functions to separate header Thomas Huth
2017-07-11  7:49   ` Cornelia Huck
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 02/10] pc-bios/s390-ccw: Move ebc2asc to sclp.c Thomas Huth
2017-07-11  9:43   ` David Hildenbrand
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 03/10] pc-bios/s390-ccw: Move virtio-block related functions into a separate file Thomas Huth
2017-07-11  7:53   ` Cornelia Huck
2017-07-11  9:45   ` David Hildenbrand
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 04/10] pc-bios/s390-ccw: Add a write() function for stdio Thomas Huth
2017-07-11  9:47   ` David Hildenbrand
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 05/10] pc-bios/s390-ccw: Move byteswap functions to a separate header Thomas Huth
2017-07-11  7:39   ` Christian Borntraeger
2017-07-11  7:59   ` Cornelia Huck
2017-07-11  8:52     ` Thomas Huth
2017-07-11  9:05       ` Cornelia Huck
2017-07-10 15:32 ` Thomas Huth [this message]
2017-07-11  8:47   ` [Qemu-devel] [PATCH v3 06/10] pc-bios/s390-ccw: Add code for virtio feature negotiation Cornelia Huck
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 07/10] roms/SLOF: Update submodule to latest status Thomas Huth
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 08/10] pc-bios/s390-ccw: Add core files for the network bootloading program Thomas Huth
2017-07-11  8:52   ` Cornelia Huck
2017-07-11 13:30     ` Thomas Huth
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 09/10] pc-bios/s390-ccw: Add virtio-net driver code Thomas Huth
2017-07-11  8:57   ` Cornelia Huck
2017-07-10 15:32 ` [Qemu-devel] [PATCH v3 10/10] pc-bios/s390-ccw: Link libnet into the netboot image and do the TFTP load Thomas Huth
2017-07-11  9:01   ` Cornelia Huck
2017-07-11  7:46 ` [Qemu-devel] [PATCH v3 00/10] Implement network booting directly into the s390-ccw BIOS Christian Borntraeger
2017-07-11 13:37 ` no-reply
2017-07-11 14:04 ` no-reply

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=1499700760-4777-7-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=alifm@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=mihajlov@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.