All of lore.kernel.org
 help / color / mirror / Atom feed
From: himanshu.madhani@oracle.com
To: Nilesh Javali <njavali@marvell.com>, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, GR-QLogic-Storage-Upstream@marvell.com
Subject: Re: [PATCH 3/3] qla2xxx: Pass SCM counters to the application.
Date: Thu, 14 May 2020 14:15:40 -0500	[thread overview]
Message-ID: <1970ba0e-8c7c-3e8e-3478-10a4e7fb693d@oracle.com> (raw)
In-Reply-To: <20200514101026.10040-4-njavali@marvell.com>



On 5/14/20 5:10 AM, Nilesh Javali wrote:
> From: Shyam Sundar <ssundar@marvell.com>
> 
> Implement 3 functions to pass on SAN congestion management
> related counters tracked by the driver, up to the Marvell
> application using the BSG interface.
> 
> Signed-off-by: Shyam Sundar <ssundar@marvell.com>
> Signed-off-by: Arun Easi <aeasi@marvell.com>
> Signed-off-by: Nilesh Javali <njavali@marvell.com>
> ---
>   drivers/scsi/qla2xxx/qla_bsg.c | 114 +++++++++++++++++++++++++++++++++
>   drivers/scsi/qla2xxx/qla_bsg.h |   3 +
>   2 files changed, 117 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
> index 97b51c477972..bd898bbdd44d 100644
> --- a/drivers/scsi/qla2xxx/qla_bsg.c
> +++ b/drivers/scsi/qla2xxx/qla_bsg.c
> @@ -2446,6 +2446,111 @@ qla2x00_get_flash_image_status(struct bsg_job *bsg_job)
>   	return 0;
>   }
>   
> +static int
> +qla2x00_get_drv_attr(struct bsg_job *bsg_job)
> +{
> +	struct qla_drv_attr drv_attr;
> +	struct fc_bsg_reply *bsg_reply = bsg_job->reply;
> +
> +	memset(&drv_attr, 0, sizeof(struct qla_drv_attr));
> +	/* Additional check should be added if SCM is not enabled
> +	 * by default for a given driver version.
> +	 */
> +	drv_attr.attributes |= QLA_DRV_ATTR_SCM_SUPPORTED;
> +
> +	sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
> +			    bsg_job->reply_payload.sg_cnt, &drv_attr,
> +			    sizeof(struct qla_drv_attr));
> +
> +	bsg_reply->reply_payload_rcv_len = sizeof(struct qla_drv_attr);
> +	bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = EXT_STATUS_OK;
> +
> +	bsg_job->reply_len = sizeof(*bsg_job->reply);
> +	bsg_reply->result = DID_OK << 16;
> +	bsg_job_done(bsg_job, bsg_reply->result,
> +		     bsg_reply->reply_payload_rcv_len);
> +
> +	return 0;
> +}
> +
> +static int
> +qla2x00_get_port_scm(struct bsg_job *bsg_job)
> +{
> +	struct Scsi_Host *shost = fc_bsg_to_shost(bsg_job);
> +	scsi_qla_host_t *vha = shost_priv(shost);
> +	struct qla_hw_data *ha = vha->hw;
> +	struct fc_bsg_reply *bsg_reply = bsg_job->reply;
> +
> +	if (!IS_QLA27XX(ha) && !IS_QLA28XX(ha))
> +		return -EPERM;
> +
> +	sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
> +			    bsg_job->reply_payload.sg_cnt, &vha->scm_stats,
> +			    sizeof(struct qla_scm_port));
> +
> +	bsg_reply->reply_payload_rcv_len = sizeof(struct qla_scm_port);
> +	bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = EXT_STATUS_OK;
> +
> +	bsg_job->reply_len = sizeof(*bsg_job->reply);
> +	bsg_reply->result = DID_OK << 16;
> +	bsg_job_done(bsg_job, bsg_reply->result,
> +		     bsg_reply->reply_payload_rcv_len);
> +
> +	return 0;
> +}
> +
> +static int
> +qla2x00_get_target_scm(struct bsg_job *bsg_job)
> +{
> +	struct Scsi_Host *shost = fc_bsg_to_shost(bsg_job);
> +	scsi_qla_host_t *vha = shost_priv(shost);
> +	struct fc_bsg_reply *bsg_reply = bsg_job->reply;
> +	struct qla_hw_data *ha = vha->hw;
> +	fc_port_t *fcport =  NULL;
> +	int rval;
> +	struct qla_scm_target *scm_stats = NULL;
> +
> +	if (!IS_QLA27XX(ha) && !IS_QLA28XX(ha))
> +		return -EPERM;
> +
> +	scm_stats = kzalloc(sizeof(*scm_stats), GFP_KERNEL);
> +	if (!scm_stats) {
> +		ql_log(ql_log_warn, vha, 0x7024,
> +		       "Failed to allocate memory for target scm stats.\n");
> +		return -ENOMEM;
> +	}
> +
> +	sg_copy_to_buffer(bsg_job->request_payload.sg_list,
> +			  bsg_job->request_payload.sg_cnt, scm_stats,
> +			  sizeof(struct qla_scm_target));
> +
> +	fcport = qla2x00_find_fcport_by_wwpn(vha, scm_stats->wwpn, 0);
> +	if (fcport) {
> +		/* Copy SCM Target data to local struct, keep WWPN from user */
> +		memcpy(&scm_stats->current_events,
> +		       &fcport->scm_stats.current_events,
> +		       (sizeof(struct qla_scm_target) -
> +			sizeof(scm_stats->wwpn)));
> +		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
> +				    bsg_job->reply_payload.sg_cnt, scm_stats,
> +				    sizeof(struct qla_scm_target));
> +		rval = EXT_STATUS_OK;
> +	} else {
> +		rval = EXT_STATUS_ERR;
> +	}
> +
> +	bsg_reply->reply_payload_rcv_len = sizeof(struct qla_scm_target);
> +	bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval;
> +
> +	bsg_job->reply_len = sizeof(*bsg_job->reply);
> +	bsg_reply->result = DID_OK << 16;
> +	bsg_job_done(bsg_job, bsg_reply->result,
> +		     bsg_reply->reply_payload_rcv_len);
> +
> +	kfree(scm_stats);
> +	return 0;
> +}
> +
>   static int
>   qla2x00_process_vendor_specific(struct bsg_job *bsg_job)
>   {
> @@ -2522,6 +2627,15 @@ qla2x00_process_vendor_specific(struct bsg_job *bsg_job)
>   	case QL_VND_SS_GET_FLASH_IMAGE_STATUS:
>   		return qla2x00_get_flash_image_status(bsg_job);
>   
> +	case QL_VND_GET_PORT_SCM:
> +		return qla2x00_get_port_scm(bsg_job);
> +
> +	case QL_VND_GET_TARGET_SCM:
> +		return qla2x00_get_target_scm(bsg_job);
> +
> +	case QL_VND_GET_DRV_ATTR:
> +		return qla2x00_get_drv_attr(bsg_job);
> +
>   	default:
>   		return -ENOSYS;
>   	}
> diff --git a/drivers/scsi/qla2xxx/qla_bsg.h b/drivers/scsi/qla2xxx/qla_bsg.h
> index 0b308859047c..c7cf5f772ad3 100644
> --- a/drivers/scsi/qla2xxx/qla_bsg.h
> +++ b/drivers/scsi/qla2xxx/qla_bsg.h
> @@ -32,6 +32,9 @@
>   #define QL_VND_DPORT_DIAGNOSTICS	0x19
>   #define QL_VND_GET_PRIV_STATS_EX	0x1A
>   #define QL_VND_SS_GET_FLASH_IMAGE_STATUS	0x1E
> +#define QL_VND_GET_PORT_SCM		0x20
> +#define QL_VND_GET_TARGET_SCM		0x21
> +#define QL_VND_GET_DRV_ATTR		0x22
>   
>   /* BSG Vendor specific subcode returns */
>   #define EXT_STATUS_OK			0
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

