mirror of https://github.com/proxmox/mirror_qemu
pc-bios/s390-ccw: Add code for virtio feature negotiation
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 <cohuck@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1499863793-18627-8-git-send-email-thuth@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>master
parent
ac7bec7cf9
commit
59efbff1cb
|
@ -44,6 +44,8 @@ typedef unsigned long long __u64;
|
||||||
((b) == 0 ? (a) : (MIN(a, b))))
|
((b) == 0 ? (a) : (MIN(a, b))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
#include "cio.h"
|
#include "cio.h"
|
||||||
#include "iplb.h"
|
#include "iplb.h"
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "s390-ccw.h"
|
#include "s390-ccw.h"
|
||||||
#include "virtio.h"
|
#include "virtio.h"
|
||||||
#include "virtio-scsi.h"
|
#include "virtio-scsi.h"
|
||||||
|
#include "bswap.h"
|
||||||
|
|
||||||
#define VRING_WAIT_REPLY_TIMEOUT 3
|
#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)
|
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;
|
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");
|
IPL_assert(virtio_is_supported(vdev->schid), "PE");
|
||||||
/* device ID has been established now */
|
/* 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,
|
IPL_assert(run_ccw(vdev, CCW_CMD_READ_CONF, &vdev->config, cfg_size) == 0,
|
||||||
"Could not get block device configuration");
|
"Could not get block device configuration");
|
||||||
|
|
||||||
/*
|
/* Feature negotiation */
|
||||||
* Skipping CCW_CMD_READ_FEAT. We're not doing anything fancy, and
|
for (i = 0; i < ARRAY_SIZE(vdev->guest_features); i++) {
|
||||||
* we'll just stop dead anyway if anything does not work like we
|
feats.features = 0;
|
||||||
* expect it.
|
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++) {
|
for (i = 0; i < vdev->nr_vqs; i++) {
|
||||||
VqInfo info = {
|
VqInfo info = {
|
||||||
|
|
|
@ -251,6 +251,7 @@ struct VDev {
|
||||||
ScsiDevice selected_scsi_device;
|
ScsiDevice selected_scsi_device;
|
||||||
uint64_t netboot_start_addr;
|
uint64_t netboot_start_addr;
|
||||||
uint32_t max_transfer;
|
uint32_t max_transfer;
|
||||||
|
uint32_t guest_features[2];
|
||||||
};
|
};
|
||||||
typedef struct VDev VDev;
|
typedef struct VDev VDev;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue