From nobody Sun Feb 8 14:52:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149986423107259.855452255201385; Wed, 12 Jul 2017 05:57:11 -0700 (PDT) Received: from localhost ([::1]:52607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVHCW-0005cy-Oz for importer@patchew.org; Wed, 12 Jul 2017 08:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVH6S-0000Ly-T7 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVH6R-0004y9-U3 for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVH6R-0004xW-KN for qemu-devel@nongnu.org; Wed, 12 Jul 2017 08:50:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79DE180E72; Wed, 12 Jul 2017 12:50:50 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-62.ams2.redhat.com [10.36.117.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D8585D9CB; Wed, 12 Jul 2017 12:50:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79DE180E72 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 79DE180E72 From: Thomas Huth To: qemu-devel@nongnu.org, Christian Borntraeger , Cornelia Huck Date: Wed, 12 Jul 2017 14:49:49 +0200 Message-Id: <1499863793-18627-8-git-send-email-thuth@redhat.com> In-Reply-To: <1499863793-18627-1-git-send-email-thuth@redhat.com> References: <1499863793-18627-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 12 Jul 2017 12:50:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 07/11] pc-bios/s390-ccw: Add code for virtio feature negotiation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Mihajlovski , Farhan Ali , Alexander Graf , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Thomas Huth --- 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) =3D=3D 0 ? (a) : (MIN(a, b)))) #endif =20 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + #include "cio.h" #include "iplb.h" =20 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" =20 #define VRING_WAIT_REPLY_TIMEOUT 3 =20 @@ -249,8 +250,12 @@ int virtio_run(VDev *vdev, int vqid, VirtioCmd *cmd) =20 void virtio_setup_ccw(VDev *vdev) { - int i, cfg_size =3D 0; + int i, rc, cfg_size =3D 0; unsigned char status =3D VIRTIO_CONFIG_S_DRIVER_OK; + struct VirtioFeatureDesc { + uint32_t features; + uint8_t index; + } __attribute__((packed)) feats; =20 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) = =3D=3D 0, "Could not get block device configuration"); =20 - /* - * 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 =3D 0; i < ARRAY_SIZE(vdev->guest_features); i++) { + feats.features =3D 0; + feats.index =3D i; + rc =3D run_ccw(vdev, CCW_CMD_READ_FEAT, &feats, sizeof(feats)); + IPL_assert(rc =3D=3D 0, "Could not get features bits"); + vdev->guest_features[i] &=3D bswap32(feats.features); + feats.features =3D bswap32(vdev->guest_features[i]); + rc =3D run_ccw(vdev, CCW_CMD_WRITE_FEAT, &feats, sizeof(feats)); + IPL_assert(rc =3D=3D 0, "Could not set features bits"); + } =20 for (i =3D 0; i < vdev->nr_vqs; i++) { VqInfo info =3D { 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; =20 --=20 1.8.3.1