diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 190 |
1 files changed, 142 insertions, 48 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index b62a72dfab29..d384c16f4a87 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -219,8 +219,18 @@ lpfc_issue_lip(struct Scsi_Host *host) | |||
219 | return -ENOMEM; | 219 | return -ENOMEM; |
220 | 220 | ||
221 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); | 221 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); |
222 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, phba->cfg_link_speed); | 222 | pmboxq->mb.mbxCommand = MBX_DOWN_LINK; |
223 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); | 223 | pmboxq->mb.mbxOwner = OWN_HOST; |
224 | |||
225 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2); | ||
226 | |||
227 | if ((mbxstatus == MBX_SUCCESS) && (pmboxq->mb.mbxStatus == 0)) { | ||
228 | memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t)); | ||
229 | lpfc_init_link(phba, pmboxq, phba->cfg_topology, | ||
230 | phba->cfg_link_speed); | ||
231 | mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, | ||
232 | phba->fc_ratov * 2); | ||
233 | } | ||
224 | 234 | ||
225 | if (mbxstatus == MBX_TIMEOUT) | 235 | if (mbxstatus == MBX_TIMEOUT) |
226 | pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 236 | pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
@@ -233,51 +243,53 @@ lpfc_issue_lip(struct Scsi_Host *host) | |||
233 | return 0; | 243 | return 0; |
234 | } | 244 | } |
235 | 245 | ||
236 | static ssize_t | 246 | static int |
237 | lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) | 247 | lpfc_selective_reset(struct lpfc_hba *phba) |
238 | { | 248 | { |
239 | struct Scsi_Host *host = class_to_shost(cdev); | 249 | struct completion online_compl; |
240 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; | 250 | int status = 0; |
241 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); | 251 | |
252 | init_completion(&online_compl); | ||
253 | lpfc_workq_post_event(phba, &status, &online_compl, | ||
254 | LPFC_EVT_OFFLINE); | ||
255 | wait_for_completion(&online_compl); | ||
256 | |||
257 | if (status != 0) | ||
258 | return -EIO; | ||
259 | |||
260 | init_completion(&online_compl); | ||
261 | lpfc_workq_post_event(phba, &status, &online_compl, | ||
262 | LPFC_EVT_ONLINE); | ||
263 | wait_for_completion(&online_compl); | ||
264 | |||
265 | if (status != 0) | ||
266 | return -EIO; | ||
267 | |||
268 | return 0; | ||
242 | } | 269 | } |
243 | 270 | ||
244 | static ssize_t | 271 | static ssize_t |
245 | lpfc_board_online_show(struct class_device *cdev, char *buf) | 272 | lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count) |
246 | { | 273 | { |
247 | struct Scsi_Host *host = class_to_shost(cdev); | 274 | struct Scsi_Host *host = class_to_shost(cdev); |
248 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; | 275 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; |
276 | int status = -EINVAL; | ||
249 | 277 | ||
250 | if (phba->fc_flag & FC_OFFLINE_MODE) | 278 | if (strncmp(buf, "selective", sizeof("selective") - 1) == 0) |
251 | return snprintf(buf, PAGE_SIZE, "0\n"); | 279 | status = lpfc_selective_reset(phba); |
280 | |||
281 | if (status == 0) | ||
282 | return strlen(buf); | ||
252 | else | 283 | else |
253 | return snprintf(buf, PAGE_SIZE, "1\n"); | 284 | return status; |
254 | } | 285 | } |
255 | 286 | ||
256 | static ssize_t | 287 | static ssize_t |
257 | lpfc_board_online_store(struct class_device *cdev, const char *buf, | 288 | lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf) |
258 | size_t count) | ||
259 | { | 289 | { |
260 | struct Scsi_Host *host = class_to_shost(cdev); | 290 | struct Scsi_Host *host = class_to_shost(cdev); |
261 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; | 291 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; |
262 | struct completion online_compl; | 292 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
263 | int val=0, status=0; | ||
264 | |||
265 | if (sscanf(buf, "%d", &val) != 1) | ||
266 | return -EINVAL; | ||
267 | |||
268 | init_completion(&online_compl); | ||
269 | |||
270 | if (val) | ||
271 | lpfc_workq_post_event(phba, &status, &online_compl, | ||
272 | LPFC_EVT_ONLINE); | ||
273 | else | ||
274 | lpfc_workq_post_event(phba, &status, &online_compl, | ||
275 | LPFC_EVT_OFFLINE); | ||
276 | wait_for_completion(&online_compl); | ||
277 | if (!status) | ||
278 | return strlen(buf); | ||
279 | else | ||
280 | return -EIO; | ||
281 | } | 293 | } |
282 | 294 | ||
283 | static ssize_t | 295 | static ssize_t |
@@ -532,10 +544,9 @@ static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, | |||
532 | NULL); | 544 | NULL); |
533 | static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show, | 545 | static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show, |
534 | NULL); | 546 | NULL); |
535 | static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR, | ||
536 | lpfc_board_online_show, lpfc_board_online_store); | ||
537 | static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, | 547 | static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, |
538 | lpfc_board_mode_show, lpfc_board_mode_store); | 548 | lpfc_board_mode_show, lpfc_board_mode_store); |
549 | static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); | ||
539 | 550 | ||
540 | static int lpfc_poll = 0; | 551 | static int lpfc_poll = 0; |
541 | module_param(lpfc_poll, int, 0); | 552 | module_param(lpfc_poll, int, 0); |
@@ -695,12 +706,12 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " | |||
695 | "during discovery"); | 706 | "during discovery"); |
696 | 707 | ||
697 | /* | 708 | /* |
698 | # lpfc_max_luns: maximum number of LUNs per target driver will support | 709 | # lpfc_max_luns: maximum allowed LUN. |
699 | # Value range is [1,32768]. Default value is 256. | 710 | # Value range is [0,65535]. Default value is 255. |
700 | # NOTE: The SCSI layer will scan each target for this many luns | 711 | # NOTE: The SCSI layer might probe all allowed LUN on some old targets. |
701 | */ | 712 | */ |
702 | LPFC_ATTR_R(max_luns, 256, 1, 32768, | 713 | LPFC_ATTR_R(max_luns, 255, 0, 65535, |
703 | "Maximum number of LUNs per target driver will support"); | 714 | "Maximum allowed LUN"); |
704 | 715 | ||
705 | /* | 716 | /* |
706 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. | 717 | # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. |
@@ -739,8 +750,8 @@ struct class_device_attribute *lpfc_host_attrs[] = { | |||
739 | &class_device_attr_lpfc_max_luns, | 750 | &class_device_attr_lpfc_max_luns, |
740 | &class_device_attr_nport_evt_cnt, | 751 | &class_device_attr_nport_evt_cnt, |
741 | &class_device_attr_management_version, | 752 | &class_device_attr_management_version, |
742 | &class_device_attr_board_online, | ||
743 | &class_device_attr_board_mode, | 753 | &class_device_attr_board_mode, |
754 | &class_device_attr_issue_reset, | ||
744 | &class_device_attr_lpfc_poll, | 755 | &class_device_attr_lpfc_poll, |
745 | &class_device_attr_lpfc_poll_tmo, | 756 | &class_device_attr_lpfc_poll_tmo, |
746 | NULL, | 757 | NULL, |
@@ -873,7 +884,7 @@ sysfs_mbox_write(struct kobject *kobj, char *buf, loff_t off, size_t count) | |||
873 | phba->sysfs_mbox.mbox == NULL ) { | 884 | phba->sysfs_mbox.mbox == NULL ) { |
874 | sysfs_mbox_idle(phba); | 885 | sysfs_mbox_idle(phba); |
875 | spin_unlock_irq(host->host_lock); | 886 | spin_unlock_irq(host->host_lock); |
876 | return -EINVAL; | 887 | return -EAGAIN; |
877 | } | 888 | } |
878 | } | 889 | } |
879 | 890 | ||
@@ -989,14 +1000,15 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | |||
989 | spin_unlock_irq(phba->host->host_lock); | 1000 | spin_unlock_irq(phba->host->host_lock); |
990 | rc = lpfc_sli_issue_mbox_wait (phba, | 1001 | rc = lpfc_sli_issue_mbox_wait (phba, |
991 | phba->sysfs_mbox.mbox, | 1002 | phba->sysfs_mbox.mbox, |
992 | phba->fc_ratov * 2); | 1003 | lpfc_mbox_tmo_val(phba, |
1004 | phba->sysfs_mbox.mbox->mb.mbxCommand) * HZ); | ||
993 | spin_lock_irq(phba->host->host_lock); | 1005 | spin_lock_irq(phba->host->host_lock); |
994 | } | 1006 | } |
995 | 1007 | ||
996 | if (rc != MBX_SUCCESS) { | 1008 | if (rc != MBX_SUCCESS) { |
997 | sysfs_mbox_idle(phba); | 1009 | sysfs_mbox_idle(phba); |
998 | spin_unlock_irq(host->host_lock); | 1010 | spin_unlock_irq(host->host_lock); |
999 | return -ENODEV; | 1011 | return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV; |
1000 | } | 1012 | } |
1001 | phba->sysfs_mbox.state = SMBOX_READING; | 1013 | phba->sysfs_mbox.state = SMBOX_READING; |
1002 | } | 1014 | } |
@@ -1005,7 +1017,7 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count) | |||
1005 | printk(KERN_WARNING "mbox_read: Bad State\n"); | 1017 | printk(KERN_WARNING "mbox_read: Bad State\n"); |
1006 | sysfs_mbox_idle(phba); | 1018 | sysfs_mbox_idle(phba); |
1007 | spin_unlock_irq(host->host_lock); | 1019 | spin_unlock_irq(host->host_lock); |
1008 | return -EINVAL; | 1020 | return -EAGAIN; |
1009 | } | 1021 | } |
1010 | 1022 | ||
1011 | memcpy(buf, (uint8_t *) & phba->sysfs_mbox.mbox->mb + off, count); | 1023 | memcpy(buf, (uint8_t *) & phba->sysfs_mbox.mbox->mb + off, count); |
@@ -1199,8 +1211,10 @@ lpfc_get_stats(struct Scsi_Host *shost) | |||
1199 | struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata; | 1211 | struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata; |
1200 | struct lpfc_sli *psli = &phba->sli; | 1212 | struct lpfc_sli *psli = &phba->sli; |
1201 | struct fc_host_statistics *hs = &phba->link_stats; | 1213 | struct fc_host_statistics *hs = &phba->link_stats; |
1214 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; | ||
1202 | LPFC_MBOXQ_t *pmboxq; | 1215 | LPFC_MBOXQ_t *pmboxq; |
1203 | MAILBOX_t *pmb; | 1216 | MAILBOX_t *pmb; |
1217 | unsigned long seconds; | ||
1204 | int rc = 0; | 1218 | int rc = 0; |
1205 | 1219 | ||
1206 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 1220 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
@@ -1261,22 +1275,103 @@ lpfc_get_stats(struct Scsi_Host *shost) | |||
1261 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; | 1275 | hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt; |
1262 | hs->error_frames = pmb->un.varRdLnk.crcCnt; | 1276 | hs->error_frames = pmb->un.varRdLnk.crcCnt; |
1263 | 1277 | ||
1278 | hs->link_failure_count -= lso->link_failure_count; | ||
1279 | hs->loss_of_sync_count -= lso->loss_of_sync_count; | ||
1280 | hs->loss_of_signal_count -= lso->loss_of_signal_count; | ||
1281 | hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count; | ||
1282 | hs->invalid_tx_word_count -= lso->invalid_tx_word_count; | ||
1283 | hs->invalid_crc_count -= lso->invalid_crc_count; | ||
1284 | hs->error_frames -= lso->error_frames; | ||
1285 | |||
1264 | if (phba->fc_topology == TOPOLOGY_LOOP) { | 1286 | if (phba->fc_topology == TOPOLOGY_LOOP) { |
1265 | hs->lip_count = (phba->fc_eventTag >> 1); | 1287 | hs->lip_count = (phba->fc_eventTag >> 1); |
1288 | hs->lip_count -= lso->link_events; | ||
1266 | hs->nos_count = -1; | 1289 | hs->nos_count = -1; |
1267 | } else { | 1290 | } else { |
1268 | hs->lip_count = -1; | 1291 | hs->lip_count = -1; |
1269 | hs->nos_count = (phba->fc_eventTag >> 1); | 1292 | hs->nos_count = (phba->fc_eventTag >> 1); |
1293 | hs->nos_count -= lso->link_events; | ||
1270 | } | 1294 | } |
1271 | 1295 | ||
1272 | hs->dumped_frames = -1; | 1296 | hs->dumped_frames = -1; |
1273 | 1297 | ||
1274 | /* FIX ME */ | 1298 | seconds = get_seconds(); |
1275 | /*hs->SecondsSinceLastReset = (jiffies - lpfc_loadtime) / HZ;*/ | 1299 | if (seconds < psli->stats_start) |
1300 | hs->seconds_since_last_reset = seconds + | ||
1301 | ((unsigned long)-1 - psli->stats_start); | ||
1302 | else | ||
1303 | hs->seconds_since_last_reset = seconds - psli->stats_start; | ||
1276 | 1304 | ||
1277 | return hs; | 1305 | return hs; |
1278 | } | 1306 | } |
1279 | 1307 | ||
1308 | static void | ||
1309 | lpfc_reset_stats(struct Scsi_Host *shost) | ||
1310 | { | ||
1311 | struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata; | ||
1312 | struct lpfc_sli *psli = &phba->sli; | ||
1313 | struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets; | ||
1314 | LPFC_MBOXQ_t *pmboxq; | ||
1315 | MAILBOX_t *pmb; | ||
1316 | int rc = 0; | ||
1317 | |||
1318 | pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
1319 | if (!pmboxq) | ||
1320 | return; | ||
1321 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); | ||
1322 | |||
1323 | pmb = &pmboxq->mb; | ||
1324 | pmb->mbxCommand = MBX_READ_STATUS; | ||
1325 | pmb->mbxOwner = OWN_HOST; | ||
1326 | pmb->un.varWords[0] = 0x1; /* reset request */ | ||
1327 | pmboxq->context1 = NULL; | ||
1328 | |||
1329 | if ((phba->fc_flag & FC_OFFLINE_MODE) || | ||
1330 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) | ||
1331 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); | ||
1332 | else | ||
1333 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); | ||
1334 | |||
1335 | if (rc != MBX_SUCCESS) { | ||
1336 | if (rc == MBX_TIMEOUT) | ||
1337 | pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | ||
1338 | else | ||
1339 | mempool_free(pmboxq, phba->mbox_mem_pool); | ||
1340 | return; | ||
1341 | } | ||
1342 | |||
1343 | memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t)); | ||
1344 | pmb->mbxCommand = MBX_READ_LNK_STAT; | ||
1345 | pmb->mbxOwner = OWN_HOST; | ||
1346 | pmboxq->context1 = NULL; | ||
1347 | |||
1348 | if ((phba->fc_flag & FC_OFFLINE_MODE) || | ||
1349 | (!(psli->sli_flag & LPFC_SLI2_ACTIVE))) | ||
1350 | rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL); | ||
1351 | else | ||
1352 | rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); | ||
1353 | |||
1354 | if (rc != MBX_SUCCESS) { | ||
1355 | if (rc == MBX_TIMEOUT) | ||
1356 | pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | ||
1357 | else | ||
1358 | mempool_free( pmboxq, phba->mbox_mem_pool); | ||
1359 | return; | ||
1360 | } | ||
1361 | |||
1362 | lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt; | ||
1363 | lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt; | ||
1364 | lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt; | ||
1365 | lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt; | ||
1366 | lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord; | ||
1367 | lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt; | ||
1368 | lso->error_frames = pmb->un.varRdLnk.crcCnt; | ||
1369 | lso->link_events = (phba->fc_eventTag >> 1); | ||
1370 | |||
1371 | psli->stats_start = get_seconds(); | ||
1372 | |||
1373 | return; | ||
1374 | } | ||
1280 | 1375 | ||
1281 | /* | 1376 | /* |
1282 | * The LPFC driver treats linkdown handling as target loss events so there | 1377 | * The LPFC driver treats linkdown handling as target loss events so there |
@@ -1420,8 +1515,7 @@ struct fc_function_template lpfc_transport_functions = { | |||
1420 | */ | 1515 | */ |
1421 | 1516 | ||
1422 | .get_fc_host_stats = lpfc_get_stats, | 1517 | .get_fc_host_stats = lpfc_get_stats, |
1423 | 1518 | .reset_fc_host_stats = lpfc_reset_stats, | |
1424 | /* the LPFC driver doesn't support resetting stats yet */ | ||
1425 | 1519 | ||
1426 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), | 1520 | .dd_fcrport_size = sizeof(struct lpfc_rport_data), |
1427 | .show_rport_maxframe_size = 1, | 1521 | .show_rport_maxframe_size = 1, |