[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 24/40] pc-bios/s390-ccw: Add code for virtio feature
From: |
Christian Borntraeger |
Subject: |
[Qemu-devel] [PULL 24/40] pc-bios/s390-ccw: Add code for virtio feature negotiation |
Date: |
Fri, 14 Jul 2017 12:40:51 +0200 |
From: Thomas Huth <address@hidden>
The upcoming virtio-net driver needs to negotiate some features,
so we need the possibility to do this in the core virtio code.
Reviewed-by: Cornelia Huck <address@hidden>
Signed-off-by: Thomas Huth <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Christian Borntraeger <address@hidden>
---
pc-bios/s390-ccw/s390-ccw.h | 2 ++
pc-bios/s390-ccw/virtio.c | 23 +++++++++++++++++------
pc-bios/s390-ccw/virtio.h | 1 +
3 files changed, 20 insertions(+), 6 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.c b/pc-bios/s390-ccw/virtio.c
index 9d9e61f..18fc5d1 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
@@ -249,8 +250,12 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd)
void virtio_setup_ccw(VDev *vdev)
{
- 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(vdev->guest_features); 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");
+ vdev->guest_features[i] &= bswap32(feats.features);
+ feats.features = bswap32(vdev->guest_features[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 d733780..a00a320 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -251,6 +251,7 @@ struct VDev {
ScsiDevice selected_scsi_device;
uint64_t netboot_start_addr;
uint32_t max_transfer;
+ uint32_t guest_features[2];
};
typedef struct VDev VDev;
--
2.7.4
- [Qemu-devel] [PULL 30/40] pc-bios/s390: rebuild s390-ccw.img, (continued)
- [Qemu-devel] [PULL 30/40] pc-bios/s390: rebuild s390-ccw.img, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 13/40] s390x: add css_migration_enabled to machine class, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 09/40] s390x/flic: introduce inject_airq callback, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 11/40] s390x/css: update css_adapter_interrupt, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 08/40] s390x/flic: introduce modify_ais_mode callback, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 21/40] pc-bios/s390-ccw: Add a write() function for stdio, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 32/40] s390x/cpumodel: add zpci, aen and ais facilities, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 24/40] pc-bios/s390-ccw: Add code for virtio feature negotiation,
Christian Borntraeger <=
- [Qemu-devel] [PULL 31/40] s390x: initialize cpu firstly, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 16/40] s390x/css: activate ChannelSubSys migration, Christian Borntraeger, 2017/07/14
- [Qemu-devel] [PULL 34/40] s390x/cpumodel: wire up new hardware features, Christian Borntraeger, 2017/07/14
[Qemu-devel] [PULL 33/40] s390x/flic: migrate ais states, Christian Borntraeger, 2017/07/14
[Qemu-devel] [PULL 04/40] s390x/migration: Monitor commands for storage attributes, Christian Borntraeger, 2017/07/14
[Qemu-devel] [PULL 12/40] s390x: add helper get_machine_class, Christian Borntraeger, 2017/07/14
[Qemu-devel] [PULL 10/40] s390x/sic: realize SIC handling, Christian Borntraeger, 2017/07/14