diff options
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_init.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_init.c | 516 |
1 files changed, 247 insertions, 269 deletions
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index dcf6106f557a..dcb4ba0ecee1 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************* |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2006 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2007 Emulex. All rights reserved. * |
5 | * EMULEX and SLI are trademarks of Emulex. * | 5 | * EMULEX and SLI are trademarks of Emulex. * |
6 | * www.emulex.com * | 6 | * www.emulex.com * |
7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * | 7 | * Portions Copyright (C) 2004-2005 Christoph Hellwig * |
@@ -386,12 +386,12 @@ lpfc_config_port_post(struct lpfc_hba * phba) | |||
386 | * Setup the ring 0 (els) timeout handler | 386 | * Setup the ring 0 (els) timeout handler |
387 | */ | 387 | */ |
388 | timeout = phba->fc_ratov << 1; | 388 | timeout = phba->fc_ratov << 1; |
389 | phba->els_tmofunc.expires = jiffies + HZ * timeout; | 389 | mod_timer(&phba->els_tmofunc, jiffies + HZ * timeout); |
390 | add_timer(&phba->els_tmofunc); | ||
391 | 390 | ||
392 | lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); | 391 | lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); |
393 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; | 392 | pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; |
394 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); | 393 | rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); |
394 | lpfc_set_loopback_flag(phba); | ||
395 | if (rc != MBX_SUCCESS) { | 395 | if (rc != MBX_SUCCESS) { |
396 | lpfc_printf_log(phba, | 396 | lpfc_printf_log(phba, |
397 | KERN_ERR, | 397 | KERN_ERR, |
@@ -418,33 +418,6 @@ lpfc_config_port_post(struct lpfc_hba * phba) | |||
418 | return (0); | 418 | return (0); |
419 | } | 419 | } |
420 | 420 | ||
421 | static int | ||
422 | lpfc_discovery_wait(struct lpfc_hba *phba) | ||
423 | { | ||
424 | int i = 0; | ||
425 | |||
426 | while ((phba->hba_state != LPFC_HBA_READY) || | ||
427 | (phba->num_disc_nodes) || (phba->fc_prli_sent) || | ||
428 | ((phba->fc_map_cnt == 0) && (i<2)) || | ||
429 | (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) { | ||
430 | /* Check every second for 30 retries. */ | ||
431 | i++; | ||
432 | if (i > 30) { | ||
433 | return -ETIMEDOUT; | ||
434 | } | ||
435 | if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) { | ||
436 | /* The link is down. Set linkdown timeout */ | ||
437 | return -ETIMEDOUT; | ||
438 | } | ||
439 | |||
440 | /* Delay for 1 second to give discovery time to complete. */ | ||
441 | msleep(1000); | ||
442 | |||
443 | } | ||
444 | |||
445 | return 0; | ||
446 | } | ||
447 | |||
448 | /************************************************************************/ | 421 | /************************************************************************/ |
449 | /* */ | 422 | /* */ |
450 | /* lpfc_hba_down_prep */ | 423 | /* lpfc_hba_down_prep */ |
@@ -550,12 +523,15 @@ lpfc_handle_eratt(struct lpfc_hba * phba) | |||
550 | * There was a firmware error. Take the hba offline and then | 523 | * There was a firmware error. Take the hba offline and then |
551 | * attempt to restart it. | 524 | * attempt to restart it. |
552 | */ | 525 | */ |
526 | lpfc_offline_prep(phba); | ||
553 | lpfc_offline(phba); | 527 | lpfc_offline(phba); |
554 | lpfc_sli_brdrestart(phba); | 528 | lpfc_sli_brdrestart(phba); |
555 | if (lpfc_online(phba) == 0) { /* Initialize the HBA */ | 529 | if (lpfc_online(phba) == 0) { /* Initialize the HBA */ |
556 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); | 530 | mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); |
531 | lpfc_unblock_mgmt_io(phba); | ||
557 | return; | 532 | return; |
558 | } | 533 | } |
534 | lpfc_unblock_mgmt_io(phba); | ||
559 | } else { | 535 | } else { |
560 | /* The if clause above forces this code path when the status | 536 | /* The if clause above forces this code path when the status |
561 | * failure is a value other than FFER6. Do not call the offline | 537 | * failure is a value other than FFER6. Do not call the offline |
@@ -573,7 +549,9 @@ lpfc_handle_eratt(struct lpfc_hba * phba) | |||
573 | SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); | 549 | SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); |
574 | 550 | ||
575 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; | 551 | psli->sli_flag &= ~LPFC_SLI2_ACTIVE; |
552 | lpfc_offline_prep(phba); | ||
576 | lpfc_offline(phba); | 553 | lpfc_offline(phba); |
554 | lpfc_unblock_mgmt_io(phba); | ||
577 | phba->hba_state = LPFC_HBA_ERROR; | 555 | phba->hba_state = LPFC_HBA_ERROR; |
578 | lpfc_hba_down_post(phba); | 556 | lpfc_hba_down_post(phba); |
579 | } | 557 | } |
@@ -633,7 +611,7 @@ lpfc_handle_latt_free_mbuf: | |||
633 | lpfc_handle_latt_free_mp: | 611 | lpfc_handle_latt_free_mp: |
634 | kfree(mp); | 612 | kfree(mp); |
635 | lpfc_handle_latt_free_pmb: | 613 | lpfc_handle_latt_free_pmb: |
636 | kfree(pmb); | 614 | mempool_free(pmb, phba->mbox_mem_pool); |
637 | lpfc_handle_latt_err_exit: | 615 | lpfc_handle_latt_err_exit: |
638 | /* Enable Link attention interrupts */ | 616 | /* Enable Link attention interrupts */ |
639 | spin_lock_irq(phba->host->host_lock); | 617 | spin_lock_irq(phba->host->host_lock); |
@@ -925,6 +903,24 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) | |||
925 | m = (typeof(m)){"LPe11000-S", max_speed, | 903 | m = (typeof(m)){"LPe11000-S", max_speed, |
926 | "PCIe"}; | 904 | "PCIe"}; |
927 | break; | 905 | break; |
906 | case PCI_DEVICE_ID_SAT: | ||
907 | m = (typeof(m)){"LPe12000", max_speed, "PCIe"}; | ||
908 | break; | ||
909 | case PCI_DEVICE_ID_SAT_MID: | ||
910 | m = (typeof(m)){"LPe1250", max_speed, "PCIe"}; | ||
911 | break; | ||
912 | case PCI_DEVICE_ID_SAT_SMB: | ||
913 | m = (typeof(m)){"LPe121", max_speed, "PCIe"}; | ||
914 | break; | ||
915 | case PCI_DEVICE_ID_SAT_DCSP: | ||
916 | m = (typeof(m)){"LPe12002-SP", max_speed, "PCIe"}; | ||
917 | break; | ||
918 | case PCI_DEVICE_ID_SAT_SCSP: | ||
919 | m = (typeof(m)){"LPe12000-SP", max_speed, "PCIe"}; | ||
920 | break; | ||
921 | case PCI_DEVICE_ID_SAT_S: | ||
922 | m = (typeof(m)){"LPe12000-S", max_speed, "PCIe"}; | ||
923 | break; | ||
928 | default: | 924 | default: |
929 | m = (typeof(m)){ NULL }; | 925 | m = (typeof(m)){ NULL }; |
930 | break; | 926 | break; |
@@ -1174,69 +1170,17 @@ lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit) | |||
1174 | } | 1170 | } |
1175 | 1171 | ||
1176 | static void | 1172 | static void |
1177 | lpfc_cleanup(struct lpfc_hba * phba, uint32_t save_bind) | 1173 | lpfc_cleanup(struct lpfc_hba * phba) |
1178 | { | 1174 | { |
1179 | struct lpfc_nodelist *ndlp, *next_ndlp; | 1175 | struct lpfc_nodelist *ndlp, *next_ndlp; |
1180 | 1176 | ||
1181 | /* clean up phba - lpfc specific */ | 1177 | /* clean up phba - lpfc specific */ |
1182 | lpfc_can_disctmo(phba); | 1178 | lpfc_can_disctmo(phba); |
1183 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list, | 1179 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) |
1184 | nlp_listp) { | 1180 | lpfc_nlp_put(ndlp); |
1185 | lpfc_nlp_remove(phba, ndlp); | ||
1186 | } | ||
1187 | 1181 | ||
1188 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list, | 1182 | INIT_LIST_HEAD(&phba->fc_nodes); |
1189 | nlp_listp) { | ||
1190 | lpfc_nlp_remove(phba, ndlp); | ||
1191 | } | ||
1192 | |||
1193 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, | ||
1194 | nlp_listp) { | ||
1195 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | ||
1196 | } | ||
1197 | |||
1198 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list, | ||
1199 | nlp_listp) { | ||
1200 | lpfc_nlp_remove(phba, ndlp); | ||
1201 | } | ||
1202 | |||
1203 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list, | ||
1204 | nlp_listp) { | ||
1205 | lpfc_nlp_remove(phba, ndlp); | ||
1206 | } | ||
1207 | |||
1208 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list, | ||
1209 | nlp_listp) { | ||
1210 | lpfc_nlp_remove(phba, ndlp); | ||
1211 | } | ||
1212 | 1183 | ||
1213 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list, | ||
1214 | nlp_listp) { | ||
1215 | lpfc_nlp_remove(phba, ndlp); | ||
1216 | } | ||
1217 | |||
1218 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, | ||
1219 | nlp_listp) { | ||
1220 | lpfc_nlp_remove(phba, ndlp); | ||
1221 | } | ||
1222 | |||
1223 | INIT_LIST_HEAD(&phba->fc_nlpmap_list); | ||
1224 | INIT_LIST_HEAD(&phba->fc_nlpunmap_list); | ||
1225 | INIT_LIST_HEAD(&phba->fc_unused_list); | ||
1226 | INIT_LIST_HEAD(&phba->fc_plogi_list); | ||
1227 | INIT_LIST_HEAD(&phba->fc_adisc_list); | ||
1228 | INIT_LIST_HEAD(&phba->fc_reglogin_list); | ||
1229 | INIT_LIST_HEAD(&phba->fc_prli_list); | ||
1230 | INIT_LIST_HEAD(&phba->fc_npr_list); | ||
1231 | |||
1232 | phba->fc_map_cnt = 0; | ||
1233 | phba->fc_unmap_cnt = 0; | ||
1234 | phba->fc_plogi_cnt = 0; | ||
1235 | phba->fc_adisc_cnt = 0; | ||
1236 | phba->fc_reglogin_cnt = 0; | ||
1237 | phba->fc_prli_cnt = 0; | ||
1238 | phba->fc_npr_cnt = 0; | ||
1239 | phba->fc_unused_cnt= 0; | ||
1240 | return; | 1184 | return; |
1241 | } | 1185 | } |
1242 | 1186 | ||
@@ -1262,21 +1206,6 @@ lpfc_stop_timer(struct lpfc_hba * phba) | |||
1262 | { | 1206 | { |
1263 | struct lpfc_sli *psli = &phba->sli; | 1207 | struct lpfc_sli *psli = &phba->sli; |
1264 | 1208 | ||
1265 | /* Instead of a timer, this has been converted to a | ||
1266 | * deferred procedding list. | ||
1267 | */ | ||
1268 | while (!list_empty(&phba->freebufList)) { | ||
1269 | |||
1270 | struct lpfc_dmabuf *mp = NULL; | ||
1271 | |||
1272 | list_remove_head((&phba->freebufList), mp, | ||
1273 | struct lpfc_dmabuf, list); | ||
1274 | if (mp) { | ||
1275 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | ||
1276 | kfree(mp); | ||
1277 | } | ||
1278 | } | ||
1279 | |||
1280 | del_timer_sync(&phba->fcp_poll_timer); | 1209 | del_timer_sync(&phba->fcp_poll_timer); |
1281 | del_timer_sync(&phba->fc_estabtmo); | 1210 | del_timer_sync(&phba->fc_estabtmo); |
1282 | del_timer_sync(&phba->fc_disctmo); | 1211 | del_timer_sync(&phba->fc_disctmo); |
@@ -1302,60 +1231,76 @@ lpfc_online(struct lpfc_hba * phba) | |||
1302 | "%d:0458 Bring Adapter online\n", | 1231 | "%d:0458 Bring Adapter online\n", |
1303 | phba->brd_no); | 1232 | phba->brd_no); |
1304 | 1233 | ||
1305 | if (!lpfc_sli_queue_setup(phba)) | 1234 | lpfc_block_mgmt_io(phba); |
1235 | |||
1236 | if (!lpfc_sli_queue_setup(phba)) { | ||
1237 | lpfc_unblock_mgmt_io(phba); | ||
1306 | return 1; | 1238 | return 1; |
1239 | } | ||
1307 | 1240 | ||
1308 | if (lpfc_sli_hba_setup(phba)) /* Initialize the HBA */ | 1241 | if (lpfc_sli_hba_setup(phba)) { /* Initialize the HBA */ |
1242 | lpfc_unblock_mgmt_io(phba); | ||
1309 | return 1; | 1243 | return 1; |
1244 | } | ||
1310 | 1245 | ||
1311 | spin_lock_irq(phba->host->host_lock); | 1246 | spin_lock_irq(phba->host->host_lock); |
1312 | phba->fc_flag &= ~FC_OFFLINE_MODE; | 1247 | phba->fc_flag &= ~FC_OFFLINE_MODE; |
1313 | spin_unlock_irq(phba->host->host_lock); | 1248 | spin_unlock_irq(phba->host->host_lock); |
1314 | 1249 | ||
1250 | lpfc_unblock_mgmt_io(phba); | ||
1315 | return 0; | 1251 | return 0; |
1316 | } | 1252 | } |
1317 | 1253 | ||
1318 | int | 1254 | void |
1319 | lpfc_offline(struct lpfc_hba * phba) | 1255 | lpfc_block_mgmt_io(struct lpfc_hba * phba) |
1320 | { | 1256 | { |
1321 | struct lpfc_sli_ring *pring; | ||
1322 | struct lpfc_sli *psli; | ||
1323 | unsigned long iflag; | 1257 | unsigned long iflag; |
1324 | int i; | ||
1325 | int cnt = 0; | ||
1326 | 1258 | ||
1327 | if (!phba) | 1259 | spin_lock_irqsave(phba->host->host_lock, iflag); |
1328 | return 0; | 1260 | phba->fc_flag |= FC_BLOCK_MGMT_IO; |
1261 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | ||
1262 | } | ||
1263 | |||
1264 | void | ||
1265 | lpfc_unblock_mgmt_io(struct lpfc_hba * phba) | ||
1266 | { | ||
1267 | unsigned long iflag; | ||
1268 | |||
1269 | spin_lock_irqsave(phba->host->host_lock, iflag); | ||
1270 | phba->fc_flag &= ~FC_BLOCK_MGMT_IO; | ||
1271 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | ||
1272 | } | ||
1273 | |||
1274 | void | ||
1275 | lpfc_offline_prep(struct lpfc_hba * phba) | ||
1276 | { | ||
1277 | struct lpfc_nodelist *ndlp, *next_ndlp; | ||
1329 | 1278 | ||
1330 | if (phba->fc_flag & FC_OFFLINE_MODE) | 1279 | if (phba->fc_flag & FC_OFFLINE_MODE) |
1331 | return 0; | 1280 | return; |
1332 | 1281 | ||
1333 | psli = &phba->sli; | 1282 | lpfc_block_mgmt_io(phba); |
1334 | 1283 | ||
1335 | lpfc_linkdown(phba); | 1284 | lpfc_linkdown(phba); |
1285 | |||
1286 | /* Issue an unreg_login to all nodes */ | ||
1287 | list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) | ||
1288 | if (ndlp->nlp_state != NLP_STE_UNUSED_NODE) | ||
1289 | lpfc_unreg_rpi(phba, ndlp); | ||
1290 | |||
1336 | lpfc_sli_flush_mbox_queue(phba); | 1291 | lpfc_sli_flush_mbox_queue(phba); |
1292 | } | ||
1337 | 1293 | ||
1338 | for (i = 0; i < psli->num_rings; i++) { | 1294 | void |
1339 | pring = &psli->ring[i]; | 1295 | lpfc_offline(struct lpfc_hba * phba) |
1340 | /* The linkdown event takes 30 seconds to timeout. */ | 1296 | { |
1341 | while (pring->txcmplq_cnt) { | 1297 | unsigned long iflag; |
1342 | mdelay(10); | ||
1343 | if (cnt++ > 3000) { | ||
1344 | lpfc_printf_log(phba, | ||
1345 | KERN_WARNING, LOG_INIT, | ||
1346 | "%d:0466 Outstanding IO when " | ||
1347 | "bringing Adapter offline\n", | ||
1348 | phba->brd_no); | ||
1349 | break; | ||
1350 | } | ||
1351 | } | ||
1352 | } | ||
1353 | 1298 | ||
1299 | if (phba->fc_flag & FC_OFFLINE_MODE) | ||
1300 | return; | ||
1354 | 1301 | ||
1355 | /* stop all timers associated with this hba */ | 1302 | /* stop all timers associated with this hba */ |
1356 | lpfc_stop_timer(phba); | 1303 | lpfc_stop_timer(phba); |
1357 | phba->work_hba_events = 0; | ||
1358 | phba->work_ha = 0; | ||
1359 | 1304 | ||
1360 | lpfc_printf_log(phba, | 1305 | lpfc_printf_log(phba, |
1361 | KERN_WARNING, | 1306 | KERN_WARNING, |
@@ -1366,11 +1311,12 @@ lpfc_offline(struct lpfc_hba * phba) | |||
1366 | /* Bring down the SLI Layer and cleanup. The HBA is offline | 1311 | /* Bring down the SLI Layer and cleanup. The HBA is offline |
1367 | now. */ | 1312 | now. */ |
1368 | lpfc_sli_hba_down(phba); | 1313 | lpfc_sli_hba_down(phba); |
1369 | lpfc_cleanup(phba, 1); | 1314 | lpfc_cleanup(phba); |
1370 | spin_lock_irqsave(phba->host->host_lock, iflag); | 1315 | spin_lock_irqsave(phba->host->host_lock, iflag); |
1316 | phba->work_hba_events = 0; | ||
1317 | phba->work_ha = 0; | ||
1371 | phba->fc_flag |= FC_OFFLINE_MODE; | 1318 | phba->fc_flag |= FC_OFFLINE_MODE; |
1372 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | 1319 | spin_unlock_irqrestore(phba->host->host_lock, iflag); |
1373 | return 0; | ||
1374 | } | 1320 | } |
1375 | 1321 | ||
1376 | /****************************************************************************** | 1322 | /****************************************************************************** |
@@ -1407,6 +1353,156 @@ lpfc_scsi_free(struct lpfc_hba * phba) | |||
1407 | return 0; | 1353 | return 0; |
1408 | } | 1354 | } |
1409 | 1355 | ||
1356 | void lpfc_remove_device(struct lpfc_hba *phba) | ||
1357 | { | ||
1358 | unsigned long iflag; | ||
1359 | |||
1360 | lpfc_free_sysfs_attr(phba); | ||
1361 | |||
1362 | spin_lock_irqsave(phba->host->host_lock, iflag); | ||
1363 | phba->fc_flag |= FC_UNLOADING; | ||
1364 | |||
1365 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | ||
1366 | |||
1367 | fc_remove_host(phba->host); | ||
1368 | scsi_remove_host(phba->host); | ||
1369 | |||
1370 | kthread_stop(phba->worker_thread); | ||
1371 | |||
1372 | /* | ||
1373 | * Bring down the SLI Layer. This step disable all interrupts, | ||
1374 | * clears the rings, discards all mailbox commands, and resets | ||
1375 | * the HBA. | ||
1376 | */ | ||
1377 | lpfc_sli_hba_down(phba); | ||
1378 | lpfc_sli_brdrestart(phba); | ||
1379 | |||
1380 | /* Release the irq reservation */ | ||
1381 | free_irq(phba->pcidev->irq, phba); | ||
1382 | pci_disable_msi(phba->pcidev); | ||
1383 | |||
1384 | lpfc_cleanup(phba); | ||
1385 | lpfc_stop_timer(phba); | ||
1386 | phba->work_hba_events = 0; | ||
1387 | |||
1388 | /* | ||
1389 | * Call scsi_free before mem_free since scsi bufs are released to their | ||
1390 | * corresponding pools here. | ||
1391 | */ | ||
1392 | lpfc_scsi_free(phba); | ||
1393 | lpfc_mem_free(phba); | ||
1394 | |||
1395 | /* Free resources associated with SLI2 interface */ | ||
1396 | dma_free_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE, | ||
1397 | phba->slim2p, phba->slim2p_mapping); | ||
1398 | |||
1399 | /* unmap adapter SLIM and Control Registers */ | ||
1400 | iounmap(phba->ctrl_regs_memmap_p); | ||
1401 | iounmap(phba->slim_memmap_p); | ||
1402 | |||
1403 | pci_release_regions(phba->pcidev); | ||
1404 | pci_disable_device(phba->pcidev); | ||
1405 | |||
1406 | idr_remove(&lpfc_hba_index, phba->brd_no); | ||
1407 | scsi_host_put(phba->host); | ||
1408 | } | ||
1409 | |||
1410 | void lpfc_scan_start(struct Scsi_Host *host) | ||
1411 | { | ||
1412 | struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; | ||
1413 | |||
1414 | if (lpfc_alloc_sysfs_attr(phba)) | ||
1415 | goto error; | ||
1416 | |||
1417 | phba->MBslimaddr = phba->slim_memmap_p; | ||
1418 | phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | ||
1419 | phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | ||
1420 | phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | ||
1421 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | ||
1422 | |||
1423 | if (lpfc_sli_hba_setup(phba)) | ||
1424 | goto error; | ||
1425 | |||
1426 | /* | ||
1427 | * hba setup may have changed the hba_queue_depth so we need to adjust | ||
1428 | * the value of can_queue. | ||
1429 | */ | ||
1430 | host->can_queue = phba->cfg_hba_queue_depth - 10; | ||
1431 | return; | ||
1432 | |||
1433 | error: | ||
1434 | lpfc_remove_device(phba); | ||
1435 | } | ||
1436 | |||
1437 | int lpfc_scan_finished(struct Scsi_Host *shost, unsigned long time) | ||
1438 | { | ||
1439 | struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata; | ||
1440 | |||
1441 | if (!phba->host) | ||
1442 | return 1; | ||
1443 | if (time >= 30 * HZ) | ||
1444 | goto finished; | ||
1445 | |||
1446 | if (phba->hba_state != LPFC_HBA_READY) | ||
1447 | return 0; | ||
1448 | if (phba->num_disc_nodes || phba->fc_prli_sent) | ||
1449 | return 0; | ||
1450 | if ((phba->fc_map_cnt == 0) && (time < 2 * HZ)) | ||
1451 | return 0; | ||
1452 | if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) | ||
1453 | return 0; | ||
1454 | if ((phba->hba_state > LPFC_LINK_DOWN) || (time < 15 * HZ)) | ||
1455 | return 0; | ||
1456 | |||
1457 | finished: | ||
1458 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { | ||
1459 | spin_lock_irq(shost->host_lock); | ||
1460 | lpfc_poll_start_timer(phba); | ||
1461 | spin_unlock_irq(shost->host_lock); | ||
1462 | } | ||
1463 | |||
1464 | /* | ||
1465 | * set fixed host attributes | ||
1466 | * Must done after lpfc_sli_hba_setup() | ||
1467 | */ | ||
1468 | |||
1469 | fc_host_node_name(shost) = wwn_to_u64(phba->fc_nodename.u.wwn); | ||
1470 | fc_host_port_name(shost) = wwn_to_u64(phba->fc_portname.u.wwn); | ||
1471 | fc_host_supported_classes(shost) = FC_COS_CLASS3; | ||
1472 | |||
1473 | memset(fc_host_supported_fc4s(shost), 0, | ||
1474 | sizeof(fc_host_supported_fc4s(shost))); | ||
1475 | fc_host_supported_fc4s(shost)[2] = 1; | ||
1476 | fc_host_supported_fc4s(shost)[7] = 1; | ||
1477 | |||
1478 | lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(shost)); | ||
1479 | |||
1480 | fc_host_supported_speeds(shost) = 0; | ||
1481 | if (phba->lmt & LMT_10Gb) | ||
1482 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_10GBIT; | ||
1483 | if (phba->lmt & LMT_4Gb) | ||
1484 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_4GBIT; | ||
1485 | if (phba->lmt & LMT_2Gb) | ||
1486 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_2GBIT; | ||
1487 | if (phba->lmt & LMT_1Gb) | ||
1488 | fc_host_supported_speeds(shost) |= FC_PORTSPEED_1GBIT; | ||
1489 | |||
1490 | fc_host_maxframe_size(shost) = | ||
1491 | ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | | ||
1492 | (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb); | ||
1493 | |||
1494 | /* This value is also unchanging */ | ||
1495 | memset(fc_host_active_fc4s(shost), 0, | ||
1496 | sizeof(fc_host_active_fc4s(shost))); | ||
1497 | fc_host_active_fc4s(shost)[2] = 1; | ||
1498 | fc_host_active_fc4s(shost)[7] = 1; | ||
1499 | |||
1500 | spin_lock_irq(shost->host_lock); | ||
1501 | phba->fc_flag &= ~FC_LOADING; | ||
1502 | spin_unlock_irq(shost->host_lock); | ||
1503 | |||
1504 | return 1; | ||
1505 | } | ||
1410 | 1506 | ||
1411 | static int __devinit | 1507 | static int __devinit |
1412 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | 1508 | lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) |
@@ -1445,9 +1541,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1445 | goto out_put_host; | 1541 | goto out_put_host; |
1446 | 1542 | ||
1447 | host->unique_id = phba->brd_no; | 1543 | host->unique_id = phba->brd_no; |
1448 | INIT_LIST_HEAD(&phba->ctrspbuflist); | ||
1449 | INIT_LIST_HEAD(&phba->rnidrspbuflist); | ||
1450 | INIT_LIST_HEAD(&phba->freebufList); | ||
1451 | 1544 | ||
1452 | /* Initialize timers used by driver */ | 1545 | /* Initialize timers used by driver */ |
1453 | init_timer(&phba->fc_estabtmo); | 1546 | init_timer(&phba->fc_estabtmo); |
@@ -1482,16 +1575,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1482 | host->max_lun = phba->cfg_max_luns; | 1575 | host->max_lun = phba->cfg_max_luns; |
1483 | host->this_id = -1; | 1576 | host->this_id = -1; |
1484 | 1577 | ||
1485 | /* Initialize all internally managed lists. */ | 1578 | INIT_LIST_HEAD(&phba->fc_nodes); |
1486 | INIT_LIST_HEAD(&phba->fc_nlpmap_list); | ||
1487 | INIT_LIST_HEAD(&phba->fc_nlpunmap_list); | ||
1488 | INIT_LIST_HEAD(&phba->fc_unused_list); | ||
1489 | INIT_LIST_HEAD(&phba->fc_plogi_list); | ||
1490 | INIT_LIST_HEAD(&phba->fc_adisc_list); | ||
1491 | INIT_LIST_HEAD(&phba->fc_reglogin_list); | ||
1492 | INIT_LIST_HEAD(&phba->fc_prli_list); | ||
1493 | INIT_LIST_HEAD(&phba->fc_npr_list); | ||
1494 | |||
1495 | 1579 | ||
1496 | pci_set_master(pdev); | 1580 | pci_set_master(pdev); |
1497 | retval = pci_set_mwi(pdev); | 1581 | retval = pci_set_mwi(pdev); |
@@ -1609,13 +1693,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1609 | 1693 | ||
1610 | host->transportt = lpfc_transport_template; | 1694 | host->transportt = lpfc_transport_template; |
1611 | pci_set_drvdata(pdev, host); | 1695 | pci_set_drvdata(pdev, host); |
1612 | error = scsi_add_host(host, &pdev->dev); | ||
1613 | if (error) | ||
1614 | goto out_kthread_stop; | ||
1615 | |||
1616 | error = lpfc_alloc_sysfs_attr(phba); | ||
1617 | if (error) | ||
1618 | goto out_remove_host; | ||
1619 | 1696 | ||
1620 | if (phba->cfg_use_msi) { | 1697 | if (phba->cfg_use_msi) { |
1621 | error = pci_enable_msi(phba->pcidev); | 1698 | error = pci_enable_msi(phba->pcidev); |
@@ -1631,73 +1708,15 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1631 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1708 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
1632 | "%d:0451 Enable interrupt handler failed\n", | 1709 | "%d:0451 Enable interrupt handler failed\n", |
1633 | phba->brd_no); | 1710 | phba->brd_no); |
1634 | goto out_free_sysfs_attr; | 1711 | goto out_kthread_stop; |
1635 | } | 1712 | } |
1636 | phba->MBslimaddr = phba->slim_memmap_p; | ||
1637 | phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; | ||
1638 | phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; | ||
1639 | phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; | ||
1640 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | ||
1641 | 1713 | ||
1642 | error = lpfc_sli_hba_setup(phba); | 1714 | error = scsi_add_host(host, &pdev->dev); |
1643 | if (error) { | 1715 | if (error) |
1644 | error = -ENODEV; | ||
1645 | goto out_free_irq; | 1716 | goto out_free_irq; |
1646 | } | ||
1647 | |||
1648 | /* | ||
1649 | * hba setup may have changed the hba_queue_depth so we need to adjust | ||
1650 | * the value of can_queue. | ||
1651 | */ | ||
1652 | host->can_queue = phba->cfg_hba_queue_depth - 10; | ||
1653 | |||
1654 | lpfc_discovery_wait(phba); | ||
1655 | 1717 | ||
1656 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { | 1718 | scsi_scan_host(host); |
1657 | spin_lock_irq(phba->host->host_lock); | ||
1658 | lpfc_poll_start_timer(phba); | ||
1659 | spin_unlock_irq(phba->host->host_lock); | ||
1660 | } | ||
1661 | 1719 | ||
1662 | /* | ||
1663 | * set fixed host attributes | ||
1664 | * Must done after lpfc_sli_hba_setup() | ||
1665 | */ | ||
1666 | |||
1667 | fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn); | ||
1668 | fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn); | ||
1669 | fc_host_supported_classes(host) = FC_COS_CLASS3; | ||
1670 | |||
1671 | memset(fc_host_supported_fc4s(host), 0, | ||
1672 | sizeof(fc_host_supported_fc4s(host))); | ||
1673 | fc_host_supported_fc4s(host)[2] = 1; | ||
1674 | fc_host_supported_fc4s(host)[7] = 1; | ||
1675 | |||
1676 | lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host)); | ||
1677 | |||
1678 | fc_host_supported_speeds(host) = 0; | ||
1679 | if (phba->lmt & LMT_10Gb) | ||
1680 | fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT; | ||
1681 | if (phba->lmt & LMT_4Gb) | ||
1682 | fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT; | ||
1683 | if (phba->lmt & LMT_2Gb) | ||
1684 | fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT; | ||
1685 | if (phba->lmt & LMT_1Gb) | ||
1686 | fc_host_supported_speeds(host) |= FC_PORTSPEED_1GBIT; | ||
1687 | |||
1688 | fc_host_maxframe_size(host) = | ||
1689 | ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | | ||
1690 | (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb); | ||
1691 | |||
1692 | /* This value is also unchanging */ | ||
1693 | memset(fc_host_active_fc4s(host), 0, | ||
1694 | sizeof(fc_host_active_fc4s(host))); | ||
1695 | fc_host_active_fc4s(host)[2] = 1; | ||
1696 | fc_host_active_fc4s(host)[7] = 1; | ||
1697 | |||
1698 | spin_lock_irq(phba->host->host_lock); | ||
1699 | phba->fc_flag &= ~FC_LOADING; | ||
1700 | spin_unlock_irq(phba->host->host_lock); | ||
1701 | return 0; | 1720 | return 0; |
1702 | 1721 | ||
1703 | out_free_irq: | 1722 | out_free_irq: |
@@ -1705,11 +1724,6 @@ out_free_irq: | |||
1705 | phba->work_hba_events = 0; | 1724 | phba->work_hba_events = 0; |
1706 | free_irq(phba->pcidev->irq, phba); | 1725 | free_irq(phba->pcidev->irq, phba); |
1707 | pci_disable_msi(phba->pcidev); | 1726 | pci_disable_msi(phba->pcidev); |
1708 | out_free_sysfs_attr: | ||
1709 | lpfc_free_sysfs_attr(phba); | ||
1710 | out_remove_host: | ||
1711 | fc_remove_host(phba->host); | ||
1712 | scsi_remove_host(phba->host); | ||
1713 | out_kthread_stop: | 1727 | out_kthread_stop: |
1714 | kthread_stop(phba->worker_thread); | 1728 | kthread_stop(phba->worker_thread); |
1715 | out_free_iocbq: | 1729 | out_free_iocbq: |
@@ -1747,56 +1761,8 @@ lpfc_pci_remove_one(struct pci_dev *pdev) | |||
1747 | { | 1761 | { |
1748 | struct Scsi_Host *host = pci_get_drvdata(pdev); | 1762 | struct Scsi_Host *host = pci_get_drvdata(pdev); |
1749 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; | 1763 | struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; |
1750 | unsigned long iflag; | ||
1751 | |||
1752 | lpfc_free_sysfs_attr(phba); | ||
1753 | |||
1754 | spin_lock_irqsave(phba->host->host_lock, iflag); | ||
1755 | phba->fc_flag |= FC_UNLOADING; | ||
1756 | |||
1757 | spin_unlock_irqrestore(phba->host->host_lock, iflag); | ||
1758 | 1764 | ||
1759 | fc_remove_host(phba->host); | 1765 | lpfc_remove_device(phba); |
1760 | scsi_remove_host(phba->host); | ||
1761 | |||
1762 | kthread_stop(phba->worker_thread); | ||
1763 | |||
1764 | /* | ||
1765 | * Bring down the SLI Layer. This step disable all interrupts, | ||
1766 | * clears the rings, discards all mailbox commands, and resets | ||
1767 | * the HBA. | ||
1768 | */ | ||
1769 | lpfc_sli_hba_down(phba); | ||
1770 | lpfc_sli_brdrestart(phba); | ||
1771 | |||
1772 | /* Release the irq reservation */ | ||
1773 | free_irq(phba->pcidev->irq, phba); | ||
1774 | pci_disable_msi(phba->pcidev); | ||
1775 | |||
1776 | lpfc_cleanup(phba, 0); | ||
1777 | lpfc_stop_timer(phba); | ||
1778 | phba->work_hba_events = 0; | ||
1779 | |||
1780 | /* | ||
1781 | * Call scsi_free before mem_free since scsi bufs are released to their | ||
1782 | * corresponding pools here. | ||
1783 | */ | ||
1784 | lpfc_scsi_free(phba); | ||
1785 | lpfc_mem_free(phba); | ||
1786 | |||
1787 | /* Free resources associated with SLI2 interface */ | ||
1788 | dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, | ||
1789 | phba->slim2p, phba->slim2p_mapping); | ||
1790 | |||
1791 | /* unmap adapter SLIM and Control Registers */ | ||
1792 | iounmap(phba->ctrl_regs_memmap_p); | ||
1793 | iounmap(phba->slim_memmap_p); | ||
1794 | |||
1795 | pci_release_regions(phba->pcidev); | ||
1796 | pci_disable_device(phba->pcidev); | ||
1797 | |||
1798 | idr_remove(&lpfc_hba_index, phba->brd_no); | ||
1799 | scsi_host_put(phba->host); | ||
1800 | 1766 | ||
1801 | pci_set_drvdata(pdev, NULL); | 1767 | pci_set_drvdata(pdev, NULL); |
1802 | } | 1768 | } |
@@ -1941,6 +1907,18 @@ static struct pci_device_id lpfc_id_table[] = { | |||
1941 | PCI_ANY_ID, PCI_ANY_ID, }, | 1907 | PCI_ANY_ID, PCI_ANY_ID, }, |
1942 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, | 1908 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, |
1943 | PCI_ANY_ID, PCI_ANY_ID, }, | 1909 | PCI_ANY_ID, PCI_ANY_ID, }, |
1910 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT, | ||
1911 | PCI_ANY_ID, PCI_ANY_ID, }, | ||
1912 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_MID, | ||
1913 | PCI_ANY_ID, PCI_ANY_ID, }, | ||
1914 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_SMB, | ||
1915 | PCI_ANY_ID, PCI_ANY_ID, }, | ||
1916 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_DCSP, | ||
1917 | PCI_ANY_ID, PCI_ANY_ID, }, | ||
1918 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_SCSP, | ||
1919 | PCI_ANY_ID, PCI_ANY_ID, }, | ||
1920 | {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_S, | ||
1921 | PCI_ANY_ID, PCI_ANY_ID, }, | ||
1944 | { 0 } | 1922 | { 0 } |
1945 | }; | 1923 | }; |
1946 | 1924 | ||