From patchwork Fri Jan 19 05:00:01 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: 10174553 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 D3FA960386 for ; Fri, 19 Jan 2018 05:11:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C49C028575 for ; Fri, 19 Jan 2018 05:11:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5FD928583; Fri, 19 Jan 2018 05:11:10 +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 4658328575 for ; Fri, 19 Jan 2018 05:11:10 +0000 (UTC) Received: from localhost ([::1]:52675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOxJ-0008LZ-CL for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 00:11:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOn4-0007V9-Kv for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecOn3-0004rB-Kd for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:34 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35812) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecOmx-0004om-WC; Fri, 19 Jan 2018 00:00:28 -0500 Received: by mail-pf0-x242.google.com with SMTP id t12so545371pfg.2; Thu, 18 Jan 2018 21:00:27 -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=mEg+JNdllWDH9x7o5VO2+CjyvHIGVOgiOqa5LtLQzMA=; b=WJaeN3Qucl/8K1l3UiFx7eRm13CZiksmi37HLDXUCN/Za0VUKAZjN2UsTfhIWdoTLN P1psshPkIxcPtcwRa8unnzayOkd/fk7OyC+XMqtyZ8UyG00wI6CUSGdyFbaN9l1XnAko 4YXoAlTo0RXhxopWSFg0lmmV+9aLPHFdjAIIDeAOTeBn7X0PCKpBKxeRkk5IxQ/Sr2Gw h8IXt3tjNRRELrZxGE4oDWIziC+33yE/Y7WzXlFbey+hhGXqLv4jlv7hWesbTI6QQ5Hd p7Eq1IUwcWGH5pUebOogjuvUvyxMq4OGaSFk7H+r8b9sHnkmHq0amA+ITAt1ioAw8JOw WNDw== 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=mEg+JNdllWDH9x7o5VO2+CjyvHIGVOgiOqa5LtLQzMA=; b=pfRX1TtJBVb6+KWWmW55A2Mbgq+a3YC0bNtkn0k6BzsUOdJUn0IQ+T2Yiau2HSnWdt jYlOmWMe0FmvZ9kJYSREasWOp21a6kLFSHVui5Sw4aADBD6p15Zhd8vs6nq8Wu+BDKJd OJ+3wIlTMiauP3RIv3L6l54cnpOQzHkPeZs0GSr4fdoNBw2WrZO+X+0qLo0Rq3rHaCq9 3ZVgGyGeA6dgZzi96GFgF5YuxW0eGuMJfZ4eti33nVXt+H1sR+WrvF4Gp+JAX/kOOCU4 rWTa8qZTgDZfp5WZzo5EFJkgMqkFxnfQPGml9cRtn7Bl0RoTODZb66kAtNkZV441a4m8 pNLg== X-Gm-Message-State: AKwxytc08LuhCnFp8H7/D4lDQfQ5Sf3IxuWMzojbaUgFfvZc7soCtO9/ zLF3+/9WFR8exIO7JUD/2gpByvew X-Google-Smtp-Source: ACJfBotMpscWp6k1AXwpUuC01Jv1Xy8XcsHI+nwqSKaxbL14uWYtPxp5TEduVXhiDsmHaUJd45xnIw== X-Received: by 2002:a17:902:828c:: with SMTP id y12-v6mr957112pln.145.1516338026837; Thu, 18 Jan 2018 21:00:26 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i128sm14653163pfg.83.2018.01.18.21.00.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 21:00:26 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 19 Jan 2018 16:00:01 +1100 Message-Id: <20180119050005.29392-4-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180119050005.29392-1-sjitindarsingh@gmail.com> References: <20180119050005.29392-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V5 3/7] 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, Suraj Jitindar Singh , 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 --- V4 -> V5: - Add unused directive to fix bisection breakage --- hw/ppc/spapr_caps.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 4 +++ 2 files changed, 70 insertions(+) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 5d52969bd5..d6f82b18fc 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -73,6 +73,72 @@ 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 __attribute__ ((unused)) 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 __attribute__ ((unused)) 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 {