From patchwork Mon Jan 15 06:32:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10163161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10882601C0 for ; Mon, 15 Jan 2018 06:35:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5A65286A8 for ; Mon, 15 Jan 2018 06:35:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D61EB28926; Mon, 15 Jan 2018 06:35:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DB8E286A8 for ; Mon, 15 Jan 2018 06:35:28 +0000 (UTC) Received: from localhost ([::1]:41113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayMi-0001AH-7X for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Jan 2018 01:35:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eayKQ-0007mQ-LP for qemu-devel@nongnu.org; Mon, 15 Jan 2018 01:33:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eayKP-0006q7-Qb for qemu-devel@nongnu.org; Mon, 15 Jan 2018 01:33:06 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:43535) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eayKN-0006nV-FP; Mon, 15 Jan 2018 01:33:03 -0500 Received: by mail-pg0-x243.google.com with SMTP id f14so7499462pga.10; Sun, 14 Jan 2018 22:33:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iGUbhPCAMWHjnmrrQbsjO3fODSRLLO/U9kz2waRD9sM=; b=IvQY7/tSTuvcxSVYK7wNYKqkuyjreOfE32rDjJhs4IiTRfE+JOjNhbzVF84w/2STz5 GeNITRoUyyV4TOTAxIoZxGuJ29WetqgyqOwF7I7Hdp9taXOdPg15vcwcP18XOtqqL+3X ZSLtDEb4FhQaerZLBPIfNa5PklxcTeNgt+gGGhBuXSABFywJaOKstftKnFLzGB/MBphH ESwhc+/TtKffO2tXPK4YMWQGPVzXOoVFoeQ7aQiIDsziub4DfLsm1bYTdH8O+1FFSPYe U/wSITHLKlAiQIoSlOAOlqiNoR+oH5y7tJvBfs1EYxAR758webBOds5S6sqO+aBBNaOl 3WeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iGUbhPCAMWHjnmrrQbsjO3fODSRLLO/U9kz2waRD9sM=; b=PYWAcze61R3OeKlGiMdpun18aAErD9pXS+2oVkIVUovEpYIBxrrVbisdQaUOuGCYjY RQt7ViGMPvQtS5OH3Ip+sqmyW3M6Sxpmfn6zD0/qwEpk+riikwmQkgKZjH0gomdYNT0R F59n1ayS53ZY+Bbac5rQdwUpE44uepsRoO8phfYMD0OSdHHzsplvppB3zEJU6ed04AU2 bQLBwIYrleRmfAAqurtOFFoGwq6INwkxMEUzqATc/e6BSSi2BNk2vdfL1A34MTqLV8KO DFtgaG33W3ejTyVREeW/+hdi0ZvHZvatjvVF3UvJh4Nw8/uKnuOynXtxUyV0coVazMT9 xXnQ== X-Gm-Message-State: AKGB3mLZ4+0k/Lq6XLNTKV34C2q21kxR4thVDy9e99zPK4RlY5ak8DH/ WShZ1qtVha4y9K/Gw7cjYhkKoVuT X-Google-Smtp-Source: ACJfBosjpWZSSqxZccWOQcVEENchT4lfeDVLGopSaHcT0utvxp+FTuHzXhbd4i3DoGNBsZt7ByTvyA== X-Received: by 10.101.93.79 with SMTP id e15mr18649742pgt.129.1515997982399; Sun, 14 Jan 2018 22:33:02 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 13sm62362864pfs.112.2018.01.14.22.32.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jan 2018 22:33:01 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Mon, 15 Jan 2018 17:32:31 +1100 Message-Id: <20180115063235.7518-3-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180115063235.7518-1-sjitindarsingh@gmail.com> References: <20180115063235.7518-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V3 2/6] target/ppc/spapr_caps: Add support for tristate spapr_capabilities 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: paulus@ozlabs.org, qemu-devel@nongnu.org, sjitindarsingh@gmail.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP spapr_caps are used to represent the level of support for various capabilities related to the spapr machine type. Currently there is only support for boolean capabilities. Add support for tristate capabilities by implementing their get/set functions. These capabilities can have the values 0, 1 or 2 corresponding to broken, workaround and fixed. Signed-off-by: Suraj Jitindar Singh --- hw/ppc/spapr_caps.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 4 ++++ 2 files changed, 64 insertions(+) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index d5c9ce774a..436250d77b 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -73,6 +73,66 @@ static void spapr_cap_set_bool(Object *obj, Visitor *v, const char *name, spapr->eff.caps[cap->index] = value ? SPAPR_CAP_ON : SPAPR_CAP_OFF; } +static void spapr_cap_get_tristate(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + sPAPRCapabilityInfo *cap = opaque; + sPAPRMachineState *spapr = SPAPR_MACHINE(obj); + char *val = NULL; + uint8_t value = spapr_get_cap(spapr, cap->index); + + switch (value) { + case SPAPR_CAP_BROKEN: + val = g_strdup("broken"); + break; + case SPAPR_CAP_WORKAROUND: + val = g_strdup("workaround"); + break; + case SPAPR_CAP_FIXED: + val = g_strdup("fixed"); + break; + default: + error_setg(errp, "Invalid value (%d) for cap-%s", value, cap->name); + return; + } + + visit_type_str(v, name, &val, errp); + g_free(val); +} + +static void spapr_cap_set_tristate(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + sPAPRCapabilityInfo *cap = opaque; + sPAPRMachineState *spapr = SPAPR_MACHINE(obj); + char *val; + Error *local_err = NULL; + uint8_t value; + + visit_type_str(v, name, &val, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + if (!strcasecmp(val, "broken")) { + value = SPAPR_CAP_BROKEN; + } else if (!strcasecmp(val, "workaround")) { + value = SPAPR_CAP_WORKAROUND; + } else if (!strcasecmp(val, "fixed")) { + value = SPAPR_CAP_FIXED; + } else { + error_setg(errp, "Invalid capability mode \"%s\" for cap-%s", val, + cap->name); + goto out; + } + + spapr->cmd_line_caps[cap->index] = true; + spapr->eff.caps[cap->index] = value; +out: + g_free(val); +} + static void cap_htm_apply(sPAPRMachineState *spapr, uint8_t val, Error **errp) { if (!val) { diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index eded0ea57d..61bb3632c4 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -69,6 +69,10 @@ typedef enum { /* Bool Caps */ #define SPAPR_CAP_OFF 0x00 #define SPAPR_CAP_ON 0x01 +/* Broken | Workaround | Fixed Caps */ +#define SPAPR_CAP_BROKEN 0x00 +#define SPAPR_CAP_WORKAROUND 0x01 +#define SPAPR_CAP_FIXED 0x02 typedef struct sPAPRCapabilities sPAPRCapabilities; struct sPAPRCapabilities {