diff mbox

[11/19] qla2xxx: Add bsg interface to support statistics counter reset.

Message ID 1467818075-15246-12-git-send-email-himanshu.madhani@qlogic.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Himanshu Madhani July 6, 2016, 3:14 p.m. UTC
From: Sawan Chandak <sawan.chandak@qlogic.com>

Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
---
 drivers/scsi/qla2xxx/qla_bsg.c | 48 ++++++++++++++++++++++--------------------
 drivers/scsi/qla2xxx/qla_bsg.h |  1 +
 2 files changed, 26 insertions(+), 23 deletions(-)

Comments

kernel test robot July 6, 2016, 4:36 p.m. UTC | #1
Hi,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.7-rc6 next-20160706]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Himanshu-Madhani/qla2xxx-Patches-for-scsi-misc-branch/20160707-000429
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

   drivers/scsi/qla2xxx/qla_bsg.c: In function 'qla2x00_get_priv_stats':
>> drivers/scsi/qla2xxx/qla_bsg.c:2295:1: warning: label 'done' defined but not used [-Wunused-label]
    done:
    ^
>> drivers/scsi/qla2xxx/qla_bsg.c:2292:1: warning: label 'done_free' defined but not used [-Wunused-label]
    done_free:
    ^

vim +/done +2295 drivers/scsi/qla2xxx/qla_bsg.c

181330c1 Sawan Chandak    2016-07-06  2286  	    rval ? EXT_STATUS_MAILBOX : EXT_STATUS_OK;
243de676 Harish Zunjarrao 2016-01-27  2287  
181330c1 Sawan Chandak    2016-07-06  2288  	bsg_job->reply_len = sizeof(*bsg_job->reply);
243de676 Harish Zunjarrao 2016-01-27  2289  	bsg_job->reply->result = DID_OK << 16;
243de676 Harish Zunjarrao 2016-01-27  2290  	bsg_job->job_done(bsg_job);
243de676 Harish Zunjarrao 2016-01-27  2291  
243de676 Harish Zunjarrao 2016-01-27 @2292  done_free:
181330c1 Sawan Chandak    2016-07-06  2293  	dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
243de676 Harish Zunjarrao 2016-01-27  2294  		stats, stats_dma);
243de676 Harish Zunjarrao 2016-01-27 @2295  done:
181330c1 Sawan Chandak    2016-07-06  2296  	return 0;
243de676 Harish Zunjarrao 2016-01-27  2297  }
243de676 Harish Zunjarrao 2016-01-27  2298  

:::::: The code at line 2295 was first introduced by commit
:::::: 243de6768db50266f595ec62c5ae34783edb72ea qla2xxx: Add support for Private link statistics counters.

:::::: TO: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
:::::: CC: Martin K. Petersen <martin.petersen@oracle.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Hannes Reinecke July 15, 2016, 12:56 p.m. UTC | #2
On 07/06/2016 05:14 PM, Himanshu Madhani wrote:
> From: Sawan Chandak <sawan.chandak@qlogic.com>
> 
> Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
> Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
> ---
>  drivers/scsi/qla2xxx/qla_bsg.c | 48 ++++++++++++++++++++++--------------------
>  drivers/scsi/qla2xxx/qla_bsg.h |  1 +
>  2 files changed, 26 insertions(+), 23 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
diff mbox

Patch

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 592e924..8a953aa 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -2246,53 +2246,54 @@  qla2x00_get_priv_stats(struct fc_bsg_job *bsg_job)
 	struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
 	struct link_statistics *stats = NULL;
 	dma_addr_t stats_dma;
-	int rval = QLA_FUNCTION_FAILED;
+	int rval;
+	uint32_t *cmd = bsg_job->request->rqst_data.h_vendor.vendor_cmd;
+	uint options = cmd[0] == QL_VND_GET_PRIV_STATS_EX ? cmd[1] : 0;
 
 	if (test_bit(UNLOADING, &vha->dpc_flags))
-		goto done;
+		return -ENODEV;
 
 	if (unlikely(pci_channel_offline(ha->pdev)))
-		goto done;
+		return -ENODEV;
 
 	if (qla2x00_reset_active(vha))
-		goto done;
+		return -EBUSY;
 
 	if (!IS_FWI2_CAPABLE(ha))
-		goto done;
+		return -EPERM;
 
 	stats = dma_alloc_coherent(&ha->pdev->dev,
-		sizeof(struct link_statistics), &stats_dma, GFP_KERNEL);
+		sizeof(*stats), &stats_dma, GFP_KERNEL);
 	if (!stats) {
 		ql_log(ql_log_warn, vha, 0x70e2,
-		"Failed to allocate memory for stats.\n");
-		goto done;
+		    "Failed to allocate memory for stats.\n");
+		return -ENOMEM;
 	}
 
-	memset(stats, 0, sizeof(struct link_statistics));
-
-	rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, 0);
-
-	if (rval != QLA_SUCCESS)
-		goto done_free;
+	memset(stats, 0, sizeof(*stats));
 
-	ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, vha, 0x70e3,
-	    (uint8_t *)stats, sizeof(struct link_statistics));
+	rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, options);
 
-	sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
-	bsg_job->reply_payload.sg_cnt, stats, sizeof(struct link_statistics));
-	bsg_job->reply->reply_payload_rcv_len = sizeof(struct link_statistics);
+	if (rval == QLA_SUCCESS) {
+		ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, vha, 0x70e3,
+		    (uint8_t *)stats, sizeof(*stats));
+		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
+			bsg_job->reply_payload.sg_cnt, stats, sizeof(*stats));
+	}
 
-	bsg_job->reply->reply_data.vendor_reply.vendor_rsp[0] = EXT_STATUS_OK;
+	bsg_job->reply->reply_payload_rcv_len = sizeof(*stats);
+	bsg_job->reply->reply_data.vendor_reply.vendor_rsp[0] =
+	    rval ? EXT_STATUS_MAILBOX : EXT_STATUS_OK;
 
-	bsg_job->reply_len = sizeof(struct fc_bsg_reply);
+	bsg_job->reply_len = sizeof(*bsg_job->reply);
 	bsg_job->reply->result = DID_OK << 16;
 	bsg_job->job_done(bsg_job);
 
 done_free:
-	dma_free_coherent(&ha->pdev->dev, sizeof(struct link_statistics),
+	dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
 		stats, stats_dma);
 done:
-	return rval;
+	return 0;
 }
 
 static int
@@ -2401,6 +2402,7 @@  qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job)
 		return qla27xx_get_bbcr_data(bsg_job);
 
 	case QL_VND_GET_PRIV_STATS:
+	case QL_VND_GET_PRIV_STATS_EX:
 		return qla2x00_get_priv_stats(bsg_job);
 
 	case QL_VND_DPORT_DIAGNOSTICS:
diff --git a/drivers/scsi/qla2xxx/qla_bsg.h b/drivers/scsi/qla2xxx/qla_bsg.h
index 3b1045f..d97dfd5 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.h
+++ b/drivers/scsi/qla2xxx/qla_bsg.h
@@ -30,6 +30,7 @@ 
 #define QL_VND_GET_BBCR_DATA    0x17
 #define QL_VND_GET_PRIV_STATS	0x18
 #define QL_VND_DPORT_DIAGNOSTICS	0x19
+#define QL_VND_GET_PRIV_STATS_EX	0x1A
 
 /* BSG Vendor specific subcode returns */
 #define EXT_STATUS_OK			0