From patchwork Sat Mar 23 04:20:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10866761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22856922 for ; Sat, 23 Mar 2019 04:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 004A12A94F for ; Sat, 23 Mar 2019 04:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8E402A95D; Sat, 23 Mar 2019 04:20:42 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC8F42A94F for ; Sat, 23 Mar 2019 04:20:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A5CF2211E9FA8; Fri, 22 Mar 2019 21:20:42 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::844; helo=mail-qt1-x844.google.com; envelope-from=dexuan.cui@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4D3F2211E9FA3 for ; Fri, 22 Mar 2019 21:20:41 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id t28so4881358qte.6 for ; Fri, 22 Mar 2019 21:20:41 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=JK73HA9FlClT5xM0YEyWS2jmQcS1f9MvElb1iZtc/+E=; b=KbnwzG/RBEmG+3+EltcsTTRGD5J5Tzq+YX6vMwT1GOL3fo8zGMI6ND/tGtSYUTwBZa 05FZVKNOaUQRgvunqmiKElTsJRPvpAf3TcPdMDGti2CFK3kZhgJ/7PtNoBKadNQdxRRy ql9WG9JYqUyo+gPbHgiZ9xTn2BHJHYa6CjcfWh/wMnP1KHDHkCE57tBkNt66OyGOzfZw IIFSjlBn4jvAPvUxfURu3MSYJJYE2ApmuIR1fJ33MKTGA9NxXtlxZropIE9nHqTKA65f tU4RS46W4A2Sq26PX6MbeeGaAU0UZP11O1WcJCwfFqVECZ3FZ/f2OJLhFF7IdWinaEYh bVkw== 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:mime-version:content-transfer-encoding; bh=JK73HA9FlClT5xM0YEyWS2jmQcS1f9MvElb1iZtc/+E=; b=DGxTxQ+ttbRcEFPniLJu8z2kt1gA5c6w2ZMuU5SEyStHqkUiLKz/Sroxk0IYmwx6Xs 5pc2v0kS3Im9IrjYIbM6N/GnwK6uSvwpxU6yR/Em6d3UAILDhJ7f+KP0S3RRztEk9l+Y tTPNokW7QmEcrLUXOzPBe0yprWLkHr14EFOZrAi93vTVLQEyuLr5kD5jM4rz22BzZYWm r6KJqMzY6N3MwdVLoHLFXJ/Y1DCEaEL/aBYbWk5l4wKvdSen9WzddEb0P4ZFfkd4vp4N b4NLXKIgd6CysQlyiS1OBZuh97nMpL7DNYPWJTZxtxqp8KO30RAdAurjBmWzy+Vw52T5 Wfaw== X-Gm-Message-State: APjAAAUi8ifYq6hk0yz9YlDi+h4Mb3dXazYYy5Zbab/tgBnlFnEzLLx+ DOebE3jB/now0vN+SIH1blM= X-Google-Smtp-Source: APXvYqzOsInHPpIq1DrP0aJrNiQ0aXQn2iASjHGKOiO1WGPq3GyVpKFSX4sfJeYtqzhdmSBnPAFOgQ== X-Received: by 2002:ac8:2598:: with SMTP id e24mr11673247qte.27.1553314839999; Fri, 22 Mar 2019 21:20:39 -0700 (PDT) Received: from linuxonhyperv2.linuxonhyperv.com (ip-107-180-71-197.ip.secureserver.net. [107.180.71.197]) by smtp.gmail.com with ESMTPSA id k12sm6919699qti.38.2019.03.22.21.20.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 21:20:39 -0700 (PDT) From: Dexuan Cui X-Google-Original-From: Dexuan Cui To: vishal.l.verma@intel.com, dan.j.williams@intel.com, dave.jiang@intel.com, linux-nvdimm@lists.01.org, mikelley@microsoft.com Subject: [ndctl PATCH v3 4/5] libndctl: Add a new dimm-op cmd_is_supported() Date: Sat, 23 Mar 2019 04:20:28 +0000 Message-Id: <20190323042028.4310-5-decui@microsoft.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190323042028.4310-1-decui@microsoft.com> References: <20190323042028.4310-1-decui@microsoft.com> MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qi.fuli@fujitsu.com Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP A NVDIMM family may need to report that it supports a command, even if the command is not set in dimm->cmd_mask, e.g. a non-NVDIMM_FAMILY_INTEL famimy may support ND_CMD_SMART or some kind of variant of ND_CMD_SMART, while the kernel only sets ND_CMD_SMART in the nvdimm->cmd_mask for NVDIMM_FAMILY_INTEL. Signed-off-by: Dexuan Cui --- ndctl/lib/libndctl.c | 5 +++++ ndctl/lib/private.h | 1 + 2 files changed, 6 insertions(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 24b8ad3..4acfb03 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -1769,6 +1769,11 @@ NDCTL_EXPORT int ndctl_dimm_failed_map(struct ndctl_dimm *dimm) NDCTL_EXPORT int ndctl_dimm_is_cmd_supported(struct ndctl_dimm *dimm, int cmd) { + struct ndctl_dimm_ops *ops = dimm->ops; + + if (ops && ops->cmd_is_supported) + return ops->cmd_is_supported(dimm, cmd); + return !!(dimm->cmd_mask & (1ULL << cmd)); } diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h index a9d35c5..2ddc1d2 100644 --- a/ndctl/lib/private.h +++ b/ndctl/lib/private.h @@ -292,6 +292,7 @@ struct ndctl_bb { struct ndctl_dimm_ops { const char *(*cmd_desc)(int); + bool (*cmd_is_supported)(struct ndctl_dimm *, int); struct ndctl_cmd *(*new_smart)(struct ndctl_dimm *); unsigned int (*smart_get_flags)(struct ndctl_cmd *); unsigned int (*smart_get_health)(struct ndctl_cmd *);