-- 
Himanshu Madhani
Oracle Linux Engineering

  reply	other threads:[~2020-05-14 19:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 10:10 [PATCH 0/3] qla2xxx SAN Congestion Management (SCM) support Nilesh Javali
2020-05-14 10:10 ` [PATCH 1/3] qla2xxx: Change in PUREX to handle FPIN ELS requests Nilesh Javali
2020-05-14 17:03   ` himanshu.madhani
2020-05-15 18:52   ` James Smart
2020-05-14 10:10 ` [PATCH 2/3] qla2xxx: SAN congestion management(SCM) implementation Nilesh Javali
2020-05-14 18:52   ` himanshu.madhani
2020-05-15 22:48   ` James Smart
     [not found]     ` <CA+ihqdiA7AN05k5MjPG=o8_pf=L-La6UigY4t0emKgJMXm=hnQ@mail.gmail.com>
     [not found]       ` <BYAPR18MB2805AEA357302FCFA20D2B57B48F0@BYAPR18MB2805.namprd18.prod.outlook.com>
2020-06-11 17:42         ` Shyam Sundar
2020-06-25 23:25           ` James Smart
2020-06-26  0:14             ` Shyam Sundar
2020-07-30 16:10             ` Shyam Sundar
2020-09-21 17:48               ` James Smart
     [not found]     ` <CA+ihqdjtoA=1q7N0pg1TQDAMGo1XtNN8+XnO1qXORyqGYfpq=A@mail.gmail.com>
2020-06-11 18:10       ` Shyam S
2020-05-14 10:10 ` [PATCH 3/3] qla2xxx: Pass SCM counters to the application Nilesh Javali
2020-05-14 19:15   ` himanshu.madhani [this message]
2020-05-14 14:11 ` [PATCH 0/3] qla2xxx SAN Congestion Management (SCM) support Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1970ba0e-8c7c-3e8e-3478-10a4e7fb693d@oracle.com \
    --to=himanshu.madhani@oracle.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=njavali@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.