Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] lpfc: bug fixes

Following the NPIV support, the following changes have been accumulated
in the testing and qualification of the driver:

- Fix affinity of ELS ring to slow/deferred event processing
- Fix Ring attention masks
- Defer dev_loss_tmo timeout handling to worker thread
- Consolidate link down error classification for better error checking
- Remove unused/deprecated nlp_initiator_tmr timer
- Fix for async scan - move adapter init code back into pci_probe_one
context. Fix async scan interfaces.
- Expand validation of ability to create vports
- Extract VPI resource cnt from firmware
- Tuning of Login/Reject policies to better deal with overwhelmned targets
- Misc ELS and discovery fixes
- Export the npiv_enable attribute to sysfs
- Mailbox handling fix
- Add debugfs support
- A few other small misc fixes:
- wrong return values, double-frees, bad locking
- Added adapter failure heartbeat

Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

James Smart and committed by
James Bottomley
858c9f6c 92d7f7b0

+1798 -425
+1 -1
drivers/scsi/lpfc/Makefile
··· 28 28 29 29 lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o lpfc_hbadisc.o \ 30 30 lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o lpfc_scsi.o lpfc_attr.o \ 31 - lpfc_vport.o 31 + lpfc_vport.o lpfc_debugfs.o
+31 -9
drivers/scsi/lpfc/lpfc.h
··· 23 23 24 24 struct lpfc_sli2_slim; 25 25 26 - 27 26 #define LPFC_MAX_TARGET 256 /* max number of targets supported */ 28 27 #define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els 29 28 requests */ ··· 43 44 44 45 /* Number of exchanges reserved for discovery to complete */ 45 46 #define LPFC_DISC_IOCB_BUFF_COUNT 20 47 + 48 + #define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */ 49 + #define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */ 46 50 47 51 /* Define macros for 64 bit support */ 48 52 #define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr))) ··· 310 308 311 309 spinlock_t work_port_lock; 312 310 uint32_t work_port_events; /* Timeout to be handled */ 313 - #define WORKER_DISC_TMO 0x1 /* Discovery timeout */ 314 - #define WORKER_ELS_TMO 0x2 /* ELS timeout */ 315 - #define WORKER_MBOX_TMO 0x4 /* MBOX timeout */ 316 - #define WORKER_FDMI_TMO 0x8 /* FDMI timeout */ 317 - #define WORKER_FABRIC_BLOCK_TMO 0x10 /* fabric block timout */ 318 - #define WORKER_RAMP_DOWN_QUEUE 0x20 /* Decrease Q depth */ 319 - #define WORKER_RAMP_UP_QUEUE 0x40 /* Increase Q depth */ 311 + #define WORKER_DISC_TMO 0x1 /* vport: Discovery timeout */ 312 + #define WORKER_ELS_TMO 0x2 /* vport: ELS timeout */ 313 + #define WORKER_FDMI_TMO 0x4 /* vport: FDMI timeout */ 314 + 315 + #define WORKER_MBOX_TMO 0x100 /* hba: MBOX timeout */ 316 + #define WORKER_HB_TMO 0x200 /* hba: Heart beat timeout */ 317 + #define WORKER_FABRIC_BLOCK_TMO 0x400 /* hba: fabric block timout */ 318 + #define WORKER_RAMP_DOWN_QUEUE 0x800 /* hba: Decrease Q depth */ 319 + #define WORKER_RAMP_UP_QUEUE 0x1000 /* hba: Increase Q depth */ 320 320 321 321 struct timer_list fc_fdmitmo; 322 322 struct timer_list els_tmofunc; ··· 330 326 #define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */ 331 327 char *vname; /* Application assigned name */ 332 328 struct fc_vport *fc_vport; 329 + 330 + #ifdef CONFIG_LPFC_DEBUG_FS 331 + struct dentry *debug_disc_trc; 332 + struct dentry *debug_nodelist; 333 + struct dentry *vport_debugfs_root; 334 + struct lpfc_disc_trc *disc_trc; 335 + atomic_t disc_trc_cnt; 336 + #endif 333 337 }; 334 338 335 339 struct hbq_s { ··· 420 408 uint32_t cfg_hba_queue_depth; 421 409 uint32_t cfg_peer_port_login; 422 410 uint32_t cfg_vport_restrict_login; 411 + uint32_t cfg_npiv_enable; 423 412 uint32_t cfg_fcp_class; 424 413 uint32_t cfg_use_adisc; 425 414 uint32_t cfg_ack0; ··· 526 513 mempool_t *nlp_mem_pool; 527 514 528 515 struct fc_host_statistics link_stats; 516 + 529 517 struct list_head port_list; 530 518 struct lpfc_vport *pport; /* physical lpfc_vport pointer */ 531 519 uint16_t max_vpi; /* Maximum virtual nports */ 532 - uint16_t vpi_cnt; /* Nport count */ 533 520 #define LPFC_MAX_VPI 100 /* Max number of VPorts supported */ 534 521 unsigned long *vpi_bmask; /* vpi allocation table */ 535 522 ··· 544 531 unsigned long last_rsrc_error_time; 545 532 unsigned long last_ramp_down_time; 546 533 unsigned long last_ramp_up_time; 534 + #ifdef CONFIG_LPFC_DEBUG_FS 535 + struct dentry *hba_debugfs_root; 536 + atomic_t debugfs_vport_count; 537 + #endif 538 + 539 + /* Fields used for heart beat. */ 540 + unsigned long last_completion_time; 541 + struct timer_list hb_tmofunc; 542 + uint8_t hb_outstanding; 547 543 }; 548 544 549 545 static inline struct Scsi_Host *
+67 -50
drivers/scsi/lpfc/lpfc_attr.c
··· 282 282 } 283 283 284 284 lpfc_set_loopback_flag(phba); 285 - if (mbxstatus == MBX_TIMEOUT) 286 - pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 287 - else 285 + if (mbxstatus != MBX_TIMEOUT) 288 286 mempool_free(pmboxq, phba->mbox_mem_pool); 289 287 290 288 if (mbxstatus == MBXERR_ERROR) ··· 437 439 return -EIO; 438 440 } 439 441 440 - static ssize_t 441 - lpfc_max_vpi_show(struct class_device *cdev, char *buf) 442 - { 443 - struct Scsi_Host *shost = class_to_shost(cdev); 444 - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 445 - struct lpfc_hba *phba = vport->phba; 446 - 447 - return snprintf(buf, PAGE_SIZE, "%d\n", phba->max_vpi); 448 - } 449 - 450 - static ssize_t 451 - lpfc_used_vpi_show(struct class_device *cdev, char *buf) 452 - { 453 - struct Scsi_Host *shost = class_to_shost(cdev); 454 - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 455 - struct lpfc_hba *phba = vport->phba; 456 - 457 - /* Don't count the physical port */ 458 - return snprintf(buf, PAGE_SIZE, "%d\n", phba->vpi_cnt-1); 459 - } 460 - 461 442 int 462 - lpfc_get_hba_info(struct lpfc_hba *phba, uint32_t *mxri, 463 - uint32_t *axri, uint32_t *mrpi, uint32_t *arpi) 443 + lpfc_get_hba_info(struct lpfc_hba *phba, 444 + uint32_t *mxri, uint32_t *axri, 445 + uint32_t *mrpi, uint32_t *arpi, 446 + uint32_t *mvpi, uint32_t *avpi) 464 447 { 465 448 struct lpfc_sli *psli = &phba->sli; 466 449 LPFC_MBOXQ_t *pmboxq; ··· 477 498 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); 478 499 479 500 if (rc != MBX_SUCCESS) { 480 - if (rc == MBX_TIMEOUT) 481 - pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 482 - else 501 + if (rc != MBX_TIMEOUT) 483 502 mempool_free(pmboxq, phba->mbox_mem_pool); 484 503 return 0; 485 504 } ··· 490 513 *mxri = pmb->un.varRdConfig.max_xri; 491 514 if (axri) 492 515 *axri = pmb->un.varRdConfig.avail_xri; 516 + if (mvpi) 517 + *mvpi = pmb->un.varRdConfig.max_vpi; 518 + if (avpi) 519 + *avpi = pmb->un.varRdConfig.avail_vpi; 493 520 494 521 mempool_free(pmboxq, phba->mbox_mem_pool); 495 522 return 1; ··· 507 526 struct lpfc_hba *phba = vport->phba; 508 527 uint32_t cnt; 509 528 510 - if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL)) 529 + if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, NULL, NULL, NULL)) 511 530 return snprintf(buf, PAGE_SIZE, "%d\n", cnt); 512 531 return snprintf(buf, PAGE_SIZE, "Unknown\n"); 513 532 } ··· 520 539 struct lpfc_hba *phba = vport->phba; 521 540 uint32_t cnt, acnt; 522 541 523 - if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt)) 542 + if (lpfc_get_hba_info(phba, NULL, NULL, &cnt, &acnt, NULL, NULL)) 524 543 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); 525 544 return snprintf(buf, PAGE_SIZE, "Unknown\n"); 526 545 } ··· 533 552 struct lpfc_hba *phba = vport->phba; 534 553 uint32_t cnt; 535 554 536 - if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL)) 555 + if (lpfc_get_hba_info(phba, &cnt, NULL, NULL, NULL, NULL, NULL)) 537 556 return snprintf(buf, PAGE_SIZE, "%d\n", cnt); 538 557 return snprintf(buf, PAGE_SIZE, "Unknown\n"); 539 558 } ··· 546 565 struct lpfc_hba *phba = vport->phba; 547 566 uint32_t cnt, acnt; 548 567 549 - if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL)) 568 + if (lpfc_get_hba_info(phba, &cnt, &acnt, NULL, NULL, NULL, NULL)) 569 + return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); 570 + return snprintf(buf, PAGE_SIZE, "Unknown\n"); 571 + } 572 + 573 + static ssize_t 574 + lpfc_max_vpi_show(struct class_device *cdev, char *buf) 575 + { 576 + struct Scsi_Host *shost = class_to_shost(cdev); 577 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 578 + struct lpfc_hba *phba = vport->phba; 579 + uint32_t cnt; 580 + 581 + if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, NULL)) 582 + return snprintf(buf, PAGE_SIZE, "%d\n", cnt); 583 + return snprintf(buf, PAGE_SIZE, "Unknown\n"); 584 + } 585 + 586 + static ssize_t 587 + lpfc_used_vpi_show(struct class_device *cdev, char *buf) 588 + { 589 + struct Scsi_Host *shost = class_to_shost(cdev); 590 + struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 591 + struct lpfc_hba *phba = vport->phba; 592 + uint32_t cnt, acnt; 593 + 594 + if (lpfc_get_hba_info(phba, NULL, NULL, NULL, NULL, &cnt, &acnt)) 550 595 return snprintf(buf, PAGE_SIZE, "%d\n", (cnt - acnt)); 551 596 return snprintf(buf, PAGE_SIZE, "Unknown\n"); 552 597 } ··· 1002 995 " 2 - select SLI-2 even on SLI-3 capable HBAs," 1003 996 " 3 - select SLI-3"); 1004 997 1005 - int lpfc_npiv_enable = 0; 1006 - module_param(lpfc_npiv_enable, int, 0); 1007 - MODULE_PARM_DESC(lpfc_npiv_enable, "Enable NPIV functionality"); 998 + LPFC_ATTR_R(npiv_enable, 0, 0, 1, "Enable NPIV functionality"); 1008 999 1009 1000 /* 1010 1001 # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear ··· 1057 1052 return -EINVAL; 1058 1053 } 1059 1054 1055 + static void 1056 + lpfc_update_rport_devloss_tmo(struct lpfc_hba *phba) 1057 + { 1058 + struct lpfc_vport *vport; 1059 + struct Scsi_Host *shost; 1060 + struct lpfc_nodelist *ndlp; 1061 + 1062 + list_for_each_entry(vport, &phba->port_list, listentry) { 1063 + shost = lpfc_shost_from_vport(vport); 1064 + spin_lock_irq(shost->host_lock); 1065 + list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) 1066 + if (ndlp->rport) 1067 + ndlp->rport->dev_loss_tmo = 1068 + phba->cfg_devloss_tmo; 1069 + spin_unlock_irq(shost->host_lock); 1070 + } 1071 + } 1072 + 1060 1073 static int 1061 1074 lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val) 1062 1075 { ··· 1090 1067 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1091 1068 phba->cfg_nodev_tmo = val; 1092 1069 phba->cfg_devloss_tmo = val; 1070 + lpfc_update_rport_devloss_tmo(phba); 1093 1071 return 0; 1094 1072 } 1095 1073 ··· 1126 1102 phba->cfg_nodev_tmo = val; 1127 1103 phba->cfg_devloss_tmo = val; 1128 1104 phba->dev_loss_tmo_changed = 1; 1105 + lpfc_update_rport_devloss_tmo(phba); 1129 1106 return 0; 1130 1107 } 1131 1108 ··· 1383 1358 &class_device_attr_lpfc_multi_ring_type, 1384 1359 &class_device_attr_lpfc_fdmi_on, 1385 1360 &class_device_attr_lpfc_max_luns, 1361 + &class_device_attr_lpfc_npiv_enable, 1386 1362 &class_device_attr_nport_evt_cnt, 1387 1363 &class_device_attr_management_version, 1388 1364 &class_device_attr_board_mode, ··· 1667 1641 1668 1642 if (rc != MBX_SUCCESS) { 1669 1643 if (rc == MBX_TIMEOUT) { 1670 - phba->sysfs_mbox.mbox->mbox_cmpl = 1671 - lpfc_sli_def_mbox_cmpl; 1672 1644 phba->sysfs_mbox.mbox = NULL; 1673 1645 } 1674 1646 sysfs_mbox_idle(phba); ··· 1910 1886 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); 1911 1887 1912 1888 if (rc != MBX_SUCCESS) { 1913 - if (rc == MBX_TIMEOUT) 1914 - pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 1915 - else 1889 + if (rc != MBX_TIMEOUT) 1916 1890 mempool_free(pmboxq, phba->mbox_mem_pool); 1917 1891 return NULL; 1918 1892 } ··· 1935 1913 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); 1936 1914 1937 1915 if (rc != MBX_SUCCESS) { 1938 - if (rc == MBX_TIMEOUT) 1939 - pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 1940 - else 1916 + if (rc != MBX_TIMEOUT) 1941 1917 mempool_free(pmboxq, phba->mbox_mem_pool); 1942 1918 return NULL; 1943 1919 } ··· 2013 1993 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); 2014 1994 2015 1995 if (rc != MBX_SUCCESS) { 2016 - if (rc == MBX_TIMEOUT) 2017 - pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 2018 - else 1996 + if (rc != MBX_TIMEOUT) 2019 1997 mempool_free(pmboxq, phba->mbox_mem_pool); 2020 1998 return; 2021 1999 } ··· 2031 2013 rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2); 2032 2014 2033 2015 if (rc != MBX_SUCCESS) { 2034 - if (rc == MBX_TIMEOUT) 2035 - pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 2036 - else 2016 + if (rc != MBX_TIMEOUT) 2037 2017 mempool_free( pmboxq, phba->mbox_mem_pool); 2038 2018 return; 2039 2019 } ··· 2269 2253 lpfc_max_luns_init(phba, lpfc_max_luns); 2270 2254 lpfc_poll_tmo_init(phba, lpfc_poll_tmo); 2271 2255 lpfc_peer_port_login_init(phba, lpfc_peer_port_login); 2256 + lpfc_npiv_enable_init(phba, lpfc_npiv_enable); 2272 2257 lpfc_vport_restrict_login_init(phba, lpfc_vport_restrict_login); 2273 2258 lpfc_use_msi_init(phba, lpfc_use_msi); 2274 2259 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo);
+13 -3
drivers/scsi/lpfc/lpfc_crtn.h
··· 23 23 struct fc_rport; 24 24 void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); 25 25 void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *); 26 + void lpfc_heart_beat(struct lpfc_hba *, LPFC_MBOXQ_t *); 26 27 int lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, 27 28 struct lpfc_dmabuf *mp); 28 29 void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *); ··· 46 45 47 46 void lpfc_mbx_cmpl_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *); 48 47 void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); 48 + void lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *, LPFC_MBOXQ_t *); 49 49 void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); 50 50 void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); 51 51 void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); ··· 87 85 int lpfc_check_sparm(struct lpfc_vport *, struct lpfc_nodelist *, 88 86 struct serv_parm *, uint32_t); 89 87 int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist *); 88 + int lpfc_els_chk_latt(struct lpfc_vport *); 90 89 int lpfc_els_abort_flogi(struct lpfc_hba *); 91 90 int lpfc_initial_flogi(struct lpfc_vport *); 92 91 int lpfc_initial_fdisc(struct lpfc_vport *); ··· 99 96 int lpfc_issue_els_npiv_logo(struct lpfc_vport *, struct lpfc_nodelist *); 100 97 int lpfc_issue_els_scr(struct lpfc_vport *, uint32_t, uint8_t); 101 98 int lpfc_els_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *); 99 + int lpfc_ct_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *); 102 100 int lpfc_els_rsp_acc(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *, 103 101 struct lpfc_nodelist *, LPFC_MBOXQ_t *, uint8_t); 104 102 int lpfc_els_rsp_reject(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *, 105 - struct lpfc_nodelist *); 103 + struct lpfc_nodelist *, LPFC_MBOXQ_t *); 106 104 int lpfc_els_rsp_adisc_acc(struct lpfc_vport *, struct lpfc_iocbq *, 107 105 struct lpfc_nodelist *); 108 106 int lpfc_els_rsp_prli_acc(struct lpfc_vport *, struct lpfc_iocbq *, ··· 111 107 void lpfc_cancel_retry_delay_tmo(struct lpfc_vport *, struct lpfc_nodelist *); 112 108 void lpfc_els_retry_delay(unsigned long); 113 109 void lpfc_els_retry_delay_handler(struct lpfc_nodelist *); 110 + void lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *); 114 111 void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *, 115 112 struct lpfc_iocbq *); 116 113 int lpfc_els_handle_rscn(struct lpfc_vport *); ··· 122 117 int lpfc_els_disc_plogi(struct lpfc_vport *); 123 118 void lpfc_els_timeout(unsigned long); 124 119 void lpfc_els_timeout_handler(struct lpfc_vport *); 120 + void lpfc_hb_timeout(unsigned long); 121 + void lpfc_hb_timeout_handler(struct lpfc_hba *); 125 122 126 123 void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *, 127 124 struct lpfc_iocbq *); ··· 245 238 void lpfc_in_buf_free(struct lpfc_hba *, struct lpfc_dmabuf *); 246 239 /* Function prototypes. */ 247 240 const char* lpfc_info(struct Scsi_Host *); 248 - void lpfc_scan_start(struct Scsi_Host *); 249 241 int lpfc_scan_finished(struct Scsi_Host *, unsigned long); 250 242 251 243 void lpfc_get_cfgparam(struct lpfc_hba *); ··· 255 249 extern struct fc_function_template lpfc_transport_functions; 256 250 extern struct fc_function_template lpfc_vport_transport_functions; 257 251 extern int lpfc_sli_mode; 258 - extern int lpfc_npiv_enable; 259 252 260 253 int lpfc_vport_symbolic_node_name(struct lpfc_vport *, char *, size_t); 261 254 void lpfc_terminate_rport_io(struct fc_rport *); ··· 266 261 void destroy_port(struct lpfc_vport *); 267 262 int lpfc_get_instance(void); 268 263 void lpfc_host_attrib_init(struct Scsi_Host *); 264 + 265 + extern void lpfc_debugfs_initialize(struct lpfc_vport *); 266 + extern void lpfc_debugfs_terminate(struct lpfc_vport *); 267 + extern void lpfc_debugfs_disc_trc(struct lpfc_vport *, int, char *, uint32_t, 268 + uint32_t, uint32_t); 269 269 270 270 /* Interface exported by fabric iocb scheduler */ 271 271 int lpfc_issue_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
+164 -53
drivers/scsi/lpfc/lpfc_ct.c
··· 41 41 #include "lpfc_crtn.h" 42 42 #include "lpfc_version.h" 43 43 #include "lpfc_vport.h" 44 + #include "lpfc_debugfs.h" 44 45 45 46 #define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver 46 47 * incapable of reporting */ ··· 252 251 return mlist; 253 252 } 254 253 254 + int 255 + lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb) 256 + { 257 + struct lpfc_dmabuf *buf_ptr; 258 + 259 + if (ctiocb->context1) { 260 + buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; 261 + lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); 262 + kfree(buf_ptr); 263 + ctiocb->context1 = NULL; 264 + } 265 + if (ctiocb->context2) { 266 + lpfc_free_ct_rsp(phba, (struct lpfc_dmabuf *) ctiocb->context2); 267 + ctiocb->context2 = NULL; 268 + } 269 + 270 + if (ctiocb->context3) { 271 + buf_ptr = (struct lpfc_dmabuf *) ctiocb->context3; 272 + lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); 273 + kfree(buf_ptr); 274 + ctiocb->context1 = NULL; 275 + } 276 + lpfc_sli_release_iocbq(phba, ctiocb); 277 + return 0; 278 + } 279 + 255 280 static int 256 281 lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp, 257 282 struct lpfc_dmabuf *inp, struct lpfc_dmabuf *outp, ··· 455 428 (!phba->cfg_vport_restrict_login)) { 456 429 ndlp = lpfc_setup_disc_node(vport, Did); 457 430 if (ndlp) { 431 + lpfc_debugfs_disc_trc(vport, 432 + LPFC_DISC_TRC_CT, 433 + "Parse GID_FTrsp: " 434 + "did:x%x flg:x%x x%x", 435 + Did, ndlp->nlp_flag, 436 + vport->fc_flag); 437 + 458 438 lpfc_printf_log(phba, KERN_INFO, 459 439 LOG_DISCOVERY, 460 440 "%d (%d):0238 Process " ··· 473 439 vport->fc_flag, 474 440 vport->fc_rscn_id_cnt); 475 441 } else { 442 + lpfc_debugfs_disc_trc(vport, 443 + LPFC_DISC_TRC_CT, 444 + "Skip1 GID_FTrsp: " 445 + "did:x%x flg:x%x cnt:%d", 446 + Did, vport->fc_flag, 447 + vport->fc_rscn_id_cnt); 448 + 476 449 lpfc_printf_log(phba, KERN_INFO, 477 450 LOG_DISCOVERY, 478 451 "%d (%d):0239 Skip x%x " ··· 494 453 } else { 495 454 if (!(vport->fc_flag & FC_RSCN_MODE) || 496 455 (lpfc_rscn_payload_check(vport, Did))) { 456 + lpfc_debugfs_disc_trc(vport, 457 + LPFC_DISC_TRC_CT, 458 + "Query GID_FTrsp: " 459 + "did:x%x flg:x%x cnt:%d", 460 + Did, vport->fc_flag, 461 + vport->fc_rscn_id_cnt); 462 + 497 463 if (lpfc_ns_cmd(vport, 498 464 SLI_CTNS_GFF_ID, 499 465 0, Did) == 0) 500 466 vport->num_disc_nodes++; 501 467 } 502 468 else { 469 + lpfc_debugfs_disc_trc(vport, 470 + LPFC_DISC_TRC_CT, 471 + "Skip2 GID_FTrsp: " 472 + "did:x%x flg:x%x cnt:%d", 473 + Did, vport->fc_flag, 474 + vport->fc_rscn_id_cnt); 475 + 503 476 lpfc_printf_log(phba, KERN_INFO, 504 477 LOG_DISCOVERY, 505 478 "%d (%d):0245 Skip x%x " ··· 547 492 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 548 493 IOCB_t *irsp; 549 494 struct lpfc_dmabuf *bmp; 550 - struct lpfc_dmabuf *inp; 551 495 struct lpfc_dmabuf *outp; 552 496 struct lpfc_sli_ct_request *CTrsp; 553 497 int rc; ··· 554 500 /* we pass cmdiocb to state machine which needs rspiocb as well */ 555 501 cmdiocb->context_un.rsp_iocb = rspiocb; 556 502 557 - inp = (struct lpfc_dmabuf *) cmdiocb->context1; 558 503 outp = (struct lpfc_dmabuf *) cmdiocb->context2; 559 504 bmp = (struct lpfc_dmabuf *) cmdiocb->context3; 505 + irsp = &rspiocb->iocb; 506 + 507 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 508 + "GID_FT cmpl: status:x%x/x%x rtry:%d", 509 + irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_ns_retry); 560 510 561 511 /* Don't bother processing response if vport is being torn down. */ 562 512 if (vport->load_flag & FC_UNLOADING) 563 513 goto out; 564 514 565 - irsp = &rspiocb->iocb; 566 - if (irsp->ulpStatus) { 567 - if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 568 - ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || 569 - (irsp->un.ulpWord[4] == IOERR_SLI_ABORTED))) 570 - goto err1; 571 515 516 + if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) { 517 + lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 518 + "%d (%d):0216 Link event during NS query\n", 519 + phba->brd_no, vport->vpi); 520 + lpfc_vport_set_state(vport, FC_VPORT_FAILED); 521 + goto out; 522 + } 523 + 524 + if (irsp->ulpStatus) { 572 525 /* Check for retry */ 573 526 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { 574 - vport->fc_ns_retry++; 527 + if ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || 528 + (irsp->un.ulpWord[4] != IOERR_NO_RESOURCES)) 529 + vport->fc_ns_retry++; 575 530 /* CT command is being retried */ 576 531 rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT, 577 532 vport->fc_ns_retry, 0); 578 533 if (rc == 0) 579 534 goto out; 580 535 } 581 - err1: 582 536 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 583 537 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 584 538 "%d (%d):0257 GID_FT Query error: 0x%x 0x%x\n", ··· 615 553 (uint32_t) CTrsp->ReasonCode, 616 554 (uint32_t) CTrsp->Explanation, 617 555 vport->fc_flag); 556 + 557 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 558 + "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", 559 + (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, 560 + (uint32_t) CTrsp->ReasonCode, 561 + (uint32_t) CTrsp->Explanation); 562 + 618 563 } else { 619 564 /* NameServer Rsp Error */ 620 565 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, ··· 632 563 (uint32_t) CTrsp->ReasonCode, 633 564 (uint32_t) CTrsp->Explanation, 634 565 vport->fc_flag); 566 + 567 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 568 + "GID_FT rsp err2 cmd:x%x rsn:x%x exp:x%x", 569 + (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, 570 + (uint32_t) CTrsp->ReasonCode, 571 + (uint32_t) CTrsp->Explanation); 635 572 } 636 573 } 637 574 /* Link up / RSCN discovery */ ··· 661 586 lpfc_disc_start(vport); 662 587 } 663 588 out: 664 - lpfc_free_ct_rsp(phba, outp); 665 - lpfc_mbuf_free(phba, inp->virt, inp->phys); 666 - lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 667 - kfree(inp); 668 - kfree(bmp); 669 - lpfc_sli_release_iocbq(phba, cmdiocb); 589 + lpfc_ct_free_iocb(phba, cmdiocb); 670 590 return; 671 591 } 672 592 ··· 672 602 struct lpfc_vport *vport = cmdiocb->vport; 673 603 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 674 604 IOCB_t *irsp = &rspiocb->iocb; 675 - struct lpfc_dmabuf *bmp = (struct lpfc_dmabuf *) cmdiocb->context3; 676 605 struct lpfc_dmabuf *inp = (struct lpfc_dmabuf *) cmdiocb->context1; 677 606 struct lpfc_dmabuf *outp = (struct lpfc_dmabuf *) cmdiocb->context2; 678 607 struct lpfc_sli_ct_request *CTrsp; ··· 681 612 682 613 did = ((struct lpfc_sli_ct_request *) inp->virt)->un.gff.PortId; 683 614 did = be32_to_cpu(did); 615 + 616 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 617 + "GFF_ID cmpl: status:x%x/x%x did:x%x", 618 + irsp->ulpStatus, irsp->un.ulpWord[4], did); 684 619 685 620 if (irsp->ulpStatus == IOSTAT_SUCCESS) { 686 621 /* Good status, continue checking */ ··· 705 632 } 706 633 } 707 634 } 635 + else { 636 + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 637 + "%d (%d):0267 NameServer GFF Rsp" 638 + " x%x Error (%d %d) Data: x%x x%x\n", 639 + phba->brd_no, vport->vpi, did, 640 + irsp->ulpStatus, irsp->un.ulpWord[4], 641 + vport->fc_flag, vport->fc_rscn_id_cnt) 642 + } 643 + 708 644 /* This is a target port, unregistered port, or the GFF_ID failed */ 709 645 ndlp = lpfc_setup_disc_node(vport, did); 710 646 if (ndlp) { ··· 752 670 } 753 671 lpfc_disc_start(vport); 754 672 } 755 - 756 - lpfc_free_ct_rsp(phba, outp); 757 - lpfc_mbuf_free(phba, inp->virt, inp->phys); 758 - lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 759 - kfree(inp); 760 - kfree(bmp); 761 - lpfc_sli_release_iocbq(phba, cmdiocb); 673 + lpfc_ct_free_iocb(phba, cmdiocb); 762 674 return; 763 675 } 764 676 ··· 762 686 struct lpfc_iocbq *rspiocb) 763 687 { 764 688 struct lpfc_vport *vport = cmdiocb->vport; 765 - struct lpfc_dmabuf *bmp; 766 689 struct lpfc_dmabuf *inp; 767 690 struct lpfc_dmabuf *outp; 768 691 IOCB_t *irsp; 769 692 struct lpfc_sli_ct_request *CTrsp; 770 693 int cmdcode, rc; 771 694 uint8_t retry; 695 + uint32_t latt; 772 696 773 697 /* we pass cmdiocb to state machine which needs rspiocb as well */ 774 698 cmdiocb->context_un.rsp_iocb = rspiocb; 775 699 776 700 inp = (struct lpfc_dmabuf *) cmdiocb->context1; 777 701 outp = (struct lpfc_dmabuf *) cmdiocb->context2; 778 - bmp = (struct lpfc_dmabuf *) cmdiocb->context3; 779 702 irsp = &rspiocb->iocb; 780 703 781 704 cmdcode = be16_to_cpu(((struct lpfc_sli_ct_request *) inp->virt)-> 782 705 CommandResponse.bits.CmdRsp); 783 706 CTrsp = (struct lpfc_sli_ct_request *) outp->virt; 784 707 785 - /* NS request completes status <ulpStatus> CmdRsp <CmdRsp> */ 708 + latt = lpfc_els_chk_latt(vport); 709 + 710 + /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ 786 711 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 787 - "%d (%d):0209 NS request %x completes " 788 - "ulpStatus x%x / x%x " 789 - "CmdRsp x%x, Context x%x, Tag x%x\n", 790 - phba->brd_no, vport->vpi, 791 - cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4], 712 + "%d (%d):0209 RFT request completes, latt %d, " 713 + "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", 714 + phba->brd_no, vport->vpi, latt, irsp->ulpStatus, 792 715 CTrsp->CommandResponse.bits.CmdRsp, 793 716 cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); 794 717 718 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 719 + "CT cmd cmpl: status:x%x/x%x cmd:x%x", 720 + irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); 721 + 795 722 if (irsp->ulpStatus) { 723 + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 724 + "%d (%d):0268 NS cmd %x Error (%d %d)\n", 725 + phba->brd_no, vport->vpi, cmdcode, 726 + irsp->ulpStatus, irsp->un.ulpWord[4]); 727 + 796 728 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 797 729 ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || 798 730 (irsp->un.ulpWord[4] == IOERR_SLI_ABORTED))) ··· 820 736 } 821 737 822 738 out: 823 - lpfc_free_ct_rsp(phba, outp); 824 - lpfc_mbuf_free(phba, inp->virt, inp->phys); 825 - lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 826 - kfree(inp); 827 - kfree(bmp); 828 - lpfc_sli_release_iocbq(phba, cmdiocb); 739 + lpfc_ct_free_iocb(phba, cmdiocb); 829 740 return; 830 741 } 831 742 ··· 919 840 struct lpfc_iocbq *) = NULL; 920 841 uint32_t rsp_size = 1024; 921 842 size_t size; 843 + int rc = 0; 922 844 923 845 ndlp = lpfc_findnode_did(vport, NameServer_DID); 924 - if (ndlp == NULL || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) 925 - return 1; 846 + if (ndlp == NULL || ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) { 847 + rc=1; 848 + goto ns_cmd_exit; 849 + } 926 850 927 851 /* fill in BDEs for command */ 928 852 /* Allocate buffer for command payload */ 929 853 mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); 930 - if (!mp) 854 + if (!mp) { 855 + rc=2; 931 856 goto ns_cmd_exit; 857 + } 932 858 933 859 INIT_LIST_HEAD(&mp->list); 934 860 mp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(mp->phys)); 935 - if (!mp->virt) 861 + if (!mp->virt) { 862 + rc=3; 936 863 goto ns_cmd_free_mp; 864 + } 937 865 938 866 /* Allocate buffer for Buffer ptr list */ 939 867 bmp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL); 940 - if (!bmp) 868 + if (!bmp) { 869 + rc=4; 941 870 goto ns_cmd_free_mpvirt; 871 + } 942 872 943 873 INIT_LIST_HEAD(&bmp->list); 944 874 bmp->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &(bmp->phys)); 945 - if (!bmp->virt) 875 + if (!bmp->virt) { 876 + rc=5; 946 877 goto ns_cmd_free_bmp; 878 + } 947 879 948 880 /* NameServer Req */ 949 881 lpfc_printf_log(phba, KERN_INFO ,LOG_DISCOVERY, ··· 1060 970 break; 1061 971 } 1062 972 1063 - if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) 973 + if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { 1064 974 /* On success, The cmpl function will free the buffers */ 975 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 976 + "Issue CT cmd: cmd:x%x did:x%x", 977 + cmdcode, ndlp->nlp_DID, 0); 1065 978 return 0; 979 + } 1066 980 981 + rc=6; 1067 982 lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 1068 983 ns_cmd_free_bmp: 1069 984 kfree(bmp); ··· 1077 982 ns_cmd_free_mp: 1078 983 kfree(mp); 1079 984 ns_cmd_exit: 985 + lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 986 + "%d (%d):0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", 987 + phba->brd_no, vport->vpi, cmdcode, rc, vport->fc_flag, 988 + vport->fc_rscn_id_cnt); 1080 989 return 1; 1081 990 } 1082 991 ··· 1088 989 lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, 1089 990 struct lpfc_iocbq * rspiocb) 1090 991 { 1091 - struct lpfc_dmabuf *bmp = cmdiocb->context3; 1092 992 struct lpfc_dmabuf *inp = cmdiocb->context1; 1093 993 struct lpfc_dmabuf *outp = cmdiocb->context2; 1094 994 struct lpfc_sli_ct_request *CTrsp = outp->virt; ··· 1096 998 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; 1097 999 uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; 1098 1000 struct lpfc_vport *vport = cmdiocb->vport; 1001 + IOCB_t *irsp = &rspiocb->iocb; 1002 + uint32_t latt; 1003 + 1004 + latt = lpfc_els_chk_latt(vport); 1005 + 1006 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 1007 + "FDMI cmpl: status:x%x/x%x latt:%d", 1008 + irsp->ulpStatus, irsp->un.ulpWord[4], latt); 1009 + 1010 + if (latt || irsp->ulpStatus) { 1011 + lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1012 + "%d (%d):0229 FDMI cmd %04x failed, latt = %d " 1013 + "ulpStatus: x%x, rid x%x\n", 1014 + phba->brd_no, vport->vpi, 1015 + be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, 1016 + irsp->un.ulpWord[4]); 1017 + lpfc_ct_free_iocb(phba, cmdiocb); 1018 + return; 1019 + } 1099 1020 1100 1021 ndlp = lpfc_findnode_did(vport, FDMI_DID); 1101 1022 if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { ··· 1141 1024 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_RHBA); 1142 1025 break; 1143 1026 } 1144 - 1145 - lpfc_free_ct_rsp(phba, outp); 1146 - lpfc_mbuf_free(phba, inp->virt, inp->phys); 1147 - lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 1148 - kfree(inp); 1149 - kfree(bmp); 1150 - lpfc_sli_release_iocbq(phba, cmdiocb); 1027 + lpfc_ct_free_iocb(phba, cmdiocb); 1151 1028 return; 1152 1029 } 1153 1030
+508
drivers/scsi/lpfc/lpfc_debugfs.c
··· 1 + /******************************************************************* 2 + * This file is part of the Emulex Linux Device Driver for * 3 + * Fibre Channel Host Bus Adapters. * 4 + * Copyright (C) 2007 Emulex. All rights reserved. * 5 + * EMULEX and SLI are trademarks of Emulex. * 6 + * www.emulex.com * 7 + * * 8 + * This program is free software; you can redistribute it and/or * 9 + * modify it under the terms of version 2 of the GNU General * 10 + * Public License as published by the Free Software Foundation. * 11 + * This program is distributed in the hope that it will be useful. * 12 + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * 13 + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * 14 + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * 15 + * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * 16 + * TO BE LEGALLY INVALID. See the GNU General Public License for * 17 + * more details, a copy of which can be found in the file COPYING * 18 + * included with this package. * 19 + *******************************************************************/ 20 + 21 + #include <linux/blkdev.h> 22 + #include <linux/delay.h> 23 + #include <linux/dma-mapping.h> 24 + #include <linux/idr.h> 25 + #include <linux/interrupt.h> 26 + #include <linux/kthread.h> 27 + #include <linux/pci.h> 28 + #include <linux/spinlock.h> 29 + #include <linux/ctype.h> 30 + #include <linux/version.h> 31 + 32 + #include <scsi/scsi.h> 33 + #include <scsi/scsi_device.h> 34 + #include <scsi/scsi_host.h> 35 + #include <scsi/scsi_transport_fc.h> 36 + 37 + #include "lpfc_hw.h" 38 + #include "lpfc_sli.h" 39 + #include "lpfc_disc.h" 40 + #include "lpfc_scsi.h" 41 + #include "lpfc.h" 42 + #include "lpfc_logmsg.h" 43 + #include "lpfc_crtn.h" 44 + #include "lpfc_vport.h" 45 + #include "lpfc_version.h" 46 + #include "lpfc_vport.h" 47 + #include "lpfc_debugfs.h" 48 + 49 + #ifdef CONFIG_LPFC_DEBUG_FS 50 + /* debugfs interface 51 + * 52 + * To access this interface the user should: 53 + * # mkdir /debug 54 + * # mount -t debugfs none /debug 55 + * 56 + * The lpfc debugfs directory hierachy is: 57 + * lpfc/lpfcX/vportY 58 + * where X is the lpfc hba unique_id 59 + * where Y is the vport VPI on that hba 60 + * 61 + * Debugging services available per vport: 62 + * discovery_trace 63 + * This is an ACSII readable file that contains a trace of the last 64 + * lpfc_debugfs_max_disc_trc events that happened on a specific vport. 65 + * See lpfc_debugfs.h for different categories of 66 + * discovery events. To enable the discovery trace, the following 67 + * module parameters must be set: 68 + * lpfc_debugfs_enable=1 Turns on lpfc debugfs filesystem support 69 + * lpfc_debugfs_max_disc_trc=X Where X is the event trace depth for 70 + * EACH vport. X MUST also be a power of 2. 71 + * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in 72 + * lpfc_debugfs.h . 73 + */ 74 + static int lpfc_debugfs_enable = 0; 75 + module_param(lpfc_debugfs_enable, int, 0); 76 + MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); 77 + 78 + static int lpfc_debugfs_max_disc_trc = 0; /* This MUST be a power of 2 */ 79 + module_param(lpfc_debugfs_max_disc_trc, int, 0); 80 + MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, 81 + "Set debugfs discovery trace depth"); 82 + 83 + static int lpfc_debugfs_mask_disc_trc = 0; 84 + module_param(lpfc_debugfs_mask_disc_trc, int, 0); 85 + MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, 86 + "Set debugfs discovery trace mask"); 87 + 88 + #include <linux/debugfs.h> 89 + 90 + /* size of discovery_trace output line */ 91 + #define LPFC_DISC_TRC_ENTRY_SIZE 80 92 + 93 + /* nodelist output buffer size */ 94 + #define LPFC_NODELIST_SIZE 8192 95 + #define LPFC_NODELIST_ENTRY_SIZE 120 96 + 97 + struct lpfc_debug { 98 + char *buffer; 99 + int len; 100 + }; 101 + 102 + atomic_t lpfc_debugfs_disc_trc_cnt = ATOMIC_INIT(0); 103 + unsigned long lpfc_debugfs_start_time = 0L; 104 + 105 + static int 106 + lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) 107 + { 108 + int i, index, len, enable; 109 + uint32_t ms; 110 + struct lpfc_disc_trc *dtp; 111 + char buffer[80]; 112 + 113 + 114 + enable = lpfc_debugfs_enable; 115 + lpfc_debugfs_enable = 0; 116 + 117 + len = 0; 118 + index = (atomic_read(&vport->disc_trc_cnt) + 1) & 119 + (lpfc_debugfs_max_disc_trc - 1); 120 + for (i = index; i < lpfc_debugfs_max_disc_trc; i++) { 121 + dtp = vport->disc_trc + i; 122 + if (!dtp->fmt) 123 + continue; 124 + ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); 125 + snprintf(buffer, 80, "%010d:%010d ms:%s\n", 126 + dtp->seq_cnt, ms, dtp->fmt); 127 + len += snprintf(buf+len, size-len, buffer, 128 + dtp->data1, dtp->data2, dtp->data3); 129 + } 130 + for (i = 0; i < index; i++) { 131 + dtp = vport->disc_trc + i; 132 + if (!dtp->fmt) 133 + continue; 134 + ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); 135 + snprintf(buffer, 80, "%010d:%010d ms:%s\n", 136 + dtp->seq_cnt, ms, dtp->fmt); 137 + len += snprintf(buf+len, size-len, buffer, 138 + dtp->data1, dtp->data2, dtp->data3); 139 + } 140 + 141 + lpfc_debugfs_enable = enable; 142 + return len; 143 + } 144 + 145 + static int 146 + lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) 147 + { 148 + int len = 0; 149 + int cnt; 150 + struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 151 + struct lpfc_nodelist *ndlp; 152 + unsigned char *statep, *name; 153 + 154 + cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE); 155 + 156 + spin_lock_irq(shost->host_lock); 157 + list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) { 158 + if (!cnt) { 159 + len += snprintf(buf+len, size-len, 160 + "Missing Nodelist Entries\n"); 161 + break; 162 + } 163 + cnt--; 164 + switch (ndlp->nlp_state) { 165 + case NLP_STE_UNUSED_NODE: 166 + statep = "UNUSED"; 167 + break; 168 + case NLP_STE_PLOGI_ISSUE: 169 + statep = "PLOGI "; 170 + break; 171 + case NLP_STE_ADISC_ISSUE: 172 + statep = "ADISC "; 173 + break; 174 + case NLP_STE_REG_LOGIN_ISSUE: 175 + statep = "REGLOG"; 176 + break; 177 + case NLP_STE_PRLI_ISSUE: 178 + statep = "PRLI "; 179 + break; 180 + case NLP_STE_UNMAPPED_NODE: 181 + statep = "UNMAP "; 182 + break; 183 + case NLP_STE_MAPPED_NODE: 184 + statep = "MAPPED"; 185 + break; 186 + case NLP_STE_NPR_NODE: 187 + statep = "NPR "; 188 + break; 189 + default: 190 + statep = "UNKNOWN"; 191 + } 192 + len += snprintf(buf+len, size-len, "%s DID:x%06x ", 193 + statep, ndlp->nlp_DID); 194 + name = (unsigned char *)&ndlp->nlp_portname; 195 + len += snprintf(buf+len, size-len, 196 + "WWPN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", 197 + *name, *(name+1), *(name+2), *(name+3), 198 + *(name+4), *(name+5), *(name+6), *(name+7)); 199 + name = (unsigned char *)&ndlp->nlp_nodename; 200 + len += snprintf(buf+len, size-len, 201 + "WWNN %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x ", 202 + *name, *(name+1), *(name+2), *(name+3), 203 + *(name+4), *(name+5), *(name+6), *(name+7)); 204 + len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ", 205 + ndlp->nlp_rpi, ndlp->nlp_flag); 206 + if (!ndlp->nlp_type) 207 + len += snprintf(buf+len, size-len, "UNKNOWN_TYPE"); 208 + if (ndlp->nlp_type & NLP_FC_NODE) 209 + len += snprintf(buf+len, size-len, "FC_NODE "); 210 + if (ndlp->nlp_type & NLP_FABRIC) 211 + len += snprintf(buf+len, size-len, "FABRIC "); 212 + if (ndlp->nlp_type & NLP_FCP_TARGET) 213 + len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ", 214 + ndlp->nlp_sid); 215 + if (ndlp->nlp_type & NLP_FCP_INITIATOR) 216 + len += snprintf(buf+len, size-len, "FCP_INITIATOR"); 217 + len += snprintf(buf+len, size-len, "\n"); 218 + } 219 + spin_unlock_irq(shost->host_lock); 220 + return len; 221 + } 222 + #endif 223 + 224 + 225 + inline void 226 + lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt, 227 + uint32_t data1, uint32_t data2, uint32_t data3) 228 + { 229 + #ifdef CONFIG_LPFC_DEBUG_FS 230 + struct lpfc_disc_trc *dtp; 231 + int index; 232 + 233 + if (!(lpfc_debugfs_mask_disc_trc & mask)) 234 + return; 235 + 236 + if (!lpfc_debugfs_enable || !lpfc_debugfs_max_disc_trc || 237 + !vport || !vport->disc_trc) 238 + return; 239 + 240 + index = atomic_inc_return(&vport->disc_trc_cnt) & 241 + (lpfc_debugfs_max_disc_trc - 1); 242 + dtp = vport->disc_trc + index; 243 + dtp->fmt = fmt; 244 + dtp->data1 = data1; 245 + dtp->data2 = data2; 246 + dtp->data3 = data3; 247 + dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_disc_trc_cnt); 248 + dtp->jif = jiffies; 249 + #endif 250 + return; 251 + } 252 + 253 + #ifdef CONFIG_LPFC_DEBUG_FS 254 + static int 255 + lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file) 256 + { 257 + struct lpfc_vport *vport = inode->i_private; 258 + struct lpfc_debug *debug; 259 + int size; 260 + int rc = -ENOMEM; 261 + 262 + if (!lpfc_debugfs_max_disc_trc) { 263 + rc = -ENOSPC; 264 + goto out; 265 + } 266 + 267 + debug = kmalloc(sizeof(*debug), GFP_KERNEL); 268 + if (!debug) 269 + goto out; 270 + 271 + /* Round to page boundry */ 272 + size = (lpfc_debugfs_max_disc_trc * LPFC_DISC_TRC_ENTRY_SIZE); 273 + size = PAGE_ALIGN(size); 274 + 275 + debug->buffer = kmalloc(size, GFP_KERNEL); 276 + if (!debug->buffer) { 277 + kfree(debug); 278 + goto out; 279 + } 280 + 281 + debug->len = lpfc_debugfs_disc_trc_data(vport, debug->buffer, size); 282 + file->private_data = debug; 283 + 284 + rc = 0; 285 + out: 286 + return rc; 287 + } 288 + 289 + static int 290 + lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) 291 + { 292 + struct lpfc_vport *vport = inode->i_private; 293 + struct lpfc_debug *debug; 294 + int rc = -ENOMEM; 295 + 296 + debug = kmalloc(sizeof(*debug), GFP_KERNEL); 297 + if (!debug) 298 + goto out; 299 + 300 + /* Round to page boundry */ 301 + debug->buffer = kmalloc(LPFC_NODELIST_SIZE, GFP_KERNEL); 302 + if (!debug->buffer) { 303 + kfree(debug); 304 + goto out; 305 + } 306 + 307 + debug->len = lpfc_debugfs_nodelist_data(vport, debug->buffer, 308 + LPFC_NODELIST_SIZE); 309 + file->private_data = debug; 310 + 311 + rc = 0; 312 + out: 313 + return rc; 314 + } 315 + 316 + static loff_t 317 + lpfc_debugfs_lseek(struct file *file, loff_t off, int whence) 318 + { 319 + struct lpfc_debug *debug; 320 + loff_t pos = -1; 321 + 322 + debug = file->private_data; 323 + 324 + switch (whence) { 325 + case 0: 326 + pos = off; 327 + break; 328 + case 1: 329 + pos = file->f_pos + off; 330 + break; 331 + case 2: 332 + pos = debug->len - off; 333 + } 334 + return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos); 335 + } 336 + 337 + static ssize_t 338 + lpfc_debugfs_read(struct file *file, char __user *buf, 339 + size_t nbytes, loff_t *ppos) 340 + { 341 + struct lpfc_debug *debug = file->private_data; 342 + return simple_read_from_buffer(buf, nbytes, ppos, debug->buffer, 343 + debug->len); 344 + } 345 + 346 + static int 347 + lpfc_debugfs_release(struct inode *inode, struct file *file) 348 + { 349 + struct lpfc_debug *debug = file->private_data; 350 + 351 + kfree(debug->buffer); 352 + kfree(debug); 353 + 354 + return 0; 355 + } 356 + 357 + #undef lpfc_debugfs_op_disc_trc 358 + static struct file_operations lpfc_debugfs_op_disc_trc = { 359 + .owner = THIS_MODULE, 360 + .open = lpfc_debugfs_disc_trc_open, 361 + .llseek = lpfc_debugfs_lseek, 362 + .read = lpfc_debugfs_read, 363 + .release = lpfc_debugfs_release, 364 + }; 365 + 366 + #undef lpfc_debugfs_op_nodelist 367 + static struct file_operations lpfc_debugfs_op_nodelist = { 368 + .owner = THIS_MODULE, 369 + .open = lpfc_debugfs_nodelist_open, 370 + .llseek = lpfc_debugfs_lseek, 371 + .read = lpfc_debugfs_read, 372 + .release = lpfc_debugfs_release, 373 + }; 374 + 375 + static struct dentry *lpfc_debugfs_root = NULL; 376 + static atomic_t lpfc_debugfs_hba_count; 377 + #endif 378 + 379 + inline void 380 + lpfc_debugfs_initialize(struct lpfc_vport *vport) 381 + { 382 + #ifdef CONFIG_LPFC_DEBUG_FS 383 + struct lpfc_hba *phba = vport->phba; 384 + char name[64]; 385 + uint32_t num, i; 386 + 387 + if (!lpfc_debugfs_enable) 388 + return; 389 + 390 + if (lpfc_debugfs_max_disc_trc) { 391 + num = lpfc_debugfs_max_disc_trc - 1; 392 + if (num & lpfc_debugfs_max_disc_trc) { 393 + /* Change to be a power of 2 */ 394 + num = lpfc_debugfs_max_disc_trc; 395 + i = 0; 396 + while (num > 1) { 397 + num = num >> 1; 398 + i++; 399 + } 400 + lpfc_debugfs_max_disc_trc = (1 << i); 401 + printk(KERN_ERR 402 + "lpfc_debugfs_max_disc_trc changed to %d\n", 403 + lpfc_debugfs_max_disc_trc); 404 + } 405 + } 406 + 407 + if (!lpfc_debugfs_root) { 408 + lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); 409 + atomic_set(&lpfc_debugfs_hba_count, 0); 410 + if (!lpfc_debugfs_root) 411 + goto debug_failed; 412 + } 413 + 414 + snprintf(name, sizeof(name), "lpfc%d", phba->brd_no); 415 + if (!phba->hba_debugfs_root) { 416 + phba->hba_debugfs_root = 417 + debugfs_create_dir(name, lpfc_debugfs_root); 418 + if (!phba->hba_debugfs_root) 419 + goto debug_failed; 420 + atomic_inc(&lpfc_debugfs_hba_count); 421 + atomic_set(&phba->debugfs_vport_count, 0); 422 + } 423 + 424 + snprintf(name, sizeof(name), "vport%d", vport->vpi); 425 + if (!vport->vport_debugfs_root) { 426 + vport->vport_debugfs_root = 427 + debugfs_create_dir(name, phba->hba_debugfs_root); 428 + if (!vport->vport_debugfs_root) 429 + goto debug_failed; 430 + atomic_inc(&phba->debugfs_vport_count); 431 + } 432 + 433 + if (!lpfc_debugfs_start_time) 434 + lpfc_debugfs_start_time = jiffies; 435 + 436 + vport->disc_trc = kmalloc( 437 + (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc), 438 + GFP_KERNEL); 439 + 440 + if (!vport->disc_trc) 441 + goto debug_failed; 442 + memset(vport->disc_trc, 0, 443 + (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc)); 444 + 445 + snprintf(name, sizeof(name), "discovery_trace"); 446 + vport->debug_disc_trc = 447 + debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 448 + vport->vport_debugfs_root, 449 + vport, &lpfc_debugfs_op_disc_trc); 450 + if (!vport->debug_disc_trc) { 451 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 452 + "%d:0409 Cannot create debugfs", 453 + phba->brd_no); 454 + goto debug_failed; 455 + } 456 + snprintf(name, sizeof(name), "nodelist"); 457 + vport->debug_nodelist = 458 + debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 459 + vport->vport_debugfs_root, 460 + vport, &lpfc_debugfs_op_nodelist); 461 + if (!vport->debug_nodelist) { 462 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 463 + "%d:0409 Cannot create debugfs", 464 + phba->brd_no); 465 + goto debug_failed; 466 + } 467 + debug_failed: 468 + return; 469 + #endif 470 + } 471 + 472 + 473 + inline void 474 + lpfc_debugfs_terminate(struct lpfc_vport *vport) 475 + { 476 + #ifdef CONFIG_LPFC_DEBUG_FS 477 + struct lpfc_hba *phba = vport->phba; 478 + 479 + if (vport->disc_trc) { 480 + kfree(vport->disc_trc); 481 + vport->disc_trc = NULL; 482 + } 483 + if (vport->debug_disc_trc) { 484 + debugfs_remove(vport->debug_disc_trc); /* discovery_trace */ 485 + vport->debug_disc_trc = NULL; 486 + } 487 + if (vport->debug_nodelist) { 488 + debugfs_remove(vport->debug_nodelist); /* nodelist */ 489 + vport->debug_nodelist = NULL; 490 + } 491 + if (vport->vport_debugfs_root) { 492 + debugfs_remove(vport->vport_debugfs_root); /* vportX */ 493 + vport->vport_debugfs_root = NULL; 494 + atomic_dec(&phba->debugfs_vport_count); 495 + } 496 + if (atomic_read(&phba->debugfs_vport_count) == 0) { 497 + debugfs_remove(vport->phba->hba_debugfs_root); /* lpfcX */ 498 + vport->phba->hba_debugfs_root = NULL; 499 + atomic_dec(&lpfc_debugfs_hba_count); 500 + if (atomic_read(&lpfc_debugfs_hba_count) == 0) { 501 + debugfs_remove(lpfc_debugfs_root); /* lpfc */ 502 + lpfc_debugfs_root = NULL; 503 + } 504 + } 505 + #endif 506 + } 507 + 508 +
+50
drivers/scsi/lpfc/lpfc_debugfs.h
··· 1 + /******************************************************************* 2 + * This file is part of the Emulex Linux Device Driver for * 3 + * Fibre Channel Host Bus Adapters. * 4 + * Copyright (C) 2007 Emulex. All rights reserved. * 5 + * EMULEX and SLI are trademarks of Emulex. * 6 + * www.emulex.com * 7 + * * 8 + * This program is free software; you can redistribute it and/or * 9 + * modify it under the terms of version 2 of the GNU General * 10 + * Public License as published by the Free Software Foundation. * 11 + * This program is distributed in the hope that it will be useful. * 12 + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * 13 + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * 14 + * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE * 15 + * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD * 16 + * TO BE LEGALLY INVALID. See the GNU General Public License for * 17 + * more details, a copy of which can be found in the file COPYING * 18 + * included with this package. * 19 + *******************************************************************/ 20 + 21 + #ifndef _H_LPFC_DEBUG_FS 22 + #define _H_LPFC_DEBUG_FS 23 + 24 + #ifdef CONFIG_LPFC_DEBUG_FS 25 + struct lpfc_disc_trc { 26 + char *fmt; 27 + uint32_t data1; 28 + uint32_t data2; 29 + uint32_t data3; 30 + uint32_t seq_cnt; 31 + unsigned long jif; 32 + }; 33 + #endif 34 + 35 + /* Mask for discovery_trace */ 36 + #define LPFC_DISC_TRC_ELS_CMD 0x1 /* Trace ELS commands */ 37 + #define LPFC_DISC_TRC_ELS_RSP 0x2 /* Trace ELS response */ 38 + #define LPFC_DISC_TRC_ELS_UNSOL 0x4 /* Trace ELS rcv'ed */ 39 + #define LPFC_DISC_TRC_ELS_ALL 0x7 /* Trace ELS */ 40 + #define LPFC_DISC_TRC_MBOX_VPORT 0x8 /* Trace vport MBOXs */ 41 + #define LPFC_DISC_TRC_MBOX 0x10 /* Trace other MBOXs */ 42 + #define LPFC_DISC_TRC_MBOX_ALL 0x18 /* Trace all MBOXs */ 43 + #define LPFC_DISC_TRC_CT 0x20 /* Trace disc CT requests */ 44 + #define LPFC_DISC_TRC_DSM 0x40 /* Trace DSM events */ 45 + #define LPFC_DISC_TRC_RPORT 0x80 /* Trace rport events */ 46 + #define LPFC_DISC_TRC_NODE 0x100 /* Trace ndlp state changes */ 47 + 48 + #define LPFC_DISC_TRC_DISCOVERY 0xef /* common mask for general 49 + * discovery */ 50 + #endif /* H_LPFC_DEBUG_FS */
+2 -1
drivers/scsi/lpfc/lpfc_disc.h
··· 36 36 LPFC_EVT_WARM_START, 37 37 LPFC_EVT_KILL, 38 38 LPFC_EVT_ELS_RETRY, 39 + LPFC_EVT_DEV_LOSS_DELAY, 39 40 LPFC_EVT_DEV_LOSS, 40 41 }; 41 42 ··· 75 74 #define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */ 76 75 77 76 struct timer_list nlp_delayfunc; /* Used for delayed ELS cmds */ 78 - struct timer_list nlp_initiator_tmr; /* Used with dev_loss */ 79 77 struct fc_rport *rport; /* Corresponding FC transport 80 78 port structure */ 81 79 struct lpfc_vport *vport; ··· 101 101 ACC */ 102 102 #define NLP_NPR_ADISC 0x2000000 /* Issue ADISC when dq'ed from 103 103 NPR list */ 104 + #define NLP_RM_DFLT_RPI 0x4000000 /* need to remove leftover dflt RPI */ 104 105 #define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */ 105 106 #define NLP_TARGET_REMOVE 0x10000000 /* Target remove in process */ 106 107
+318 -92
drivers/scsi/lpfc/lpfc_els.c
··· 36 36 #include "lpfc_logmsg.h" 37 37 #include "lpfc_crtn.h" 38 38 #include "lpfc_vport.h" 39 + #include "lpfc_debugfs.h" 39 40 40 41 static int lpfc_els_retry(struct lpfc_hba *, struct lpfc_iocbq *, 41 42 struct lpfc_iocbq *); ··· 45 44 46 45 static int lpfc_max_els_tries = 3; 47 46 48 - static int 47 + int 49 48 lpfc_els_chk_latt(struct lpfc_vport *vport) 50 49 { 51 50 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); ··· 354 353 "%d:1817 Fabric does not support NPIV " 355 354 "- configuring single port mode.\n", 356 355 phba->brd_no); 357 - phba->vpi_cnt = 1; 358 356 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; 359 357 } 360 358 } ··· 406 406 407 407 spin_lock_irq(shost->host_lock); 408 408 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 409 - phba->vpi_cnt = 1; 410 409 spin_unlock_irq(shost->host_lock); 411 410 412 411 phba->fc_edtov = FF_DEF_EDTOV; ··· 498 499 goto out; 499 500 } 500 501 502 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 503 + "FLOGI cmpl: status:x%x/x%x state:x%x", 504 + irsp->ulpStatus, irsp->un.ulpWord[4], 505 + vport->port_state); 506 + 501 507 if (irsp->ulpStatus) { 502 508 /* Check for retry */ 503 509 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) ··· 511 507 /* FLOGI failed, so there is no fabric */ 512 508 spin_lock_irq(shost->host_lock); 513 509 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 514 - phba->vpi_cnt = 1; 515 510 spin_unlock_irq(shost->host_lock); 516 511 517 512 /* If private loop, then allow max outstanding els to be ··· 563 560 564 561 flogifail: 565 562 lpfc_nlp_put(ndlp); 566 - phba->vpi_cnt = 1; 567 563 568 - if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT || 569 - (irsp->un.ulpWord[4] != IOERR_SLI_ABORTED && 570 - irsp->un.ulpWord[4] != IOERR_SLI_DOWN)) { 564 + if (!lpfc_error_lost_link(irsp)) { 571 565 /* FLOGI failed, so just use loop map to make discovery list */ 572 566 lpfc_disc_list_loopmap(vport); 573 567 ··· 627 627 icmd->ulpCt_l = 0; 628 628 } 629 629 630 + if (phba->fc_topology != TOPOLOGY_LOOP) { 631 + icmd->un.elsreq64.myID = 0; 632 + icmd->un.elsreq64.fl = 1; 633 + } 634 + 630 635 tmo = phba->fc_ratov; 631 636 phba->fc_ratov = LPFC_DISC_FLOGI_TMO; 632 637 lpfc_set_disctmo(vport); ··· 639 634 640 635 phba->fc_stat.elsXmitFLOGI++; 641 636 elsiocb->iocb_cmpl = lpfc_cmpl_els_flogi; 637 + 638 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 639 + "Issue FLOGI: opt:x%x", 640 + phba->sli3_options, 0, 0); 641 + 642 642 rc = lpfc_issue_fabric_iocb(phba, elsiocb); 643 643 if (rc == IOCB_ERROR) { 644 644 lpfc_els_free_iocb(phba, elsiocb); ··· 826 816 cmdiocb->context_un.rsp_iocb = rspiocb; 827 817 828 818 irsp = &rspiocb->iocb; 819 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 820 + "PLOGI cmpl: status:x%x/x%x did:x%x", 821 + irsp->ulpStatus, irsp->un.ulpWord[4], 822 + irsp->un.elsreq64.remoteID); 823 + 829 824 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); 830 825 if (!ndlp) { 831 826 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, ··· 893 878 } 894 879 895 880 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 896 - if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 897 - ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 898 - (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 899 - (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 881 + if (lpfc_error_lost_link(irsp)) { 900 882 rc = NLP_STE_FREED_NODE; 901 883 } else { 902 884 rc = lpfc_disc_state_machine(vport, ndlp, cmdiocb, ··· 978 966 if (sp->cmn.fcphHigh < FC_PH3) 979 967 sp->cmn.fcphHigh = FC_PH3; 980 968 969 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 970 + "Issue PLOGI: did:x%x", 971 + did, 0, 0); 972 + 981 973 phba->fc_stat.elsXmitPLOGI++; 982 974 elsiocb->iocb_cmpl = lpfc_cmpl_els_plogi; 983 975 ret = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0); ··· 1013 997 ndlp->nlp_flag &= ~NLP_PRLI_SND; 1014 998 spin_unlock_irq(shost->host_lock); 1015 999 1000 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1001 + "PRLI cmpl: status:x%x/x%x did:x%x", 1002 + irsp->ulpStatus, irsp->un.ulpWord[4], 1003 + ndlp->nlp_DID); 1004 + 1016 1005 /* PRLI completes to NPort <nlp_DID> */ 1017 1006 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1018 1007 "%d (%d):0103 PRLI completes to NPort x%x " ··· 1039 1018 } 1040 1019 /* PRLI failed */ 1041 1020 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 1042 - if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1043 - ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1044 - (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 1045 - (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 1021 + if (lpfc_error_lost_link(irsp)) { 1046 1022 goto out; 1047 1023 } else { 1048 1024 lpfc_disc_state_machine(vport, ndlp, cmdiocb, ··· 1105 1087 npr->prliType = PRLI_FCP_TYPE; 1106 1088 npr->initiatorFunc = 1; 1107 1089 1090 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1091 + "Issue PRLI: did:x%x", 1092 + ndlp->nlp_DID, 0, 0); 1093 + 1108 1094 phba->fc_stat.elsXmitPRLI++; 1109 1095 elsiocb->iocb_cmpl = lpfc_cmpl_els_prli; 1110 1096 spin_lock_irq(shost->host_lock); ··· 1155 1133 { 1156 1134 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1157 1135 1136 + lpfc_can_disctmo(vport); 1137 + 1158 1138 /* RSCN discovery */ 1159 1139 /* go thru NPR nodes and issue ELS PLOGIs */ 1160 1140 if (vport->fc_npr_cnt) ··· 1193 1169 1194 1170 irsp = &(rspiocb->iocb); 1195 1171 ndlp = (struct lpfc_nodelist *) cmdiocb->context1; 1172 + 1173 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1174 + "ADISC cmpl: status:x%x/x%x did:x%x", 1175 + irsp->ulpStatus, irsp->un.ulpWord[4], 1176 + ndlp->nlp_DID); 1196 1177 1197 1178 /* Since ndlp can be freed in the disc state machine, note if this node 1198 1179 * is being used during discovery. ··· 1237 1208 } 1238 1209 /* ADISC failed */ 1239 1210 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 1240 - if ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || 1241 - ((irsp->un.ulpWord[4] != IOERR_SLI_ABORTED) && 1242 - (irsp->un.ulpWord[4] != IOERR_LINK_DOWN) && 1243 - (irsp->un.ulpWord[4] != IOERR_SLI_DOWN))) { 1211 + if (!lpfc_error_lost_link(irsp)) { 1244 1212 lpfc_disc_state_machine(vport, ndlp, cmdiocb, 1245 - NLP_EVT_CMPL_ADISC); 1213 + NLP_EVT_CMPL_ADISC); 1246 1214 } 1247 1215 } else { 1248 1216 /* Good status, call state machine */ ··· 1332 1306 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); 1333 1307 ap->DID = be32_to_cpu(vport->fc_myDID); 1334 1308 1309 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1310 + "Issue ADISC: did:x%x", 1311 + ndlp->nlp_DID, 0, 0); 1312 + 1335 1313 phba->fc_stat.elsXmitADISC++; 1336 1314 elsiocb->iocb_cmpl = lpfc_cmpl_els_adisc; 1337 1315 spin_lock_irq(shost->host_lock); ··· 1370 1340 ndlp->nlp_flag &= ~NLP_LOGO_SND; 1371 1341 spin_unlock_irq(shost->host_lock); 1372 1342 1343 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1344 + "LOGO cmpl: status:x%x/x%x did:x%x", 1345 + irsp->ulpStatus, irsp->un.ulpWord[4], 1346 + ndlp->nlp_DID); 1347 + 1373 1348 /* LOGO completes to NPort <nlp_DID> */ 1374 1349 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1375 1350 "%d (%d):0105 LOGO completes to NPort x%x " ··· 1403 1368 goto out; 1404 1369 /* LOGO failed */ 1405 1370 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 1406 - if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1407 - ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1408 - (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 1409 - (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 1371 + if (lpfc_error_lost_link(irsp)) 1410 1372 goto out; 1411 - } else { 1373 + else 1412 1374 lpfc_disc_state_machine(vport, ndlp, cmdiocb, 1413 1375 NLP_EVT_CMPL_LOGO); 1414 - } 1415 1376 } else { 1416 1377 /* Good status, call state machine. 1417 1378 * This will unregister the rpi if needed. ··· 1454 1423 pcmd += sizeof(uint32_t); 1455 1424 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); 1456 1425 1426 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1427 + "Issue LOGO: did:x%x", 1428 + ndlp->nlp_DID, 0, 0); 1429 + 1457 1430 phba->fc_stat.elsXmitLOGO++; 1458 1431 elsiocb->iocb_cmpl = lpfc_cmpl_els_logo; 1459 1432 spin_lock_irq(shost->host_lock); ··· 1483 1448 IOCB_t *irsp; 1484 1449 1485 1450 irsp = &rspiocb->iocb; 1451 + 1452 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1453 + "ELS cmd cmpl: status:x%x/x%x did:x%x", 1454 + irsp->ulpStatus, irsp->un.ulpWord[4], 1455 + irsp->un.elsreq64.remoteID); 1486 1456 1487 1457 /* ELS cmd tag <ulpIoTag> completes */ 1488 1458 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, ··· 1541 1501 /* For SCR, remainder of payload is SCR parameter page */ 1542 1502 memset(pcmd, 0, sizeof(SCR)); 1543 1503 ((SCR *) pcmd)->Function = SCR_FUNC_FULL; 1504 + 1505 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1506 + "Issue SCR: did:x%x", 1507 + ndlp->nlp_DID, 0, 0); 1544 1508 1545 1509 phba->fc_stat.elsXmitSCR++; 1546 1510 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; ··· 1612 1568 memcpy(&fp->OnodeName, &ondlp->nlp_nodename, 1613 1569 sizeof(struct lpfc_name)); 1614 1570 } 1571 + 1572 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1573 + "Issue FARPR: did:x%x", 1574 + ndlp->nlp_DID, 0, 0); 1615 1575 1616 1576 phba->fc_stat.elsXmitFARPR++; 1617 1577 elsiocb->iocb_cmpl = lpfc_cmpl_els_cmd; ··· 1811 1763 return 1; 1812 1764 } 1813 1765 1766 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1767 + "Retry ELS: wd7:x%x wd4:x%x did:x%x", 1768 + *(((uint32_t *) irsp) + 7), irsp->un.ulpWord[4], ndlp->nlp_DID); 1769 + 1814 1770 switch (irsp->ulpStatus) { 1815 1771 case IOSTAT_FCP_RSP_ERROR: 1816 1772 case IOSTAT_REMOTE_STOP: ··· 1825 1773 case IOERR_LOOP_OPEN_FAILURE: 1826 1774 if (cmd == ELS_CMD_PLOGI && cmdiocb->retry == 0) 1827 1775 delay = 1000; 1828 - retry = 1; 1829 - break; 1830 - 1831 - case IOERR_SEQUENCE_TIMEOUT: 1832 1776 retry = 1; 1833 1777 break; 1834 1778 ··· 1842 1794 break; 1843 1795 1844 1796 case IOERR_NO_RESOURCES: 1797 + retry = 1; 1798 + if (cmdiocb->retry > 100) 1799 + delay = 100; 1800 + maxretry = 250; 1801 + break; 1802 + 1803 + case IOERR_ILLEGAL_FRAME: 1845 1804 delay = 100; 1846 1805 retry = 1; 1847 1806 break; 1848 1807 1808 + case IOERR_SEQUENCE_TIMEOUT: 1849 1809 case IOERR_INVALID_RPI: 1850 1810 retry = 1; 1851 1811 break; ··· 1908 1852 break; 1909 1853 1910 1854 case LSRJT_LOGICAL_BSY: 1911 - if (cmd == ELS_CMD_PLOGI) { 1855 + if ((cmd == ELS_CMD_PLOGI) || 1856 + (cmd == ELS_CMD_PRLI)) { 1912 1857 delay = 1000; 1913 1858 maxretry = 48; 1914 1859 } else if (cmd == ELS_CMD_FDISC) { ··· 1965 1908 phba->brd_no, vport->vpi, 1966 1909 cmd, did, cmdiocb->retry, delay); 1967 1910 1968 - if ((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) { 1911 + if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && 1912 + ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || 1913 + ((irsp->un.ulpWord[4] & 0xff) != IOERR_NO_RESOURCES))) { 1914 + /* Don't reset timer for no resources */ 1915 + 1969 1916 /* If discovery / RSCN timer is running, reset it */ 1970 1917 if (timer_pending(&vport->fc_disctmo) || 1971 1918 (vport->fc_flag & FC_RSCN_MODE)) ··· 1989 1928 spin_unlock_irq(shost->host_lock); 1990 1929 1991 1930 ndlp->nlp_prev_state = ndlp->nlp_state; 1992 - lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE); 1931 + if (cmd == ELS_CMD_PRLI) 1932 + lpfc_nlp_set_state(vport, ndlp, 1933 + NLP_STE_REG_LOGIN_ISSUE); 1934 + else 1935 + lpfc_nlp_set_state(vport, ndlp, 1936 + NLP_STE_NPR_NODE); 1993 1937 ndlp->nlp_last_elscmd = cmd; 1994 1938 1995 1939 return 1; ··· 2081 2015 { 2082 2016 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; 2083 2017 struct lpfc_vport *vport = cmdiocb->vport; 2018 + IOCB_t *irsp; 2019 + 2020 + irsp = &rspiocb->iocb; 2021 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2022 + "ACC LOGO cmpl: status:x%x/x%x did:x%x", 2023 + irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); 2084 2024 2085 2025 /* ACC to LOGO completes to NPort <nlp_DID> */ 2086 2026 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, ··· 2109 2037 return; 2110 2038 } 2111 2039 2040 + void 2041 + lpfc_mbx_cmpl_dflt_rpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 2042 + { 2043 + struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); 2044 + struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) pmb->context2; 2045 + 2046 + pmb->context1 = NULL; 2047 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 2048 + kfree(mp); 2049 + mempool_free(pmb, phba->mbox_mem_pool); 2050 + lpfc_nlp_put(ndlp); 2051 + return; 2052 + } 2053 + 2112 2054 static void 2113 - lpfc_cmpl_els_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, 2055 + lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, 2114 2056 struct lpfc_iocbq *rspiocb) 2115 2057 { 2116 2058 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1; ··· 2152 2066 goto out; 2153 2067 } 2154 2068 2069 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2070 + "ACC cmpl: status:x%x/x%x did:x%x", 2071 + irsp->ulpStatus, irsp->un.ulpWord[4], 2072 + irsp->un.rcvels.remoteID); 2073 + 2155 2074 /* ELS response tag <ulpIoTag> completes */ 2156 2075 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2157 2076 "%d (%d):0110 ELS response tag x%x completes " ··· 2171 2080 if ((rspiocb->iocb.ulpStatus == 0) 2172 2081 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { 2173 2082 lpfc_unreg_rpi(vport, ndlp); 2174 - mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; 2175 2083 mbox->context2 = lpfc_nlp_get(ndlp); 2176 2084 mbox->vport = vport; 2177 - ndlp->nlp_prev_state = ndlp->nlp_state; 2178 - lpfc_nlp_set_state(vport, ndlp, 2085 + if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) { 2086 + mbox->mbox_flag |= LPFC_MBX_IMED_UNREG; 2087 + mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; 2088 + } 2089 + else { 2090 + mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; 2091 + ndlp->nlp_prev_state = ndlp->nlp_state; 2092 + lpfc_nlp_set_state(vport, ndlp, 2179 2093 NLP_STE_REG_LOGIN_ISSUE); 2094 + } 2180 2095 if (lpfc_sli_issue_mbox(phba, mbox, 2181 2096 (MBX_NOWAIT | MBX_STOP_IOCB)) 2182 2097 != MBX_NOT_FINISHED) { ··· 2192 2095 /* NOTE: we should have messages for unsuccessful 2193 2096 reglogin */ 2194 2097 } else { 2195 - /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */ 2196 - if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 2197 - ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 2198 - (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 2199 - (irsp->un.ulpWord[4] == IOERR_SLI_DOWN)))) { 2200 - if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) { 2201 - lpfc_drop_node(vport, ndlp); 2202 - ndlp = NULL; 2203 - } 2098 + /* Do not drop node for lpfc_els_abort'ed ELS cmds */ 2099 + if (!lpfc_error_lost_link(irsp) && 2100 + ndlp->nlp_flag & NLP_ACC_REGLOGIN) { 2101 + lpfc_drop_node(vport, ndlp); 2102 + ndlp = NULL; 2204 2103 } 2205 2104 } 2206 2105 mp = (struct lpfc_dmabuf *) mbox->context1; ··· 2209 2116 out: 2210 2117 if (ndlp) { 2211 2118 spin_lock_irq(shost->host_lock); 2212 - ndlp->nlp_flag &= ~NLP_ACC_REGLOGIN; 2119 + ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI); 2213 2120 spin_unlock_irq(shost->host_lock); 2214 2121 } 2215 2122 lpfc_els_free_iocb(phba, cmdiocb); ··· 2254 2161 pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2255 2162 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2256 2163 pcmd += sizeof(uint32_t); 2164 + 2165 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2166 + "Issue ACC: did:x%x flg:x%x", 2167 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 2257 2168 break; 2258 2169 case ELS_CMD_PLOGI: 2259 2170 cmdsize = (sizeof(struct serv_parm) + sizeof(uint32_t)); ··· 2276 2179 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2277 2180 pcmd += sizeof(uint32_t); 2278 2181 memcpy(pcmd, &vport->fc_sparam, sizeof(struct serv_parm)); 2182 + 2183 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2184 + "Issue ACC PLOGI: did:x%x flg:x%x", 2185 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 2279 2186 break; 2280 2187 case ELS_CMD_PRLO: 2281 2188 cmdsize = sizeof(uint32_t) + sizeof(PRLO); ··· 2297 2196 *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; 2298 2197 els_pkt_ptr = (ELS_PKT *) pcmd; 2299 2198 els_pkt_ptr->un.prlo.acceptRspCode = PRLO_REQ_EXECUTED; 2199 + 2200 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2201 + "Issue ACC PRLO: did:x%x flg:x%x", 2202 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 2300 2203 break; 2301 2204 default: 2302 2205 return 1; ··· 2325 2220 spin_unlock_irq(shost->host_lock); 2326 2221 elsiocb->iocb_cmpl = lpfc_cmpl_els_logo_acc; 2327 2222 } else { 2328 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2223 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2329 2224 } 2330 2225 2331 2226 phba->fc_stat.elsXmitACC++; ··· 2339 2234 2340 2235 int 2341 2236 lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError, 2342 - struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp) 2237 + struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, 2238 + LPFC_MBOXQ_t *mbox) 2343 2239 { 2344 2240 struct lpfc_hba *phba = vport->phba; 2345 2241 IOCB_t *icmd; ··· 2370 2264 pcmd += sizeof(uint32_t); 2371 2265 *((uint32_t *) (pcmd)) = rejectError; 2372 2266 2267 + if (mbox) { 2268 + elsiocb->context_un.mbox = mbox; 2269 + elsiocb->context1 = lpfc_nlp_get(ndlp); 2270 + } 2271 + 2373 2272 /* Xmit ELS RJT <err> response tag <ulpIoTag> */ 2374 2273 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2375 2274 "%d (%d):0129 Xmit ELS RJT x%x response tag x%x " ··· 2384 2273 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2385 2274 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2386 2275 2276 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2277 + "Issue LS_RJT: did:x%x flg:x%x err:x%x", 2278 + ndlp->nlp_DID, ndlp->nlp_flag, rejectError); 2279 + 2387 2280 phba->fc_stat.elsXmitLSRJT++; 2388 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2281 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2389 2282 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0); 2390 2283 if (rc == IOCB_ERROR) { 2391 2284 lpfc_els_free_iocb(phba, elsiocb); ··· 2441 2326 memcpy(&ap->nodeName, &vport->fc_nodename, sizeof(struct lpfc_name)); 2442 2327 ap->DID = be32_to_cpu(vport->fc_myDID); 2443 2328 2329 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2330 + "Issue ACC ADISC: did:x%x flg:x%x", 2331 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 2332 + 2444 2333 phba->fc_stat.elsXmitACC++; 2445 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2334 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2446 2335 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0); 2447 2336 if (rc == IOCB_ERROR) { 2448 2337 lpfc_els_free_iocb(phba, elsiocb); ··· 2520 2401 npr->prliType = PRLI_FCP_TYPE; 2521 2402 npr->initiatorFunc = 1; 2522 2403 2404 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2405 + "Issue ACC PRLI: did:x%x flg:x%x", 2406 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 2407 + 2523 2408 phba->fc_stat.elsXmitACC++; 2524 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2409 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2525 2410 2526 2411 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0); 2527 2412 if (rc == IOCB_ERROR) { ··· 2602 2479 break; 2603 2480 } 2604 2481 2482 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2483 + "Issue ACC RNID: did:x%x flg:x%x", 2484 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 2485 + 2605 2486 phba->fc_stat.elsXmitACC++; 2606 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2487 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2607 2488 lpfc_nlp_put(ndlp); 2608 2489 elsiocb->context1 = NULL; /* Don't need ndlp for cmpl, 2609 2490 * it could be freed */ ··· 2830 2703 * Discovery processing will satisfy it. 2831 2704 */ 2832 2705 if (vport->port_state <= LPFC_NS_QRY) { 2706 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 2707 + "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", 2708 + ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 2709 + 2833 2710 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 2834 2711 newnode); 2835 2712 return 0; ··· 2865 2734 "%d (%d):0214 Ignore RSCN Data: x%x x%x x%x x%x\n", 2866 2735 phba->brd_no, vport->vpi, vport->fc_flag, payload_len, 2867 2736 *lp, rscn_cnt); 2737 + 2738 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 2739 + "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", 2740 + ndlp->nlp_DID, vport->port_state, 2741 + ndlp->nlp_flag); 2742 + 2868 2743 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, 2869 2744 ndlp, NULL, newnode); 2870 2745 return 0; ··· 2881 2744 * RSCN payload buffer, cmdiocb->context2 to process later. 2882 2745 */ 2883 2746 if (vport->fc_flag & (FC_RSCN_MODE | FC_NDISC_ACTIVE)) { 2747 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 2748 + "RCV RSCN defer: did:x%x/ste:x%x flg:x%x", 2749 + ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 2750 + 2884 2751 vport->fc_flag |= FC_RSCN_DEFERRED; 2885 2752 if ((rscn_cnt < FC_MAX_HOLD_RSCN) && 2886 2753 !(vport->fc_flag & FC_RSCN_DISCOVERY)) { ··· 2938 2797 vport->fc_flag &= ~FC_RSCN_DEFERRED; 2939 2798 return 0; 2940 2799 } 2800 + 2801 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 2802 + "RCV RSCN: did:x%x/ste:x%x flg:x%x", 2803 + ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 2941 2804 2942 2805 spin_lock_irq(shost->host_lock); 2943 2806 vport->fc_flag |= FC_RSCN_MODE; ··· 3103 2958 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3104 2959 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; 3105 2960 stat.un.b.vendorUnique = 0; 3106 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 2961 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, 2962 + NULL); 3107 2963 return 1; 3108 2964 } 3109 2965 ··· 3147 3001 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3148 3002 stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; 3149 3003 stat.un.b.vendorUnique = 0; 3150 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 3004 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, 3005 + NULL); 3151 3006 } 3152 3007 return 0; 3153 3008 } ··· 3164 3017 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3165 3018 stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; 3166 3019 stat.un.b.vendorUnique = 0; 3167 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 3020 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); 3168 3021 return 0; 3169 3022 } 3170 3023 ··· 3236 3089 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 3237 3090 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 3238 3091 3239 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 3092 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 3240 3093 phba->fc_stat.elsXmitACC++; 3241 3094 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) 3242 3095 lpfc_els_free_iocb(phba, elsiocb); ··· 3261 3114 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3262 3115 stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; 3263 3116 stat.un.b.vendorUnique = 0; 3264 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 3117 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, 3118 + NULL); 3265 3119 } 3266 3120 3267 3121 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; ··· 3298 3150 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3299 3151 stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; 3300 3152 stat.un.b.vendorUnique = 0; 3301 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 3153 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); 3302 3154 return 0; 3303 3155 } 3304 3156 ··· 3350 3202 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 3351 3203 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 3352 3204 3353 - elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 3205 + elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 3354 3206 3355 3207 phba->fc_stat.elsXmitACC++; 3356 3208 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { ··· 3377 3229 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3378 3230 stat.un.b.lsRjtRsnCodeExp = LSEXP_CANT_GIVE_DATA; 3379 3231 stat.un.b.vendorUnique = 0; 3380 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 3232 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, 3233 + NULL); 3381 3234 } 3382 3235 3383 3236 pcmd = (struct lpfc_dmabuf *) cmdiocb->context2; ··· 3687 3538 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING]; 3688 3539 struct lpfc_iocbq *tmp_iocb, *piocb; 3689 3540 IOCB_t *cmd = NULL; 3690 - struct lpfc_dmabuf *pcmd; 3691 - uint32_t *elscmd; 3692 - uint32_t els_command; 3693 3541 3694 3542 lpfc_fabric_abort_vport(vport); 3695 3543 ··· 3704 3558 cmd->ulpCommand == CMD_CLOSE_XRI_CN || 3705 3559 cmd->ulpCommand == CMD_ABORT_XRI_CN) 3706 3560 continue; 3707 - 3708 - pcmd = (struct lpfc_dmabuf *) piocb->context2; 3709 - elscmd = (uint32_t *) (pcmd->virt); 3710 - els_command = *elscmd; 3711 3561 3712 3562 if (piocb->vport != vport) 3713 3563 continue; ··· 3760 3618 if ((phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) == 0) 3761 3619 lpfc_post_buffer(phba, pring, 1, 1); 3762 3620 3763 - if (icmd->ulpStatus) 3621 + did = icmd->un.rcvels.remoteID; 3622 + if (icmd->ulpStatus) { 3623 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3624 + "RCV Unsol ELS: status:x%x/x%x did:x%x", 3625 + icmd->ulpStatus, icmd->un.ulpWord[4], did); 3764 3626 goto dropit; 3627 + } 3765 3628 3766 3629 /* Check to see if link went down during discovery */ 3767 3630 if (lpfc_els_chk_latt(vport)) ··· 3776 3629 if (vport->load_flag & FC_UNLOADING) 3777 3630 goto dropit; 3778 3631 3779 - did = icmd->un.rcvels.remoteID; 3780 3632 ndlp = lpfc_findnode_did(vport, did); 3781 3633 if (!ndlp) { 3782 3634 /* Cannot find existing Fabric ndlp, so allocate a new one */ ··· 3808 3662 3809 3663 switch (cmd) { 3810 3664 case ELS_CMD_PLOGI: 3665 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3666 + "RCV PLOGI: did:x%x/ste:x%x flg:x%x", 3667 + did, vport->port_state, ndlp->nlp_flag); 3668 + 3811 3669 phba->fc_stat.elsRcvPLOGI++; 3812 - if ((vport->port_state < LPFC_DISC_AUTH) || 3813 - ((vport->port_type == LPFC_NPIV_PORT && 3814 - phba->cfg_vport_restrict_login))) { 3815 - rjt_err = 2; 3670 + ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); 3671 + 3672 + if (vport->port_state < LPFC_DISC_AUTH) { 3673 + rjt_err = LSRJT_UNABLE_TPC; 3816 3674 break; 3817 3675 } 3818 - ndlp = lpfc_plogi_confirm_nport(phba, payload, ndlp); 3819 3676 lpfc_disc_state_machine(vport, ndlp, elsiocb, 3820 3677 NLP_EVT_RCV_PLOGI); 3678 + 3821 3679 break; 3822 3680 case ELS_CMD_FLOGI: 3681 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3682 + "RCV FLOGI: did:x%x/ste:x%x flg:x%x", 3683 + did, vport->port_state, ndlp->nlp_flag); 3684 + 3823 3685 phba->fc_stat.elsRcvFLOGI++; 3824 3686 lpfc_els_rcv_flogi(vport, elsiocb, ndlp, newnode); 3825 3687 if (newnode) 3826 3688 lpfc_drop_node(vport, ndlp); 3827 3689 break; 3828 3690 case ELS_CMD_LOGO: 3691 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3692 + "RCV LOGO: did:x%x/ste:x%x flg:x%x", 3693 + did, vport->port_state, ndlp->nlp_flag); 3694 + 3829 3695 phba->fc_stat.elsRcvLOGO++; 3830 3696 if (vport->port_state < LPFC_DISC_AUTH) { 3831 - rjt_err = 1; 3697 + rjt_err = LSRJT_UNABLE_TPC; 3832 3698 break; 3833 3699 } 3834 3700 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_LOGO); 3835 3701 break; 3836 3702 case ELS_CMD_PRLO: 3703 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3704 + "RCV PRLO: did:x%x/ste:x%x flg:x%x", 3705 + did, vport->port_state, ndlp->nlp_flag); 3706 + 3837 3707 phba->fc_stat.elsRcvPRLO++; 3838 3708 if (vport->port_state < LPFC_DISC_AUTH) { 3839 - rjt_err = 1; 3709 + rjt_err = LSRJT_UNABLE_TPC; 3840 3710 break; 3841 3711 } 3842 3712 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLO); ··· 3864 3702 lpfc_drop_node(vport, ndlp); 3865 3703 break; 3866 3704 case ELS_CMD_ADISC: 3705 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3706 + "RCV ADISC: did:x%x/ste:x%x flg:x%x", 3707 + did, vport->port_state, ndlp->nlp_flag); 3708 + 3867 3709 phba->fc_stat.elsRcvADISC++; 3868 3710 if (vport->port_state < LPFC_DISC_AUTH) { 3869 - rjt_err = 1; 3711 + rjt_err = LSRJT_UNABLE_TPC; 3870 3712 break; 3871 3713 } 3872 3714 lpfc_disc_state_machine(vport, ndlp, elsiocb, 3873 3715 NLP_EVT_RCV_ADISC); 3874 3716 break; 3875 3717 case ELS_CMD_PDISC: 3718 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3719 + "RCV PDISC: did:x%x/ste:x%x flg:x%x", 3720 + did, vport->port_state, ndlp->nlp_flag); 3721 + 3876 3722 phba->fc_stat.elsRcvPDISC++; 3877 3723 if (vport->port_state < LPFC_DISC_AUTH) { 3878 - rjt_err = 1; 3724 + rjt_err = LSRJT_UNABLE_TPC; 3879 3725 break; 3880 3726 } 3881 3727 lpfc_disc_state_machine(vport, ndlp, elsiocb, 3882 3728 NLP_EVT_RCV_PDISC); 3883 3729 break; 3884 3730 case ELS_CMD_FARPR: 3731 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3732 + "RCV FARPR: did:x%x/ste:x%x flg:x%x", 3733 + did, vport->port_state, ndlp->nlp_flag); 3734 + 3885 3735 phba->fc_stat.elsRcvFARPR++; 3886 3736 lpfc_els_rcv_farpr(vport, elsiocb, ndlp); 3887 3737 break; 3888 3738 case ELS_CMD_FARP: 3739 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3740 + "RCV FARP: did:x%x/ste:x%x flg:x%x", 3741 + did, vport->port_state, ndlp->nlp_flag); 3742 + 3889 3743 phba->fc_stat.elsRcvFARP++; 3890 3744 lpfc_els_rcv_farp(vport, elsiocb, ndlp); 3891 3745 break; 3892 3746 case ELS_CMD_FAN: 3747 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3748 + "RCV FAN: did:x%x/ste:x%x flg:x%x", 3749 + did, vport->port_state, ndlp->nlp_flag); 3750 + 3893 3751 phba->fc_stat.elsRcvFAN++; 3894 3752 lpfc_els_rcv_fan(vport, elsiocb, ndlp); 3895 3753 break; 3896 3754 case ELS_CMD_PRLI: 3755 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3756 + "RCV PRLI: did:x%x/ste:x%x flg:x%x", 3757 + did, vport->port_state, ndlp->nlp_flag); 3758 + 3897 3759 phba->fc_stat.elsRcvPRLI++; 3898 3760 if (vport->port_state < LPFC_DISC_AUTH) { 3899 - rjt_err = 1; 3761 + rjt_err = LSRJT_UNABLE_TPC; 3900 3762 break; 3901 3763 } 3902 3764 lpfc_disc_state_machine(vport, ndlp, elsiocb, NLP_EVT_RCV_PRLI); 3903 3765 break; 3904 3766 case ELS_CMD_LIRR: 3767 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3768 + "RCV LIRR: did:x%x/ste:x%x flg:x%x", 3769 + did, vport->port_state, ndlp->nlp_flag); 3770 + 3905 3771 phba->fc_stat.elsRcvLIRR++; 3906 3772 lpfc_els_rcv_lirr(vport, elsiocb, ndlp); 3907 3773 if (newnode) 3908 3774 lpfc_drop_node(vport, ndlp); 3909 3775 break; 3910 3776 case ELS_CMD_RPS: 3777 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3778 + "RCV RPS: did:x%x/ste:x%x flg:x%x", 3779 + did, vport->port_state, ndlp->nlp_flag); 3780 + 3911 3781 phba->fc_stat.elsRcvRPS++; 3912 3782 lpfc_els_rcv_rps(vport, elsiocb, ndlp); 3913 3783 if (newnode) 3914 3784 lpfc_drop_node(vport, ndlp); 3915 3785 break; 3916 3786 case ELS_CMD_RPL: 3787 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3788 + "RCV RPL: did:x%x/ste:x%x flg:x%x", 3789 + did, vport->port_state, ndlp->nlp_flag); 3790 + 3917 3791 phba->fc_stat.elsRcvRPL++; 3918 3792 lpfc_els_rcv_rpl(vport, elsiocb, ndlp); 3919 3793 if (newnode) 3920 3794 lpfc_drop_node(vport, ndlp); 3921 3795 break; 3922 3796 case ELS_CMD_RNID: 3797 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3798 + "RCV RNID: did:x%x/ste:x%x flg:x%x", 3799 + did, vport->port_state, ndlp->nlp_flag); 3800 + 3923 3801 phba->fc_stat.elsRcvRNID++; 3924 3802 lpfc_els_rcv_rnid(vport, elsiocb, ndlp); 3925 3803 if (newnode) 3926 3804 lpfc_drop_node(vport, ndlp); 3927 3805 break; 3928 3806 default: 3807 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3808 + "RCV ELS cmd: cmd:x%x did:x%x/ste:x%x", 3809 + cmd, did, vport->port_state); 3810 + 3929 3811 /* Unsupported ELS command, reject */ 3930 - rjt_err = 2; 3812 + rjt_err = LSRJT_INVALID_CMD; 3931 3813 3932 3814 /* Unknown ELS command <elsCmd> received from NPORT <did> */ 3933 3815 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, ··· 3986 3780 /* check if need to LS_RJT received ELS cmd */ 3987 3781 if (rjt_err) { 3988 3782 memset(&stat, 0, sizeof(stat)); 3989 - if (rjt_err == 1) 3990 - stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 3991 - else 3992 - stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD; 3783 + stat.un.b.lsRjtRsnCode = rjt_err; 3993 3784 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 3994 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp); 3785 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp, 3786 + NULL); 3995 3787 if (newnode) 3996 3788 lpfc_drop_node(vport, ndlp); 3997 3789 } ··· 4248 4044 lpfc_set_disctmo(piocb->vport); 4249 4045 } 4250 4046 4047 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 4048 + "FDISC cmpl: status:x%x/x%x prevdid:x%x", 4049 + irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID); 4050 + 4251 4051 if (irsp->ulpStatus) { 4252 4052 /* Check for retry */ 4253 4053 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) ··· 4262 4054 "%d (%d):0124 FDISC failed. (%d/%d)\n", 4263 4055 phba->brd_no, vport->vpi, 4264 4056 irsp->ulpStatus, irsp->un.ulpWord[4]); 4057 + 4265 4058 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) 4266 4059 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4267 4060 ··· 4322 4113 uint16_t cmdsize; 4323 4114 int did = ndlp->nlp_DID; 4324 4115 int rc; 4325 - int new_ndlp = 0; 4326 4116 4327 4117 cmdsize = (sizeof(uint32_t) + sizeof(struct serv_parm)); 4328 4118 elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp, did, 4329 4119 ELS_CMD_FDISC); 4330 4120 if (!elsiocb) { 4331 - if (new_ndlp) 4332 - mempool_free(ndlp, phba->nlp_mem_pool); 4333 4121 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4334 4122 4335 4123 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, ··· 4369 4163 phba->fc_stat.elsXmitFDISC++; 4370 4164 elsiocb->iocb_cmpl = lpfc_cmpl_els_fdisc; 4371 4165 4166 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 4167 + "Issue FDISC: did:x%x", 4168 + did, 0, 0); 4169 + 4372 4170 rc = lpfc_issue_fabric_iocb(phba, elsiocb); 4373 4171 if (rc == IOCB_ERROR) { 4374 4172 lpfc_els_free_iocb(phba, elsiocb); 4375 - if (new_ndlp) 4376 - mempool_free(ndlp, phba->nlp_mem_pool); 4377 4173 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4378 4174 4379 4175 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, ··· 4394 4186 struct lpfc_iocbq *rspiocb) 4395 4187 { 4396 4188 struct lpfc_vport *vport = cmdiocb->vport; 4189 + IOCB_t *irsp; 4190 + 4191 + irsp = &rspiocb->iocb; 4192 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 4193 + "LOGO npiv cmpl: status:x%x/x%x did:x%x", 4194 + irsp->ulpStatus, irsp->un.ulpWord[4], irsp->un.rcvels.remoteID); 4397 4195 4398 4196 lpfc_els_free_iocb(phba, cmdiocb); 4399 4197 vport->unreg_vpi_cmpl = VPORT_ERROR; ··· 4431 4217 *((uint32_t *) (pcmd)) = be32_to_cpu(vport->fc_myDID); 4432 4218 pcmd += sizeof(uint32_t); 4433 4219 memcpy(pcmd, &vport->fc_portname, sizeof(struct lpfc_name)); 4220 + 4221 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 4222 + "Issue LOGO npiv did:x%x flg:x%x", 4223 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 4434 4224 4435 4225 elsiocb->iocb_cmpl = lpfc_cmpl_els_npiv_logo; 4436 4226 spin_lock_irq(shost->host_lock); ··· 4494 4276 iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; 4495 4277 iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; 4496 4278 iocb->iocb_flag |= LPFC_IO_FABRIC; 4279 + 4280 + lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, 4281 + "Fabric sched1: ste:x%x", 4282 + iocb->vport->port_state, 0, 0); 4497 4283 4498 4284 ret = lpfc_sli_issue_iocb(phba, pring, iocb, 0); 4499 4285 ··· 4608 4386 iocb->fabric_iocb_cmpl = iocb->iocb_cmpl; 4609 4387 iocb->iocb_cmpl = lpfc_cmpl_fabric_iocb; 4610 4388 iocb->iocb_flag |= LPFC_IO_FABRIC; 4389 + 4390 + lpfc_debugfs_disc_trc(iocb->vport, LPFC_DISC_TRC_ELS_CMD, 4391 + "Fabric sched2: ste:x%x", 4392 + iocb->vport->port_state, 0, 0); 4611 4393 4612 4394 atomic_inc(&phba->fabric_iocb_count); 4613 4395 ret = lpfc_sli_issue_iocb(phba, pring, iocb, 0);
+195 -81
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 37 37 #include "lpfc_logmsg.h" 38 38 #include "lpfc_crtn.h" 39 39 #include "lpfc_vport.h" 40 + #include "lpfc_debugfs.h" 40 41 41 42 /* AlpaArray for assignment of scsid for scan-down and bind_method */ 42 43 static uint8_t lpfcAlpaArray[] = { ··· 78 77 79 78 phba = ndlp->vport->phba; 80 79 80 + lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_RPORT, 81 + "rport terminate: sid:x%x did:x%x flg:x%x", 82 + ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag); 83 + 81 84 if (ndlp->nlp_sid != NLP_NO_SID) { 82 85 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 83 86 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); ··· 98 93 { 99 94 struct lpfc_rport_data *rdata; 100 95 struct lpfc_nodelist * ndlp; 101 - uint8_t *name; 102 - int warn_on = 0; 103 - struct lpfc_hba *phba; 104 96 struct lpfc_vport *vport; 105 - int put_node; 106 - int put_rport; 97 + struct lpfc_hba *phba; 98 + struct completion devloss_compl; 99 + struct lpfc_work_evt *evtp; 107 100 108 101 rdata = rport->dd_data; 109 102 ndlp = rdata->pnode; ··· 115 112 return; 116 113 } 117 114 115 + vport = ndlp->vport; 116 + phba = vport->phba; 117 + 118 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, 119 + "rport devlosscb: sid:x%x did:x%x flg:x%x", 120 + ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag); 121 + 122 + init_completion(&devloss_compl); 123 + evtp = &ndlp->dev_loss_evt; 124 + 125 + if (!list_empty(&evtp->evt_listp)) 126 + return; 127 + 128 + spin_lock_irq(&phba->hbalock); 129 + evtp->evt_arg1 = ndlp; 130 + evtp->evt_arg2 = &devloss_compl; 131 + evtp->evt = LPFC_EVT_DEV_LOSS; 132 + list_add_tail(&evtp->evt_listp, &phba->work_list); 133 + if (phba->work_wait) 134 + wake_up(phba->work_wait); 135 + 136 + spin_unlock_irq(&phba->hbalock); 137 + 138 + wait_for_completion(&devloss_compl); 139 + 140 + return; 141 + } 142 + 143 + /* 144 + * This function is called from the worker thread when dev_loss_tmo 145 + * expire. 146 + */ 147 + void 148 + lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp) 149 + { 150 + struct lpfc_rport_data *rdata; 151 + struct fc_rport *rport; 152 + struct lpfc_vport *vport; 153 + struct lpfc_hba *phba; 154 + uint8_t *name; 155 + int warn_on = 0; 156 + 157 + rport = ndlp->rport; 158 + 159 + if (!rport) 160 + return; 161 + 162 + rdata = rport->dd_data; 163 + name = (uint8_t *) &ndlp->nlp_portname; 164 + vport = ndlp->vport; 165 + phba = vport->phba; 166 + 167 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, 168 + "rport devlosstmo:did:x%x type:x%x id:x%x", 169 + ndlp->nlp_DID, ndlp->nlp_type, rport->scsi_target_id); 170 + 171 + if (!(vport->load_flag & FC_UNLOADING) && 172 + ndlp->nlp_state == NLP_STE_MAPPED_NODE) 173 + return; 174 + 118 175 if (ndlp->nlp_type & NLP_FABRIC) { 176 + int put_node; 177 + int put_rport; 178 + 119 179 /* We will clean up these Nodes in linkup */ 120 180 put_node = rdata->pnode != NULL; 121 181 put_rport = ndlp->rport != NULL; ··· 190 124 put_device(&rport->dev); 191 125 return; 192 126 } 193 - 194 - name = (uint8_t *)&ndlp->nlp_portname; 195 - vport = ndlp->vport; 196 - phba = vport->phba; 197 - 198 - if (!(vport->load_flag & FC_UNLOADING) && 199 - ndlp->nlp_state == NLP_STE_MAPPED_NODE) 200 - return; 201 - 202 127 203 128 if (ndlp->nlp_sid != NLP_NO_SID) { 204 129 warn_on = 1; ··· 228 171 (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE)) 229 172 lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM); 230 173 else { 174 + int put_node; 175 + int put_rport; 176 + 231 177 put_node = rdata->pnode != NULL; 232 178 put_rport = ndlp->rport != NULL; 233 179 rdata->pnode = NULL; ··· 240 180 if (put_rport) 241 181 put_device(&rport->dev); 242 182 } 243 - return; 244 183 } 245 184 246 185 ··· 265 206 spin_unlock_irq(&phba->hbalock); 266 207 free_evt = 1; 267 208 switch (evtp->evt) { 268 - case LPFC_EVT_DEV_LOSS: 209 + case LPFC_EVT_DEV_LOSS_DELAY: 269 210 free_evt = 0; /* evt is part of ndlp */ 270 211 ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1); 271 212 vport = ndlp->vport; 272 213 if (!vport) 273 214 break; 215 + 216 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, 217 + "rport devlossdly:did:x%x flg:x%x", 218 + ndlp->nlp_DID, ndlp->nlp_flag, 0); 219 + 274 220 if (!(vport->load_flag & FC_UNLOADING) && 275 221 !(ndlp->nlp_flag & NLP_DELAY_TMO) && 276 222 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)) { ··· 287 223 ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1); 288 224 lpfc_els_retry_delay_handler(ndlp); 289 225 free_evt = 0; /* evt is part of ndlp */ 226 + break; 227 + case LPFC_EVT_DEV_LOSS: 228 + ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1); 229 + lpfc_nlp_get(ndlp); 230 + lpfc_dev_loss_tmo_handler(ndlp); 231 + free_evt = 0; 232 + complete((struct completion *)(evtp->evt_arg2)); 233 + lpfc_nlp_put(ndlp); 290 234 break; 291 235 case LPFC_EVT_ONLINE: 292 236 if (phba->link_state < LPFC_LINK_DOWN) ··· 344 272 345 273 } 346 274 347 - static void 275 + void 348 276 lpfc_work_done(struct lpfc_hba *phba) 349 277 { 350 278 struct lpfc_sli_ring *pring; 351 - uint32_t ha_copy, control, work_port_events; 279 + uint32_t ha_copy, status, control, work_port_events; 352 280 struct lpfc_vport *vport; 353 - int i; 354 281 355 282 spin_lock_irq(&phba->hbalock); 356 283 ha_copy = phba->work_ha; ··· 381 310 if (work_port_events & WORKER_ELS_TMO) 382 311 lpfc_els_timeout_handler(vport); 383 312 313 + if (work_port_events & WORKER_HB_TMO) 314 + lpfc_hb_timeout_handler(phba); 315 + 384 316 if (work_port_events & WORKER_MBOX_TMO) 385 317 lpfc_mbox_timeout_handler(phba); 386 318 ··· 407 333 } 408 334 spin_unlock_irq(&phba->hbalock); 409 335 410 - for (i = 0; i < phba->sli.num_rings; i++, ha_copy >>= 4) { 411 - pring = &phba->sli.ring[i]; 412 - if ((ha_copy & HA_RXATT) 413 - || (pring->flag & LPFC_DEFERRED_RING_EVENT)) { 414 - if (pring->flag & LPFC_STOP_IOCB_MASK) { 415 - pring->flag |= LPFC_DEFERRED_RING_EVENT; 416 - } else { 417 - lpfc_sli_handle_slow_ring_event(phba, pring, 418 - (ha_copy & 419 - HA_RXMASK)); 420 - pring->flag &= ~LPFC_DEFERRED_RING_EVENT; 421 - } 422 - /* 423 - * Turn on Ring interrupts 424 - */ 425 - spin_lock_irq(&phba->hbalock); 426 - control = readl(phba->HCregaddr); 427 - control |= (HC_R0INT_ENA << i); 336 + pring = &phba->sli.ring[LPFC_ELS_RING]; 337 + status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); 338 + status >>= (4*LPFC_ELS_RING); 339 + if ((status & HA_RXMASK) 340 + || (pring->flag & LPFC_DEFERRED_RING_EVENT)) { 341 + if (pring->flag & LPFC_STOP_IOCB_MASK) { 342 + pring->flag |= LPFC_DEFERRED_RING_EVENT; 343 + } else { 344 + lpfc_sli_handle_slow_ring_event(phba, pring, 345 + (status & 346 + HA_RXMASK)); 347 + pring->flag &= ~LPFC_DEFERRED_RING_EVENT; 348 + } 349 + /* 350 + * Turn on Ring interrupts 351 + */ 352 + spin_lock_irq(&phba->hbalock); 353 + control = readl(phba->HCregaddr); 354 + if (!(control & (HC_R0INT_ENA << LPFC_ELS_RING))) { 355 + control |= (HC_R0INT_ENA << LPFC_ELS_RING); 428 356 writel(control, phba->HCregaddr); 429 357 readl(phba->HCregaddr); /* flush */ 430 - spin_unlock_irq(&phba->hbalock); 431 358 } 359 + spin_unlock_irq(&phba->hbalock); 432 360 } 433 - 434 361 lpfc_work_list_done(phba); 435 362 } 436 363 ··· 440 365 { 441 366 struct lpfc_vport *vport; 442 367 struct lpfc_sli_ring *pring; 443 - int i, rc = 0; 368 + int rc = 0; 444 369 445 370 spin_lock_irq(&phba->hbalock); 446 371 list_for_each_entry(vport, &phba->port_list, listentry) { ··· 455 380 rc = 1; 456 381 goto exit; 457 382 } 458 - for (i = 0; i < phba->sli.num_rings; i++) { 459 - pring = &phba->sli.ring[i]; 460 - if (pring->flag & LPFC_DEFERRED_RING_EVENT) { 461 - rc = 1; 462 - goto exit; 463 - } 464 - } 383 + 384 + pring = &phba->sli.ring[LPFC_ELS_RING]; 385 + if (pring->flag & LPFC_DEFERRED_RING_EVENT) 386 + rc = 1; 465 387 exit: 466 388 if (rc) 467 389 phba->work_found++; ··· 578 506 579 507 fc_host_post_event(shost, fc_get_event_number(), FCH_EVT_LINKDOWN, 0); 580 508 509 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 510 + "Link Down: state:x%x rtry:x%x flg:x%x", 511 + vport->port_state, vport->fc_ns_retry, vport->fc_flag); 512 + 581 513 /* Cleanup any outstanding RSCN activity */ 582 514 lpfc_els_flush_rscn(vport); 583 515 ··· 692 616 693 617 if ((vport->load_flag & FC_UNLOADING) != 0) 694 618 return; 619 + 620 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 621 + "Link Up: top:x%x speed:x%x flg:x%x", 622 + phba->fc_topology, phba->fc_linkspeed, phba->link_flag); 695 623 696 624 /* If NPIV is not enabled, only bring the physical port up */ 697 625 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && ··· 1015 935 } 1016 936 } else { 1017 937 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) { 1018 - if (phba->max_vpi && lpfc_npiv_enable && 938 + if (phba->max_vpi && phba->cfg_npiv_enable && 1019 939 (phba->sli_rev == 3)) 1020 940 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; 1021 941 } ··· 1204 1124 "mb status = 0x%x\n", 1205 1125 phba->brd_no, vport->vpi, mb->mbxStatus); 1206 1126 break; 1207 - default: 1208 - phba->vpi_cnt--; 1209 1127 } 1210 1128 vport->unreg_vpi_cmpl = VPORT_OK; 1211 1129 mempool_free(pmb, phba->mbox_mem_pool); ··· 1260 1182 vport->fc_myDID = 0; 1261 1183 goto out; 1262 1184 } 1263 - phba->vpi_cnt++; 1264 1185 1265 1186 vport->num_disc_nodes = 0; 1266 1187 /* go thru NPR list and issue ELS PLOGIs */ ··· 1334 1257 1335 1258 if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) 1336 1259 lpfc_initial_fdisc(next_vport); 1337 - else { 1338 - if (phba->sli3_options & 1339 - LPFC_SLI3_NPIV_ENABLED) { 1340 - lpfc_vport_set_state(vport, 1341 - FC_VPORT_NO_FABRIC_SUPP); 1342 - lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1260 + else if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { 1261 + lpfc_vport_set_state(vport, 1262 + FC_VPORT_NO_FABRIC_SUPP); 1263 + lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1343 1264 "%d (%d):0259 No NPIV Fabric " 1344 1265 "support\n", 1345 1266 phba->brd_no, vport->vpi); 1346 - } 1347 1267 } 1348 1268 } 1349 1269 lpfc_do_scr_ns_plogi(phba, vport); ··· 1451 1377 ((struct lpfc_rport_data *) ndlp->rport->dd_data)->pnode == ndlp) { 1452 1378 lpfc_nlp_put(ndlp); 1453 1379 } 1380 + 1381 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, 1382 + "rport add: did:x%x flg:x%x type x%x", 1383 + ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type); 1384 + 1454 1385 ndlp->rport = rport = fc_remote_port_add(shost, 0, &rport_ids); 1455 1386 if (!rport || !get_device(&rport->dev)) { 1456 1387 dev_printk(KERN_WARNING, &phba->pcidev->dev, ··· 1473 1394 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; 1474 1395 if (ndlp->nlp_type & NLP_FCP_INITIATOR) 1475 1396 rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; 1476 - del_timer_sync(&ndlp->nlp_initiator_tmr); 1477 1397 1478 1398 1479 1399 if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN) ··· 1489 1411 lpfc_unregister_remote_port(struct lpfc_nodelist *ndlp) 1490 1412 { 1491 1413 struct fc_rport *rport = ndlp->rport; 1414 + 1415 + lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_RPORT, 1416 + "rport delete: did:x%x flg:x%x type x%x", 1417 + ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type); 1492 1418 1493 1419 fc_remote_port_delete(rport); 1494 1420 ··· 1560 1478 if (new_state == NLP_STE_MAPPED_NODE || 1561 1479 new_state == NLP_STE_UNMAPPED_NODE) { 1562 1480 vport->phba->nport_event_cnt++; 1563 - /* 1564 - * Tell the fc transport about the port, if we haven't 1565 - * already. If we have, and it's a scsi entity, be 1566 - * sure to unblock any attached scsi devices 1567 - */ 1568 - lpfc_register_remote_port(vport, ndlp); 1481 + /* 1482 + * Tell the fc transport about the port, if we haven't 1483 + * already. If we have, and it's a scsi entity, be 1484 + * sure to unblock any attached scsi devices 1485 + */ 1486 + lpfc_register_remote_port(vport, ndlp); 1569 1487 } 1570 - 1571 - /* 1572 - * if we added to Mapped list, but the remote port 1573 - * registration failed or assigned a target id outside 1574 - * our presentable range - move the node to the 1575 - * Unmapped List 1576 - */ 1488 + /* 1489 + * if we added to Mapped list, but the remote port 1490 + * registration failed or assigned a target id outside 1491 + * our presentable range - move the node to the 1492 + * Unmapped List 1493 + */ 1577 1494 if (new_state == NLP_STE_MAPPED_NODE && 1578 1495 (!ndlp->rport || 1579 1496 ndlp->rport->scsi_target_id == -1 || ··· 1614 1533 char name1[16], name2[16]; 1615 1534 1616 1535 lpfc_printf_log(vport->phba, KERN_INFO, LOG_NODE, 1617 - "%d:0904 NPort state transition x%06x, %s -> %s\n", 1618 - vport->phba->brd_no, 1536 + "%d (%d):0904 NPort state transition x%06x, %s -> %s\n", 1537 + vport->phba->brd_no, vport->vpi, 1619 1538 ndlp->nlp_DID, 1620 1539 lpfc_nlp_state_name(name1, sizeof(name1), old_state), 1621 1540 lpfc_nlp_state_name(name2, sizeof(name2), state)); 1541 + 1542 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, 1543 + "node statechg did:x%x old:%d ste:%d", 1544 + ndlp->nlp_DID, old_state, state); 1545 + 1622 1546 if (old_state == NLP_STE_NPR_NODE && 1623 1547 (ndlp->nlp_flag & NLP_DELAY_TMO) != 0 && 1624 1548 state != NLP_STE_NPR_NODE) ··· 1657 1571 spin_lock_irq(shost->host_lock); 1658 1572 list_del_init(&ndlp->nlp_listp); 1659 1573 spin_unlock_irq(shost->host_lock); 1660 - lpfc_nlp_state_cleanup(vport, ndlp, ndlp->nlp_state, 0); 1574 + lpfc_nlp_state_cleanup(vport, ndlp, ndlp->nlp_state, 1575 + NLP_STE_UNUSED_NODE); 1661 1576 } 1662 1577 1663 1578 void ··· 1672 1585 lpfc_nlp_counters(vport, ndlp->nlp_state, -1); 1673 1586 spin_lock_irq(shost->host_lock); 1674 1587 list_del_init(&ndlp->nlp_listp); 1588 + ndlp->nlp_flag &= ~NLP_TARGET_REMOVE; 1675 1589 spin_unlock_irq(shost->host_lock); 1676 1590 lpfc_nlp_put(ndlp); 1677 1591 } ··· 1695 1607 * FC spec states we need 3 * ratov for CT requests 1696 1608 */ 1697 1609 tmo = ((phba->fc_ratov * 3) + 3); 1610 + } 1611 + 1612 + 1613 + if (!timer_pending(&vport->fc_disctmo)) { 1614 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1615 + "set disc timer: tmo:x%x state:x%x flg:x%x", 1616 + tmo, vport->port_state, vport->fc_flag); 1698 1617 } 1699 1618 1700 1619 mod_timer(&vport->fc_disctmo, jiffies + HZ * tmo); ··· 1729 1634 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1730 1635 struct lpfc_hba *phba = vport->phba; 1731 1636 unsigned long iflags; 1637 + 1638 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1639 + "can disc timer: state:x%x rtry:x%x flg:x%x", 1640 + vport->port_state, vport->fc_ns_retry, vport->fc_flag); 1732 1641 1733 1642 /* Turn off discovery timer if its running */ 1734 1643 if (vport->fc_flag & FC_DISC_TMO) { ··· 1997 1898 1998 1899 ndlp->nlp_last_elscmd = 0; 1999 1900 del_timer_sync(&ndlp->nlp_delayfunc); 2000 - del_timer_sync(&ndlp->nlp_initiator_tmr); 2001 1901 2002 1902 if (!list_empty(&ndlp->els_retry_evt.evt_listp)) 2003 1903 list_del_init(&ndlp->els_retry_evt.evt_listp); 2004 1904 if (!list_empty(&ndlp->dev_loss_evt.evt_listp)) 2005 1905 list_del_init(&ndlp->dev_loss_evt.evt_listp); 1906 + 1907 + if (!list_empty(&ndlp->dev_loss_evt.evt_listp)) { 1908 + list_del_init(&ndlp->dev_loss_evt.evt_listp); 1909 + complete((struct completion *)(ndlp->dev_loss_evt.evt_arg2)); 1910 + } 2006 1911 2007 1912 lpfc_unreg_rpi(vport, ndlp); 2008 1913 ··· 2521 2418 vport->fc_flag &= ~FC_DISC_TMO; 2522 2419 spin_unlock_irq(shost->host_lock); 2523 2420 2421 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 2422 + "disc timeout: state:x%x rtry:x%x flg:x%x", 2423 + vport->port_state, vport->fc_ns_retry, vport->fc_flag); 2424 + 2524 2425 switch (vport->port_state) { 2525 2426 2526 2427 case LPFC_LOCAL_CFG_LINK: ··· 2850 2743 spin_lock_irq(shost->host_lock); 2851 2744 ndlp = __lpfc_find_node(vport, lpfc_filter_by_wwpn, wwpn); 2852 2745 spin_unlock_irq(shost->host_lock); 2853 - return NULL; 2746 + return ndlp; 2854 2747 } 2855 2748 2856 2749 void ··· 2871 2764 } 2872 2765 2873 2766 evtp->evt_arg1 = ndlp; 2874 - evtp->evt = LPFC_EVT_DEV_LOSS; 2767 + evtp->evt = LPFC_EVT_DEV_LOSS_DELAY; 2875 2768 list_add_tail(&evtp->evt_listp, &phba->work_list); 2876 2769 if (phba->work_wait) 2877 2770 lpfc_worker_wake_up(phba); ··· 2886 2779 memset(ndlp, 0, sizeof (struct lpfc_nodelist)); 2887 2780 INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp); 2888 2781 INIT_LIST_HEAD(&ndlp->dev_loss_evt.evt_listp); 2889 - init_timer(&ndlp->nlp_initiator_tmr); 2890 - ndlp->nlp_initiator_tmr.function = lpfc_dev_loss_delay; 2891 - ndlp->nlp_initiator_tmr.data = (unsigned long)ndlp; 2892 2782 init_timer(&ndlp->nlp_delayfunc); 2893 2783 ndlp->nlp_delayfunc.function = lpfc_els_retry_delay; 2894 2784 ndlp->nlp_delayfunc.data = (unsigned long)ndlp; ··· 2894 2790 ndlp->nlp_sid = NLP_NO_SID; 2895 2791 INIT_LIST_HEAD(&ndlp->nlp_listp); 2896 2792 kref_init(&ndlp->kref); 2793 + 2794 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, 2795 + "node init: did:x%x", 2796 + ndlp->nlp_DID, 0, 0); 2797 + 2897 2798 return; 2898 2799 } 2899 2800 ··· 2907 2798 { 2908 2799 struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist, 2909 2800 kref); 2801 + 2802 + lpfc_debugfs_disc_trc(ndlp->vport, LPFC_DISC_TRC_NODE, 2803 + "node release: did:x%x flg:x%x type:x%x", 2804 + ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_type); 2805 + 2910 2806 lpfc_nlp_remove(ndlp->vport, ndlp); 2911 2807 mempool_free(ndlp, ndlp->vport->phba->nlp_mem_pool); 2912 2808 }
+18 -3
drivers/scsi/lpfc/lpfc_hw.h
··· 1278 1278 #define MBX_KILL_BOARD 0x24 1279 1279 #define MBX_CONFIG_FARP 0x25 1280 1280 #define MBX_BEACON 0x2A 1281 + #define MBX_HEARTBEAT 0x31 1281 1282 1282 1283 #define MBX_CONFIG_HBQ 0x7C 1283 1284 #define MBX_LOAD_AREA 0x81 ··· 1778 1777 #define LMT_4Gb 0x040 1779 1778 #define LMT_8Gb 0x080 1780 1779 #define LMT_10Gb 0x100 1781 - 1782 - 1783 1780 uint32_t rsvd2; 1784 1781 uint32_t rsvd3; 1785 1782 uint32_t max_xri; ··· 1786 1787 uint32_t avail_xri; 1787 1788 uint32_t avail_iocb; 1788 1789 uint32_t avail_rpi; 1789 - uint32_t default_rpi; 1790 + uint32_t max_vpi; 1791 + uint32_t rsvd4; 1792 + uint32_t rsvd5; 1793 + uint32_t avail_vpi; 1790 1794 } READ_CONFIG_VAR; 1791 1795 1792 1796 /* Structure for MB Command READ_RCONFIG (12) */ ··· 3172 3170 return 1; 3173 3171 else 3174 3172 return 0; 3173 + } 3174 + 3175 + /* 3176 + * Determine if an IOCB failed because of a link event or firmware reset. 3177 + */ 3178 + 3179 + static inline int 3180 + lpfc_error_lost_link(IOCB_t *iocbp) 3181 + { 3182 + return (iocbp->ulpStatus == IOSTAT_LOCAL_REJECT && 3183 + (iocbp->un.ulpWord[4] == IOERR_SLI_ABORTED || 3184 + iocbp->un.ulpWord[4] == IOERR_LINK_DOWN || 3185 + iocbp->un.ulpWord[4] == IOERR_SLI_DOWN)); 3175 3186 }
+181 -47
drivers/scsi/lpfc/lpfc_init.c
··· 391 391 */ 392 392 timeout = phba->fc_ratov << 1; 393 393 mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout); 394 + mod_timer(&phba->hb_tmofunc, jiffies + HZ * LPFC_HB_MBOX_INTERVAL); 395 + phba->hb_outstanding = 0; 396 + phba->last_completion_time = jiffies; 394 397 395 398 lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); 396 399 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; ··· 486 483 } 487 484 488 485 return 0; 486 + } 487 + 488 + /* HBA heart beat timeout handler */ 489 + void 490 + lpfc_hb_timeout(unsigned long ptr) 491 + { 492 + struct lpfc_hba *phba; 493 + unsigned long iflag; 494 + 495 + phba = (struct lpfc_hba *)ptr; 496 + spin_lock_irqsave(&phba->pport->work_port_lock, iflag); 497 + if (!(phba->pport->work_port_events & WORKER_HB_TMO)) 498 + phba->pport->work_port_events |= WORKER_HB_TMO; 499 + spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); 500 + 501 + if (phba->work_wait) 502 + wake_up(phba->work_wait); 503 + return; 504 + } 505 + 506 + static void 507 + lpfc_hb_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq) 508 + { 509 + unsigned long drvr_flag; 510 + 511 + spin_lock_irqsave(&phba->hbalock, drvr_flag); 512 + phba->hb_outstanding = 0; 513 + spin_unlock_irqrestore(&phba->hbalock, drvr_flag); 514 + 515 + mempool_free(pmboxq, phba->mbox_mem_pool); 516 + if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && 517 + !(phba->link_state == LPFC_HBA_ERROR) && 518 + !(phba->pport->fc_flag & FC_UNLOADING)) 519 + mod_timer(&phba->hb_tmofunc, 520 + jiffies + HZ * LPFC_HB_MBOX_INTERVAL); 521 + return; 522 + } 523 + 524 + void 525 + lpfc_hb_timeout_handler(struct lpfc_hba *phba) 526 + { 527 + LPFC_MBOXQ_t *pmboxq; 528 + int retval; 529 + struct lpfc_sli *psli = &phba->sli; 530 + 531 + if ((phba->link_state == LPFC_HBA_ERROR) || 532 + (phba->pport->fc_flag & FC_UNLOADING) || 533 + (phba->pport->fc_flag & FC_OFFLINE_MODE)) 534 + return; 535 + 536 + spin_lock_irq(&phba->pport->work_port_lock); 537 + /* If the timer is already canceled do nothing */ 538 + if (!(phba->pport->work_port_events & WORKER_HB_TMO)) { 539 + spin_unlock_irq(&phba->pport->work_port_lock); 540 + return; 541 + } 542 + 543 + if (time_after(phba->last_completion_time + LPFC_HB_MBOX_INTERVAL * HZ, 544 + jiffies)) { 545 + spin_unlock_irq(&phba->pport->work_port_lock); 546 + if (!phba->hb_outstanding) 547 + mod_timer(&phba->hb_tmofunc, 548 + jiffies + HZ * LPFC_HB_MBOX_INTERVAL); 549 + else 550 + mod_timer(&phba->hb_tmofunc, 551 + jiffies + HZ * LPFC_HB_MBOX_TIMEOUT); 552 + return; 553 + } 554 + spin_unlock_irq(&phba->pport->work_port_lock); 555 + 556 + /* If there is no heart beat outstanding, issue a heartbeat command */ 557 + if (!phba->hb_outstanding) { 558 + pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL); 559 + if (!pmboxq) { 560 + mod_timer(&phba->hb_tmofunc, 561 + jiffies + HZ * LPFC_HB_MBOX_INTERVAL); 562 + return; 563 + } 564 + 565 + lpfc_heart_beat(phba, pmboxq); 566 + pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; 567 + pmboxq->vport = phba->pport; 568 + retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT); 569 + 570 + if (retval != MBX_BUSY && retval != MBX_SUCCESS) { 571 + mempool_free(pmboxq, phba->mbox_mem_pool); 572 + mod_timer(&phba->hb_tmofunc, 573 + jiffies + HZ * LPFC_HB_MBOX_INTERVAL); 574 + return; 575 + } 576 + mod_timer(&phba->hb_tmofunc, 577 + jiffies + HZ * LPFC_HB_MBOX_TIMEOUT); 578 + phba->hb_outstanding = 1; 579 + return; 580 + } else { 581 + /* 582 + * If heart beat timeout called with hb_outstanding set we 583 + * need to take the HBA offline. 584 + */ 585 + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 586 + "%d:0459 Adapter heartbeat failure, taking " 587 + "this port offline.\n", phba->brd_no); 588 + 589 + spin_lock_irq(&phba->hbalock); 590 + psli->sli_flag &= ~LPFC_SLI2_ACTIVE; 591 + spin_unlock_irq(&phba->hbalock); 592 + 593 + lpfc_offline_prep(phba); 594 + lpfc_offline(phba); 595 + lpfc_unblock_mgmt_io(phba); 596 + phba->link_state = LPFC_HBA_ERROR; 597 + lpfc_hba_down_post(phba); 598 + } 489 599 } 490 600 491 601 /************************************************************************/ ··· 1306 1190 lpfc_can_disctmo(vport); 1307 1191 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) 1308 1192 lpfc_nlp_put(ndlp); 1309 - 1310 - INIT_LIST_HEAD(&vport->fc_nodes); 1311 - 1312 1193 return; 1313 1194 } 1314 1195 ··· 1351 1238 lpfc_stop_vport_timers(vport); 1352 1239 del_timer_sync(&phba->sli.mbox_tmo); 1353 1240 del_timer_sync(&phba->fabric_block_timer); 1241 + phba->hb_outstanding = 0; 1242 + del_timer_sync(&phba->hb_tmofunc); 1354 1243 return; 1355 1244 } 1356 1245 ··· 1589 1474 struct lpfc_hba *phba = vport->phba; 1590 1475 1591 1476 kfree(vport->vname); 1592 - lpfc_free_sysfs_attr(vport); 1593 1477 1478 + lpfc_debugfs_terminate(vport); 1594 1479 fc_remove_host(shost); 1595 1480 scsi_remove_host(shost); 1596 1481 ··· 1615 1500 return instance; 1616 1501 } 1617 1502 1618 - static void 1619 - lpfc_remove_device(struct lpfc_vport *vport) 1620 - { 1621 - struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1622 - 1623 - lpfc_free_sysfs_attr(vport); 1624 - 1625 - spin_lock_irq(shost->host_lock); 1626 - vport->fc_flag |= FC_UNLOADING; 1627 - spin_unlock_irq(shost->host_lock); 1628 - 1629 - fc_remove_host(shost); 1630 - scsi_remove_host(shost); 1631 - } 1632 - 1633 - void lpfc_scan_start(struct Scsi_Host *shost) 1634 - { 1635 - struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1636 - struct lpfc_hba *phba = vport->phba; 1637 - 1638 - if (lpfc_sli_hba_setup(phba)) 1639 - goto error; 1640 - 1641 - /* 1642 - * hba setup may have changed the hba_queue_depth so we need to adjust 1643 - * the value of can_queue. 1644 - */ 1645 - shost->can_queue = phba->cfg_hba_queue_depth - 10; 1646 - return; 1647 - 1648 - error: 1649 - lpfc_remove_device(vport); 1650 - } 1503 + /* 1504 + * Note: there is no scan_start function as adapter initialization 1505 + * will have asynchronously kicked off the link initialization. 1506 + */ 1651 1507 1652 1508 int lpfc_scan_finished(struct Scsi_Host *shost, unsigned long time) 1653 1509 { 1654 1510 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1655 1511 struct lpfc_hba *phba = vport->phba; 1512 + int stat = 0; 1656 1513 1514 + spin_lock_irq(shost->host_lock); 1515 + 1516 + if (vport->fc_flag & FC_UNLOADING) { 1517 + stat = 1; 1518 + goto finished; 1519 + } 1657 1520 if (time >= 30 * HZ) { 1658 1521 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 1659 1522 "%d:0461 Scanning longer than 30 " 1660 1523 "seconds. Continuing initialization\n", 1661 1524 phba->brd_no); 1525 + stat = 1; 1662 1526 goto finished; 1663 1527 } 1664 1528 if (time >= 15 * HZ && phba->link_state <= LPFC_LINK_DOWN) { ··· 1645 1551 "%d:0465 Link down longer than 15 " 1646 1552 "seconds. Continuing initialization\n", 1647 1553 phba->brd_no); 1554 + stat = 1; 1648 1555 goto finished; 1649 1556 } 1650 1557 1651 1558 if (vport->port_state != LPFC_VPORT_READY) 1652 - return 0; 1559 + goto finished; 1653 1560 if (vport->num_disc_nodes || vport->fc_prli_sent) 1654 - return 0; 1561 + goto finished; 1655 1562 if (vport->fc_map_cnt == 0 && time < 2 * HZ) 1656 - return 0; 1563 + goto finished; 1657 1564 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) 1658 - return 0; 1565 + goto finished; 1566 + 1567 + stat = 1; 1659 1568 1660 1569 finished: 1661 - lpfc_host_attrib_init(shost); 1662 - return 1; 1570 + spin_unlock_irq(shost->host_lock); 1571 + return stat; 1663 1572 } 1664 1573 1665 1574 void lpfc_host_attrib_init(struct Scsi_Host *shost) ··· 1753 1656 /* Initialize timers used by driver */ 1754 1657 init_timer(&phba->fc_estabtmo); 1755 1658 phba->fc_estabtmo.function = lpfc_establish_link_tmo; 1756 - phba->fc_estabtmo.data = (unsigned long) phba; 1659 + phba->fc_estabtmo.data = (unsigned long)phba; 1660 + 1661 + init_timer(&phba->hb_tmofunc); 1662 + phba->hb_tmofunc.function = lpfc_hb_timeout; 1663 + phba->hb_tmofunc.data = (unsigned long)phba; 1664 + 1757 1665 psli = &phba->sli; 1758 1666 init_timer(&psli->mbox_tmo); 1759 1667 psli->mbox_tmo.function = lpfc_mbox_timeout; ··· 1893 1791 1894 1792 shost = lpfc_shost_from_vport(vport); 1895 1793 phba->pport = vport; 1794 + lpfc_debugfs_initialize(vport); 1896 1795 1897 1796 pci_set_drvdata(pdev, shost); 1898 1797 ··· 1923 1820 if (lpfc_alloc_sysfs_attr(vport)) 1924 1821 goto out_free_irq; 1925 1822 1926 - scsi_scan_host(shost); 1823 + if (lpfc_sli_hba_setup(phba)) 1824 + goto out_remove_device; 1825 + 1826 + /* 1827 + * hba setup may have changed the hba_queue_depth so we need to adjust 1828 + * the value of can_queue. 1829 + */ 1830 + shost->can_queue = phba->cfg_hba_queue_depth - 10; 1831 + 1832 + lpfc_host_attrib_init(shost); 1833 + 1927 1834 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { 1928 1835 spin_lock_irq(shost->host_lock); 1929 1836 lpfc_poll_start_timer(phba); 1930 1837 spin_unlock_irq(shost->host_lock); 1931 1838 } 1932 1839 1840 + scsi_scan_host(shost); 1841 + 1933 1842 return 0; 1934 1843 1844 + out_remove_device: 1845 + lpfc_free_sysfs_attr(vport); 1846 + spin_lock_irq(shost->host_lock); 1847 + vport->fc_flag |= FC_UNLOADING; 1848 + spin_unlock_irq(shost->host_lock); 1935 1849 out_free_irq: 1936 1850 lpfc_stop_phba_timers(phba); 1937 1851 phba->pport->work_port_events = 0; ··· 1985 1865 pci_disable_device(pdev); 1986 1866 out: 1987 1867 pci_set_drvdata(pdev, NULL); 1868 + if (shost) 1869 + scsi_host_put(shost); 1988 1870 return error; 1989 1871 } 1990 1872 ··· 2000 1878 list_for_each_entry(port_iterator, &phba->port_list, listentry) 2001 1879 port_iterator->load_flag |= FC_UNLOADING; 2002 1880 1881 + kfree(vport->vname); 1882 + lpfc_free_sysfs_attr(vport); 1883 + 1884 + fc_remove_host(shost); 1885 + scsi_remove_host(shost); 1886 + 2003 1887 /* 2004 1888 * Bring down the SLI Layer. This step disable all interrupts, 2005 1889 * clears the rings, discards all mailbox commands, and resets ··· 2015 1887 lpfc_sli_brdrestart(phba); 2016 1888 2017 1889 lpfc_stop_phba_timers(phba); 1890 + spin_lock_irq(&phba->hbalock); 1891 + list_del_init(&vport->listentry); 1892 + spin_unlock_irq(&phba->hbalock); 1893 + 1894 + 1895 + lpfc_debugfs_terminate(vport); 1896 + lpfc_cleanup(vport); 2018 1897 2019 1898 kthread_stop(phba->worker_thread); 2020 1899 ··· 2029 1894 free_irq(phba->pcidev->irq, phba); 2030 1895 pci_disable_msi(phba->pcidev); 2031 1896 2032 - destroy_port(vport); 2033 - 2034 1897 pci_set_drvdata(pdev, NULL); 1898 + scsi_host_put(shost); 2035 1899 2036 1900 /* 2037 1901 * Call scsi_free before mem_free since scsi bufs are released to their
+17 -1
drivers/scsi/lpfc/lpfc_mbox.c
··· 82 82 } 83 83 84 84 /**********************************************/ 85 + /* lpfc_heart_beat Issue a HEART_BEAT */ 86 + /* mailbox command */ 87 + /**********************************************/ 88 + void 89 + lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) 90 + { 91 + MAILBOX_t *mb; 92 + 93 + mb = &pmb->mb; 94 + memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); 95 + mb->mbxCommand = MBX_HEARTBEAT; 96 + mb->mbxOwner = OWN_HOST; 97 + return; 98 + } 99 + 100 + /**********************************************/ 85 101 /* lpfc_read_la Issue a READ LA */ 86 102 /* mailbox command */ 87 103 /**********************************************/ ··· 692 676 if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) { 693 677 mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ 694 678 mb->un.varCfgPort.max_hbq = 1; /* Requesting 2 HBQs */ 695 - if (phba->max_vpi && lpfc_npiv_enable && 679 + if (phba->max_vpi && phba->cfg_npiv_enable && 696 680 phba->vpd.sli3Feat.cmv) { 697 681 mb->un.varCfgPort.max_vpi = phba->max_vpi; 698 682 mb->un.varCfgPort.cmv = 1;
+2 -1
drivers/scsi/lpfc/lpfc_mem.c
··· 88 88 if (!phba->lpfc_hbq_pool) 89 89 goto fail_free_nlp_mem_pool; 90 90 91 - longs = (phba->max_vpi + BITS_PER_LONG - 1) / BITS_PER_LONG; 91 + /* vpi zero is reserved for the physical port so add 1 to max */ 92 + longs = ((phba->max_vpi + 1) + BITS_PER_LONG - 1) / BITS_PER_LONG; 92 93 phba->vpi_bmask = kzalloc(longs * sizeof(unsigned long), GFP_KERNEL); 93 94 if (!phba->vpi_bmask) 94 95 goto fail_free_hbq_pool;
+49 -14
drivers/scsi/lpfc/lpfc_nportdisc.c
··· 36 36 #include "lpfc_logmsg.h" 37 37 #include "lpfc_crtn.h" 38 38 #include "lpfc_vport.h" 39 + #include "lpfc_debugfs.h" 39 40 40 41 41 42 /* Called to verify a rcv'ed ADISC was intended for us. */ ··· 205 204 /* First check the txq */ 206 205 spin_lock_irq(&phba->hbalock); 207 206 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 208 - /* Check to see if iocb matches the nport we are looking 209 - for */ 207 + /* Check to see if iocb matches the nport we are looking for */ 210 208 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) { 211 - /* It matches, so deque and call compl with an 212 - error */ 209 + /* It matches, so deque and call compl with anp error */ 213 210 list_move_tail(&iocb->list, &completions); 214 211 pring->txq_cnt--; 215 212 } ··· 215 216 216 217 /* Next check the txcmplq */ 217 218 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { 218 - /* Check to see if iocb matches the nport we are looking 219 - for */ 219 + /* Check to see if iocb matches the nport we are looking for */ 220 220 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) { 221 221 lpfc_sli_issue_abort_iotag(phba, pring, iocb); 222 222 } ··· 280 282 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY; 281 283 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 282 284 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, 283 - ndlp); 285 + ndlp, NULL); 284 286 return 0; 285 287 } 286 288 } ··· 291 293 /* Reject this request because invalid parameters */ 292 294 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 293 295 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; 294 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 296 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, 297 + NULL); 295 298 return 0; 296 299 } 297 300 icmd = &cmdiocb->iocb; ··· 391 392 lpfc_els_abort(phba, ndlp); 392 393 } 393 394 395 + if ((vport->port_type == LPFC_NPIV_PORT && 396 + phba->cfg_vport_restrict_login)) { 397 + 398 + /* In order to preserve RPIs, we want to cleanup 399 + * the default RPI the firmware created to rcv 400 + * this ELS request. The only way to do this is 401 + * to register, then unregister the RPI. 402 + */ 403 + spin_lock_irq(shost->host_lock); 404 + ndlp->nlp_flag |= NLP_RM_DFLT_RPI; 405 + spin_unlock_irq(shost->host_lock); 406 + stat.un.b.lsRjtRsnCode = LSRJT_INVALID_CMD; 407 + stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 408 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, 409 + ndlp, mbox); 410 + return 1; 411 + } 394 412 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0); 395 413 return 1; 396 414 397 415 out: 398 416 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 399 417 stat.un.b.lsRjtRsnCodeExp = LSEXP_OUT_OF_RESOURCE; 400 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 418 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); 401 419 return 0; 402 420 } 403 421 ··· 461 445 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 462 446 stat.un.b.lsRjtRsnCodeExp = LSEXP_SPARM_OPTIONS; 463 447 stat.un.b.vendorUnique = 0; 464 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 448 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); 465 449 466 450 /* 1 sec timeout */ 467 451 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); ··· 551 535 roles |= FC_RPORT_ROLE_FCP_INITIATOR; 552 536 if (ndlp->nlp_type & NLP_FCP_TARGET) 553 537 roles |= FC_RPORT_ROLE_FCP_TARGET; 538 + 539 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_RPORT, 540 + "rport rolechg: role:x%x did:x%x flg:x%x", 541 + roles, ndlp->nlp_DID, ndlp->nlp_flag); 542 + 554 543 fc_remote_port_rolechg(rport, roles); 555 544 } 556 545 } ··· 678 657 ours */ 679 658 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 680 659 stat.un.b.lsRjtRsnCodeExp = LSEXP_CMD_IN_PROGRESS; 681 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 660 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, 661 + NULL); 682 662 } else { 683 663 lpfc_rcv_plogi(vport, ndlp, cmdiocb); 684 664 } /* If our portname was less */ ··· 697 675 memset(&stat, 0, sizeof (struct ls_rjt)); 698 676 stat.un.b.lsRjtRsnCode = LSRJT_LOGICAL_BSY; 699 677 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 700 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 678 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); 701 679 return ndlp->nlp_state; 702 680 } 703 681 ··· 1357 1335 1358 1336 irsp = &rspiocb->iocb; 1359 1337 if (irsp->ulpStatus) { 1338 + if ((vport->port_type == LPFC_NPIV_PORT) && 1339 + phba->cfg_vport_restrict_login) { 1340 + goto out; 1341 + } 1360 1342 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1361 1343 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNMAPPED_NODE); 1362 1344 return ndlp->nlp_state; ··· 1381 1355 if (!(ndlp->nlp_type & NLP_FCP_TARGET) && 1382 1356 (vport->port_type == LPFC_NPIV_PORT) && 1383 1357 phba->cfg_vport_restrict_login) { 1358 + out: 1384 1359 spin_lock_irq(shost->host_lock); 1385 1360 ndlp->nlp_flag |= NLP_TARGET_REMOVE; 1386 1361 spin_unlock_irq(shost->host_lock); ··· 1633 1606 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; 1634 1607 1635 1608 /* Ignore PLOGI if we have an outstanding LOGO */ 1636 - if (ndlp->nlp_flag & NLP_LOGO_SND) { 1609 + if (ndlp->nlp_flag & (NLP_LOGO_SND | NLP_LOGO_ACC)) { 1637 1610 return ndlp->nlp_state; 1638 1611 } 1639 1612 ··· 1665 1638 memset(&stat, 0, sizeof (struct ls_rjt)); 1666 1639 stat.un.b.lsRjtRsnCode = LSRJT_UNABLE_TPC; 1667 1640 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 1668 - lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp); 1641 + lpfc_els_rsp_reject(vport, stat.un.lsRjtError, cmdiocb, ndlp, NULL); 1669 1642 1670 1643 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { 1671 1644 if (ndlp->nlp_flag & NLP_NPR_ADISC) { ··· 2062 2035 phba->brd_no, vport->vpi, 2063 2036 evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag); 2064 2037 2038 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, 2039 + "DSM in: evt:%d ste:%d did:x%x", 2040 + evt, cur_state, ndlp->nlp_DID); 2041 + 2065 2042 func = lpfc_disc_action[(cur_state * NLP_EVT_MAX_EVENT) + evt]; 2066 2043 rc = (func) (vport, ndlp, arg, evt); 2067 2044 ··· 2075 2044 "Data: x%x\n", 2076 2045 phba->brd_no, vport->vpi, 2077 2046 rc, ndlp->nlp_DID, ndlp->nlp_flag); 2047 + 2048 + lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, 2049 + "DSM out: ste:%d did:x%x flg:x%x", 2050 + rc, ndlp->nlp_DID, ndlp->nlp_flag); 2078 2051 2079 2052 lpfc_nlp_put(ndlp); 2080 2053
-1
drivers/scsi/lpfc/lpfc_scsi.c
··· 1532 1532 .slave_configure = lpfc_slave_configure, 1533 1533 .slave_destroy = lpfc_slave_destroy, 1534 1534 .scan_finished = lpfc_scan_finished, 1535 - .scan_start = lpfc_scan_start, 1536 1535 .this_id = -1, 1537 1536 .sg_tablesize = LPFC_SG_SEG_CNT, 1538 1537 .cmd_per_lun = LPFC_CMD_PER_LUN,
+153 -55
drivers/scsi/lpfc/lpfc_sli.c
··· 38 38 #include "lpfc_crtn.h" 39 39 #include "lpfc_logmsg.h" 40 40 #include "lpfc_compat.h" 41 + #include "lpfc_debugfs.h" 41 42 42 43 /* 43 44 * Define macro to log: Mailbox command x%x cannot issue Data ··· 270 269 static struct lpfc_iocbq * 271 270 lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) 272 271 { 273 - struct list_head *dlp; 274 272 struct lpfc_iocbq *cmd_iocb; 275 273 276 - dlp = &pring->txq; 277 - cmd_iocb = NULL; 278 - list_remove_head((&pring->txq), cmd_iocb, 279 - struct lpfc_iocbq, 280 - list); 281 - if (cmd_iocb) { 282 - /* If the first ptr is not equal to the list header, 283 - * deque the IOCBQ_t and return it. 284 - */ 274 + list_remove_head((&pring->txq), cmd_iocb, struct lpfc_iocbq, list); 275 + if (cmd_iocb != NULL) 285 276 pring->txq_cnt--; 286 - } 287 277 return cmd_iocb; 288 278 } 289 279 ··· 728 736 case MBX_LOAD_EXP_ROM: 729 737 case MBX_REG_VPI: 730 738 case MBX_UNREG_VPI: 739 + case MBX_HEARTBEAT: 731 740 ret = mbxCommand; 732 741 break; 733 742 default: ··· 741 748 lpfc_sli_wake_mbox_wait(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq) 742 749 { 743 750 wait_queue_head_t *pdone_q; 751 + unsigned long drvr_flag; 744 752 745 753 /* 746 754 * If pdone_q is empty, the driver thread gave up waiting and 747 755 * continued running. 748 756 */ 749 757 pmboxq->mbox_flag |= LPFC_MBX_WAKE; 758 + spin_lock_irqsave(&phba->hbalock, drvr_flag); 750 759 pdone_q = (wait_queue_head_t *) pmboxq->context1; 751 760 if (pdone_q) 752 761 wake_up_interruptible(pdone_q); 762 + spin_unlock_irqrestore(&phba->hbalock, drvr_flag); 753 763 return; 754 764 } 755 765 ··· 812 816 break; 813 817 814 818 pmbox = &pmb->mb; 819 + 820 + if (pmbox->mbxCommand != MBX_HEARTBEAT) { 821 + if (pmb->vport) { 822 + lpfc_debugfs_disc_trc(pmb->vport, 823 + LPFC_DISC_TRC_MBOX_VPORT, 824 + "MBOX cmpl vport: cmd:x%x mb:x%x x%x", 825 + (uint32_t)pmbox->mbxCommand, 826 + pmbox->un.varWords[0], 827 + pmbox->un.varWords[1]); 828 + } 829 + else { 830 + lpfc_debugfs_disc_trc(phba->pport, 831 + LPFC_DISC_TRC_MBOX, 832 + "MBOX cmpl: cmd:x%x mb:x%x x%x", 833 + (uint32_t)pmbox->mbxCommand, 834 + pmbox->un.varWords[0], 835 + pmbox->un.varWords[1]); 836 + } 837 + } 815 838 816 839 /* 817 840 * It is a fatal error if unknown mbox command completion. ··· 1324 1309 * network byte order and pci byte orders are different. 1325 1310 */ 1326 1311 entry = lpfc_resp_iocb(phba, pring); 1312 + phba->last_completion_time = jiffies; 1327 1313 1328 1314 if (++pring->rspidx >= portRspMax) 1329 1315 pring->rspidx = 0; ··· 1527 1511 */ 1528 1512 entry = lpfc_resp_iocb(phba, pring); 1529 1513 1514 + phba->last_completion_time = jiffies; 1530 1515 rspiocbp = __lpfc_sli_get_iocbq(phba); 1531 1516 if (rspiocbp == NULL) { 1532 1517 printk(KERN_ERR "%s: out of buffers! Failing " ··· 2321 2304 2322 2305 switch (lpfc_sli_mode) { 2323 2306 case 2: 2324 - if (lpfc_npiv_enable) { 2307 + if (phba->cfg_npiv_enable) { 2325 2308 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, 2326 2309 "%d:1824 NPIV enabled: Override lpfc_sli_mode " 2327 2310 "parameter (%d) to auto (0).\n", ··· 2590 2573 psli->slistat.mbox_busy++; 2591 2574 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); 2592 2575 2576 + if (pmbox->vport) { 2577 + lpfc_debugfs_disc_trc(pmbox->vport, 2578 + LPFC_DISC_TRC_MBOX_VPORT, 2579 + "MBOX Bsy vport: cmd:x%x mb:x%x x%x", 2580 + (uint32_t)mb->mbxCommand, 2581 + mb->un.varWords[0], mb->un.varWords[1]); 2582 + } 2583 + else { 2584 + lpfc_debugfs_disc_trc(phba->pport, 2585 + LPFC_DISC_TRC_MBOX, 2586 + "MBOX Bsy: cmd:x%x mb:x%x x%x", 2587 + (uint32_t)mb->mbxCommand, 2588 + mb->un.varWords[0], mb->un.varWords[1]); 2589 + } 2590 + 2593 2591 return MBX_BUSY; 2594 2592 } 2595 2593 ··· 2649 2617 phba->brd_no, pmbox->vport ? pmbox->vport->vpi : 0, 2650 2618 mb->mbxCommand, phba->pport->port_state, 2651 2619 psli->sli_flag, flag); 2620 + 2621 + if (mb->mbxCommand != MBX_HEARTBEAT) { 2622 + if (pmbox->vport) { 2623 + lpfc_debugfs_disc_trc(pmbox->vport, 2624 + LPFC_DISC_TRC_MBOX_VPORT, 2625 + "MBOX Send vport: cmd:x%x mb:x%x x%x", 2626 + (uint32_t)mb->mbxCommand, 2627 + mb->un.varWords[0], mb->un.varWords[1]); 2628 + } 2629 + else { 2630 + lpfc_debugfs_disc_trc(phba->pport, 2631 + LPFC_DISC_TRC_MBOX, 2632 + "MBOX Send: cmd:x%x mb:x%x x%x", 2633 + (uint32_t)mb->mbxCommand, 2634 + mb->un.varWords[0], mb->un.varWords[1]); 2635 + } 2636 + } 2652 2637 2653 2638 psli->slistat.mbox_cmd++; 2654 2639 evtctr = psli->slistat.mbox_event; ··· 2809 2760 /* 2810 2761 * Caller needs to hold lock. 2811 2762 */ 2812 - static int 2763 + static void 2813 2764 __lpfc_sli_ringtx_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 2814 2765 struct lpfc_iocbq *piocb) 2815 2766 { 2816 2767 /* Insert the caller's iocb in the txq tail for later processing. */ 2817 2768 list_add_tail(&piocb->list, &pring->txq); 2818 2769 pring->txq_cnt++; 2819 - return 0; 2820 2770 } 2821 2771 2822 2772 static struct lpfc_iocbq * ··· 3122 3074 int 3123 3075 lpfc_sli_host_down(struct lpfc_vport *vport) 3124 3076 { 3077 + LIST_HEAD(completions); 3125 3078 struct lpfc_hba *phba = vport->phba; 3126 3079 struct lpfc_sli *psli = &phba->sli; 3127 3080 struct lpfc_sli_ring *pring; 3128 3081 struct lpfc_iocbq *iocb, *next_iocb; 3129 - IOCB_t *icmd = NULL; 3130 3082 int i; 3131 3083 unsigned long flags = 0; 3132 3084 uint16_t prev_pring_flag; ··· 3134 3086 lpfc_cleanup_discovery_resources(vport); 3135 3087 3136 3088 spin_lock_irqsave(&phba->hbalock, flags); 3137 - 3138 3089 for (i = 0; i < psli->num_rings; i++) { 3139 3090 pring = &psli->ring[i]; 3140 3091 prev_pring_flag = pring->flag; 3141 - pring->flag |= LPFC_DEFERRED_RING_EVENT; 3142 - 3092 + if (pring->ringno == LPFC_ELS_RING) /* Only slow rings */ 3093 + pring->flag |= LPFC_DEFERRED_RING_EVENT; 3143 3094 /* 3144 3095 * Error everything on the txq since these iocbs have not been 3145 3096 * given to the FW yet. 3146 3097 */ 3147 - 3148 3098 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 3149 3099 if (iocb->vport != vport) 3150 3100 continue; 3151 - list_del_init(&iocb->list); 3101 + list_move_tail(&iocb->list, &completions); 3152 3102 pring->txq_cnt--; 3153 - if (iocb->iocb_cmpl) { 3154 - icmd = &iocb->iocb; 3155 - icmd->ulpStatus = IOSTAT_LOCAL_REJECT; 3156 - icmd->un.ulpWord[4] = IOERR_SLI_DOWN; 3157 - spin_unlock_irqrestore(&phba->hbalock, flags); 3158 - (iocb->iocb_cmpl) (phba, iocb, iocb); 3159 - spin_lock_irqsave(&phba->hbalock, flags); 3160 - } else 3161 - lpfc_sli_release_iocbq(phba, iocb); 3162 3103 } 3163 3104 3164 3105 /* Next issue ABTS for everything on the txcmplq */ ··· 3163 3126 3164 3127 spin_unlock_irqrestore(&phba->hbalock, flags); 3165 3128 3129 + while (!list_empty(&completions)) { 3130 + list_remove_head(&completions, iocb, struct lpfc_iocbq, list); 3131 + 3132 + if (!iocb->iocb_cmpl) 3133 + lpfc_sli_release_iocbq(phba, iocb); 3134 + else { 3135 + iocb->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; 3136 + iocb->iocb.un.ulpWord[4] = IOERR_SLI_DOWN; 3137 + (iocb->iocb_cmpl) (phba, iocb, iocb); 3138 + } 3139 + } 3166 3140 return 1; 3167 3141 } 3168 3142 ··· 3196 3148 spin_lock_irqsave(&phba->hbalock, flags); 3197 3149 for (i = 0; i < psli->num_rings; i++) { 3198 3150 pring = &psli->ring[i]; 3199 - pring->flag |= LPFC_DEFERRED_RING_EVENT; 3151 + if (pring->ringno == LPFC_ELS_RING) /* Only slow rings */ 3152 + pring->flag |= LPFC_DEFERRED_RING_EVENT; 3200 3153 3201 3154 /* 3202 3155 * Error everything on the txq since these iocbs have not been ··· 3375 3326 "x%x x%x x%x\n", 3376 3327 phba->brd_no, irsp->ulpIoTag, irsp->ulpStatus, 3377 3328 irsp->un.ulpWord[4], irsp->ulpTimeout); 3378 - 3379 - lpfc_els_free_iocb(phba, cmdiocb); 3329 + if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) 3330 + lpfc_ct_free_iocb(phba, cmdiocb); 3331 + else 3332 + lpfc_els_free_iocb(phba, cmdiocb); 3380 3333 return; 3381 3334 } 3382 3335 ··· 3403 3352 (cmdiocb->iocb_flag & LPFC_DRIVER_ABORTED) != 0) 3404 3353 return 0; 3405 3354 3406 - /* If we're unloading, don't abort the iocb, but change the callback so 3407 - * that nothing happens when it finishes. 3355 + /* If we're unloading, don't abort iocb on the ELS ring, but change the 3356 + * callback so that nothing happens when it finishes. 3408 3357 */ 3409 - if (vport->load_flag & FC_UNLOADING) { 3358 + if ((vport->load_flag & FC_UNLOADING) && 3359 + (pring->ringno == LPFC_ELS_RING)) { 3410 3360 if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) 3411 3361 cmdiocb->fabric_iocb_cmpl = lpfc_ignore_els_cmpl; 3412 3362 else ··· 3592 3540 &rspiocbq->iocb, sizeof(IOCB_t)); 3593 3541 3594 3542 pdone_q = cmdiocbq->context_un.wait_queue; 3595 - spin_unlock_irqrestore(&phba->hbalock, iflags); 3596 3543 if (pdone_q) 3597 3544 wake_up(pdone_q); 3545 + spin_unlock_irqrestore(&phba->hbalock, iflags); 3598 3546 return; 3599 3547 } 3600 3548 ··· 3690 3638 { 3691 3639 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q); 3692 3640 int retval; 3641 + unsigned long flag; 3693 3642 3694 3643 /* The caller must leave context1 empty. */ 3695 3644 if (pmboxq->context1 != 0) ··· 3709 3656 pmboxq->mbox_flag & LPFC_MBX_WAKE, 3710 3657 timeout * HZ); 3711 3658 3659 + spin_lock_irqsave(&phba->hbalock, flag); 3712 3660 pmboxq->context1 = NULL; 3713 3661 /* 3714 3662 * if LPFC_MBX_WAKE flag is set the mailbox is completed ··· 3717 3663 */ 3718 3664 if (pmboxq->mbox_flag & LPFC_MBX_WAKE) 3719 3665 retval = MBX_SUCCESS; 3720 - else 3666 + else { 3721 3667 retval = MBX_TIMEOUT; 3668 + pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 3669 + } 3670 + spin_unlock_irqrestore(&phba->hbalock, flag); 3722 3671 } 3723 3672 3724 3673 return retval; ··· 3769 3712 uint32_t control; 3770 3713 3771 3714 MAILBOX_t *mbox, *pmbox; 3715 + struct lpfc_vport *vport; 3716 + struct lpfc_nodelist *ndlp; 3717 + struct lpfc_dmabuf *mp; 3772 3718 LPFC_MBOXQ_t *pmb; 3773 3719 int rc; 3774 3720 ··· 3840 3780 } 3841 3781 3842 3782 if (work_ha_copy & ~(HA_ERATT|HA_MBATT|HA_LATT)) { 3843 - for (i = 0; i < phba->sli.num_rings; i++) { 3844 - if (work_ha_copy & (HA_RXATT << (4*i))) { 3845 - /* 3846 - * Turn off Slow Rings interrupts 3847 - */ 3848 - spin_lock(&phba->hbalock); 3849 - control = readl(phba->HCregaddr); 3850 - control &= ~(HC_R0INT_ENA << i); 3783 + /* 3784 + * Turn off Slow Rings interrupts, LPFC_ELS_RING is 3785 + * the only slow ring. 3786 + */ 3787 + status = (work_ha_copy & 3788 + (HA_RXMASK << (4*LPFC_ELS_RING))); 3789 + status >>= (4*LPFC_ELS_RING); 3790 + if (status & HA_RXMASK) { 3791 + spin_lock(&phba->hbalock); 3792 + control = readl(phba->HCregaddr); 3793 + if (control & (HC_R0INT_ENA << LPFC_ELS_RING)) { 3794 + control &= 3795 + ~(HC_R0INT_ENA << LPFC_ELS_RING); 3851 3796 writel(control, phba->HCregaddr); 3852 3797 readl(phba->HCregaddr); /* flush */ 3853 - spin_unlock(&phba->hbalock); 3854 3798 } 3799 + spin_unlock(&phba->hbalock); 3855 3800 } 3856 3801 } 3857 3802 ··· 3884 3819 pmb = phba->sli.mbox_active; 3885 3820 pmbox = &pmb->mb; 3886 3821 mbox = &phba->slim2p->mbx; 3822 + vport = pmb->vport; 3887 3823 3888 3824 /* First check out the status word */ 3889 3825 lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof(uint32_t)); ··· 3899 3833 "Interrupt mbxCommand x%x " 3900 3834 "mbxStatus x%x\n", 3901 3835 phba->brd_no, 3902 - (pmb->vport 3903 - ? pmb->vport->vpi 3904 - : 0), 3836 + (vport 3837 + ? vport->vpi : 0), 3905 3838 pmbox->mbxCommand, 3906 3839 pmbox->mbxStatus); 3907 3840 } 3841 + phba->last_completion_time = jiffies; 3908 3842 del_timer_sync(&phba->sli.mbox_tmo); 3909 3843 3910 - spin_lock(&phba->pport->work_port_lock); 3911 - phba->pport->work_port_events &= ~WORKER_MBOX_TMO; 3912 - spin_unlock(&phba->pport->work_port_lock); 3913 3844 phba->sli.mbox_active = NULL; 3914 3845 if (pmb->mbox_cmpl) { 3915 3846 lpfc_sli_pcimem_bcopy(mbox, pmbox, 3916 3847 MAILBOX_CMD_SIZE); 3917 3848 } 3849 + if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { 3850 + pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; 3851 + 3852 + lpfc_debugfs_disc_trc(vport, 3853 + LPFC_DISC_TRC_MBOX_VPORT, 3854 + "MBOX dflt rpi: : status:x%x rpi:x%x", 3855 + (uint32_t)pmbox->mbxStatus, 3856 + pmbox->un.varWords[0], 0); 3857 + 3858 + if ( !pmbox->mbxStatus) { 3859 + mp = (struct lpfc_dmabuf *) 3860 + (pmb->context1); 3861 + ndlp = (struct lpfc_nodelist *) 3862 + pmb->context2; 3863 + 3864 + /* Reg_LOGIN of dflt RPI was successful. 3865 + * new lets get rid of the RPI using the 3866 + * same mbox buffer. 3867 + */ 3868 + lpfc_unreg_login(phba, vport->vpi, 3869 + pmbox->un.varWords[0], pmb); 3870 + pmb->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; 3871 + pmb->context1 = mp; 3872 + pmb->context2 = ndlp; 3873 + pmb->vport = vport; 3874 + spin_lock(&phba->hbalock); 3875 + phba->sli.sli_flag &= 3876 + ~LPFC_SLI_MBOX_ACTIVE; 3877 + spin_unlock(&phba->hbalock); 3878 + goto send_current_mbox; 3879 + } 3880 + } 3881 + spin_lock(&phba->pport->work_port_lock); 3882 + phba->pport->work_port_events &= ~WORKER_MBOX_TMO; 3883 + spin_unlock(&phba->pport->work_port_lock); 3918 3884 lpfc_mbox_cmpl_put(phba, pmb); 3919 3885 } 3920 3886 if ((work_ha_copy & HA_MBATT) && ··· 3956 3858 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; 3957 3859 pmb = lpfc_mbox_get(phba); 3958 3860 spin_unlock(&phba->hbalock); 3959 - 3861 + send_current_mbox: 3960 3862 /* Process next mailbox command if there is one */ 3961 3863 if (pmb != NULL) { 3962 3864 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); ··· 3989 3891 */ 3990 3892 status = (ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); 3991 3893 status >>= (4*LPFC_FCP_RING); 3992 - if (status & HA_RXATT) 3894 + if (status & HA_RXMASK) 3993 3895 lpfc_sli_handle_fast_ring_event(phba, 3994 3896 &phba->sli.ring[LPFC_FCP_RING], 3995 3897 status); ··· 4002 3904 */ 4003 3905 status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); 4004 3906 status >>= (4*LPFC_EXTRA_RING); 4005 - if (status & HA_RXATT) { 3907 + if (status & HA_RXMASK) { 4006 3908 lpfc_sli_handle_fast_ring_event(phba, 4007 3909 &phba->sli.ring[LPFC_EXTRA_RING], 4008 3910 status);
+2 -1
drivers/scsi/lpfc/lpfc_sli.h
··· 73 73 #define IOCB_ERROR 2 74 74 #define IOCB_TIMEDOUT 3 75 75 76 - #define LPFC_MBX_WAKE 1 76 + #define LPFC_MBX_WAKE 1 77 + #define LPFC_MBX_IMED_UNREG 2 77 78 78 79 typedef struct lpfcMboxq { 79 80 /* MBOXQs are used in single linked lists */
+27 -12
drivers/scsi/lpfc/lpfc_vport.c
··· 82 82 int vpi; 83 83 84 84 spin_lock_irq(&phba->hbalock); 85 - vpi = find_next_zero_bit(phba->vpi_bmask, phba->max_vpi, 1); 85 + /* Start at bit 1 because vpi zero is reserved for the physical port */ 86 + vpi = find_next_zero_bit(phba->vpi_bmask, (phba->max_vpi + 1), 1); 86 87 if (vpi > phba->max_vpi) 87 88 vpi = 0; 88 89 else ··· 132 131 mb->mbxCommand, mb->mbxStatus, rc); 133 132 lpfc_mbuf_free(phba, mp->virt, mp->phys); 134 133 kfree(mp); 135 - mempool_free(pmb, phba->mbox_mem_pool); 134 + if (rc != MBX_TIMEOUT) 135 + mempool_free(pmb, phba->mbox_mem_pool); 136 136 return -EIO; 137 137 } 138 138 ··· 243 241 } 244 242 245 243 vport->vpi = vpi; 244 + lpfc_debugfs_initialize(vport); 245 + 246 246 if (lpfc_vport_sparm(phba, vport)) { 247 247 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 248 248 "%d:1813 Create VPORT failed: vpi:%d " ··· 310 306 */ 311 307 ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); 312 308 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { 313 - lpfc_set_disctmo(vport); 314 - lpfc_initial_fdisc(vport); 309 + if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) { 310 + lpfc_set_disctmo(vport); 311 + lpfc_initial_fdisc(vport); 312 + } else { 313 + lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); 314 + lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 315 + "%d (%d):0262 No NPIV Fabric " 316 + "support\n", 317 + phba->brd_no, vport->vpi); 318 + } 315 319 } else { 316 320 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 317 321 } ··· 395 383 */ 396 384 ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); 397 385 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) { 398 - lpfc_set_disctmo(vport); 399 - lpfc_initial_fdisc(vport); 386 + if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) { 387 + lpfc_set_disctmo(vport); 388 + lpfc_initial_fdisc(vport); 389 + } else { 390 + lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); 391 + lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 392 + "%d (%d):0264 No NPIV Fabric " 393 + "support\n", 394 + phba->brd_no, vport->vpi); 395 + } 400 396 } else { 401 397 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 402 398 } ··· 461 441 vport->load_flag |= FC_UNLOADING; 462 442 463 443 kfree(vport->vname); 444 + lpfc_debugfs_terminate(vport); 464 445 fc_remove_host(lpfc_shost_from_vport(vport)); 465 446 scsi_remove_host(lpfc_shost_from_vport(vport)); 466 447 ··· 495 474 NLP_EVT_DEVICE_RECOVERY); 496 475 lpfc_disc_state_machine(vport, ndlp, NULL, 497 476 NLP_EVT_DEVICE_RM); 498 - } 499 - 500 - list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { 501 - /* free any ndlp's in unused state */ 502 - if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) 503 - lpfc_drop_node(vport, ndlp); 504 477 } 505 478 506 479 lpfc_stop_vport_timers(vport);