diff options
author | Sawan Chandak <sawan.chandak@qlogic.com> | 2016-07-06 11:14:27 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-07-15 15:35:37 -0400 |
commit | 8437dda036da5dc839455b5281bd7eac5751765b (patch) | |
tree | 2df0c3b0b1044ab9be95aa32c614856f53ab5d1f | |
parent | ec89146215d124c429bff84b498dccdc4919ffa7 (diff) |
qla2xxx: Add bsg interface to support statistics counter reset.
[mkp: Folded in compile fix]
Signed-off-by: Sawan Chandak <sawan.chandak@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/qla2xxx/qla_bsg.c | 51 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_bsg.h | 1 |
2 files changed, 27 insertions, 25 deletions
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 592e9249db02..643014f82f7d 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c | |||
@@ -2246,53 +2246,53 @@ qla2x00_get_priv_stats(struct fc_bsg_job *bsg_job) | |||
2246 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); | 2246 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
2247 | struct link_statistics *stats = NULL; | 2247 | struct link_statistics *stats = NULL; |
2248 | dma_addr_t stats_dma; | 2248 | dma_addr_t stats_dma; |
2249 | int rval = QLA_FUNCTION_FAILED; | 2249 | int rval; |
2250 | uint32_t *cmd = bsg_job->request->rqst_data.h_vendor.vendor_cmd; | ||
2251 | uint options = cmd[0] == QL_VND_GET_PRIV_STATS_EX ? cmd[1] : 0; | ||
2250 | 2252 | ||
2251 | if (test_bit(UNLOADING, &vha->dpc_flags)) | 2253 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
2252 | goto done; | 2254 | return -ENODEV; |
2253 | 2255 | ||
2254 | if (unlikely(pci_channel_offline(ha->pdev))) | 2256 | if (unlikely(pci_channel_offline(ha->pdev))) |
2255 | goto done; | 2257 | return -ENODEV; |
2256 | 2258 | ||
2257 | if (qla2x00_reset_active(vha)) | 2259 | if (qla2x00_reset_active(vha)) |
2258 | goto done; | 2260 | return -EBUSY; |
2259 | 2261 | ||
2260 | if (!IS_FWI2_CAPABLE(ha)) | 2262 | if (!IS_FWI2_CAPABLE(ha)) |
2261 | goto done; | 2263 | return -EPERM; |
2262 | 2264 | ||
2263 | stats = dma_alloc_coherent(&ha->pdev->dev, | 2265 | stats = dma_alloc_coherent(&ha->pdev->dev, |
2264 | sizeof(struct link_statistics), &stats_dma, GFP_KERNEL); | 2266 | sizeof(*stats), &stats_dma, GFP_KERNEL); |
2265 | if (!stats) { | 2267 | if (!stats) { |
2266 | ql_log(ql_log_warn, vha, 0x70e2, | 2268 | ql_log(ql_log_warn, vha, 0x70e2, |
2267 | "Failed to allocate memory for stats.\n"); | 2269 | "Failed to allocate memory for stats.\n"); |
2268 | goto done; | 2270 | return -ENOMEM; |
2269 | } | 2271 | } |
2270 | 2272 | ||
2271 | memset(stats, 0, sizeof(struct link_statistics)); | 2273 | memset(stats, 0, sizeof(*stats)); |
2272 | 2274 | ||
2273 | rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, 0); | 2275 | rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, options); |
2274 | 2276 | ||
2275 | if (rval != QLA_SUCCESS) | 2277 | if (rval == QLA_SUCCESS) { |
2276 | goto done_free; | 2278 | ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, vha, 0x70e3, |
2277 | 2279 | (uint8_t *)stats, sizeof(*stats)); | |
2278 | ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, vha, 0x70e3, | 2280 | sg_copy_from_buffer(bsg_job->reply_payload.sg_list, |
2279 | (uint8_t *)stats, sizeof(struct link_statistics)); | 2281 | bsg_job->reply_payload.sg_cnt, stats, sizeof(*stats)); |
2280 | 2282 | } | |
2281 | sg_copy_from_buffer(bsg_job->reply_payload.sg_list, | ||
2282 | bsg_job->reply_payload.sg_cnt, stats, sizeof(struct link_statistics)); | ||
2283 | bsg_job->reply->reply_payload_rcv_len = sizeof(struct link_statistics); | ||
2284 | 2283 | ||
2285 | bsg_job->reply->reply_data.vendor_reply.vendor_rsp[0] = EXT_STATUS_OK; | 2284 | bsg_job->reply->reply_payload_rcv_len = sizeof(*stats); |
2285 | bsg_job->reply->reply_data.vendor_reply.vendor_rsp[0] = | ||
2286 | rval ? EXT_STATUS_MAILBOX : EXT_STATUS_OK; | ||
2286 | 2287 | ||
2287 | bsg_job->reply_len = sizeof(struct fc_bsg_reply); | 2288 | bsg_job->reply_len = sizeof(*bsg_job->reply); |
2288 | bsg_job->reply->result = DID_OK << 16; | 2289 | bsg_job->reply->result = DID_OK << 16; |
2289 | bsg_job->job_done(bsg_job); | 2290 | bsg_job->job_done(bsg_job); |
2290 | 2291 | ||
2291 | done_free: | 2292 | dma_free_coherent(&ha->pdev->dev, sizeof(*stats), |
2292 | dma_free_coherent(&ha->pdev->dev, sizeof(struct link_statistics), | ||
2293 | stats, stats_dma); | 2293 | stats, stats_dma); |
2294 | done: | 2294 | |
2295 | return rval; | 2295 | return 0; |
2296 | } | 2296 | } |
2297 | 2297 | ||
2298 | static int | 2298 | static int |
@@ -2401,6 +2401,7 @@ qla2x00_process_vendor_specific(struct fc_bsg_job *bsg_job) | |||
2401 | return qla27xx_get_bbcr_data(bsg_job); | 2401 | return qla27xx_get_bbcr_data(bsg_job); |
2402 | 2402 | ||
2403 | case QL_VND_GET_PRIV_STATS: | 2403 | case QL_VND_GET_PRIV_STATS: |
2404 | case QL_VND_GET_PRIV_STATS_EX: | ||
2404 | return qla2x00_get_priv_stats(bsg_job); | 2405 | return qla2x00_get_priv_stats(bsg_job); |
2405 | 2406 | ||
2406 | case QL_VND_DPORT_DIAGNOSTICS: | 2407 | case QL_VND_DPORT_DIAGNOSTICS: |
diff --git a/drivers/scsi/qla2xxx/qla_bsg.h b/drivers/scsi/qla2xxx/qla_bsg.h index 3b1045f95d6f..d97dfd521356 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.h +++ b/drivers/scsi/qla2xxx/qla_bsg.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #define QL_VND_GET_BBCR_DATA 0x17 | 30 | #define QL_VND_GET_BBCR_DATA 0x17 |
31 | #define QL_VND_GET_PRIV_STATS 0x18 | 31 | #define QL_VND_GET_PRIV_STATS 0x18 |
32 | #define QL_VND_DPORT_DIAGNOSTICS 0x19 | 32 | #define QL_VND_DPORT_DIAGNOSTICS 0x19 |
33 | #define QL_VND_GET_PRIV_STATS_EX 0x1A | ||
33 | 34 | ||
34 | /* BSG Vendor specific subcode returns */ | 35 | /* BSG Vendor specific subcode returns */ |
35 | #define EXT_STATUS_OK 0 | 36 | #define EXT_STATUS_OK 0 |