aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc')
-rw-r--r--drivers/scsi/lpfc/lpfc.h33
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c212
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h32
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c24
-rw-r--r--drivers/scsi/lpfc/lpfc_disc.h28
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c552
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c884
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h11
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c516
-rw-r--r--drivers/scsi/lpfc/lpfc_mbox.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c307
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c109
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c427
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.h12
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h6
15 files changed, 1550 insertions, 1606 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index a7de0bca5bdd..82e8f90c4617 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -27,10 +27,6 @@ struct lpfc_sli2_slim;
27 requests */ 27 requests */
28#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact 28#define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
29 the NameServer before giving up. */ 29 the NameServer before giving up. */
30#define LPFC_DFT_HBA_Q_DEPTH 2048 /* max cmds per hba */
31#define LPFC_LC_HBA_Q_DEPTH 1024 /* max cmds per low cost hba */
32#define LPFC_LP101_HBA_Q_DEPTH 128 /* max cmds per low cost hba */
33
34#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */ 30#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
35#define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */ 31#define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
36#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */ 32#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
@@ -244,28 +240,23 @@ struct lpfc_hba {
244#define FC_FABRIC 0x100 /* We are fabric attached */ 240#define FC_FABRIC 0x100 /* We are fabric attached */
245#define FC_ESTABLISH_LINK 0x200 /* Reestablish Link */ 241#define FC_ESTABLISH_LINK 0x200 /* Reestablish Link */
246#define FC_RSCN_DISCOVERY 0x400 /* Authenticate all devices after RSCN*/ 242#define FC_RSCN_DISCOVERY 0x400 /* Authenticate all devices after RSCN*/
243#define FC_BLOCK_MGMT_IO 0x800 /* Don't allow mgmt mbx or iocb cmds */
247#define FC_LOADING 0x1000 /* HBA in process of loading drvr */ 244#define FC_LOADING 0x1000 /* HBA in process of loading drvr */
248#define FC_UNLOADING 0x2000 /* HBA in process of unloading drvr */ 245#define FC_UNLOADING 0x2000 /* HBA in process of unloading drvr */
249#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */ 246#define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
250#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */ 247#define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
251#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */ 248#define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
252#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */ 249#define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
250#define FC_LOOPBACK_MODE 0x40000 /* NPort is in Loopback mode */
251 /* This flag is set while issuing */
252 /* INIT_LINK mailbox command */
253#define FC_IGNORE_ERATT 0x80000 /* intr handler should ignore ERATT */
253 254
254 uint32_t fc_topology; /* link topology, from LINK INIT */ 255 uint32_t fc_topology; /* link topology, from LINK INIT */
255 256
256 struct lpfc_stats fc_stat; 257 struct lpfc_stats fc_stat;
257 258
258 /* These are the head/tail pointers for the bind, plogi, adisc, unmap, 259 struct list_head fc_nodes;
259 * and map lists. Their counters are immediately following.
260 */
261 struct list_head fc_plogi_list;
262 struct list_head fc_adisc_list;
263 struct list_head fc_reglogin_list;
264 struct list_head fc_prli_list;
265 struct list_head fc_nlpunmap_list;
266 struct list_head fc_nlpmap_list;
267 struct list_head fc_npr_list;
268 struct list_head fc_unused_list;
269 260
270 /* Keep counters for the number of entries in each list. */ 261 /* Keep counters for the number of entries in each list. */
271 uint16_t fc_plogi_cnt; 262 uint16_t fc_plogi_cnt;
@@ -387,13 +378,17 @@ struct lpfc_hba {
387 378
388 mempool_t *mbox_mem_pool; 379 mempool_t *mbox_mem_pool;
389 mempool_t *nlp_mem_pool; 380 mempool_t *nlp_mem_pool;
390 struct list_head freebufList;
391 struct list_head ctrspbuflist;
392 struct list_head rnidrspbuflist;
393 381
394 struct fc_host_statistics link_stats; 382 struct fc_host_statistics link_stats;
395}; 383};
396 384
385static inline void
386lpfc_set_loopback_flag(struct lpfc_hba *phba) {
387 if (phba->cfg_topology == FLAGS_LOCAL_LB)
388 phba->fc_flag |= FC_LOOPBACK_MODE;
389 else
390 phba->fc_flag &= ~FC_LOOPBACK_MODE;
391}
397 392
398struct rnidrsp { 393struct rnidrsp {
399 void *buf; 394 void *buf;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index f247e786af99..95fe77e816f8 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -20,6 +20,7 @@
20 *******************************************************************/ 20 *******************************************************************/
21 21
22#include <linux/ctype.h> 22#include <linux/ctype.h>
23#include <linux/delay.h>
23#include <linux/pci.h> 24#include <linux/pci.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25 26
@@ -213,6 +214,7 @@ lpfc_issue_lip(struct Scsi_Host *host)
213 int mbxstatus = MBXERR_ERROR; 214 int mbxstatus = MBXERR_ERROR;
214 215
215 if ((phba->fc_flag & FC_OFFLINE_MODE) || 216 if ((phba->fc_flag & FC_OFFLINE_MODE) ||
217 (phba->fc_flag & FC_BLOCK_MGMT_IO) ||
216 (phba->hba_state != LPFC_HBA_READY)) 218 (phba->hba_state != LPFC_HBA_READY))
217 return -EPERM; 219 return -EPERM;
218 220
@@ -235,6 +237,7 @@ lpfc_issue_lip(struct Scsi_Host *host)
235 phba->fc_ratov * 2); 237 phba->fc_ratov * 2);
236 } 238 }
237 239
240 lpfc_set_loopback_flag(phba);
238 if (mbxstatus == MBX_TIMEOUT) 241 if (mbxstatus == MBX_TIMEOUT)
239 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 242 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
240 else 243 else
@@ -247,19 +250,62 @@ lpfc_issue_lip(struct Scsi_Host *host)
247} 250}
248 251
249static int 252static int
250lpfc_selective_reset(struct lpfc_hba *phba) 253lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
251{ 254{
252 struct completion online_compl; 255 struct completion online_compl;
256 struct lpfc_sli_ring *pring;
257 struct lpfc_sli *psli;
253 int status = 0; 258 int status = 0;
259 int cnt = 0;
260 int i;
254 261
255 init_completion(&online_compl); 262 init_completion(&online_compl);
256 lpfc_workq_post_event(phba, &status, &online_compl, 263 lpfc_workq_post_event(phba, &status, &online_compl,
257 LPFC_EVT_OFFLINE); 264 LPFC_EVT_OFFLINE_PREP);
265 wait_for_completion(&online_compl);
266
267 if (status != 0)
268 return -EIO;
269
270 psli = &phba->sli;
271
272 for (i = 0; i < psli->num_rings; i++) {
273 pring = &psli->ring[i];
274 /* The linkdown event takes 30 seconds to timeout. */
275 while (pring->txcmplq_cnt) {
276 msleep(10);
277 if (cnt++ > 3000) {
278 lpfc_printf_log(phba,
279 KERN_WARNING, LOG_INIT,
280 "%d:0466 Outstanding IO when "
281 "bringing Adapter offline\n",
282 phba->brd_no);
283 break;
284 }
285 }
286 }
287
288 init_completion(&online_compl);
289 lpfc_workq_post_event(phba, &status, &online_compl, type);
258 wait_for_completion(&online_compl); 290 wait_for_completion(&online_compl);
259 291
260 if (status != 0) 292 if (status != 0)
261 return -EIO; 293 return -EIO;
262 294
295 return 0;
296}
297
298static int
299lpfc_selective_reset(struct lpfc_hba *phba)
300{
301 struct completion online_compl;
302 int status = 0;
303
304 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
305
306 if (status != 0)
307 return status;
308
263 init_completion(&online_compl); 309 init_completion(&online_compl);
264 lpfc_workq_post_event(phba, &status, &online_compl, 310 lpfc_workq_post_event(phba, &status, &online_compl,
265 LPFC_EVT_ONLINE); 311 LPFC_EVT_ONLINE);
@@ -324,23 +370,19 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
324 370
325 init_completion(&online_compl); 371 init_completion(&online_compl);
326 372
327 if(strncmp(buf, "online", sizeof("online") - 1) == 0) 373 if(strncmp(buf, "online", sizeof("online") - 1) == 0) {
328 lpfc_workq_post_event(phba, &status, &online_compl, 374 lpfc_workq_post_event(phba, &status, &online_compl,
329 LPFC_EVT_ONLINE); 375 LPFC_EVT_ONLINE);
330 else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0) 376 wait_for_completion(&online_compl);
331 lpfc_workq_post_event(phba, &status, &online_compl, 377 } else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
332 LPFC_EVT_OFFLINE); 378 status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
333 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0) 379 else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
334 lpfc_workq_post_event(phba, &status, &online_compl, 380 status = lpfc_do_offline(phba, LPFC_EVT_WARM_START);
335 LPFC_EVT_WARM_START); 381 else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
336 else if (strncmp(buf, "error", sizeof("error") - 1) == 0) 382 status = lpfc_do_offline(phba, LPFC_EVT_KILL);
337 lpfc_workq_post_event(phba, &status, &online_compl,
338 LPFC_EVT_KILL);
339 else 383 else
340 return -EINVAL; 384 return -EINVAL;
341 385
342 wait_for_completion(&online_compl);
343
344 if (!status) 386 if (!status)
345 return strlen(buf); 387 return strlen(buf);
346 else 388 else
@@ -645,9 +687,7 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
645 dev_printk(KERN_NOTICE, &phba->pcidev->dev, 687 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
646 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); 688 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
647 689
648 init_completion(&online_compl); 690 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
649 lpfc_workq_post_event(phba, &stat1, &online_compl, LPFC_EVT_OFFLINE);
650 wait_for_completion(&online_compl);
651 if (stat1) 691 if (stat1)
652 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 692 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
653 "%d:0463 lpfc_soft_wwpn attribute set failed to reinit " 693 "%d:0463 lpfc_soft_wwpn attribute set failed to reinit "
@@ -789,6 +829,18 @@ lpfc_nodev_tmo_init(struct lpfc_hba *phba, int val)
789 return -EINVAL; 829 return -EINVAL;
790} 830}
791 831
832static void
833lpfc_update_rport_devloss_tmo(struct lpfc_hba *phba)
834{
835 struct lpfc_nodelist *ndlp;
836
837 spin_lock_irq(phba->host->host_lock);
838 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp)
839 if (ndlp->rport)
840 ndlp->rport->dev_loss_tmo = phba->cfg_devloss_tmo;
841 spin_unlock_irq(phba->host->host_lock);
842}
843
792static int 844static int
793lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val) 845lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val)
794{ 846{
@@ -804,6 +856,7 @@ lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val)
804 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 856 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
805 phba->cfg_nodev_tmo = val; 857 phba->cfg_nodev_tmo = val;
806 phba->cfg_devloss_tmo = val; 858 phba->cfg_devloss_tmo = val;
859 lpfc_update_rport_devloss_tmo(phba);
807 return 0; 860 return 0;
808 } 861 }
809 862
@@ -839,6 +892,7 @@ lpfc_devloss_tmo_set(struct lpfc_hba *phba, int val)
839 phba->cfg_nodev_tmo = val; 892 phba->cfg_nodev_tmo = val;
840 phba->cfg_devloss_tmo = val; 893 phba->cfg_devloss_tmo = val;
841 phba->dev_loss_tmo_changed = 1; 894 phba->dev_loss_tmo_changed = 1;
895 lpfc_update_rport_devloss_tmo(phba);
842 return 0; 896 return 0;
843 } 897 }
844 898
@@ -931,9 +985,10 @@ LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");
931# 1 = 1 Gigabaud 985# 1 = 1 Gigabaud
932# 2 = 2 Gigabaud 986# 2 = 2 Gigabaud
933# 4 = 4 Gigabaud 987# 4 = 4 Gigabaud
934# Value range is [0,4]. Default value is 0. 988# 8 = 8 Gigabaud
989# Value range is [0,8]. Default value is 0.
935*/ 990*/
936LPFC_ATTR_R(link_speed, 0, 0, 4, "Select link speed"); 991LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");
937 992
938/* 993/*
939# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 994# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
@@ -958,7 +1013,7 @@ LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
958/* 1013/*
959# lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing 1014# lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
960# cr_delay (msec) or cr_count outstanding commands. cr_delay can take 1015# cr_delay (msec) or cr_count outstanding commands. cr_delay can take
961# value [0,63]. cr_count can take value [0,255]. Default value of cr_delay 1016# value [0,63]. cr_count can take value [1,255]. Default value of cr_delay
962# is 0. Default value of cr_count is 1. The cr_count feature is disabled if 1017# is 0. Default value of cr_count is 1. The cr_count feature is disabled if
963# cr_delay is set to 0. 1018# cr_delay is set to 0.
964*/ 1019*/
@@ -1227,11 +1282,11 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
1227 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 1282 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
1228 int rc; 1283 int rc;
1229 1284
1230 if (off > sizeof(MAILBOX_t)) 1285 if (off > MAILBOX_CMD_SIZE)
1231 return -ERANGE; 1286 return -ERANGE;
1232 1287
1233 if ((count + off) > sizeof(MAILBOX_t)) 1288 if ((count + off) > MAILBOX_CMD_SIZE)
1234 count = sizeof(MAILBOX_t) - off; 1289 count = MAILBOX_CMD_SIZE - off;
1235 1290
1236 if (off % 4 || count % 4 || (unsigned long)buf % 4) 1291 if (off % 4 || count % 4 || (unsigned long)buf % 4)
1237 return -EINVAL; 1292 return -EINVAL;
@@ -1307,6 +1362,12 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
1307 return -EPERM; 1362 return -EPERM;
1308 } 1363 }
1309 1364
1365 if (phba->fc_flag & FC_BLOCK_MGMT_IO) {
1366 sysfs_mbox_idle(phba);
1367 spin_unlock_irq(host->host_lock);
1368 return -EAGAIN;
1369 }
1370
1310 if ((phba->fc_flag & FC_OFFLINE_MODE) || 1371 if ((phba->fc_flag & FC_OFFLINE_MODE) ||
1311 (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE))){ 1372 (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE))){
1312 1373
@@ -1326,6 +1387,11 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
1326 } 1387 }
1327 1388
1328 if (rc != MBX_SUCCESS) { 1389 if (rc != MBX_SUCCESS) {
1390 if (rc == MBX_TIMEOUT) {
1391 phba->sysfs_mbox.mbox->mbox_cmpl =
1392 lpfc_sli_def_mbox_cmpl;
1393 phba->sysfs_mbox.mbox = NULL;
1394 }
1329 sysfs_mbox_idle(phba); 1395 sysfs_mbox_idle(phba);
1330 spin_unlock_irq(host->host_lock); 1396 spin_unlock_irq(host->host_lock);
1331 return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV; 1397 return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV;
@@ -1344,7 +1410,7 @@ sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
1344 1410
1345 phba->sysfs_mbox.offset = off + count; 1411 phba->sysfs_mbox.offset = off + count;
1346 1412
1347 if (phba->sysfs_mbox.offset == sizeof(MAILBOX_t)) 1413 if (phba->sysfs_mbox.offset == MAILBOX_CMD_SIZE)
1348 sysfs_mbox_idle(phba); 1414 sysfs_mbox_idle(phba);
1349 1415
1350 spin_unlock_irq(phba->host->host_lock); 1416 spin_unlock_irq(phba->host->host_lock);
@@ -1358,7 +1424,7 @@ static struct bin_attribute sysfs_mbox_attr = {
1358 .mode = S_IRUSR | S_IWUSR, 1424 .mode = S_IRUSR | S_IWUSR,
1359 .owner = THIS_MODULE, 1425 .owner = THIS_MODULE,
1360 }, 1426 },
1361 .size = sizeof(MAILBOX_t), 1427 .size = MAILBOX_CMD_SIZE,
1362 .read = sysfs_mbox_read, 1428 .read = sysfs_mbox_read,
1363 .write = sysfs_mbox_write, 1429 .write = sysfs_mbox_write,
1364}; 1430};
@@ -1494,6 +1560,9 @@ lpfc_get_host_speed(struct Scsi_Host *shost)
1494 case LA_4GHZ_LINK: 1560 case LA_4GHZ_LINK:
1495 fc_host_speed(shost) = FC_PORTSPEED_4GBIT; 1561 fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
1496 break; 1562 break;
1563 case LA_8GHZ_LINK:
1564 fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
1565 break;
1497 default: 1566 default:
1498 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 1567 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
1499 break; 1568 break;
@@ -1546,6 +1615,9 @@ lpfc_get_stats(struct Scsi_Host *shost)
1546 unsigned long seconds; 1615 unsigned long seconds;
1547 int rc = 0; 1616 int rc = 0;
1548 1617
1618 if (phba->fc_flag & FC_BLOCK_MGMT_IO)
1619 return NULL;
1620
1549 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 1621 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1550 if (!pmboxq) 1622 if (!pmboxq)
1551 return NULL; 1623 return NULL;
@@ -1631,6 +1703,8 @@ lpfc_get_stats(struct Scsi_Host *shost)
1631 else 1703 else
1632 hs->seconds_since_last_reset = seconds - psli->stats_start; 1704 hs->seconds_since_last_reset = seconds - psli->stats_start;
1633 1705
1706 mempool_free(pmboxq, phba->mbox_mem_pool);
1707
1634 return hs; 1708 return hs;
1635} 1709}
1636 1710
@@ -1644,6 +1718,9 @@ lpfc_reset_stats(struct Scsi_Host *shost)
1644 MAILBOX_t *pmb; 1718 MAILBOX_t *pmb;
1645 int rc = 0; 1719 int rc = 0;
1646 1720
1721 if (phba->fc_flag & FC_BLOCK_MGMT_IO)
1722 return;
1723
1647 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 1724 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
1648 if (!pmboxq) 1725 if (!pmboxq)
1649 return; 1726 return;
@@ -1699,6 +1776,8 @@ lpfc_reset_stats(struct Scsi_Host *shost)
1699 1776
1700 psli->stats_start = get_seconds(); 1777 psli->stats_start = get_seconds();
1701 1778
1779 mempool_free(pmboxq, phba->mbox_mem_pool);
1780
1702 return; 1781 return;
1703} 1782}
1704 1783
@@ -1706,67 +1785,51 @@ lpfc_reset_stats(struct Scsi_Host *shost)
1706 * The LPFC driver treats linkdown handling as target loss events so there 1785 * The LPFC driver treats linkdown handling as target loss events so there
1707 * are no sysfs handlers for link_down_tmo. 1786 * are no sysfs handlers for link_down_tmo.
1708 */ 1787 */
1709static void 1788
1710lpfc_get_starget_port_id(struct scsi_target *starget) 1789static struct lpfc_nodelist *
1790lpfc_get_node_by_target(struct scsi_target *starget)
1711{ 1791{
1712 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1792 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1713 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata; 1793 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
1714 uint32_t did = -1; 1794 struct lpfc_nodelist *ndlp;
1715 struct lpfc_nodelist *ndlp = NULL;
1716 1795
1717 spin_lock_irq(shost->host_lock); 1796 spin_lock_irq(shost->host_lock);
1718 /* Search the mapped list for this target ID */ 1797 /* Search for this, mapped, target ID */
1719 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { 1798 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
1720 if (starget->id == ndlp->nlp_sid) { 1799 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
1721 did = ndlp->nlp_DID; 1800 starget->id == ndlp->nlp_sid) {
1722 break; 1801 spin_unlock_irq(shost->host_lock);
1802 return ndlp;
1723 } 1803 }
1724 } 1804 }
1725 spin_unlock_irq(shost->host_lock); 1805 spin_unlock_irq(shost->host_lock);
1806 return NULL;
1807}
1808
1809static void
1810lpfc_get_starget_port_id(struct scsi_target *starget)
1811{
1812 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
1726 1813
1727 fc_starget_port_id(starget) = did; 1814 fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1;
1728} 1815}
1729 1816
1730static void 1817static void
1731lpfc_get_starget_node_name(struct scsi_target *starget) 1818lpfc_get_starget_node_name(struct scsi_target *starget)
1732{ 1819{
1733 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1820 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
1734 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
1735 u64 node_name = 0;
1736 struct lpfc_nodelist *ndlp = NULL;
1737
1738 spin_lock_irq(shost->host_lock);
1739 /* Search the mapped list for this target ID */
1740 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
1741 if (starget->id == ndlp->nlp_sid) {
1742 node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
1743 break;
1744 }
1745 }
1746 spin_unlock_irq(shost->host_lock);
1747 1821
1748 fc_starget_node_name(starget) = node_name; 1822 fc_starget_node_name(starget) =
1823 ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0;
1749} 1824}
1750 1825
1751static void 1826static void
1752lpfc_get_starget_port_name(struct scsi_target *starget) 1827lpfc_get_starget_port_name(struct scsi_target *starget)
1753{ 1828{
1754 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1829 struct lpfc_nodelist *ndlp = lpfc_get_node_by_target(starget);
1755 struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
1756 u64 port_name = 0;
1757 struct lpfc_nodelist *ndlp = NULL;
1758
1759 spin_lock_irq(shost->host_lock);
1760 /* Search the mapped list for this target ID */
1761 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
1762 if (starget->id == ndlp->nlp_sid) {
1763 port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
1764 break;
1765 }
1766 }
1767 spin_unlock_irq(shost->host_lock);
1768 1830
1769 fc_starget_port_name(starget) = port_name; 1831 fc_starget_port_name(starget) =
1832 ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0;
1770} 1833}
1771 1834
1772static void 1835static void
@@ -1895,25 +1958,8 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
1895 sizeof(struct fcp_rsp) + 1958 sizeof(struct fcp_rsp) +
1896 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64)); 1959 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
1897 1960
1898 switch (phba->pcidev->device) {
1899 case PCI_DEVICE_ID_LP101:
1900 case PCI_DEVICE_ID_BSMB:
1901 case PCI_DEVICE_ID_ZSMB:
1902 phba->cfg_hba_queue_depth = LPFC_LP101_HBA_Q_DEPTH;
1903 break;
1904 case PCI_DEVICE_ID_RFLY:
1905 case PCI_DEVICE_ID_PFLY:
1906 case PCI_DEVICE_ID_BMID:
1907 case PCI_DEVICE_ID_ZMID:
1908 case PCI_DEVICE_ID_TFLY:
1909 phba->cfg_hba_queue_depth = LPFC_LC_HBA_Q_DEPTH;
1910 break;
1911 default:
1912 phba->cfg_hba_queue_depth = LPFC_DFT_HBA_Q_DEPTH;
1913 }
1914 1961
1915 if (phba->cfg_hba_queue_depth > lpfc_hba_queue_depth) 1962 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
1916 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
1917 1963
1918 return; 1964 return;
1919} 1965}
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 1251788ce2a3..b8c2a8862d8c 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * * 7 * *
@@ -18,6 +18,8 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21typedef int (*node_filter)(struct lpfc_nodelist *ndlp, void *param);
22
21struct fc_rport; 23struct fc_rport;
22void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t); 24void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);
23void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *); 25void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
@@ -43,20 +45,24 @@ void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
43void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); 45void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
44void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); 46void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
45void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); 47void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
46int lpfc_nlp_list(struct lpfc_hba *, struct lpfc_nodelist *, int); 48void lpfc_dequeue_node(struct lpfc_hba *, struct lpfc_nodelist *);
49void lpfc_nlp_set_state(struct lpfc_hba *, struct lpfc_nodelist *, int);
50void lpfc_drop_node(struct lpfc_hba *, struct lpfc_nodelist *);
47void lpfc_set_disctmo(struct lpfc_hba *); 51void lpfc_set_disctmo(struct lpfc_hba *);
48int lpfc_can_disctmo(struct lpfc_hba *); 52int lpfc_can_disctmo(struct lpfc_hba *);
49int lpfc_unreg_rpi(struct lpfc_hba *, struct lpfc_nodelist *); 53int lpfc_unreg_rpi(struct lpfc_hba *, struct lpfc_nodelist *);
50int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *, 54int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *,
51 struct lpfc_iocbq *, struct lpfc_nodelist *); 55 struct lpfc_iocbq *, struct lpfc_nodelist *);
52int lpfc_nlp_remove(struct lpfc_hba *, struct lpfc_nodelist *);
53void lpfc_nlp_init(struct lpfc_hba *, struct lpfc_nodelist *, uint32_t); 56void lpfc_nlp_init(struct lpfc_hba *, struct lpfc_nodelist *, uint32_t);
57struct lpfc_nodelist *lpfc_nlp_get(struct lpfc_nodelist *);
58int lpfc_nlp_put(struct lpfc_nodelist *);
54struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_hba *, uint32_t); 59struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_hba *, uint32_t);
55void lpfc_disc_list_loopmap(struct lpfc_hba *); 60void lpfc_disc_list_loopmap(struct lpfc_hba *);
56void lpfc_disc_start(struct lpfc_hba *); 61void lpfc_disc_start(struct lpfc_hba *);
57void lpfc_disc_flush_list(struct lpfc_hba *); 62void lpfc_disc_flush_list(struct lpfc_hba *);
58void lpfc_disc_timeout(unsigned long); 63void lpfc_disc_timeout(unsigned long);
59 64
65struct lpfc_nodelist *__lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi);
60struct lpfc_nodelist *lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi); 66struct lpfc_nodelist *lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi);
61 67
62int lpfc_workq_post_event(struct lpfc_hba *, void *, void *, uint32_t); 68int lpfc_workq_post_event(struct lpfc_hba *, void *, void *, uint32_t);
@@ -66,8 +72,7 @@ int lpfc_disc_state_machine(struct lpfc_hba *, struct lpfc_nodelist *, void *,
66 72
67int lpfc_check_sparm(struct lpfc_hba *, struct lpfc_nodelist *, 73int lpfc_check_sparm(struct lpfc_hba *, struct lpfc_nodelist *,
68 struct serv_parm *, uint32_t); 74 struct serv_parm *, uint32_t);
69int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist * ndlp, 75int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist * ndlp);
70 int);
71int lpfc_els_abort_flogi(struct lpfc_hba *); 76int lpfc_els_abort_flogi(struct lpfc_hba *);
72int lpfc_initial_flogi(struct lpfc_hba *); 77int lpfc_initial_flogi(struct lpfc_hba *);
73int lpfc_issue_els_plogi(struct lpfc_hba *, uint32_t, uint8_t); 78int lpfc_issue_els_plogi(struct lpfc_hba *, uint32_t, uint8_t);
@@ -113,7 +118,10 @@ void lpfc_hba_init(struct lpfc_hba *, uint32_t *);
113int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int); 118int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int);
114void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int); 119void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);
115int lpfc_online(struct lpfc_hba *); 120int lpfc_online(struct lpfc_hba *);
116int lpfc_offline(struct lpfc_hba *); 121void lpfc_block_mgmt_io(struct lpfc_hba *);
122void lpfc_unblock_mgmt_io(struct lpfc_hba *);
123void lpfc_offline_prep(struct lpfc_hba *);
124void lpfc_offline(struct lpfc_hba *);
117 125
118int lpfc_sli_setup(struct lpfc_hba *); 126int lpfc_sli_setup(struct lpfc_hba *);
119int lpfc_sli_queue_setup(struct lpfc_hba *); 127int lpfc_sli_queue_setup(struct lpfc_hba *);
@@ -162,8 +170,8 @@ int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *,
162struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *, 170struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
163 struct lpfc_sli_ring *, 171 struct lpfc_sli_ring *,
164 dma_addr_t); 172 dma_addr_t);
165int lpfc_sli_issue_abort_iotag32(struct lpfc_hba *, struct lpfc_sli_ring *, 173int lpfc_sli_issue_abort_iotag(struct lpfc_hba *, struct lpfc_sli_ring *,
166 struct lpfc_iocbq *); 174 struct lpfc_iocbq *);
167int lpfc_sli_sum_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t, 175int lpfc_sli_sum_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
168 uint64_t, lpfc_ctx_cmd); 176 uint64_t, lpfc_ctx_cmd);
169int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t, 177int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
@@ -172,9 +180,8 @@ int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
172void lpfc_mbox_timeout(unsigned long); 180void lpfc_mbox_timeout(unsigned long);
173void lpfc_mbox_timeout_handler(struct lpfc_hba *); 181void lpfc_mbox_timeout_handler(struct lpfc_hba *);
174 182
175struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_hba *, uint32_t, uint32_t); 183struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_hba *, uint32_t);
176struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_hba *, uint32_t, 184struct lpfc_nodelist *lpfc_findnode_wwpn(struct lpfc_hba *, struct lpfc_name *);
177 struct lpfc_name *);
178 185
179int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, 186int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
180 uint32_t timeout); 187 uint32_t timeout);
@@ -193,6 +200,9 @@ void lpfc_mbuf_free(struct lpfc_hba *, void *, dma_addr_t);
193 200
194/* Function prototypes. */ 201/* Function prototypes. */
195const char* lpfc_info(struct Scsi_Host *); 202const char* lpfc_info(struct Scsi_Host *);
203void lpfc_scan_start(struct Scsi_Host *);
204int lpfc_scan_finished(struct Scsi_Host *, unsigned long);
205
196void lpfc_get_cfgparam(struct lpfc_hba *); 206void lpfc_get_cfgparam(struct lpfc_hba *);
197int lpfc_alloc_sysfs_attr(struct lpfc_hba *); 207int lpfc_alloc_sysfs_attr(struct lpfc_hba *);
198void lpfc_free_sysfs_attr(struct lpfc_hba *); 208void lpfc_free_sysfs_attr(struct lpfc_hba *);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index a51a41b7f15d..34a9e3bb2614 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * * 7 * *
@@ -334,21 +334,22 @@ lpfc_ns_rsp(struct lpfc_hba * phba, struct lpfc_dmabuf * mp, uint32_t Size)
334 334
335 lpfc_set_disctmo(phba); 335 lpfc_set_disctmo(phba);
336 336
337 Cnt = Size > FCELSSIZE ? FCELSSIZE : Size;
338 337
339 list_add_tail(&head, &mp->list); 338 list_add_tail(&head, &mp->list);
340 list_for_each_entry_safe(mp, next_mp, &head, list) { 339 list_for_each_entry_safe(mp, next_mp, &head, list) {
341 mlast = mp; 340 mlast = mp;
342 341
342 Cnt = Size > FCELSSIZE ? FCELSSIZE : Size;
343
343 Size -= Cnt; 344 Size -= Cnt;
344 345
345 if (!ctptr) 346 if (!ctptr) {
346 ctptr = (uint32_t *) mlast->virt; 347 ctptr = (uint32_t *) mlast->virt;
347 else 348 } else
348 Cnt -= 16; /* subtract length of CT header */ 349 Cnt -= 16; /* subtract length of CT header */
349 350
350 /* Loop through entire NameServer list of DIDs */ 351 /* Loop through entire NameServer list of DIDs */
351 while (Cnt) { 352 while (Cnt >= sizeof (uint32_t)) {
352 353
353 /* Get next DID from NameServer List */ 354 /* Get next DID from NameServer List */
354 CTentry = *ctptr++; 355 CTentry = *ctptr++;
@@ -442,10 +443,8 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
442 if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) { 443 if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) {
443 phba->fc_ns_retry++; 444 phba->fc_ns_retry++;
444 /* CT command is being retried */ 445 /* CT command is being retried */
445 ndlp = 446 ndlp = lpfc_findnode_did(phba, NameServer_DID);
446 lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, 447 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
447 NameServer_DID);
448 if (ndlp) {
449 if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 448 if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) ==
450 0) { 449 0) {
451 goto out; 450 goto out;
@@ -729,7 +728,7 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba * phba,
729 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp; 728 uint16_t fdmi_cmd = CTcmd->CommandResponse.bits.CmdRsp;
730 uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp; 729 uint16_t fdmi_rsp = CTrsp->CommandResponse.bits.CmdRsp;
731 730
732 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, FDMI_DID); 731 ndlp = lpfc_findnode_did(phba, FDMI_DID);
733 if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { 732 if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
734 /* FDMI rsp failed */ 733 /* FDMI rsp failed */
735 lpfc_printf_log(phba, 734 lpfc_printf_log(phba,
@@ -1039,6 +1038,9 @@ lpfc_fdmi_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
1039 case LA_4GHZ_LINK: 1038 case LA_4GHZ_LINK:
1040 ae->un.PortSpeed = HBA_PORTSPEED_4GBIT; 1039 ae->un.PortSpeed = HBA_PORTSPEED_4GBIT;
1041 break; 1040 break;
1041 case LA_8GHZ_LINK:
1042 ae->un.PortSpeed = HBA_PORTSPEED_8GBIT;
1043 break;
1042 default: 1044 default:
1043 ae->un.PortSpeed = 1045 ae->un.PortSpeed =
1044 HBA_PORTSPEED_UNKNOWN; 1046 HBA_PORTSPEED_UNKNOWN;
@@ -1161,7 +1163,7 @@ lpfc_fdmi_tmo_handler(struct lpfc_hba *phba)
1161{ 1163{
1162 struct lpfc_nodelist *ndlp; 1164 struct lpfc_nodelist *ndlp;
1163 1165
1164 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, FDMI_DID); 1166 ndlp = lpfc_findnode_did(phba, FDMI_DID);
1165 if (ndlp) { 1167 if (ndlp) {
1166 if (init_utsname()->nodename[0] != '\0') { 1168 if (init_utsname()->nodename[0] != '\0') {
1167 lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DHBA); 1169 lpfc_fdmi_cmd(phba, ndlp, SLI_MGMT_DHBA);
diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h
index 9766f909c9c6..498059f3f7f4 100644
--- a/drivers/scsi/lpfc/lpfc_disc.h
+++ b/drivers/scsi/lpfc/lpfc_disc.h
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * * 7 * *
@@ -31,6 +31,7 @@
31/* worker thread events */ 31/* worker thread events */
32enum lpfc_work_type { 32enum lpfc_work_type {
33 LPFC_EVT_ONLINE, 33 LPFC_EVT_ONLINE,
34 LPFC_EVT_OFFLINE_PREP,
34 LPFC_EVT_OFFLINE, 35 LPFC_EVT_OFFLINE,
35 LPFC_EVT_WARM_START, 36 LPFC_EVT_WARM_START,
36 LPFC_EVT_KILL, 37 LPFC_EVT_KILL,
@@ -68,7 +69,6 @@ struct lpfc_nodelist {
68 uint16_t nlp_maxframe; /* Max RCV frame size */ 69 uint16_t nlp_maxframe; /* Max RCV frame size */
69 uint8_t nlp_class_sup; /* Supported Classes */ 70 uint8_t nlp_class_sup; /* Supported Classes */
70 uint8_t nlp_retry; /* used for ELS retries */ 71 uint8_t nlp_retry; /* used for ELS retries */
71 uint8_t nlp_disc_refcnt; /* used for DSM */
72 uint8_t nlp_fcp_info; /* class info, bits 0-3 */ 72 uint8_t nlp_fcp_info; /* class info, bits 0-3 */
73#define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */ 73#define NLP_FCP_2_DEVICE 0x10 /* FCP-2 device */
74 74
@@ -79,20 +79,10 @@ struct lpfc_nodelist {
79 struct lpfc_work_evt els_retry_evt; 79 struct lpfc_work_evt els_retry_evt;
80 unsigned long last_ramp_up_time; /* jiffy of last ramp up */ 80 unsigned long last_ramp_up_time; /* jiffy of last ramp up */
81 unsigned long last_q_full_time; /* jiffy of last queue full */ 81 unsigned long last_q_full_time; /* jiffy of last queue full */
82 struct kref kref;
82}; 83};
83 84
84/* Defines for nlp_flag (uint32) */ 85/* Defines for nlp_flag (uint32) */
85#define NLP_NO_LIST 0x0 /* Indicates immediately free node */
86#define NLP_UNUSED_LIST 0x1 /* Flg to indicate node will be freed */
87#define NLP_PLOGI_LIST 0x2 /* Flg to indicate sent PLOGI */
88#define NLP_ADISC_LIST 0x3 /* Flg to indicate sent ADISC */
89#define NLP_REGLOGIN_LIST 0x4 /* Flg to indicate sent REG_LOGIN */
90#define NLP_PRLI_LIST 0x5 /* Flg to indicate sent PRLI */
91#define NLP_UNMAPPED_LIST 0x6 /* Node is now unmapped */
92#define NLP_MAPPED_LIST 0x7 /* Node is now mapped */
93#define NLP_NPR_LIST 0x8 /* Node is in NPort Recovery state */
94#define NLP_JUST_DQ 0x9 /* just deque ndlp in lpfc_nlp_list */
95#define NLP_LIST_MASK 0xf /* mask to see what list node is on */
96#define NLP_PLOGI_SND 0x20 /* sent PLOGI request for this entry */ 86#define NLP_PLOGI_SND 0x20 /* sent PLOGI request for this entry */
97#define NLP_PRLI_SND 0x40 /* sent PRLI request for this entry */ 87#define NLP_PRLI_SND 0x40 /* sent PRLI request for this entry */
98#define NLP_ADISC_SND 0x80 /* sent ADISC request for this entry */ 88#define NLP_ADISC_SND 0x80 /* sent ADISC request for this entry */
@@ -108,20 +98,8 @@ struct lpfc_nodelist {
108 ACC */ 98 ACC */
109#define NLP_NPR_ADISC 0x2000000 /* Issue ADISC when dq'ed from 99#define NLP_NPR_ADISC 0x2000000 /* Issue ADISC when dq'ed from
110 NPR list */ 100 NPR list */
111#define NLP_DELAY_REMOVE 0x4000000 /* Defer removal till end of DSM */
112#define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */ 101#define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */
113 102
114/* Defines for list searchs */
115#define NLP_SEARCH_MAPPED 0x1 /* search mapped */
116#define NLP_SEARCH_UNMAPPED 0x2 /* search unmapped */
117#define NLP_SEARCH_PLOGI 0x4 /* search plogi */
118#define NLP_SEARCH_ADISC 0x8 /* search adisc */
119#define NLP_SEARCH_REGLOGIN 0x10 /* search reglogin */
120#define NLP_SEARCH_PRLI 0x20 /* search prli */
121#define NLP_SEARCH_NPR 0x40 /* search npr */
122#define NLP_SEARCH_UNUSED 0x80 /* search mapped */
123#define NLP_SEARCH_ALL 0xff /* search all lists */
124
125/* There are 4 different double linked lists nodelist entries can reside on. 103/* There are 4 different double linked lists nodelist entries can reside on.
126 * The Port Login (PLOGI) list and Address Discovery (ADISC) list are used 104 * The Port Login (PLOGI) list and Address Discovery (ADISC) list are used
127 * when Link Up discovery or Registered State Change Notification (RSCN) 105 * when Link Up discovery or Registered State Change Notification (RSCN)
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index a5f33a0dd4e7..638b3cd677bd 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -182,6 +182,7 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba, uint8_t expectRsp,
182 icmd->un.elsreq64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64)); 182 icmd->un.elsreq64.bdl.bdeSize = (2 * sizeof (struct ulp_bde64));
183 icmd->un.elsreq64.remoteID = did; /* DID */ 183 icmd->un.elsreq64.remoteID = did; /* DID */
184 icmd->ulpCommand = CMD_ELS_REQUEST64_CR; 184 icmd->ulpCommand = CMD_ELS_REQUEST64_CR;
185 icmd->ulpTimeout = phba->fc_ratov * 2;
185 } else { 186 } else {
186 icmd->un.elsreq64.bdl.bdeSize = sizeof (struct ulp_bde64); 187 icmd->un.elsreq64.bdl.bdeSize = sizeof (struct ulp_bde64);
187 icmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX; 188 icmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX;
@@ -208,9 +209,9 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba, uint8_t expectRsp,
208 } 209 }
209 210
210 /* Save for completion so we can release these resources */ 211 /* Save for completion so we can release these resources */
211 elsiocb->context1 = (uint8_t *) ndlp; 212 elsiocb->context1 = lpfc_nlp_get(ndlp);
212 elsiocb->context2 = (uint8_t *) pcmd; 213 elsiocb->context2 = pcmd;
213 elsiocb->context3 = (uint8_t *) pbuflist; 214 elsiocb->context3 = pbuflist;
214 elsiocb->retry = retry; 215 elsiocb->retry = retry;
215 elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT; 216 elsiocb->drvrTimeout = (phba->fc_ratov << 1) + LPFC_DRVR_TIMEOUT;
216 217
@@ -222,16 +223,16 @@ lpfc_prep_els_iocb(struct lpfc_hba * phba, uint8_t expectRsp,
222 /* Xmit ELS command <elsCmd> to remote NPORT <did> */ 223 /* Xmit ELS command <elsCmd> to remote NPORT <did> */
223 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 224 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
224 "%d:0116 Xmit ELS command x%x to remote " 225 "%d:0116 Xmit ELS command x%x to remote "
225 "NPORT x%x Data: x%x x%x\n", 226 "NPORT x%x I/O tag: x%x, HBA state: x%x\n",
226 phba->brd_no, elscmd, 227 phba->brd_no, elscmd,
227 did, icmd->ulpIoTag, phba->hba_state); 228 did, elsiocb->iotag, phba->hba_state);
228 } else { 229 } else {
229 /* Xmit ELS response <elsCmd> to remote NPORT <did> */ 230 /* Xmit ELS response <elsCmd> to remote NPORT <did> */
230 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 231 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
231 "%d:0117 Xmit ELS response x%x to remote " 232 "%d:0117 Xmit ELS response x%x to remote "
232 "NPORT x%x Data: x%x x%x\n", 233 "NPORT x%x I/O tag: x%x, size: x%x\n",
233 phba->brd_no, elscmd, 234 phba->brd_no, elscmd,
234 ndlp->nlp_DID, icmd->ulpIoTag, cmdSize); 235 ndlp->nlp_DID, elsiocb->iotag, cmdSize);
235 } 236 }
236 237
237 return elsiocb; 238 return elsiocb;
@@ -304,7 +305,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
304 goto fail_free_mbox; 305 goto fail_free_mbox;
305 306
306 mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; 307 mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login;
307 mbox->context2 = ndlp; 308 mbox->context2 = lpfc_nlp_get(ndlp);
308 309
309 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB); 310 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
310 if (rc == MBX_NOT_FINISHED) 311 if (rc == MBX_NOT_FINISHED)
@@ -313,6 +314,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
313 return 0; 314 return 0;
314 315
315 fail_issue_reg_login: 316 fail_issue_reg_login:
317 lpfc_nlp_put(ndlp);
316 mp = (struct lpfc_dmabuf *) mbox->context1; 318 mp = (struct lpfc_dmabuf *) mbox->context1;
317 lpfc_mbuf_free(phba, mp->virt, mp->phys); 319 lpfc_mbuf_free(phba, mp->virt, mp->phys);
318 kfree(mp); 320 kfree(mp);
@@ -368,9 +370,9 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
368 mempool_free(mbox, phba->mbox_mem_pool); 370 mempool_free(mbox, phba->mbox_mem_pool);
369 goto fail; 371 goto fail;
370 } 372 }
371 mempool_free(ndlp, phba->nlp_mem_pool); 373 lpfc_nlp_put(ndlp);
372 374
373 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, PT2PT_RemoteID); 375 ndlp = lpfc_findnode_did(phba, PT2PT_RemoteID);
374 if (!ndlp) { 376 if (!ndlp) {
375 /* 377 /*
376 * Cannot find existing Fabric ndlp, so allocate a 378 * Cannot find existing Fabric ndlp, so allocate a
@@ -387,12 +389,11 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
387 sizeof(struct lpfc_name)); 389 sizeof(struct lpfc_name));
388 memcpy(&ndlp->nlp_nodename, &sp->nodeName, 390 memcpy(&ndlp->nlp_nodename, &sp->nodeName,
389 sizeof(struct lpfc_name)); 391 sizeof(struct lpfc_name));
390 ndlp->nlp_state = NLP_STE_NPR_NODE; 392 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
391 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
392 ndlp->nlp_flag |= NLP_NPR_2B_DISC; 393 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
393 } else { 394 } else {
394 /* This side will wait for the PLOGI */ 395 /* This side will wait for the PLOGI */
395 mempool_free( ndlp, phba->nlp_mem_pool); 396 lpfc_nlp_put(ndlp);
396 } 397 }
397 398
398 spin_lock_irq(phba->host->host_lock); 399 spin_lock_irq(phba->host->host_lock);
@@ -407,8 +408,8 @@ lpfc_cmpl_els_flogi_nport(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
407} 408}
408 409
409static void 410static void
410lpfc_cmpl_els_flogi(struct lpfc_hba * phba, 411lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
411 struct lpfc_iocbq * cmdiocb, struct lpfc_iocbq * rspiocb) 412 struct lpfc_iocbq *rspiocb)
412{ 413{
413 IOCB_t *irsp = &rspiocb->iocb; 414 IOCB_t *irsp = &rspiocb->iocb;
414 struct lpfc_nodelist *ndlp = cmdiocb->context1; 415 struct lpfc_nodelist *ndlp = cmdiocb->context1;
@@ -418,7 +419,7 @@ lpfc_cmpl_els_flogi(struct lpfc_hba * phba,
418 419
419 /* Check to see if link went down during discovery */ 420 /* Check to see if link went down during discovery */
420 if (lpfc_els_chk_latt(phba)) { 421 if (lpfc_els_chk_latt(phba)) {
421 lpfc_nlp_remove(phba, ndlp); 422 lpfc_nlp_put(ndlp);
422 goto out; 423 goto out;
423 } 424 }
424 425
@@ -433,13 +434,12 @@ lpfc_cmpl_els_flogi(struct lpfc_hba * phba,
433 phba->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 434 phba->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
434 spin_unlock_irq(phba->host->host_lock); 435 spin_unlock_irq(phba->host->host_lock);
435 436
436 /* If private loop, then allow max outstandting els to be 437 /* If private loop, then allow max outstanding els to be
437 * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no 438 * LPFC_MAX_DISC_THREADS (32). Scanning in the case of no
438 * alpa map would take too long otherwise. 439 * alpa map would take too long otherwise.
439 */ 440 */
440 if (phba->alpa_map[0] == 0) { 441 if (phba->alpa_map[0] == 0) {
441 phba->cfg_discovery_threads = 442 phba->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
442 LPFC_MAX_DISC_THREADS;
443 } 443 }
444 444
445 /* FLOGI failure */ 445 /* FLOGI failure */
@@ -484,7 +484,7 @@ lpfc_cmpl_els_flogi(struct lpfc_hba * phba,
484 } 484 }
485 485
486flogifail: 486flogifail:
487 lpfc_nlp_remove(phba, ndlp); 487 lpfc_nlp_put(ndlp);
488 488
489 if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT || 489 if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT ||
490 (irsp->un.ulpWord[4] != IOERR_SLI_ABORTED && 490 (irsp->un.ulpWord[4] != IOERR_SLI_ABORTED &&
@@ -582,24 +582,8 @@ lpfc_els_abort_flogi(struct lpfc_hba * phba)
582 icmd = &iocb->iocb; 582 icmd = &iocb->iocb;
583 if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) { 583 if (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) {
584 ndlp = (struct lpfc_nodelist *)(iocb->context1); 584 ndlp = (struct lpfc_nodelist *)(iocb->context1);
585 if (ndlp && (ndlp->nlp_DID == Fabric_DID)) { 585 if (ndlp && (ndlp->nlp_DID == Fabric_DID))
586 list_del(&iocb->list); 586 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
587 pring->txcmplq_cnt--;
588
589 if ((icmd->un.elsreq64.bdl.ulpIoTag32)) {
590 lpfc_sli_issue_abort_iotag32
591 (phba, pring, iocb);
592 }
593 if (iocb->iocb_cmpl) {
594 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
595 icmd->un.ulpWord[4] =
596 IOERR_SLI_ABORTED;
597 spin_unlock_irq(phba->host->host_lock);
598 (iocb->iocb_cmpl) (phba, iocb, iocb);
599 spin_lock_irq(phba->host->host_lock);
600 } else
601 lpfc_sli_release_iocbq(phba, iocb);
602 }
603 } 587 }
604 } 588 }
605 spin_unlock_irq(phba->host->host_lock); 589 spin_unlock_irq(phba->host->host_lock);
@@ -608,12 +592,12 @@ lpfc_els_abort_flogi(struct lpfc_hba * phba)
608} 592}
609 593
610int 594int
611lpfc_initial_flogi(struct lpfc_hba * phba) 595lpfc_initial_flogi(struct lpfc_hba *phba)
612{ 596{
613 struct lpfc_nodelist *ndlp; 597 struct lpfc_nodelist *ndlp;
614 598
615 /* First look for the Fabric ndlp */ 599 /* First look for the Fabric ndlp */
616 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, Fabric_DID); 600 ndlp = lpfc_findnode_did(phba, Fabric_DID);
617 if (!ndlp) { 601 if (!ndlp) {
618 /* Cannot find existing Fabric ndlp, so allocate a new one */ 602 /* Cannot find existing Fabric ndlp, so allocate a new one */
619 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); 603 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
@@ -621,10 +605,10 @@ lpfc_initial_flogi(struct lpfc_hba * phba)
621 return 0; 605 return 0;
622 lpfc_nlp_init(phba, ndlp, Fabric_DID); 606 lpfc_nlp_init(phba, ndlp, Fabric_DID);
623 } else { 607 } else {
624 lpfc_nlp_list(phba, ndlp, NLP_JUST_DQ); 608 lpfc_dequeue_node(phba, ndlp);
625 } 609 }
626 if (lpfc_issue_els_flogi(phba, ndlp, 0)) { 610 if (lpfc_issue_els_flogi(phba, ndlp, 0)) {
627 mempool_free( ndlp, phba->nlp_mem_pool); 611 lpfc_nlp_put(ndlp);
628 } 612 }
629 return 1; 613 return 1;
630} 614}
@@ -653,7 +637,7 @@ lpfc_more_plogi(struct lpfc_hba * phba)
653} 637}
654 638
655static struct lpfc_nodelist * 639static struct lpfc_nodelist *
656lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp, 640lpfc_plogi_confirm_nport(struct lpfc_hba *phba, struct lpfc_dmabuf *prsp,
657 struct lpfc_nodelist *ndlp) 641 struct lpfc_nodelist *ndlp)
658{ 642{
659 struct lpfc_nodelist *new_ndlp; 643 struct lpfc_nodelist *new_ndlp;
@@ -670,12 +654,12 @@ lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp,
670 654
671 lp = (uint32_t *) prsp->virt; 655 lp = (uint32_t *) prsp->virt;
672 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); 656 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
673 memset(name, 0, sizeof (struct lpfc_name)); 657 memset(name, 0, sizeof(struct lpfc_name));
674 658
675 /* Now we to find out if the NPort we are logging into, matches the WWPN 659 /* Now we find out if the NPort we are logging into, matches the WWPN
676 * we have for that ndlp. If not, we have some work to do. 660 * we have for that ndlp. If not, we have some work to do.
677 */ 661 */
678 new_ndlp = lpfc_findnode_wwpn(phba, NLP_SEARCH_ALL, &sp->portName); 662 new_ndlp = lpfc_findnode_wwpn(phba, &sp->portName);
679 663
680 if (new_ndlp == ndlp) 664 if (new_ndlp == ndlp)
681 return ndlp; 665 return ndlp;
@@ -695,18 +679,15 @@ lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp,
695 lpfc_unreg_rpi(phba, new_ndlp); 679 lpfc_unreg_rpi(phba, new_ndlp);
696 new_ndlp->nlp_DID = ndlp->nlp_DID; 680 new_ndlp->nlp_DID = ndlp->nlp_DID;
697 new_ndlp->nlp_prev_state = ndlp->nlp_prev_state; 681 new_ndlp->nlp_prev_state = ndlp->nlp_prev_state;
698 new_ndlp->nlp_state = ndlp->nlp_state; 682 lpfc_nlp_set_state(phba, new_ndlp, ndlp->nlp_state);
699 lpfc_nlp_list(phba, new_ndlp, ndlp->nlp_flag & NLP_LIST_MASK);
700 683
701 /* Move this back to NPR list */ 684 /* Move this back to NPR list */
702 if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0) { 685 if (memcmp(&ndlp->nlp_portname, name, sizeof(struct lpfc_name)) == 0)
703 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 686 lpfc_drop_node(phba, ndlp);
704 }
705 else { 687 else {
706 lpfc_unreg_rpi(phba, ndlp); 688 lpfc_unreg_rpi(phba, ndlp);
707 ndlp->nlp_DID = 0; /* Two ndlps cannot have the same did */ 689 ndlp->nlp_DID = 0; /* Two ndlps cannot have the same did */
708 ndlp->nlp_state = NLP_STE_NPR_NODE; 690 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
709 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
710 } 691 }
711 return new_ndlp; 692 return new_ndlp;
712} 693}
@@ -720,13 +701,11 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
720 struct lpfc_dmabuf *prsp; 701 struct lpfc_dmabuf *prsp;
721 int disc, rc, did, type; 702 int disc, rc, did, type;
722 703
723
724 /* we pass cmdiocb to state machine which needs rspiocb as well */ 704 /* we pass cmdiocb to state machine which needs rspiocb as well */
725 cmdiocb->context_un.rsp_iocb = rspiocb; 705 cmdiocb->context_un.rsp_iocb = rspiocb;
726 706
727 irsp = &rspiocb->iocb; 707 irsp = &rspiocb->iocb;
728 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, 708 ndlp = lpfc_findnode_did(phba, irsp->un.elsreq64.remoteID);
729 irsp->un.elsreq64.remoteID);
730 if (!ndlp) 709 if (!ndlp)
731 goto out; 710 goto out;
732 711
@@ -1354,7 +1333,7 @@ lpfc_issue_els_scr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1354 elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp, 1333 elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp,
1355 ndlp->nlp_DID, ELS_CMD_SCR); 1334 ndlp->nlp_DID, ELS_CMD_SCR);
1356 if (!elsiocb) { 1335 if (!elsiocb) {
1357 mempool_free( ndlp, phba->nlp_mem_pool); 1336 lpfc_nlp_put(ndlp);
1358 return 1; 1337 return 1;
1359 } 1338 }
1360 1339
@@ -1373,12 +1352,12 @@ lpfc_issue_els_scr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1373 spin_lock_irq(phba->host->host_lock); 1352 spin_lock_irq(phba->host->host_lock);
1374 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { 1353 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
1375 spin_unlock_irq(phba->host->host_lock); 1354 spin_unlock_irq(phba->host->host_lock);
1376 mempool_free( ndlp, phba->nlp_mem_pool); 1355 lpfc_nlp_put(ndlp);
1377 lpfc_els_free_iocb(phba, elsiocb); 1356 lpfc_els_free_iocb(phba, elsiocb);
1378 return 1; 1357 return 1;
1379 } 1358 }
1380 spin_unlock_irq(phba->host->host_lock); 1359 spin_unlock_irq(phba->host->host_lock);
1381 mempool_free( ndlp, phba->nlp_mem_pool); 1360 lpfc_nlp_put(ndlp);
1382 return 0; 1361 return 0;
1383} 1362}
1384 1363
@@ -1407,7 +1386,7 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1407 elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp, 1386 elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp,
1408 ndlp->nlp_DID, ELS_CMD_RNID); 1387 ndlp->nlp_DID, ELS_CMD_RNID);
1409 if (!elsiocb) { 1388 if (!elsiocb) {
1410 mempool_free( ndlp, phba->nlp_mem_pool); 1389 lpfc_nlp_put(ndlp);
1411 return 1; 1390 return 1;
1412 } 1391 }
1413 1392
@@ -1428,7 +1407,7 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1428 1407
1429 memcpy(&fp->RportName, &phba->fc_portname, sizeof (struct lpfc_name)); 1408 memcpy(&fp->RportName, &phba->fc_portname, sizeof (struct lpfc_name));
1430 memcpy(&fp->RnodeName, &phba->fc_nodename, sizeof (struct lpfc_name)); 1409 memcpy(&fp->RnodeName, &phba->fc_nodename, sizeof (struct lpfc_name));
1431 if ((ondlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, nportid))) { 1410 if ((ondlp = lpfc_findnode_did(phba, nportid))) {
1432 memcpy(&fp->OportName, &ondlp->nlp_portname, 1411 memcpy(&fp->OportName, &ondlp->nlp_portname,
1433 sizeof (struct lpfc_name)); 1412 sizeof (struct lpfc_name));
1434 memcpy(&fp->OnodeName, &ondlp->nlp_nodename, 1413 memcpy(&fp->OnodeName, &ondlp->nlp_nodename,
@@ -1440,12 +1419,12 @@ lpfc_issue_els_farpr(struct lpfc_hba * phba, uint32_t nportid, uint8_t retry)
1440 spin_lock_irq(phba->host->host_lock); 1419 spin_lock_irq(phba->host->host_lock);
1441 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { 1420 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
1442 spin_unlock_irq(phba->host->host_lock); 1421 spin_unlock_irq(phba->host->host_lock);
1443 mempool_free( ndlp, phba->nlp_mem_pool); 1422 lpfc_nlp_put(ndlp);
1444 lpfc_els_free_iocb(phba, elsiocb); 1423 lpfc_els_free_iocb(phba, elsiocb);
1445 return 1; 1424 return 1;
1446 } 1425 }
1447 spin_unlock_irq(phba->host->host_lock); 1426 spin_unlock_irq(phba->host->host_lock);
1448 mempool_free( ndlp, phba->nlp_mem_pool); 1427 lpfc_nlp_put(ndlp);
1449 return 0; 1428 return 0;
1450} 1429}
1451 1430
@@ -1554,29 +1533,25 @@ lpfc_els_retry_delay_handler(struct lpfc_nodelist *ndlp)
1554 case ELS_CMD_PLOGI: 1533 case ELS_CMD_PLOGI:
1555 if(!lpfc_issue_els_plogi(phba, ndlp->nlp_DID, retry)) { 1534 if(!lpfc_issue_els_plogi(phba, ndlp->nlp_DID, retry)) {
1556 ndlp->nlp_prev_state = ndlp->nlp_state; 1535 ndlp->nlp_prev_state = ndlp->nlp_state;
1557 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1536 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1558 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1559 } 1537 }
1560 break; 1538 break;
1561 case ELS_CMD_ADISC: 1539 case ELS_CMD_ADISC:
1562 if (!lpfc_issue_els_adisc(phba, ndlp, retry)) { 1540 if (!lpfc_issue_els_adisc(phba, ndlp, retry)) {
1563 ndlp->nlp_prev_state = ndlp->nlp_state; 1541 ndlp->nlp_prev_state = ndlp->nlp_state;
1564 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1542 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1565 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1566 } 1543 }
1567 break; 1544 break;
1568 case ELS_CMD_PRLI: 1545 case ELS_CMD_PRLI:
1569 if (!lpfc_issue_els_prli(phba, ndlp, retry)) { 1546 if (!lpfc_issue_els_prli(phba, ndlp, retry)) {
1570 ndlp->nlp_prev_state = ndlp->nlp_state; 1547 ndlp->nlp_prev_state = ndlp->nlp_state;
1571 ndlp->nlp_state = NLP_STE_PRLI_ISSUE; 1548 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PRLI_ISSUE);
1572 lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
1573 } 1549 }
1574 break; 1550 break;
1575 case ELS_CMD_LOGO: 1551 case ELS_CMD_LOGO:
1576 if (!lpfc_issue_els_logo(phba, ndlp, retry)) { 1552 if (!lpfc_issue_els_logo(phba, ndlp, retry)) {
1577 ndlp->nlp_prev_state = ndlp->nlp_state; 1553 ndlp->nlp_prev_state = ndlp->nlp_state;
1578 ndlp->nlp_state = NLP_STE_NPR_NODE; 1554 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1579 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1580 } 1555 }
1581 break; 1556 break;
1582 } 1557 }
@@ -1614,12 +1589,12 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1614 cmd = *elscmd++; 1589 cmd = *elscmd++;
1615 } 1590 }
1616 1591
1617 if(ndlp) 1592 if (ndlp)
1618 did = ndlp->nlp_DID; 1593 did = ndlp->nlp_DID;
1619 else { 1594 else {
1620 /* We should only hit this case for retrying PLOGI */ 1595 /* We should only hit this case for retrying PLOGI */
1621 did = irsp->un.elsreq64.remoteID; 1596 did = irsp->un.elsreq64.remoteID;
1622 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did); 1597 ndlp = lpfc_findnode_did(phba, did);
1623 if (!ndlp && (cmd != ELS_CMD_PLOGI)) 1598 if (!ndlp && (cmd != ELS_CMD_PLOGI))
1624 return 1; 1599 return 1;
1625 } 1600 }
@@ -1746,8 +1721,7 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1746 ndlp->nlp_flag |= NLP_DELAY_TMO; 1721 ndlp->nlp_flag |= NLP_DELAY_TMO;
1747 1722
1748 ndlp->nlp_prev_state = ndlp->nlp_state; 1723 ndlp->nlp_prev_state = ndlp->nlp_state;
1749 ndlp->nlp_state = NLP_STE_NPR_NODE; 1724 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1750 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1751 ndlp->nlp_last_elscmd = cmd; 1725 ndlp->nlp_last_elscmd = cmd;
1752 1726
1753 return 1; 1727 return 1;
@@ -1759,27 +1733,24 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1759 case ELS_CMD_PLOGI: 1733 case ELS_CMD_PLOGI:
1760 if (ndlp) { 1734 if (ndlp) {
1761 ndlp->nlp_prev_state = ndlp->nlp_state; 1735 ndlp->nlp_prev_state = ndlp->nlp_state;
1762 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1736 lpfc_nlp_set_state(phba, ndlp,
1763 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 1737 NLP_STE_PLOGI_ISSUE);
1764 } 1738 }
1765 lpfc_issue_els_plogi(phba, did, cmdiocb->retry); 1739 lpfc_issue_els_plogi(phba, did, cmdiocb->retry);
1766 return 1; 1740 return 1;
1767 case ELS_CMD_ADISC: 1741 case ELS_CMD_ADISC:
1768 ndlp->nlp_prev_state = ndlp->nlp_state; 1742 ndlp->nlp_prev_state = ndlp->nlp_state;
1769 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1743 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1770 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1771 lpfc_issue_els_adisc(phba, ndlp, cmdiocb->retry); 1744 lpfc_issue_els_adisc(phba, ndlp, cmdiocb->retry);
1772 return 1; 1745 return 1;
1773 case ELS_CMD_PRLI: 1746 case ELS_CMD_PRLI:
1774 ndlp->nlp_prev_state = ndlp->nlp_state; 1747 ndlp->nlp_prev_state = ndlp->nlp_state;
1775 ndlp->nlp_state = NLP_STE_PRLI_ISSUE; 1748 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PRLI_ISSUE);
1776 lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
1777 lpfc_issue_els_prli(phba, ndlp, cmdiocb->retry); 1749 lpfc_issue_els_prli(phba, ndlp, cmdiocb->retry);
1778 return 1; 1750 return 1;
1779 case ELS_CMD_LOGO: 1751 case ELS_CMD_LOGO:
1780 ndlp->nlp_prev_state = ndlp->nlp_state; 1752 ndlp->nlp_prev_state = ndlp->nlp_state;
1781 ndlp->nlp_state = NLP_STE_NPR_NODE; 1753 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1782 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1783 lpfc_issue_els_logo(phba, ndlp, cmdiocb->retry); 1754 lpfc_issue_els_logo(phba, ndlp, cmdiocb->retry);
1784 return 1; 1755 return 1;
1785 } 1756 }
@@ -1796,10 +1767,14 @@ lpfc_els_retry(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1796} 1767}
1797 1768
1798int 1769int
1799lpfc_els_free_iocb(struct lpfc_hba * phba, struct lpfc_iocbq * elsiocb) 1770lpfc_els_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *elsiocb)
1800{ 1771{
1801 struct lpfc_dmabuf *buf_ptr, *buf_ptr1; 1772 struct lpfc_dmabuf *buf_ptr, *buf_ptr1;
1802 1773
1774 if (elsiocb->context1) {
1775 lpfc_nlp_put(elsiocb->context1);
1776 elsiocb->context1 = NULL;
1777 }
1803 /* context2 = cmd, context2->next = rsp, context3 = bpl */ 1778 /* context2 = cmd, context2->next = rsp, context3 = bpl */
1804 if (elsiocb->context2) { 1779 if (elsiocb->context2) {
1805 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2; 1780 buf_ptr1 = (struct lpfc_dmabuf *) elsiocb->context2;
@@ -1843,7 +1818,7 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1843 1818
1844 switch (ndlp->nlp_state) { 1819 switch (ndlp->nlp_state) {
1845 case NLP_STE_UNUSED_NODE: /* node is just allocated */ 1820 case NLP_STE_UNUSED_NODE: /* node is just allocated */
1846 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1821 lpfc_drop_node(phba, ndlp);
1847 break; 1822 break;
1848 case NLP_STE_NPR_NODE: /* NPort Recovery mode */ 1823 case NLP_STE_NPR_NODE: /* NPort Recovery mode */
1849 lpfc_unreg_rpi(phba, ndlp); 1824 lpfc_unreg_rpi(phba, ndlp);
@@ -1856,8 +1831,8 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1856} 1831}
1857 1832
1858static void 1833static void
1859lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, 1834lpfc_cmpl_els_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1860 struct lpfc_iocbq * rspiocb) 1835 struct lpfc_iocbq *rspiocb)
1861{ 1836{
1862 IOCB_t *irsp; 1837 IOCB_t *irsp;
1863 struct lpfc_nodelist *ndlp; 1838 struct lpfc_nodelist *ndlp;
@@ -1872,14 +1847,14 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1872 1847
1873 1848
1874 /* Check to see if link went down during discovery */ 1849 /* Check to see if link went down during discovery */
1875 if ((lpfc_els_chk_latt(phba)) || !ndlp) { 1850 if (lpfc_els_chk_latt(phba) || !ndlp) {
1876 if (mbox) { 1851 if (mbox) {
1877 mp = (struct lpfc_dmabuf *) mbox->context1; 1852 mp = (struct lpfc_dmabuf *) mbox->context1;
1878 if (mp) { 1853 if (mp) {
1879 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1854 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1880 kfree(mp); 1855 kfree(mp);
1881 } 1856 }
1882 mempool_free( mbox, phba->mbox_mem_pool); 1857 mempool_free(mbox, phba->mbox_mem_pool);
1883 } 1858 }
1884 goto out; 1859 goto out;
1885 } 1860 }
@@ -1899,15 +1874,15 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1899 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { 1874 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) {
1900 lpfc_unreg_rpi(phba, ndlp); 1875 lpfc_unreg_rpi(phba, ndlp);
1901 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; 1876 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
1902 mbox->context2 = ndlp; 1877 mbox->context2 = lpfc_nlp_get(ndlp);
1903 ndlp->nlp_prev_state = ndlp->nlp_state; 1878 ndlp->nlp_prev_state = ndlp->nlp_state;
1904 ndlp->nlp_state = NLP_STE_REG_LOGIN_ISSUE; 1879 lpfc_nlp_set_state(phba, ndlp, NLP_STE_REG_LOGIN_ISSUE);
1905 lpfc_nlp_list(phba, ndlp, NLP_REGLOGIN_LIST);
1906 if (lpfc_sli_issue_mbox(phba, mbox, 1880 if (lpfc_sli_issue_mbox(phba, mbox,
1907 (MBX_NOWAIT | MBX_STOP_IOCB)) 1881 (MBX_NOWAIT | MBX_STOP_IOCB))
1908 != MBX_NOT_FINISHED) { 1882 != MBX_NOT_FINISHED) {
1909 goto out; 1883 goto out;
1910 } 1884 }
1885 lpfc_nlp_put(ndlp);
1911 /* NOTE: we should have messages for unsuccessful 1886 /* NOTE: we should have messages for unsuccessful
1912 reglogin */ 1887 reglogin */
1913 } else { 1888 } else {
@@ -1917,7 +1892,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1917 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || 1892 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) ||
1918 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN)))) { 1893 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN)))) {
1919 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) { 1894 if (ndlp->nlp_flag & NLP_ACC_REGLOGIN) {
1920 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1895 lpfc_drop_node(phba, ndlp);
1921 ndlp = NULL; 1896 ndlp = NULL;
1922 } 1897 }
1923 } 1898 }
@@ -2012,15 +1987,16 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag,
2012 return 1; 1987 return 1;
2013 } 1988 }
2014 1989
2015 if (newnode) 1990 if (newnode) {
1991 lpfc_nlp_put(ndlp);
2016 elsiocb->context1 = NULL; 1992 elsiocb->context1 = NULL;
1993 }
2017 1994
2018 /* Xmit ELS ACC response tag <ulpIoTag> */ 1995 /* Xmit ELS ACC response tag <ulpIoTag> */
2019 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1996 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2020 "%d:0128 Xmit ELS ACC response tag x%x " 1997 "%d:0128 Xmit ELS ACC response tag x%x, XRI: x%x, "
2021 "Data: x%x x%x x%x x%x x%x\n", 1998 "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x\n",
2022 phba->brd_no, 1999 phba->brd_no, elsiocb->iotag,
2023 elsiocb->iocb.ulpIoTag,
2024 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2000 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2025 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2001 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2026 2002
@@ -2077,10 +2053,9 @@ lpfc_els_rsp_reject(struct lpfc_hba * phba, uint32_t rejectError,
2077 2053
2078 /* Xmit ELS RJT <err> response tag <ulpIoTag> */ 2054 /* Xmit ELS RJT <err> response tag <ulpIoTag> */
2079 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2055 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2080 "%d:0129 Xmit ELS RJT x%x response tag x%x " 2056 "%d:0129 Xmit ELS RJT x%x response tag x%x xri x%x, "
2081 "Data: x%x x%x x%x x%x x%x\n", 2057 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
2082 phba->brd_no, 2058 phba->brd_no, rejectError, elsiocb->iotag,
2083 rejectError, elsiocb->iocb.ulpIoTag,
2084 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2059 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2085 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2060 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2086 2061
@@ -2119,18 +2094,18 @@ lpfc_els_rsp_adisc_acc(struct lpfc_hba * phba,
2119 if (!elsiocb) 2094 if (!elsiocb)
2120 return 1; 2095 return 1;
2121 2096
2097 icmd = &elsiocb->iocb;
2098 oldcmd = &oldiocb->iocb;
2099 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2100
2122 /* Xmit ADISC ACC response tag <ulpIoTag> */ 2101 /* Xmit ADISC ACC response tag <ulpIoTag> */
2123 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2102 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2124 "%d:0130 Xmit ADISC ACC response tag x%x " 2103 "%d:0130 Xmit ADISC ACC response iotag x%x xri: "
2125 "Data: x%x x%x x%x x%x x%x\n", 2104 "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n",
2126 phba->brd_no, 2105 phba->brd_no, elsiocb->iotag,
2127 elsiocb->iocb.ulpIoTag,
2128 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2106 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2129 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2107 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2130 2108
2131 icmd = &elsiocb->iocb;
2132 oldcmd = &oldiocb->iocb;
2133 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2134 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2109 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2135 2110
2136 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2111 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
@@ -2155,8 +2130,8 @@ lpfc_els_rsp_adisc_acc(struct lpfc_hba * phba,
2155} 2130}
2156 2131
2157int 2132int
2158lpfc_els_rsp_prli_acc(struct lpfc_hba * phba, 2133lpfc_els_rsp_prli_acc(struct lpfc_hba *phba, struct lpfc_iocbq *oldiocb,
2159 struct lpfc_iocbq * oldiocb, struct lpfc_nodelist * ndlp) 2134 struct lpfc_nodelist *ndlp)
2160{ 2135{
2161 PRLI *npr; 2136 PRLI *npr;
2162 lpfc_vpd_t *vpd; 2137 lpfc_vpd_t *vpd;
@@ -2178,18 +2153,18 @@ lpfc_els_rsp_prli_acc(struct lpfc_hba * phba,
2178 if (!elsiocb) 2153 if (!elsiocb)
2179 return 1; 2154 return 1;
2180 2155
2156 icmd = &elsiocb->iocb;
2157 oldcmd = &oldiocb->iocb;
2158 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2159
2181 /* Xmit PRLI ACC response tag <ulpIoTag> */ 2160 /* Xmit PRLI ACC response tag <ulpIoTag> */
2182 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2161 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2183 "%d:0131 Xmit PRLI ACC response tag x%x " 2162 "%d:0131 Xmit PRLI ACC response tag x%x xri x%x, "
2184 "Data: x%x x%x x%x x%x x%x\n", 2163 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
2185 phba->brd_no, 2164 phba->brd_no, elsiocb->iotag,
2186 elsiocb->iocb.ulpIoTag,
2187 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2165 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2188 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2166 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2189 2167
2190 icmd = &elsiocb->iocb;
2191 oldcmd = &oldiocb->iocb;
2192 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2193 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2168 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2194 2169
2195 *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); 2170 *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK));
@@ -2232,9 +2207,8 @@ lpfc_els_rsp_prli_acc(struct lpfc_hba * phba,
2232} 2207}
2233 2208
2234static int 2209static int
2235lpfc_els_rsp_rnid_acc(struct lpfc_hba * phba, 2210lpfc_els_rsp_rnid_acc(struct lpfc_hba *phba, uint8_t format,
2236 uint8_t format, 2211 struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp)
2237 struct lpfc_iocbq * oldiocb, struct lpfc_nodelist * ndlp)
2238{ 2212{
2239 RNID *rn; 2213 RNID *rn;
2240 IOCB_t *icmd; 2214 IOCB_t *icmd;
@@ -2259,17 +2233,17 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba * phba,
2259 if (!elsiocb) 2233 if (!elsiocb)
2260 return 1; 2234 return 1;
2261 2235
2236 icmd = &elsiocb->iocb;
2237 oldcmd = &oldiocb->iocb;
2238 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2239
2262 /* Xmit RNID ACC response tag <ulpIoTag> */ 2240 /* Xmit RNID ACC response tag <ulpIoTag> */
2263 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2241 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2264 "%d:0132 Xmit RNID ACC response tag x%x " 2242 "%d:0132 Xmit RNID ACC response tag x%x "
2265 "Data: x%x\n", 2243 "xri x%x\n",
2266 phba->brd_no, 2244 phba->brd_no, elsiocb->iotag,
2267 elsiocb->iocb.ulpIoTag,
2268 elsiocb->iocb.ulpContext); 2245 elsiocb->iocb.ulpContext);
2269 2246
2270 icmd = &elsiocb->iocb;
2271 oldcmd = &oldiocb->iocb;
2272 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2273 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2247 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2274 2248
2275 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2249 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
@@ -2301,6 +2275,7 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba * phba,
2301 2275
2302 phba->fc_stat.elsXmitACC++; 2276 phba->fc_stat.elsXmitACC++;
2303 elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2277 elsiocb->iocb_cmpl = lpfc_cmpl_els_acc;
2278 lpfc_nlp_put(ndlp);
2304 elsiocb->context1 = NULL; /* Don't need ndlp for cmpl, 2279 elsiocb->context1 = NULL; /* Don't need ndlp for cmpl,
2305 * it could be freed */ 2280 * it could be freed */
2306 2281
@@ -2315,32 +2290,31 @@ lpfc_els_rsp_rnid_acc(struct lpfc_hba * phba,
2315} 2290}
2316 2291
2317int 2292int
2318lpfc_els_disc_adisc(struct lpfc_hba * phba) 2293lpfc_els_disc_adisc(struct lpfc_hba *phba)
2319{ 2294{
2320 int sentadisc; 2295 int sentadisc;
2321 struct lpfc_nodelist *ndlp, *next_ndlp; 2296 struct lpfc_nodelist *ndlp, *next_ndlp;
2322 2297
2323 sentadisc = 0; 2298 sentadisc = 0;
2324 /* go thru NPR list and issue any remaining ELS ADISCs */ 2299 /* go thru NPR nodes and issue any remaining ELS ADISCs */
2325 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, 2300 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) {
2326 nlp_listp) { 2301 if (ndlp->nlp_state == NLP_STE_NPR_NODE &&
2327 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { 2302 (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 &&
2328 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 2303 (ndlp->nlp_flag & NLP_NPR_ADISC) != 0) {
2329 ndlp->nlp_flag &= ~NLP_NPR_ADISC; 2304 spin_lock_irq(phba->host->host_lock);
2330 ndlp->nlp_prev_state = ndlp->nlp_state; 2305 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
2331 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 2306 spin_unlock_irq(phba->host->host_lock);
2332 lpfc_nlp_list(phba, ndlp, 2307 ndlp->nlp_prev_state = ndlp->nlp_state;
2333 NLP_ADISC_LIST); 2308 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
2334 lpfc_issue_els_adisc(phba, ndlp, 0); 2309 lpfc_issue_els_adisc(phba, ndlp, 0);
2335 sentadisc++; 2310 sentadisc++;
2336 phba->num_disc_nodes++; 2311 phba->num_disc_nodes++;
2337 if (phba->num_disc_nodes >= 2312 if (phba->num_disc_nodes >=
2338 phba->cfg_discovery_threads) { 2313 phba->cfg_discovery_threads) {
2339 spin_lock_irq(phba->host->host_lock); 2314 spin_lock_irq(phba->host->host_lock);
2340 phba->fc_flag |= FC_NLP_MORE; 2315 phba->fc_flag |= FC_NLP_MORE;
2341 spin_unlock_irq(phba->host->host_lock); 2316 spin_unlock_irq(phba->host->host_lock);
2342 break; 2317 break;
2343 }
2344 } 2318 }
2345 } 2319 }
2346 } 2320 }
@@ -2360,24 +2334,22 @@ lpfc_els_disc_plogi(struct lpfc_hba * phba)
2360 2334
2361 sentplogi = 0; 2335 sentplogi = 0;
2362 /* go thru NPR list and issue any remaining ELS PLOGIs */ 2336 /* go thru NPR list and issue any remaining ELS PLOGIs */
2363 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, 2337 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) {
2364 nlp_listp) { 2338 if (ndlp->nlp_state == NLP_STE_NPR_NODE &&
2365 if ((ndlp->nlp_flag & NLP_NPR_2B_DISC) && 2339 (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 &&
2366 (!(ndlp->nlp_flag & NLP_DELAY_TMO))) { 2340 (ndlp->nlp_flag & NLP_DELAY_TMO) == 0 &&
2367 if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { 2341 (ndlp->nlp_flag & NLP_NPR_ADISC) == 0) {
2368 ndlp->nlp_prev_state = ndlp->nlp_state; 2342 ndlp->nlp_prev_state = ndlp->nlp_state;
2369 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 2343 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
2370 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 2344 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
2371 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 2345 sentplogi++;
2372 sentplogi++; 2346 phba->num_disc_nodes++;
2373 phba->num_disc_nodes++; 2347 if (phba->num_disc_nodes >=
2374 if (phba->num_disc_nodes >= 2348 phba->cfg_discovery_threads) {
2375 phba->cfg_discovery_threads) { 2349 spin_lock_irq(phba->host->host_lock);
2376 spin_lock_irq(phba->host->host_lock); 2350 phba->fc_flag |= FC_NLP_MORE;
2377 phba->fc_flag |= FC_NLP_MORE; 2351 spin_unlock_irq(phba->host->host_lock);
2378 spin_unlock_irq(phba->host->host_lock); 2352 break;
2379 break;
2380 }
2381 } 2353 }
2382 } 2354 }
2383 } 2355 }
@@ -2479,42 +2451,30 @@ lpfc_rscn_payload_check(struct lpfc_hba * phba, uint32_t did)
2479} 2451}
2480 2452
2481static int 2453static int
2482lpfc_rscn_recovery_check(struct lpfc_hba * phba) 2454lpfc_rscn_recovery_check(struct lpfc_hba *phba)
2483{ 2455{
2484 struct lpfc_nodelist *ndlp = NULL, *next_ndlp; 2456 struct lpfc_nodelist *ndlp = NULL;
2485 struct list_head *listp;
2486 struct list_head *node_list[7];
2487 int i;
2488 2457
2489 /* Look at all nodes effected by pending RSCNs and move 2458 /* Look at all nodes effected by pending RSCNs and move
2490 * them to NPR list. 2459 * them to NPR state.
2491 */ 2460 */
2492 node_list[0] = &phba->fc_npr_list; /* MUST do this list first */
2493 node_list[1] = &phba->fc_nlpmap_list;
2494 node_list[2] = &phba->fc_nlpunmap_list;
2495 node_list[3] = &phba->fc_prli_list;
2496 node_list[4] = &phba->fc_reglogin_list;
2497 node_list[5] = &phba->fc_adisc_list;
2498 node_list[6] = &phba->fc_plogi_list;
2499 for (i = 0; i < 7; i++) {
2500 listp = node_list[i];
2501 if (list_empty(listp))
2502 continue;
2503 2461
2504 list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) { 2462 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
2505 if (!(lpfc_rscn_payload_check(phba, ndlp->nlp_DID))) 2463 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE ||
2506 continue; 2464 lpfc_rscn_payload_check(phba, ndlp->nlp_DID) == 0)
2465 continue;
2507 2466
2508 lpfc_disc_state_machine(phba, ndlp, NULL, 2467 lpfc_disc_state_machine(phba, ndlp, NULL,
2509 NLP_EVT_DEVICE_RECOVERY); 2468 NLP_EVT_DEVICE_RECOVERY);
2510 2469
2511 /* Make sure NLP_DELAY_TMO is NOT running 2470 /*
2512 * after a device recovery event. 2471 * Make sure NLP_DELAY_TMO is NOT running after a device
2513 */ 2472 * recovery event.
2514 if (ndlp->nlp_flag & NLP_DELAY_TMO) 2473 */
2515 lpfc_cancel_retry_delay_tmo(phba, ndlp); 2474 if (ndlp->nlp_flag & NLP_DELAY_TMO)
2516 } 2475 lpfc_cancel_retry_delay_tmo(phba, ndlp);
2517 } 2476 }
2477
2518 return 0; 2478 return 0;
2519} 2479}
2520 2480
@@ -2639,8 +2599,8 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2639 2599
2640 /* To process RSCN, first compare RSCN data with NameServer */ 2600 /* To process RSCN, first compare RSCN data with NameServer */
2641 phba->fc_ns_retry = 0; 2601 phba->fc_ns_retry = 0;
2642 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, NameServer_DID); 2602 ndlp = lpfc_findnode_did(phba, NameServer_DID);
2643 if (ndlp) { 2603 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
2644 /* Good ndlp, issue CT Request to NameServer */ 2604 /* Good ndlp, issue CT Request to NameServer */
2645 if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 0) { 2605 if (lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT) == 0) {
2646 /* Wait for NameServer query cmpl before we can 2606 /* Wait for NameServer query cmpl before we can
@@ -2650,7 +2610,7 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2650 } else { 2610 } else {
2651 /* If login to NameServer does not exist, issue one */ 2611 /* If login to NameServer does not exist, issue one */
2652 /* Good status, issue PLOGI to NameServer */ 2612 /* Good status, issue PLOGI to NameServer */
2653 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID); 2613 ndlp = lpfc_findnode_did(phba, NameServer_DID);
2654 if (ndlp) { 2614 if (ndlp) {
2655 /* Wait for NameServer login cmpl before we can 2615 /* Wait for NameServer login cmpl before we can
2656 continue */ 2616 continue */
@@ -2664,8 +2624,7 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2664 lpfc_nlp_init(phba, ndlp, NameServer_DID); 2624 lpfc_nlp_init(phba, ndlp, NameServer_DID);
2665 ndlp->nlp_type |= NLP_FABRIC; 2625 ndlp->nlp_type |= NLP_FABRIC;
2666 ndlp->nlp_prev_state = ndlp->nlp_state; 2626 ndlp->nlp_prev_state = ndlp->nlp_state;
2667 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 2627 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
2668 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
2669 lpfc_issue_els_plogi(phba, NameServer_DID, 0); 2628 lpfc_issue_els_plogi(phba, NameServer_DID, 0);
2670 /* Wait for NameServer login cmpl before we can 2629 /* Wait for NameServer login cmpl before we can
2671 continue */ 2630 continue */
@@ -2734,8 +2693,9 @@ lpfc_els_rcv_flogi(struct lpfc_hba * phba,
2734 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 2693 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
2735 rc = lpfc_sli_issue_mbox 2694 rc = lpfc_sli_issue_mbox
2736 (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB)); 2695 (phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
2696 lpfc_set_loopback_flag(phba);
2737 if (rc == MBX_NOT_FINISHED) { 2697 if (rc == MBX_NOT_FINISHED) {
2738 mempool_free( mbox, phba->mbox_mem_pool); 2698 mempool_free(mbox, phba->mbox_mem_pool);
2739 } 2699 }
2740 return 1; 2700 return 1;
2741 } else if (rc > 0) { /* greater than */ 2701 } else if (rc > 0) { /* greater than */
@@ -2800,8 +2760,8 @@ lpfc_els_rcv_rnid(struct lpfc_hba * phba,
2800} 2760}
2801 2761
2802static int 2762static int
2803lpfc_els_rcv_lirr(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, 2763lpfc_els_rcv_lirr(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2804 struct lpfc_nodelist * ndlp) 2764 struct lpfc_nodelist *ndlp)
2805{ 2765{
2806 struct ls_rjt stat; 2766 struct ls_rjt stat;
2807 2767
@@ -2815,7 +2775,7 @@ lpfc_els_rcv_lirr(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
2815} 2775}
2816 2776
2817static void 2777static void
2818lpfc_els_rsp_rps_acc(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) 2778lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2819{ 2779{
2820 struct lpfc_sli *psli; 2780 struct lpfc_sli *psli;
2821 struct lpfc_sli_ring *pring; 2781 struct lpfc_sli_ring *pring;
@@ -2838,14 +2798,15 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
2838 pmb->context2 = NULL; 2798 pmb->context2 = NULL;
2839 2799
2840 if (mb->mbxStatus) { 2800 if (mb->mbxStatus) {
2841 mempool_free( pmb, phba->mbox_mem_pool); 2801 mempool_free(pmb, phba->mbox_mem_pool);
2842 return; 2802 return;
2843 } 2803 }
2844 2804
2845 cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t); 2805 cmdsize = sizeof(RPS_RSP) + sizeof(uint32_t);
2846 mempool_free( pmb, phba->mbox_mem_pool); 2806 mempool_free(pmb, phba->mbox_mem_pool);
2847 elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, lpfc_max_els_tries, ndlp, 2807 elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, lpfc_max_els_tries, ndlp,
2848 ndlp->nlp_DID, ELS_CMD_ACC); 2808 ndlp->nlp_DID, ELS_CMD_ACC);
2809 lpfc_nlp_put(ndlp);
2849 if (!elsiocb) 2810 if (!elsiocb)
2850 return; 2811 return;
2851 2812
@@ -2875,15 +2836,15 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
2875 2836
2876 /* Xmit ELS RPS ACC response tag <ulpIoTag> */ 2837 /* Xmit ELS RPS ACC response tag <ulpIoTag> */
2877 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2838 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2878 "%d:0118 Xmit ELS RPS ACC response tag x%x " 2839 "%d:0118 Xmit ELS RPS ACC response tag x%x xri x%x, "
2879 "Data: x%x x%x x%x x%x x%x\n", 2840 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
2880 phba->brd_no, 2841 phba->brd_no, elsiocb->iotag,
2881 elsiocb->iocb.ulpIoTag,
2882 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2842 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2883 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2843 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2884 2844
2885 elsiocb->iocb_cmpl = lpfc_cmpl_els_acc; 2845 elsiocb->iocb_cmpl = lpfc_cmpl_els_acc;
2886 phba->fc_stat.elsXmitACC++; 2846 phba->fc_stat.elsXmitACC++;
2847
2887 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { 2848 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
2888 lpfc_els_free_iocb(phba, elsiocb); 2849 lpfc_els_free_iocb(phba, elsiocb);
2889 } 2850 }
@@ -2923,13 +2884,14 @@ lpfc_els_rcv_rps(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
2923 lpfc_read_lnk_stat(phba, mbox); 2884 lpfc_read_lnk_stat(phba, mbox);
2924 mbox->context1 = 2885 mbox->context1 =
2925 (void *)((unsigned long)cmdiocb->iocb.ulpContext); 2886 (void *)((unsigned long)cmdiocb->iocb.ulpContext);
2926 mbox->context2 = ndlp; 2887 mbox->context2 = lpfc_nlp_get(ndlp);
2927 mbox->mbox_cmpl = lpfc_els_rsp_rps_acc; 2888 mbox->mbox_cmpl = lpfc_els_rsp_rps_acc;
2928 if (lpfc_sli_issue_mbox (phba, mbox, 2889 if (lpfc_sli_issue_mbox (phba, mbox,
2929 (MBX_NOWAIT | MBX_STOP_IOCB)) != MBX_NOT_FINISHED) { 2890 (MBX_NOWAIT | MBX_STOP_IOCB)) != MBX_NOT_FINISHED) {
2930 /* Mbox completion will send ELS Response */ 2891 /* Mbox completion will send ELS Response */
2931 return 0; 2892 return 0;
2932 } 2893 }
2894 lpfc_nlp_put(ndlp);
2933 mempool_free(mbox, phba->mbox_mem_pool); 2895 mempool_free(mbox, phba->mbox_mem_pool);
2934 } 2896 }
2935 } 2897 }
@@ -2984,10 +2946,9 @@ lpfc_els_rsp_rpl_acc(struct lpfc_hba * phba, uint16_t cmdsize,
2984 2946
2985 /* Xmit ELS RPL ACC response tag <ulpIoTag> */ 2947 /* Xmit ELS RPL ACC response tag <ulpIoTag> */
2986 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2948 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
2987 "%d:0120 Xmit ELS RPL ACC response tag x%x " 2949 "%d:0120 Xmit ELS RPL ACC response tag x%x xri x%x, "
2988 "Data: x%x x%x x%x x%x x%x\n", 2950 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
2989 phba->brd_no, 2951 phba->brd_no, elsiocb->iotag,
2990 elsiocb->iocb.ulpIoTag,
2991 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2952 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2992 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2953 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2993 2954
@@ -3091,8 +3052,8 @@ lpfc_els_rcv_farp(struct lpfc_hba * phba,
3091 /* Log back into the node before sending the FARP. */ 3052 /* Log back into the node before sending the FARP. */
3092 if (fp->Rflags & FARP_REQUEST_PLOGI) { 3053 if (fp->Rflags & FARP_REQUEST_PLOGI) {
3093 ndlp->nlp_prev_state = ndlp->nlp_state; 3054 ndlp->nlp_prev_state = ndlp->nlp_state;
3094 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 3055 lpfc_nlp_set_state(phba, ndlp,
3095 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST); 3056 NLP_STE_PLOGI_ISSUE);
3096 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 3057 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
3097 } 3058 }
3098 3059
@@ -3169,14 +3130,15 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
3169 */ 3130 */
3170 3131
3171 list_for_each_entry_safe(ndlp, next_ndlp, 3132 list_for_each_entry_safe(ndlp, next_ndlp,
3172 &phba->fc_npr_list, nlp_listp) { 3133 &phba->fc_nodes, nlp_listp) {
3173 3134 if (ndlp->nlp_state != NLP_STE_NPR_NODE)
3135 continue;
3174 if (ndlp->nlp_type & NLP_FABRIC) { 3136 if (ndlp->nlp_type & NLP_FABRIC) {
3175 /* 3137 /*
3176 * Clean up old Fabric, Nameserver and 3138 * Clean up old Fabric, Nameserver and
3177 * other NLP_FABRIC logins 3139 * other NLP_FABRIC logins
3178 */ 3140 */
3179 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3141 lpfc_drop_node(phba, ndlp);
3180 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { 3142 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
3181 /* Fail outstanding I/O now since this 3143 /* Fail outstanding I/O now since this
3182 * device is marked for PLOGI 3144 * device is marked for PLOGI
@@ -3193,20 +3155,22 @@ lpfc_els_rcv_fan(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
3193 /* Discovery not needed, 3155 /* Discovery not needed,
3194 * move the nodes to their original state. 3156 * move the nodes to their original state.
3195 */ 3157 */
3196 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, 3158 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes,
3197 nlp_listp) { 3159 nlp_listp) {
3160 if (ndlp->nlp_state != NLP_STE_NPR_NODE)
3161 continue;
3198 3162
3199 switch (ndlp->nlp_prev_state) { 3163 switch (ndlp->nlp_prev_state) {
3200 case NLP_STE_UNMAPPED_NODE: 3164 case NLP_STE_UNMAPPED_NODE:
3201 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 3165 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
3202 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 3166 lpfc_nlp_set_state(phba, ndlp,
3203 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); 3167 NLP_STE_UNMAPPED_NODE);
3204 break; 3168 break;
3205 3169
3206 case NLP_STE_MAPPED_NODE: 3170 case NLP_STE_MAPPED_NODE:
3207 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 3171 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
3208 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 3172 lpfc_nlp_set_state(phba, ndlp,
3209 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST); 3173 NLP_STE_MAPPED_NODE);
3210 break; 3174 break;
3211 3175
3212 default: 3176 default:
@@ -3246,9 +3210,8 @@ lpfc_els_timeout_handler(struct lpfc_hba *phba)
3246 struct lpfc_iocbq *tmp_iocb, *piocb; 3210 struct lpfc_iocbq *tmp_iocb, *piocb;
3247 IOCB_t *cmd = NULL; 3211 IOCB_t *cmd = NULL;
3248 struct lpfc_dmabuf *pcmd; 3212 struct lpfc_dmabuf *pcmd;
3249 struct list_head *dlp;
3250 uint32_t *elscmd; 3213 uint32_t *elscmd;
3251 uint32_t els_command; 3214 uint32_t els_command=0;
3252 uint32_t timeout; 3215 uint32_t timeout;
3253 uint32_t remote_ID; 3216 uint32_t remote_ID;
3254 3217
@@ -3263,17 +3226,20 @@ lpfc_els_timeout_handler(struct lpfc_hba *phba)
3263 timeout = (uint32_t)(phba->fc_ratov << 1); 3226 timeout = (uint32_t)(phba->fc_ratov << 1);
3264 3227
3265 pring = &phba->sli.ring[LPFC_ELS_RING]; 3228 pring = &phba->sli.ring[LPFC_ELS_RING];
3266 dlp = &pring->txcmplq;
3267 3229
3268 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { 3230 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) {
3269 cmd = &piocb->iocb; 3231 cmd = &piocb->iocb;
3270 3232
3271 if (piocb->iocb_flag & LPFC_IO_LIBDFC) { 3233 if ((piocb->iocb_flag & LPFC_IO_LIBDFC) ||
3234 (piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN) ||
3235 (piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN)) {
3272 continue; 3236 continue;
3273 } 3237 }
3274 pcmd = (struct lpfc_dmabuf *) piocb->context2; 3238 pcmd = (struct lpfc_dmabuf *) piocb->context2;
3275 elscmd = (uint32_t *) (pcmd->virt); 3239 if (pcmd) {
3276 els_command = *elscmd; 3240 elscmd = (uint32_t *) (pcmd->virt);
3241 els_command = *elscmd;
3242 }
3277 3243
3278 if ((els_command == ELS_CMD_FARP) 3244 if ((els_command == ELS_CMD_FARP)
3279 || (els_command == ELS_CMD_FARPR)) { 3245 || (els_command == ELS_CMD_FARPR)) {
@@ -3289,19 +3255,10 @@ lpfc_els_timeout_handler(struct lpfc_hba *phba)
3289 continue; 3255 continue;
3290 } 3256 }
3291 3257
3292 list_del(&piocb->list);
3293 pring->txcmplq_cnt--;
3294
3295 if (cmd->ulpCommand == CMD_GEN_REQUEST64_CR) { 3258 if (cmd->ulpCommand == CMD_GEN_REQUEST64_CR) {
3296 struct lpfc_nodelist *ndlp; 3259 struct lpfc_nodelist *ndlp;
3297 spin_unlock_irq(phba->host->host_lock); 3260 ndlp = __lpfc_findnode_rpi(phba, cmd->ulpContext);
3298 ndlp = lpfc_findnode_rpi(phba, cmd->ulpContext);
3299 spin_lock_irq(phba->host->host_lock);
3300 remote_ID = ndlp->nlp_DID; 3261 remote_ID = ndlp->nlp_DID;
3301 if (cmd->un.elsreq64.bdl.ulpIoTag32) {
3302 lpfc_sli_issue_abort_iotag32(phba,
3303 pring, piocb);
3304 }
3305 } else { 3262 } else {
3306 remote_ID = cmd->un.elsreq64.remoteID; 3263 remote_ID = cmd->un.elsreq64.remoteID;
3307 } 3264 }
@@ -3313,17 +3270,7 @@ lpfc_els_timeout_handler(struct lpfc_hba *phba)
3313 phba->brd_no, els_command, 3270 phba->brd_no, els_command,
3314 remote_ID, cmd->ulpCommand, cmd->ulpIoTag); 3271 remote_ID, cmd->ulpCommand, cmd->ulpIoTag);
3315 3272
3316 /* 3273 lpfc_sli_issue_abort_iotag(phba, pring, piocb);
3317 * The iocb has timed out; abort it.
3318 */
3319 if (piocb->iocb_cmpl) {
3320 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
3321 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
3322 spin_unlock_irq(phba->host->host_lock);
3323 (piocb->iocb_cmpl) (phba, piocb, piocb);
3324 spin_lock_irq(phba->host->host_lock);
3325 } else
3326 lpfc_sli_release_iocbq(phba, piocb);
3327 } 3274 }
3328 if (phba->sli.ring[LPFC_ELS_RING].txcmplq_cnt) 3275 if (phba->sli.ring[LPFC_ELS_RING].txcmplq_cnt)
3329 mod_timer(&phba->els_tmofunc, jiffies + HZ * timeout); 3276 mod_timer(&phba->els_tmofunc, jiffies + HZ * timeout);
@@ -3332,16 +3279,13 @@ lpfc_els_timeout_handler(struct lpfc_hba *phba)
3332} 3279}
3333 3280
3334void 3281void
3335lpfc_els_flush_cmd(struct lpfc_hba * phba) 3282lpfc_els_flush_cmd(struct lpfc_hba *phba)
3336{ 3283{
3337 struct lpfc_sli_ring *pring; 3284 LIST_HEAD(completions);
3285 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
3338 struct lpfc_iocbq *tmp_iocb, *piocb; 3286 struct lpfc_iocbq *tmp_iocb, *piocb;
3339 IOCB_t *cmd = NULL; 3287 IOCB_t *cmd = NULL;
3340 struct lpfc_dmabuf *pcmd;
3341 uint32_t *elscmd;
3342 uint32_t els_command;
3343 3288
3344 pring = &phba->sli.ring[LPFC_ELS_RING];
3345 spin_lock_irq(phba->host->host_lock); 3289 spin_lock_irq(phba->host->host_lock);
3346 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) { 3290 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) {
3347 cmd = &piocb->iocb; 3291 cmd = &piocb->iocb;
@@ -3351,29 +3295,15 @@ lpfc_els_flush_cmd(struct lpfc_hba * phba)
3351 } 3295 }
3352 3296
3353 /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */ 3297 /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */
3354 if ((cmd->ulpCommand == CMD_QUE_RING_BUF_CN) || 3298 if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN ||
3355 (cmd->ulpCommand == CMD_QUE_RING_BUF64_CN) || 3299 cmd->ulpCommand == CMD_QUE_RING_BUF64_CN ||
3356 (cmd->ulpCommand == CMD_CLOSE_XRI_CN) || 3300 cmd->ulpCommand == CMD_CLOSE_XRI_CN ||
3357 (cmd->ulpCommand == CMD_ABORT_XRI_CN)) { 3301 cmd->ulpCommand == CMD_ABORT_XRI_CN)
3358 continue; 3302 continue;
3359 }
3360 3303
3361 pcmd = (struct lpfc_dmabuf *) piocb->context2; 3304 list_move_tail(&piocb->list, &completions);
3362 elscmd = (uint32_t *) (pcmd->virt); 3305 pring->txq_cnt--;
3363 els_command = *elscmd;
3364 3306
3365 list_del(&piocb->list);
3366 pring->txcmplq_cnt--;
3367
3368 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
3369 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
3370
3371 if (piocb->iocb_cmpl) {
3372 spin_unlock_irq(phba->host->host_lock);
3373 (piocb->iocb_cmpl) (phba, piocb, piocb);
3374 spin_lock_irq(phba->host->host_lock);
3375 } else
3376 lpfc_sli_release_iocbq(phba, piocb);
3377 } 3307 }
3378 3308
3379 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) { 3309 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) {
@@ -3382,24 +3312,24 @@ lpfc_els_flush_cmd(struct lpfc_hba * phba)
3382 if (piocb->iocb_flag & LPFC_IO_LIBDFC) { 3312 if (piocb->iocb_flag & LPFC_IO_LIBDFC) {
3383 continue; 3313 continue;
3384 } 3314 }
3385 pcmd = (struct lpfc_dmabuf *) piocb->context2;
3386 elscmd = (uint32_t *) (pcmd->virt);
3387 els_command = *elscmd;
3388 3315
3389 list_del(&piocb->list); 3316 lpfc_sli_issue_abort_iotag(phba, pring, piocb);
3390 pring->txcmplq_cnt--; 3317 }
3318 spin_unlock_irq(phba->host->host_lock);
3391 3319
3392 cmd->ulpStatus = IOSTAT_LOCAL_REJECT; 3320 while(!list_empty(&completions)) {
3393 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; 3321 piocb = list_get_first(&completions, struct lpfc_iocbq, list);
3322 cmd = &piocb->iocb;
3323 list_del(&piocb->list);
3394 3324
3395 if (piocb->iocb_cmpl) { 3325 if (piocb->iocb_cmpl) {
3396 spin_unlock_irq(phba->host->host_lock); 3326 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
3327 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
3397 (piocb->iocb_cmpl) (phba, piocb, piocb); 3328 (piocb->iocb_cmpl) (phba, piocb, piocb);
3398 spin_lock_irq(phba->host->host_lock);
3399 } else 3329 } else
3400 lpfc_sli_release_iocbq(phba, piocb); 3330 lpfc_sli_release_iocbq(phba, piocb);
3401 } 3331 }
3402 spin_unlock_irq(phba->host->host_lock); 3332
3403 return; 3333 return;
3404} 3334}
3405 3335
@@ -3468,7 +3398,7 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3468 } 3398 }
3469 3399
3470 did = icmd->un.rcvels.remoteID; 3400 did = icmd->un.rcvels.remoteID;
3471 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did); 3401 ndlp = lpfc_findnode_did(phba, did);
3472 if (!ndlp) { 3402 if (!ndlp) {
3473 /* Cannot find existing Fabric ndlp, so allocate a new one */ 3403 /* Cannot find existing Fabric ndlp, so allocate a new one */
3474 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL); 3404 ndlp = mempool_alloc(phba->nlp_mem_pool, GFP_KERNEL);
@@ -3484,12 +3414,13 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3484 if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) { 3414 if ((did & Fabric_DID_MASK) == Fabric_DID_MASK) {
3485 ndlp->nlp_type |= NLP_FABRIC; 3415 ndlp->nlp_type |= NLP_FABRIC;
3486 } 3416 }
3487 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 3417 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
3488 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
3489 } 3418 }
3490 3419
3491 phba->fc_stat.elsRcvFrame++; 3420 phba->fc_stat.elsRcvFrame++;
3492 elsiocb->context1 = ndlp; 3421 if (elsiocb->context1)
3422 lpfc_nlp_put(elsiocb->context1);
3423 elsiocb->context1 = lpfc_nlp_get(ndlp);
3493 elsiocb->context2 = mp; 3424 elsiocb->context2 = mp;
3494 3425
3495 if ((cmd & ELS_CMD_MASK) == ELS_CMD_RSCN) { 3426 if ((cmd & ELS_CMD_MASK) == ELS_CMD_RSCN) {
@@ -3513,9 +3444,8 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3513 case ELS_CMD_FLOGI: 3444 case ELS_CMD_FLOGI:
3514 phba->fc_stat.elsRcvFLOGI++; 3445 phba->fc_stat.elsRcvFLOGI++;
3515 lpfc_els_rcv_flogi(phba, elsiocb, ndlp, newnode); 3446 lpfc_els_rcv_flogi(phba, elsiocb, ndlp, newnode);
3516 if (newnode) { 3447 if (newnode)
3517 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3448 lpfc_drop_node(phba, ndlp);
3518 }
3519 break; 3449 break;
3520 case ELS_CMD_LOGO: 3450 case ELS_CMD_LOGO:
3521 phba->fc_stat.elsRcvLOGO++; 3451 phba->fc_stat.elsRcvLOGO++;
@@ -3536,9 +3466,8 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3536 case ELS_CMD_RSCN: 3466 case ELS_CMD_RSCN:
3537 phba->fc_stat.elsRcvRSCN++; 3467 phba->fc_stat.elsRcvRSCN++;
3538 lpfc_els_rcv_rscn(phba, elsiocb, ndlp, newnode); 3468 lpfc_els_rcv_rscn(phba, elsiocb, ndlp, newnode);
3539 if (newnode) { 3469 if (newnode)
3540 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3470 lpfc_drop_node(phba, ndlp);
3541 }
3542 break; 3471 break;
3543 case ELS_CMD_ADISC: 3472 case ELS_CMD_ADISC:
3544 phba->fc_stat.elsRcvADISC++; 3473 phba->fc_stat.elsRcvADISC++;
@@ -3579,30 +3508,26 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3579 case ELS_CMD_LIRR: 3508 case ELS_CMD_LIRR:
3580 phba->fc_stat.elsRcvLIRR++; 3509 phba->fc_stat.elsRcvLIRR++;
3581 lpfc_els_rcv_lirr(phba, elsiocb, ndlp); 3510 lpfc_els_rcv_lirr(phba, elsiocb, ndlp);
3582 if (newnode) { 3511 if (newnode)
3583 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3512 lpfc_drop_node(phba, ndlp);
3584 }
3585 break; 3513 break;
3586 case ELS_CMD_RPS: 3514 case ELS_CMD_RPS:
3587 phba->fc_stat.elsRcvRPS++; 3515 phba->fc_stat.elsRcvRPS++;
3588 lpfc_els_rcv_rps(phba, elsiocb, ndlp); 3516 lpfc_els_rcv_rps(phba, elsiocb, ndlp);
3589 if (newnode) { 3517 if (newnode)
3590 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3518 lpfc_drop_node(phba, ndlp);
3591 }
3592 break; 3519 break;
3593 case ELS_CMD_RPL: 3520 case ELS_CMD_RPL:
3594 phba->fc_stat.elsRcvRPL++; 3521 phba->fc_stat.elsRcvRPL++;
3595 lpfc_els_rcv_rpl(phba, elsiocb, ndlp); 3522 lpfc_els_rcv_rpl(phba, elsiocb, ndlp);
3596 if (newnode) { 3523 if (newnode)
3597 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3524 lpfc_drop_node(phba, ndlp);
3598 }
3599 break; 3525 break;
3600 case ELS_CMD_RNID: 3526 case ELS_CMD_RNID:
3601 phba->fc_stat.elsRcvRNID++; 3527 phba->fc_stat.elsRcvRNID++;
3602 lpfc_els_rcv_rnid(phba, elsiocb, ndlp); 3528 lpfc_els_rcv_rnid(phba, elsiocb, ndlp);
3603 if (newnode) { 3529 if (newnode)
3604 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3530 lpfc_drop_node(phba, ndlp);
3605 }
3606 break; 3531 break;
3607 default: 3532 default:
3608 /* Unsupported ELS command, reject */ 3533 /* Unsupported ELS command, reject */
@@ -3612,9 +3537,8 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3612 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3537 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
3613 "%d:0115 Unknown ELS command x%x received from " 3538 "%d:0115 Unknown ELS command x%x received from "
3614 "NPORT x%x\n", phba->brd_no, cmd, did); 3539 "NPORT x%x\n", phba->brd_no, cmd, did);
3615 if (newnode) { 3540 if (newnode)
3616 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 3541 lpfc_drop_node(phba, ndlp);
3617 }
3618 break; 3542 break;
3619 } 3543 }
3620 3544
@@ -3627,6 +3551,8 @@ lpfc_els_unsol_event(struct lpfc_hba * phba,
3627 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, elsiocb, ndlp); 3551 lpfc_els_rsp_reject(phba, stat.un.lsRjtError, elsiocb, ndlp);
3628 } 3552 }
3629 3553
3554 lpfc_nlp_put(elsiocb->context1);
3555 elsiocb->context1 = NULL;
3630 if (elsiocb->context2) { 3556 if (elsiocb->context2) {
3631 lpfc_mbuf_free(phba, mp->virt, mp->phys); 3557 lpfc_mbuf_free(phba, mp->virt, mp->phys);
3632 kfree(mp); 3558 kfree(mp);
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index c39564e85e94..61caa8d379e2 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -109,6 +109,9 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)
109 return; 109 return;
110 } 110 }
111 111
112 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE)
113 return;
114
112 name = (uint8_t *)&ndlp->nlp_portname; 115 name = (uint8_t *)&ndlp->nlp_portname;
113 phba = ndlp->nlp_phba; 116 phba = ndlp->nlp_phba;
114 117
@@ -147,11 +150,17 @@ lpfc_dev_loss_tmo_callbk(struct fc_rport *rport)
147 ndlp->nlp_state, ndlp->nlp_rpi); 150 ndlp->nlp_state, ndlp->nlp_rpi);
148 } 151 }
149 152
150 ndlp->rport = NULL; 153 if (!(phba->fc_flag & FC_UNLOADING) &&
151 rdata->pnode = NULL; 154 !(ndlp->nlp_flag & NLP_DELAY_TMO) &&
152 155 !(ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
153 if (!(phba->fc_flag & FC_UNLOADING)) 156 (ndlp->nlp_state != NLP_STE_UNMAPPED_NODE))
154 lpfc_disc_state_machine(phba, ndlp, NULL, NLP_EVT_DEVICE_RM); 157 lpfc_disc_state_machine(phba, ndlp, NULL, NLP_EVT_DEVICE_RM);
158 else {
159 rdata->pnode = NULL;
160 ndlp->rport = NULL;
161 lpfc_nlp_put(ndlp);
162 put_device(&rport->dev);
163 }
155 164
156 return; 165 return;
157} 166}
@@ -182,29 +191,35 @@ lpfc_work_list_done(struct lpfc_hba * phba)
182 *(int *)(evtp->evt_arg1) = 0; 191 *(int *)(evtp->evt_arg1) = 0;
183 complete((struct completion *)(evtp->evt_arg2)); 192 complete((struct completion *)(evtp->evt_arg2));
184 break; 193 break;
185 case LPFC_EVT_OFFLINE: 194 case LPFC_EVT_OFFLINE_PREP:
186 if (phba->hba_state >= LPFC_LINK_DOWN) 195 if (phba->hba_state >= LPFC_LINK_DOWN)
187 lpfc_offline(phba); 196 lpfc_offline_prep(phba);
197 *(int *)(evtp->evt_arg1) = 0;
198 complete((struct completion *)(evtp->evt_arg2));
199 break;
200 case LPFC_EVT_OFFLINE:
201 lpfc_offline(phba);
188 lpfc_sli_brdrestart(phba); 202 lpfc_sli_brdrestart(phba);
189 *(int *)(evtp->evt_arg1) = 203 *(int *)(evtp->evt_arg1) =
190 lpfc_sli_brdready(phba,HS_FFRDY | HS_MBRDY); 204 lpfc_sli_brdready(phba, HS_FFRDY | HS_MBRDY);
205 lpfc_unblock_mgmt_io(phba);
191 complete((struct completion *)(evtp->evt_arg2)); 206 complete((struct completion *)(evtp->evt_arg2));
192 break; 207 break;
193 case LPFC_EVT_WARM_START: 208 case LPFC_EVT_WARM_START:
194 if (phba->hba_state >= LPFC_LINK_DOWN) 209 lpfc_offline(phba);
195 lpfc_offline(phba);
196 lpfc_reset_barrier(phba); 210 lpfc_reset_barrier(phba);
197 lpfc_sli_brdreset(phba); 211 lpfc_sli_brdreset(phba);
198 lpfc_hba_down_post(phba); 212 lpfc_hba_down_post(phba);
199 *(int *)(evtp->evt_arg1) = 213 *(int *)(evtp->evt_arg1) =
200 lpfc_sli_brdready(phba, HS_MBRDY); 214 lpfc_sli_brdready(phba, HS_MBRDY);
215 lpfc_unblock_mgmt_io(phba);
201 complete((struct completion *)(evtp->evt_arg2)); 216 complete((struct completion *)(evtp->evt_arg2));
202 break; 217 break;
203 case LPFC_EVT_KILL: 218 case LPFC_EVT_KILL:
204 if (phba->hba_state >= LPFC_LINK_DOWN) 219 lpfc_offline(phba);
205 lpfc_offline(phba);
206 *(int *)(evtp->evt_arg1) 220 *(int *)(evtp->evt_arg1)
207 = (phba->stopped) ? 0 : lpfc_sli_brdkill(phba); 221 = (phba->stopped) ? 0 : lpfc_sli_brdkill(phba);
222 lpfc_unblock_mgmt_io(phba);
208 complete((struct completion *)(evtp->evt_arg2)); 223 complete((struct completion *)(evtp->evt_arg2));
209 break; 224 break;
210 } 225 }
@@ -359,13 +374,12 @@ lpfc_workq_post_event(struct lpfc_hba * phba, void *arg1, void *arg2,
359} 374}
360 375
361int 376int
362lpfc_linkdown(struct lpfc_hba * phba) 377lpfc_linkdown(struct lpfc_hba *phba)
363{ 378{
364 struct lpfc_sli *psli; 379 struct lpfc_sli *psli;
365 struct lpfc_nodelist *ndlp, *next_ndlp; 380 struct lpfc_nodelist *ndlp, *next_ndlp;
366 struct list_head *listp, *node_list[7]; 381 LPFC_MBOXQ_t *mb;
367 LPFC_MBOXQ_t *mb; 382 int rc;
368 int rc, i;
369 383
370 psli = &phba->sli; 384 psli = &phba->sli;
371 /* sysfs or selective reset may call this routine to clean up */ 385 /* sysfs or selective reset may call this routine to clean up */
@@ -397,31 +411,16 @@ lpfc_linkdown(struct lpfc_hba * phba)
397 /* Cleanup any outstanding ELS commands */ 411 /* Cleanup any outstanding ELS commands */
398 lpfc_els_flush_cmd(phba); 412 lpfc_els_flush_cmd(phba);
399 413
400 /* Issue a LINK DOWN event to all nodes */ 414 /*
401 node_list[0] = &phba->fc_npr_list; /* MUST do this list first */ 415 * Issue a LINK DOWN event to all nodes.
402 node_list[1] = &phba->fc_nlpmap_list; 416 */
403 node_list[2] = &phba->fc_nlpunmap_list; 417 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) {
404 node_list[3] = &phba->fc_prli_list; 418 /* free any ndlp's on unused list */
405 node_list[4] = &phba->fc_reglogin_list; 419 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
406 node_list[5] = &phba->fc_adisc_list; 420 lpfc_drop_node(phba, ndlp);
407 node_list[6] = &phba->fc_plogi_list; 421 else /* otherwise, force node recovery. */
408 for (i = 0; i < 7; i++) {
409 listp = node_list[i];
410 if (list_empty(listp))
411 continue;
412
413 list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) {
414
415 rc = lpfc_disc_state_machine(phba, ndlp, NULL, 422 rc = lpfc_disc_state_machine(phba, ndlp, NULL,
416 NLP_EVT_DEVICE_RECOVERY); 423 NLP_EVT_DEVICE_RECOVERY);
417
418 }
419 }
420
421 /* free any ndlp's on unused list */
422 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list,
423 nlp_listp) {
424 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
425 } 424 }
426 425
427 /* Setup myDID for link up if we are in pt2pt mode */ 426 /* Setup myDID for link up if we are in pt2pt mode */
@@ -452,11 +451,9 @@ lpfc_linkdown(struct lpfc_hba * phba)
452} 451}
453 452
454static int 453static int
455lpfc_linkup(struct lpfc_hba * phba) 454lpfc_linkup(struct lpfc_hba *phba)
456{ 455{
457 struct lpfc_nodelist *ndlp, *next_ndlp; 456 struct lpfc_nodelist *ndlp, *next_ndlp;
458 struct list_head *listp, *node_list[7];
459 int i;
460 457
461 fc_host_post_event(phba->host, fc_get_event_number(), 458 fc_host_post_event(phba->host, fc_get_event_number(),
462 FCH_EVT_LINKUP, 0); 459 FCH_EVT_LINKUP, 0);
@@ -470,29 +467,20 @@ lpfc_linkup(struct lpfc_hba * phba)
470 spin_unlock_irq(phba->host->host_lock); 467 spin_unlock_irq(phba->host->host_lock);
471 468
472 469
473 node_list[0] = &phba->fc_plogi_list; 470 if (phba->fc_flag & FC_LBIT) {
474 node_list[1] = &phba->fc_adisc_list; 471 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
475 node_list[2] = &phba->fc_reglogin_list; 472 if (ndlp->nlp_state != NLP_STE_UNUSED_NODE) {
476 node_list[3] = &phba->fc_prli_list;
477 node_list[4] = &phba->fc_nlpunmap_list;
478 node_list[5] = &phba->fc_nlpmap_list;
479 node_list[6] = &phba->fc_npr_list;
480 for (i = 0; i < 7; i++) {
481 listp = node_list[i];
482 if (list_empty(listp))
483 continue;
484
485 list_for_each_entry_safe(ndlp, next_ndlp, listp, nlp_listp) {
486 if (phba->fc_flag & FC_LBIT) {
487 if (ndlp->nlp_type & NLP_FABRIC) { 473 if (ndlp->nlp_type & NLP_FABRIC) {
488 /* On Linkup its safe to clean up the 474 /*
475 * On Linkup its safe to clean up the
489 * ndlp from Fabric connections. 476 * ndlp from Fabric connections.
490 */ 477 */
491 lpfc_nlp_list(phba, ndlp, 478 lpfc_nlp_set_state(phba, ndlp,
492 NLP_UNUSED_LIST); 479 NLP_STE_UNUSED_NODE);
493 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { 480 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
494 /* Fail outstanding IO now since device 481 /*
495 * is marked for PLOGI. 482 * Fail outstanding IO now since
483 * device is marked for PLOGI.
496 */ 484 */
497 lpfc_unreg_rpi(phba, ndlp); 485 lpfc_unreg_rpi(phba, ndlp);
498 } 486 }
@@ -501,9 +489,10 @@ lpfc_linkup(struct lpfc_hba * phba)
501 } 489 }
502 490
503 /* free any ndlp's on unused list */ 491 /* free any ndlp's on unused list */
504 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list, 492 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes,
505 nlp_listp) { 493 nlp_listp) {
506 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 494 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
495 lpfc_drop_node(phba, ndlp);
507 } 496 }
508 497
509 return 0; 498 return 0;
@@ -734,6 +723,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
734 case LA_4GHZ_LINK: 723 case LA_4GHZ_LINK:
735 phba->fc_linkspeed = LA_4GHZ_LINK; 724 phba->fc_linkspeed = LA_4GHZ_LINK;
736 break; 725 break;
726 case LA_8GHZ_LINK:
727 phba->fc_linkspeed = LA_8GHZ_LINK;
728 break;
737 default: 729 default:
738 phba->fc_linkspeed = LA_UNKNW_LINK; 730 phba->fc_linkspeed = LA_UNKNW_LINK;
739 break; 731 break;
@@ -889,12 +881,21 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
889 881
890 if (la->attType == AT_LINK_UP) { 882 if (la->attType == AT_LINK_UP) {
891 phba->fc_stat.LinkUp++; 883 phba->fc_stat.LinkUp++;
892 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 884 if (phba->fc_flag & FC_LOOPBACK_MODE) {
885 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
886 "%d:1306 Link Up Event in loop back mode "
887 "x%x received Data: x%x x%x x%x x%x\n",
888 phba->brd_no, la->eventTag, phba->fc_eventTag,
889 la->granted_AL_PA, la->UlnkSpeed,
890 phba->alpa_map[0]);
891 } else {
892 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
893 "%d:1303 Link Up Event x%x received " 893 "%d:1303 Link Up Event x%x received "
894 "Data: x%x x%x x%x x%x\n", 894 "Data: x%x x%x x%x x%x\n",
895 phba->brd_no, la->eventTag, phba->fc_eventTag, 895 phba->brd_no, la->eventTag, phba->fc_eventTag,
896 la->granted_AL_PA, la->UlnkSpeed, 896 la->granted_AL_PA, la->UlnkSpeed,
897 phba->alpa_map[0]); 897 phba->alpa_map[0]);
898 }
898 lpfc_mbx_process_link_up(phba, la); 899 lpfc_mbx_process_link_up(phba, la);
899 } else { 900 } else {
900 phba->fc_stat.LinkDown++; 901 phba->fc_stat.LinkDown++;
@@ -940,6 +941,7 @@ lpfc_mbx_cmpl_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
940 lpfc_mbuf_free(phba, mp->virt, mp->phys); 941 lpfc_mbuf_free(phba, mp->virt, mp->phys);
941 kfree(mp); 942 kfree(mp);
942 mempool_free( pmb, phba->mbox_mem_pool); 943 mempool_free( pmb, phba->mbox_mem_pool);
944 lpfc_nlp_put(ndlp);
943 945
944 return; 946 return;
945} 947}
@@ -966,11 +968,14 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
966 ndlp = (struct lpfc_nodelist *) pmb->context2; 968 ndlp = (struct lpfc_nodelist *) pmb->context2;
967 mp = (struct lpfc_dmabuf *) (pmb->context1); 969 mp = (struct lpfc_dmabuf *) (pmb->context1);
968 970
971 pmb->context1 = NULL;
972 pmb->context2 = NULL;
973
969 if (mb->mbxStatus) { 974 if (mb->mbxStatus) {
970 lpfc_mbuf_free(phba, mp->virt, mp->phys); 975 lpfc_mbuf_free(phba, mp->virt, mp->phys);
971 kfree(mp); 976 kfree(mp);
972 mempool_free( pmb, phba->mbox_mem_pool); 977 mempool_free(pmb, phba->mbox_mem_pool);
973 mempool_free( ndlp, phba->nlp_mem_pool); 978 lpfc_nlp_put(ndlp);
974 979
975 /* FLOGI failed, so just use loop map to make discovery list */ 980 /* FLOGI failed, so just use loop map to make discovery list */
976 lpfc_disc_list_loopmap(phba); 981 lpfc_disc_list_loopmap(phba);
@@ -980,12 +985,11 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
980 return; 985 return;
981 } 986 }
982 987
983 pmb->context1 = NULL;
984
985 ndlp->nlp_rpi = mb->un.varWords[0]; 988 ndlp->nlp_rpi = mb->un.varWords[0];
986 ndlp->nlp_type |= NLP_FABRIC; 989 ndlp->nlp_type |= NLP_FABRIC;
987 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 990 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
988 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST); 991
992 lpfc_nlp_put(ndlp); /* Drop the reference from the mbox */
989 993
990 if (phba->hba_state == LPFC_FABRIC_CFG_LINK) { 994 if (phba->hba_state == LPFC_FABRIC_CFG_LINK) {
991 /* This NPort has been assigned an NPort_ID by the fabric as a 995 /* This NPort has been assigned an NPort_ID by the fabric as a
@@ -996,7 +1000,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
996 */ 1000 */
997 lpfc_issue_els_scr(phba, SCR_DID, 0); 1001 lpfc_issue_els_scr(phba, SCR_DID, 0);
998 1002
999 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID); 1003 ndlp = lpfc_findnode_did(phba, NameServer_DID);
1000 if (!ndlp) { 1004 if (!ndlp) {
1001 /* Allocate a new node instance. If the pool is empty, 1005 /* Allocate a new node instance. If the pool is empty,
1002 * start the discovery process and skip the Nameserver 1006 * start the discovery process and skip the Nameserver
@@ -1008,15 +1012,14 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1008 lpfc_disc_start(phba); 1012 lpfc_disc_start(phba);
1009 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1013 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1010 kfree(mp); 1014 kfree(mp);
1011 mempool_free( pmb, phba->mbox_mem_pool); 1015 mempool_free(pmb, phba->mbox_mem_pool);
1012 return; 1016 return;
1013 } else { 1017 } else {
1014 lpfc_nlp_init(phba, ndlp, NameServer_DID); 1018 lpfc_nlp_init(phba, ndlp, NameServer_DID);
1015 ndlp->nlp_type |= NLP_FABRIC; 1019 ndlp->nlp_type |= NLP_FABRIC;
1016 } 1020 }
1017 } 1021 }
1018 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1022 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1019 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1020 lpfc_issue_els_plogi(phba, NameServer_DID, 0); 1023 lpfc_issue_els_plogi(phba, NameServer_DID, 0);
1021 if (phba->cfg_fdmi_on) { 1024 if (phba->cfg_fdmi_on) {
1022 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, 1025 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool,
@@ -1032,7 +1035,7 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1032 1035
1033 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1036 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1034 kfree(mp); 1037 kfree(mp);
1035 mempool_free( pmb, phba->mbox_mem_pool); 1038 mempool_free(pmb, phba->mbox_mem_pool);
1036 return; 1039 return;
1037} 1040}
1038 1041
@@ -1057,10 +1060,11 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1057 mp = (struct lpfc_dmabuf *) (pmb->context1); 1060 mp = (struct lpfc_dmabuf *) (pmb->context1);
1058 1061
1059 if (mb->mbxStatus) { 1062 if (mb->mbxStatus) {
1063 lpfc_nlp_put(ndlp);
1060 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1064 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1061 kfree(mp); 1065 kfree(mp);
1062 mempool_free( pmb, phba->mbox_mem_pool); 1066 mempool_free(pmb, phba->mbox_mem_pool);
1063 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1067 lpfc_drop_node(phba, ndlp);
1064 1068
1065 /* RegLogin failed, so just use loop map to make discovery 1069 /* RegLogin failed, so just use loop map to make discovery
1066 list */ 1070 list */
@@ -1075,8 +1079,7 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1075 1079
1076 ndlp->nlp_rpi = mb->un.varWords[0]; 1080 ndlp->nlp_rpi = mb->un.varWords[0];
1077 ndlp->nlp_type |= NLP_FABRIC; 1081 ndlp->nlp_type |= NLP_FABRIC;
1078 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1082 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1079 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1080 1083
1081 if (phba->hba_state < LPFC_HBA_READY) { 1084 if (phba->hba_state < LPFC_HBA_READY) {
1082 /* Link up discovery requires Fabrib registration. */ 1085 /* Link up discovery requires Fabrib registration. */
@@ -1093,6 +1096,7 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1093 lpfc_disc_start(phba); 1096 lpfc_disc_start(phba);
1094 } 1097 }
1095 1098
1099 lpfc_nlp_put(ndlp);
1096 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1100 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1097 kfree(mp); 1101 kfree(mp);
1098 mempool_free( pmb, phba->mbox_mem_pool); 1102 mempool_free( pmb, phba->mbox_mem_pool);
@@ -1101,8 +1105,7 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1101} 1105}
1102 1106
1103static void 1107static void
1104lpfc_register_remote_port(struct lpfc_hba * phba, 1108lpfc_register_remote_port(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
1105 struct lpfc_nodelist * ndlp)
1106{ 1109{
1107 struct fc_rport *rport; 1110 struct fc_rport *rport;
1108 struct lpfc_rport_data *rdata; 1111 struct lpfc_rport_data *rdata;
@@ -1114,8 +1117,19 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1114 rport_ids.port_id = ndlp->nlp_DID; 1117 rport_ids.port_id = ndlp->nlp_DID;
1115 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 1118 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
1116 1119
1120 /*
1121 * We leave our node pointer in rport->dd_data when we unregister a
1122 * FCP target port. But fc_remote_port_add zeros the space to which
1123 * rport->dd_data points. So, if we're reusing a previously
1124 * registered port, drop the reference that we took the last time we
1125 * registered the port.
1126 */
1127 if (ndlp->rport && ndlp->rport->dd_data &&
1128 *(struct lpfc_rport_data **) ndlp->rport->dd_data) {
1129 lpfc_nlp_put(ndlp);
1130 }
1117 ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids); 1131 ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids);
1118 if (!rport) { 1132 if (!rport || !get_device(&rport->dev)) {
1119 dev_printk(KERN_WARNING, &phba->pcidev->dev, 1133 dev_printk(KERN_WARNING, &phba->pcidev->dev,
1120 "Warning: fc_remote_port_add failed\n"); 1134 "Warning: fc_remote_port_add failed\n");
1121 return; 1135 return;
@@ -1125,7 +1139,7 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1125 rport->maxframe_size = ndlp->nlp_maxframe; 1139 rport->maxframe_size = ndlp->nlp_maxframe;
1126 rport->supported_classes = ndlp->nlp_class_sup; 1140 rport->supported_classes = ndlp->nlp_class_sup;
1127 rdata = rport->dd_data; 1141 rdata = rport->dd_data;
1128 rdata->pnode = ndlp; 1142 rdata->pnode = lpfc_nlp_get(ndlp);
1129 1143
1130 if (ndlp->nlp_type & NLP_FCP_TARGET) 1144 if (ndlp->nlp_type & NLP_FCP_TARGET)
1131 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; 1145 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
@@ -1145,8 +1159,7 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1145} 1159}
1146 1160
1147static void 1161static void
1148lpfc_unregister_remote_port(struct lpfc_hba * phba, 1162lpfc_unregister_remote_port(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
1149 struct lpfc_nodelist * ndlp)
1150{ 1163{
1151 struct fc_rport *rport = ndlp->rport; 1164 struct fc_rport *rport = ndlp->rport;
1152 struct lpfc_rport_data *rdata = rport->dd_data; 1165 struct lpfc_rport_data *rdata = rport->dd_data;
@@ -1154,6 +1167,8 @@ lpfc_unregister_remote_port(struct lpfc_hba * phba,
1154 if (rport->scsi_target_id == -1) { 1167 if (rport->scsi_target_id == -1) {
1155 ndlp->rport = NULL; 1168 ndlp->rport = NULL;
1156 rdata->pnode = NULL; 1169 rdata->pnode = NULL;
1170 lpfc_nlp_put(ndlp);
1171 put_device(&rport->dev);
1157 } 1172 }
1158 1173
1159 fc_remote_port_delete(rport); 1174 fc_remote_port_delete(rport);
@@ -1161,178 +1176,70 @@ lpfc_unregister_remote_port(struct lpfc_hba * phba,
1161 return; 1176 return;
1162} 1177}
1163 1178
1164int 1179static void
1165lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) 1180lpfc_nlp_counters(struct lpfc_hba *phba, int state, int count)
1166{ 1181{
1167 enum { none, unmapped, mapped } rport_add = none, rport_del = none;
1168 struct lpfc_sli *psli;
1169
1170 psli = &phba->sli;
1171 /* Sanity check to ensure we are not moving to / from the same list */
1172 if ((nlp->nlp_flag & NLP_LIST_MASK) == list)
1173 if (list != NLP_NO_LIST)
1174 return 0;
1175
1176 spin_lock_irq(phba->host->host_lock); 1182 spin_lock_irq(phba->host->host_lock);
1177 switch (nlp->nlp_flag & NLP_LIST_MASK) { 1183 switch (state) {
1178 case NLP_NO_LIST: /* Not on any list */ 1184 case NLP_STE_UNUSED_NODE:
1185 phba->fc_unused_cnt += count;
1179 break; 1186 break;
1180 case NLP_UNUSED_LIST: 1187 case NLP_STE_PLOGI_ISSUE:
1181 phba->fc_unused_cnt--; 1188 phba->fc_plogi_cnt += count;
1182 list_del(&nlp->nlp_listp);
1183 break; 1189 break;
1184 case NLP_PLOGI_LIST: 1190 case NLP_STE_ADISC_ISSUE:
1185 phba->fc_plogi_cnt--; 1191 phba->fc_adisc_cnt += count;
1186 list_del(&nlp->nlp_listp);
1187 break; 1192 break;
1188 case NLP_ADISC_LIST: 1193 case NLP_STE_REG_LOGIN_ISSUE:
1189 phba->fc_adisc_cnt--; 1194 phba->fc_reglogin_cnt += count;
1190 list_del(&nlp->nlp_listp);
1191 break; 1195 break;
1192 case NLP_REGLOGIN_LIST: 1196 case NLP_STE_PRLI_ISSUE:
1193 phba->fc_reglogin_cnt--; 1197 phba->fc_prli_cnt += count;
1194 list_del(&nlp->nlp_listp);
1195 break; 1198 break;
1196 case NLP_PRLI_LIST: 1199 case NLP_STE_UNMAPPED_NODE:
1197 phba->fc_prli_cnt--; 1200 phba->fc_unmap_cnt += count;
1198 list_del(&nlp->nlp_listp);
1199 break; 1201 break;
1200 case NLP_UNMAPPED_LIST: 1202 case NLP_STE_MAPPED_NODE:
1201 phba->fc_unmap_cnt--; 1203 phba->fc_map_cnt += count;
1202 list_del(&nlp->nlp_listp);
1203 nlp->nlp_flag &= ~NLP_TGT_NO_SCSIID;
1204 nlp->nlp_type &= ~NLP_FC_NODE;
1205 phba->nport_event_cnt++;
1206 if (nlp->rport)
1207 rport_del = unmapped;
1208 break; 1204 break;
1209 case NLP_MAPPED_LIST: 1205 case NLP_STE_NPR_NODE:
1210 phba->fc_map_cnt--; 1206 phba->fc_npr_cnt += count;
1211 list_del(&nlp->nlp_listp);
1212 phba->nport_event_cnt++;
1213 if (nlp->rport)
1214 rport_del = mapped;
1215 break;
1216 case NLP_NPR_LIST:
1217 phba->fc_npr_cnt--;
1218 list_del(&nlp->nlp_listp);
1219 /* Stop delay tmo if taking node off NPR list */
1220 if ((nlp->nlp_flag & NLP_DELAY_TMO) &&
1221 (list != NLP_NPR_LIST)) {
1222 spin_unlock_irq(phba->host->host_lock);
1223 lpfc_cancel_retry_delay_tmo(phba, nlp);
1224 spin_lock_irq(phba->host->host_lock);
1225 }
1226 break; 1207 break;
1227 } 1208 }
1209 spin_unlock_irq(phba->host->host_lock);
1210}
1228 1211
1229 nlp->nlp_flag &= ~NLP_LIST_MASK; 1212static void
1230 1213lpfc_nlp_state_cleanup(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
1231 /* Add NPort <did> to <num> list */ 1214 int old_state, int new_state)
1232 lpfc_printf_log(phba, 1215{
1233 KERN_INFO, 1216 if (new_state == NLP_STE_UNMAPPED_NODE) {
1234 LOG_NODE, 1217 ndlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
1235 "%d:0904 Add NPort x%x to %d list Data: x%x\n", 1218 ndlp->nlp_flag &= ~NLP_NODEV_REMOVE;
1236 phba->brd_no, 1219 ndlp->nlp_type |= NLP_FC_NODE;
1237 nlp->nlp_DID, list, nlp->nlp_flag); 1220 }
1238 1221 if (new_state == NLP_STE_MAPPED_NODE)
1239 switch (list) { 1222 ndlp->nlp_flag &= ~NLP_NODEV_REMOVE;
1240 case NLP_NO_LIST: /* No list, just remove it */ 1223 if (new_state == NLP_STE_NPR_NODE)
1241 spin_unlock_irq(phba->host->host_lock); 1224 ndlp->nlp_flag &= ~NLP_RCV_PLOGI;
1242 lpfc_nlp_remove(phba, nlp); 1225
1243 spin_lock_irq(phba->host->host_lock); 1226 /* Transport interface */
1244 /* as node removed - stop further transport calls */ 1227 if (ndlp->rport && (old_state == NLP_STE_MAPPED_NODE ||
1245 rport_del = none; 1228 old_state == NLP_STE_UNMAPPED_NODE)) {
1246 break;
1247 case NLP_UNUSED_LIST:
1248 nlp->nlp_flag |= list;
1249 /* Put it at the end of the unused list */
1250 list_add_tail(&nlp->nlp_listp, &phba->fc_unused_list);
1251 phba->fc_unused_cnt++;
1252 break;
1253 case NLP_PLOGI_LIST:
1254 nlp->nlp_flag |= list;
1255 /* Put it at the end of the plogi list */
1256 list_add_tail(&nlp->nlp_listp, &phba->fc_plogi_list);
1257 phba->fc_plogi_cnt++;
1258 break;
1259 case NLP_ADISC_LIST:
1260 nlp->nlp_flag |= list;
1261 /* Put it at the end of the adisc list */
1262 list_add_tail(&nlp->nlp_listp, &phba->fc_adisc_list);
1263 phba->fc_adisc_cnt++;
1264 break;
1265 case NLP_REGLOGIN_LIST:
1266 nlp->nlp_flag |= list;
1267 /* Put it at the end of the reglogin list */
1268 list_add_tail(&nlp->nlp_listp, &phba->fc_reglogin_list);
1269 phba->fc_reglogin_cnt++;
1270 break;
1271 case NLP_PRLI_LIST:
1272 nlp->nlp_flag |= list;
1273 /* Put it at the end of the prli list */
1274 list_add_tail(&nlp->nlp_listp, &phba->fc_prli_list);
1275 phba->fc_prli_cnt++;
1276 break;
1277 case NLP_UNMAPPED_LIST:
1278 rport_add = unmapped;
1279 /* ensure all vestiges of "mapped" significance are gone */
1280 nlp->nlp_type &= ~(NLP_FCP_TARGET | NLP_FCP_INITIATOR);
1281 nlp->nlp_flag |= list;
1282 /* Put it at the end of the unmap list */
1283 list_add_tail(&nlp->nlp_listp, &phba->fc_nlpunmap_list);
1284 phba->fc_unmap_cnt++;
1285 phba->nport_event_cnt++;
1286 nlp->nlp_flag &= ~NLP_NODEV_REMOVE;
1287 nlp->nlp_type |= NLP_FC_NODE;
1288 break;
1289 case NLP_MAPPED_LIST:
1290 rport_add = mapped;
1291 nlp->nlp_flag |= list;
1292 /* Put it at the end of the map list */
1293 list_add_tail(&nlp->nlp_listp, &phba->fc_nlpmap_list);
1294 phba->fc_map_cnt++;
1295 phba->nport_event_cnt++; 1229 phba->nport_event_cnt++;
1296 nlp->nlp_flag &= ~NLP_NODEV_REMOVE; 1230 lpfc_unregister_remote_port(phba, ndlp);
1297 break;
1298 case NLP_NPR_LIST:
1299 nlp->nlp_flag |= list;
1300 /* Put it at the end of the npr list */
1301 list_add_tail(&nlp->nlp_listp, &phba->fc_npr_list);
1302 phba->fc_npr_cnt++;
1303
1304 nlp->nlp_flag &= ~NLP_RCV_PLOGI;
1305 break;
1306 case NLP_JUST_DQ:
1307 break;
1308 } 1231 }
1309 1232
1310 spin_unlock_irq(phba->host->host_lock); 1233 if (new_state == NLP_STE_MAPPED_NODE ||
1311 1234 new_state == NLP_STE_UNMAPPED_NODE) {
1312 /* 1235 phba->nport_event_cnt++;
1313 * We make all the calls into the transport after we have
1314 * moved the node between lists. This so that we don't
1315 * release the lock while in-between lists.
1316 */
1317
1318 /* Don't upcall midlayer if we're unloading */
1319 if (!(phba->fc_flag & FC_UNLOADING)) {
1320 /*
1321 * We revalidate the rport pointer as the "add" function
1322 * may have removed the remote port.
1323 */
1324 if ((rport_del != none) && nlp->rport)
1325 lpfc_unregister_remote_port(phba, nlp);
1326
1327 if (rport_add != none) {
1328 /* 1236 /*
1329 * Tell the fc transport about the port, if we haven't 1237 * Tell the fc transport about the port, if we haven't
1330 * already. If we have, and it's a scsi entity, be 1238 * already. If we have, and it's a scsi entity, be
1331 * sure to unblock any attached scsi devices 1239 * sure to unblock any attached scsi devices
1332 */ 1240 */
1333 if ((!nlp->rport) || (nlp->rport->port_state == 1241 lpfc_register_remote_port(phba, ndlp);
1334 FC_PORTSTATE_BLOCKED)) 1242 }
1335 lpfc_register_remote_port(phba, nlp);
1336 1243
1337 /* 1244 /*
1338 * if we added to Mapped list, but the remote port 1245 * if we added to Mapped list, but the remote port
@@ -1340,19 +1247,95 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
1340 * our presentable range - move the node to the 1247 * our presentable range - move the node to the
1341 * Unmapped List 1248 * Unmapped List
1342 */ 1249 */
1343 if ((rport_add == mapped) && 1250 if (new_state == NLP_STE_MAPPED_NODE &&
1344 ((!nlp->rport) || 1251 (!ndlp->rport ||
1345 (nlp->rport->scsi_target_id == -1) || 1252 ndlp->rport->scsi_target_id == -1 ||
1346 (nlp->rport->scsi_target_id >= LPFC_MAX_TARGET))) { 1253 ndlp->rport->scsi_target_id >= LPFC_MAX_TARGET)) {
1347 nlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1254 spin_lock_irq(phba->host->host_lock);
1348 spin_lock_irq(phba->host->host_lock); 1255 ndlp->nlp_flag |= NLP_TGT_NO_SCSIID;
1349 nlp->nlp_flag |= NLP_TGT_NO_SCSIID; 1256 spin_unlock_irq(phba->host->host_lock);
1350 spin_unlock_irq(phba->host->host_lock); 1257 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1351 lpfc_nlp_list(phba, nlp, NLP_UNMAPPED_LIST);
1352 }
1353 }
1354 } 1258 }
1355 return 0; 1259}
1260
1261static char *
1262lpfc_nlp_state_name(char *buffer, size_t size, int state)
1263{
1264 static char *states[] = {
1265 [NLP_STE_UNUSED_NODE] = "UNUSED",
1266 [NLP_STE_PLOGI_ISSUE] = "PLOGI",
1267 [NLP_STE_ADISC_ISSUE] = "ADISC",
1268 [NLP_STE_REG_LOGIN_ISSUE] = "REGLOGIN",
1269 [NLP_STE_PRLI_ISSUE] = "PRLI",
1270 [NLP_STE_UNMAPPED_NODE] = "UNMAPPED",
1271 [NLP_STE_MAPPED_NODE] = "MAPPED",
1272 [NLP_STE_NPR_NODE] = "NPR",
1273 };
1274
1275 if (state < ARRAY_SIZE(states) && states[state])
1276 strlcpy(buffer, states[state], size);
1277 else
1278 snprintf(buffer, size, "unknown (%d)", state);
1279 return buffer;
1280}
1281
1282void
1283lpfc_nlp_set_state(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, int state)
1284{
1285 int old_state = ndlp->nlp_state;
1286 char name1[16], name2[16];
1287
1288 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1289 "%d:0904 NPort state transition x%06x, %s -> %s\n",
1290 phba->brd_no,
1291 ndlp->nlp_DID,
1292 lpfc_nlp_state_name(name1, sizeof(name1), old_state),
1293 lpfc_nlp_state_name(name2, sizeof(name2), state));
1294 if (old_state == NLP_STE_NPR_NODE &&
1295 (ndlp->nlp_flag & NLP_DELAY_TMO) != 0 &&
1296 state != NLP_STE_NPR_NODE)
1297 lpfc_cancel_retry_delay_tmo(phba, ndlp);
1298 if (old_state == NLP_STE_UNMAPPED_NODE) {
1299 ndlp->nlp_flag &= ~NLP_TGT_NO_SCSIID;
1300 ndlp->nlp_type &= ~NLP_FC_NODE;
1301 }
1302
1303 if (list_empty(&ndlp->nlp_listp)) {
1304 spin_lock_irq(phba->host->host_lock);
1305 list_add_tail(&ndlp->nlp_listp, &phba->fc_nodes);
1306 spin_unlock_irq(phba->host->host_lock);
1307 } else if (old_state)
1308 lpfc_nlp_counters(phba, old_state, -1);
1309
1310 ndlp->nlp_state = state;
1311 lpfc_nlp_counters(phba, state, 1);
1312 lpfc_nlp_state_cleanup(phba, ndlp, old_state, state);
1313}
1314
1315void
1316lpfc_dequeue_node(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
1317{
1318 if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0)
1319 lpfc_cancel_retry_delay_tmo(phba, ndlp);
1320 if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp))
1321 lpfc_nlp_counters(phba, ndlp->nlp_state, -1);
1322 spin_lock_irq(phba->host->host_lock);
1323 list_del_init(&ndlp->nlp_listp);
1324 spin_unlock_irq(phba->host->host_lock);
1325 lpfc_nlp_state_cleanup(phba, ndlp, ndlp->nlp_state, 0);
1326}
1327
1328void
1329lpfc_drop_node(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
1330{
1331 if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0)
1332 lpfc_cancel_retry_delay_tmo(phba, ndlp);
1333 if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp))
1334 lpfc_nlp_counters(phba, ndlp->nlp_state, -1);
1335 spin_lock_irq(phba->host->host_lock);
1336 list_del_init(&ndlp->nlp_listp);
1337 spin_unlock_irq(phba->host->host_lock);
1338 lpfc_nlp_put(ndlp);
1356} 1339}
1357 1340
1358/* 1341/*
@@ -1464,6 +1447,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba * phba,
1464static int 1447static int
1465lpfc_no_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) 1448lpfc_no_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1466{ 1449{
1450 LIST_HEAD(completions);
1467 struct lpfc_sli *psli; 1451 struct lpfc_sli *psli;
1468 struct lpfc_sli_ring *pring; 1452 struct lpfc_sli_ring *pring;
1469 struct lpfc_iocbq *iocb, *next_iocb; 1453 struct lpfc_iocbq *iocb, *next_iocb;
@@ -1492,29 +1476,29 @@ lpfc_no_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1492 (phba, pring, iocb, ndlp))) { 1476 (phba, pring, iocb, ndlp))) {
1493 /* It matches, so deque and call compl 1477 /* It matches, so deque and call compl
1494 with an error */ 1478 with an error */
1495 list_del(&iocb->list); 1479 list_move_tail(&iocb->list,
1480 &completions);
1496 pring->txq_cnt--; 1481 pring->txq_cnt--;
1497 if (iocb->iocb_cmpl) {
1498 icmd = &iocb->iocb;
1499 icmd->ulpStatus =
1500 IOSTAT_LOCAL_REJECT;
1501 icmd->un.ulpWord[4] =
1502 IOERR_SLI_ABORTED;
1503 spin_unlock_irq(phba->host->
1504 host_lock);
1505 (iocb->iocb_cmpl) (phba,
1506 iocb, iocb);
1507 spin_lock_irq(phba->host->
1508 host_lock);
1509 } else
1510 lpfc_sli_release_iocbq(phba,
1511 iocb);
1512 } 1482 }
1513 } 1483 }
1514 spin_unlock_irq(phba->host->host_lock); 1484 spin_unlock_irq(phba->host->host_lock);
1515 1485
1516 } 1486 }
1517 } 1487 }
1488
1489 while (!list_empty(&completions)) {
1490 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
1491 list_del(&iocb->list);
1492
1493 if (iocb->iocb_cmpl) {
1494 icmd = &iocb->iocb;
1495 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
1496 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
1497 (iocb->iocb_cmpl) (phba, iocb, iocb);
1498 } else
1499 lpfc_sli_release_iocbq(phba, iocb);
1500 }
1501
1518 return 0; 1502 return 0;
1519} 1503}
1520 1504
@@ -1554,7 +1538,7 @@ lpfc_unreg_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1554 * so it can be freed. 1538 * so it can be freed.
1555 */ 1539 */
1556static int 1540static int
1557lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) 1541lpfc_cleanup_node(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1558{ 1542{
1559 LPFC_MBOXQ_t *mb; 1543 LPFC_MBOXQ_t *mb;
1560 LPFC_MBOXQ_t *nextmb; 1544 LPFC_MBOXQ_t *nextmb;
@@ -1567,17 +1551,7 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1567 phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag, 1551 phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
1568 ndlp->nlp_state, ndlp->nlp_rpi); 1552 ndlp->nlp_state, ndlp->nlp_rpi);
1569 1553
1570 lpfc_nlp_list(phba, ndlp, NLP_JUST_DQ); 1554 lpfc_dequeue_node(phba, ndlp);
1571
1572 /*
1573 * if unloading the driver - just leave the remote port in place.
1574 * The driver unload will force the attached devices to detach
1575 * and flush cache's w/o generating flush errors.
1576 */
1577 if ((ndlp->rport) && !(phba->fc_flag & FC_UNLOADING)) {
1578 lpfc_unregister_remote_port(phba, ndlp);
1579 ndlp->nlp_sid = NLP_NO_SID;
1580 }
1581 1555
1582 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ 1556 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1583 if ((mb = phba->sli.mbox_active)) { 1557 if ((mb = phba->sli.mbox_active)) {
@@ -1599,11 +1573,12 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1599 } 1573 }
1600 list_del(&mb->list); 1574 list_del(&mb->list);
1601 mempool_free(mb, phba->mbox_mem_pool); 1575 mempool_free(mb, phba->mbox_mem_pool);
1576 lpfc_nlp_put(ndlp);
1602 } 1577 }
1603 } 1578 }
1604 spin_unlock_irq(phba->host->host_lock); 1579 spin_unlock_irq(phba->host->host_lock);
1605 1580
1606 lpfc_els_abort(phba,ndlp,0); 1581 lpfc_els_abort(phba,ndlp);
1607 spin_lock_irq(phba->host->host_lock); 1582 spin_lock_irq(phba->host->host_lock);
1608 ndlp->nlp_flag &= ~NLP_DELAY_TMO; 1583 ndlp->nlp_flag &= ~NLP_DELAY_TMO;
1609 spin_unlock_irq(phba->host->host_lock); 1584 spin_unlock_irq(phba->host->host_lock);
@@ -1624,27 +1599,27 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1624 * If we are in the middle of using the nlp in the discovery state 1599 * If we are in the middle of using the nlp in the discovery state
1625 * machine, defer the free till we reach the end of the state machine. 1600 * machine, defer the free till we reach the end of the state machine.
1626 */ 1601 */
1627int 1602static void
1628lpfc_nlp_remove(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) 1603lpfc_nlp_remove(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
1629{ 1604{
1605 struct lpfc_rport_data *rdata;
1630 1606
1631 if (ndlp->nlp_flag & NLP_DELAY_TMO) { 1607 if (ndlp->nlp_flag & NLP_DELAY_TMO) {
1632 lpfc_cancel_retry_delay_tmo(phba, ndlp); 1608 lpfc_cancel_retry_delay_tmo(phba, ndlp);
1633 } 1609 }
1634 1610
1635 if (ndlp->nlp_disc_refcnt) { 1611 lpfc_cleanup_node(phba, ndlp);
1636 spin_lock_irq(phba->host->host_lock); 1612
1637 ndlp->nlp_flag |= NLP_DELAY_REMOVE; 1613 if ((ndlp->rport) && !(phba->fc_flag & FC_UNLOADING)) {
1638 spin_unlock_irq(phba->host->host_lock); 1614 put_device(&ndlp->rport->dev);
1639 } else { 1615 rdata = ndlp->rport->dd_data;
1640 lpfc_freenode(phba, ndlp); 1616 rdata->pnode = NULL;
1641 mempool_free( ndlp, phba->nlp_mem_pool); 1617 ndlp->rport = NULL;
1642 } 1618 }
1643 return 0;
1644} 1619}
1645 1620
1646static int 1621static int
1647lpfc_matchdid(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, uint32_t did) 1622lpfc_matchdid(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, uint32_t did)
1648{ 1623{
1649 D_ID mydid; 1624 D_ID mydid;
1650 D_ID ndlpdid; 1625 D_ID ndlpdid;
@@ -1693,57 +1668,36 @@ lpfc_matchdid(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, uint32_t did)
1693 return 0; 1668 return 0;
1694} 1669}
1695 1670
1696/* Search for a nodelist entry on a specific list */ 1671/* Search for a nodelist entry */
1697struct lpfc_nodelist * 1672struct lpfc_nodelist *
1698lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did) 1673lpfc_findnode_did(struct lpfc_hba *phba, uint32_t did)
1699{ 1674{
1700 struct lpfc_nodelist *ndlp; 1675 struct lpfc_nodelist *ndlp;
1701 struct list_head *lists[]={&phba->fc_nlpunmap_list,
1702 &phba->fc_nlpmap_list,
1703 &phba->fc_plogi_list,
1704 &phba->fc_adisc_list,
1705 &phba->fc_reglogin_list,
1706 &phba->fc_prli_list,
1707 &phba->fc_npr_list,
1708 &phba->fc_unused_list};
1709 uint32_t search[]={NLP_SEARCH_UNMAPPED,
1710 NLP_SEARCH_MAPPED,
1711 NLP_SEARCH_PLOGI,
1712 NLP_SEARCH_ADISC,
1713 NLP_SEARCH_REGLOGIN,
1714 NLP_SEARCH_PRLI,
1715 NLP_SEARCH_NPR,
1716 NLP_SEARCH_UNUSED};
1717 int i;
1718 uint32_t data1; 1676 uint32_t data1;
1719 1677
1720 spin_lock_irq(phba->host->host_lock); 1678 spin_lock_irq(phba->host->host_lock);
1721 for (i = 0; i < ARRAY_SIZE(lists); i++ ) { 1679 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
1722 if (!(order & search[i])) 1680 if (lpfc_matchdid(phba, ndlp, did)) {
1723 continue; 1681 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1724 list_for_each_entry(ndlp, lists[i], nlp_listp) { 1682 ((uint32_t) ndlp->nlp_xri << 16) |
1725 if (lpfc_matchdid(phba, ndlp, did)) { 1683 ((uint32_t) ndlp->nlp_type << 8) |
1726 data1 = (((uint32_t) ndlp->nlp_state << 24) | 1684 ((uint32_t) ndlp->nlp_rpi & 0xff));
1727 ((uint32_t) ndlp->nlp_xri << 16) | 1685 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1728 ((uint32_t) ndlp->nlp_type << 8) | 1686 "%d:0929 FIND node DID "
1729 ((uint32_t) ndlp->nlp_rpi & 0xff)); 1687 " Data: x%p x%x x%x x%x\n",
1730 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1688 phba->brd_no,
1731 "%d:0929 FIND node DID " 1689 ndlp, ndlp->nlp_DID,
1732 " Data: x%p x%x x%x x%x\n", 1690 ndlp->nlp_flag, data1);
1733 phba->brd_no, 1691 spin_unlock_irq(phba->host->host_lock);
1734 ndlp, ndlp->nlp_DID, 1692 return ndlp;
1735 ndlp->nlp_flag, data1);
1736 spin_unlock_irq(phba->host->host_lock);
1737 return ndlp;
1738 }
1739 } 1693 }
1740 } 1694 }
1741 spin_unlock_irq(phba->host->host_lock); 1695 spin_unlock_irq(phba->host->host_lock);
1742 1696
1743 /* FIND node did <did> NOT FOUND */ 1697 /* FIND node did <did> NOT FOUND */
1744 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1698 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1745 "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n", 1699 "%d:0932 FIND node did x%x NOT FOUND.\n",
1746 phba->brd_no, did, order); 1700 phba->brd_no, did);
1747 return NULL; 1701 return NULL;
1748} 1702}
1749 1703
@@ -1751,9 +1705,8 @@ struct lpfc_nodelist *
1751lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did) 1705lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
1752{ 1706{
1753 struct lpfc_nodelist *ndlp; 1707 struct lpfc_nodelist *ndlp;
1754 uint32_t flg;
1755 1708
1756 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, did); 1709 ndlp = lpfc_findnode_did(phba, did);
1757 if (!ndlp) { 1710 if (!ndlp) {
1758 if ((phba->fc_flag & FC_RSCN_MODE) && 1711 if ((phba->fc_flag & FC_RSCN_MODE) &&
1759 ((lpfc_rscn_payload_check(phba, did) == 0))) 1712 ((lpfc_rscn_payload_check(phba, did) == 0)))
@@ -1763,8 +1716,7 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
1763 if (!ndlp) 1716 if (!ndlp)
1764 return NULL; 1717 return NULL;
1765 lpfc_nlp_init(phba, ndlp, did); 1718 lpfc_nlp_init(phba, ndlp, did);
1766 ndlp->nlp_state = NLP_STE_NPR_NODE; 1719 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1767 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1768 ndlp->nlp_flag |= NLP_NPR_2B_DISC; 1720 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
1769 return ndlp; 1721 return ndlp;
1770 } 1722 }
@@ -1780,11 +1732,10 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did)
1780 } else 1732 } else
1781 ndlp = NULL; 1733 ndlp = NULL;
1782 } else { 1734 } else {
1783 flg = ndlp->nlp_flag & NLP_LIST_MASK; 1735 if (ndlp->nlp_state == NLP_STE_ADISC_ISSUE ||
1784 if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST)) 1736 ndlp->nlp_state == NLP_STE_PLOGI_ISSUE)
1785 return NULL; 1737 return NULL;
1786 ndlp->nlp_state = NLP_STE_NPR_NODE; 1738 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1787 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1788 ndlp->nlp_flag |= NLP_NPR_2B_DISC; 1739 ndlp->nlp_flag |= NLP_NPR_2B_DISC;
1789 } 1740 }
1790 return ndlp; 1741 return ndlp;
@@ -1842,8 +1793,9 @@ lpfc_disc_start(struct lpfc_hba * phba)
1842 struct lpfc_sli *psli; 1793 struct lpfc_sli *psli;
1843 LPFC_MBOXQ_t *mbox; 1794 LPFC_MBOXQ_t *mbox;
1844 struct lpfc_nodelist *ndlp, *next_ndlp; 1795 struct lpfc_nodelist *ndlp, *next_ndlp;
1845 uint32_t did_changed, num_sent; 1796 uint32_t num_sent;
1846 uint32_t clear_la_pending; 1797 uint32_t clear_la_pending;
1798 int did_changed;
1847 int rc; 1799 int rc;
1848 1800
1849 psli = &phba->sli; 1801 psli = &phba->sli;
@@ -1877,14 +1829,13 @@ lpfc_disc_start(struct lpfc_hba * phba)
1877 phba->fc_plogi_cnt, phba->fc_adisc_cnt); 1829 phba->fc_plogi_cnt, phba->fc_adisc_cnt);
1878 1830
1879 /* If our did changed, we MUST do PLOGI */ 1831 /* If our did changed, we MUST do PLOGI */
1880 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, 1832 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp) {
1881 nlp_listp) { 1833 if (ndlp->nlp_state == NLP_STE_NPR_NODE &&
1882 if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { 1834 (ndlp->nlp_flag & NLP_NPR_2B_DISC) != 0 &&
1883 if (did_changed) { 1835 did_changed) {
1884 spin_lock_irq(phba->host->host_lock); 1836 spin_lock_irq(phba->host->host_lock);
1885 ndlp->nlp_flag &= ~NLP_NPR_ADISC; 1837 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1886 spin_unlock_irq(phba->host->host_lock); 1838 spin_unlock_irq(phba->host->host_lock);
1887 }
1888 } 1839 }
1889 } 1840 }
1890 1841
@@ -1944,11 +1895,11 @@ lpfc_disc_start(struct lpfc_hba * phba)
1944static void 1895static void
1945lpfc_free_tx(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp) 1896lpfc_free_tx(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1946{ 1897{
1898 LIST_HEAD(completions);
1947 struct lpfc_sli *psli; 1899 struct lpfc_sli *psli;
1948 IOCB_t *icmd; 1900 IOCB_t *icmd;
1949 struct lpfc_iocbq *iocb, *next_iocb; 1901 struct lpfc_iocbq *iocb, *next_iocb;
1950 struct lpfc_sli_ring *pring; 1902 struct lpfc_sli_ring *pring;
1951 struct lpfc_dmabuf *mp;
1952 1903
1953 psli = &phba->sli; 1904 psli = &phba->sli;
1954 pring = &psli->ring[LPFC_ELS_RING]; 1905 pring = &psli->ring[LPFC_ELS_RING];
@@ -1956,6 +1907,7 @@ lpfc_free_tx(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1956 /* Error matching iocb on txq or txcmplq 1907 /* Error matching iocb on txq or txcmplq
1957 * First check the txq. 1908 * First check the txq.
1958 */ 1909 */
1910 spin_lock_irq(phba->host->host_lock);
1959 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 1911 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
1960 if (iocb->context1 != ndlp) { 1912 if (iocb->context1 != ndlp) {
1961 continue; 1913 continue;
@@ -1964,9 +1916,8 @@ lpfc_free_tx(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1964 if ((icmd->ulpCommand == CMD_ELS_REQUEST64_CR) || 1916 if ((icmd->ulpCommand == CMD_ELS_REQUEST64_CR) ||
1965 (icmd->ulpCommand == CMD_XMIT_ELS_RSP64_CX)) { 1917 (icmd->ulpCommand == CMD_XMIT_ELS_RSP64_CX)) {
1966 1918
1967 list_del(&iocb->list); 1919 list_move_tail(&iocb->list, &completions);
1968 pring->txq_cnt--; 1920 pring->txq_cnt--;
1969 lpfc_els_free_iocb(phba, iocb);
1970 } 1921 }
1971 } 1922 }
1972 1923
@@ -1978,43 +1929,22 @@ lpfc_free_tx(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
1978 icmd = &iocb->iocb; 1929 icmd = &iocb->iocb;
1979 if ((icmd->ulpCommand == CMD_ELS_REQUEST64_CR) || 1930 if ((icmd->ulpCommand == CMD_ELS_REQUEST64_CR) ||
1980 (icmd->ulpCommand == CMD_XMIT_ELS_RSP64_CX)) { 1931 (icmd->ulpCommand == CMD_XMIT_ELS_RSP64_CX)) {
1932 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
1933 }
1934 }
1935 spin_unlock_irq(phba->host->host_lock);
1981 1936
1982 iocb->iocb_cmpl = NULL; 1937 while (!list_empty(&completions)) {
1983 /* context2 = cmd, context2->next = rsp, context3 = 1938 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
1984 bpl */ 1939 list_del(&iocb->list);
1985 if (iocb->context2) {
1986 /* Free the response IOCB before handling the
1987 command. */
1988
1989 mp = (struct lpfc_dmabuf *) (iocb->context2);
1990 mp = list_get_first(&mp->list,
1991 struct lpfc_dmabuf,
1992 list);
1993 if (mp) {
1994 /* Delay before releasing rsp buffer to
1995 * give UNREG mbox a chance to take
1996 * effect.
1997 */
1998 list_add(&mp->list,
1999 &phba->freebufList);
2000 }
2001 lpfc_mbuf_free(phba,
2002 ((struct lpfc_dmabuf *)
2003 iocb->context2)->virt,
2004 ((struct lpfc_dmabuf *)
2005 iocb->context2)->phys);
2006 kfree(iocb->context2);
2007 }
2008 1940
2009 if (iocb->context3) { 1941 if (iocb->iocb_cmpl) {
2010 lpfc_mbuf_free(phba, 1942 icmd = &iocb->iocb;
2011 ((struct lpfc_dmabuf *) 1943 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
2012 iocb->context3)->virt, 1944 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
2013 ((struct lpfc_dmabuf *) 1945 (iocb->iocb_cmpl) (phba, iocb, iocb);
2014 iocb->context3)->phys); 1946 } else
2015 kfree(iocb->context3); 1947 lpfc_sli_release_iocbq(phba, iocb);
2016 }
2017 }
2018 } 1948 }
2019 1949
2020 return; 1950 return;
@@ -2025,21 +1955,16 @@ lpfc_disc_flush_list(struct lpfc_hba * phba)
2025{ 1955{
2026 struct lpfc_nodelist *ndlp, *next_ndlp; 1956 struct lpfc_nodelist *ndlp, *next_ndlp;
2027 1957
2028 if (phba->fc_plogi_cnt) { 1958 if (phba->fc_plogi_cnt || phba->fc_adisc_cnt) {
2029 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list, 1959 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes,
2030 nlp_listp) { 1960 nlp_listp) {
2031 lpfc_free_tx(phba, ndlp); 1961 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE ||
2032 lpfc_nlp_remove(phba, ndlp); 1962 ndlp->nlp_state == NLP_STE_ADISC_ISSUE) {
2033 } 1963 lpfc_free_tx(phba, ndlp);
2034 } 1964 lpfc_nlp_put(ndlp);
2035 if (phba->fc_adisc_cnt) { 1965 }
2036 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
2037 nlp_listp) {
2038 lpfc_free_tx(phba, ndlp);
2039 lpfc_nlp_remove(phba, ndlp);
2040 } 1966 }
2041 } 1967 }
2042 return;
2043} 1968}
2044 1969
2045/*****************************************************************************/ 1970/*****************************************************************************/
@@ -2108,11 +2033,13 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2108 phba->brd_no); 2033 phba->brd_no);
2109 2034
2110 /* Start discovery by sending FLOGI, clean up old rpis */ 2035 /* Start discovery by sending FLOGI, clean up old rpis */
2111 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list, 2036 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes,
2112 nlp_listp) { 2037 nlp_listp) {
2038 if (ndlp->nlp_state != NLP_STE_NPR_NODE)
2039 continue;
2113 if (ndlp->nlp_type & NLP_FABRIC) { 2040 if (ndlp->nlp_type & NLP_FABRIC) {
2114 /* Clean up the ndlp on Fabric connections */ 2041 /* Clean up the ndlp on Fabric connections */
2115 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 2042 lpfc_drop_node(phba, ndlp);
2116 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) { 2043 } else if (!(ndlp->nlp_flag & NLP_NPR_ADISC)) {
2117 /* Fail outstanding IO now since device 2044 /* Fail outstanding IO now since device
2118 * is marked for PLOGI. 2045 * is marked for PLOGI.
@@ -2153,9 +2080,9 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2153 "login\n", phba->brd_no); 2080 "login\n", phba->brd_no);
2154 2081
2155 /* Next look for NameServer ndlp */ 2082 /* Next look for NameServer ndlp */
2156 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_ALL, NameServer_DID); 2083 ndlp = lpfc_findnode_did(phba, NameServer_DID);
2157 if (ndlp) 2084 if (ndlp)
2158 lpfc_nlp_remove(phba, ndlp); 2085 lpfc_nlp_put(ndlp);
2159 /* Start discovery */ 2086 /* Start discovery */
2160 lpfc_disc_start(phba); 2087 lpfc_disc_start(phba);
2161 break; 2088 break;
@@ -2168,9 +2095,8 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2168 phba->brd_no, 2095 phba->brd_no,
2169 phba->fc_ns_retry, LPFC_MAX_NS_RETRY); 2096 phba->fc_ns_retry, LPFC_MAX_NS_RETRY);
2170 2097
2171 ndlp = lpfc_findnode_did(phba, NLP_SEARCH_UNMAPPED, 2098 ndlp = lpfc_findnode_did(phba, NameServer_DID);
2172 NameServer_DID); 2099 if (ndlp && ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) {
2173 if (ndlp) {
2174 if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) { 2100 if (phba->fc_ns_retry < LPFC_MAX_NS_RETRY) {
2175 /* Try it one more time */ 2101 /* Try it one more time */
2176 rc = lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT); 2102 rc = lpfc_ns_cmd(phba, ndlp, SLI_CTNS_GID_FT);
@@ -2220,6 +2146,7 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2220 initlinkmbox->mb.un.varInitLnk.lipsr_AL_PA = 0; 2146 initlinkmbox->mb.un.varInitLnk.lipsr_AL_PA = 0;
2221 rc = lpfc_sli_issue_mbox(phba, initlinkmbox, 2147 rc = lpfc_sli_issue_mbox(phba, initlinkmbox,
2222 (MBX_NOWAIT | MBX_STOP_IOCB)); 2148 (MBX_NOWAIT | MBX_STOP_IOCB));
2149 lpfc_set_loopback_flag(phba);
2223 if (rc == MBX_NOT_FINISHED) 2150 if (rc == MBX_NOT_FINISHED)
2224 mempool_free(initlinkmbox, phba->mbox_mem_pool); 2151 mempool_free(initlinkmbox, phba->mbox_mem_pool);
2225 2152
@@ -2317,8 +2244,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
2317 2244
2318 ndlp->nlp_rpi = mb->un.varWords[0]; 2245 ndlp->nlp_rpi = mb->un.varWords[0];
2319 ndlp->nlp_type |= NLP_FABRIC; 2246 ndlp->nlp_type |= NLP_FABRIC;
2320 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 2247 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
2321 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
2322 2248
2323 /* Start issuing Fabric-Device Management Interface (FDMI) 2249 /* Start issuing Fabric-Device Management Interface (FDMI)
2324 * command to 0xfffffa (FDMI well known port) 2250 * command to 0xfffffa (FDMI well known port)
@@ -2333,87 +2259,100 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
2333 mod_timer(&phba->fc_fdmitmo, jiffies + HZ * 60); 2259 mod_timer(&phba->fc_fdmitmo, jiffies + HZ * 60);
2334 } 2260 }
2335 2261
2262 /* Mailbox took a reference to the node */
2263 lpfc_nlp_put(ndlp);
2336 lpfc_mbuf_free(phba, mp->virt, mp->phys); 2264 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2337 kfree(mp); 2265 kfree(mp);
2338 mempool_free( pmb, phba->mbox_mem_pool); 2266 mempool_free(pmb, phba->mbox_mem_pool);
2339 2267
2340 return; 2268 return;
2341} 2269}
2342 2270
2271static int
2272lpfc_filter_by_rpi(struct lpfc_nodelist *ndlp, void *param)
2273{
2274 uint16_t *rpi = param;
2275
2276 return ndlp->nlp_rpi == *rpi;
2277}
2278
2279static int
2280lpfc_filter_by_wwpn(struct lpfc_nodelist *ndlp, void *param)
2281{
2282 return memcmp(&ndlp->nlp_portname, param,
2283 sizeof(ndlp->nlp_portname)) == 0;
2284}
2285
2286/*
2287 * Search node lists for a remote port matching filter criteria
2288 * Caller needs to hold host_lock before calling this routine.
2289 */
2290struct lpfc_nodelist *
2291__lpfc_find_node(struct lpfc_hba *phba, node_filter filter, void *param)
2292{
2293 struct lpfc_nodelist *ndlp;
2294
2295 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
2296 if (ndlp->nlp_state != NLP_STE_UNUSED_NODE &&
2297 filter(ndlp, param))
2298 return ndlp;
2299 }
2300 return NULL;
2301}
2302
2343/* 2303/*
2344 * This routine looks up the ndlp lists 2304 * Search node lists for a remote port matching filter criteria
2345 * for the given RPI. If rpi found 2305 * This routine is used when the caller does NOT have host_lock.
2346 * it return the node list pointer
2347 * else return NULL.
2348 */ 2306 */
2349struct lpfc_nodelist * 2307struct lpfc_nodelist *
2308lpfc_find_node(struct lpfc_hba *phba, node_filter filter, void *param)
2309{
2310 struct lpfc_nodelist *ndlp;
2311
2312 spin_lock_irq(phba->host->host_lock);
2313 ndlp = __lpfc_find_node(phba, filter, param);
2314 spin_unlock_irq(phba->host->host_lock);
2315 return ndlp;
2316}
2317
2318/*
2319 * This routine looks up the ndlp lists for the given RPI. If rpi found it
2320 * returns the node list pointer else return NULL.
2321 */
2322struct lpfc_nodelist *
2323__lpfc_findnode_rpi(struct lpfc_hba *phba, uint16_t rpi)
2324{
2325 return __lpfc_find_node(phba, lpfc_filter_by_rpi, &rpi);
2326}
2327
2328struct lpfc_nodelist *
2350lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi) 2329lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi)
2351{ 2330{
2352 struct lpfc_nodelist *ndlp; 2331 struct lpfc_nodelist *ndlp;
2353 struct list_head * lists[]={&phba->fc_nlpunmap_list,
2354 &phba->fc_nlpmap_list,
2355 &phba->fc_plogi_list,
2356 &phba->fc_adisc_list,
2357 &phba->fc_reglogin_list};
2358 int i;
2359 2332
2360 spin_lock_irq(phba->host->host_lock); 2333 spin_lock_irq(phba->host->host_lock);
2361 for (i = 0; i < ARRAY_SIZE(lists); i++ ) 2334 ndlp = __lpfc_findnode_rpi(phba, rpi);
2362 list_for_each_entry(ndlp, lists[i], nlp_listp)
2363 if (ndlp->nlp_rpi == rpi) {
2364 spin_unlock_irq(phba->host->host_lock);
2365 return ndlp;
2366 }
2367 spin_unlock_irq(phba->host->host_lock); 2335 spin_unlock_irq(phba->host->host_lock);
2368 return NULL; 2336 return ndlp;
2369} 2337}
2370 2338
2371/* 2339/*
2372 * This routine looks up the ndlp lists 2340 * This routine looks up the ndlp lists for the given WWPN. If WWPN found it
2373 * for the given WWPN. If WWPN found 2341 * returns the node list pointer else return NULL.
2374 * it return the node list pointer
2375 * else return NULL.
2376 */ 2342 */
2377struct lpfc_nodelist * 2343struct lpfc_nodelist *
2378lpfc_findnode_wwpn(struct lpfc_hba * phba, uint32_t order, 2344lpfc_findnode_wwpn(struct lpfc_hba *phba, struct lpfc_name *wwpn)
2379 struct lpfc_name * wwpn)
2380{ 2345{
2381 struct lpfc_nodelist *ndlp; 2346 struct lpfc_nodelist *ndlp;
2382 struct list_head * lists[]={&phba->fc_nlpunmap_list,
2383 &phba->fc_nlpmap_list,
2384 &phba->fc_npr_list,
2385 &phba->fc_plogi_list,
2386 &phba->fc_adisc_list,
2387 &phba->fc_reglogin_list,
2388 &phba->fc_prli_list};
2389 uint32_t search[]={NLP_SEARCH_UNMAPPED,
2390 NLP_SEARCH_MAPPED,
2391 NLP_SEARCH_NPR,
2392 NLP_SEARCH_PLOGI,
2393 NLP_SEARCH_ADISC,
2394 NLP_SEARCH_REGLOGIN,
2395 NLP_SEARCH_PRLI};
2396 int i;
2397 2347
2398 spin_lock_irq(phba->host->host_lock); 2348 spin_lock_irq(phba->host->host_lock);
2399 for (i = 0; i < ARRAY_SIZE(lists); i++ ) { 2349 ndlp = __lpfc_find_node(phba, lpfc_filter_by_wwpn, wwpn);
2400 if (!(order & search[i]))
2401 continue;
2402 list_for_each_entry(ndlp, lists[i], nlp_listp) {
2403 if (memcmp(&ndlp->nlp_portname, wwpn,
2404 sizeof(struct lpfc_name)) == 0) {
2405 spin_unlock_irq(phba->host->host_lock);
2406 return ndlp;
2407 }
2408 }
2409 }
2410 spin_unlock_irq(phba->host->host_lock); 2350 spin_unlock_irq(phba->host->host_lock);
2411 return NULL; 2351 return NULL;
2412} 2352}
2413 2353
2414void 2354void
2415lpfc_nlp_init(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, 2355lpfc_nlp_init(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, uint32_t did)
2416 uint32_t did)
2417{ 2356{
2418 memset(ndlp, 0, sizeof (struct lpfc_nodelist)); 2357 memset(ndlp, 0, sizeof (struct lpfc_nodelist));
2419 INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp); 2358 INIT_LIST_HEAD(&ndlp->els_retry_evt.evt_listp);
@@ -2423,5 +2362,30 @@ lpfc_nlp_init(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
2423 ndlp->nlp_DID = did; 2362 ndlp->nlp_DID = did;
2424 ndlp->nlp_phba = phba; 2363 ndlp->nlp_phba = phba;
2425 ndlp->nlp_sid = NLP_NO_SID; 2364 ndlp->nlp_sid = NLP_NO_SID;
2365 INIT_LIST_HEAD(&ndlp->nlp_listp);
2366 kref_init(&ndlp->kref);
2426 return; 2367 return;
2427} 2368}
2369
2370void
2371lpfc_nlp_release(struct kref *kref)
2372{
2373 struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist,
2374 kref);
2375 lpfc_nlp_remove(ndlp->nlp_phba, ndlp);
2376 mempool_free(ndlp, ndlp->nlp_phba->nlp_mem_pool);
2377}
2378
2379struct lpfc_nodelist *
2380lpfc_nlp_get(struct lpfc_nodelist *ndlp)
2381{
2382 if (ndlp)
2383 kref_get(&ndlp->kref);
2384 return ndlp;
2385}
2386
2387int
2388lpfc_nlp_put(struct lpfc_nodelist *ndlp)
2389{
2390 return ndlp ? kref_put(&ndlp->kref, lpfc_nlp_release) : 0;
2391}
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index f79cb6136906..2623a9bc7775 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * * 7 * *
@@ -1078,6 +1078,8 @@ typedef struct {
1078/* Start FireFly Register definitions */ 1078/* Start FireFly Register definitions */
1079#define PCI_VENDOR_ID_EMULEX 0x10df 1079#define PCI_VENDOR_ID_EMULEX 0x10df
1080#define PCI_DEVICE_ID_FIREFLY 0x1ae5 1080#define PCI_DEVICE_ID_FIREFLY 0x1ae5
1081#define PCI_DEVICE_ID_SAT_SMB 0xf011
1082#define PCI_DEVICE_ID_SAT_MID 0xf015
1081#define PCI_DEVICE_ID_RFLY 0xf095 1083#define PCI_DEVICE_ID_RFLY 0xf095
1082#define PCI_DEVICE_ID_PFLY 0xf098 1084#define PCI_DEVICE_ID_PFLY 0xf098
1083#define PCI_DEVICE_ID_LP101 0xf0a1 1085#define PCI_DEVICE_ID_LP101 0xf0a1
@@ -1089,6 +1091,9 @@ typedef struct {
1089#define PCI_DEVICE_ID_NEPTUNE 0xf0f5 1091#define PCI_DEVICE_ID_NEPTUNE 0xf0f5
1090#define PCI_DEVICE_ID_NEPTUNE_SCSP 0xf0f6 1092#define PCI_DEVICE_ID_NEPTUNE_SCSP 0xf0f6
1091#define PCI_DEVICE_ID_NEPTUNE_DCSP 0xf0f7 1093#define PCI_DEVICE_ID_NEPTUNE_DCSP 0xf0f7
1094#define PCI_DEVICE_ID_SAT 0xf100
1095#define PCI_DEVICE_ID_SAT_SCSP 0xf111
1096#define PCI_DEVICE_ID_SAT_DCSP 0xf112
1092#define PCI_DEVICE_ID_SUPERFLY 0xf700 1097#define PCI_DEVICE_ID_SUPERFLY 0xf700
1093#define PCI_DEVICE_ID_DRAGONFLY 0xf800 1098#define PCI_DEVICE_ID_DRAGONFLY 0xf800
1094#define PCI_DEVICE_ID_CENTAUR 0xf900 1099#define PCI_DEVICE_ID_CENTAUR 0xf900
@@ -1098,6 +1103,7 @@ typedef struct {
1098#define PCI_DEVICE_ID_LP10000S 0xfc00 1103#define PCI_DEVICE_ID_LP10000S 0xfc00
1099#define PCI_DEVICE_ID_LP11000S 0xfc10 1104#define PCI_DEVICE_ID_LP11000S 0xfc10
1100#define PCI_DEVICE_ID_LPE11000S 0xfc20 1105#define PCI_DEVICE_ID_LPE11000S 0xfc20
1106#define PCI_DEVICE_ID_SAT_S 0xfc40
1101#define PCI_DEVICE_ID_HELIOS 0xfd00 1107#define PCI_DEVICE_ID_HELIOS 0xfd00
1102#define PCI_DEVICE_ID_HELIOS_SCSP 0xfd11 1108#define PCI_DEVICE_ID_HELIOS_SCSP 0xfd11
1103#define PCI_DEVICE_ID_HELIOS_DCSP 0xfd12 1109#define PCI_DEVICE_ID_HELIOS_DCSP 0xfd12
@@ -1118,6 +1124,7 @@ typedef struct {
1118#define HELIOS_JEDEC_ID 0x0364 1124#define HELIOS_JEDEC_ID 0x0364
1119#define ZEPHYR_JEDEC_ID 0x0577 1125#define ZEPHYR_JEDEC_ID 0x0577
1120#define VIPER_JEDEC_ID 0x4838 1126#define VIPER_JEDEC_ID 0x4838
1127#define SATURN_JEDEC_ID 0x1004
1121 1128
1122#define JEDEC_ID_MASK 0x0FFFF000 1129#define JEDEC_ID_MASK 0x0FFFF000
1123#define JEDEC_ID_SHIFT 12 1130#define JEDEC_ID_SHIFT 12
@@ -1565,7 +1572,7 @@ typedef struct {
1565#define LINK_SPEED_1G 1 /* 1 Gigabaud */ 1572#define LINK_SPEED_1G 1 /* 1 Gigabaud */
1566#define LINK_SPEED_2G 2 /* 2 Gigabaud */ 1573#define LINK_SPEED_2G 2 /* 2 Gigabaud */
1567#define LINK_SPEED_4G 4 /* 4 Gigabaud */ 1574#define LINK_SPEED_4G 4 /* 4 Gigabaud */
1568#define LINK_SPEED_8G 8 /* 4 Gigabaud */ 1575#define LINK_SPEED_8G 8 /* 8 Gigabaud */
1569#define LINK_SPEED_10G 16 /* 10 Gigabaud */ 1576#define LINK_SPEED_10G 16 /* 10 Gigabaud */
1570 1577
1571} INIT_LINK_VAR; 1578} INIT_LINK_VAR;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index dcf6106f557a..dcb4ba0ecee1 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -386,12 +386,12 @@ lpfc_config_port_post(struct lpfc_hba * phba)
386 * Setup the ring 0 (els) timeout handler 386 * Setup the ring 0 (els) timeout handler
387 */ 387 */
388 timeout = phba->fc_ratov << 1; 388 timeout = phba->fc_ratov << 1;
389 phba->els_tmofunc.expires = jiffies + HZ * timeout; 389 mod_timer(&phba->els_tmofunc, jiffies + HZ * timeout);
390 add_timer(&phba->els_tmofunc);
391 390
392 lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); 391 lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed);
393 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; 392 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
394 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); 393 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
394 lpfc_set_loopback_flag(phba);
395 if (rc != MBX_SUCCESS) { 395 if (rc != MBX_SUCCESS) {
396 lpfc_printf_log(phba, 396 lpfc_printf_log(phba,
397 KERN_ERR, 397 KERN_ERR,
@@ -418,33 +418,6 @@ lpfc_config_port_post(struct lpfc_hba * phba)
418 return (0); 418 return (0);
419} 419}
420 420
421static int
422lpfc_discovery_wait(struct lpfc_hba *phba)
423{
424 int i = 0;
425
426 while ((phba->hba_state != LPFC_HBA_READY) ||
427 (phba->num_disc_nodes) || (phba->fc_prli_sent) ||
428 ((phba->fc_map_cnt == 0) && (i<2)) ||
429 (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)) {
430 /* Check every second for 30 retries. */
431 i++;
432 if (i > 30) {
433 return -ETIMEDOUT;
434 }
435 if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) {
436 /* The link is down. Set linkdown timeout */
437 return -ETIMEDOUT;
438 }
439
440 /* Delay for 1 second to give discovery time to complete. */
441 msleep(1000);
442
443 }
444
445 return 0;
446}
447
448/************************************************************************/ 421/************************************************************************/
449/* */ 422/* */
450/* lpfc_hba_down_prep */ 423/* lpfc_hba_down_prep */
@@ -550,12 +523,15 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
550 * There was a firmware error. Take the hba offline and then 523 * There was a firmware error. Take the hba offline and then
551 * attempt to restart it. 524 * attempt to restart it.
552 */ 525 */
526 lpfc_offline_prep(phba);
553 lpfc_offline(phba); 527 lpfc_offline(phba);
554 lpfc_sli_brdrestart(phba); 528 lpfc_sli_brdrestart(phba);
555 if (lpfc_online(phba) == 0) { /* Initialize the HBA */ 529 if (lpfc_online(phba) == 0) { /* Initialize the HBA */
556 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); 530 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
531 lpfc_unblock_mgmt_io(phba);
557 return; 532 return;
558 } 533 }
534 lpfc_unblock_mgmt_io(phba);
559 } else { 535 } else {
560 /* The if clause above forces this code path when the status 536 /* The if clause above forces this code path when the status
561 * failure is a value other than FFER6. Do not call the offline 537 * failure is a value other than FFER6. Do not call the offline
@@ -573,7 +549,9 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
573 SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX); 549 SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_EMULEX);
574 550
575 psli->sli_flag &= ~LPFC_SLI2_ACTIVE; 551 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
552 lpfc_offline_prep(phba);
576 lpfc_offline(phba); 553 lpfc_offline(phba);
554 lpfc_unblock_mgmt_io(phba);
577 phba->hba_state = LPFC_HBA_ERROR; 555 phba->hba_state = LPFC_HBA_ERROR;
578 lpfc_hba_down_post(phba); 556 lpfc_hba_down_post(phba);
579 } 557 }
@@ -633,7 +611,7 @@ lpfc_handle_latt_free_mbuf:
633lpfc_handle_latt_free_mp: 611lpfc_handle_latt_free_mp:
634 kfree(mp); 612 kfree(mp);
635lpfc_handle_latt_free_pmb: 613lpfc_handle_latt_free_pmb:
636 kfree(pmb); 614 mempool_free(pmb, phba->mbox_mem_pool);
637lpfc_handle_latt_err_exit: 615lpfc_handle_latt_err_exit:
638 /* Enable Link attention interrupts */ 616 /* Enable Link attention interrupts */
639 spin_lock_irq(phba->host->host_lock); 617 spin_lock_irq(phba->host->host_lock);
@@ -925,6 +903,24 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
925 m = (typeof(m)){"LPe11000-S", max_speed, 903 m = (typeof(m)){"LPe11000-S", max_speed,
926 "PCIe"}; 904 "PCIe"};
927 break; 905 break;
906 case PCI_DEVICE_ID_SAT:
907 m = (typeof(m)){"LPe12000", max_speed, "PCIe"};
908 break;
909 case PCI_DEVICE_ID_SAT_MID:
910 m = (typeof(m)){"LPe1250", max_speed, "PCIe"};
911 break;
912 case PCI_DEVICE_ID_SAT_SMB:
913 m = (typeof(m)){"LPe121", max_speed, "PCIe"};
914 break;
915 case PCI_DEVICE_ID_SAT_DCSP:
916 m = (typeof(m)){"LPe12002-SP", max_speed, "PCIe"};
917 break;
918 case PCI_DEVICE_ID_SAT_SCSP:
919 m = (typeof(m)){"LPe12000-SP", max_speed, "PCIe"};
920 break;
921 case PCI_DEVICE_ID_SAT_S:
922 m = (typeof(m)){"LPe12000-S", max_speed, "PCIe"};
923 break;
928 default: 924 default:
929 m = (typeof(m)){ NULL }; 925 m = (typeof(m)){ NULL };
930 break; 926 break;
@@ -1174,69 +1170,17 @@ lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
1174} 1170}
1175 1171
1176static void 1172static void
1177lpfc_cleanup(struct lpfc_hba * phba, uint32_t save_bind) 1173lpfc_cleanup(struct lpfc_hba * phba)
1178{ 1174{
1179 struct lpfc_nodelist *ndlp, *next_ndlp; 1175 struct lpfc_nodelist *ndlp, *next_ndlp;
1180 1176
1181 /* clean up phba - lpfc specific */ 1177 /* clean up phba - lpfc specific */
1182 lpfc_can_disctmo(phba); 1178 lpfc_can_disctmo(phba);
1183 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list, 1179 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp)
1184 nlp_listp) { 1180 lpfc_nlp_put(ndlp);
1185 lpfc_nlp_remove(phba, ndlp);
1186 }
1187 1181
1188 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list, 1182 INIT_LIST_HEAD(&phba->fc_nodes);
1189 nlp_listp) {
1190 lpfc_nlp_remove(phba, ndlp);
1191 }
1192
1193 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list,
1194 nlp_listp) {
1195 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
1196 }
1197
1198 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
1199 nlp_listp) {
1200 lpfc_nlp_remove(phba, ndlp);
1201 }
1202
1203 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
1204 nlp_listp) {
1205 lpfc_nlp_remove(phba, ndlp);
1206 }
1207
1208 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list,
1209 nlp_listp) {
1210 lpfc_nlp_remove(phba, ndlp);
1211 }
1212 1183
1213 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list,
1214 nlp_listp) {
1215 lpfc_nlp_remove(phba, ndlp);
1216 }
1217
1218 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
1219 nlp_listp) {
1220 lpfc_nlp_remove(phba, ndlp);
1221 }
1222
1223 INIT_LIST_HEAD(&phba->fc_nlpmap_list);
1224 INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
1225 INIT_LIST_HEAD(&phba->fc_unused_list);
1226 INIT_LIST_HEAD(&phba->fc_plogi_list);
1227 INIT_LIST_HEAD(&phba->fc_adisc_list);
1228 INIT_LIST_HEAD(&phba->fc_reglogin_list);
1229 INIT_LIST_HEAD(&phba->fc_prli_list);
1230 INIT_LIST_HEAD(&phba->fc_npr_list);
1231
1232 phba->fc_map_cnt = 0;
1233 phba->fc_unmap_cnt = 0;
1234 phba->fc_plogi_cnt = 0;
1235 phba->fc_adisc_cnt = 0;
1236 phba->fc_reglogin_cnt = 0;
1237 phba->fc_prli_cnt = 0;
1238 phba->fc_npr_cnt = 0;
1239 phba->fc_unused_cnt= 0;
1240 return; 1184 return;
1241} 1185}
1242 1186
@@ -1262,21 +1206,6 @@ lpfc_stop_timer(struct lpfc_hba * phba)
1262{ 1206{
1263 struct lpfc_sli *psli = &phba->sli; 1207 struct lpfc_sli *psli = &phba->sli;
1264 1208
1265 /* Instead of a timer, this has been converted to a
1266 * deferred procedding list.
1267 */
1268 while (!list_empty(&phba->freebufList)) {
1269
1270 struct lpfc_dmabuf *mp = NULL;
1271
1272 list_remove_head((&phba->freebufList), mp,
1273 struct lpfc_dmabuf, list);
1274 if (mp) {
1275 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1276 kfree(mp);
1277 }
1278 }
1279
1280 del_timer_sync(&phba->fcp_poll_timer); 1209 del_timer_sync(&phba->fcp_poll_timer);
1281 del_timer_sync(&phba->fc_estabtmo); 1210 del_timer_sync(&phba->fc_estabtmo);
1282 del_timer_sync(&phba->fc_disctmo); 1211 del_timer_sync(&phba->fc_disctmo);
@@ -1302,60 +1231,76 @@ lpfc_online(struct lpfc_hba * phba)
1302 "%d:0458 Bring Adapter online\n", 1231 "%d:0458 Bring Adapter online\n",
1303 phba->brd_no); 1232 phba->brd_no);
1304 1233
1305 if (!lpfc_sli_queue_setup(phba)) 1234 lpfc_block_mgmt_io(phba);
1235
1236 if (!lpfc_sli_queue_setup(phba)) {
1237 lpfc_unblock_mgmt_io(phba);
1306 return 1; 1238 return 1;
1239 }
1307 1240
1308 if (lpfc_sli_hba_setup(phba)) /* Initialize the HBA */ 1241 if (lpfc_sli_hba_setup(phba)) { /* Initialize the HBA */
1242 lpfc_unblock_mgmt_io(phba);
1309 return 1; 1243 return 1;
1244 }
1310 1245
1311 spin_lock_irq(phba->host->host_lock); 1246 spin_lock_irq(phba->host->host_lock);
1312 phba->fc_flag &= ~FC_OFFLINE_MODE; 1247 phba->fc_flag &= ~FC_OFFLINE_MODE;
1313 spin_unlock_irq(phba->host->host_lock); 1248 spin_unlock_irq(phba->host->host_lock);
1314 1249
1250 lpfc_unblock_mgmt_io(phba);
1315 return 0; 1251 return 0;
1316} 1252}
1317 1253
1318int 1254void
1319lpfc_offline(struct lpfc_hba * phba) 1255lpfc_block_mgmt_io(struct lpfc_hba * phba)
1320{ 1256{
1321 struct lpfc_sli_ring *pring;
1322 struct lpfc_sli *psli;
1323 unsigned long iflag; 1257 unsigned long iflag;
1324 int i;
1325 int cnt = 0;
1326 1258
1327 if (!phba) 1259 spin_lock_irqsave(phba->host->host_lock, iflag);
1328 return 0; 1260 phba->fc_flag |= FC_BLOCK_MGMT_IO;
1261 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1262}
1263
1264void
1265lpfc_unblock_mgmt_io(struct lpfc_hba * phba)
1266{
1267 unsigned long iflag;
1268
1269 spin_lock_irqsave(phba->host->host_lock, iflag);
1270 phba->fc_flag &= ~FC_BLOCK_MGMT_IO;
1271 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1272}
1273
1274void
1275lpfc_offline_prep(struct lpfc_hba * phba)
1276{
1277 struct lpfc_nodelist *ndlp, *next_ndlp;
1329 1278
1330 if (phba->fc_flag & FC_OFFLINE_MODE) 1279 if (phba->fc_flag & FC_OFFLINE_MODE)
1331 return 0; 1280 return;
1332 1281
1333 psli = &phba->sli; 1282 lpfc_block_mgmt_io(phba);
1334 1283
1335 lpfc_linkdown(phba); 1284 lpfc_linkdown(phba);
1285
1286 /* Issue an unreg_login to all nodes */
1287 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nodes, nlp_listp)
1288 if (ndlp->nlp_state != NLP_STE_UNUSED_NODE)
1289 lpfc_unreg_rpi(phba, ndlp);
1290
1336 lpfc_sli_flush_mbox_queue(phba); 1291 lpfc_sli_flush_mbox_queue(phba);
1292}
1337 1293
1338 for (i = 0; i < psli->num_rings; i++) { 1294void
1339 pring = &psli->ring[i]; 1295lpfc_offline(struct lpfc_hba * phba)
1340 /* The linkdown event takes 30 seconds to timeout. */ 1296{
1341 while (pring->txcmplq_cnt) { 1297 unsigned long iflag;
1342 mdelay(10);
1343 if (cnt++ > 3000) {
1344 lpfc_printf_log(phba,
1345 KERN_WARNING, LOG_INIT,
1346 "%d:0466 Outstanding IO when "
1347 "bringing Adapter offline\n",
1348 phba->brd_no);
1349 break;
1350 }
1351 }
1352 }
1353 1298
1299 if (phba->fc_flag & FC_OFFLINE_MODE)
1300 return;
1354 1301
1355 /* stop all timers associated with this hba */ 1302 /* stop all timers associated with this hba */
1356 lpfc_stop_timer(phba); 1303 lpfc_stop_timer(phba);
1357 phba->work_hba_events = 0;
1358 phba->work_ha = 0;
1359 1304
1360 lpfc_printf_log(phba, 1305 lpfc_printf_log(phba,
1361 KERN_WARNING, 1306 KERN_WARNING,
@@ -1366,11 +1311,12 @@ lpfc_offline(struct lpfc_hba * phba)
1366 /* Bring down the SLI Layer and cleanup. The HBA is offline 1311 /* Bring down the SLI Layer and cleanup. The HBA is offline
1367 now. */ 1312 now. */
1368 lpfc_sli_hba_down(phba); 1313 lpfc_sli_hba_down(phba);
1369 lpfc_cleanup(phba, 1); 1314 lpfc_cleanup(phba);
1370 spin_lock_irqsave(phba->host->host_lock, iflag); 1315 spin_lock_irqsave(phba->host->host_lock, iflag);
1316 phba->work_hba_events = 0;
1317 phba->work_ha = 0;
1371 phba->fc_flag |= FC_OFFLINE_MODE; 1318 phba->fc_flag |= FC_OFFLINE_MODE;
1372 spin_unlock_irqrestore(phba->host->host_lock, iflag); 1319 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1373 return 0;
1374} 1320}
1375 1321
1376/****************************************************************************** 1322/******************************************************************************
@@ -1407,6 +1353,156 @@ lpfc_scsi_free(struct lpfc_hba * phba)
1407 return 0; 1353 return 0;
1408} 1354}
1409 1355
1356void lpfc_remove_device(struct lpfc_hba *phba)
1357{
1358 unsigned long iflag;
1359
1360 lpfc_free_sysfs_attr(phba);
1361
1362 spin_lock_irqsave(phba->host->host_lock, iflag);
1363 phba->fc_flag |= FC_UNLOADING;
1364
1365 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1366
1367 fc_remove_host(phba->host);
1368 scsi_remove_host(phba->host);
1369
1370 kthread_stop(phba->worker_thread);
1371
1372 /*
1373 * Bring down the SLI Layer. This step disable all interrupts,
1374 * clears the rings, discards all mailbox commands, and resets
1375 * the HBA.
1376 */
1377 lpfc_sli_hba_down(phba);
1378 lpfc_sli_brdrestart(phba);
1379
1380 /* Release the irq reservation */
1381 free_irq(phba->pcidev->irq, phba);
1382 pci_disable_msi(phba->pcidev);
1383
1384 lpfc_cleanup(phba);
1385 lpfc_stop_timer(phba);
1386 phba->work_hba_events = 0;
1387
1388 /*
1389 * Call scsi_free before mem_free since scsi bufs are released to their
1390 * corresponding pools here.
1391 */
1392 lpfc_scsi_free(phba);
1393 lpfc_mem_free(phba);
1394
1395 /* Free resources associated with SLI2 interface */
1396 dma_free_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE,
1397 phba->slim2p, phba->slim2p_mapping);
1398
1399 /* unmap adapter SLIM and Control Registers */
1400 iounmap(phba->ctrl_regs_memmap_p);
1401 iounmap(phba->slim_memmap_p);
1402
1403 pci_release_regions(phba->pcidev);
1404 pci_disable_device(phba->pcidev);
1405
1406 idr_remove(&lpfc_hba_index, phba->brd_no);
1407 scsi_host_put(phba->host);
1408}
1409
1410void lpfc_scan_start(struct Scsi_Host *host)
1411{
1412 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
1413
1414 if (lpfc_alloc_sysfs_attr(phba))
1415 goto error;
1416
1417 phba->MBslimaddr = phba->slim_memmap_p;
1418 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET;
1419 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET;
1420 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET;
1421 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET;
1422
1423 if (lpfc_sli_hba_setup(phba))
1424 goto error;
1425
1426 /*
1427 * hba setup may have changed the hba_queue_depth so we need to adjust
1428 * the value of can_queue.
1429 */
1430 host->can_queue = phba->cfg_hba_queue_depth - 10;
1431 return;
1432
1433error:
1434 lpfc_remove_device(phba);
1435}
1436
1437int lpfc_scan_finished(struct Scsi_Host *shost, unsigned long time)
1438{
1439 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata;
1440
1441 if (!phba->host)
1442 return 1;
1443 if (time >= 30 * HZ)
1444 goto finished;
1445
1446 if (phba->hba_state != LPFC_HBA_READY)
1447 return 0;
1448 if (phba->num_disc_nodes || phba->fc_prli_sent)
1449 return 0;
1450 if ((phba->fc_map_cnt == 0) && (time < 2 * HZ))
1451 return 0;
1452 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE)
1453 return 0;
1454 if ((phba->hba_state > LPFC_LINK_DOWN) || (time < 15 * HZ))
1455 return 0;
1456
1457finished:
1458 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
1459 spin_lock_irq(shost->host_lock);
1460 lpfc_poll_start_timer(phba);
1461 spin_unlock_irq(shost->host_lock);
1462 }
1463
1464 /*
1465 * set fixed host attributes
1466 * Must done after lpfc_sli_hba_setup()
1467 */
1468
1469 fc_host_node_name(shost) = wwn_to_u64(phba->fc_nodename.u.wwn);
1470 fc_host_port_name(shost) = wwn_to_u64(phba->fc_portname.u.wwn);
1471 fc_host_supported_classes(shost) = FC_COS_CLASS3;
1472
1473 memset(fc_host_supported_fc4s(shost), 0,
1474 sizeof(fc_host_supported_fc4s(shost)));
1475 fc_host_supported_fc4s(shost)[2] = 1;
1476 fc_host_supported_fc4s(shost)[7] = 1;
1477
1478 lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(shost));
1479
1480 fc_host_supported_speeds(shost) = 0;
1481 if (phba->lmt & LMT_10Gb)
1482 fc_host_supported_speeds(shost) |= FC_PORTSPEED_10GBIT;
1483 if (phba->lmt & LMT_4Gb)
1484 fc_host_supported_speeds(shost) |= FC_PORTSPEED_4GBIT;
1485 if (phba->lmt & LMT_2Gb)
1486 fc_host_supported_speeds(shost) |= FC_PORTSPEED_2GBIT;
1487 if (phba->lmt & LMT_1Gb)
1488 fc_host_supported_speeds(shost) |= FC_PORTSPEED_1GBIT;
1489
1490 fc_host_maxframe_size(shost) =
1491 ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) |
1492 (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb);
1493
1494 /* This value is also unchanging */
1495 memset(fc_host_active_fc4s(shost), 0,
1496 sizeof(fc_host_active_fc4s(shost)));
1497 fc_host_active_fc4s(shost)[2] = 1;
1498 fc_host_active_fc4s(shost)[7] = 1;
1499
1500 spin_lock_irq(shost->host_lock);
1501 phba->fc_flag &= ~FC_LOADING;
1502 spin_unlock_irq(shost->host_lock);
1503
1504 return 1;
1505}
1410 1506
1411static int __devinit 1507static int __devinit
1412lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) 1508lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
@@ -1445,9 +1541,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1445 goto out_put_host; 1541 goto out_put_host;
1446 1542
1447 host->unique_id = phba->brd_no; 1543 host->unique_id = phba->brd_no;
1448 INIT_LIST_HEAD(&phba->ctrspbuflist);
1449 INIT_LIST_HEAD(&phba->rnidrspbuflist);
1450 INIT_LIST_HEAD(&phba->freebufList);
1451 1544
1452 /* Initialize timers used by driver */ 1545 /* Initialize timers used by driver */
1453 init_timer(&phba->fc_estabtmo); 1546 init_timer(&phba->fc_estabtmo);
@@ -1482,16 +1575,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1482 host->max_lun = phba->cfg_max_luns; 1575 host->max_lun = phba->cfg_max_luns;
1483 host->this_id = -1; 1576 host->this_id = -1;
1484 1577
1485 /* Initialize all internally managed lists. */ 1578 INIT_LIST_HEAD(&phba->fc_nodes);
1486 INIT_LIST_HEAD(&phba->fc_nlpmap_list);
1487 INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
1488 INIT_LIST_HEAD(&phba->fc_unused_list);
1489 INIT_LIST_HEAD(&phba->fc_plogi_list);
1490 INIT_LIST_HEAD(&phba->fc_adisc_list);
1491 INIT_LIST_HEAD(&phba->fc_reglogin_list);
1492 INIT_LIST_HEAD(&phba->fc_prli_list);
1493 INIT_LIST_HEAD(&phba->fc_npr_list);
1494
1495 1579
1496 pci_set_master(pdev); 1580 pci_set_master(pdev);
1497 retval = pci_set_mwi(pdev); 1581 retval = pci_set_mwi(pdev);
@@ -1609,13 +1693,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1609 1693
1610 host->transportt = lpfc_transport_template; 1694 host->transportt = lpfc_transport_template;
1611 pci_set_drvdata(pdev, host); 1695 pci_set_drvdata(pdev, host);
1612 error = scsi_add_host(host, &pdev->dev);
1613 if (error)
1614 goto out_kthread_stop;
1615
1616 error = lpfc_alloc_sysfs_attr(phba);
1617 if (error)
1618 goto out_remove_host;
1619 1696
1620 if (phba->cfg_use_msi) { 1697 if (phba->cfg_use_msi) {
1621 error = pci_enable_msi(phba->pcidev); 1698 error = pci_enable_msi(phba->pcidev);
@@ -1631,73 +1708,15 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1631 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1708 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1632 "%d:0451 Enable interrupt handler failed\n", 1709 "%d:0451 Enable interrupt handler failed\n",
1633 phba->brd_no); 1710 phba->brd_no);
1634 goto out_free_sysfs_attr; 1711 goto out_kthread_stop;
1635 } 1712 }
1636 phba->MBslimaddr = phba->slim_memmap_p;
1637 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET;
1638 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET;
1639 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET;
1640 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET;
1641 1713
1642 error = lpfc_sli_hba_setup(phba); 1714 error = scsi_add_host(host, &pdev->dev);
1643 if (error) { 1715 if (error)
1644 error = -ENODEV;
1645 goto out_free_irq; 1716 goto out_free_irq;
1646 }
1647
1648 /*
1649 * hba setup may have changed the hba_queue_depth so we need to adjust
1650 * the value of can_queue.
1651 */
1652 host->can_queue = phba->cfg_hba_queue_depth - 10;
1653
1654 lpfc_discovery_wait(phba);
1655 1717
1656 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { 1718 scsi_scan_host(host);
1657 spin_lock_irq(phba->host->host_lock);
1658 lpfc_poll_start_timer(phba);
1659 spin_unlock_irq(phba->host->host_lock);
1660 }
1661 1719
1662 /*
1663 * set fixed host attributes
1664 * Must done after lpfc_sli_hba_setup()
1665 */
1666
1667 fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn);
1668 fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn);
1669 fc_host_supported_classes(host) = FC_COS_CLASS3;
1670
1671 memset(fc_host_supported_fc4s(host), 0,
1672 sizeof(fc_host_supported_fc4s(host)));
1673 fc_host_supported_fc4s(host)[2] = 1;
1674 fc_host_supported_fc4s(host)[7] = 1;
1675
1676 lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host));
1677
1678 fc_host_supported_speeds(host) = 0;
1679 if (phba->lmt & LMT_10Gb)
1680 fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT;
1681 if (phba->lmt & LMT_4Gb)
1682 fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT;
1683 if (phba->lmt & LMT_2Gb)
1684 fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT;
1685 if (phba->lmt & LMT_1Gb)
1686 fc_host_supported_speeds(host) |= FC_PORTSPEED_1GBIT;
1687
1688 fc_host_maxframe_size(host) =
1689 ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) |
1690 (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb);
1691
1692 /* This value is also unchanging */
1693 memset(fc_host_active_fc4s(host), 0,
1694 sizeof(fc_host_active_fc4s(host)));
1695 fc_host_active_fc4s(host)[2] = 1;
1696 fc_host_active_fc4s(host)[7] = 1;
1697
1698 spin_lock_irq(phba->host->host_lock);
1699 phba->fc_flag &= ~FC_LOADING;
1700 spin_unlock_irq(phba->host->host_lock);
1701 return 0; 1720 return 0;
1702 1721
1703out_free_irq: 1722out_free_irq:
@@ -1705,11 +1724,6 @@ out_free_irq:
1705 phba->work_hba_events = 0; 1724 phba->work_hba_events = 0;
1706 free_irq(phba->pcidev->irq, phba); 1725 free_irq(phba->pcidev->irq, phba);
1707 pci_disable_msi(phba->pcidev); 1726 pci_disable_msi(phba->pcidev);
1708out_free_sysfs_attr:
1709 lpfc_free_sysfs_attr(phba);
1710out_remove_host:
1711 fc_remove_host(phba->host);
1712 scsi_remove_host(phba->host);
1713out_kthread_stop: 1727out_kthread_stop:
1714 kthread_stop(phba->worker_thread); 1728 kthread_stop(phba->worker_thread);
1715out_free_iocbq: 1729out_free_iocbq:
@@ -1747,56 +1761,8 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
1747{ 1761{
1748 struct Scsi_Host *host = pci_get_drvdata(pdev); 1762 struct Scsi_Host *host = pci_get_drvdata(pdev);
1749 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; 1763 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata;
1750 unsigned long iflag;
1751
1752 lpfc_free_sysfs_attr(phba);
1753
1754 spin_lock_irqsave(phba->host->host_lock, iflag);
1755 phba->fc_flag |= FC_UNLOADING;
1756
1757 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1758 1764
1759 fc_remove_host(phba->host); 1765 lpfc_remove_device(phba);
1760 scsi_remove_host(phba->host);
1761
1762 kthread_stop(phba->worker_thread);
1763
1764 /*
1765 * Bring down the SLI Layer. This step disable all interrupts,
1766 * clears the rings, discards all mailbox commands, and resets
1767 * the HBA.
1768 */
1769 lpfc_sli_hba_down(phba);
1770 lpfc_sli_brdrestart(phba);
1771
1772 /* Release the irq reservation */
1773 free_irq(phba->pcidev->irq, phba);
1774 pci_disable_msi(phba->pcidev);
1775
1776 lpfc_cleanup(phba, 0);
1777 lpfc_stop_timer(phba);
1778 phba->work_hba_events = 0;
1779
1780 /*
1781 * Call scsi_free before mem_free since scsi bufs are released to their
1782 * corresponding pools here.
1783 */
1784 lpfc_scsi_free(phba);
1785 lpfc_mem_free(phba);
1786
1787 /* Free resources associated with SLI2 interface */
1788 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE,
1789 phba->slim2p, phba->slim2p_mapping);
1790
1791 /* unmap adapter SLIM and Control Registers */
1792 iounmap(phba->ctrl_regs_memmap_p);
1793 iounmap(phba->slim_memmap_p);
1794
1795 pci_release_regions(phba->pcidev);
1796 pci_disable_device(phba->pcidev);
1797
1798 idr_remove(&lpfc_hba_index, phba->brd_no);
1799 scsi_host_put(phba->host);
1800 1766
1801 pci_set_drvdata(pdev, NULL); 1767 pci_set_drvdata(pdev, NULL);
1802} 1768}
@@ -1941,6 +1907,18 @@ static struct pci_device_id lpfc_id_table[] = {
1941 PCI_ANY_ID, PCI_ANY_ID, }, 1907 PCI_ANY_ID, PCI_ANY_ID, },
1942 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, 1908 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S,
1943 PCI_ANY_ID, PCI_ANY_ID, }, 1909 PCI_ANY_ID, PCI_ANY_ID, },
1910 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT,
1911 PCI_ANY_ID, PCI_ANY_ID, },
1912 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_MID,
1913 PCI_ANY_ID, PCI_ANY_ID, },
1914 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_SMB,
1915 PCI_ANY_ID, PCI_ANY_ID, },
1916 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_DCSP,
1917 PCI_ANY_ID, PCI_ANY_ID, },
1918 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_SCSP,
1919 PCI_ANY_ID, PCI_ANY_ID, },
1920 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SAT_S,
1921 PCI_ANY_ID, PCI_ANY_ID, },
1944 { 0 } 1922 { 0 }
1945}; 1923};
1946 1924
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 4d016c2a1b26..8041c3f06f7b 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -212,6 +212,7 @@ lpfc_init_link(struct lpfc_hba * phba,
212 case LINK_SPEED_1G: 212 case LINK_SPEED_1G:
213 case LINK_SPEED_2G: 213 case LINK_SPEED_2G:
214 case LINK_SPEED_4G: 214 case LINK_SPEED_4G:
215 case LINK_SPEED_8G:
215 mb->un.varInitLnk.link_flags |= 216 mb->un.varInitLnk.link_flags |=
216 FLAGS_LINK_SPEED; 217 FLAGS_LINK_SPEED;
217 mb->un.varInitLnk.link_speed = linkspeed; 218 mb->un.varInitLnk.link_speed = linkspeed;
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 0c7e731dc45a..b309841e3846 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -168,14 +168,13 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba * phba,
168 * routine effectively results in a "software abort". 168 * routine effectively results in a "software abort".
169 */ 169 */
170int 170int
171lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, 171lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
172 int send_abts)
173{ 172{
173 LIST_HEAD(completions);
174 struct lpfc_sli *psli; 174 struct lpfc_sli *psli;
175 struct lpfc_sli_ring *pring; 175 struct lpfc_sli_ring *pring;
176 struct lpfc_iocbq *iocb, *next_iocb; 176 struct lpfc_iocbq *iocb, *next_iocb;
177 IOCB_t *icmd; 177 IOCB_t *cmd;
178 int found = 0;
179 178
180 /* Abort outstanding I/O on NPort <nlp_DID> */ 179 /* Abort outstanding I/O on NPort <nlp_DID> */
181 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 180 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
@@ -188,75 +187,39 @@ lpfc_els_abort(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
188 pring = &psli->ring[LPFC_ELS_RING]; 187 pring = &psli->ring[LPFC_ELS_RING];
189 188
190 /* First check the txq */ 189 /* First check the txq */
191 do { 190 spin_lock_irq(phba->host->host_lock);
192 found = 0; 191 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) {
193 spin_lock_irq(phba->host->host_lock); 192 /* Check to see if iocb matches the nport we are looking
194 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 193 for */
195 /* Check to see if iocb matches the nport we are looking 194 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp)) {
196 for */ 195 /* It matches, so deque and call compl with an
197 if ((lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))) { 196 error */
198 found = 1; 197 list_move_tail(&iocb->list, &completions);
199 /* It matches, so deque and call compl with an 198 pring->txq_cnt--;
200 error */
201 list_del(&iocb->list);
202 pring->txq_cnt--;
203 if (iocb->iocb_cmpl) {
204 icmd = &iocb->iocb;
205 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
206 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
207 spin_unlock_irq(phba->host->host_lock);
208 (iocb->iocb_cmpl) (phba, iocb, iocb);
209 spin_lock_irq(phba->host->host_lock);
210 } else
211 lpfc_sli_release_iocbq(phba, iocb);
212 break;
213 }
214 } 199 }
215 spin_unlock_irq(phba->host->host_lock); 200 }
216 } while (found);
217 201
218 /* Everything on txcmplq will be returned by firmware
219 * with a no rpi / linkdown / abort error. For ring 0,
220 * ELS discovery, we want to get rid of it right here.
221 */
222 /* Next check the txcmplq */ 202 /* Next check the txcmplq */
223 do { 203 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) {
224 found = 0; 204 /* Check to see if iocb matches the nport we are looking
225 spin_lock_irq(phba->host->host_lock); 205 for */
226 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, 206 if (lpfc_check_sli_ndlp(phba, pring, iocb, ndlp))
227 list) { 207 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
228 /* Check to see if iocb matches the nport we are looking 208 }
229 for */ 209 spin_unlock_irq(phba->host->host_lock);
230 if ((lpfc_check_sli_ndlp (phba, pring, iocb, ndlp))) { 210
231 found = 1; 211 while (!list_empty(&completions)) {
232 /* It matches, so deque and call compl with an 212 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
233 error */ 213 cmd = &iocb->iocb;
234 list_del(&iocb->list); 214 list_del(&iocb->list);
235 pring->txcmplq_cnt--; 215
236 216 if (iocb->iocb_cmpl) {
237 icmd = &iocb->iocb; 217 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
238 /* If the driver is completing an ELS 218 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
239 * command early, flush it out of the firmware. 219 (iocb->iocb_cmpl) (phba, iocb, iocb);
240 */ 220 } else
241 if (send_abts && 221 lpfc_sli_release_iocbq(phba, iocb);
242 (icmd->ulpCommand == CMD_ELS_REQUEST64_CR) && 222 }
243 (icmd->un.elsreq64.bdl.ulpIoTag32)) {
244 lpfc_sli_issue_abort_iotag32(phba,
245 pring, iocb);
246 }
247 if (iocb->iocb_cmpl) {
248 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
249 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
250 spin_unlock_irq(phba->host->host_lock);
251 (iocb->iocb_cmpl) (phba, iocb, iocb);
252 spin_lock_irq(phba->host->host_lock);
253 } else
254 lpfc_sli_release_iocbq(phba, iocb);
255 break;
256 }
257 }
258 spin_unlock_irq(phba->host->host_lock);
259 } while(found);
260 223
261 /* If we are delaying issuing an ELS command, cancel it */ 224 /* If we are delaying issuing an ELS command, cancel it */
262 if (ndlp->nlp_flag & NLP_DELAY_TMO) 225 if (ndlp->nlp_flag & NLP_DELAY_TMO)
@@ -390,7 +353,10 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
390 * queue this mbox command to be processed later. 353 * queue this mbox command to be processed later.
391 */ 354 */
392 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; 355 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
393 mbox->context2 = ndlp; 356 /*
357 * mbox->context2 = lpfc_nlp_get(ndlp) deferred until mailbox
358 * command issued in lpfc_cmpl_els_acc().
359 */
394 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI); 360 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);
395 361
396 /* 362 /*
@@ -404,7 +370,7 @@ lpfc_rcv_plogi(struct lpfc_hba * phba,
404 */ 370 */
405 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) { 371 if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {
406 /* software abort outstanding PLOGI */ 372 /* software abort outstanding PLOGI */
407 lpfc_els_abort(phba, ndlp, 1); 373 lpfc_els_abort(phba, ndlp);
408 } 374 }
409 375
410 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0); 376 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);
@@ -471,8 +437,7 @@ lpfc_rcv_padisc(struct lpfc_hba * phba,
471 spin_unlock_irq(phba->host->host_lock); 437 spin_unlock_irq(phba->host->host_lock);
472 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; 438 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
473 ndlp->nlp_prev_state = ndlp->nlp_state; 439 ndlp->nlp_prev_state = ndlp->nlp_state;
474 ndlp->nlp_state = NLP_STE_NPR_NODE; 440 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
475 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
476 return 0; 441 return 0;
477} 442}
478 443
@@ -502,12 +467,10 @@ lpfc_rcv_logo(struct lpfc_hba * phba,
502 467
503 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; 468 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
504 ndlp->nlp_prev_state = ndlp->nlp_state; 469 ndlp->nlp_prev_state = ndlp->nlp_state;
505 ndlp->nlp_state = NLP_STE_NPR_NODE; 470 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
506 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
507 } else { 471 } else {
508 ndlp->nlp_prev_state = ndlp->nlp_state; 472 ndlp->nlp_prev_state = ndlp->nlp_state;
509 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 473 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
510 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
511 } 474 }
512 475
513 spin_lock_irq(phba->host->host_lock); 476 spin_lock_irq(phba->host->host_lock);
@@ -601,11 +564,10 @@ lpfc_rcv_plogi_unused_node(struct lpfc_hba * phba,
601 564
602 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) { 565 if (lpfc_rcv_plogi(phba, ndlp, cmdiocb)) {
603 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; 566 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
604 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 567 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
605 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
606 return ndlp->nlp_state; 568 return ndlp->nlp_state;
607 } 569 }
608 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 570 lpfc_drop_node(phba, ndlp);
609 return NLP_STE_FREED_NODE; 571 return NLP_STE_FREED_NODE;
610} 572}
611 573
@@ -614,7 +576,7 @@ lpfc_rcv_els_unused_node(struct lpfc_hba * phba,
614 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 576 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
615{ 577{
616 lpfc_issue_els_logo(phba, ndlp, 0); 578 lpfc_issue_els_logo(phba, ndlp, 0);
617 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 579 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
618 return ndlp->nlp_state; 580 return ndlp->nlp_state;
619} 581}
620 582
@@ -630,7 +592,7 @@ lpfc_rcv_logo_unused_node(struct lpfc_hba * phba,
630 ndlp->nlp_flag |= NLP_LOGO_ACC; 592 ndlp->nlp_flag |= NLP_LOGO_ACC;
631 spin_unlock_irq(phba->host->host_lock); 593 spin_unlock_irq(phba->host->host_lock);
632 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 594 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
633 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST); 595 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
634 596
635 return ndlp->nlp_state; 597 return ndlp->nlp_state;
636} 598}
@@ -639,7 +601,7 @@ static uint32_t
639lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba, 601lpfc_cmpl_logo_unused_node(struct lpfc_hba * phba,
640 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 602 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
641{ 603{
642 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 604 lpfc_drop_node(phba, ndlp);
643 return NLP_STE_FREED_NODE; 605 return NLP_STE_FREED_NODE;
644} 606}
645 607
@@ -647,7 +609,7 @@ static uint32_t
647lpfc_device_rm_unused_node(struct lpfc_hba * phba, 609lpfc_device_rm_unused_node(struct lpfc_hba * phba,
648 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 610 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
649{ 611{
650 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 612 lpfc_drop_node(phba, ndlp);
651 return NLP_STE_FREED_NODE; 613 return NLP_STE_FREED_NODE;
652} 614}
653 615
@@ -697,7 +659,7 @@ lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba,
697 cmdiocb = (struct lpfc_iocbq *) arg; 659 cmdiocb = (struct lpfc_iocbq *) arg;
698 660
699 /* software abort outstanding PLOGI */ 661 /* software abort outstanding PLOGI */
700 lpfc_els_abort(phba, ndlp, 1); 662 lpfc_els_abort(phba, ndlp);
701 663
702 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 664 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
703 return ndlp->nlp_state; 665 return ndlp->nlp_state;
@@ -712,7 +674,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
712 cmdiocb = (struct lpfc_iocbq *) arg; 674 cmdiocb = (struct lpfc_iocbq *) arg;
713 675
714 /* software abort outstanding PLOGI */ 676 /* software abort outstanding PLOGI */
715 lpfc_els_abort(phba, ndlp, 1); 677 lpfc_els_abort(phba, ndlp);
716 678
717 if (evt == NLP_EVT_RCV_LOGO) { 679 if (evt == NLP_EVT_RCV_LOGO) {
718 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 680 lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0);
@@ -727,8 +689,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_hba * phba,
727 spin_unlock_irq(phba->host->host_lock); 689 spin_unlock_irq(phba->host->host_lock);
728 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI; 690 ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
729 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; 691 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
730 ndlp->nlp_state = NLP_STE_NPR_NODE; 692 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
731 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
732 693
733 return ndlp->nlp_state; 694 return ndlp->nlp_state;
734} 695}
@@ -803,32 +764,26 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
803 goto out; 764 goto out;
804 765
805 lpfc_unreg_rpi(phba, ndlp); 766 lpfc_unreg_rpi(phba, ndlp);
806 if (lpfc_reg_login 767 if (lpfc_reg_login(phba, irsp->un.elsreq64.remoteID, (uint8_t *) sp,
807 (phba, irsp->un.elsreq64.remoteID, 768 mbox, 0) == 0) {
808 (uint8_t *) sp, mbox, 0) == 0) {
809 switch (ndlp->nlp_DID) { 769 switch (ndlp->nlp_DID) {
810 case NameServer_DID: 770 case NameServer_DID:
811 mbox->mbox_cmpl = 771 mbox->mbox_cmpl = lpfc_mbx_cmpl_ns_reg_login;
812 lpfc_mbx_cmpl_ns_reg_login;
813 break; 772 break;
814 case FDMI_DID: 773 case FDMI_DID:
815 mbox->mbox_cmpl = 774 mbox->mbox_cmpl = lpfc_mbx_cmpl_fdmi_reg_login;
816 lpfc_mbx_cmpl_fdmi_reg_login;
817 break; 775 break;
818 default: 776 default:
819 mbox->mbox_cmpl = 777 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
820 lpfc_mbx_cmpl_reg_login;
821 } 778 }
822 mbox->context2 = ndlp; 779 mbox->context2 = lpfc_nlp_get(ndlp);
823 if (lpfc_sli_issue_mbox(phba, mbox, 780 if (lpfc_sli_issue_mbox(phba, mbox,
824 (MBX_NOWAIT | MBX_STOP_IOCB)) 781 (MBX_NOWAIT | MBX_STOP_IOCB))
825 != MBX_NOT_FINISHED) { 782 != MBX_NOT_FINISHED) {
826 ndlp->nlp_state = 783 lpfc_nlp_set_state(phba, ndlp, NLP_STE_REG_LOGIN_ISSUE);
827 NLP_STE_REG_LOGIN_ISSUE;
828 lpfc_nlp_list(phba, ndlp,
829 NLP_REGLOGIN_LIST);
830 return ndlp->nlp_state; 784 return ndlp->nlp_state;
831 } 785 }
786 lpfc_nlp_put(ndlp);
832 mp = (struct lpfc_dmabuf *)mbox->context1; 787 mp = (struct lpfc_dmabuf *)mbox->context1;
833 lpfc_mbuf_free(phba, mp->virt, mp->phys); 788 lpfc_mbuf_free(phba, mp->virt, mp->phys);
834 kfree(mp); 789 kfree(mp);
@@ -841,7 +796,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
841 out: 796 out:
842 /* Free this node since the driver cannot login or has the wrong 797 /* Free this node since the driver cannot login or has the wrong
843 sparm */ 798 sparm */
844 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 799 lpfc_drop_node(phba, ndlp);
845 return NLP_STE_FREED_NODE; 800 return NLP_STE_FREED_NODE;
846} 801}
847 802
@@ -855,9 +810,9 @@ lpfc_device_rm_plogi_issue(struct lpfc_hba * phba,
855 } 810 }
856 else { 811 else {
857 /* software abort outstanding PLOGI */ 812 /* software abort outstanding PLOGI */
858 lpfc_els_abort(phba, ndlp, 1); 813 lpfc_els_abort(phba, ndlp);
859 814
860 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 815 lpfc_drop_node(phba, ndlp);
861 return NLP_STE_FREED_NODE; 816 return NLP_STE_FREED_NODE;
862 } 817 }
863} 818}
@@ -868,11 +823,10 @@ lpfc_device_recov_plogi_issue(struct lpfc_hba * phba,
868 uint32_t evt) 823 uint32_t evt)
869{ 824{
870 /* software abort outstanding PLOGI */ 825 /* software abort outstanding PLOGI */
871 lpfc_els_abort(phba, ndlp, 1); 826 lpfc_els_abort(phba, ndlp);
872 827
873 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE; 828 ndlp->nlp_prev_state = NLP_STE_PLOGI_ISSUE;
874 ndlp->nlp_state = NLP_STE_NPR_NODE; 829 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
875 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
876 spin_lock_irq(phba->host->host_lock); 830 spin_lock_irq(phba->host->host_lock);
877 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 831 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
878 spin_unlock_irq(phba->host->host_lock); 832 spin_unlock_irq(phba->host->host_lock);
@@ -888,7 +842,7 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
888 struct lpfc_iocbq *cmdiocb; 842 struct lpfc_iocbq *cmdiocb;
889 843
890 /* software abort outstanding ADISC */ 844 /* software abort outstanding ADISC */
891 lpfc_els_abort(phba, ndlp, 1); 845 lpfc_els_abort(phba, ndlp);
892 846
893 cmdiocb = (struct lpfc_iocbq *) arg; 847 cmdiocb = (struct lpfc_iocbq *) arg;
894 848
@@ -896,8 +850,7 @@ lpfc_rcv_plogi_adisc_issue(struct lpfc_hba * phba,
896 return ndlp->nlp_state; 850 return ndlp->nlp_state;
897 } 851 }
898 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 852 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
899 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 853 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
900 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
901 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 854 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
902 855
903 return ndlp->nlp_state; 856 return ndlp->nlp_state;
@@ -926,7 +879,7 @@ lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba,
926 cmdiocb = (struct lpfc_iocbq *) arg; 879 cmdiocb = (struct lpfc_iocbq *) arg;
927 880
928 /* software abort outstanding ADISC */ 881 /* software abort outstanding ADISC */
929 lpfc_els_abort(phba, ndlp, 0); 882 lpfc_els_abort(phba, ndlp);
930 883
931 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 884 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
932 return ndlp->nlp_state; 885 return ndlp->nlp_state;
@@ -987,20 +940,17 @@ lpfc_cmpl_adisc_adisc_issue(struct lpfc_hba * phba,
987 memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name)); 940 memset(&ndlp->nlp_portname, 0, sizeof (struct lpfc_name));
988 941
989 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 942 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
990 ndlp->nlp_state = NLP_STE_NPR_NODE; 943 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
991 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
992 lpfc_unreg_rpi(phba, ndlp); 944 lpfc_unreg_rpi(phba, ndlp);
993 return ndlp->nlp_state; 945 return ndlp->nlp_state;
994 } 946 }
995 947
996 if (ndlp->nlp_type & NLP_FCP_TARGET) { 948 if (ndlp->nlp_type & NLP_FCP_TARGET) {
997 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 949 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
998 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 950 lpfc_nlp_set_state(phba, ndlp, NLP_STE_MAPPED_NODE);
999 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
1000 } else { 951 } else {
1001 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 952 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1002 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 953 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1003 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1004 } 954 }
1005 return ndlp->nlp_state; 955 return ndlp->nlp_state;
1006} 956}
@@ -1016,9 +966,9 @@ lpfc_device_rm_adisc_issue(struct lpfc_hba * phba,
1016 } 966 }
1017 else { 967 else {
1018 /* software abort outstanding ADISC */ 968 /* software abort outstanding ADISC */
1019 lpfc_els_abort(phba, ndlp, 1); 969 lpfc_els_abort(phba, ndlp);
1020 970
1021 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 971 lpfc_drop_node(phba, ndlp);
1022 return NLP_STE_FREED_NODE; 972 return NLP_STE_FREED_NODE;
1023 } 973 }
1024} 974}
@@ -1029,11 +979,10 @@ lpfc_device_recov_adisc_issue(struct lpfc_hba * phba,
1029 uint32_t evt) 979 uint32_t evt)
1030{ 980{
1031 /* software abort outstanding ADISC */ 981 /* software abort outstanding ADISC */
1032 lpfc_els_abort(phba, ndlp, 1); 982 lpfc_els_abort(phba, ndlp);
1033 983
1034 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE; 984 ndlp->nlp_prev_state = NLP_STE_ADISC_ISSUE;
1035 ndlp->nlp_state = NLP_STE_NPR_NODE; 985 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1036 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1037 spin_lock_irq(phba->host->host_lock); 986 spin_lock_irq(phba->host->host_lock);
1038 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 987 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1039 ndlp->nlp_flag |= NLP_NPR_ADISC; 988 ndlp->nlp_flag |= NLP_NPR_ADISC;
@@ -1074,9 +1023,36 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba,
1074 uint32_t evt) 1023 uint32_t evt)
1075{ 1024{
1076 struct lpfc_iocbq *cmdiocb; 1025 struct lpfc_iocbq *cmdiocb;
1026 LPFC_MBOXQ_t *mb;
1027 LPFC_MBOXQ_t *nextmb;
1028 struct lpfc_dmabuf *mp;
1077 1029
1078 cmdiocb = (struct lpfc_iocbq *) arg; 1030 cmdiocb = (struct lpfc_iocbq *) arg;
1079 1031
1032 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
1033 if ((mb = phba->sli.mbox_active)) {
1034 if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
1035 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1036 mb->context2 = NULL;
1037 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
1038 }
1039 }
1040
1041 spin_lock_irq(phba->host->host_lock);
1042 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) {
1043 if ((mb->mb.mbxCommand == MBX_REG_LOGIN64) &&
1044 (ndlp == (struct lpfc_nodelist *) mb->context2)) {
1045 mp = (struct lpfc_dmabuf *) (mb->context1);
1046 if (mp) {
1047 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1048 kfree(mp);
1049 }
1050 list_del(&mb->list);
1051 mempool_free(mb, phba->mbox_mem_pool);
1052 }
1053 }
1054 spin_unlock_irq(phba->host->host_lock);
1055
1080 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 1056 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1081 return ndlp->nlp_state; 1057 return ndlp->nlp_state;
1082} 1058}
@@ -1133,8 +1109,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1133 */ 1109 */
1134 if (mb->mbxStatus == MBXERR_RPI_FULL) { 1110 if (mb->mbxStatus == MBXERR_RPI_FULL) {
1135 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE; 1111 ndlp->nlp_prev_state = NLP_STE_UNUSED_NODE;
1136 ndlp->nlp_state = NLP_STE_UNUSED_NODE; 1112 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNUSED_NODE);
1137 lpfc_nlp_list(phba, ndlp, NLP_UNUSED_LIST);
1138 return ndlp->nlp_state; 1113 return ndlp->nlp_state;
1139 } 1114 }
1140 1115
@@ -1147,8 +1122,7 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1147 1122
1148 lpfc_issue_els_logo(phba, ndlp, 0); 1123 lpfc_issue_els_logo(phba, ndlp, 0);
1149 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1124 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1150 ndlp->nlp_state = NLP_STE_NPR_NODE; 1125 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1151 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1152 return ndlp->nlp_state; 1126 return ndlp->nlp_state;
1153 } 1127 }
1154 1128
@@ -1157,13 +1131,11 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_hba * phba,
1157 /* Only if we are not a fabric nport do we issue PRLI */ 1131 /* Only if we are not a fabric nport do we issue PRLI */
1158 if (!(ndlp->nlp_type & NLP_FABRIC)) { 1132 if (!(ndlp->nlp_type & NLP_FABRIC)) {
1159 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1133 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1160 ndlp->nlp_state = NLP_STE_PRLI_ISSUE; 1134 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PRLI_ISSUE);
1161 lpfc_nlp_list(phba, ndlp, NLP_PRLI_LIST);
1162 lpfc_issue_els_prli(phba, ndlp, 0); 1135 lpfc_issue_els_prli(phba, ndlp, 0);
1163 } else { 1136 } else {
1164 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1137 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1165 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1138 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1166 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1167 } 1139 }
1168 return ndlp->nlp_state; 1140 return ndlp->nlp_state;
1169} 1141}
@@ -1178,7 +1150,7 @@ lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba,
1178 return ndlp->nlp_state; 1150 return ndlp->nlp_state;
1179 } 1151 }
1180 else { 1152 else {
1181 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1153 lpfc_drop_node(phba, ndlp);
1182 return NLP_STE_FREED_NODE; 1154 return NLP_STE_FREED_NODE;
1183 } 1155 }
1184} 1156}
@@ -1189,8 +1161,7 @@ lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba,
1189 uint32_t evt) 1161 uint32_t evt)
1190{ 1162{
1191 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE; 1163 ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1192 ndlp->nlp_state = NLP_STE_NPR_NODE; 1164 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1193 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1194 spin_lock_irq(phba->host->host_lock); 1165 spin_lock_irq(phba->host->host_lock);
1195 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1166 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1196 spin_unlock_irq(phba->host->host_lock); 1167 spin_unlock_irq(phba->host->host_lock);
@@ -1230,7 +1201,7 @@ lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba,
1230 cmdiocb = (struct lpfc_iocbq *) arg; 1201 cmdiocb = (struct lpfc_iocbq *) arg;
1231 1202
1232 /* Software abort outstanding PRLI before sending acc */ 1203 /* Software abort outstanding PRLI before sending acc */
1233 lpfc_els_abort(phba, ndlp, 1); 1204 lpfc_els_abort(phba, ndlp);
1234 1205
1235 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); 1206 lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO);
1236 return ndlp->nlp_state; 1207 return ndlp->nlp_state;
@@ -1279,8 +1250,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1279 irsp = &rspiocb->iocb; 1250 irsp = &rspiocb->iocb;
1280 if (irsp->ulpStatus) { 1251 if (irsp->ulpStatus) {
1281 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1252 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1282 ndlp->nlp_state = NLP_STE_UNMAPPED_NODE; 1253 lpfc_nlp_set_state(phba, ndlp, NLP_STE_UNMAPPED_NODE);
1283 lpfc_nlp_list(phba, ndlp, NLP_UNMAPPED_LIST);
1284 return ndlp->nlp_state; 1254 return ndlp->nlp_state;
1285 } 1255 }
1286 1256
@@ -1298,8 +1268,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_hba * phba,
1298 } 1268 }
1299 1269
1300 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1270 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1301 ndlp->nlp_state = NLP_STE_MAPPED_NODE; 1271 lpfc_nlp_set_state(phba, ndlp, NLP_STE_MAPPED_NODE);
1302 lpfc_nlp_list(phba, ndlp, NLP_MAPPED_LIST);
1303 return ndlp->nlp_state; 1272 return ndlp->nlp_state;
1304} 1273}
1305 1274
@@ -1330,9 +1299,9 @@ lpfc_device_rm_prli_issue(struct lpfc_hba * phba,
1330 } 1299 }
1331 else { 1300 else {
1332 /* software abort outstanding PLOGI */ 1301 /* software abort outstanding PLOGI */
1333 lpfc_els_abort(phba, ndlp, 1); 1302 lpfc_els_abort(phba, ndlp);
1334 1303
1335 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1304 lpfc_drop_node(phba, ndlp);
1336 return NLP_STE_FREED_NODE; 1305 return NLP_STE_FREED_NODE;
1337 } 1306 }
1338} 1307}
@@ -1359,11 +1328,10 @@ lpfc_device_recov_prli_issue(struct lpfc_hba * phba,
1359 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 1328 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1360{ 1329{
1361 /* software abort outstanding PRLI */ 1330 /* software abort outstanding PRLI */
1362 lpfc_els_abort(phba, ndlp, 1); 1331 lpfc_els_abort(phba, ndlp);
1363 1332
1364 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1333 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
1365 ndlp->nlp_state = NLP_STE_NPR_NODE; 1334 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1366 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1367 spin_lock_irq(phba->host->host_lock); 1335 spin_lock_irq(phba->host->host_lock);
1368 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1336 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1369 spin_unlock_irq(phba->host->host_lock); 1337 spin_unlock_irq(phba->host->host_lock);
@@ -1436,8 +1404,7 @@ lpfc_device_recov_unmap_node(struct lpfc_hba * phba,
1436 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) 1404 struct lpfc_nodelist * ndlp, void *arg, uint32_t evt)
1437{ 1405{
1438 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE; 1406 ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE;
1439 ndlp->nlp_state = NLP_STE_NPR_NODE; 1407 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1440 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1441 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1408 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1442 lpfc_disc_set_adisc(phba, ndlp); 1409 lpfc_disc_set_adisc(phba, ndlp);
1443 1410
@@ -1518,8 +1485,7 @@ lpfc_device_recov_mapped_node(struct lpfc_hba * phba,
1518 uint32_t evt) 1485 uint32_t evt)
1519{ 1486{
1520 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE; 1487 ndlp->nlp_prev_state = NLP_STE_MAPPED_NODE;
1521 ndlp->nlp_state = NLP_STE_NPR_NODE; 1488 lpfc_nlp_set_state(phba, ndlp, NLP_STE_NPR_NODE);
1522 lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST);
1523 spin_lock_irq(phba->host->host_lock); 1489 spin_lock_irq(phba->host->host_lock);
1524 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); 1490 ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC);
1525 spin_unlock_irq(phba->host->host_lock); 1491 spin_unlock_irq(phba->host->host_lock);
@@ -1551,8 +1517,7 @@ lpfc_rcv_plogi_npr_node(struct lpfc_hba * phba,
1551 /* send PLOGI immediately, move to PLOGI issue state */ 1517 /* send PLOGI immediately, move to PLOGI issue state */
1552 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) { 1518 if (!(ndlp->nlp_flag & NLP_DELAY_TMO)) {
1553 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1519 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1554 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1520 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1555 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1556 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 1521 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1557 } 1522 }
1558 1523
@@ -1580,16 +1545,13 @@ lpfc_rcv_prli_npr_node(struct lpfc_hba * phba,
1580 ndlp->nlp_flag &= ~NLP_NPR_ADISC; 1545 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
1581 spin_unlock_irq(phba->host->host_lock); 1546 spin_unlock_irq(phba->host->host_lock);
1582 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1547 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1583 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1548 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1584 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1585 lpfc_issue_els_adisc(phba, ndlp, 0); 1549 lpfc_issue_els_adisc(phba, ndlp, 0);
1586 } else { 1550 } else {
1587 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1551 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1588 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1552 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1589 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1590 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 1553 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1591 } 1554 }
1592
1593 } 1555 }
1594 return ndlp->nlp_state; 1556 return ndlp->nlp_state;
1595} 1557}
@@ -1627,13 +1589,11 @@ lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
1627 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){ 1589 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
1628 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 1590 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1629 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1591 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1630 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1592 lpfc_nlp_set_state(phba, ndlp, NLP_STE_ADISC_ISSUE);
1631 lpfc_nlp_list(phba, ndlp, NLP_ADISC_LIST);
1632 lpfc_issue_els_adisc(phba, ndlp, 0); 1593 lpfc_issue_els_adisc(phba, ndlp, 0);
1633 } else { 1594 } else {
1634 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1595 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1635 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 1596 lpfc_nlp_set_state(phba, ndlp, NLP_STE_PLOGI_ISSUE);
1636 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
1637 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0); 1597 lpfc_issue_els_plogi(phba, ndlp->nlp_DID, 0);
1638 } 1598 }
1639 } 1599 }
@@ -1682,7 +1642,7 @@ lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba,
1682 1642
1683 irsp = &rspiocb->iocb; 1643 irsp = &rspiocb->iocb;
1684 if (irsp->ulpStatus) { 1644 if (irsp->ulpStatus) {
1685 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1645 lpfc_drop_node(phba, ndlp);
1686 return NLP_STE_FREED_NODE; 1646 return NLP_STE_FREED_NODE;
1687 } 1647 }
1688 return ndlp->nlp_state; 1648 return ndlp->nlp_state;
@@ -1700,7 +1660,7 @@ lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba,
1700 1660
1701 irsp = &rspiocb->iocb; 1661 irsp = &rspiocb->iocb;
1702 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) { 1662 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
1703 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1663 lpfc_drop_node(phba, ndlp);
1704 return NLP_STE_FREED_NODE; 1664 return NLP_STE_FREED_NODE;
1705 } 1665 }
1706 return ndlp->nlp_state; 1666 return ndlp->nlp_state;
@@ -1728,7 +1688,7 @@ lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba,
1728 1688
1729 irsp = &rspiocb->iocb; 1689 irsp = &rspiocb->iocb;
1730 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) { 1690 if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) {
1731 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1691 lpfc_drop_node(phba, ndlp);
1732 return NLP_STE_FREED_NODE; 1692 return NLP_STE_FREED_NODE;
1733 } 1693 }
1734 return ndlp->nlp_state; 1694 return ndlp->nlp_state;
@@ -1749,7 +1709,7 @@ lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba,
1749 ndlp->nlp_rpi = mb->un.varWords[0]; 1709 ndlp->nlp_rpi = mb->un.varWords[0];
1750 else { 1710 else {
1751 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) { 1711 if (ndlp->nlp_flag & NLP_NODEV_REMOVE) {
1752 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1712 lpfc_drop_node(phba, ndlp);
1753 return NLP_STE_FREED_NODE; 1713 return NLP_STE_FREED_NODE;
1754 } 1714 }
1755 } 1715 }
@@ -1765,7 +1725,7 @@ lpfc_device_rm_npr_node(struct lpfc_hba * phba,
1765 ndlp->nlp_flag |= NLP_NODEV_REMOVE; 1725 ndlp->nlp_flag |= NLP_NODEV_REMOVE;
1766 return ndlp->nlp_state; 1726 return ndlp->nlp_state;
1767 } 1727 }
1768 lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); 1728 lpfc_drop_node(phba, ndlp);
1769 return NLP_STE_FREED_NODE; 1729 return NLP_STE_FREED_NODE;
1770} 1730}
1771 1731
@@ -1964,7 +1924,7 @@ lpfc_disc_state_machine(struct lpfc_hba * phba,
1964 uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *, 1924 uint32_t(*func) (struct lpfc_hba *, struct lpfc_nodelist *, void *,
1965 uint32_t); 1925 uint32_t);
1966 1926
1967 ndlp->nlp_disc_refcnt++; 1927 lpfc_nlp_get(ndlp);
1968 cur_state = ndlp->nlp_state; 1928 cur_state = ndlp->nlp_state;
1969 1929
1970 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */ 1930 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
@@ -1987,18 +1947,7 @@ lpfc_disc_state_machine(struct lpfc_hba * phba,
1987 phba->brd_no, 1947 phba->brd_no,
1988 rc, ndlp->nlp_DID, ndlp->nlp_flag); 1948 rc, ndlp->nlp_DID, ndlp->nlp_flag);
1989 1949
1990 ndlp->nlp_disc_refcnt--; 1950 lpfc_nlp_put(ndlp);
1991 1951
1992 /* Check to see if ndlp removal is deferred */
1993 if ((ndlp->nlp_disc_refcnt == 0)
1994 && (ndlp->nlp_flag & NLP_DELAY_REMOVE)) {
1995 spin_lock_irq(phba->host->host_lock);
1996 ndlp->nlp_flag &= ~NLP_DELAY_REMOVE;
1997 spin_unlock_irq(phba->host->host_lock);
1998 lpfc_nlp_remove(phba, ndlp);
1999 return NLP_STE_FREED_NODE;
2000 }
2001 if (rc == NLP_STE_FREED_NODE)
2002 return NLP_STE_FREED_NODE;
2003 return rc; 1952 return rc;
2004} 1953}
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c3e68e0d8f74..9a12d05e99e4 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -146,6 +146,10 @@ lpfc_get_scsi_buf(struct lpfc_hba * phba)
146 146
147 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); 147 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);
148 list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list); 148 list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list);
149 if (lpfc_cmd) {
150 lpfc_cmd->seg_cnt = 0;
151 lpfc_cmd->nonsg_phys = 0;
152 }
149 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag); 153 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag);
150 return lpfc_cmd; 154 return lpfc_cmd;
151} 155}
@@ -288,13 +292,13 @@ lpfc_scsi_unprep_dma_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)
288} 292}
289 293
290static void 294static void
291lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd) 295lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_iocbq *rsp_iocb)
292{ 296{
293 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; 297 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
294 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd; 298 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd;
295 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; 299 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
296 struct lpfc_hba *phba = lpfc_cmd->scsi_hba; 300 struct lpfc_hba *phba = lpfc_cmd->scsi_hba;
297 uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm; 301 uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm;
298 uint32_t resp_info = fcprsp->rspStatus2; 302 uint32_t resp_info = fcprsp->rspStatus2;
299 uint32_t scsi_status = fcprsp->rspStatus3; 303 uint32_t scsi_status = fcprsp->rspStatus3;
300 uint32_t *lp; 304 uint32_t *lp;
@@ -356,6 +360,24 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
356 fcpi_parm, cmnd->cmnd[0], cmnd->underflow); 360 fcpi_parm, cmnd->cmnd[0], cmnd->underflow);
357 361
358 /* 362 /*
363 * If there is an under run check if under run reported by
364 * storage array is same as the under run reported by HBA.
365 * If this is not same, there is a dropped frame.
366 */
367 if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) &&
368 fcpi_parm &&
369 (cmnd->resid != fcpi_parm)) {
370 lpfc_printf_log(phba, KERN_WARNING,
371 LOG_FCP | LOG_FCP_ERROR,
372 "%d:0735 FCP Read Check Error and Underrun "
373 "Data: x%x x%x x%x x%x\n", phba->brd_no,
374 be32_to_cpu(fcpcmd->fcpDl),
375 cmnd->resid,
376 fcpi_parm, cmnd->cmnd[0]);
377 cmnd->resid = cmnd->request_bufflen;
378 host_status = DID_ERROR;
379 }
380 /*
359 * The cmnd->underflow is the minimum number of bytes that must 381 * The cmnd->underflow is the minimum number of bytes that must
360 * be transfered for this command. Provided a sense condition 382 * be transfered for this command. Provided a sense condition
361 * is not present, make sure the actual amount transferred is at 383 * is not present, make sure the actual amount transferred is at
@@ -435,7 +457,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
435 switch (lpfc_cmd->status) { 457 switch (lpfc_cmd->status) {
436 case IOSTAT_FCP_RSP_ERROR: 458 case IOSTAT_FCP_RSP_ERROR:
437 /* Call FCP RSP handler to determine result */ 459 /* Call FCP RSP handler to determine result */
438 lpfc_handle_fcp_err(lpfc_cmd); 460 lpfc_handle_fcp_err(lpfc_cmd,pIocbOut);
439 break; 461 break;
440 case IOSTAT_NPORT_BSY: 462 case IOSTAT_NPORT_BSY:
441 case IOSTAT_FABRIC_BSY: 463 case IOSTAT_FABRIC_BSY:
@@ -466,10 +488,10 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
466 488
467 result = cmd->result; 489 result = cmd->result;
468 sdev = cmd->device; 490 sdev = cmd->device;
491 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
469 cmd->scsi_done(cmd); 492 cmd->scsi_done(cmd);
470 493
471 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 494 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
472 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
473 lpfc_release_scsi_buf(phba, lpfc_cmd); 495 lpfc_release_scsi_buf(phba, lpfc_cmd);
474 return; 496 return;
475 } 497 }
@@ -527,7 +549,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
527 } 549 }
528 } 550 }
529 551
530 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
531 lpfc_release_scsi_buf(phba, lpfc_cmd); 552 lpfc_release_scsi_buf(phba, lpfc_cmd);
532} 553}
533 554
@@ -670,6 +691,18 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba,
670 return (1); 691 return (1);
671} 692}
672 693
694static void
695lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba,
696 struct lpfc_iocbq *cmdiocbq,
697 struct lpfc_iocbq *rspiocbq)
698{
699 struct lpfc_scsi_buf *lpfc_cmd =
700 (struct lpfc_scsi_buf *) cmdiocbq->context1;
701 if (lpfc_cmd)
702 lpfc_release_scsi_buf(phba, lpfc_cmd);
703 return;
704}
705
673static int 706static int
674lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba, 707lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,
675 unsigned tgt_id, unsigned int lun, 708 unsigned tgt_id, unsigned int lun,
@@ -706,8 +739,9 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,
706 &phba->sli.ring[phba->sli.fcp_ring], 739 &phba->sli.ring[phba->sli.fcp_ring],
707 iocbq, iocbqrsp, lpfc_cmd->timeout); 740 iocbq, iocbqrsp, lpfc_cmd->timeout);
708 if (ret != IOCB_SUCCESS) { 741 if (ret != IOCB_SUCCESS) {
742 if (ret == IOCB_TIMEDOUT)
743 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
709 lpfc_cmd->status = IOSTAT_DRIVER_REJECT; 744 lpfc_cmd->status = IOSTAT_DRIVER_REJECT;
710 ret = FAILED;
711 } else { 745 } else {
712 ret = SUCCESS; 746 ret = SUCCESS;
713 lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4]; 747 lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4];
@@ -974,7 +1008,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
974} 1008}
975 1009
976static int 1010static int
977lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) 1011lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
978{ 1012{
979 struct Scsi_Host *shost = cmnd->device->host; 1013 struct Scsi_Host *shost = cmnd->device->host;
980 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata; 1014 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata;
@@ -984,6 +1018,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
984 struct lpfc_nodelist *pnode = rdata->pnode; 1018 struct lpfc_nodelist *pnode = rdata->pnode;
985 uint32_t cmd_result = 0, cmd_status = 0; 1019 uint32_t cmd_result = 0, cmd_status = 0;
986 int ret = FAILED; 1020 int ret = FAILED;
1021 int iocb_status = IOCB_SUCCESS;
987 int cnt, loopcnt; 1022 int cnt, loopcnt;
988 1023
989 lpfc_block_error_handler(cmnd); 1024 lpfc_block_error_handler(cmnd);
@@ -995,7 +1030,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
995 */ 1030 */
996 while ( 1 ) { 1031 while ( 1 ) {
997 if (!pnode) 1032 if (!pnode)
998 return FAILED; 1033 goto out;
999 1034
1000 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { 1035 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
1001 spin_unlock_irq(phba->host->host_lock); 1036 spin_unlock_irq(phba->host->host_lock);
@@ -1013,7 +1048,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
1013 } 1048 }
1014 pnode = rdata->pnode; 1049 pnode = rdata->pnode;
1015 if (!pnode) 1050 if (!pnode)
1016 return FAILED; 1051 goto out;
1017 } 1052 }
1018 if (pnode->nlp_state == NLP_STE_MAPPED_NODE) 1053 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
1019 break; 1054 break;
@@ -1028,7 +1063,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
1028 lpfc_cmd->rdata = rdata; 1063 lpfc_cmd->rdata = rdata;
1029 1064
1030 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, cmnd->device->lun, 1065 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, cmnd->device->lun,
1031 FCP_LUN_RESET); 1066 FCP_TARGET_RESET);
1032 if (!ret) 1067 if (!ret)
1033 goto out_free_scsi_buf; 1068 goto out_free_scsi_buf;
1034 1069
@@ -1040,16 +1075,21 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
1040 goto out_free_scsi_buf; 1075 goto out_free_scsi_buf;
1041 1076
1042 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 1077 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
1043 "%d:0703 Issue LUN Reset to TGT %d LUN %d " 1078 "%d:0703 Issue target reset to TGT %d LUN %d rpi x%x "
1044 "Data: x%x x%x\n", phba->brd_no, cmnd->device->id, 1079 "nlp_flag x%x\n", phba->brd_no, cmnd->device->id,
1045 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag); 1080 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
1046 1081
1047 ret = lpfc_sli_issue_iocb_wait(phba, 1082 iocb_status = lpfc_sli_issue_iocb_wait(phba,
1048 &phba->sli.ring[phba->sli.fcp_ring], 1083 &phba->sli.ring[phba->sli.fcp_ring],
1049 iocbq, iocbqrsp, lpfc_cmd->timeout); 1084 iocbq, iocbqrsp, lpfc_cmd->timeout);
1050 if (ret == IOCB_SUCCESS)
1051 ret = SUCCESS;
1052 1085
1086 if (iocb_status == IOCB_TIMEDOUT)
1087 iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl;
1088
1089 if (iocb_status == IOCB_SUCCESS)
1090 ret = SUCCESS;
1091 else
1092 ret = iocb_status;
1053 1093
1054 cmd_result = iocbqrsp->iocb.un.ulpWord[4]; 1094 cmd_result = iocbqrsp->iocb.un.ulpWord[4];
1055 cmd_status = iocbqrsp->iocb.ulpStatus; 1095 cmd_status = iocbqrsp->iocb.ulpStatus;
@@ -1087,18 +1127,19 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
1087 1127
1088 if (cnt) { 1128 if (cnt) {
1089 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1129 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1090 "%d:0719 LUN Reset I/O flush failure: cnt x%x\n", 1130 "%d:0719 device reset I/O flush failure: cnt x%x\n",
1091 phba->brd_no, cnt); 1131 phba->brd_no, cnt);
1092 ret = FAILED; 1132 ret = FAILED;
1093 } 1133 }
1094 1134
1095out_free_scsi_buf: 1135out_free_scsi_buf:
1096 lpfc_release_scsi_buf(phba, lpfc_cmd); 1136 if (iocb_status != IOCB_TIMEDOUT) {
1097 1137 lpfc_release_scsi_buf(phba, lpfc_cmd);
1138 }
1098 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1139 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1099 "%d:0713 SCSI layer issued LUN reset (%d, %d) " 1140 "%d:0713 SCSI layer issued device reset (%d, %d) "
1100 "Data: x%x x%x x%x\n", 1141 "return x%x status x%x result x%x\n",
1101 phba->brd_no, cmnd->device->id,cmnd->device->lun, 1142 phba->brd_no, cmnd->device->id, cmnd->device->lun,
1102 ret, cmd_status, cmd_result); 1143 ret, cmd_status, cmd_result);
1103 1144
1104out: 1145out:
@@ -1107,7 +1148,7 @@ out:
1107} 1148}
1108 1149
1109static int 1150static int
1110lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) 1151lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1111{ 1152{
1112 struct Scsi_Host *shost = cmnd->device->host; 1153 struct Scsi_Host *shost = cmnd->device->host;
1113 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata; 1154 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata;
@@ -1134,10 +1175,12 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
1134 * fail, this routine returns failure to the midlayer. 1175 * fail, this routine returns failure to the midlayer.
1135 */ 1176 */
1136 for (i = 0; i < LPFC_MAX_TARGET; i++) { 1177 for (i = 0; i < LPFC_MAX_TARGET; i++) {
1137 /* Search the mapped list for this target ID */ 1178 /* Search for mapped node by target ID */
1138 match = 0; 1179 match = 0;
1139 list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) { 1180 list_for_each_entry(ndlp, &phba->fc_nodes, nlp_listp) {
1140 if ((i == ndlp->nlp_sid) && ndlp->rport) { 1181 if (ndlp->nlp_state == NLP_STE_MAPPED_NODE &&
1182 i == ndlp->nlp_sid &&
1183 ndlp->rport) {
1141 match = 1; 1184 match = 1;
1142 break; 1185 break;
1143 } 1186 }
@@ -1152,13 +1195,17 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
1152 "%d:0700 Bus Reset on target %d failed\n", 1195 "%d:0700 Bus Reset on target %d failed\n",
1153 phba->brd_no, i); 1196 phba->brd_no, i);
1154 err_count++; 1197 err_count++;
1198 break;
1155 } 1199 }
1156 } 1200 }
1157 1201
1202 if (ret != IOCB_TIMEDOUT)
1203 lpfc_release_scsi_buf(phba, lpfc_cmd);
1204
1158 if (err_count == 0) 1205 if (err_count == 0)
1159 ret = SUCCESS; 1206 ret = SUCCESS;
1160 1207 else
1161 lpfc_release_scsi_buf(phba, lpfc_cmd); 1208 ret = FAILED;
1162 1209
1163 /* 1210 /*
1164 * All outstanding txcmplq I/Os should have been aborted by 1211 * All outstanding txcmplq I/Os should have been aborted by
@@ -1299,11 +1346,13 @@ struct scsi_host_template lpfc_template = {
1299 .info = lpfc_info, 1346 .info = lpfc_info,
1300 .queuecommand = lpfc_queuecommand, 1347 .queuecommand = lpfc_queuecommand,
1301 .eh_abort_handler = lpfc_abort_handler, 1348 .eh_abort_handler = lpfc_abort_handler,
1302 .eh_device_reset_handler= lpfc_reset_lun_handler, 1349 .eh_device_reset_handler= lpfc_device_reset_handler,
1303 .eh_bus_reset_handler = lpfc_reset_bus_handler, 1350 .eh_bus_reset_handler = lpfc_bus_reset_handler,
1304 .slave_alloc = lpfc_slave_alloc, 1351 .slave_alloc = lpfc_slave_alloc,
1305 .slave_configure = lpfc_slave_configure, 1352 .slave_configure = lpfc_slave_configure,
1306 .slave_destroy = lpfc_slave_destroy, 1353 .slave_destroy = lpfc_slave_destroy,
1354 .scan_finished = lpfc_scan_finished,
1355 .scan_start = lpfc_scan_start,
1307 .this_id = -1, 1356 .this_id = -1,
1308 .sg_tablesize = LPFC_SG_SEG_CNT, 1357 .sg_tablesize = LPFC_SG_SEG_CNT,
1309 .cmd_per_lun = LPFC_CMD_PER_LUN, 1358 .cmd_per_lun = LPFC_CMD_PER_LUN,
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 9fb6960a8ada..a1e721459e2b 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
@@ -528,6 +528,7 @@ lpfc_sli_wake_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq)
528 * If pdone_q is empty, the driver thread gave up waiting and 528 * If pdone_q is empty, the driver thread gave up waiting and
529 * continued running. 529 * continued running.
530 */ 530 */
531 pmboxq->mbox_flag |= LPFC_MBX_WAKE;
531 pdone_q = (wait_queue_head_t *) pmboxq->context1; 532 pdone_q = (wait_queue_head_t *) pmboxq->context1;
532 if (pdone_q) 533 if (pdone_q)
533 wake_up_interruptible(pdone_q); 534 wake_up_interruptible(pdone_q);
@@ -538,11 +539,32 @@ void
538lpfc_sli_def_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb) 539lpfc_sli_def_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
539{ 540{
540 struct lpfc_dmabuf *mp; 541 struct lpfc_dmabuf *mp;
542 uint16_t rpi;
543 int rc;
544
541 mp = (struct lpfc_dmabuf *) (pmb->context1); 545 mp = (struct lpfc_dmabuf *) (pmb->context1);
546
542 if (mp) { 547 if (mp) {
543 lpfc_mbuf_free(phba, mp->virt, mp->phys); 548 lpfc_mbuf_free(phba, mp->virt, mp->phys);
544 kfree(mp); 549 kfree(mp);
545 } 550 }
551
552 /*
553 * If a REG_LOGIN succeeded after node is destroyed or node
554 * is in re-discovery driver need to cleanup the RPI.
555 */
556 if (!(phba->fc_flag & FC_UNLOADING) &&
557 (pmb->mb.mbxCommand == MBX_REG_LOGIN64) &&
558 (!pmb->mb.mbxStatus)) {
559
560 rpi = pmb->mb.un.varWords[0];
561 lpfc_unreg_login(phba, rpi, pmb);
562 pmb->mbox_cmpl=lpfc_sli_def_mbox_cmpl;
563 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
564 if (rc != MBX_NOT_FINISHED)
565 return;
566 }
567
546 mempool_free( pmb, phba->mbox_mem_pool); 568 mempool_free( pmb, phba->mbox_mem_pool);
547 return; 569 return;
548} 570}
@@ -693,25 +715,8 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
693 } else { 715 } else {
694 spin_unlock_irq(phba->host->host_lock); 716 spin_unlock_irq(phba->host->host_lock);
695 /* Turn on IOCB processing */ 717 /* Turn on IOCB processing */
696 for (i = 0; i < phba->sli.num_rings; i++) { 718 for (i = 0; i < phba->sli.num_rings; i++)
697 lpfc_sli_turn_on_ring(phba, i); 719 lpfc_sli_turn_on_ring(phba, i);
698 }
699
700 /* Free any lpfc_dmabuf's waiting for mbox cmd cmpls */
701 while (!list_empty(&phba->freebufList)) {
702 struct lpfc_dmabuf *mp;
703
704 mp = NULL;
705 list_remove_head((&phba->freebufList),
706 mp,
707 struct lpfc_dmabuf,
708 list);
709 if (mp) {
710 lpfc_mbuf_free(phba, mp->virt,
711 mp->phys);
712 kfree(mp);
713 }
714 }
715 } 720 }
716 721
717 } while (process_next); 722 } while (process_next);
@@ -833,6 +838,14 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
833 * All other are passed to the completion callback. 838 * All other are passed to the completion callback.
834 */ 839 */
835 if (pring->ringno == LPFC_ELS_RING) { 840 if (pring->ringno == LPFC_ELS_RING) {
841 if (cmdiocbp->iocb_flag & LPFC_DRIVER_ABORTED) {
842 cmdiocbp->iocb_flag &=
843 ~LPFC_DRIVER_ABORTED;
844 saveq->iocb.ulpStatus =
845 IOSTAT_LOCAL_REJECT;
846 saveq->iocb.un.ulpWord[4] =
847 IOERR_SLI_ABORTED;
848 }
836 spin_unlock_irqrestore(phba->host->host_lock, 849 spin_unlock_irqrestore(phba->host->host_lock,
837 iflag); 850 iflag);
838 (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); 851 (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq);
@@ -1464,8 +1477,9 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
1464int 1477int
1465lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) 1478lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
1466{ 1479{
1480 LIST_HEAD(completions);
1467 struct lpfc_iocbq *iocb, *next_iocb; 1481 struct lpfc_iocbq *iocb, *next_iocb;
1468 IOCB_t *icmd = NULL, *cmd = NULL; 1482 IOCB_t *cmd = NULL;
1469 int errcnt; 1483 int errcnt;
1470 1484
1471 errcnt = 0; 1485 errcnt = 0;
@@ -1474,46 +1488,28 @@ lpfc_sli_abort_iocb_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
1474 * First do the txq. 1488 * First do the txq.
1475 */ 1489 */
1476 spin_lock_irq(phba->host->host_lock); 1490 spin_lock_irq(phba->host->host_lock);
1477 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 1491 list_splice_init(&pring->txq, &completions);
1478 list_del_init(&iocb->list);
1479 if (iocb->iocb_cmpl) {
1480 icmd = &iocb->iocb;
1481 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
1482 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
1483 spin_unlock_irq(phba->host->host_lock);
1484 (iocb->iocb_cmpl) (phba, iocb, iocb);
1485 spin_lock_irq(phba->host->host_lock);
1486 } else
1487 lpfc_sli_release_iocbq(phba, iocb);
1488 }
1489 pring->txq_cnt = 0; 1492 pring->txq_cnt = 0;
1490 INIT_LIST_HEAD(&(pring->txq));
1491 1493
1492 /* Next issue ABTS for everything on the txcmplq */ 1494 /* Next issue ABTS for everything on the txcmplq */
1493 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) { 1495 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list)
1494 cmd = &iocb->iocb; 1496 lpfc_sli_issue_abort_iotag(phba, pring, iocb);
1495 1497
1496 /* 1498 spin_unlock_irq(phba->host->host_lock);
1497 * Imediate abort of IOCB, deque and call compl
1498 */
1499 1499
1500 list_del_init(&iocb->list); 1500 while (!list_empty(&completions)) {
1501 pring->txcmplq_cnt--; 1501 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
1502 cmd = &iocb->iocb;
1503 list_del(&iocb->list);
1502 1504
1503 if (iocb->iocb_cmpl) { 1505 if (iocb->iocb_cmpl) {
1504 cmd->ulpStatus = IOSTAT_LOCAL_REJECT; 1506 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
1505 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED; 1507 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
1506 spin_unlock_irq(phba->host->host_lock);
1507 (iocb->iocb_cmpl) (phba, iocb, iocb); 1508 (iocb->iocb_cmpl) (phba, iocb, iocb);
1508 spin_lock_irq(phba->host->host_lock);
1509 } else 1509 } else
1510 lpfc_sli_release_iocbq(phba, iocb); 1510 lpfc_sli_release_iocbq(phba, iocb);
1511 } 1511 }
1512 1512
1513 INIT_LIST_HEAD(&pring->txcmplq);
1514 pring->txcmplq_cnt = 0;
1515 spin_unlock_irq(phba->host->host_lock);
1516
1517 return errcnt; 1513 return errcnt;
1518} 1514}
1519 1515
@@ -1588,6 +1584,7 @@ void lpfc_reset_barrier(struct lpfc_hba * phba)
1588 hc_copy = readl(phba->HCregaddr); 1584 hc_copy = readl(phba->HCregaddr);
1589 writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); 1585 writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr);
1590 readl(phba->HCregaddr); /* flush */ 1586 readl(phba->HCregaddr); /* flush */
1587 phba->fc_flag |= FC_IGNORE_ERATT;
1591 1588
1592 if (readl(phba->HAregaddr) & HA_ERATT) { 1589 if (readl(phba->HAregaddr) & HA_ERATT) {
1593 /* Clear Chip error bit */ 1590 /* Clear Chip error bit */
@@ -1630,6 +1627,7 @@ clear_errat:
1630 } 1627 }
1631 1628
1632restore_hc: 1629restore_hc:
1630 phba->fc_flag &= ~FC_IGNORE_ERATT;
1633 writel(hc_copy, phba->HCregaddr); 1631 writel(hc_copy, phba->HCregaddr);
1634 readl(phba->HCregaddr); /* flush */ 1632 readl(phba->HCregaddr); /* flush */
1635} 1633}
@@ -1665,6 +1663,7 @@ lpfc_sli_brdkill(struct lpfc_hba * phba)
1665 status &= ~HC_ERINT_ENA; 1663 status &= ~HC_ERINT_ENA;
1666 writel(status, phba->HCregaddr); 1664 writel(status, phba->HCregaddr);
1667 readl(phba->HCregaddr); /* flush */ 1665 readl(phba->HCregaddr); /* flush */
1666 phba->fc_flag |= FC_IGNORE_ERATT;
1668 spin_unlock_irq(phba->host->host_lock); 1667 spin_unlock_irq(phba->host->host_lock);
1669 1668
1670 lpfc_kill_board(phba, pmb); 1669 lpfc_kill_board(phba, pmb);
@@ -1674,6 +1673,9 @@ lpfc_sli_brdkill(struct lpfc_hba * phba)
1674 if (retval != MBX_SUCCESS) { 1673 if (retval != MBX_SUCCESS) {
1675 if (retval != MBX_BUSY) 1674 if (retval != MBX_BUSY)
1676 mempool_free(pmb, phba->mbox_mem_pool); 1675 mempool_free(pmb, phba->mbox_mem_pool);
1676 spin_lock_irq(phba->host->host_lock);
1677 phba->fc_flag &= ~FC_IGNORE_ERATT;
1678 spin_unlock_irq(phba->host->host_lock);
1677 return 1; 1679 return 1;
1678 } 1680 }
1679 1681
@@ -1700,6 +1702,7 @@ lpfc_sli_brdkill(struct lpfc_hba * phba)
1700 } 1702 }
1701 spin_lock_irq(phba->host->host_lock); 1703 spin_lock_irq(phba->host->host_lock);
1702 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; 1704 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
1705 phba->fc_flag &= ~FC_IGNORE_ERATT;
1703 spin_unlock_irq(phba->host->host_lock); 1706 spin_unlock_irq(phba->host->host_lock);
1704 1707
1705 psli->mbox_active = NULL; 1708 psli->mbox_active = NULL;
@@ -1985,42 +1988,6 @@ lpfc_sli_hba_setup_exit:
1985 return rc; 1988 return rc;
1986} 1989}
1987 1990
1988static void
1989lpfc_mbox_abort(struct lpfc_hba * phba)
1990{
1991 LPFC_MBOXQ_t *pmbox;
1992 MAILBOX_t *mb;
1993
1994 if (phba->sli.mbox_active) {
1995 del_timer_sync(&phba->sli.mbox_tmo);
1996 phba->work_hba_events &= ~WORKER_MBOX_TMO;
1997 pmbox = phba->sli.mbox_active;
1998 mb = &pmbox->mb;
1999 phba->sli.mbox_active = NULL;
2000 if (pmbox->mbox_cmpl) {
2001 mb->mbxStatus = MBX_NOT_FINISHED;
2002 (pmbox->mbox_cmpl) (phba, pmbox);
2003 }
2004 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
2005 }
2006
2007 /* Abort all the non active mailbox commands. */
2008 spin_lock_irq(phba->host->host_lock);
2009 pmbox = lpfc_mbox_get(phba);
2010 while (pmbox) {
2011 mb = &pmbox->mb;
2012 if (pmbox->mbox_cmpl) {
2013 mb->mbxStatus = MBX_NOT_FINISHED;
2014 spin_unlock_irq(phba->host->host_lock);
2015 (pmbox->mbox_cmpl) (phba, pmbox);
2016 spin_lock_irq(phba->host->host_lock);
2017 }
2018 pmbox = lpfc_mbox_get(phba);
2019 }
2020 spin_unlock_irq(phba->host->host_lock);
2021 return;
2022}
2023
2024/*! lpfc_mbox_timeout 1991/*! lpfc_mbox_timeout
2025 * 1992 *
2026 * \pre 1993 * \pre
@@ -2055,6 +2022,8 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
2055{ 2022{
2056 LPFC_MBOXQ_t *pmbox; 2023 LPFC_MBOXQ_t *pmbox;
2057 MAILBOX_t *mb; 2024 MAILBOX_t *mb;
2025 struct lpfc_sli *psli = &phba->sli;
2026 struct lpfc_sli_ring *pring;
2058 2027
2059 spin_lock_irq(phba->host->host_lock); 2028 spin_lock_irq(phba->host->host_lock);
2060 if (!(phba->work_hba_events & WORKER_MBOX_TMO)) { 2029 if (!(phba->work_hba_events & WORKER_MBOX_TMO)) {
@@ -2062,8 +2031,6 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
2062 return; 2031 return;
2063 } 2032 }
2064 2033
2065 phba->work_hba_events &= ~WORKER_MBOX_TMO;
2066
2067 pmbox = phba->sli.mbox_active; 2034 pmbox = phba->sli.mbox_active;
2068 mb = &pmbox->mb; 2035 mb = &pmbox->mb;
2069 2036
@@ -2078,17 +2045,32 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
2078 phba->sli.sli_flag, 2045 phba->sli.sli_flag,
2079 phba->sli.mbox_active); 2046 phba->sli.mbox_active);
2080 2047
2081 phba->sli.mbox_active = NULL; 2048 /* Setting state unknown so lpfc_sli_abort_iocb_ring
2082 if (pmbox->mbox_cmpl) { 2049 * would get IOCB_ERROR from lpfc_sli_issue_iocb, allowing
2083 mb->mbxStatus = MBX_NOT_FINISHED; 2050 * it to fail all oustanding SCSI IO.
2084 spin_unlock_irq(phba->host->host_lock); 2051 */
2085 (pmbox->mbox_cmpl) (phba, pmbox); 2052 phba->hba_state = LPFC_STATE_UNKNOWN;
2086 spin_lock_irq(phba->host->host_lock); 2053 phba->work_hba_events &= ~WORKER_MBOX_TMO;
2087 } 2054 phba->fc_flag |= FC_ESTABLISH_LINK;
2088 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; 2055 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
2089
2090 spin_unlock_irq(phba->host->host_lock); 2056 spin_unlock_irq(phba->host->host_lock);
2091 lpfc_mbox_abort(phba); 2057
2058 pring = &psli->ring[psli->fcp_ring];
2059 lpfc_sli_abort_iocb_ring(phba, pring);
2060
2061 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
2062 "%d:0316 Resetting board due to mailbox timeout\n",
2063 phba->brd_no);
2064 /*
2065 * lpfc_offline calls lpfc_sli_hba_down which will clean up
2066 * on oustanding mailbox commands.
2067 */
2068 lpfc_offline_prep(phba);
2069 lpfc_offline(phba);
2070 lpfc_sli_brdrestart(phba);
2071 if (lpfc_online(phba) == 0) /* Initialize the HBA */
2072 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
2073 lpfc_unblock_mgmt_io(phba);
2092 return; 2074 return;
2093} 2075}
2094 2076
@@ -2320,9 +2302,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
2320 spin_unlock_irqrestore(phba->host->host_lock, 2302 spin_unlock_irqrestore(phba->host->host_lock,
2321 drvr_flag); 2303 drvr_flag);
2322 2304
2323 /* Can be in interrupt context, do not sleep */ 2305 msleep(1);
2324 /* (or might be called with interrupts disabled) */
2325 mdelay(1);
2326 2306
2327 spin_lock_irqsave(phba->host->host_lock, drvr_flag); 2307 spin_lock_irqsave(phba->host->host_lock, drvr_flag);
2328 2308
@@ -2430,7 +2410,7 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2430 2410
2431 if (unlikely(phba->hba_state == LPFC_LINK_DOWN)) { 2411 if (unlikely(phba->hba_state == LPFC_LINK_DOWN)) {
2432 /* 2412 /*
2433 * Only CREATE_XRI, CLOSE_XRI, ABORT_XRI, and QUE_RING_BUF 2413 * Only CREATE_XRI, CLOSE_XRI, and QUE_RING_BUF
2434 * can be issued if the link is not up. 2414 * can be issued if the link is not up.
2435 */ 2415 */
2436 switch (piocb->iocb.ulpCommand) { 2416 switch (piocb->iocb.ulpCommand) {
@@ -2444,6 +2424,8 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2444 piocb->iocb_cmpl = NULL; 2424 piocb->iocb_cmpl = NULL;
2445 /*FALLTHROUGH*/ 2425 /*FALLTHROUGH*/
2446 case CMD_CREATE_XRI_CR: 2426 case CMD_CREATE_XRI_CR:
2427 case CMD_CLOSE_XRI_CN:
2428 case CMD_CLOSE_XRI_CX:
2447 break; 2429 break;
2448 default: 2430 default:
2449 goto iocb_busy; 2431 goto iocb_busy;
@@ -2637,11 +2619,12 @@ lpfc_sli_queue_setup(struct lpfc_hba * phba)
2637int 2619int
2638lpfc_sli_hba_down(struct lpfc_hba * phba) 2620lpfc_sli_hba_down(struct lpfc_hba * phba)
2639{ 2621{
2622 LIST_HEAD(completions);
2640 struct lpfc_sli *psli; 2623 struct lpfc_sli *psli;
2641 struct lpfc_sli_ring *pring; 2624 struct lpfc_sli_ring *pring;
2642 LPFC_MBOXQ_t *pmb; 2625 LPFC_MBOXQ_t *pmb;
2643 struct lpfc_iocbq *iocb, *next_iocb; 2626 struct lpfc_iocbq *iocb;
2644 IOCB_t *icmd = NULL; 2627 IOCB_t *cmd = NULL;
2645 int i; 2628 int i;
2646 unsigned long flags = 0; 2629 unsigned long flags = 0;
2647 2630
@@ -2649,7 +2632,6 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
2649 lpfc_hba_down_prep(phba); 2632 lpfc_hba_down_prep(phba);
2650 2633
2651 spin_lock_irqsave(phba->host->host_lock, flags); 2634 spin_lock_irqsave(phba->host->host_lock, flags);
2652
2653 for (i = 0; i < psli->num_rings; i++) { 2635 for (i = 0; i < psli->num_rings; i++) {
2654 pring = &psli->ring[i]; 2636 pring = &psli->ring[i];
2655 pring->flag |= LPFC_DEFERRED_RING_EVENT; 2637 pring->flag |= LPFC_DEFERRED_RING_EVENT;
@@ -2658,28 +2640,25 @@ lpfc_sli_hba_down(struct lpfc_hba * phba)
2658 * Error everything on the txq since these iocbs have not been 2640 * Error everything on the txq since these iocbs have not been
2659 * given to the FW yet. 2641 * given to the FW yet.
2660 */ 2642 */
2643 list_splice_init(&pring->txq, &completions);
2661 pring->txq_cnt = 0; 2644 pring->txq_cnt = 0;
2662 2645
2663 list_for_each_entry_safe(iocb, next_iocb, &pring->txq, list) { 2646 }
2664 list_del_init(&iocb->list); 2647 spin_unlock_irqrestore(phba->host->host_lock, flags);
2665 if (iocb->iocb_cmpl) {
2666 icmd = &iocb->iocb;
2667 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
2668 icmd->un.ulpWord[4] = IOERR_SLI_DOWN;
2669 spin_unlock_irqrestore(phba->host->host_lock,
2670 flags);
2671 (iocb->iocb_cmpl) (phba, iocb, iocb);
2672 spin_lock_irqsave(phba->host->host_lock, flags);
2673 } else
2674 lpfc_sli_release_iocbq(phba, iocb);
2675 }
2676 2648
2677 INIT_LIST_HEAD(&(pring->txq)); 2649 while (!list_empty(&completions)) {
2650 iocb = list_get_first(&completions, struct lpfc_iocbq, list);
2651 cmd = &iocb->iocb;
2652 list_del(&iocb->list);
2678 2653
2654 if (iocb->iocb_cmpl) {
2655 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
2656 cmd->un.ulpWord[4] = IOERR_SLI_DOWN;
2657 (iocb->iocb_cmpl) (phba, iocb, iocb);
2658 } else
2659 lpfc_sli_release_iocbq(phba, iocb);
2679 } 2660 }
2680 2661
2681 spin_unlock_irqrestore(phba->host->host_lock, flags);
2682
2683 /* Return any active mbox cmds */ 2662 /* Return any active mbox cmds */
2684 del_timer_sync(&psli->mbox_tmo); 2663 del_timer_sync(&psli->mbox_tmo);
2685 spin_lock_irqsave(phba->host->host_lock, flags); 2664 spin_lock_irqsave(phba->host->host_lock, flags);
@@ -2768,85 +2747,138 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2768} 2747}
2769 2748
2770static void 2749static void
2771lpfc_sli_abort_elsreq_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, 2750lpfc_sli_abort_els_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
2772 struct lpfc_iocbq * rspiocb) 2751 struct lpfc_iocbq * rspiocb)
2773{ 2752{
2774 struct lpfc_dmabuf *buf_ptr, *buf_ptr1; 2753 IOCB_t *irsp;
2775 /* Free the resources associated with the ELS_REQUEST64 IOCB the driver 2754 uint16_t abort_iotag, abort_context;
2776 * just aborted. 2755 struct lpfc_iocbq *abort_iocb, *rsp_ab_iocb;
2777 * In this case, context2 = cmd, context2->next = rsp, context3 = bpl 2756 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
2778 */ 2757
2779 if (cmdiocb->context2) { 2758 abort_iocb = NULL;
2780 buf_ptr1 = (struct lpfc_dmabuf *) cmdiocb->context2; 2759 irsp = &rspiocb->iocb;
2781 2760
2782 /* Free the response IOCB before completing the abort 2761 spin_lock_irq(phba->host->host_lock);
2783 command. */
2784 buf_ptr = NULL;
2785 list_remove_head((&buf_ptr1->list), buf_ptr,
2786 struct lpfc_dmabuf, list);
2787 if (buf_ptr) {
2788 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
2789 kfree(buf_ptr);
2790 }
2791 lpfc_mbuf_free(phba, buf_ptr1->virt, buf_ptr1->phys);
2792 kfree(buf_ptr1);
2793 }
2794 2762
2795 if (cmdiocb->context3) { 2763 if (irsp->ulpStatus) {
2796 buf_ptr = (struct lpfc_dmabuf *) cmdiocb->context3; 2764 abort_context = cmdiocb->iocb.un.acxri.abortContextTag;
2797 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); 2765 abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag;
2798 kfree(buf_ptr); 2766
2767 if (abort_iotag != 0 && abort_iotag <= phba->sli.last_iotag)
2768 abort_iocb = phba->sli.iocbq_lookup[abort_iotag];
2769
2770 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
2771 "%d:0327 Cannot abort els iocb %p"
2772 " with tag %x context %x\n",
2773 phba->brd_no, abort_iocb,
2774 abort_iotag, abort_context);
2775
2776 /*
2777 * make sure we have the right iocbq before taking it
2778 * off the txcmplq and try to call completion routine.
2779 */
2780 if (abort_iocb &&
2781 abort_iocb->iocb.ulpContext == abort_context &&
2782 abort_iocb->iocb_flag & LPFC_DRIVER_ABORTED) {
2783 list_del(&abort_iocb->list);
2784 pring->txcmplq_cnt--;
2785
2786 rsp_ab_iocb = lpfc_sli_get_iocbq(phba);
2787 if (rsp_ab_iocb == NULL)
2788 lpfc_sli_release_iocbq(phba, abort_iocb);
2789 else {
2790 abort_iocb->iocb_flag &=
2791 ~LPFC_DRIVER_ABORTED;
2792 rsp_ab_iocb->iocb.ulpStatus =
2793 IOSTAT_LOCAL_REJECT;
2794 rsp_ab_iocb->iocb.un.ulpWord[4] =
2795 IOERR_SLI_ABORTED;
2796 spin_unlock_irq(phba->host->host_lock);
2797 (abort_iocb->iocb_cmpl)
2798 (phba, abort_iocb, rsp_ab_iocb);
2799 spin_lock_irq(phba->host->host_lock);
2800 lpfc_sli_release_iocbq(phba, rsp_ab_iocb);
2801 }
2802 }
2799 } 2803 }
2800 2804
2801 lpfc_sli_release_iocbq(phba, cmdiocb); 2805 lpfc_sli_release_iocbq(phba, cmdiocb);
2806 spin_unlock_irq(phba->host->host_lock);
2802 return; 2807 return;
2803} 2808}
2804 2809
2805int 2810int
2806lpfc_sli_issue_abort_iotag32(struct lpfc_hba * phba, 2811lpfc_sli_issue_abort_iotag(struct lpfc_hba * phba,
2807 struct lpfc_sli_ring * pring, 2812 struct lpfc_sli_ring * pring,
2808 struct lpfc_iocbq * cmdiocb) 2813 struct lpfc_iocbq * cmdiocb)
2809{ 2814{
2810 struct lpfc_iocbq *abtsiocbp; 2815 struct lpfc_iocbq *abtsiocbp;
2811 IOCB_t *icmd = NULL; 2816 IOCB_t *icmd = NULL;
2812 IOCB_t *iabt = NULL; 2817 IOCB_t *iabt = NULL;
2818 int retval = IOCB_ERROR;
2819
2820 /* There are certain command types we don't want
2821 * to abort.
2822 */
2823 icmd = &cmdiocb->iocb;
2824 if ((icmd->ulpCommand == CMD_ABORT_XRI_CN) ||
2825 (icmd->ulpCommand == CMD_CLOSE_XRI_CN))
2826 return 0;
2827
2828 /* If we're unloading, interrupts are disabled so we
2829 * need to cleanup the iocb here.
2830 */
2831 if (phba->fc_flag & FC_UNLOADING)
2832 goto abort_iotag_exit;
2813 2833
2814 /* issue ABTS for this IOCB based on iotag */ 2834 /* issue ABTS for this IOCB based on iotag */
2815 abtsiocbp = lpfc_sli_get_iocbq(phba); 2835 abtsiocbp = lpfc_sli_get_iocbq(phba);
2816 if (abtsiocbp == NULL) 2836 if (abtsiocbp == NULL)
2817 return 0; 2837 return 0;
2818 2838
2839 /* This signals the response to set the correct status
2840 * before calling the completion handler.
2841 */
2842 cmdiocb->iocb_flag |= LPFC_DRIVER_ABORTED;
2843
2819 iabt = &abtsiocbp->iocb; 2844 iabt = &abtsiocbp->iocb;
2820 icmd = &cmdiocb->iocb; 2845 iabt->un.acxri.abortType = ABORT_TYPE_ABTS;
2821 switch (icmd->ulpCommand) { 2846 iabt->un.acxri.abortContextTag = icmd->ulpContext;
2822 case CMD_ELS_REQUEST64_CR: 2847 iabt->un.acxri.abortIoTag = icmd->ulpIoTag;
2823 /* Even though we abort the ELS command, the firmware may access 2848 iabt->ulpLe = 1;
2824 * the BPL or other resources before it processes our 2849 iabt->ulpClass = icmd->ulpClass;
2825 * ABORT_MXRI64. Thus we must delay reusing the cmdiocb
2826 * resources till the actual abort request completes.
2827 */
2828 abtsiocbp->context1 = (void *)((unsigned long)icmd->ulpCommand);
2829 abtsiocbp->context2 = cmdiocb->context2;
2830 abtsiocbp->context3 = cmdiocb->context3;
2831 cmdiocb->context2 = NULL;
2832 cmdiocb->context3 = NULL;
2833 abtsiocbp->iocb_cmpl = lpfc_sli_abort_elsreq_cmpl;
2834 break;
2835 default:
2836 lpfc_sli_release_iocbq(phba, abtsiocbp);
2837 return 0;
2838 }
2839 2850
2840 iabt->un.amxri.abortType = ABORT_TYPE_ABTS; 2851 if (phba->hba_state >= LPFC_LINK_UP)
2841 iabt->un.amxri.iotag32 = icmd->un.elsreq64.bdl.ulpIoTag32; 2852 iabt->ulpCommand = CMD_ABORT_XRI_CN;
2853 else
2854 iabt->ulpCommand = CMD_CLOSE_XRI_CN;
2842 2855
2843 iabt->ulpLe = 1; 2856 abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl;
2844 iabt->ulpClass = CLASS3;
2845 iabt->ulpCommand = CMD_ABORT_MXRI64_CN;
2846 2857
2847 if (lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0) == IOCB_ERROR) { 2858 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
2848 lpfc_sli_release_iocbq(phba, abtsiocbp); 2859 "%d:0339 Abort xri x%x, original iotag x%x, abort "
2849 return 0; 2860 "cmd iotag x%x\n",
2861 phba->brd_no, iabt->un.acxri.abortContextTag,
2862 iabt->un.acxri.abortIoTag, abtsiocbp->iotag);
2863 retval = lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0);
2864
2865abort_iotag_exit:
2866
2867 /* If we could not issue an abort dequeue the iocb and handle
2868 * the completion here.
2869 */
2870 if (retval == IOCB_ERROR) {
2871 list_del(&cmdiocb->list);
2872 pring->txcmplq_cnt--;
2873
2874 if (cmdiocb->iocb_cmpl) {
2875 icmd->ulpStatus = IOSTAT_LOCAL_REJECT;
2876 icmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
2877 spin_unlock_irq(phba->host->host_lock);
2878 (cmdiocb->iocb_cmpl) (phba, cmdiocb, cmdiocb);
2879 spin_lock_irq(phba->host->host_lock);
2880 } else
2881 lpfc_sli_release_iocbq(phba, cmdiocb);
2850 } 2882 }
2851 2883
2852 return 1; 2884 return 1;
@@ -2918,9 +2950,11 @@ void
2918lpfc_sli_abort_fcp_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, 2950lpfc_sli_abort_fcp_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
2919 struct lpfc_iocbq * rspiocb) 2951 struct lpfc_iocbq * rspiocb)
2920{ 2952{
2921 spin_lock_irq(phba->host->host_lock); 2953 unsigned long iflags;
2954
2955 spin_lock_irqsave(phba->host->host_lock, iflags);
2922 lpfc_sli_release_iocbq(phba, cmdiocb); 2956 lpfc_sli_release_iocbq(phba, cmdiocb);
2923 spin_unlock_irq(phba->host->host_lock); 2957 spin_unlock_irqrestore(phba->host->host_lock, iflags);
2924 return; 2958 return;
2925} 2959}
2926 2960
@@ -3043,22 +3077,22 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
3043 timeout_req); 3077 timeout_req);
3044 spin_lock_irq(phba->host->host_lock); 3078 spin_lock_irq(phba->host->host_lock);
3045 3079
3046 if (timeleft == 0) { 3080 if (piocb->iocb_flag & LPFC_IO_WAKE) {
3081 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
3082 "%d:0331 IOCB wake signaled\n",
3083 phba->brd_no);
3084 } else if (timeleft == 0) {
3047 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3085 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3048 "%d:0338 IOCB wait timeout error - no " 3086 "%d:0338 IOCB wait timeout error - no "
3049 "wake response Data x%x\n", 3087 "wake response Data x%x\n",
3050 phba->brd_no, timeout); 3088 phba->brd_no, timeout);
3051 retval = IOCB_TIMEDOUT; 3089 retval = IOCB_TIMEDOUT;
3052 } else if (!(piocb->iocb_flag & LPFC_IO_WAKE)) { 3090 } else {
3053 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3091 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3054 "%d:0330 IOCB wake NOT set, " 3092 "%d:0330 IOCB wake NOT set, "
3055 "Data x%x x%lx\n", phba->brd_no, 3093 "Data x%x x%lx\n", phba->brd_no,
3056 timeout, (timeleft / jiffies)); 3094 timeout, (timeleft / jiffies));
3057 retval = IOCB_TIMEDOUT; 3095 retval = IOCB_TIMEDOUT;
3058 } else {
3059 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
3060 "%d:0331 IOCB wake signaled\n",
3061 phba->brd_no);
3062 } 3096 }
3063 } else { 3097 } else {
3064 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3098 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
@@ -3087,8 +3121,6 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
3087 uint32_t timeout) 3121 uint32_t timeout)
3088{ 3122{
3089 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q); 3123 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
3090 DECLARE_WAITQUEUE(wq_entry, current);
3091 uint32_t timeleft = 0;
3092 int retval; 3124 int retval;
3093 3125
3094 /* The caller must leave context1 empty. */ 3126 /* The caller must leave context1 empty. */
@@ -3101,27 +3133,25 @@ lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
3101 /* setup context field to pass wait_queue pointer to wake function */ 3133 /* setup context field to pass wait_queue pointer to wake function */
3102 pmboxq->context1 = &done_q; 3134 pmboxq->context1 = &done_q;
3103 3135
3104 /* start to sleep before we wait, to avoid races */
3105 set_current_state(TASK_INTERRUPTIBLE);
3106 add_wait_queue(&done_q, &wq_entry);
3107
3108 /* now issue the command */ 3136 /* now issue the command */
3109 retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT); 3137 retval = lpfc_sli_issue_mbox(phba, pmboxq, MBX_NOWAIT);
3110 3138
3111 if (retval == MBX_BUSY || retval == MBX_SUCCESS) { 3139 if (retval == MBX_BUSY || retval == MBX_SUCCESS) {
3112 timeleft = schedule_timeout(timeout * HZ); 3140 wait_event_interruptible_timeout(done_q,
3141 pmboxq->mbox_flag & LPFC_MBX_WAKE,
3142 timeout * HZ);
3143
3113 pmboxq->context1 = NULL; 3144 pmboxq->context1 = NULL;
3114 /* if schedule_timeout returns 0, we timed out and were not 3145 /*
3115 woken up */ 3146 * if LPFC_MBX_WAKE flag is set the mailbox is completed
3116 if ((timeleft == 0) || signal_pending(current)) 3147 * else do not free the resources.
3117 retval = MBX_TIMEOUT; 3148 */
3118 else 3149 if (pmboxq->mbox_flag & LPFC_MBX_WAKE)
3119 retval = MBX_SUCCESS; 3150 retval = MBX_SUCCESS;
3151 else
3152 retval = MBX_TIMEOUT;
3120 } 3153 }
3121 3154
3122
3123 set_current_state(TASK_RUNNING);
3124 remove_wait_queue(&done_q, &wq_entry);
3125 return retval; 3155 return retval;
3126} 3156}
3127 3157
@@ -3184,6 +3214,11 @@ lpfc_intr_handler(int irq, void *dev_id)
3184 */ 3214 */
3185 spin_lock(phba->host->host_lock); 3215 spin_lock(phba->host->host_lock);
3186 ha_copy = readl(phba->HAregaddr); 3216 ha_copy = readl(phba->HAregaddr);
3217 /* If somebody is waiting to handle an eratt don't process it
3218 * here. The brdkill function will do this.
3219 */
3220 if (phba->fc_flag & FC_IGNORE_ERATT)
3221 ha_copy &= ~HA_ERATT;
3187 writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); 3222 writel((ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr);
3188 readl(phba->HAregaddr); /* flush */ 3223 readl(phba->HAregaddr); /* flush */
3189 spin_unlock(phba->host->host_lock); 3224 spin_unlock(phba->host->host_lock);
diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h
index a43549959dc7..41c38d324ab0 100644
--- a/drivers/scsi/lpfc/lpfc_sli.h
+++ b/drivers/scsi/lpfc/lpfc_sli.h
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * * 7 * *
@@ -39,9 +39,10 @@ struct lpfc_iocbq {
39 IOCB_t iocb; /* IOCB cmd */ 39 IOCB_t iocb; /* IOCB cmd */
40 uint8_t retry; /* retry counter for IOCB cmd - if needed */ 40 uint8_t retry; /* retry counter for IOCB cmd - if needed */
41 uint8_t iocb_flag; 41 uint8_t iocb_flag;
42#define LPFC_IO_LIBDFC 1 /* libdfc iocb */ 42#define LPFC_IO_LIBDFC 1 /* libdfc iocb */
43#define LPFC_IO_WAKE 2 /* High Priority Queue signal flag */ 43#define LPFC_IO_WAKE 2 /* High Priority Queue signal flag */
44#define LPFC_IO_FCP 4 /* FCP command -- iocbq in scsi_buf */ 44#define LPFC_IO_FCP 4 /* FCP command -- iocbq in scsi_buf */
45#define LPFC_DRIVER_ABORTED 8 /* driver aborted this request */
45 46
46 uint8_t abort_count; 47 uint8_t abort_count;
47 uint8_t rsvd2; 48 uint8_t rsvd2;
@@ -67,6 +68,8 @@ struct lpfc_iocbq {
67#define IOCB_ERROR 2 68#define IOCB_ERROR 2
68#define IOCB_TIMEDOUT 3 69#define IOCB_TIMEDOUT 3
69 70
71#define LPFC_MBX_WAKE 1
72
70typedef struct lpfcMboxq { 73typedef struct lpfcMboxq {
71 /* MBOXQs are used in single linked lists */ 74 /* MBOXQs are used in single linked lists */
72 struct list_head list; /* ptr to next mailbox command */ 75 struct list_head list; /* ptr to next mailbox command */
@@ -75,6 +78,7 @@ typedef struct lpfcMboxq {
75 void *context2; /* caller context information */ 78 void *context2; /* caller context information */
76 79
77 void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *); 80 void (*mbox_cmpl) (struct lpfc_hba *, struct lpfcMboxq *);
81 uint8_t mbox_flag;
78 82
79} LPFC_MBOXQ_t; 83} LPFC_MBOXQ_t;
80 84
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index a61ef3d1e7f1..92a9107019d2 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -1,7 +1,7 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2006 Emulex. All rights reserved. * 4 * Copyright (C) 2004-2007 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com * 6 * www.emulex.com *
7 * * 7 * *
@@ -18,12 +18,12 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21#define LPFC_DRIVER_VERSION "8.1.11" 21#define LPFC_DRIVER_VERSION "8.1.12"
22 22
23#define LPFC_DRIVER_NAME "lpfc" 23#define LPFC_DRIVER_NAME "lpfc"
24 24
25#define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \ 25#define LPFC_MODULE_DESC "Emulex LightPulse Fibre Channel SCSI driver " \
26 LPFC_DRIVER_VERSION 26 LPFC_DRIVER_VERSION
27#define LPFC_COPYRIGHT "Copyright(c) 2004-2006 Emulex. All rights reserved." 27#define LPFC_COPYRIGHT "Copyright(c) 2004-2007 Emulex. All rights reserved."
28 28
29#define DFC_API_VERSION "0.0.0" 29#define DFC_API_VERSION "0.0.0"