From patchwork Thu May 12 14:00:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 12847726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F95BC433FE for ; Thu, 12 May 2022 13:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354505AbiELNud (ORCPT ); Thu, 12 May 2022 09:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354694AbiELNu1 (ORCPT ); Thu, 12 May 2022 09:50:27 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD26E2550A9 for ; Thu, 12 May 2022 06:50:26 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id c14so4865158pfn.2 for ; Thu, 12 May 2022 06:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=rM70m8eZ0pakv69/iTvtJzOWiFpVeylcQX42wha9Z4w=; b=NQvrMdOzQ4dB6DLqQpRKShb6bsG3gRH87u39uKG3sWdMYrTB4uckttbH5k/TS5esqK SwfAumu4PlCxn5MJFp9kiuI1OTD6/EJQwvs5Uu7GkSd8rVwAPYHLBYPfvsfLDMggPZlz od7FKf1ktwA8aO27pXmA0QonFkgrCb4N204cw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=rM70m8eZ0pakv69/iTvtJzOWiFpVeylcQX42wha9Z4w=; b=HkSwtQCMAMKiYJEO6r6o34LPw7cTITsNM0lmbIMSjf3pt38YmuRmZJQZI5X26LuuGa Wn1h5scyBHKoVaQdjnYFBKza9hupG3kJYND+uqpUxBoRatuHdkHDJ+wxiuwa/0G5Fb0+ TjD0PjiC9SuMeVZ6lZ96upB4jg2VvpBYHBLRtZs3Dx1xwcNa5LuybJpaD+jIBqT9gctt IXDaCujxl+BALlHJXEaVj7+WyMh4aNkx8Yo6CkxRULU5f6t7d3sTRIYHyPw1VcSKFvLq WNHVN6rLaT1Wtkp1+0MXrJSslgKRnuaYT1bsRDB9MZoknCP55zQ6hVknQHiXoa2i37Yi Vzzg== X-Gm-Message-State: AOAM530ppGI65aJWQJGJDuNrRTv4WzPd8jAygk8X292CWeo4RIdxyBUJ 1utGL5VCrVipRAV9tqgCRgLxkPKqDvLHKEX9Z2MC341H8+sOylYYahTTX55o7IYsK8zwg/pIF8b xp9zXK0NQyAYhHL9sb0eoyOwwTXCfF3uQp2HyoMi06Q45rWKdyMA6krMzLVStFR0OaI3a81QwgP htUSwy82/7 X-Google-Smtp-Source: ABdhPJzNvt2R6ul81nFckPjiuczwAWfxRNLv86HNvyvOBsyPKmR5kBLCcBWV6e47Xxy6BhwGVZyBNQ== X-Received: by 2002:a63:d907:0:b0:3c6:c6e3:1498 with SMTP id r7-20020a63d907000000b003c6c6e31498mr15433803pgg.535.1652363425593; Thu, 12 May 2022 06:50:25 -0700 (PDT) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.252.250]) by smtp.gmail.com with ESMTPSA id t21-20020a17090ad15500b001cd4989ff47sm1872409pjw.14.2022.05.12.06.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 06:50:24 -0700 (PDT) From: Sreekanth Reddy To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, Sreekanth Reddy Subject: [PATCH 1/2] mpi3mr: Add shost related sysfs attributes Date: Thu, 12 May 2022 19:30:45 +0530 Message-Id: <20220512140046.19046-2-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220512140046.19046-1-sreekanth.reddy@broadcom.com> References: <20220512140046.19046-1-sreekanth.reddy@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Added shost related sysfs attributes to get the controller's firmware version, controlller's queue depth, number of request & reply queues. Also added an attribute to set & get the logging_level. Signed-off-by: Sreekanth Reddy Reviewed-by: Himanshu Madhani --- drivers/scsi/mpi3mr/mpi3mr_app.c | 139 +++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 73bb799..c9b153c 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -1558,6 +1558,140 @@ err_device_add: kfree(mrioc->bsg_dev); } +/** + * version_fw_show - SysFS callback for firmware version read + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: snprintf() return after copying firmware version + */ +static ssize_t +version_fw_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + struct mpi3mr_compimg_ver *fwver = &mrioc->facts.fw_ver; + + return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d.%05d-%05d\n", + fwver->gen_major, fwver->gen_minor, fwver->ph_major, + fwver->ph_minor, fwver->cust_id, fwver->build_num); +} +static DEVICE_ATTR_RO(version_fw); + +/** + * fw_queue_depth_show - SysFS callback for firmware max cmds + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: snprintf() return after copying firmware max commands + */ +static ssize_t +fw_queue_depth_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return snprintf(buf, PAGE_SIZE, "%d\n", mrioc->facts.max_reqs); +} +static DEVICE_ATTR_RO(fw_queue_depth); + +/** + * op_req_q_count_show - SysFS callback for request queue count + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: snprintf() return after copying request queue count + */ +static ssize_t +op_req_q_count_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return snprintf(buf, PAGE_SIZE, "%d\n", mrioc->num_op_req_q); +} +static DEVICE_ATTR_RO(op_req_q_count); + +/** + * reply_queue_count_show - SysFS callback for reply queue count + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: snprintf() return after copying reply queue count + */ +static ssize_t +reply_queue_count_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return snprintf(buf, PAGE_SIZE, "%d\n", mrioc->num_op_reply_q); +} + +static DEVICE_ATTR_RO(reply_queue_count); + +/** + * logging_level_show - Show controller debug level + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * A sysfs 'read/write' shost attribute, to show the current + * debug log level used by the driver for the specific + * controller. + * + * Return: snprintf() return + */ +static ssize_t +logging_level_show(struct device *dev, + struct device_attribute *attr, char *buf) + +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + + return snprintf(buf, PAGE_SIZE, "%08xh\n", mrioc->logging_level); +} + +/** + * logging_level_store- Change controller debug level + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * @count: size of the buffer + * + * A sysfs 'read/write' shost attribute, to change the current + * debug log level used by the driver for the specific + * controller. + * + * Return: strlen() return + */ +static ssize_t +logging_level_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct mpi3mr_ioc *mrioc = shost_priv(shost); + int val = 0; + + if (kstrtoint(buf, 0, &val) != 0) + return -EINVAL; + + mrioc->logging_level = val; + ioc_info(mrioc, "logging_level=%08xh\n", mrioc->logging_level); + return strlen(buf); +} +static DEVICE_ATTR_RW(logging_level); + /** * adapter_state_show - SysFS callback for adapter state show * @dev: class device @@ -1591,6 +1725,11 @@ adp_state_show(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RO(adp_state); static struct attribute *mpi3mr_host_attrs[] = { + &dev_attr_version_fw.attr, + &dev_attr_fw_queue_depth.attr, + &dev_attr_op_req_q_count.attr, + &dev_attr_reply_queue_count.attr, + &dev_attr_logging_level.attr, &dev_attr_adp_state.attr, NULL, };