From patchwork Fri Apr 29 21:16:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Saxena X-Patchwork-Id: 568475 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 2D5ABC433EF for ; Fri, 29 Apr 2022 21:17:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237481AbiD2VVK (ORCPT ); Fri, 29 Apr 2022 17:21:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237396AbiD2VVA (ORCPT ); Fri, 29 Apr 2022 17:21:00 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6568A3D1FB for ; Fri, 29 Apr 2022 14:17:41 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id p6so8171853plf.9 for ; Fri, 29 Apr 2022 14:17:41 -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=mUxkQfAxtjWLH19jKjSLNoGsPyQC8s1UdY63wdBIR74=; b=AHqt7uubzGEQQTeDPcauXCKPpa7SfrkwmOhxLnItG/2GN95yUlIIUyz2degq4O7ECI gndqzguxoRfMkPcaR6aGFdHtyp8kdakk8+9CxJmbXtj8z/KUDDIf7/RnY9Y3Bh2LoHCj ESuxV8XPCrCecvpqDOxvZFL29GjyTLZnFAVpQ= 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=mUxkQfAxtjWLH19jKjSLNoGsPyQC8s1UdY63wdBIR74=; b=R9TpANZuKZdJlgPfZliyMDcEAZKTZDK1xxtwgBDupxLEg07hdaxukc1jux/4SfpgFp 9otcdY6CTkYR3AgzVdBH0HQC0pJ2LfOFJh9c1FJqc+CYhTq+G3qVTR/G9xwFhFCGF7fj 82ahOtk43JqTgwVWjIE0sFYWEJGwlJGSo13q6h5cmGCHXC0BR/mXLWkHn8VzQFpKy98g vEFJOZW3W7OfwN7y7KMTR2jmiEUev4We3EQdoOjhq09p4WnTWyWDCKQV9DRrYqCujkry xEqh+2ji/30Y4dpIdFdddSj86/s9ucZxg3XqkMmHhmFjJL5stS/yAuUNILuWiOlY/i6Z UFfA== X-Gm-Message-State: AOAM531hKVkEWxHcs5Xt4cC1YSw43i1CpbSnfa+Xg4dbX5MQ5XXVlJCH vUOz2Ne3D2TjhURaRRGHuyV8hoeb6SnvJFt9caE0aawDg2VaWsPV8O3OUXacCzAP0DTFk4sDSB7 3f4cNqKesWTy7jHfx49FnlUr0dKs3Ri+eqCexRbqwQG+VAKBGtoIdZAgB+uEh/8a3yeU3l4QhVz UyGisNRJA= X-Google-Smtp-Source: ABdhPJzNSjGRZGr8otBMvQ9VaPu7NltIYxLt/jjC6INSNhg350cpmFNrr4FiURlchsfBQXPnYZYRDQ== X-Received: by 2002:a17:902:e552:b0:156:9cdc:e6cf with SMTP id n18-20020a170902e55200b001569cdce6cfmr969290plf.78.1651267060586; Fri, 29 Apr 2022 14:17:40 -0700 (PDT) Received: from dhcp-10-123-20-15.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y9-20020a17090a1f4900b001cd498dc153sm14494849pjy.3.2022.04.29.14.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 14:17:40 -0700 (PDT) From: Sumit Saxena To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, bvanassche@acm.org, hch@lst.de, hare@suse.de, himanshu.madhani@oracle.com, sathya.prakash@broadcom.com, kashyap.desai@broadcom.com, chandrakanth.patil@broadcom.com, sreekanth.reddy@broadcom.com, prayas.patel@broadcom.com, Sumit Saxena Subject: [PATCH v7 6/8] mpi3mr: Expose adapter state to sysfs Date: Fri, 29 Apr 2022 17:16:39 -0400 Message-Id: <20220429211641.642010-7-sumit.saxena@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220429211641.642010-1-sumit.saxena@broadcom.com> References: <20220429211641.642010-1-sumit.saxena@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Reviewed-by: Himanshu Madhani Signed-off-by: Sumit Saxena --- drivers/scsi/mpi3mr/mpi3mr.h | 2 +- drivers/scsi/mpi3mr/mpi3mr_app.c | 46 ++++++++++++++++++++++++++++++++ drivers/scsi/mpi3mr/mpi3mr_os.c | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index cc54231da658..1de3b006f444 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -1056,5 +1056,5 @@ int mpi3mr_pel_get_seqnum_post(struct mpi3mr_ioc *mrioc, struct mpi3mr_drv_cmd *drv_cmd); void mpi3mr_app_save_logdata(struct mpi3mr_ioc *mrioc, char *event_data, u16 event_data_size); - +extern const struct attribute_group *mpi3mr_host_groups[]; #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 06a1e950bec4..5221058e3d6b 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -1215,3 +1215,49 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc) err_device_add: kfree(mrioc->bsg_dev); } + +/** + * adapter_state_show - SysFS callback for adapter state show + * @dev: class device + * @attr: Device attributes + * @buf: Buffer to copy + * + * Return: snprintf() return after copying adapter state + */ +static ssize_t +adp_state_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); + enum mpi3mr_iocstate ioc_state; + uint8_t adp_state; + + ioc_state = mpi3mr_get_iocstate(mrioc); + if (ioc_state == MRIOC_STATE_UNRECOVERABLE) + adp_state = MPI3MR_BSG_ADPSTATE_UNRECOVERABLE; + else if ((mrioc->reset_in_progress) || (mrioc->stop_bsgs)) + adp_state = MPI3MR_BSG_ADPSTATE_IN_RESET; + else if (ioc_state == MRIOC_STATE_FAULT) + adp_state = MPI3MR_BSG_ADPSTATE_FAULT; + else + adp_state = MPI3MR_BSG_ADPSTATE_OPERATIONAL; + + return snprintf(buf, PAGE_SIZE, "%u\n", adp_state); +} + +static DEVICE_ATTR_RO(adp_state); + +static struct attribute *mpi3mr_host_attrs[] = { + &dev_attr_adp_state.attr, + NULL, +}; + +static const struct attribute_group mpi3mr_host_attr_group = { + .attrs = mpi3mr_host_attrs +}; + +const struct attribute_group *mpi3mr_host_groups[] = { + &mpi3mr_host_attr_group, + NULL, +}; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 19298136edb6..89a4918c4a9e 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -4134,6 +4134,7 @@ static struct scsi_host_template mpi3mr_driver_template = { .max_segment_size = 0xffffffff, .track_queue_depth = 1, .cmd_size = sizeof(struct scmd_priv), + .shost_groups = mpi3mr_host_groups, }; /**