From patchwork Wed Dec 6 22:53:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Jiang X-Patchwork-Id: 10097359 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 B5E7260327 for ; Wed, 6 Dec 2017 22:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A695328C1C for ; Wed, 6 Dec 2017 22:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B4E129271; Wed, 6 Dec 2017 22:53:36 +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 09E1628C1C for ; Wed, 6 Dec 2017 22:53:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2A44020352ABE; Wed, 6 Dec 2017 14:49:03 -0800 (PST) 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=192.55.52.88; helo=mga01.intel.com; envelope-from=dave.jiang@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 75DDD20352AB6 for ; Wed, 6 Dec 2017 14:49:01 -0800 (PST) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Dec 2017 14:53:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,369,1508828400"; d="scan'208";a="693545" Received: from djiang5-desk3.ch.intel.com ([143.182.136.93]) by orsmga008.jf.intel.com with ESMTP; 06 Dec 2017 14:53:33 -0800 Subject: [PATCH 1/2] ndctl: add support to enable latch system shutdown status From: Dave Jiang To: dan.j.williams@intel.com Date: Wed, 06 Dec 2017 15:53:32 -0700 Message-ID: <151260081283.5641.2560511933614024819.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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: , Cc: linux-nvdimm@lists.01.org Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Adding the Enable Latch System Shutdown Status (Function Index 10) for DSM v1.6 spec. Signed-off-by: Dave Jiang --- ndctl/lib/Makefile.am | 1 + ndctl/lib/intel.c | 38 ++++++++++++++++++++++++++++++++++++++ ndctl/lib/intel.h | 7 +++++++ ndctl/lib/libndctl.sym | 2 ++ ndctl/lib/lss.c | 43 +++++++++++++++++++++++++++++++++++++++++++ ndctl/lib/private.h | 2 ++ 6 files changed, 93 insertions(+) create mode 100644 ndctl/lib/lss.c diff --git a/ndctl/lib/Makefile.am b/ndctl/lib/Makefile.am index e3a12e7..c1ea371 100644 --- a/ndctl/lib/Makefile.am +++ b/ndctl/lib/Makefile.am @@ -22,6 +22,7 @@ libndctl_la_SOURCES =\ msft.c \ ars.c \ firmware.c \ + lss.c \ libndctl.c libndctl_la_LIBADD =\ diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c index 6d26a6c..10a0881 100644 --- a/ndctl/lib/intel.c +++ b/ndctl/lib/intel.c @@ -547,6 +547,42 @@ static unsigned long intel_cmd_fw_fquery_get_fw_rev(struct ndctl_cmd *cmd) return cmd->intel->fquery.updated_fw_rev; } +static struct ndctl_cmd * +intel_dimm_cmd_new_lss_enable(struct ndctl_dimm *dimm) +{ + struct ndctl_cmd *cmd; + + BUILD_ASSERT(sizeof(struct nd_intel_lss) == 5); + + cmd = alloc_intel_cmd(dimm, ND_INTEL_ENABLE_LSS_STATUS, 1, 4); + if (!cmd) + return NULL; + + cmd->firmware_status = &cmd->intel->lss.status; + return cmd; +} + +static int intel_lss_set_valid(struct ndctl_cmd *cmd) +{ + struct nd_pkg_intel *pkg = cmd->intel; + + if (cmd->type != ND_CMD_CALL || cmd->status != 1 + || pkg->gen.nd_family != NVDIMM_FAMILY_INTEL + || pkg->gen.nd_command != ND_INTEL_ENABLE_LSS_STATUS) + return -EINVAL; + return 0; +} + +static int +intel_cmd_lss_set_enable(struct ndctl_cmd *cmd, unsigned char enable) +{ + if (intel_lss_set_valid(cmd) < 0) + return -EINVAL; + cmd->intel->lss.enable = enable; + return 0; +} + + struct ndctl_dimm_ops * const intel_dimm_ops = &(struct ndctl_dimm_ops) { .cmd_desc = intel_cmd_desc, .new_smart = intel_dimm_cmd_new_smart, @@ -601,4 +637,6 @@ struct ndctl_dimm_ops * const intel_dimm_ops = &(struct ndctl_dimm_ops) { .new_fw_finish_query = intel_dimm_cmd_new_fw_finish_query, .fw_fquery_set_context = intel_cmd_fw_fquery_set_context, .fw_fquery_get_fw_rev = intel_cmd_fw_fquery_get_fw_rev, + .new_lss_enable = intel_dimm_cmd_new_lss_enable, + .lss_set_enable = intel_cmd_lss_set_enable, }; diff --git a/ndctl/lib/intel.h b/ndctl/lib/intel.h index 080e37b..92bed53 100644 --- a/ndctl/lib/intel.h +++ b/ndctl/lib/intel.h @@ -6,6 +6,7 @@ #define ND_INTEL_SMART 1 #define ND_INTEL_SMART_THRESHOLD 2 +#define ND_INTEL_ENABLE_LSS_STATUS 10 #define ND_INTEL_FW_GET_INFO 12 #define ND_INTEL_FW_START_UPDATE 13 #define ND_INTEL_FW_SEND_DATA 14 @@ -118,6 +119,11 @@ struct nd_intel_fw_finish_query { __u64 updated_fw_rev; } __attribute__((packed)); +struct nd_intel_lss { + __u8 enable; + __u32 status; +} __attribute__((packed)); + struct nd_pkg_intel { struct nd_cmd_pkg gen; union { @@ -129,6 +135,7 @@ struct nd_pkg_intel { struct nd_intel_fw_send_data send; struct nd_intel_fw_finish_update finish; struct nd_intel_fw_finish_query fquery; + struct nd_intel_lss lss; }; }; #endif /* __INTEL_H__ */ diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index 2e248ab..65673ad 100644 --- a/ndctl/lib/libndctl.sym +++ b/ndctl/lib/libndctl.sym @@ -344,4 +344,6 @@ global: ndctl_cmd_fw_finish_set_ctrl_flags; ndctl_cmd_fw_finish_set_context; ndctl_cmd_fw_fquery_set_context; + ndctl_dimm_cmd_new_lss_enable; + ndctl_cmd_lss_set_enable; } LIBNDCTL_13; diff --git a/ndctl/lib/lss.c b/ndctl/lib/lss.c new file mode 100644 index 0000000..fbeeec5 --- /dev/null +++ b/ndctl/lib/lss.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ +#include +#include +#include +#include +#include "private.h" + +/* + * Define the wrappers around the ndctl_dimm_ops for LSS DSM + */ +NDCTL_EXPORT struct ndctl_cmd * +ndctl_dimm_cmd_new_lss_enable(struct ndctl_dimm *dimm) +{ + struct ndctl_dimm_ops *ops = dimm->ops; + + if (ops && ops->new_lss_enable) + return ops->new_lss_enable(dimm); + else + return NULL; +} + +NDCTL_EXPORT int +ndctl_cmd_lss_set_enable(struct ndctl_cmd *cmd, unsigned char enable) +{ + if (cmd->dimm) { + struct ndctl_dimm_ops *ops = cmd->dimm->ops; + + if (ops && ops->lss_set_enable) + return ops->lss_set_enable(cmd, enable); + } + return -ENXIO; +} diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h index 20f9e6e..4035e11 100644 --- a/ndctl/lib/private.h +++ b/ndctl/lib/private.h @@ -325,6 +325,8 @@ struct ndctl_dimm_ops { struct ndctl_cmd *(*new_fw_finish_query)(struct ndctl_dimm *); int (*fw_fquery_set_context)(struct ndctl_cmd *, unsigned int context); unsigned long (*fw_fquery_get_fw_rev)(struct ndctl_cmd *); + struct ndctl_cmd *(*new_lss_enable)(struct ndctl_dimm *); + int (*lss_set_enable)(struct ndctl_cmd *, unsigned char enable); }; struct ndctl_dimm_ops * const intel_dimm_ops; diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h index 64a4e99..24dc7a3 100644 --- a/ndctl/libndctl.h +++ b/ndctl/libndctl.h @@ -607,6 +607,9 @@ int ndctl_cmd_fw_finish_set_ctrl_flags(struct ndctl_cmd *cmd, unsigned char flag int ndctl_cmd_fw_finish_set_context(struct ndctl_cmd *cmd, unsigned int context); int ndctl_cmd_fw_fquery_set_context(struct ndctl_cmd *cmd, unsigned int context); +struct ndctl_cmd *ndctl_dimm_cmd_new_lss_enable(struct ndctl_dimm *dimm); +int ndctl_cmd_lss_set_enable(struct ndctl_cmd *cmd, unsigned char enable); + #ifdef __cplusplus } /* extern "C" */ #endif