From patchwork Thu Sep 7 05:04:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?R290b3UsIFlhc3Vub3JpL+S6lOWztiDlurfmloc=?= X-Patchwork-Id: 9941589 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 542746038C for ; Thu, 7 Sep 2017 05:05:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F738283E8 for ; Thu, 7 Sep 2017 05:05:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43F2E283FF; Thu, 7 Sep 2017 05:05:02 +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=-1.9 required=2.0 tests=BAYES_00, 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 BF5BF283FD for ; Thu, 7 Sep 2017 05:05:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BA0A221EA35CC; Wed, 6 Sep 2017 22:02:10 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mgwym01.jp.fujitsu.com (mgwym01.jp.fujitsu.com [211.128.242.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6326520958BE5 for ; Wed, 6 Sep 2017 22:02:09 -0700 (PDT) Received: from yt-mxoi1.gw.nic.fujitsu.com (unknown [192.168.229.67]) by mgwym01.jp.fujitsu.com with smtp id 4583_0e12_e287f5c5_0b79_4793_ab3b_092a5669fe71; Thu, 07 Sep 2017 14:04:54 +0900 Received: from m3051.s.css.fujitsu.com (m3051.s.css.fujitsu.com [10.134.21.209]) by yt-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id 88FADAC019B for ; Thu, 7 Sep 2017 14:04:53 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.5.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20170217-enc X-SHieldMailCheckerMailID: cd3f0b5ced5f4847bd7746a60a37ce10 Date: Thu, 07 Sep 2017 14:04:40 +0900 From: Yasunori Goto To: NVDIMM-ML Subject: [ndctl PATCH v5 2/5] ndctl: read device/nfit/dsm_mask In-Reply-To: <20170907140049.7F71.E1E9C6FF@jp.fujitsu.com> References: <20170907140049.7F71.E1E9C6FF@jp.fujitsu.com> Message-Id: <20170907140436.7F77.E1E9C6FF@jp.fujitsu.com> MIME-Version: 1.0 X-Mailer: Becky! ver. 2.73 [ja] X-TM-AS-MML: disable X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP To check what feature can be called via ND_CMD_CALL, ndctl needs to read device/nfit/dsm_mask. To read it from ndctl/lib/nfit.c, ndctl_bus is moved to ndctl/lib/private.h. This is used later patch. Signed-off-by: Yasunori Goto --- ndctl/lib/libndctl.c | 34 ++++++---------------------------- ndctl/lib/private.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 4361cd8..6852137 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -77,34 +77,6 @@ NDCTL_EXPORT size_t ndctl_sizeof_namespace_label(void) } struct ndctl_ctx; -/** - * struct ndctl_bus - a nfit table instance - * @major: control character device major number - * @minor: control character device minor number - * @revision: NFIT table revision number - * @provider: identifier for the source of the NFIT table - * - * The expectation is one NFIT/nd bus per system provided by platform - * firmware (for example @provider == "ACPI.NFIT"). However, the - * nfit_test module provides multiple test busses with provider names of - * the format "nfit_test.N" - */ -struct ndctl_bus { - struct ndctl_ctx *ctx; - unsigned int id, major, minor, revision; - char *provider; - struct list_head dimms; - struct list_head regions; - struct list_node list; - int dimms_init; - int regions_init; - int has_nfit; - char *bus_path; - char *bus_buf; - size_t buf_len; - char *wait_probe_path; - unsigned long dsm_mask; -}; /** * struct ndctl_mapping - dimm extent relative to a region @@ -793,6 +765,12 @@ static void *add_bus(void *parent, int id, const char *ctl_base) bus->revision = strtoul(buf, NULL, 0); } + sprintf(path, "%s/device/nfit/dsm_mask", ctl_base); + if (sysfs_read_attr(ctx, path, buf) < 0) + bus->nfit_dsm_mask = 0; + else + bus->nfit_dsm_mask = strtoul(buf, NULL, 0); + sprintf(path, "%s/device/provider", ctl_base); if (sysfs_read_attr(ctx, path, buf) < 0) goto err_read; diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h index 83a8067..aeedc03 100644 --- a/ndctl/lib/private.h +++ b/ndctl/lib/private.h @@ -127,6 +127,36 @@ struct ndctl_ctx { }; /** + * struct ndctl_bus - a nfit table instance + * @major: control character device major number + * @minor: control character device minor number + * @revision: NFIT table revision number + * @provider: identifier for the source of the NFIT table + * + * The expectation is one NFIT/nd bus per system provided by platform + * firmware (for example @provider == "ACPI.NFIT"). However, the + * nfit_test module provides multiple test busses with provider names of + * the format "nfit_test.N" + */ +struct ndctl_bus { + struct ndctl_ctx *ctx; + unsigned int id, major, minor, revision; + char *provider; + struct list_head dimms; + struct list_head regions; + struct list_node list; + int dimms_init; + int regions_init; + int has_nfit; + char *bus_path; + char *bus_buf; + size_t buf_len; + char *wait_probe_path; + unsigned long dsm_mask; + unsigned long nfit_dsm_mask; +}; + +/** * struct ndctl_cmd - device-specific-method (_DSM ioctl) container * @dimm: set if the command is relative to a dimm, NULL otherwise * @bus: set if the command is relative to a bus (like ARS), NULL otherwise