|
|
4a2fec |
From ea039b07c94712a8ffb92b0a6e515f7c354d2219 Mon Sep 17 00:00:00 2001
|
|
|
4a2fec |
From: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
4a2fec |
Date: Tue, 13 Feb 2018 04:12:24 +0100
|
|
|
4a2fec |
Subject: [PATCH 07/15] target/ppc/spapr_caps: Add support for tristate
|
|
|
4a2fec |
spapr_capabilities
|
|
|
4a2fec |
|
|
|
4a2fec |
RH-Author: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
4a2fec |
Message-id: <1518495150-24134-4-git-send-email-sursingh@redhat.com>
|
|
|
4a2fec |
Patchwork-id: 78991
|
|
|
4a2fec |
O-Subject: [RHEL7.5 qemu-kvm-rhev PATCH 3/9] target/ppc/spapr_caps: Add support for tristate spapr_capabilities
|
|
|
4a2fec |
Bugzilla: 1532050
|
|
|
4a2fec |
RH-Acked-by: David Gibson <dgibson@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
4a2fec |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
|
|
|
4a2fec |
|
|
|
4a2fec |
spapr_caps are used to represent the level of support for various
|
|
|
4a2fec |
capabilities related to the spapr machine type. Currently there is
|
|
|
4a2fec |
only support for boolean capabilities.
|
|
|
4a2fec |
|
|
|
4a2fec |
Add support for tristate capabilities by implementing their get/set
|
|
|
4a2fec |
functions. These capabilities can have the values 0, 1 or 2
|
|
|
4a2fec |
corresponding to broken, workaround and fixed.
|
|
|
4a2fec |
|
|
|
4a2fec |
Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
|
|
|
4a2fec |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
4a2fec |
(cherry picked from commit 6898aed77f4636c3e77af9c12631f583f22cb5db)
|
|
|
4a2fec |
|
|
|
4a2fec |
Conflicts: none
|
|
|
4a2fec |
|
|
|
4a2fec |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1532050
|
|
|
4a2fec |
|
|
|
4a2fec |
Signed-off-by: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
4a2fec |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
4a2fec |
---
|
|
|
4a2fec |
hw/ppc/spapr_caps.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
4a2fec |
include/hw/ppc/spapr.h | 4 +++
|
|
|
4a2fec |
2 files changed, 70 insertions(+)
|
|
|
4a2fec |
|
|
|
4a2fec |
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
|
|
|
4a2fec |
index 5d52969..d6f82b1 100644
|
|
|
4a2fec |
--- a/hw/ppc/spapr_caps.c
|
|
|
4a2fec |
+++ b/hw/ppc/spapr_caps.c
|
|
|
4a2fec |
@@ -73,6 +73,72 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name,
|
|
|
4a2fec |
spapr->eff.caps[cap->index] = value ? SPAPR_CAP_ON : SPAPR_CAP_OFF;
|
|
|
4a2fec |
}
|
|
|
4a2fec |
|
|
|
4a2fec |
+static void __attribute__ ((unused)) spapr_cap_get_tristate(Object *obj,
|
|
|
4a2fec |
+ Visitor *v,
|
|
|
4a2fec |
+ const char *name,
|
|
|
4a2fec |
+ void *opaque,
|
|
|
4a2fec |
+ Error **errp)
|
|
|
4a2fec |
+{
|
|
|
4a2fec |
+ sPAPRCapabilityInfo *cap = opaque;
|
|
|
4a2fec |
+ sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
|
|
|
4a2fec |
+ char *val = NULL;
|
|
|
4a2fec |
+ uint8_t value = spapr_get_cap(spapr, cap->index);
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+ switch (value) {
|
|
|
4a2fec |
+ case SPAPR_CAP_BROKEN:
|
|
|
4a2fec |
+ val = g_strdup("broken");
|
|
|
4a2fec |
+ break;
|
|
|
4a2fec |
+ case SPAPR_CAP_WORKAROUND:
|
|
|
4a2fec |
+ val = g_strdup("workaround");
|
|
|
4a2fec |
+ break;
|
|
|
4a2fec |
+ case SPAPR_CAP_FIXED:
|
|
|
4a2fec |
+ val = g_strdup("fixed");
|
|
|
4a2fec |
+ break;
|
|
|
4a2fec |
+ default:
|
|
|
4a2fec |
+ error_setg(errp, "Invalid value (%d) for cap-%s", value, cap->name);
|
|
|
4a2fec |
+ return;
|
|
|
4a2fec |
+ }
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+ visit_type_str(v, name, &val, errp);
|
|
|
4a2fec |
+ g_free(val);
|
|
|
4a2fec |
+}
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+static void __attribute__ ((unused)) spapr_cap_set_tristate(Object *obj,
|
|
|
4a2fec |
+ Visitor *v,
|
|
|
4a2fec |
+ const char *name,
|
|
|
4a2fec |
+ void *opaque,
|
|
|
4a2fec |
+ Error **errp)
|
|
|
4a2fec |
+{
|
|
|
4a2fec |
+ sPAPRCapabilityInfo *cap = opaque;
|
|
|
4a2fec |
+ sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
|
|
|
4a2fec |
+ char *val;
|
|
|
4a2fec |
+ Error *local_err = NULL;
|
|
|
4a2fec |
+ uint8_t value;
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+ visit_type_str(v, name, &val, &local_err);
|
|
|
4a2fec |
+ if (local_err) {
|
|
|
4a2fec |
+ error_propagate(errp, local_err);
|
|
|
4a2fec |
+ return;
|
|
|
4a2fec |
+ }
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+ if (!strcasecmp(val, "broken")) {
|
|
|
4a2fec |
+ value = SPAPR_CAP_BROKEN;
|
|
|
4a2fec |
+ } else if (!strcasecmp(val, "workaround")) {
|
|
|
4a2fec |
+ value = SPAPR_CAP_WORKAROUND;
|
|
|
4a2fec |
+ } else if (!strcasecmp(val, "fixed")) {
|
|
|
4a2fec |
+ value = SPAPR_CAP_FIXED;
|
|
|
4a2fec |
+ } else {
|
|
|
4a2fec |
+ error_setg(errp, "Invalid capability mode \"%s\" for cap-%s", val,
|
|
|
4a2fec |
+ cap->name);
|
|
|
4a2fec |
+ goto out;
|
|
|
4a2fec |
+ }
|
|
|
4a2fec |
+
|
|
|
4a2fec |
+ spapr->cmd_line_caps[cap->index] = true;
|
|
|
4a2fec |
+ spapr->eff.caps[cap->index] = value;
|
|
|
4a2fec |
+out:
|
|
|
4a2fec |
+ g_free(val);
|
|
|
4a2fec |
+}
|
|
|
4a2fec |
+
|
|
|
4a2fec |
static void cap_htm_apply(sPAPRMachineState *spapr, uint8_t val, Error **errp)
|
|
|
4a2fec |
{
|
|
|
4a2fec |
if (!val) {
|
|
|
4a2fec |
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
|
|
|
4a2fec |
index 6090f3d..abe0011 100644
|
|
|
4a2fec |
--- a/include/hw/ppc/spapr.h
|
|
|
4a2fec |
+++ b/include/hw/ppc/spapr.h
|
|
|
4a2fec |
@@ -69,6 +69,10 @@ typedef enum {
|
|
|
4a2fec |
/* Bool Caps */
|
|
|
4a2fec |
#define SPAPR_CAP_OFF 0x00
|
|
|
4a2fec |
#define SPAPR_CAP_ON 0x01
|
|
|
4a2fec |
+/* Broken | Workaround | Fixed Caps */
|
|
|
4a2fec |
+#define SPAPR_CAP_BROKEN 0x00
|
|
|
4a2fec |
+#define SPAPR_CAP_WORKAROUND 0x01
|
|
|
4a2fec |
+#define SPAPR_CAP_FIXED 0x02
|
|
|
4a2fec |
|
|
|
4a2fec |
typedef struct sPAPRCapabilities sPAPRCapabilities;
|
|
|
4a2fec |
struct sPAPRCapabilities {
|
|
|
4a2fec |
--
|
|
|
4a2fec |
1.8.3.1
|
|
|
4a2fec |
|