aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-06 20:48:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-06 20:48:34 -0400
commitbced13738405b62c8203df9c103d4ba63d747872 (patch)
tree566795dc7493591182668a94855487dff034a2b3 /drivers
parent21f16289270447673a7263ccc0b22d562fb01ecb (diff)
parent2b053729a84b6aac197df51b8729bc9fec743bff (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6: (32 commits) [SCSI] aacraid: prevent panic on adapter resource failure [SCSI] aha152x: use data accessors and !use_sg cleanup [SCSI] aha152x: Fix check_condition code-path [SCSI] aha152x: Clean Reset path [SCSI] aha152x: preliminary fixes and some comments [SCSI] aha152x: use bounce buffer [SCSI] aha152x: fix debug mode symbol conflict [SCSI] sd: disentangle barriers in SCSI [SCSI] lpfc : scsi command accessor fix for 8.2.2 [SCSI] qlogicpti: Some cosmetic changes [SCSI] lpfc 8.2.2 : Change version number to 8.2.2 [SCSI] lpfc 8.2.2 : Style cleanups [SCSI] lpfc 8.2.2 : Miscellaneous Bug Fixes [SCSI] lpfc 8.2.2 : Miscellaneous management and logging mods [SCSI] lpfc 8.2.2 : Rework the lpfc_printf_log() macro [SCSI] lpfc 8.2.2 : Attribute and Parameter splits for vport and physical port [SCSI] lpfc 8.2.2 : Fix locking around HBA's port_list [SCSI] lpfc 8.2.2 : Error messages and debugfs updates [SCSI] initialize shost_data to zero [SCSI] mptsas: add SMP passthrough support via bsg ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/message/fusion/mptbase.c17
-rw-r--r--drivers/message/fusion/mptsas.c126
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c5
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c41
-rw-r--r--drivers/scsi/aacraid/linit.c4
-rw-r--r--drivers/scsi/aha152x.c169
-rw-r--r--drivers/scsi/aha152x.h2
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_core.c22
-rw-r--r--drivers/scsi/dpt_i2o.c132
-rw-r--r--drivers/scsi/dpti.h9
-rw-r--r--drivers/scsi/esp_scsi.h2
-rw-r--r--drivers/scsi/gdth.c48
-rw-r--r--drivers/scsi/gdth.h6
-rw-r--r--drivers/scsi/hosts.c2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c39
-rw-r--r--drivers/scsi/libsas/Kconfig3
-rw-r--r--drivers/scsi/lpfc/lpfc.h72
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c423
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h28
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c243
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c595
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c679
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c539
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h14
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c284
-rw-r--r--drivers/scsi/lpfc/lpfc_logmsg.h10
-rw-r--r--drivers/scsi/lpfc/lpfc_mbox.c20
-rw-r--r--drivers/scsi/lpfc/lpfc_mem.c32
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c162
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c413
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c423
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.h10
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.c164
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c14
-rw-r--r--drivers/scsi/qlogicpti.c50
-rw-r--r--drivers/scsi/scsi_lib.c17
-rw-r--r--drivers/scsi/sd.c14
-rw-r--r--drivers/scsi/st.c16
-rw-r--r--drivers/scsi/st.h3
42 files changed, 2821 insertions, 2039 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index e866dacde7e5..414c109f4cf5 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -88,7 +88,9 @@ module_param(mpt_channel_mapping, int, 0);
88MODULE_PARM_DESC(mpt_channel_mapping, " Mapping id's to channels (default=0)"); 88MODULE_PARM_DESC(mpt_channel_mapping, " Mapping id's to channels (default=0)");
89 89
90static int mpt_debug_level; 90static int mpt_debug_level;
91module_param(mpt_debug_level, int, 0); 91static int mpt_set_debug_level(const char *val, struct kernel_param *kp);
92module_param_call(mpt_debug_level, mpt_set_debug_level, param_get_int,
93 &mpt_debug_level, 0600);
92MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h - (default=0)"); 94MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h - (default=0)");
93 95
94#ifdef MFCNT 96#ifdef MFCNT
@@ -220,6 +222,19 @@ pci_enable_io_access(struct pci_dev *pdev)
220 pci_write_config_word(pdev, PCI_COMMAND, command_reg); 222 pci_write_config_word(pdev, PCI_COMMAND, command_reg);
221} 223}
222 224
225static int mpt_set_debug_level(const char *val, struct kernel_param *kp)
226{
227 int ret = param_set_int(val, kp);
228 MPT_ADAPTER *ioc;
229
230 if (ret)
231 return ret;
232
233 list_for_each_entry(ioc, &ioc_list, list)
234 ioc->debug_level = mpt_debug_level;
235 return 0;
236}
237
223/* 238/*
224 * Process turbo (context) reply... 239 * Process turbo (context) reply...
225 */ 240 */
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 29add83da588..b9c69bff218c 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1312,11 +1312,137 @@ mptsas_get_bay_identifier(struct sas_rphy *rphy)
1312 return rc; 1312 return rc;
1313} 1313}
1314 1314
1315static int mptsas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1316 struct request *req)
1317{
1318 MPT_ADAPTER *ioc = ((MPT_SCSI_HOST *) shost->hostdata)->ioc;
1319 MPT_FRAME_HDR *mf;
1320 SmpPassthroughRequest_t *smpreq;
1321 struct request *rsp = req->next_rq;
1322 int ret;
1323 int flagsLength;
1324 unsigned long timeleft;
1325 char *psge;
1326 dma_addr_t dma_addr_in = 0;
1327 dma_addr_t dma_addr_out = 0;
1328 u64 sas_address = 0;
1329
1330 if (!rsp) {
1331 printk(KERN_ERR "%s: the smp response space is missing\n",
1332 __FUNCTION__);
1333 return -EINVAL;
1334 }
1335
1336 /* do we need to support multiple segments? */
1337 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
1338 printk(KERN_ERR "%s: multiple segments req %u %u, rsp %u %u\n",
1339 __FUNCTION__, req->bio->bi_vcnt, req->data_len,
1340 rsp->bio->bi_vcnt, rsp->data_len);
1341 return -EINVAL;
1342 }
1343
1344 ret = mutex_lock_interruptible(&ioc->sas_mgmt.mutex);
1345 if (ret)
1346 goto out;
1347
1348 mf = mpt_get_msg_frame(mptsasMgmtCtx, ioc);
1349 if (!mf) {
1350 ret = -ENOMEM;
1351 goto out_unlock;
1352 }
1353
1354 smpreq = (SmpPassthroughRequest_t *)mf;
1355 memset(smpreq, 0, sizeof(*smpreq));
1356
1357 smpreq->RequestDataLength = cpu_to_le16(req->data_len - 4);
1358 smpreq->Function = MPI_FUNCTION_SMP_PASSTHROUGH;
1359
1360 if (rphy)
1361 sas_address = rphy->identify.sas_address;
1362 else {
1363 struct mptsas_portinfo *port_info;
1364
1365 mutex_lock(&ioc->sas_topology_mutex);
1366 port_info = mptsas_find_portinfo_by_handle(ioc, ioc->handle);
1367 if (port_info && port_info->phy_info)
1368 sas_address =
1369 port_info->phy_info[0].phy->identify.sas_address;
1370 mutex_unlock(&ioc->sas_topology_mutex);
1371 }
1372
1373 *((u64 *)&smpreq->SASAddress) = cpu_to_le64(sas_address);
1374
1375 psge = (char *)
1376 (((int *) mf) + (offsetof(SmpPassthroughRequest_t, SGL) / 4));
1377
1378 /* request */
1379 flagsLength = (MPI_SGE_FLAGS_SIMPLE_ELEMENT |
1380 MPI_SGE_FLAGS_END_OF_BUFFER |
1381 MPI_SGE_FLAGS_DIRECTION |
1382 mpt_addr_size()) << MPI_SGE_FLAGS_SHIFT;
1383 flagsLength |= (req->data_len - 4);
1384
1385 dma_addr_out = pci_map_single(ioc->pcidev, bio_data(req->bio),
1386 req->data_len, PCI_DMA_BIDIRECTIONAL);
1387 if (!dma_addr_out)
1388 goto put_mf;
1389 mpt_add_sge(psge, flagsLength, dma_addr_out);
1390 psge += (sizeof(u32) + sizeof(dma_addr_t));
1391
1392 /* response */
1393 flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ;
1394 flagsLength |= rsp->data_len + 4;
1395 dma_addr_in = pci_map_single(ioc->pcidev, bio_data(rsp->bio),
1396 rsp->data_len, PCI_DMA_BIDIRECTIONAL);
1397 if (!dma_addr_in)
1398 goto unmap;
1399 mpt_add_sge(psge, flagsLength, dma_addr_in);
1400
1401 mpt_put_msg_frame(mptsasMgmtCtx, ioc, mf);
1402
1403 timeleft = wait_for_completion_timeout(&ioc->sas_mgmt.done, 10 * HZ);
1404 if (!timeleft) {
1405 printk(KERN_ERR "%s: smp timeout!\n", __FUNCTION__);
1406 /* On timeout reset the board */
1407 mpt_HardResetHandler(ioc, CAN_SLEEP);
1408 ret = -ETIMEDOUT;
1409 goto unmap;
1410 }
1411 mf = NULL;
1412
1413 if (ioc->sas_mgmt.status & MPT_IOCTL_STATUS_RF_VALID) {
1414 SmpPassthroughReply_t *smprep;
1415
1416 smprep = (SmpPassthroughReply_t *)ioc->sas_mgmt.reply;
1417 memcpy(req->sense, smprep, sizeof(*smprep));
1418 req->sense_len = sizeof(*smprep);
1419 } else {
1420 printk(KERN_ERR "%s: smp passthru reply failed to be returned\n",
1421 __FUNCTION__);
1422 ret = -ENXIO;
1423 }
1424unmap:
1425 if (dma_addr_out)
1426 pci_unmap_single(ioc->pcidev, dma_addr_out, req->data_len,
1427 PCI_DMA_BIDIRECTIONAL);
1428 if (dma_addr_in)
1429 pci_unmap_single(ioc->pcidev, dma_addr_in, rsp->data_len,
1430 PCI_DMA_BIDIRECTIONAL);
1431put_mf:
1432 if (mf)
1433 mpt_free_msg_frame(ioc, mf);
1434out_unlock:
1435 mutex_unlock(&ioc->sas_mgmt.mutex);
1436out:
1437 return ret;
1438}
1439
1315static struct sas_function_template mptsas_transport_functions = { 1440static struct sas_function_template mptsas_transport_functions = {
1316 .get_linkerrors = mptsas_get_linkerrors, 1441 .get_linkerrors = mptsas_get_linkerrors,
1317 .get_enclosure_identifier = mptsas_get_enclosure_identifier, 1442 .get_enclosure_identifier = mptsas_get_enclosure_identifier,
1318 .get_bay_identifier = mptsas_get_bay_identifier, 1443 .get_bay_identifier = mptsas_get_bay_identifier,
1319 .phy_reset = mptsas_phy_reset, 1444 .phy_reset = mptsas_phy_reset,
1445 .smp_handler = mptsas_smp_handler,
1320}; 1446};
1321 1447
1322static struct scsi_transport_template *mptsas_transport_template; 1448static struct scsi_transport_template *mptsas_transport_template;
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index b240800b78d7..99299976e891 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -4154,8 +4154,9 @@ zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
4154 fcp_rsp_iu->fcp_resid, 4154 fcp_rsp_iu->fcp_resid,
4155 (int) zfcp_get_fcp_dl(fcp_cmnd_iu)); 4155 (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
4156 4156
4157 scpnt->resid = fcp_rsp_iu->fcp_resid; 4157 scsi_set_resid(scpnt, fcp_rsp_iu->fcp_resid);
4158 if (scpnt->request_bufflen - scpnt->resid < scpnt->underflow) 4158 if (scsi_bufflen(scpnt) - scsi_get_resid(scpnt) <
4159 scpnt->underflow)
4159 set_host_byte(&scpnt->result, DID_ERROR); 4160 set_host_byte(&scpnt->result, DID_ERROR);
4160 } 4161 }
4161 4162
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index c408badd2ae9..81daa8204bfe 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -36,8 +36,6 @@ static void zfcp_qdio_sbale_fill
36 (struct zfcp_fsf_req *, unsigned long, void *, int); 36 (struct zfcp_fsf_req *, unsigned long, void *, int);
37static int zfcp_qdio_sbals_from_segment 37static int zfcp_qdio_sbals_from_segment
38 (struct zfcp_fsf_req *, unsigned long, void *, unsigned long); 38 (struct zfcp_fsf_req *, unsigned long, void *, unsigned long);
39static int zfcp_qdio_sbals_from_buffer
40 (struct zfcp_fsf_req *, unsigned long, void *, unsigned long, int);
41 39
42static qdio_handler_t zfcp_qdio_request_handler; 40static qdio_handler_t zfcp_qdio_request_handler;
43static qdio_handler_t zfcp_qdio_response_handler; 41static qdio_handler_t zfcp_qdio_response_handler;
@@ -632,28 +630,6 @@ out:
632 630
633 631
634/** 632/**
635 * zfcp_qdio_sbals_from_buffer - fill SBALs from buffer
636 * @fsf_req: request to be processed
637 * @sbtype: SBALE flags
638 * @buffer: data buffer
639 * @length: length of buffer
640 * @max_sbals: upper bound for number of SBALs to be used
641 */
642static int
643zfcp_qdio_sbals_from_buffer(struct zfcp_fsf_req *fsf_req, unsigned long sbtype,
644 void *buffer, unsigned long length, int max_sbals)
645{
646 struct scatterlist sg_segment;
647
648 zfcp_address_to_sg(buffer, &sg_segment);
649 sg_segment.length = length;
650
651 return zfcp_qdio_sbals_from_sg(fsf_req, sbtype, &sg_segment, 1,
652 max_sbals);
653}
654
655
656/**
657 * zfcp_qdio_sbals_from_scsicmnd - fill SBALs from scsi command 633 * zfcp_qdio_sbals_from_scsicmnd - fill SBALs from scsi command
658 * @fsf_req: request to be processed 634 * @fsf_req: request to be processed
659 * @sbtype: SBALE flags 635 * @sbtype: SBALE flags
@@ -664,18 +640,13 @@ int
664zfcp_qdio_sbals_from_scsicmnd(struct zfcp_fsf_req *fsf_req, 640zfcp_qdio_sbals_from_scsicmnd(struct zfcp_fsf_req *fsf_req,
665 unsigned long sbtype, struct scsi_cmnd *scsi_cmnd) 641 unsigned long sbtype, struct scsi_cmnd *scsi_cmnd)
666{ 642{
667 if (scsi_cmnd->use_sg) { 643 if (scsi_sg_count(scsi_cmnd))
668 return zfcp_qdio_sbals_from_sg(fsf_req, sbtype, 644 return zfcp_qdio_sbals_from_sg(fsf_req, sbtype,
669 (struct scatterlist *) 645 scsi_sglist(scsi_cmnd),
670 scsi_cmnd->request_buffer, 646 scsi_sg_count(scsi_cmnd),
671 scsi_cmnd->use_sg, 647 ZFCP_MAX_SBALS_PER_REQ);
672 ZFCP_MAX_SBALS_PER_REQ); 648 else
673 } else { 649 return 0;
674 return zfcp_qdio_sbals_from_buffer(fsf_req, sbtype,
675 scsi_cmnd->request_buffer,
676 scsi_cmnd->request_bufflen,
677 ZFCP_MAX_SBALS_PER_REQ);
678 }
679} 650}
680 651
681/** 652/**
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 813556c60007..a7f42a17b5c7 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1110,7 +1110,9 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
1110 __aac_shutdown(aac); 1110 __aac_shutdown(aac);
1111 out_unmap: 1111 out_unmap:
1112 aac_fib_map_free(aac); 1112 aac_fib_map_free(aac);
1113 pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys); 1113 if (aac->comm_addr)
1114 pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr,
1115 aac->comm_phys);
1114 kfree(aac->queues); 1116 kfree(aac->queues);
1115 aac_adapter_ioremap(aac, 0); 1117 aac_adapter_ioremap(aac, 0);
1116 kfree(aac->fibs); 1118 kfree(aac->fibs);
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 85f2394ffc3e..d30a30786dda 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -289,18 +289,18 @@ static LIST_HEAD(aha152x_host_list);
289 if(spin_is_locked(&QLOCK)) { \ 289 if(spin_is_locked(&QLOCK)) { \
290 DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ 290 DPRINTK(debug_intr, DEBUG_LEAD "(%s:%d) already locked at %s:%d\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \
291 } \ 291 } \
292 DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ 292 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locking\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \
293 spin_lock_irqsave(&QLOCK,flags); \ 293 spin_lock_irqsave(&QLOCK,flags); \
294 DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ 294 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) locked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \
295 QLOCKER=__FUNCTION__; \ 295 QLOCKER=__FUNCTION__; \
296 QLOCKERL=__LINE__; \ 296 QLOCKERL=__LINE__; \
297 } while(0) 297 } while(0)
298 298
299#define DO_UNLOCK(flags) \ 299#define DO_UNLOCK(flags) \
300 do { \ 300 do { \
301 DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \ 301 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocking (locked at %s:%d)\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__, QLOCKER, QLOCKERL); \
302 spin_unlock_irqrestore(&QLOCK,flags); \ 302 spin_unlock_irqrestore(&QLOCK,flags); \
303 DPRINTK(debug_locks, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \ 303 DPRINTK(debug_locking, DEBUG_LEAD "(%s:%d) unlocked\n", CMDINFO(CURRENT_SC), __FUNCTION__, __LINE__); \
304 QLOCKER="(not locked)"; \ 304 QLOCKER="(not locked)"; \
305 QLOCKERL=0; \ 305 QLOCKERL=0; \
306 } while(0) 306 } while(0)
@@ -322,6 +322,12 @@ static LIST_HEAD(aha152x_host_list);
322 (cmd) ? ((cmd)->device->id & 0x0f) : -1, \ 322 (cmd) ? ((cmd)->device->id & 0x0f) : -1, \
323 (cmd) ? ((cmd)->device->lun & 0x07) : -1 323 (cmd) ? ((cmd)->device->lun & 0x07) : -1
324 324
325static inline void
326CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
327{
328 scsi_set_resid(cmd, scsi_get_resid(cmd) + inc);
329}
330
325#define DELAY_DEFAULT 1000 331#define DELAY_DEFAULT 1000
326 332
327#if defined(PCMCIA) 333#if defined(PCMCIA)
@@ -552,14 +558,11 @@ struct aha152x_hostdata {
552struct aha152x_scdata { 558struct aha152x_scdata {
553 Scsi_Cmnd *next; /* next sc in queue */ 559 Scsi_Cmnd *next; /* next sc in queue */
554 struct completion *done;/* semaphore to block on */ 560 struct completion *done;/* semaphore to block on */
555 unsigned char cmd_len; 561 unsigned char aha_orig_cmd_len;
556 unsigned char cmnd[MAX_COMMAND_SIZE]; 562 unsigned char aha_orig_cmnd[MAX_COMMAND_SIZE];
557 unsigned short use_sg; 563 int aha_orig_resid;
558 unsigned request_bufflen;
559 void *request_buffer;
560}; 564};
561 565
562
563/* access macros for hostdata */ 566/* access macros for hostdata */
564 567
565#define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata) 568#define HOSTDATA(shpnt) ((struct aha152x_hostdata *) &shpnt->hostdata)
@@ -978,15 +981,15 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
978#if defined(AHA152X_DEBUG) 981#if defined(AHA152X_DEBUG)
979 if (HOSTDATA(shpnt)->debug & debug_queue) { 982 if (HOSTDATA(shpnt)->debug & debug_queue) {
980 printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=", 983 printk(INFO_LEAD "queue: %p; cmd_len=%d pieces=%d size=%u cmnd=",
981 CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len, SCpnt->use_sg, SCpnt->request_bufflen); 984 CMDINFO(SCpnt), SCpnt, SCpnt->cmd_len,
985 scsi_sg_count(SCpnt), scsi_bufflen(SCpnt));
982 __scsi_print_command(SCpnt->cmnd); 986 __scsi_print_command(SCpnt->cmnd);
983 } 987 }
984#endif 988#endif
985 989
986 SCpnt->scsi_done = done; 990 SCpnt->scsi_done = done;
987 SCpnt->resid = SCpnt->request_bufflen;
988 SCpnt->SCp.phase = not_issued | phase; 991 SCpnt->SCp.phase = not_issued | phase;
989 SCpnt->SCp.Status = CHECK_CONDITION; 992 SCpnt->SCp.Status = 0x1; /* Ilegal status by SCSI standard */
990 SCpnt->SCp.Message = 0; 993 SCpnt->SCp.Message = 0;
991 SCpnt->SCp.have_data_in = 0; 994 SCpnt->SCp.have_data_in = 0;
992 SCpnt->SCp.sent_command = 0; 995 SCpnt->SCp.sent_command = 0;
@@ -997,20 +1000,11 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
997 return FAILED; 1000 return FAILED;
998 } 1001 }
999 } else { 1002 } else {
1000 struct aha152x_scdata *sc;
1001
1002 SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC); 1003 SCpnt->host_scribble = kmalloc(sizeof(struct aha152x_scdata), GFP_ATOMIC);
1003 if(SCpnt->host_scribble==0) { 1004 if(SCpnt->host_scribble==0) {
1004 printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt)); 1005 printk(ERR_LEAD "allocation failed\n", CMDINFO(SCpnt));
1005 return FAILED; 1006 return FAILED;
1006 } 1007 }
1007
1008 sc = SCDATA(SCpnt);
1009 memcpy(sc->cmnd, SCpnt->cmnd, sizeof(sc->cmnd));
1010 sc->request_buffer = SCpnt->request_buffer;
1011 sc->request_bufflen = SCpnt->request_bufflen;
1012 sc->use_sg = SCpnt->use_sg;
1013 sc->cmd_len = SCpnt->cmd_len;
1014 } 1008 }
1015 1009
1016 SCNEXT(SCpnt) = NULL; 1010 SCNEXT(SCpnt) = NULL;
@@ -1022,16 +1016,25 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
1022 SCp.buffer : next buffer 1016 SCp.buffer : next buffer
1023 SCp.buffers_residual : left buffers in list 1017 SCp.buffers_residual : left buffers in list
1024 SCp.phase : current state of the command */ 1018 SCp.phase : current state of the command */
1025 if (SCpnt->use_sg) { 1019
1026 SCpnt->SCp.buffer = (struct scatterlist *) SCpnt->request_buffer; 1020 if ((phase & (check_condition|resetting)) || !scsi_sglist(SCpnt)) {
1027 SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer); 1021 if (phase & check_condition) {
1028 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; 1022 SCpnt->SCp.ptr = SCpnt->sense_buffer;
1029 SCpnt->SCp.buffers_residual = SCpnt->use_sg - 1; 1023 SCpnt->SCp.this_residual = sizeof(SCpnt->sense_buffer);
1030 } else { 1024 scsi_set_resid(SCpnt, sizeof(SCpnt->sense_buffer));
1031 SCpnt->SCp.ptr = (char *) SCpnt->request_buffer; 1025 } else {
1032 SCpnt->SCp.this_residual = SCpnt->request_bufflen; 1026 SCpnt->SCp.ptr = NULL;
1027 SCpnt->SCp.this_residual = 0;
1028 scsi_set_resid(SCpnt, 0);
1029 }
1033 SCpnt->SCp.buffer = NULL; 1030 SCpnt->SCp.buffer = NULL;
1034 SCpnt->SCp.buffers_residual = 0; 1031 SCpnt->SCp.buffers_residual = 0;
1032 } else {
1033 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
1034 SCpnt->SCp.buffer = scsi_sglist(SCpnt);
1035 SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer);
1036 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
1037 SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
1035 } 1038 }
1036 1039
1037 DO_LOCK(flags); 1040 DO_LOCK(flags);
@@ -1150,9 +1153,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
1150 DECLARE_COMPLETION(done); 1153 DECLARE_COMPLETION(done);
1151 int ret, issued, disconnected; 1154 int ret, issued, disconnected;
1152 unsigned char old_cmd_len = SCpnt->cmd_len; 1155 unsigned char old_cmd_len = SCpnt->cmd_len;
1153 unsigned short old_use_sg = SCpnt->use_sg;
1154 void *old_buffer = SCpnt->request_buffer;
1155 unsigned old_bufflen = SCpnt->request_bufflen;
1156 unsigned long flags; 1156 unsigned long flags;
1157 unsigned long timeleft; 1157 unsigned long timeleft;
1158 1158
@@ -1174,9 +1174,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
1174 DO_UNLOCK(flags); 1174 DO_UNLOCK(flags);
1175 1175
1176 SCpnt->cmd_len = 0; 1176 SCpnt->cmd_len = 0;
1177 SCpnt->use_sg = 0;
1178 SCpnt->request_buffer = NULL;
1179 SCpnt->request_bufflen = 0;
1180 1177
1181 aha152x_internal_queue(SCpnt, &done, resetting, reset_done); 1178 aha152x_internal_queue(SCpnt, &done, resetting, reset_done);
1182 1179
@@ -1189,9 +1186,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt)
1189 } 1186 }
1190 1187
1191 SCpnt->cmd_len = old_cmd_len; 1188 SCpnt->cmd_len = old_cmd_len;
1192 SCpnt->use_sg = old_use_sg;
1193 SCpnt->request_buffer = old_buffer;
1194 SCpnt->request_bufflen = old_bufflen;
1195 1189
1196 DO_LOCK(flags); 1190 DO_LOCK(flags);
1197 1191
@@ -1531,8 +1525,8 @@ static void busfree_run(struct Scsi_Host *shpnt)
1531 /* target sent DISCONNECT */ 1525 /* target sent DISCONNECT */
1532 DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n", 1526 DPRINTK(debug_selection, DEBUG_LEAD "target disconnected at %d/%d\n",
1533 CMDINFO(CURRENT_SC), 1527 CMDINFO(CURRENT_SC),
1534 CURRENT_SC->resid, 1528 scsi_get_resid(CURRENT_SC),
1535 CURRENT_SC->request_bufflen); 1529 scsi_bufflen(CURRENT_SC));
1536#if defined(AHA152X_STAT) 1530#if defined(AHA152X_STAT)
1537 HOSTDATA(shpnt)->disconnections++; 1531 HOSTDATA(shpnt)->disconnections++;
1538#endif 1532#endif
@@ -1568,18 +1562,16 @@ static void busfree_run(struct Scsi_Host *shpnt)
1568#endif 1562#endif
1569 1563
1570 /* restore old command */ 1564 /* restore old command */
1571 memcpy(cmd->cmnd, sc->cmnd, sizeof(sc->cmnd)); 1565 memcpy(cmd->cmnd, sc->aha_orig_cmnd, sizeof(cmd->cmnd));
1572 cmd->request_buffer = sc->request_buffer; 1566 cmd->cmd_len = sc->aha_orig_cmd_len;
1573 cmd->request_bufflen = sc->request_bufflen; 1567 scsi_set_resid(cmd, sc->aha_orig_resid);
1574 cmd->use_sg = sc->use_sg;
1575 cmd->cmd_len = sc->cmd_len;
1576 1568
1577 cmd->SCp.Status = 0x02; 1569 cmd->SCp.Status = SAM_STAT_CHECK_CONDITION;
1578 1570
1579 HOSTDATA(shpnt)->commands--; 1571 HOSTDATA(shpnt)->commands--;
1580 if (!HOSTDATA(shpnt)->commands) 1572 if (!HOSTDATA(shpnt)->commands)
1581 SETPORT(PORTA, 0); /* turn led off */ 1573 SETPORT(PORTA, 0); /* turn led off */
1582 } else if(DONE_SC->SCp.Status==0x02) { 1574 } else if(DONE_SC->SCp.Status==SAM_STAT_CHECK_CONDITION) {
1583#if defined(AHA152X_STAT) 1575#if defined(AHA152X_STAT)
1584 HOSTDATA(shpnt)->busfree_with_check_condition++; 1576 HOSTDATA(shpnt)->busfree_with_check_condition++;
1585#endif 1577#endif
@@ -1587,13 +1579,23 @@ static void busfree_run(struct Scsi_Host *shpnt)
1587 DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC)); 1579 DPRINTK(debug_eh, ERR_LEAD "CHECK CONDITION found\n", CMDINFO(DONE_SC));
1588#endif 1580#endif
1589 1581
1590 if(!(DONE_SC->SCp.Status & not_issued)) { 1582 if(!(DONE_SC->SCp.phase & not_issued)) {
1583 struct aha152x_scdata *sc;
1591 Scsi_Cmnd *ptr = DONE_SC; 1584 Scsi_Cmnd *ptr = DONE_SC;
1592 DONE_SC=NULL; 1585 DONE_SC=NULL;
1593#if 0 1586#if 0
1594 DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr)); 1587 DPRINTK(debug_eh, ERR_LEAD "requesting sense\n", CMDINFO(ptr));
1595#endif 1588#endif
1596 1589
1590 /* save old command */
1591 sc = SCDATA(ptr);
1592 /* It was allocated in aha152x_internal_queue? */
1593 BUG_ON(!sc);
1594 memcpy(sc->aha_orig_cmnd, ptr->cmnd,
1595 sizeof(ptr->cmnd));
1596 sc->aha_orig_cmd_len = ptr->cmd_len;
1597 sc->aha_orig_resid = scsi_get_resid(ptr);
1598
1597 ptr->cmnd[0] = REQUEST_SENSE; 1599 ptr->cmnd[0] = REQUEST_SENSE;
1598 ptr->cmnd[1] = 0; 1600 ptr->cmnd[1] = 0;
1599 ptr->cmnd[2] = 0; 1601 ptr->cmnd[2] = 0;
@@ -1601,10 +1603,7 @@ static void busfree_run(struct Scsi_Host *shpnt)
1601 ptr->cmnd[4] = sizeof(ptr->sense_buffer); 1603 ptr->cmnd[4] = sizeof(ptr->sense_buffer);
1602 ptr->cmnd[5] = 0; 1604 ptr->cmnd[5] = 0;
1603 ptr->cmd_len = 6; 1605 ptr->cmd_len = 6;
1604 ptr->use_sg = 0; 1606
1605 ptr->request_buffer = ptr->sense_buffer;
1606 ptr->request_bufflen = sizeof(ptr->sense_buffer);
1607
1608 DO_UNLOCK(flags); 1607 DO_UNLOCK(flags);
1609 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done); 1608 aha152x_internal_queue(ptr, NULL, check_condition, ptr->scsi_done);
1610 DO_LOCK(flags); 1609 DO_LOCK(flags);
@@ -2180,7 +2179,8 @@ static void datai_init(struct Scsi_Host *shpnt)
2180 DATA_LEN=0; 2179 DATA_LEN=0;
2181 DPRINTK(debug_datai, 2180 DPRINTK(debug_datai,
2182 DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n", 2181 DEBUG_LEAD "datai_init: request_bufflen=%d resid=%d\n",
2183 CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); 2182 CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
2183 scsi_get_resid(CURRENT_SC));
2184} 2184}
2185 2185
2186static void datai_run(struct Scsi_Host *shpnt) 2186static void datai_run(struct Scsi_Host *shpnt)
@@ -2293,11 +2293,12 @@ static void datai_run(struct Scsi_Host *shpnt)
2293 2293
2294static void datai_end(struct Scsi_Host *shpnt) 2294static void datai_end(struct Scsi_Host *shpnt)
2295{ 2295{
2296 CURRENT_SC->resid -= GETSTCNT(); 2296 CMD_INC_RESID(CURRENT_SC, -GETSTCNT());
2297 2297
2298 DPRINTK(debug_datai, 2298 DPRINTK(debug_datai,
2299 DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n", 2299 DEBUG_LEAD "datai_end: request_bufflen=%d resid=%d stcnt=%d\n",
2300 CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid, GETSTCNT()); 2300 CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
2301 scsi_get_resid(CURRENT_SC), GETSTCNT());
2301 2302
2302 SETPORT(SXFRCTL0, CH1|CLRSTCNT); 2303 SETPORT(SXFRCTL0, CH1|CLRSTCNT);
2303 SETPORT(DMACNTRL0, 0); 2304 SETPORT(DMACNTRL0, 0);
@@ -2318,11 +2319,12 @@ static void datao_init(struct Scsi_Host *shpnt)
2318 SETPORT(SIMODE0, 0); 2319 SETPORT(SIMODE0, 0);
2319 SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE ); 2320 SETPORT(SIMODE1, ENSCSIPERR | ENSCSIRST | ENPHASEMIS | ENBUSFREE );
2320 2321
2321 DATA_LEN = CURRENT_SC->resid; 2322 DATA_LEN = scsi_get_resid(CURRENT_SC);
2322 2323
2323 DPRINTK(debug_datao, 2324 DPRINTK(debug_datao,
2324 DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n", 2325 DEBUG_LEAD "datao_init: request_bufflen=%d; resid=%d\n",
2325 CMDINFO(CURRENT_SC), CURRENT_SC->request_bufflen, CURRENT_SC->resid); 2326 CMDINFO(CURRENT_SC), scsi_bufflen(CURRENT_SC),
2327 scsi_get_resid(CURRENT_SC));
2326} 2328}
2327 2329
2328static void datao_run(struct Scsi_Host *shpnt) 2330static void datao_run(struct Scsi_Host *shpnt)
@@ -2346,7 +2348,7 @@ static void datao_run(struct Scsi_Host *shpnt)
2346 SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT); 2348 SETPORT(DMACNTRL0,WRITE_READ|ENDMA|_8BIT);
2347 SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++); 2349 SETPORT(DATAPORT, *CURRENT_SC->SCp.ptr++);
2348 CURRENT_SC->SCp.this_residual--; 2350 CURRENT_SC->SCp.this_residual--;
2349 CURRENT_SC->resid--; 2351 CMD_INC_RESID(CURRENT_SC, -1);
2350 SETPORT(DMACNTRL0,WRITE_READ|ENDMA); 2352 SETPORT(DMACNTRL0,WRITE_READ|ENDMA);
2351 } 2353 }
2352 2354
@@ -2355,7 +2357,7 @@ static void datao_run(struct Scsi_Host *shpnt)
2355 outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count); 2357 outsw(DATAPORT, CURRENT_SC->SCp.ptr, data_count);
2356 CURRENT_SC->SCp.ptr += 2 * data_count; 2358 CURRENT_SC->SCp.ptr += 2 * data_count;
2357 CURRENT_SC->SCp.this_residual -= 2 * data_count; 2359 CURRENT_SC->SCp.this_residual -= 2 * data_count;
2358 CURRENT_SC->resid -= 2 * data_count; 2360 CMD_INC_RESID(CURRENT_SC, -2 * data_count);
2359 } 2361 }
2360 2362
2361 if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) { 2363 if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
@@ -2381,35 +2383,34 @@ static void datao_run(struct Scsi_Host *shpnt)
2381static void datao_end(struct Scsi_Host *shpnt) 2383static void datao_end(struct Scsi_Host *shpnt)
2382{ 2384{
2383 if(TESTLO(DMASTAT, DFIFOEMP)) { 2385 if(TESTLO(DMASTAT, DFIFOEMP)) {
2384 int data_count = (DATA_LEN - CURRENT_SC->resid) - GETSTCNT(); 2386 int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
2387 GETSTCNT();
2385 2388
2386 DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n", 2389 DPRINTK(debug_datao, DEBUG_LEAD "datao: %d bytes to resend (%d written, %d transferred)\n",
2387 CMDINFO(CURRENT_SC), 2390 CMDINFO(CURRENT_SC),
2388 data_count, 2391 data_count,
2389 DATA_LEN-CURRENT_SC->resid, 2392 DATA_LEN - scsi_get_resid(CURRENT_SC),
2390 GETSTCNT()); 2393 GETSTCNT());
2391 2394
2392 CURRENT_SC->resid += data_count; 2395 CMD_INC_RESID(CURRENT_SC, data_count);
2393 2396
2394 if(CURRENT_SC->use_sg) { 2397 data_count -= CURRENT_SC->SCp.ptr -
2395 data_count -= CURRENT_SC->SCp.ptr - SG_ADDRESS(CURRENT_SC->SCp.buffer); 2398 SG_ADDRESS(CURRENT_SC->SCp.buffer);
2396 while(data_count>0) { 2399 while(data_count>0) {
2397 CURRENT_SC->SCp.buffer--; 2400 CURRENT_SC->SCp.buffer--;
2398 CURRENT_SC->SCp.buffers_residual++; 2401 CURRENT_SC->SCp.buffers_residual++;
2399 data_count -= CURRENT_SC->SCp.buffer->length; 2402 data_count -= CURRENT_SC->SCp.buffer->length;
2400 }
2401 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) - data_count;
2402 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length + data_count;
2403 } else {
2404 CURRENT_SC->SCp.ptr -= data_count;
2405 CURRENT_SC->SCp.this_residual += data_count;
2406 } 2403 }
2404 CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
2405 data_count;
2406 CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
2407 data_count;
2407 } 2408 }
2408 2409
2409 DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n", 2410 DPRINTK(debug_datao, DEBUG_LEAD "datao_end: request_bufflen=%d; resid=%d; stcnt=%d\n",
2410 CMDINFO(CURRENT_SC), 2411 CMDINFO(CURRENT_SC),
2411 CURRENT_SC->request_bufflen, 2412 scsi_bufflen(CURRENT_SC),
2412 CURRENT_SC->resid, 2413 scsi_get_resid(CURRENT_SC),
2413 GETSTCNT()); 2414 GETSTCNT());
2414 2415
2415 SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT); 2416 SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
@@ -2936,7 +2937,7 @@ static void show_command(Scsi_Cmnd *ptr)
2936 __scsi_print_command(ptr->cmnd); 2937 __scsi_print_command(ptr->cmnd);
2937 2938
2938 printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |", 2939 printk(KERN_DEBUG "); request_bufflen=%d; resid=%d; phase |",
2939 ptr->request_bufflen, ptr->resid); 2940 scsi_bufflen(ptr), scsi_get_resid(ptr));
2940 2941
2941 if (ptr->SCp.phase & not_issued) 2942 if (ptr->SCp.phase & not_issued)
2942 printk("not issued|"); 2943 printk("not issued|");
@@ -3006,7 +3007,8 @@ static int get_command(char *pos, Scsi_Cmnd * ptr)
3006 SPRINTF("0x%02x ", ptr->cmnd[i]); 3007 SPRINTF("0x%02x ", ptr->cmnd[i]);
3007 3008
3008 SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |", 3009 SPRINTF("); resid=%d; residual=%d; buffers=%d; phase |",
3009 ptr->resid, ptr->SCp.this_residual, ptr->SCp.buffers_residual); 3010 scsi_get_resid(ptr), ptr->SCp.this_residual,
3011 ptr->SCp.buffers_residual);
3010 3012
3011 if (ptr->SCp.phase & not_issued) 3013 if (ptr->SCp.phase & not_issued)
3012 SPRINTF("not issued|"); 3014 SPRINTF("not issued|");
@@ -3395,7 +3397,7 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
3395 PDEBUG(debug_datai, "data in"); 3397 PDEBUG(debug_datai, "data in");
3396 PDEBUG(debug_datao, "data out"); 3398 PDEBUG(debug_datao, "data out");
3397 PDEBUG(debug_eh, "eh"); 3399 PDEBUG(debug_eh, "eh");
3398 PDEBUG(debug_locks, "locks"); 3400 PDEBUG(debug_locking, "locks");
3399 PDEBUG(debug_phases, "phases"); 3401 PDEBUG(debug_phases, "phases");
3400 3402
3401 SPRINTF("\n"); 3403 SPRINTF("\n");
@@ -3474,6 +3476,12 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
3474 return thislength < length ? thislength : length; 3476 return thislength < length ? thislength : length;
3475} 3477}
3476 3478
3479static int aha152x_adjust_queue(struct scsi_device *device)
3480{
3481 blk_queue_bounce_limit(device->request_queue, BLK_BOUNCE_HIGH);
3482 return 0;
3483}
3484
3477static struct scsi_host_template aha152x_driver_template = { 3485static struct scsi_host_template aha152x_driver_template = {
3478 .module = THIS_MODULE, 3486 .module = THIS_MODULE,
3479 .name = AHA152X_REVID, 3487 .name = AHA152X_REVID,
@@ -3490,6 +3498,7 @@ static struct scsi_host_template aha152x_driver_template = {
3490 .sg_tablesize = SG_ALL, 3498 .sg_tablesize = SG_ALL,
3491 .cmd_per_lun = 1, 3499 .cmd_per_lun = 1,
3492 .use_clustering = DISABLE_CLUSTERING, 3500 .use_clustering = DISABLE_CLUSTERING,
3501 .slave_alloc = aha152x_adjust_queue,
3493}; 3502};
3494 3503
3495#if !defined(PCMCIA) 3504#if !defined(PCMCIA)
diff --git a/drivers/scsi/aha152x.h b/drivers/scsi/aha152x.h
index d2add24d02a3..ac4bfa438bf2 100644
--- a/drivers/scsi/aha152x.h
+++ b/drivers/scsi/aha152x.h
@@ -298,7 +298,7 @@ typedef union {
298enum { 298enum {
299 debug_procinfo = 0x0001, 299 debug_procinfo = 0x0001,
300 debug_queue = 0x0002, 300 debug_queue = 0x0002,
301 debug_locks = 0x0004, 301 debug_locking = 0x0004,
302 debug_intr = 0x0008, 302 debug_intr = 0x0008,
303 debug_selection = 0x0010, 303 debug_selection = 0x0010,
304 debug_msgo = 0x0020, 304 debug_msgo = 0x0020,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 75733b09f27a..f350b5e89e76 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -1701,7 +1701,16 @@ ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
1701 if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0 1701 if ((*ppr_options & MSG_EXT_PPR_DT_REQ) == 0
1702 && maxsync < AHC_SYNCRATE_ULTRA2) 1702 && maxsync < AHC_SYNCRATE_ULTRA2)
1703 maxsync = AHC_SYNCRATE_ULTRA2; 1703 maxsync = AHC_SYNCRATE_ULTRA2;
1704 1704
1705 /* Now set the maxsync based on the card capabilities
1706 * DT is already done above */
1707 if ((ahc->features & (AHC_DT | AHC_ULTRA2)) == 0
1708 && maxsync < AHC_SYNCRATE_ULTRA)
1709 maxsync = AHC_SYNCRATE_ULTRA;
1710 if ((ahc->features & (AHC_DT | AHC_ULTRA2 | AHC_ULTRA)) == 0
1711 && maxsync < AHC_SYNCRATE_FAST)
1712 maxsync = AHC_SYNCRATE_FAST;
1713
1705 for (syncrate = &ahc_syncrates[maxsync]; 1714 for (syncrate = &ahc_syncrates[maxsync];
1706 syncrate->rate != NULL; 1715 syncrate->rate != NULL;
1707 syncrate++) { 1716 syncrate++) {
@@ -1765,6 +1774,17 @@ ahc_find_period(struct ahc_softc *ahc, u_int scsirate, u_int maxsync)
1765 else 1774 else
1766 scsirate &= SXFR; 1775 scsirate &= SXFR;
1767 1776
1777 /* now set maxsync based on card capabilities */
1778 if ((ahc->features & AHC_DT) == 0 && maxsync < AHC_SYNCRATE_ULTRA2)
1779 maxsync = AHC_SYNCRATE_ULTRA2;
1780 if ((ahc->features & (AHC_DT | AHC_ULTRA2)) == 0
1781 && maxsync < AHC_SYNCRATE_ULTRA)
1782 maxsync = AHC_SYNCRATE_ULTRA;
1783 if ((ahc->features & (AHC_DT | AHC_ULTRA2 | AHC_ULTRA)) == 0
1784 && maxsync < AHC_SYNCRATE_FAST)
1785 maxsync = AHC_SYNCRATE_FAST;
1786
1787
1768 syncrate = &ahc_syncrates[maxsync]; 1788 syncrate = &ahc_syncrates[maxsync];
1769 while (syncrate->rate != NULL) { 1789 while (syncrate->rate != NULL) {
1770 1790
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 2e2362d787ca..502732ac270d 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -173,20 +173,20 @@ static struct pci_device_id dptids[] = {
173}; 173};
174MODULE_DEVICE_TABLE(pci,dptids); 174MODULE_DEVICE_TABLE(pci,dptids);
175 175
176static int adpt_detect(struct scsi_host_template* sht) 176static void adpt_exit(void);
177
178static int adpt_detect(void)
177{ 179{
178 struct pci_dev *pDev = NULL; 180 struct pci_dev *pDev = NULL;
179 adpt_hba* pHba; 181 adpt_hba* pHba;
180 182
181 adpt_init();
182
183 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 183 PINFO("Detecting Adaptec I2O RAID controllers...\n");
184 184
185 /* search for all Adatpec I2O RAID cards */ 185 /* search for all Adatpec I2O RAID cards */
186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { 186 while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) {
187 if(pDev->device == PCI_DPT_DEVICE_ID || 187 if(pDev->device == PCI_DPT_DEVICE_ID ||
188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ 188 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){
189 if(adpt_install_hba(sht, pDev) ){ 189 if(adpt_install_hba(pDev) ){
190 PERROR("Could not Init an I2O RAID device\n"); 190 PERROR("Could not Init an I2O RAID device\n");
191 PERROR("Will not try to detect others.\n"); 191 PERROR("Will not try to detect others.\n");
192 return hba_count-1; 192 return hba_count-1;
@@ -248,34 +248,33 @@ rebuild_sys_tab:
248 } 248 }
249 249
250 for (pHba = hba_chain; pHba; pHba = pHba->next) { 250 for (pHba = hba_chain; pHba; pHba = pHba->next) {
251 if( adpt_scsi_register(pHba,sht) < 0){ 251 if (adpt_scsi_register(pHba) < 0) {
252 adpt_i2o_delete_hba(pHba); 252 adpt_i2o_delete_hba(pHba);
253 continue; 253 continue;
254 } 254 }
255 pHba->initialized = TRUE; 255 pHba->initialized = TRUE;
256 pHba->state &= ~DPTI_STATE_RESET; 256 pHba->state &= ~DPTI_STATE_RESET;
257 scsi_scan_host(pHba->host);
257 } 258 }
258 259
259 // Register our control device node 260 // Register our control device node
260 // nodes will need to be created in /dev to access this 261 // nodes will need to be created in /dev to access this
261 // the nodes can not be created from within the driver 262 // the nodes can not be created from within the driver
262 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) { 263 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) {
263 adpt_i2o_sys_shutdown(); 264 adpt_exit();
264 return 0; 265 return 0;
265 } 266 }
266 return hba_count; 267 return hba_count;
267} 268}
268 269
269 270
270/* 271static int adpt_release(adpt_hba *pHba)
271 * scsi_unregister will be called AFTER we return.
272 */
273static int adpt_release(struct Scsi_Host *host)
274{ 272{
275 adpt_hba* pHba = (adpt_hba*) host->hostdata[0]; 273 struct Scsi_Host *shost = pHba->host;
274 scsi_remove_host(shost);
276// adpt_i2o_quiesce_hba(pHba); 275// adpt_i2o_quiesce_hba(pHba);
277 adpt_i2o_delete_hba(pHba); 276 adpt_i2o_delete_hba(pHba);
278 scsi_unregister(host); 277 scsi_host_put(shost);
279 return 0; 278 return 0;
280} 279}
281 280
@@ -882,7 +881,7 @@ static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p)
882#endif 881#endif
883 882
884 883
885static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) 884static int adpt_install_hba(struct pci_dev* pDev)
886{ 885{
887 886
888 adpt_hba* pHba = NULL; 887 adpt_hba* pHba = NULL;
@@ -1031,8 +1030,6 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1031 1030
1032 1031
1033 mutex_lock(&adpt_configuration_lock); 1032 mutex_lock(&adpt_configuration_lock);
1034 // scsi_unregister calls our adpt_release which
1035 // does a quiese
1036 if(pHba->host){ 1033 if(pHba->host){
1037 free_irq(pHba->host->irq, pHba); 1034 free_irq(pHba->host->irq, pHba);
1038 } 1035 }
@@ -1084,17 +1081,6 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1084} 1081}
1085 1082
1086 1083
1087static int adpt_init(void)
1088{
1089 printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n");
1090#ifdef REBOOT_NOTIFIER
1091 register_reboot_notifier(&adpt_reboot_notifier);
1092#endif
1093
1094 return 0;
1095}
1096
1097
1098static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun) 1084static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun)
1099{ 1085{
1100 struct adpt_device* d; 1086 struct adpt_device* d;
@@ -2180,37 +2166,6 @@ static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_d
2180} 2166}
2181 2167
2182 2168
2183static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht)
2184{
2185 struct Scsi_Host *host = NULL;
2186
2187 host = scsi_register(sht, sizeof(adpt_hba*));
2188 if (host == NULL) {
2189 printk ("%s: scsi_register returned NULL\n",pHba->name);
2190 return -1;
2191 }
2192 host->hostdata[0] = (unsigned long)pHba;
2193 pHba->host = host;
2194
2195 host->irq = pHba->pDev->irq;
2196 /* no IO ports, so don't have to set host->io_port and
2197 * host->n_io_port
2198 */
2199 host->io_port = 0;
2200 host->n_io_port = 0;
2201 /* see comments in scsi_host.h */
2202 host->max_id = 16;
2203 host->max_lun = 256;
2204 host->max_channel = pHba->top_scsi_channel + 1;
2205 host->cmd_per_lun = 1;
2206 host->unique_id = (uint) pHba;
2207 host->sg_tablesize = pHba->sg_tablesize;
2208 host->can_queue = pHba->post_fifo_size;
2209
2210 return 0;
2211}
2212
2213
2214static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd) 2169static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd)
2215{ 2170{
2216 adpt_hba* pHba; 2171 adpt_hba* pHba;
@@ -3329,12 +3284,10 @@ static static void adpt_delay(int millisec)
3329 3284
3330#endif 3285#endif
3331 3286
3332static struct scsi_host_template driver_template = { 3287static struct scsi_host_template adpt_template = {
3333 .name = "dpt_i2o", 3288 .name = "dpt_i2o",
3334 .proc_name = "dpt_i2o", 3289 .proc_name = "dpt_i2o",
3335 .proc_info = adpt_proc_info, 3290 .proc_info = adpt_proc_info,
3336 .detect = adpt_detect,
3337 .release = adpt_release,
3338 .info = adpt_info, 3291 .info = adpt_info,
3339 .queuecommand = adpt_queue, 3292 .queuecommand = adpt_queue,
3340 .eh_abort_handler = adpt_abort, 3293 .eh_abort_handler = adpt_abort,
@@ -3348,5 +3301,62 @@ static struct scsi_host_template driver_template = {
3348 .cmd_per_lun = 1, 3301 .cmd_per_lun = 1,
3349 .use_clustering = ENABLE_CLUSTERING, 3302 .use_clustering = ENABLE_CLUSTERING,
3350}; 3303};
3351#include "scsi_module.c" 3304
3305static s32 adpt_scsi_register(adpt_hba* pHba)
3306{
3307 struct Scsi_Host *host;
3308
3309 host = scsi_host_alloc(&adpt_template, sizeof(adpt_hba*));
3310 if (host == NULL) {
3311 printk ("%s: scsi_host_alloc returned NULL\n",pHba->name);
3312 return -1;
3313 }
3314 host->hostdata[0] = (unsigned long)pHba;
3315 pHba->host = host;
3316
3317 host->irq = pHba->pDev->irq;
3318 /* no IO ports, so don't have to set host->io_port and
3319 * host->n_io_port
3320 */
3321 host->io_port = 0;
3322 host->n_io_port = 0;
3323 /* see comments in scsi_host.h */
3324 host->max_id = 16;
3325 host->max_lun = 256;
3326 host->max_channel = pHba->top_scsi_channel + 1;
3327 host->cmd_per_lun = 1;
3328 host->unique_id = (uint) pHba;
3329 host->sg_tablesize = pHba->sg_tablesize;
3330 host->can_queue = pHba->post_fifo_size;
3331
3332 if (scsi_add_host(host, &pHba->pDev->dev)) {
3333 scsi_host_put(host);
3334 return -1;
3335 }
3336
3337 return 0;
3338}
3339
3340static int __init adpt_init(void)
3341{
3342 int count;
3343
3344 printk("Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n");
3345#ifdef REBOOT_NOTIFIER
3346 register_reboot_notifier(&adpt_reboot_notifier);
3347#endif
3348
3349 count = adpt_detect();
3350
3351 return count > 0 ? 0 : -ENODEV;
3352}
3353
3354static void __exit adpt_exit(void)
3355{
3356 while (hba_chain)
3357 adpt_release(hba_chain);
3358}
3359
3360module_init(adpt_init);
3361module_exit(adpt_exit);
3352MODULE_LICENSE("GPL"); 3362MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index fd79068c5869..0892f6c70319 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -28,11 +28,9 @@
28 * SCSI interface function Prototypes 28 * SCSI interface function Prototypes
29 */ 29 */
30 30
31static int adpt_detect(struct scsi_host_template * sht);
32static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *)); 31static int adpt_queue(struct scsi_cmnd * cmd, void (*cmdcomplete) (struct scsi_cmnd *));
33static int adpt_abort(struct scsi_cmnd * cmd); 32static int adpt_abort(struct scsi_cmnd * cmd);
34static int adpt_reset(struct scsi_cmnd* cmd); 33static int adpt_reset(struct scsi_cmnd* cmd);
35static int adpt_release(struct Scsi_Host *host);
36static int adpt_slave_configure(struct scsi_device *); 34static int adpt_slave_configure(struct scsi_device *);
37 35
38static const char *adpt_info(struct Scsi_Host *pSHost); 36static const char *adpt_info(struct Scsi_Host *pSHost);
@@ -49,8 +47,6 @@ static int adpt_device_reset(struct scsi_cmnd* cmd);
49 47
50#define DPT_DRIVER_NAME "Adaptec I2O RAID" 48#define DPT_DRIVER_NAME "Adaptec I2O RAID"
51 49
52#ifndef HOSTS_C
53
54#include "dpt/sys_info.h" 50#include "dpt/sys_info.h"
55#include <linux/wait.h> 51#include <linux/wait.h>
56#include "dpt/dpti_i2o.h" 52#include "dpt/dpti_i2o.h"
@@ -289,7 +285,7 @@ static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba);
289static s32 adpt_i2o_hrt_get(adpt_hba* pHba); 285static s32 adpt_i2o_hrt_get(adpt_hba* pHba);
290static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice); 286static s32 adpt_scsi_to_i2o(adpt_hba* pHba, struct scsi_cmnd* cmd, struct adpt_device* dptdevice);
291static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd); 287static s32 adpt_i2o_to_scsi(void __iomem *reply, struct scsi_cmnd* cmd);
292static s32 adpt_scsi_register(adpt_hba* pHba,struct scsi_host_template * sht); 288static s32 adpt_scsi_register(adpt_hba* pHba);
293static s32 adpt_hba_reset(adpt_hba* pHba); 289static s32 adpt_hba_reset(adpt_hba* pHba);
294static s32 adpt_i2o_reset_hba(adpt_hba* pHba); 290static s32 adpt_i2o_reset_hba(adpt_hba* pHba);
295static s32 adpt_rescan(adpt_hba* pHba); 291static s32 adpt_rescan(adpt_hba* pHba);
@@ -299,7 +295,7 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba);
299static void adpt_inquiry(adpt_hba* pHba); 295static void adpt_inquiry(adpt_hba* pHba);
300static void adpt_fail_posted_scbs(adpt_hba* pHba); 296static void adpt_fail_posted_scbs(adpt_hba* pHba);
301static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun); 297static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun);
302static int adpt_install_hba(struct scsi_host_template* sht, struct pci_dev* pDev) ; 298static int adpt_install_hba(struct pci_dev* pDev) ;
303static int adpt_i2o_online_hba(adpt_hba* pHba); 299static int adpt_i2o_online_hba(adpt_hba* pHba);
304static void adpt_i2o_post_wait_complete(u32, int); 300static void adpt_i2o_post_wait_complete(u32, int);
305static int adpt_i2o_systab_send(adpt_hba* pHba); 301static int adpt_i2o_systab_send(adpt_hba* pHba);
@@ -343,5 +339,4 @@ static void adpt_i386_info(sysInfo_S* si);
343#define FW_DEBUG_BLED_OFFSET 8 339#define FW_DEBUG_BLED_OFFSET 8
344 340
345#define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01 341#define FW_DEBUG_FLAGS_NO_HEADERS_B 0x01
346#endif /* !HOSTS_C */
347#endif /* _DPT_H */ 342#endif /* _DPT_H */
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
index 856e38b14861..d5576d54ce76 100644
--- a/drivers/scsi/esp_scsi.h
+++ b/drivers/scsi/esp_scsi.h
@@ -220,7 +220,7 @@
220#define ESP_BUSID_RESELID 0x10 220#define ESP_BUSID_RESELID 0x10
221#define ESP_BUSID_CTR32BIT 0x40 221#define ESP_BUSID_CTR32BIT 0x40
222 222
223#define ESP_BUS_TIMEOUT 275 /* In milli-seconds */ 223#define ESP_BUS_TIMEOUT 250 /* In milli-seconds */
224#define ESP_TIMEO_CONST 8192 224#define ESP_TIMEO_CONST 8192
225#define ESP_NEG_DEFP(mhz, cfact) \ 225#define ESP_NEG_DEFP(mhz, cfact) \
226 ((ESP_BUS_TIMEOUT * ((mhz) / 1000)) / (8192 * (cfact))) 226 ((ESP_BUS_TIMEOUT * ((mhz) / 1000)) / (8192 * (cfact)))
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index d0b95ce0ba00..55e4d2dc2bbe 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -902,11 +902,6 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
902 return; 902 return;
903 /* GDT PCI controller found, resources are already in pdev */ 903 /* GDT PCI controller found, resources are already in pdev */
904 pcistr[*cnt].pdev = pdev; 904 pcistr[*cnt].pdev = pdev;
905 pcistr[*cnt].vendor_id = vendor;
906 pcistr[*cnt].device_id = device;
907 pcistr[*cnt].subdevice_id = pdev->subsystem_device;
908 pcistr[*cnt].bus = pdev->bus->number;
909 pcistr[*cnt].device_fn = pdev->devfn;
910 pcistr[*cnt].irq = pdev->irq; 905 pcistr[*cnt].irq = pdev->irq;
911 base0 = pci_resource_flags(pdev, 0); 906 base0 = pci_resource_flags(pdev, 0);
912 base1 = pci_resource_flags(pdev, 1); 907 base1 = pci_resource_flags(pdev, 1);
@@ -926,7 +921,8 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
926 pcistr[*cnt].io = pci_resource_start(pdev, 1); 921 pcistr[*cnt].io = pci_resource_start(pdev, 1);
927 } 922 }
928 TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n", 923 TRACE2(("Controller found at %d/%d, irq %d, dpmem 0x%lx\n",
929 pcistr[*cnt].bus, PCI_SLOT(pcistr[*cnt].device_fn), 924 pcistr[*cnt].pdev->bus->number,
925 PCI_SLOT(pcistr[*cnt].pdev->devfn),
930 pcistr[*cnt].irq, pcistr[*cnt].dpmem)); 926 pcistr[*cnt].irq, pcistr[*cnt].dpmem));
931 (*cnt)++; 927 (*cnt)++;
932 } 928 }
@@ -946,20 +942,20 @@ static void __init gdth_sort_pci(gdth_pci_str *pcistr, int cnt)
946 changed = FALSE; 942 changed = FALSE;
947 for (i = 0; i < cnt-1; ++i) { 943 for (i = 0; i < cnt-1; ++i) {
948 if (!reverse_scan) { 944 if (!reverse_scan) {
949 if ((pcistr[i].bus > pcistr[i+1].bus) || 945 if ((pcistr[i].pdev->bus->number > pcistr[i+1].pdev->bus->number) ||
950 (pcistr[i].bus == pcistr[i+1].bus && 946 (pcistr[i].pdev->bus->number == pcistr[i+1].pdev->bus->number &&
951 PCI_SLOT(pcistr[i].device_fn) > 947 PCI_SLOT(pcistr[i].pdev->devfn) >
952 PCI_SLOT(pcistr[i+1].device_fn))) { 948 PCI_SLOT(pcistr[i+1].pdev->devfn))) {
953 temp = pcistr[i]; 949 temp = pcistr[i];
954 pcistr[i] = pcistr[i+1]; 950 pcistr[i] = pcistr[i+1];
955 pcistr[i+1] = temp; 951 pcistr[i+1] = temp;
956 changed = TRUE; 952 changed = TRUE;
957 } 953 }
958 } else { 954 } else {
959 if ((pcistr[i].bus < pcistr[i+1].bus) || 955 if ((pcistr[i].pdev->bus->number < pcistr[i+1].pdev->bus->number) ||
960 (pcistr[i].bus == pcistr[i+1].bus && 956 (pcistr[i].pdev->bus->number == pcistr[i+1].pdev->bus->number &&
961 PCI_SLOT(pcistr[i].device_fn) < 957 PCI_SLOT(pcistr[i].pdev->devfn) <
962 PCI_SLOT(pcistr[i+1].device_fn))) { 958 PCI_SLOT(pcistr[i+1].pdev->devfn))) {
963 temp = pcistr[i]; 959 temp = pcistr[i];
964 pcistr[i] = pcistr[i+1]; 960 pcistr[i] = pcistr[i+1];
965 pcistr[i+1] = temp; 961 pcistr[i+1] = temp;
@@ -1176,17 +1172,16 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
1176 1172
1177 TRACE(("gdth_init_pci()\n")); 1173 TRACE(("gdth_init_pci()\n"));
1178 1174
1179 if (pcistr->vendor_id == PCI_VENDOR_ID_INTEL) 1175 if (pcistr->pdev->vendor == PCI_VENDOR_ID_INTEL)
1180 ha->oem_id = OEM_ID_INTEL; 1176 ha->oem_id = OEM_ID_INTEL;
1181 else 1177 else
1182 ha->oem_id = OEM_ID_ICP; 1178 ha->oem_id = OEM_ID_ICP;
1183 ha->brd_phys = (pcistr->bus << 8) | (pcistr->device_fn & 0xf8); 1179 ha->brd_phys = (pcistr->pdev->bus->number << 8) | (pcistr->pdev->devfn & 0xf8);
1184 ha->stype = (ulong32)pcistr->device_id; 1180 ha->stype = (ulong32)pcistr->pdev->device;
1185 ha->subdevice_id = pcistr->subdevice_id;
1186 ha->irq = pcistr->irq; 1181 ha->irq = pcistr->irq;
1187 ha->pdev = pcistr->pdev; 1182 ha->pdev = pcistr->pdev;
1188 1183
1189 if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */ 1184 if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000/B */
1190 TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); 1185 TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq));
1191 ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6_dpram_str)); 1186 ha->brd = ioremap(pcistr->dpmem, sizeof(gdt6_dpram_str));
1192 if (ha->brd == NULL) { 1187 if (ha->brd == NULL) {
@@ -1293,7 +1288,7 @@ static int __init gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)
1293 1288
1294 ha->dma64_support = 0; 1289 ha->dma64_support = 0;
1295 1290
1296 } else if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, ... */ 1291 } else if (ha->pdev->device <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, ... */
1297 ha->plx = (gdt6c_plx_regs *)pcistr->io; 1292 ha->plx = (gdt6c_plx_regs *)pcistr->io;
1298 TRACE2(("init_pci_new() dpmem %lx irq %d\n", 1293 TRACE2(("init_pci_new() dpmem %lx irq %d\n",
1299 pcistr->dpmem,ha->irq)); 1294 pcistr->dpmem,ha->irq));
@@ -4601,7 +4596,8 @@ static int __init gdth_detect(Scsi_Host_Template *shtp)
4601 } 4596 }
4602 /* controller found and initialized */ 4597 /* controller found and initialized */
4603 printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n", 4598 printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
4604 pcistr[ctr].bus,PCI_SLOT(pcistr[ctr].device_fn),ha->irq); 4599 pcistr[ctr].pdev->bus->number,
4600 PCI_SLOT(pcistr[ctr].pdev->devfn), ha->irq);
4605 4601
4606 if (request_irq(ha->irq, gdth_interrupt, 4602 if (request_irq(ha->irq, gdth_interrupt,
4607 IRQF_DISABLED|IRQF_SHARED, "gdth", ha)) 4603 IRQF_DISABLED|IRQF_SHARED, "gdth", ha))
@@ -4637,7 +4633,7 @@ static int __init gdth_detect(Scsi_Host_Template *shtp)
4637#endif 4633#endif
4638 ha->scratch_busy = FALSE; 4634 ha->scratch_busy = FALSE;
4639 ha->req_first = NULL; 4635 ha->req_first = NULL;
4640 ha->tid_cnt = pcistr[ctr].device_id >= 0x200 ? MAXID : MAX_HDRIVES; 4636 ha->tid_cnt = pcistr[ctr].pdev->device >= 0x200 ? MAXID : MAX_HDRIVES;
4641 if (max_ids > 0 && max_ids < ha->tid_cnt) 4637 if (max_ids > 0 && max_ids < ha->tid_cnt)
4642 ha->tid_cnt = max_ids; 4638 ha->tid_cnt = max_ids;
4643 for (i=0; i<GDTH_MAXCMDS; ++i) 4639 for (i=0; i<GDTH_MAXCMDS; ++i)
@@ -4810,7 +4806,7 @@ static const char *gdth_ctr_name(int hanum)
4810 } else if (ha->type == GDT_ISA) { 4806 } else if (ha->type == GDT_ISA) {
4811 return("GDT2000/2020"); 4807 return("GDT2000/2020");
4812 } else if (ha->type == GDT_PCI) { 4808 } else if (ha->type == GDT_PCI) {
4813 switch (ha->stype) { 4809 switch (ha->pdev->device) {
4814 case PCI_DEVICE_ID_VORTEX_GDT60x0: 4810 case PCI_DEVICE_ID_VORTEX_GDT60x0:
4815 return("GDT6000/6020/6050"); 4811 return("GDT6000/6020/6050");
4816 case PCI_DEVICE_ID_VORTEX_GDT6000B: 4812 case PCI_DEVICE_ID_VORTEX_GDT6000B:
@@ -5448,12 +5444,12 @@ static int gdth_ioctl(struct inode *inode, struct file *filep,
5448 ctrt.type = 5444 ctrt.type =
5449 (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe); 5445 (ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe);
5450 if (ha->stype >= 0x300) 5446 if (ha->stype >= 0x300)
5451 ctrt.ext_type = 0x6000 | ha->subdevice_id; 5447 ctrt.ext_type = 0x6000 | ha->pdev->subsystem_device;
5452 else 5448 else
5453 ctrt.ext_type = 0x6000 | ha->stype; 5449 ctrt.ext_type = 0x6000 | ha->stype;
5454 } 5450 }
5455 ctrt.device_id = ha->stype; 5451 ctrt.device_id = ha->pdev->device;
5456 ctrt.sub_device_id = ha->subdevice_id; 5452 ctrt.sub_device_id = ha->pdev->subsystem_device;
5457 } 5453 }
5458 ctrt.info = ha->brd_phys; 5454 ctrt.info = ha->brd_phys;
5459 ctrt.oem_id = ha->oem_id; 5455 ctrt.oem_id = ha->oem_id;
diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
index 8c29eafd51c5..37423300592e 100644
--- a/drivers/scsi/gdth.h
+++ b/drivers/scsi/gdth.h
@@ -845,11 +845,6 @@ typedef struct {
845/* PCI resources */ 845/* PCI resources */
846typedef struct { 846typedef struct {
847 struct pci_dev *pdev; 847 struct pci_dev *pdev;
848 ushort vendor_id; /* vendor (ICP, Intel, ..) */
849 ushort device_id; /* device ID (0,..,9) */
850 ushort subdevice_id; /* sub device ID */
851 unchar bus; /* PCI bus */
852 unchar device_fn; /* PCI device/function no. */
853 ulong dpmem; /* DPRAM address */ 848 ulong dpmem; /* DPRAM address */
854 ulong io; /* IO address */ 849 ulong io; /* IO address */
855 ulong io_mm; /* IO address mem. mapped */ 850 ulong io_mm; /* IO address mem. mapped */
@@ -862,7 +857,6 @@ typedef struct {
862 ushort oem_id; /* OEM */ 857 ushort oem_id; /* OEM */
863 ushort type; /* controller class */ 858 ushort type; /* controller class */
864 ulong32 stype; /* subtype (PCI: device ID) */ 859 ulong32 stype; /* subtype (PCI: device ID) */
865 ushort subdevice_id; /* sub device ID (PCI) */
866 ushort fw_vers; /* firmware version */ 860 ushort fw_vers; /* firmware version */
867 ushort cache_feat; /* feat. cache serv. (s/g,..)*/ 861 ushort cache_feat; /* feat. cache serv. (s/g,..)*/
868 ushort raw_feat; /* feat. raw service (s/g,..)*/ 862 ushort raw_feat; /* feat. raw service (s/g,..)*/
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index bd8e7f323c69..96bc31266c98 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -220,7 +220,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
220 get_device(&shost->shost_gendev); 220 get_device(&shost->shost_gendev);
221 221
222 if (shost->transportt->host_size && 222 if (shost->transportt->host_size &&
223 (shost->shost_data = kmalloc(shost->transportt->host_size, 223 (shost->shost_data = kzalloc(shost->transportt->host_size,
224 GFP_KERNEL)) == NULL) 224 GFP_KERNEL)) == NULL)
225 goto out_del_classdev; 225 goto out_del_classdev;
226 226
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 5870866abc99..5ecc63d1b436 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -393,12 +393,6 @@ static int map_sg_data(struct scsi_cmnd *cmd,
393 return 1; 393 return 1;
394 else if (sg_mapped < 0) 394 else if (sg_mapped < 0)
395 return 0; 395 return 0;
396 else if (sg_mapped > SG_ALL) {
397 printk(KERN_ERR
398 "ibmvscsi: More than %d mapped sg entries, got %d\n",
399 SG_ALL, sg_mapped);
400 return 0;
401 }
402 396
403 set_srp_direction(cmd, srp_cmd, sg_mapped); 397 set_srp_direction(cmd, srp_cmd, sg_mapped);
404 398
@@ -708,8 +702,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd,
708 struct srp_cmd *srp_cmd; 702 struct srp_cmd *srp_cmd;
709 struct srp_event_struct *evt_struct; 703 struct srp_event_struct *evt_struct;
710 struct srp_indirect_buf *indirect; 704 struct srp_indirect_buf *indirect;
711 struct ibmvscsi_host_data *hostdata = 705 struct ibmvscsi_host_data *hostdata = shost_priv(cmnd->device->host);
712 (struct ibmvscsi_host_data *)&cmnd->device->host->hostdata;
713 u16 lun = lun_from_dev(cmnd->device); 706 u16 lun = lun_from_dev(cmnd->device);
714 u8 out_fmt, in_fmt; 707 u8 out_fmt, in_fmt;
715 708
@@ -960,8 +953,7 @@ static void sync_completion(struct srp_event_struct *evt_struct)
960 */ 953 */
961static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd) 954static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
962{ 955{
963 struct ibmvscsi_host_data *hostdata = 956 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host);
964 (struct ibmvscsi_host_data *)cmd->device->host->hostdata;
965 struct srp_tsk_mgmt *tsk_mgmt; 957 struct srp_tsk_mgmt *tsk_mgmt;
966 struct srp_event_struct *evt; 958 struct srp_event_struct *evt;
967 struct srp_event_struct *tmp_evt, *found_evt; 959 struct srp_event_struct *tmp_evt, *found_evt;
@@ -1084,9 +1076,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1084 */ 1076 */
1085static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) 1077static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1086{ 1078{
1087 struct ibmvscsi_host_data *hostdata = 1079 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host);
1088 (struct ibmvscsi_host_data *)cmd->device->host->hostdata;
1089
1090 struct srp_tsk_mgmt *tsk_mgmt; 1080 struct srp_tsk_mgmt *tsk_mgmt;
1091 struct srp_event_struct *evt; 1081 struct srp_event_struct *evt;
1092 struct srp_event_struct *tmp_evt, *pos; 1082 struct srp_event_struct *tmp_evt, *pos;
@@ -1183,8 +1173,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1183static int ibmvscsi_eh_host_reset_handler(struct scsi_cmnd *cmd) 1173static int ibmvscsi_eh_host_reset_handler(struct scsi_cmnd *cmd)
1184{ 1174{
1185 unsigned long wait_switch = 0; 1175 unsigned long wait_switch = 0;
1186 struct ibmvscsi_host_data *hostdata = 1176 struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host);
1187 (struct ibmvscsi_host_data *)cmd->device->host->hostdata;
1188 1177
1189 dev_err(hostdata->dev, "Resetting connection due to error recovery\n"); 1178 dev_err(hostdata->dev, "Resetting connection due to error recovery\n");
1190 1179
@@ -1412,8 +1401,7 @@ static int ibmvscsi_change_queue_depth(struct scsi_device *sdev, int qdepth)
1412static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf) 1401static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf)
1413{ 1402{
1414 struct Scsi_Host *shost = class_to_shost(class_dev); 1403 struct Scsi_Host *shost = class_to_shost(class_dev);
1415 struct ibmvscsi_host_data *hostdata = 1404 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1416 (struct ibmvscsi_host_data *)shost->hostdata;
1417 int len; 1405 int len;
1418 1406
1419 len = snprintf(buf, PAGE_SIZE, "%s\n", 1407 len = snprintf(buf, PAGE_SIZE, "%s\n",
@@ -1433,8 +1421,7 @@ static ssize_t show_host_partition_name(struct class_device *class_dev,
1433 char *buf) 1421 char *buf)
1434{ 1422{
1435 struct Scsi_Host *shost = class_to_shost(class_dev); 1423 struct Scsi_Host *shost = class_to_shost(class_dev);
1436 struct ibmvscsi_host_data *hostdata = 1424 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1437 (struct ibmvscsi_host_data *)shost->hostdata;
1438 int len; 1425 int len;
1439 1426
1440 len = snprintf(buf, PAGE_SIZE, "%s\n", 1427 len = snprintf(buf, PAGE_SIZE, "%s\n",
@@ -1454,8 +1441,7 @@ static ssize_t show_host_partition_number(struct class_device *class_dev,
1454 char *buf) 1441 char *buf)
1455{ 1442{
1456 struct Scsi_Host *shost = class_to_shost(class_dev); 1443 struct Scsi_Host *shost = class_to_shost(class_dev);
1457 struct ibmvscsi_host_data *hostdata = 1444 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1458 (struct ibmvscsi_host_data *)shost->hostdata;
1459 int len; 1445 int len;
1460 1446
1461 len = snprintf(buf, PAGE_SIZE, "%d\n", 1447 len = snprintf(buf, PAGE_SIZE, "%d\n",
@@ -1474,8 +1460,7 @@ static struct class_device_attribute ibmvscsi_host_partition_number = {
1474static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf) 1460static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf)
1475{ 1461{
1476 struct Scsi_Host *shost = class_to_shost(class_dev); 1462 struct Scsi_Host *shost = class_to_shost(class_dev);
1477 struct ibmvscsi_host_data *hostdata = 1463 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1478 (struct ibmvscsi_host_data *)shost->hostdata;
1479 int len; 1464 int len;
1480 1465
1481 len = snprintf(buf, PAGE_SIZE, "%d\n", 1466 len = snprintf(buf, PAGE_SIZE, "%d\n",
@@ -1494,8 +1479,7 @@ static struct class_device_attribute ibmvscsi_host_mad_version = {
1494static ssize_t show_host_os_type(struct class_device *class_dev, char *buf) 1479static ssize_t show_host_os_type(struct class_device *class_dev, char *buf)
1495{ 1480{
1496 struct Scsi_Host *shost = class_to_shost(class_dev); 1481 struct Scsi_Host *shost = class_to_shost(class_dev);
1497 struct ibmvscsi_host_data *hostdata = 1482 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1498 (struct ibmvscsi_host_data *)shost->hostdata;
1499 int len; 1483 int len;
1500 1484
1501 len = snprintf(buf, PAGE_SIZE, "%d\n", hostdata->madapter_info.os_type); 1485 len = snprintf(buf, PAGE_SIZE, "%d\n", hostdata->madapter_info.os_type);
@@ -1513,8 +1497,7 @@ static struct class_device_attribute ibmvscsi_host_os_type = {
1513static ssize_t show_host_config(struct class_device *class_dev, char *buf) 1497static ssize_t show_host_config(struct class_device *class_dev, char *buf)
1514{ 1498{
1515 struct Scsi_Host *shost = class_to_shost(class_dev); 1499 struct Scsi_Host *shost = class_to_shost(class_dev);
1516 struct ibmvscsi_host_data *hostdata = 1500 struct ibmvscsi_host_data *hostdata = shost_priv(shost);
1517 (struct ibmvscsi_host_data *)shost->hostdata;
1518 1501
1519 /* returns null-terminated host config data */ 1502 /* returns null-terminated host config data */
1520 if (ibmvscsi_do_host_config(hostdata, buf, PAGE_SIZE) == 0) 1503 if (ibmvscsi_do_host_config(hostdata, buf, PAGE_SIZE) == 0)
@@ -1582,7 +1565,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1582 goto scsi_host_alloc_failed; 1565 goto scsi_host_alloc_failed;
1583 } 1566 }
1584 1567
1585 hostdata = (struct ibmvscsi_host_data *)host->hostdata; 1568 hostdata = shost_priv(host);
1586 memset(hostdata, 0x00, sizeof(*hostdata)); 1569 memset(hostdata, 0x00, sizeof(*hostdata));
1587 INIT_LIST_HEAD(&hostdata->sent); 1570 INIT_LIST_HEAD(&hostdata->sent);
1588 hostdata->host = host; 1571 hostdata->host = host;
diff --git a/drivers/scsi/libsas/Kconfig b/drivers/scsi/libsas/Kconfig
index 3a3c1ac9c6cd..c01a40d321d4 100644
--- a/drivers/scsi/libsas/Kconfig
+++ b/drivers/scsi/libsas/Kconfig
@@ -32,7 +32,8 @@ config SCSI_SAS_LIBSAS
32 32
33config SCSI_SAS_ATA 33config SCSI_SAS_ATA
34 bool "ATA support for libsas (requires libata)" 34 bool "ATA support for libsas (requires libata)"
35 depends on SCSI_SAS_LIBSAS && ATA 35 depends on SCSI_SAS_LIBSAS
36 depends on ATA = y || ATA = SCSI_SAS_LIBSAS
36 help 37 help
37 Builds in ATA support into libsas. Will necessitate 38 Builds in ATA support into libsas. Will necessitate
38 the loading of libata along with libsas. 39 the loading of libata along with libsas.
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index f8f64d6485cd..ba3ecab9baf3 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -45,7 +45,7 @@ struct lpfc_sli2_slim;
45#define LPFC_DISC_IOCB_BUFF_COUNT 20 45#define LPFC_DISC_IOCB_BUFF_COUNT 20
46 46
47#define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */ 47#define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */
48#define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */ 48#define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */
49 49
50/* Define macros for 64 bit support */ 50/* Define macros for 64 bit support */
51#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr))) 51#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
@@ -78,6 +78,7 @@ struct lpfc_dma_pool {
78 78
79struct hbq_dmabuf { 79struct hbq_dmabuf {
80 struct lpfc_dmabuf dbuf; 80 struct lpfc_dmabuf dbuf;
81 uint32_t size;
81 uint32_t tag; 82 uint32_t tag;
82}; 83};
83 84
@@ -329,13 +330,30 @@ struct lpfc_vport {
329#define FC_LOADING 0x1 /* HBA in process of loading drvr */ 330#define FC_LOADING 0x1 /* HBA in process of loading drvr */
330#define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */ 331#define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */
331 char *vname; /* Application assigned name */ 332 char *vname; /* Application assigned name */
333
334 /* Vport Config Parameters */
335 uint32_t cfg_scan_down;
336 uint32_t cfg_lun_queue_depth;
337 uint32_t cfg_nodev_tmo;
338 uint32_t cfg_devloss_tmo;
339 uint32_t cfg_restrict_login;
340 uint32_t cfg_peer_port_login;
341 uint32_t cfg_fcp_class;
342 uint32_t cfg_use_adisc;
343 uint32_t cfg_fdmi_on;
344 uint32_t cfg_discovery_threads;
345 uint32_t cfg_log_verbose;
346 uint32_t cfg_max_luns;
347
348 uint32_t dev_loss_tmo_changed;
349
332 struct fc_vport *fc_vport; 350 struct fc_vport *fc_vport;
333 351
334#ifdef CONFIG_LPFC_DEBUG_FS 352#ifdef CONFIG_LPFC_DEBUG_FS
335 struct dentry *debug_disc_trc; 353 struct dentry *debug_disc_trc;
336 struct dentry *debug_nodelist; 354 struct dentry *debug_nodelist;
337 struct dentry *vport_debugfs_root; 355 struct dentry *vport_debugfs_root;
338 struct lpfc_disc_trc *disc_trc; 356 struct lpfc_debugfs_trc *disc_trc;
339 atomic_t disc_trc_cnt; 357 atomic_t disc_trc_cnt;
340#endif 358#endif
341}; 359};
@@ -345,17 +363,25 @@ struct hbq_s {
345 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */ 363 uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
346 uint32_t hbqPutIdx; /* HBQ slot to use */ 364 uint32_t hbqPutIdx; /* HBQ slot to use */
347 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */ 365 uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
366 void *hbq_virt; /* Virtual ptr to this hbq */
367 struct list_head hbq_buffer_list; /* buffers assigned to this HBQ */
368 /* Callback for HBQ buffer allocation */
369 struct hbq_dmabuf *(*hbq_alloc_buffer) (struct lpfc_hba *);
370 /* Callback for HBQ buffer free */
371 void (*hbq_free_buffer) (struct lpfc_hba *,
372 struct hbq_dmabuf *);
348}; 373};
349 374
350#define LPFC_MAX_HBQS 16 375#define LPFC_MAX_HBQS 4
351/* this matches the possition in the lpfc_hbq_defs array */ 376/* this matches the position in the lpfc_hbq_defs array */
352#define LPFC_ELS_HBQ 0 377#define LPFC_ELS_HBQ 0
378#define LPFC_EXTRA_HBQ 1
353 379
354struct lpfc_hba { 380struct lpfc_hba {
355 struct lpfc_sli sli; 381 struct lpfc_sli sli;
356 uint32_t sli_rev; /* SLI2 or SLI3 */ 382 uint32_t sli_rev; /* SLI2 or SLI3 */
357 uint32_t sli3_options; /* Mask of enabled SLI3 options */ 383 uint32_t sli3_options; /* Mask of enabled SLI3 options */
358#define LPFC_SLI3_ENABLED 0x01 384#define LPFC_SLI3_ENABLED 0x01
359#define LPFC_SLI3_HBQ_ENABLED 0x02 385#define LPFC_SLI3_HBQ_ENABLED 0x02
360#define LPFC_SLI3_NPIV_ENABLED 0x04 386#define LPFC_SLI3_NPIV_ENABLED 0x04
361#define LPFC_SLI3_VPORT_TEARDOWN 0x08 387#define LPFC_SLI3_VPORT_TEARDOWN 0x08
@@ -364,7 +390,7 @@ struct lpfc_hba {
364 390
365 enum hba_state link_state; 391 enum hba_state link_state;
366 uint32_t link_flag; /* link state flags */ 392 uint32_t link_flag; /* link state flags */
367#define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */ 393#define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */
368 /* This flag is set while issuing */ 394 /* This flag is set while issuing */
369 /* INIT_LINK mailbox command */ 395 /* INIT_LINK mailbox command */
370#define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */ 396#define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
@@ -413,28 +439,16 @@ struct lpfc_hba {
413 uint8_t wwpn[8]; 439 uint8_t wwpn[8];
414 uint32_t RandomData[7]; 440 uint32_t RandomData[7];
415 441
416 uint32_t cfg_log_verbose; 442 /* HBA Config Parameters */
417 uint32_t cfg_lun_queue_depth;
418 uint32_t cfg_nodev_tmo;
419 uint32_t cfg_devloss_tmo;
420 uint32_t cfg_hba_queue_depth;
421 uint32_t cfg_peer_port_login;
422 uint32_t cfg_vport_restrict_login;
423 uint32_t cfg_npiv_enable;
424 uint32_t cfg_fcp_class;
425 uint32_t cfg_use_adisc;
426 uint32_t cfg_ack0; 443 uint32_t cfg_ack0;
444 uint32_t cfg_enable_npiv;
427 uint32_t cfg_topology; 445 uint32_t cfg_topology;
428 uint32_t cfg_scan_down;
429 uint32_t cfg_link_speed; 446 uint32_t cfg_link_speed;
430 uint32_t cfg_cr_delay; 447 uint32_t cfg_cr_delay;
431 uint32_t cfg_cr_count; 448 uint32_t cfg_cr_count;
432 uint32_t cfg_multi_ring_support; 449 uint32_t cfg_multi_ring_support;
433 uint32_t cfg_multi_ring_rctl; 450 uint32_t cfg_multi_ring_rctl;
434 uint32_t cfg_multi_ring_type; 451 uint32_t cfg_multi_ring_type;
435 uint32_t cfg_fdmi_on;
436 uint32_t cfg_discovery_threads;
437 uint32_t cfg_max_luns;
438 uint32_t cfg_poll; 452 uint32_t cfg_poll;
439 uint32_t cfg_poll_tmo; 453 uint32_t cfg_poll_tmo;
440 uint32_t cfg_use_msi; 454 uint32_t cfg_use_msi;
@@ -442,8 +456,8 @@ struct lpfc_hba {
442 uint32_t cfg_sg_dma_buf_size; 456 uint32_t cfg_sg_dma_buf_size;
443 uint64_t cfg_soft_wwnn; 457 uint64_t cfg_soft_wwnn;
444 uint64_t cfg_soft_wwpn; 458 uint64_t cfg_soft_wwpn;
459 uint32_t cfg_hba_queue_depth;
445 460
446 uint32_t dev_loss_tmo_changed;
447 461
448 lpfc_vpd_t vpd; /* vital product data */ 462 lpfc_vpd_t vpd; /* vital product data */
449 463
@@ -457,7 +471,6 @@ struct lpfc_hba {
457 wait_queue_head_t *work_wait; 471 wait_queue_head_t *work_wait;
458 struct task_struct *worker_thread; 472 struct task_struct *worker_thread;
459 473
460 struct list_head hbq_buffer_list;
461 uint32_t hbq_count; /* Count of configured HBQs */ 474 uint32_t hbq_count; /* Count of configured HBQs */
462 struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */ 475 struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */
463 476
@@ -526,12 +539,14 @@ struct lpfc_hba {
526 mempool_t *nlp_mem_pool; 539 mempool_t *nlp_mem_pool;
527 540
528 struct fc_host_statistics link_stats; 541 struct fc_host_statistics link_stats;
542 uint8_t using_msi;
529 543
530 struct list_head port_list; 544 struct list_head port_list;
531 struct lpfc_vport *pport; /* physical lpfc_vport pointer */ 545 struct lpfc_vport *pport; /* physical lpfc_vport pointer */
532 uint16_t max_vpi; /* Maximum virtual nports */ 546 uint16_t max_vpi; /* Maximum virtual nports */
533#define LPFC_MAX_VPI 100 /* Max number of VPorts supported */ 547#define LPFC_MAX_VPI 100 /* Max number of VPI supported */
534 unsigned long *vpi_bmask; /* vpi allocation table */ 548#define LPFC_MAX_VPORTS (LPFC_MAX_VPI+1)/* Max number of VPorts supported */
549 unsigned long *vpi_bmask; /* vpi allocation table */
535 550
536 /* Data structure used by fabric iocb scheduler */ 551 /* Data structure used by fabric iocb scheduler */
537 struct list_head fabric_iocb_list; 552 struct list_head fabric_iocb_list;
@@ -547,6 +562,11 @@ struct lpfc_hba {
547#ifdef CONFIG_LPFC_DEBUG_FS 562#ifdef CONFIG_LPFC_DEBUG_FS
548 struct dentry *hba_debugfs_root; 563 struct dentry *hba_debugfs_root;
549 atomic_t debugfs_vport_count; 564 atomic_t debugfs_vport_count;
565 struct dentry *debug_hbqinfo;
566 struct dentry *debug_dumpslim;
567 struct dentry *debug_slow_ring_trc;
568 struct lpfc_debugfs_trc *slow_ring_trc;
569 atomic_t slow_ring_trc_cnt;
550#endif 570#endif
551 571
552 /* Fields used for heart beat. */ 572 /* Fields used for heart beat. */
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 860a52c090f4..80a11218b9bb 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -68,12 +68,6 @@ lpfc_drvr_version_show(struct class_device *cdev, char *buf)
68} 68}
69 69
70static ssize_t 70static ssize_t
71management_version_show(struct class_device *cdev, char *buf)
72{
73 return snprintf(buf, PAGE_SIZE, DFC_API_VERSION "\n");
74}
75
76static ssize_t
77lpfc_info_show(struct class_device *cdev, char *buf) 71lpfc_info_show(struct class_device *cdev, char *buf)
78{ 72{
79 struct Scsi_Host *host = class_to_shost(cdev); 73 struct Scsi_Host *host = class_to_shost(cdev);
@@ -319,9 +313,8 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type)
319 if (cnt++ > 3000) { 313 if (cnt++ > 3000) {
320 lpfc_printf_log(phba, 314 lpfc_printf_log(phba,
321 KERN_WARNING, LOG_INIT, 315 KERN_WARNING, LOG_INIT,
322 "%d:0466 Outstanding IO when " 316 "0466 Outstanding IO when "
323 "bringing Adapter offline\n", 317 "bringing Adapter offline\n");
324 phba->brd_no);
325 break; 318 break;
326 } 319 }
327 } 320 }
@@ -437,7 +430,7 @@ lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
437 return -EIO; 430 return -EIO;
438} 431}
439 432
440int 433static int
441lpfc_get_hba_info(struct lpfc_hba *phba, 434lpfc_get_hba_info(struct lpfc_hba *phba,
442 uint32_t *mxri, uint32_t *axri, 435 uint32_t *mxri, uint32_t *axri,
443 uint32_t *mrpi, uint32_t *arpi, 436 uint32_t *mrpi, uint32_t *arpi,
@@ -694,9 +687,8 @@ lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
694 return 0;\ 687 return 0;\
695 }\ 688 }\
696 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ 689 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
697 "%d:0449 lpfc_"#attr" attribute cannot be set to %d, "\ 690 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
698 "allowed range is ["#minval", "#maxval"]\n", \ 691 "allowed range is ["#minval", "#maxval"]\n", val); \
699 phba->brd_no, val); \
700 phba->cfg_##attr = default;\ 692 phba->cfg_##attr = default;\
701 return -EINVAL;\ 693 return -EINVAL;\
702} 694}
@@ -710,9 +702,8 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \
710 return 0;\ 702 return 0;\
711 }\ 703 }\
712 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ 704 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
713 "%d:0450 lpfc_"#attr" attribute cannot be set to %d, "\ 705 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
714 "allowed range is ["#minval", "#maxval"]\n", \ 706 "allowed range is ["#minval", "#maxval"]\n", val); \
715 phba->brd_no, val); \
716 return -EINVAL;\ 707 return -EINVAL;\
717} 708}
718 709
@@ -734,6 +725,75 @@ lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
734 return -EINVAL;\ 725 return -EINVAL;\
735} 726}
736 727
728#define lpfc_vport_param_show(attr) \
729static ssize_t \
730lpfc_##attr##_show(struct class_device *cdev, char *buf) \
731{ \
732 struct Scsi_Host *shost = class_to_shost(cdev);\
733 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
734 int val = 0;\
735 val = vport->cfg_##attr;\
736 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\
737}
738
739#define lpfc_vport_param_hex_show(attr) \
740static ssize_t \
741lpfc_##attr##_show(struct class_device *cdev, char *buf) \
742{ \
743 struct Scsi_Host *shost = class_to_shost(cdev);\
744 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
745 int val = 0;\
746 val = vport->cfg_##attr;\
747 return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\
748}
749
750#define lpfc_vport_param_init(attr, default, minval, maxval) \
751static int \
752lpfc_##attr##_init(struct lpfc_vport *vport, int val) \
753{ \
754 if (val >= minval && val <= maxval) {\
755 vport->cfg_##attr = val;\
756 return 0;\
757 }\
758 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
759 "0449 lpfc_"#attr" attribute cannot be set to %d, "\
760 "allowed range is ["#minval", "#maxval"]\n", val); \
761 vport->cfg_##attr = default;\
762 return -EINVAL;\
763}
764
765#define lpfc_vport_param_set(attr, default, minval, maxval) \
766static int \
767lpfc_##attr##_set(struct lpfc_vport *vport, int val) \
768{ \
769 if (val >= minval && val <= maxval) {\
770 vport->cfg_##attr = val;\
771 return 0;\
772 }\
773 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
774 "0450 lpfc_"#attr" attribute cannot be set to %d, "\
775 "allowed range is ["#minval", "#maxval"]\n", val); \
776 return -EINVAL;\
777}
778
779#define lpfc_vport_param_store(attr) \
780static ssize_t \
781lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
782{ \
783 struct Scsi_Host *shost = class_to_shost(cdev);\
784 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;\
785 int val=0;\
786 if (!isdigit(buf[0]))\
787 return -EINVAL;\
788 if (sscanf(buf, "%i", &val) != 1)\
789 return -EINVAL;\
790 if (lpfc_##attr##_set(vport, val) == 0) \
791 return strlen(buf);\
792 else \
793 return -EINVAL;\
794}
795
796
737#define LPFC_ATTR(name, defval, minval, maxval, desc) \ 797#define LPFC_ATTR(name, defval, minval, maxval, desc) \
738static int lpfc_##name = defval;\ 798static int lpfc_##name = defval;\
739module_param(lpfc_##name, int, 0);\ 799module_param(lpfc_##name, int, 0);\
@@ -778,6 +838,50 @@ lpfc_param_store(name)\
778static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\ 838static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
779 lpfc_##name##_show, lpfc_##name##_store) 839 lpfc_##name##_show, lpfc_##name##_store)
780 840
841#define LPFC_VPORT_ATTR(name, defval, minval, maxval, desc) \
842static int lpfc_##name = defval;\
843module_param(lpfc_##name, int, 0);\
844MODULE_PARM_DESC(lpfc_##name, desc);\
845lpfc_vport_param_init(name, defval, minval, maxval)
846
847#define LPFC_VPORT_ATTR_R(name, defval, minval, maxval, desc) \
848static int lpfc_##name = defval;\
849module_param(lpfc_##name, int, 0);\
850MODULE_PARM_DESC(lpfc_##name, desc);\
851lpfc_vport_param_show(name)\
852lpfc_vport_param_init(name, defval, minval, maxval)\
853static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
854
855#define LPFC_VPORT_ATTR_RW(name, defval, minval, maxval, desc) \
856static int lpfc_##name = defval;\
857module_param(lpfc_##name, int, 0);\
858MODULE_PARM_DESC(lpfc_##name, desc);\
859lpfc_vport_param_show(name)\
860lpfc_vport_param_init(name, defval, minval, maxval)\
861lpfc_vport_param_set(name, defval, minval, maxval)\
862lpfc_vport_param_store(name)\
863static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
864 lpfc_##name##_show, lpfc_##name##_store)
865
866#define LPFC_VPORT_ATTR_HEX_R(name, defval, minval, maxval, desc) \
867static int lpfc_##name = defval;\
868module_param(lpfc_##name, int, 0);\
869MODULE_PARM_DESC(lpfc_##name, desc);\
870lpfc_vport_param_hex_show(name)\
871lpfc_vport_param_init(name, defval, minval, maxval)\
872static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
873
874#define LPFC_VPORT_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
875static int lpfc_##name = defval;\
876module_param(lpfc_##name, int, 0);\
877MODULE_PARM_DESC(lpfc_##name, desc);\
878lpfc_vport_param_hex_show(name)\
879lpfc_vport_param_init(name, defval, minval, maxval)\
880lpfc_vport_param_set(name, defval, minval, maxval)\
881lpfc_vport_param_store(name)\
882static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
883 lpfc_##name##_show, lpfc_##name##_store)
884
781static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL); 885static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
782static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL); 886static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
783static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL); 887static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
@@ -794,8 +898,6 @@ static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO,
794static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 898static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
795static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, 899static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show,
796 NULL); 900 NULL);
797static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,
798 NULL);
799static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 901static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
800 lpfc_board_mode_show, lpfc_board_mode_store); 902 lpfc_board_mode_show, lpfc_board_mode_store);
801static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 903static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
@@ -908,17 +1010,15 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
908 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 1010 stat1 = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
909 if (stat1) 1011 if (stat1)
910 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1012 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
911 "%d:0463 lpfc_soft_wwpn attribute set failed to reinit " 1013 "0463 lpfc_soft_wwpn attribute set failed to "
912 "adapter - %d\n", phba->brd_no, stat1); 1014 "reinit adapter - %d\n", stat1);
913
914 init_completion(&online_compl); 1015 init_completion(&online_compl);
915 lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE); 1016 lpfc_workq_post_event(phba, &stat2, &online_compl, LPFC_EVT_ONLINE);
916 wait_for_completion(&online_compl); 1017 wait_for_completion(&online_compl);
917 if (stat2) 1018 if (stat2)
918 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1019 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
919 "%d:0464 lpfc_soft_wwpn attribute set failed to reinit " 1020 "0464 lpfc_soft_wwpn attribute set failed to "
920 "adapter - %d\n", phba->brd_no, stat2); 1021 "reinit adapter - %d\n", stat2);
921
922 return (stat1 || stat2) ? -EIO : count; 1022 return (stat1 || stat2) ? -EIO : count;
923} 1023}
924static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 1024static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
@@ -927,8 +1027,8 @@ static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
927static ssize_t 1027static ssize_t
928lpfc_soft_wwnn_show(struct class_device *cdev, char *buf) 1028lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
929{ 1029{
930 struct Scsi_Host *host = class_to_shost(cdev); 1030 struct Scsi_Host *shost = class_to_shost(cdev);
931 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 1031 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
932 return snprintf(buf, PAGE_SIZE, "0x%llx\n", 1032 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
933 (unsigned long long)phba->cfg_soft_wwnn); 1033 (unsigned long long)phba->cfg_soft_wwnn);
934} 1034}
@@ -937,8 +1037,8 @@ lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
937static ssize_t 1037static ssize_t
938lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count) 1038lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count)
939{ 1039{
940 struct Scsi_Host *host = class_to_shost(cdev); 1040 struct Scsi_Host *shost = class_to_shost(cdev);
941 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata; 1041 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
942 unsigned int i, j, cnt=count; 1042 unsigned int i, j, cnt=count;
943 u8 wwnn[8]; 1043 u8 wwnn[8];
944 1044
@@ -1002,7 +1102,7 @@ MODULE_PARM_DESC(lpfc_sli_mode, "SLI mode selector:"
1002 " 2 - select SLI-2 even on SLI-3 capable HBAs," 1102 " 2 - select SLI-2 even on SLI-3 capable HBAs,"
1003 " 3 - select SLI-3"); 1103 " 3 - select SLI-3");
1004 1104
1005LPFC_ATTR_R(npiv_enable, 0, 0, 1, "Enable NPIV functionality"); 1105LPFC_ATTR_R(enable_npiv, 0, 0, 1, "Enable NPIV functionality");
1006 1106
1007/* 1107/*
1008# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear 1108# lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
@@ -1019,90 +1119,75 @@ lpfc_nodev_tmo_show(struct class_device *cdev, char *buf)
1019{ 1119{
1020 struct Scsi_Host *shost = class_to_shost(cdev); 1120 struct Scsi_Host *shost = class_to_shost(cdev);
1021 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1121 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1022 struct lpfc_hba *phba = vport->phba;
1023 int val = 0; 1122 int val = 0;
1024 val = phba->cfg_devloss_tmo; 1123 val = vport->cfg_devloss_tmo;
1025 return snprintf(buf, PAGE_SIZE, "%d\n", 1124 return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo);
1026 phba->cfg_devloss_tmo);
1027} 1125}
1028 1126
1029static int 1127static int
1030lpfc_nodev_tmo_init(struct lpfc_hba *phba, int val) 1128lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val)
1031{ 1129{
1032 static int warned; 1130 if (vport->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) {
1033 if (phba->cfg_devloss_tmo != LPFC_DEF_DEVLOSS_TMO) { 1131 vport->cfg_nodev_tmo = vport->cfg_devloss_tmo;
1034 phba->cfg_nodev_tmo = phba->cfg_devloss_tmo; 1132 if (val != LPFC_DEF_DEVLOSS_TMO)
1035 if (!warned && val != LPFC_DEF_DEVLOSS_TMO) { 1133 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1036 warned = 1; 1134 "0402 Ignoring nodev_tmo module "
1037 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1135 "parameter because devloss_tmo is "
1038 "%d:0402 Ignoring nodev_tmo module " 1136 "set.\n");
1039 "parameter because devloss_tmo is"
1040 " set.\n",
1041 phba->brd_no);
1042 }
1043 return 0; 1137 return 0;
1044 } 1138 }
1045 1139
1046 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1140 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
1047 phba->cfg_nodev_tmo = val; 1141 vport->cfg_nodev_tmo = val;
1048 phba->cfg_devloss_tmo = val; 1142 vport->cfg_devloss_tmo = val;
1049 return 0; 1143 return 0;
1050 } 1144 }
1051 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1145 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1052 "%d:0400 lpfc_nodev_tmo attribute cannot be set to %d, " 1146 "0400 lpfc_nodev_tmo attribute cannot be set to"
1053 "allowed range is [%d, %d]\n", 1147 " %d, allowed range is [%d, %d]\n",
1054 phba->brd_no, val, 1148 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
1055 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO); 1149 vport->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
1056 phba->cfg_nodev_tmo = LPFC_DEF_DEVLOSS_TMO;
1057 return -EINVAL; 1150 return -EINVAL;
1058} 1151}
1059 1152
1060static void 1153static void
1061lpfc_update_rport_devloss_tmo(struct lpfc_hba *phba) 1154lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
1062{ 1155{
1063 struct lpfc_vport *vport;
1064 struct Scsi_Host *shost; 1156 struct Scsi_Host *shost;
1065 struct lpfc_nodelist *ndlp; 1157 struct lpfc_nodelist *ndlp;
1066 1158
1067 list_for_each_entry(vport, &phba->port_list, listentry) { 1159 shost = lpfc_shost_from_vport(vport);
1068 shost = lpfc_shost_from_vport(vport); 1160 spin_lock_irq(shost->host_lock);
1069 spin_lock_irq(shost->host_lock); 1161 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp)
1070 list_for_each_entry(ndlp, &vport->fc_nodes, nlp_listp) 1162 if (ndlp->rport)
1071 if (ndlp->rport) 1163 ndlp->rport->dev_loss_tmo = vport->cfg_devloss_tmo;
1072 ndlp->rport->dev_loss_tmo = 1164 spin_unlock_irq(shost->host_lock);
1073 phba->cfg_devloss_tmo;
1074 spin_unlock_irq(shost->host_lock);
1075 }
1076} 1165}
1077 1166
1078static int 1167static int
1079lpfc_nodev_tmo_set(struct lpfc_hba *phba, int val) 1168lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
1080{ 1169{
1081 if (phba->dev_loss_tmo_changed || 1170 if (vport->dev_loss_tmo_changed ||
1082 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) { 1171 (lpfc_devloss_tmo != LPFC_DEF_DEVLOSS_TMO)) {
1083 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1172 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1084 "%d:0401 Ignoring change to nodev_tmo " 1173 "0401 Ignoring change to nodev_tmo "
1085 "because devloss_tmo is set.\n", 1174 "because devloss_tmo is set.\n");
1086 phba->brd_no);
1087 return 0; 1175 return 0;
1088 } 1176 }
1089
1090 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1177 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
1091 phba->cfg_nodev_tmo = val; 1178 vport->cfg_nodev_tmo = val;
1092 phba->cfg_devloss_tmo = val; 1179 vport->cfg_devloss_tmo = val;
1093 lpfc_update_rport_devloss_tmo(phba); 1180 lpfc_update_rport_devloss_tmo(vport);
1094 return 0; 1181 return 0;
1095 } 1182 }
1096 1183 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1097 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1184 "0403 lpfc_nodev_tmo attribute cannot be set to"
1098 "%d:0403 lpfc_nodev_tmo attribute cannot be set to %d, " 1185 "%d, allowed range is [%d, %d]\n",
1099 "allowed range is [%d, %d]\n", 1186 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
1100 phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO,
1101 LPFC_MAX_DEVLOSS_TMO);
1102 return -EINVAL; 1187 return -EINVAL;
1103} 1188}
1104 1189
1105lpfc_param_store(nodev_tmo) 1190lpfc_vport_param_store(nodev_tmo)
1106 1191
1107static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, 1192static CLASS_DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR,
1108 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store); 1193 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
@@ -1116,29 +1201,28 @@ module_param(lpfc_devloss_tmo, int, 0);
1116MODULE_PARM_DESC(lpfc_devloss_tmo, 1201MODULE_PARM_DESC(lpfc_devloss_tmo,
1117 "Seconds driver will hold I/O waiting " 1202 "Seconds driver will hold I/O waiting "
1118 "for a device to come back"); 1203 "for a device to come back");
1119lpfc_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, 1204lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO,
1120 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) 1205 LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO)
1121lpfc_param_show(devloss_tmo) 1206lpfc_vport_param_show(devloss_tmo)
1122static int 1207static int
1123lpfc_devloss_tmo_set(struct lpfc_hba *phba, int val) 1208lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
1124{ 1209{
1125 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) { 1210 if (val >= LPFC_MIN_DEVLOSS_TMO && val <= LPFC_MAX_DEVLOSS_TMO) {
1126 phba->cfg_nodev_tmo = val; 1211 vport->cfg_nodev_tmo = val;
1127 phba->cfg_devloss_tmo = val; 1212 vport->cfg_devloss_tmo = val;
1128 phba->dev_loss_tmo_changed = 1; 1213 vport->dev_loss_tmo_changed = 1;
1129 lpfc_update_rport_devloss_tmo(phba); 1214 lpfc_update_rport_devloss_tmo(vport);
1130 return 0; 1215 return 0;
1131 } 1216 }
1132 1217
1133 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1218 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1134 "%d:0404 lpfc_devloss_tmo attribute cannot be set to" 1219 "0404 lpfc_devloss_tmo attribute cannot be set to"
1135 " %d, allowed range is [%d, %d]\n", 1220 " %d, allowed range is [%d, %d]\n",
1136 phba->brd_no, val, LPFC_MIN_DEVLOSS_TMO, 1221 val, LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO);
1137 LPFC_MAX_DEVLOSS_TMO);
1138 return -EINVAL; 1222 return -EINVAL;
1139} 1223}
1140 1224
1141lpfc_param_store(devloss_tmo) 1225lpfc_vport_param_store(devloss_tmo)
1142static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, 1226static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1143 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store); 1227 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
1144 1228
@@ -1160,14 +1244,15 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
1160# LOG_LIBDFC 0x2000 LIBDFC events 1244# LOG_LIBDFC 0x2000 LIBDFC events
1161# LOG_ALL_MSG 0xffff LOG all messages 1245# LOG_ALL_MSG 0xffff LOG all messages
1162*/ 1246*/
1163LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask"); 1247LPFC_VPORT_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff,
1248 "Verbose logging bit-mask");
1164 1249
1165/* 1250/*
1166# lun_queue_depth: This parameter is used to limit the number of outstanding 1251# lun_queue_depth: This parameter is used to limit the number of outstanding
1167# commands per FCP LUN. Value range is [1,128]. Default value is 30. 1252# commands per FCP LUN. Value range is [1,128]. Default value is 30.
1168*/ 1253*/
1169LPFC_ATTR_R(lun_queue_depth, 30, 1, 128, 1254LPFC_VPORT_ATTR_R(lun_queue_depth, 30, 1, 128,
1170 "Max number of FCP commands we can queue to a specific LUN"); 1255 "Max number of FCP commands we can queue to a specific LUN");
1171 1256
1172/* 1257/*
1173# hba_queue_depth: This parameter is used to limit the number of outstanding 1258# hba_queue_depth: This parameter is used to limit the number of outstanding
@@ -1188,12 +1273,12 @@ LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
1188# are allowed to login to each other. 1273# are allowed to login to each other.
1189# Default value of this parameter is 0. 1274# Default value of this parameter is 0.
1190*/ 1275*/
1191LPFC_ATTR_R(peer_port_login, 0, 0, 1, 1276LPFC_VPORT_ATTR_R(peer_port_login, 0, 0, 1,
1192 "Allow peer ports on the same physical port to login to each " 1277 "Allow peer ports on the same physical port to login to each "
1193 "other."); 1278 "other.");
1194 1279
1195/* 1280/*
1196# vport_restrict_login: This parameter allows/prevents logins 1281# restrict_login: This parameter allows/prevents logins
1197# between Virtual Ports and remote initiators. 1282# between Virtual Ports and remote initiators.
1198# When this parameter is not set (0) Virtual Ports will accept PLOGIs from 1283# When this parameter is not set (0) Virtual Ports will accept PLOGIs from
1199# other initiators and will attempt to PLOGI all remote ports. 1284# other initiators and will attempt to PLOGI all remote ports.
@@ -1203,8 +1288,55 @@ LPFC_ATTR_R(peer_port_login, 0, 0, 1,
1203# This parameter does not restrict logins to Fabric resident remote ports. 1288# This parameter does not restrict logins to Fabric resident remote ports.
1204# Default value of this parameter is 1. 1289# Default value of this parameter is 1.
1205*/ 1290*/
1206LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1, 1291static int lpfc_restrict_login = 1;
1207 "Restrict virtual ports login to remote initiators."); 1292module_param(lpfc_restrict_login, int, 0);
1293MODULE_PARM_DESC(lpfc_restrict_login,
1294 "Restrict virtual ports login to remote initiators.");
1295lpfc_vport_param_show(restrict_login);
1296
1297static int
1298lpfc_restrict_login_init(struct lpfc_vport *vport, int val)
1299{
1300 if (val < 0 || val > 1) {
1301 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1302 "0449 lpfc_restrict_login attribute cannot "
1303 "be set to %d, allowed range is [0, 1]\n",
1304 val);
1305 vport->cfg_restrict_login = 1;
1306 return -EINVAL;
1307 }
1308 if (vport->port_type == LPFC_PHYSICAL_PORT) {
1309 vport->cfg_restrict_login = 0;
1310 return 0;
1311 }
1312 vport->cfg_restrict_login = val;
1313 return 0;
1314}
1315
1316static int
1317lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
1318{
1319 if (val < 0 || val > 1) {
1320 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1321 "0450 lpfc_restrict_login attribute cannot "
1322 "be set to %d, allowed range is [0, 1]\n",
1323 val);
1324 vport->cfg_restrict_login = 1;
1325 return -EINVAL;
1326 }
1327 if (vport->port_type == LPFC_PHYSICAL_PORT && val != 0) {
1328 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
1329 "0468 lpfc_restrict_login must be 0 for "
1330 "Physical ports.\n");
1331 vport->cfg_restrict_login = 0;
1332 return 0;
1333 }
1334 vport->cfg_restrict_login = val;
1335 return 0;
1336}
1337lpfc_vport_param_store(restrict_login);
1338static CLASS_DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR,
1339 lpfc_restrict_login_show, lpfc_restrict_login_store);
1208 1340
1209/* 1341/*
1210# Some disk devices have a "select ID" or "select Target" capability. 1342# Some disk devices have a "select ID" or "select Target" capability.
@@ -1223,8 +1355,8 @@ LPFC_ATTR_RW(vport_restrict_login, 1, 0, 1,
1223# and will not work across a fabric. Also this parameter will take 1355# and will not work across a fabric. Also this parameter will take
1224# effect only in the case when ALPA map is not available.) 1356# effect only in the case when ALPA map is not available.)
1225*/ 1357*/
1226LPFC_ATTR_R(scan_down, 1, 0, 1, 1358LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1,
1227 "Start scanning for devices from highest ALPA to lowest"); 1359 "Start scanning for devices from highest ALPA to lowest");
1228 1360
1229/* 1361/*
1230# lpfc_topology: link topology for init link 1362# lpfc_topology: link topology for init link
@@ -1255,15 +1387,15 @@ LPFC_ATTR_R(link_speed, 0, 0, 8, "Select link speed");
1255# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 1387# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
1256# Value range is [2,3]. Default value is 3. 1388# Value range is [2,3]. Default value is 3.
1257*/ 1389*/
1258LPFC_ATTR_R(fcp_class, 3, 2, 3, 1390LPFC_VPORT_ATTR_R(fcp_class, 3, 2, 3,
1259 "Select Fibre Channel class of service for FCP sequences"); 1391 "Select Fibre Channel class of service for FCP sequences");
1260 1392
1261/* 1393/*
1262# lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range 1394# lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
1263# is [0,1]. Default value is 0. 1395# is [0,1]. Default value is 0.
1264*/ 1396*/
1265LPFC_ATTR_RW(use_adisc, 0, 0, 1, 1397LPFC_VPORT_ATTR_RW(use_adisc, 0, 0, 1,
1266 "Use ADISC on rediscovery to authenticate FCP devices"); 1398 "Use ADISC on rediscovery to authenticate FCP devices");
1267 1399
1268/* 1400/*
1269# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value 1401# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
@@ -1315,13 +1447,13 @@ LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1,
1315# 2 = support FDMI with attribute of hostname 1447# 2 = support FDMI with attribute of hostname
1316# Value range [0,2]. Default value is 0. 1448# Value range [0,2]. Default value is 0.
1317*/ 1449*/
1318LPFC_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support"); 1450LPFC_VPORT_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
1319 1451
1320/* 1452/*
1321# Specifies the maximum number of ELS cmds we can have outstanding (for 1453# Specifies the maximum number of ELS cmds we can have outstanding (for
1322# discovery). Value range is [1,64]. Default value = 32. 1454# discovery). Value range is [1,64]. Default value = 32.
1323*/ 1455*/
1324LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands " 1456LPFC_VPORT_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
1325 "during discovery"); 1457 "during discovery");
1326 1458
1327/* 1459/*
@@ -1329,8 +1461,7 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
1329# Value range is [0,65535]. Default value is 255. 1461# Value range is [0,65535]. Default value is 255.
1330# NOTE: The SCSI layer might probe all allowed LUN on some old targets. 1462# NOTE: The SCSI layer might probe all allowed LUN on some old targets.
1331*/ 1463*/
1332LPFC_ATTR_R(max_luns, 255, 0, 65535, 1464LPFC_VPORT_ATTR_R(max_luns, 255, 0, 65535, "Maximum allowed LUN");
1333 "Maximum allowed LUN");
1334 1465
1335/* 1466/*
1336# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. 1467# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
@@ -1367,7 +1498,6 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
1367 &class_device_attr_lpfc_lun_queue_depth, 1498 &class_device_attr_lpfc_lun_queue_depth,
1368 &class_device_attr_lpfc_hba_queue_depth, 1499 &class_device_attr_lpfc_hba_queue_depth,
1369 &class_device_attr_lpfc_peer_port_login, 1500 &class_device_attr_lpfc_peer_port_login,
1370 &class_device_attr_lpfc_vport_restrict_login,
1371 &class_device_attr_lpfc_nodev_tmo, 1501 &class_device_attr_lpfc_nodev_tmo,
1372 &class_device_attr_lpfc_devloss_tmo, 1502 &class_device_attr_lpfc_devloss_tmo,
1373 &class_device_attr_lpfc_fcp_class, 1503 &class_device_attr_lpfc_fcp_class,
@@ -1383,9 +1513,8 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
1383 &class_device_attr_lpfc_multi_ring_type, 1513 &class_device_attr_lpfc_multi_ring_type,
1384 &class_device_attr_lpfc_fdmi_on, 1514 &class_device_attr_lpfc_fdmi_on,
1385 &class_device_attr_lpfc_max_luns, 1515 &class_device_attr_lpfc_max_luns,
1386 &class_device_attr_lpfc_npiv_enable, 1516 &class_device_attr_lpfc_enable_npiv,
1387 &class_device_attr_nport_evt_cnt, 1517 &class_device_attr_nport_evt_cnt,
1388 &class_device_attr_management_version,
1389 &class_device_attr_board_mode, 1518 &class_device_attr_board_mode,
1390 &class_device_attr_max_vpi, 1519 &class_device_attr_max_vpi,
1391 &class_device_attr_used_vpi, 1520 &class_device_attr_used_vpi,
@@ -1404,6 +1533,28 @@ struct class_device_attribute *lpfc_hba_attrs[] = {
1404 NULL, 1533 NULL,
1405}; 1534};
1406 1535
1536struct class_device_attribute *lpfc_vport_attrs[] = {
1537 &class_device_attr_info,
1538 &class_device_attr_state,
1539 &class_device_attr_num_discovered_ports,
1540 &class_device_attr_lpfc_drvr_version,
1541
1542 &class_device_attr_lpfc_log_verbose,
1543 &class_device_attr_lpfc_lun_queue_depth,
1544 &class_device_attr_lpfc_nodev_tmo,
1545 &class_device_attr_lpfc_devloss_tmo,
1546 &class_device_attr_lpfc_hba_queue_depth,
1547 &class_device_attr_lpfc_peer_port_login,
1548 &class_device_attr_lpfc_restrict_login,
1549 &class_device_attr_lpfc_fcp_class,
1550 &class_device_attr_lpfc_use_adisc,
1551 &class_device_attr_lpfc_fdmi_on,
1552 &class_device_attr_lpfc_max_luns,
1553 &class_device_attr_nport_evt_cnt,
1554 &class_device_attr_npiv_info,
1555 NULL,
1556};
1557
1407static ssize_t 1558static ssize_t
1408sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, 1559sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr,
1409 char *buf, loff_t off, size_t count) 1560 char *buf, loff_t off, size_t count)
@@ -2243,7 +2394,6 @@ struct fc_function_template lpfc_vport_transport_functions = {
2243 .get_starget_port_name = lpfc_get_starget_port_name, 2394 .get_starget_port_name = lpfc_get_starget_port_name,
2244 .show_starget_port_name = 1, 2395 .show_starget_port_name = 1,
2245 2396
2246 .issue_fc_host_lip = lpfc_issue_lip,
2247 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk, 2397 .dev_loss_tmo_callbk = lpfc_dev_loss_tmo_callbk,
2248 .terminate_rport_io = lpfc_terminate_rport_io, 2398 .terminate_rport_io = lpfc_terminate_rport_io,
2249 2399
@@ -2253,39 +2403,25 @@ struct fc_function_template lpfc_vport_transport_functions = {
2253void 2403void
2254lpfc_get_cfgparam(struct lpfc_hba *phba) 2404lpfc_get_cfgparam(struct lpfc_hba *phba)
2255{ 2405{
2256 lpfc_log_verbose_init(phba, lpfc_log_verbose);
2257 lpfc_cr_delay_init(phba, lpfc_cr_delay); 2406 lpfc_cr_delay_init(phba, lpfc_cr_delay);
2258 lpfc_cr_count_init(phba, lpfc_cr_count); 2407 lpfc_cr_count_init(phba, lpfc_cr_count);
2259 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); 2408 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
2260 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl); 2409 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
2261 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type); 2410 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
2262 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth);
2263 lpfc_fcp_class_init(phba, lpfc_fcp_class);
2264 lpfc_use_adisc_init(phba, lpfc_use_adisc);
2265 lpfc_ack0_init(phba, lpfc_ack0); 2411 lpfc_ack0_init(phba, lpfc_ack0);
2266 lpfc_topology_init(phba, lpfc_topology); 2412 lpfc_topology_init(phba, lpfc_topology);
2267 lpfc_scan_down_init(phba, lpfc_scan_down);
2268 lpfc_link_speed_init(phba, lpfc_link_speed); 2413 lpfc_link_speed_init(phba, lpfc_link_speed);
2269 lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
2270 lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
2271 lpfc_max_luns_init(phba, lpfc_max_luns);
2272 lpfc_poll_tmo_init(phba, lpfc_poll_tmo); 2414 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
2273 lpfc_peer_port_login_init(phba, lpfc_peer_port_login); 2415 lpfc_enable_npiv_init(phba, lpfc_enable_npiv);
2274 lpfc_npiv_enable_init(phba, lpfc_npiv_enable);
2275 lpfc_vport_restrict_login_init(phba, lpfc_vport_restrict_login);
2276 lpfc_use_msi_init(phba, lpfc_use_msi); 2416 lpfc_use_msi_init(phba, lpfc_use_msi);
2277 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo);
2278 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo);
2279 phba->cfg_poll = lpfc_poll; 2417 phba->cfg_poll = lpfc_poll;
2280 phba->cfg_soft_wwnn = 0L; 2418 phba->cfg_soft_wwnn = 0L;
2281 phba->cfg_soft_wwpn = 0L; 2419 phba->cfg_soft_wwpn = 0L;
2282
2283 /* 2420 /*
2284 * The total number of segments is the configuration value plus 2 2421 * The total number of segments is the configuration value plus 2
2285 * since the IOCB need a command and response bde. 2422 * since the IOCB need a command and response bde.
2286 */ 2423 */
2287 phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2; 2424 phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
2288
2289 /* 2425 /*
2290 * Since the sg_tablesize is module parameter, the sg_dma_buf_size 2426 * Since the sg_tablesize is module parameter, the sg_dma_buf_size
2291 * used to create the sg_dma_buf_pool must be dynamically calculated 2427 * used to create the sg_dma_buf_pool must be dynamically calculated
@@ -2293,9 +2429,24 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
2293 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + 2429 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
2294 sizeof(struct fcp_rsp) + 2430 sizeof(struct fcp_rsp) +
2295 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64)); 2431 (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
2296
2297
2298 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth); 2432 lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
2433 return;
2434}
2299 2435
2436void
2437lpfc_get_vport_cfgparam(struct lpfc_vport *vport)
2438{
2439 lpfc_log_verbose_init(vport, lpfc_log_verbose);
2440 lpfc_lun_queue_depth_init(vport, lpfc_lun_queue_depth);
2441 lpfc_devloss_tmo_init(vport, lpfc_devloss_tmo);
2442 lpfc_nodev_tmo_init(vport, lpfc_nodev_tmo);
2443 lpfc_peer_port_login_init(vport, lpfc_peer_port_login);
2444 lpfc_restrict_login_init(vport, lpfc_restrict_login);
2445 lpfc_fcp_class_init(vport, lpfc_fcp_class);
2446 lpfc_use_adisc_init(vport, lpfc_use_adisc);
2447 lpfc_fdmi_on_init(vport, lpfc_fdmi_on);
2448 lpfc_discovery_threads_init(vport, lpfc_discovery_threads);
2449 lpfc_max_luns_init(vport, lpfc_max_luns);
2450 lpfc_scan_down_init(vport, lpfc_scan_down);
2300 return; 2451 return;
2301} 2452}
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index e19d1a746586..a599e1510710 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -40,6 +40,7 @@ void lpfc_reg_vpi(struct lpfc_hba *, uint16_t, uint32_t, LPFC_MBOXQ_t *);
40void lpfc_unreg_vpi(struct lpfc_hba *, uint16_t, LPFC_MBOXQ_t *); 40void lpfc_unreg_vpi(struct lpfc_hba *, uint16_t, LPFC_MBOXQ_t *);
41void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t); 41void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t);
42 42
43struct lpfc_vport *lpfc_find_vport_by_did(struct lpfc_hba *, uint32_t);
43void lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove); 44void lpfc_cleanup_rpis(struct lpfc_vport *vport, int remove);
44int lpfc_linkdown(struct lpfc_hba *); 45int lpfc_linkdown(struct lpfc_hba *);
45void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *); 46void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
@@ -101,7 +102,7 @@ int lpfc_issue_els_scr(struct lpfc_vport *, uint32_t, uint8_t);
101int lpfc_els_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *); 102int lpfc_els_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
102int lpfc_ct_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *); 103int lpfc_ct_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
103int lpfc_els_rsp_acc(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *, 104int lpfc_els_rsp_acc(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *,
104 struct lpfc_nodelist *, LPFC_MBOXQ_t *, uint8_t); 105 struct lpfc_nodelist *, LPFC_MBOXQ_t *);
105int lpfc_els_rsp_reject(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *, 106int lpfc_els_rsp_reject(struct lpfc_vport *, uint32_t, struct lpfc_iocbq *,
106 struct lpfc_nodelist *, LPFC_MBOXQ_t *); 107 struct lpfc_nodelist *, LPFC_MBOXQ_t *);
107int lpfc_els_rsp_adisc_acc(struct lpfc_vport *, struct lpfc_iocbq *, 108int lpfc_els_rsp_adisc_acc(struct lpfc_vport *, struct lpfc_iocbq *,
@@ -117,6 +118,7 @@ void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
117int lpfc_els_handle_rscn(struct lpfc_vport *); 118int lpfc_els_handle_rscn(struct lpfc_vport *);
118void lpfc_els_flush_rscn(struct lpfc_vport *); 119void lpfc_els_flush_rscn(struct lpfc_vport *);
119int lpfc_rscn_payload_check(struct lpfc_vport *, uint32_t); 120int lpfc_rscn_payload_check(struct lpfc_vport *, uint32_t);
121void lpfc_els_flush_all_cmd(struct lpfc_hba *);
120void lpfc_els_flush_cmd(struct lpfc_vport *); 122void lpfc_els_flush_cmd(struct lpfc_vport *);
121int lpfc_els_disc_adisc(struct lpfc_vport *); 123int lpfc_els_disc_adisc(struct lpfc_vport *);
122int lpfc_els_disc_plogi(struct lpfc_vport *); 124int lpfc_els_disc_plogi(struct lpfc_vport *);
@@ -161,9 +163,11 @@ LPFC_MBOXQ_t *lpfc_mbox_get(struct lpfc_hba *);
161void lpfc_mbox_cmpl_put(struct lpfc_hba *, LPFC_MBOXQ_t *); 163void lpfc_mbox_cmpl_put(struct lpfc_hba *, LPFC_MBOXQ_t *);
162int lpfc_mbox_tmo_val(struct lpfc_hba *, int); 164int lpfc_mbox_tmo_val(struct lpfc_hba *, int);
163 165
164void lpfc_config_hbq(struct lpfc_hba *, struct lpfc_hbq_init *, uint32_t , 166void lpfc_config_hbq(struct lpfc_hba *, uint32_t, struct lpfc_hbq_init *,
165 LPFC_MBOXQ_t *); 167 uint32_t , LPFC_MBOXQ_t *);
166struct lpfc_hbq_entry * lpfc_sli_next_hbq_slot(struct lpfc_hba *, uint32_t); 168struct lpfc_hbq_entry * lpfc_sli_next_hbq_slot(struct lpfc_hba *, uint32_t);
169struct hbq_dmabuf *lpfc_els_hbq_alloc(struct lpfc_hba *);
170void lpfc_els_hbq_free(struct lpfc_hba *, struct hbq_dmabuf *);
167 171
168int lpfc_mem_alloc(struct lpfc_hba *); 172int lpfc_mem_alloc(struct lpfc_hba *);
169void lpfc_mem_free(struct lpfc_hba *); 173void lpfc_mem_free(struct lpfc_hba *);
@@ -200,6 +204,7 @@ int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *,
200struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *, 204struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
201 struct lpfc_sli_ring *, 205 struct lpfc_sli_ring *,
202 dma_addr_t); 206 dma_addr_t);
207int lpfc_sli_hbq_count(void);
203int lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *, uint32_t); 208int lpfc_sli_hbqbuf_init_hbqs(struct lpfc_hba *, uint32_t);
204int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *, uint32_t); 209int lpfc_sli_hbqbuf_add_hbqs(struct lpfc_hba *, uint32_t);
205void lpfc_sli_hbqbuf_free_all(struct lpfc_hba *); 210void lpfc_sli_hbqbuf_free_all(struct lpfc_hba *);
@@ -207,10 +212,9 @@ struct hbq_dmabuf *lpfc_sli_hbqbuf_find(struct lpfc_hba *, uint32_t);
207int lpfc_sli_hbq_size(void); 212int lpfc_sli_hbq_size(void);
208int lpfc_sli_issue_abort_iotag(struct lpfc_hba *, struct lpfc_sli_ring *, 213int lpfc_sli_issue_abort_iotag(struct lpfc_hba *, struct lpfc_sli_ring *,
209 struct lpfc_iocbq *); 214 struct lpfc_iocbq *);
210int lpfc_sli_sum_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t, 215int lpfc_sli_sum_iocb(struct lpfc_vport *, uint16_t, uint64_t, lpfc_ctx_cmd);
211 uint64_t, lpfc_ctx_cmd); 216int lpfc_sli_abort_iocb(struct lpfc_vport *, struct lpfc_sli_ring *, uint16_t,
212int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t, 217 uint64_t, lpfc_ctx_cmd);
213 uint64_t, uint32_t, lpfc_ctx_cmd);
214 218
215void lpfc_mbox_timeout(unsigned long); 219void lpfc_mbox_timeout(unsigned long);
216void lpfc_mbox_timeout_handler(struct lpfc_hba *); 220void lpfc_mbox_timeout_handler(struct lpfc_hba *);
@@ -234,8 +238,6 @@ void lpfc_sli_abort_fcp_cmpl(struct lpfc_hba * phba,
234 struct lpfc_iocbq * cmdiocb, 238 struct lpfc_iocbq * cmdiocb,
235 struct lpfc_iocbq * rspiocb); 239 struct lpfc_iocbq * rspiocb);
236 240
237void *lpfc_hbq_alloc(struct lpfc_hba *, int, dma_addr_t *);
238void lpfc_hbq_free(struct lpfc_hba *, void *, dma_addr_t);
239void lpfc_sli_free_hbq(struct lpfc_hba *, struct hbq_dmabuf *); 241void lpfc_sli_free_hbq(struct lpfc_hba *, struct hbq_dmabuf *);
240 242
241void *lpfc_mbuf_alloc(struct lpfc_hba *, int, dma_addr_t *); 243void *lpfc_mbuf_alloc(struct lpfc_hba *, int, dma_addr_t *);
@@ -248,10 +250,13 @@ const char* lpfc_info(struct Scsi_Host *);
248int lpfc_scan_finished(struct Scsi_Host *, unsigned long); 250int lpfc_scan_finished(struct Scsi_Host *, unsigned long);
249 251
250void lpfc_get_cfgparam(struct lpfc_hba *); 252void lpfc_get_cfgparam(struct lpfc_hba *);
253void lpfc_get_vport_cfgparam(struct lpfc_vport *);
251int lpfc_alloc_sysfs_attr(struct lpfc_vport *); 254int lpfc_alloc_sysfs_attr(struct lpfc_vport *);
252void lpfc_free_sysfs_attr(struct lpfc_vport *); 255void lpfc_free_sysfs_attr(struct lpfc_vport *);
253extern struct class_device_attribute *lpfc_hba_attrs[]; 256extern struct class_device_attribute *lpfc_hba_attrs[];
257extern struct class_device_attribute *lpfc_vport_attrs[];
254extern struct scsi_host_template lpfc_template; 258extern struct scsi_host_template lpfc_template;
259extern struct scsi_host_template lpfc_vport_template;
255extern struct fc_function_template lpfc_transport_functions; 260extern struct fc_function_template lpfc_transport_functions;
256extern struct fc_function_template lpfc_vport_transport_functions; 261extern struct fc_function_template lpfc_vport_transport_functions;
257extern int lpfc_sli_mode; 262extern int lpfc_sli_mode;
@@ -260,7 +265,7 @@ int lpfc_vport_symbolic_node_name(struct lpfc_vport *, char *, size_t);
260void lpfc_terminate_rport_io(struct fc_rport *); 265void lpfc_terminate_rport_io(struct fc_rport *);
261void lpfc_dev_loss_tmo_callbk(struct fc_rport *rport); 266void lpfc_dev_loss_tmo_callbk(struct fc_rport *rport);
262 267
263struct lpfc_vport *lpfc_create_port(struct lpfc_hba *, int, struct fc_vport *); 268struct lpfc_vport *lpfc_create_port(struct lpfc_hba *, int, struct device *);
264int lpfc_vport_disable(struct fc_vport *fc_vport, bool disable); 269int lpfc_vport_disable(struct fc_vport *fc_vport, bool disable);
265void lpfc_mbx_unreg_vpi(struct lpfc_vport *); 270void lpfc_mbx_unreg_vpi(struct lpfc_vport *);
266void destroy_port(struct lpfc_vport *); 271void destroy_port(struct lpfc_vport *);
@@ -271,6 +276,9 @@ extern void lpfc_debugfs_initialize(struct lpfc_vport *);
271extern void lpfc_debugfs_terminate(struct lpfc_vport *); 276extern void lpfc_debugfs_terminate(struct lpfc_vport *);
272extern void lpfc_debugfs_disc_trc(struct lpfc_vport *, int, char *, uint32_t, 277extern void lpfc_debugfs_disc_trc(struct lpfc_vport *, int, char *, uint32_t,
273 uint32_t, uint32_t); 278 uint32_t, uint32_t);
279extern void lpfc_debugfs_slow_ring_trc(struct lpfc_hba *, char *, uint32_t,
280 uint32_t, uint32_t);
281extern struct lpfc_hbq_init *lpfc_hbq_defs[];
274 282
275/* Interface exported by fabric iocb scheduler */ 283/* Interface exported by fabric iocb scheduler */
276int lpfc_issue_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *); 284int lpfc_issue_fabric_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index ae9d6f385a6c..c701e4d611a9 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -257,6 +257,10 @@ lpfc_ct_free_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *ctiocb)
257{ 257{
258 struct lpfc_dmabuf *buf_ptr; 258 struct lpfc_dmabuf *buf_ptr;
259 259
260 if (ctiocb->context_un.ndlp) {
261 lpfc_nlp_put(ctiocb->context_un.ndlp);
262 ctiocb->context_un.ndlp = NULL;
263 }
260 if (ctiocb->context1) { 264 if (ctiocb->context1) {
261 buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1; 265 buf_ptr = (struct lpfc_dmabuf *) ctiocb->context1;
262 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); 266 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys);
@@ -314,6 +318,7 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp,
314 /* Save for completion so we can release these resources */ 318 /* Save for completion so we can release these resources */
315 geniocb->context1 = (uint8_t *) inp; 319 geniocb->context1 = (uint8_t *) inp;
316 geniocb->context2 = (uint8_t *) outp; 320 geniocb->context2 = (uint8_t *) outp;
321 geniocb->context_un.ndlp = ndlp;
317 322
318 /* Fill in payload, bp points to frame payload */ 323 /* Fill in payload, bp points to frame payload */
319 icmd->ulpCommand = CMD_GEN_REQUEST64_CR; 324 icmd->ulpCommand = CMD_GEN_REQUEST64_CR;
@@ -341,11 +346,11 @@ lpfc_gen_req(struct lpfc_vport *vport, struct lpfc_dmabuf *bmp,
341 } 346 }
342 347
343 /* Issue GEN REQ IOCB for NPORT <did> */ 348 /* Issue GEN REQ IOCB for NPORT <did> */
344 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 349 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
345 "%d (%d):0119 Issue GEN REQ IOCB to NPORT x%x " 350 "0119 Issue GEN REQ IOCB to NPORT x%x "
346 "Data: x%x x%x\n", phba->brd_no, vport->vpi, 351 "Data: x%x x%x\n",
347 ndlp->nlp_DID, icmd->ulpIoTag, 352 ndlp->nlp_DID, icmd->ulpIoTag,
348 vport->port_state); 353 vport->port_state);
349 geniocb->iocb_cmpl = cmpl; 354 geniocb->iocb_cmpl = cmpl;
350 geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT; 355 geniocb->drvrTimeout = icmd->ulpTimeout + LPFC_DRVR_TIMEOUT;
351 geniocb->vport = vport; 356 geniocb->vport = vport;
@@ -390,17 +395,19 @@ lpfc_ct_cmd(struct lpfc_vport *vport, struct lpfc_dmabuf *inmp,
390 return 0; 395 return 0;
391} 396}
392 397
393static struct lpfc_vport * 398struct lpfc_vport *
394lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) { 399lpfc_find_vport_by_did(struct lpfc_hba *phba, uint32_t did) {
395
396 struct lpfc_vport *vport_curr; 400 struct lpfc_vport *vport_curr;
401 unsigned long flags;
397 402
403 spin_lock_irqsave(&phba->hbalock, flags);
398 list_for_each_entry(vport_curr, &phba->port_list, listentry) { 404 list_for_each_entry(vport_curr, &phba->port_list, listentry) {
399 if ((vport_curr->fc_myDID) && 405 if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) {
400 (vport_curr->fc_myDID == did)) 406 spin_unlock_irqrestore(&phba->hbalock, flags);
401 return vport_curr; 407 return vport_curr;
408 }
402 } 409 }
403 410 spin_unlock_irqrestore(&phba->hbalock, flags);
404 return NULL; 411 return NULL;
405} 412}
406 413
@@ -449,10 +456,10 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size)
449 */ 456 */
450 if ((Did != vport->fc_myDID) && 457 if ((Did != vport->fc_myDID) &&
451 ((lpfc_find_vport_by_did(phba, Did) == NULL) || 458 ((lpfc_find_vport_by_did(phba, Did) == NULL) ||
452 phba->cfg_peer_port_login)) { 459 vport->cfg_peer_port_login)) {
453 if ((vport->port_type != LPFC_NPIV_PORT) || 460 if ((vport->port_type != LPFC_NPIV_PORT) ||
454 (vport->fc_flag & FC_RFF_NOT_SUPPORTED) || 461 (vport->fc_flag & FC_RFF_NOT_SUPPORTED) ||
455 (!phba->cfg_vport_restrict_login)) { 462 (!vport->cfg_restrict_login)) {
456 ndlp = lpfc_setup_disc_node(vport, Did); 463 ndlp = lpfc_setup_disc_node(vport, Did);
457 if (ndlp) { 464 if (ndlp) {
458 lpfc_debugfs_disc_trc(vport, 465 lpfc_debugfs_disc_trc(vport,
@@ -462,14 +469,13 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size)
462 Did, ndlp->nlp_flag, 469 Did, ndlp->nlp_flag,
463 vport->fc_flag); 470 vport->fc_flag);
464 471
465 lpfc_printf_log(phba, KERN_INFO, 472 lpfc_printf_vlog(vport,
473 KERN_INFO,
466 LOG_DISCOVERY, 474 LOG_DISCOVERY,
467 "%d (%d):0238 Process " 475 "0238 Process "
468 "x%x NameServer Rsp" 476 "x%x NameServer Rsp"
469 "Data: x%x x%x x%x\n", 477 "Data: x%x x%x x%x\n",
470 phba->brd_no, 478 Did, ndlp->nlp_flag,
471 vport->vpi, Did,
472 ndlp->nlp_flag,
473 vport->fc_flag, 479 vport->fc_flag,
474 vport->fc_rscn_id_cnt); 480 vport->fc_rscn_id_cnt);
475 } else { 481 } else {
@@ -480,14 +486,13 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size)
480 Did, vport->fc_flag, 486 Did, vport->fc_flag,
481 vport->fc_rscn_id_cnt); 487 vport->fc_rscn_id_cnt);
482 488
483 lpfc_printf_log(phba, KERN_INFO, 489 lpfc_printf_vlog(vport,
490 KERN_INFO,
484 LOG_DISCOVERY, 491 LOG_DISCOVERY,
485 "%d (%d):0239 Skip x%x " 492 "0239 Skip x%x "
486 "NameServer Rsp Data: " 493 "NameServer Rsp Data: "
487 "x%x x%x\n", 494 "x%x x%x\n",
488 phba->brd_no, 495 Did, vport->fc_flag,
489 vport->vpi, Did,
490 vport->fc_flag,
491 vport->fc_rscn_id_cnt); 496 vport->fc_rscn_id_cnt);
492 } 497 }
493 498
@@ -514,14 +519,13 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint32_t Size)
514 Did, vport->fc_flag, 519 Did, vport->fc_flag,
515 vport->fc_rscn_id_cnt); 520 vport->fc_rscn_id_cnt);
516 521
517 lpfc_printf_log(phba, KERN_INFO, 522 lpfc_printf_vlog(vport,
523 KERN_INFO,
518 LOG_DISCOVERY, 524 LOG_DISCOVERY,
519 "%d (%d):0245 Skip x%x " 525 "0245 Skip x%x "
520 "NameServer Rsp Data: " 526 "NameServer Rsp Data: "
521 "x%x x%x\n", 527 "x%x x%x\n",
522 phba->brd_no, 528 Did, vport->fc_flag,
523 vport->vpi, Did,
524 vport->fc_flag,
525 vport->fc_rscn_id_cnt); 529 vport->fc_rscn_id_cnt);
526 } 530 }
527 } 531 }
@@ -549,8 +553,12 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
549 struct lpfc_dmabuf *bmp; 553 struct lpfc_dmabuf *bmp;
550 struct lpfc_dmabuf *outp; 554 struct lpfc_dmabuf *outp;
551 struct lpfc_sli_ct_request *CTrsp; 555 struct lpfc_sli_ct_request *CTrsp;
556 struct lpfc_nodelist *ndlp;
552 int rc; 557 int rc;
553 558
559 /* First save ndlp, before we overwrite it */
560 ndlp = cmdiocb->context_un.ndlp;
561
554 /* we pass cmdiocb to state machine which needs rspiocb as well */ 562 /* we pass cmdiocb to state machine which needs rspiocb as well */
555 cmdiocb->context_un.rsp_iocb = rspiocb; 563 cmdiocb->context_un.rsp_iocb = rspiocb;
556 564
@@ -568,9 +576,8 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
568 576
569 577
570 if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) { 578 if (lpfc_els_chk_latt(vport) || lpfc_error_lost_link(irsp)) {
571 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 579 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
572 "%d (%d):0216 Link event during NS query\n", 580 "0216 Link event during NS query\n");
573 phba->brd_no, vport->vpi);
574 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 581 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
575 goto out; 582 goto out;
576 } 583 }
@@ -588,46 +595,61 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
588 goto out; 595 goto out;
589 } 596 }
590 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 597 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
591 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 598 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
592 "%d (%d):0257 GID_FT Query error: 0x%x 0x%x\n", 599 "0257 GID_FT Query error: 0x%x 0x%x\n",
593 phba->brd_no, vport->vpi, irsp->ulpStatus, 600 irsp->ulpStatus, vport->fc_ns_retry);
594 vport->fc_ns_retry);
595 } else { 601 } else {
596 /* Good status, continue checking */ 602 /* Good status, continue checking */
597 CTrsp = (struct lpfc_sli_ct_request *) outp->virt; 603 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
598 if (CTrsp->CommandResponse.bits.CmdRsp == 604 if (CTrsp->CommandResponse.bits.CmdRsp ==
599 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { 605 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) {
600 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 606 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
601 "%d (%d):0208 NameServer Rsp " 607 "0208 NameServer Rsp Data: x%x\n",
602 "Data: x%x\n", 608 vport->fc_flag);
603 phba->brd_no, vport->vpi,
604 vport->fc_flag);
605 lpfc_ns_rsp(vport, outp, 609 lpfc_ns_rsp(vport, outp,
606 (uint32_t) (irsp->un.genreq64.bdl.bdeSize)); 610 (uint32_t) (irsp->un.genreq64.bdl.bdeSize));
607 } else if (CTrsp->CommandResponse.bits.CmdRsp == 611 } else if (CTrsp->CommandResponse.bits.CmdRsp ==
608 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { 612 be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
609 /* NameServer Rsp Error */ 613 /* NameServer Rsp Error */
610 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 614 if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ)
611 "%d (%d):0240 NameServer Rsp Error " 615 && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) {
616 lpfc_printf_vlog(vport, KERN_INFO,
617 LOG_DISCOVERY,
618 "0269 No NameServer Entries "
612 "Data: x%x x%x x%x x%x\n", 619 "Data: x%x x%x x%x x%x\n",
613 phba->brd_no, vport->vpi,
614 CTrsp->CommandResponse.bits.CmdRsp, 620 CTrsp->CommandResponse.bits.CmdRsp,
615 (uint32_t) CTrsp->ReasonCode, 621 (uint32_t) CTrsp->ReasonCode,
616 (uint32_t) CTrsp->Explanation, 622 (uint32_t) CTrsp->Explanation,
617 vport->fc_flag); 623 vport->fc_flag);
618 624
619 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 625 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
626 "GID_FT no entry cmd:x%x rsn:x%x exp:x%x",
627 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
628 (uint32_t) CTrsp->ReasonCode,
629 (uint32_t) CTrsp->Explanation);
630 } else {
631 lpfc_printf_vlog(vport, KERN_INFO,
632 LOG_DISCOVERY,
633 "0240 NameServer Rsp Error "
634 "Data: x%x x%x x%x x%x\n",
635 CTrsp->CommandResponse.bits.CmdRsp,
636 (uint32_t) CTrsp->ReasonCode,
637 (uint32_t) CTrsp->Explanation,
638 vport->fc_flag);
639
640 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
620 "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x", 641 "GID_FT rsp err1 cmd:x%x rsn:x%x exp:x%x",
621 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp, 642 (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
622 (uint32_t) CTrsp->ReasonCode, 643 (uint32_t) CTrsp->ReasonCode,
623 (uint32_t) CTrsp->Explanation); 644 (uint32_t) CTrsp->Explanation);
645 }
646
624 647
625 } else { 648 } else {
626 /* NameServer Rsp Error */ 649 /* NameServer Rsp Error */
627 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 650 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
628 "%d (%d):0241 NameServer Rsp Error " 651 "0241 NameServer Rsp Error "
629 "Data: x%x x%x x%x x%x\n", 652 "Data: x%x x%x x%x x%x\n",
630 phba->brd_no, vport->vpi,
631 CTrsp->CommandResponse.bits.CmdRsp, 653 CTrsp->CommandResponse.bits.CmdRsp,
632 (uint32_t) CTrsp->ReasonCode, 654 (uint32_t) CTrsp->ReasonCode,
633 (uint32_t) CTrsp->Explanation, 655 (uint32_t) CTrsp->Explanation,
@@ -661,11 +683,12 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
661 lpfc_disc_start(vport); 683 lpfc_disc_start(vport);
662 } 684 }
663out: 685out:
686 cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */
664 lpfc_ct_free_iocb(phba, cmdiocb); 687 lpfc_ct_free_iocb(phba, cmdiocb);
665 return; 688 return;
666} 689}
667 690
668void 691static void
669lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, 692lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
670 struct lpfc_iocbq *rspiocb) 693 struct lpfc_iocbq *rspiocb)
671{ 694{
@@ -695,40 +718,37 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
695 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) { 718 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) {
696 if ((fbits & FC4_FEATURE_INIT) && 719 if ((fbits & FC4_FEATURE_INIT) &&
697 !(fbits & FC4_FEATURE_TARGET)) { 720 !(fbits & FC4_FEATURE_TARGET)) {
698 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 721 lpfc_printf_vlog(vport, KERN_INFO,
699 "%d (%d):0245 Skip x%x GFF " 722 LOG_DISCOVERY,
700 "NameServer Rsp Data: (init) " 723 "0270 Skip x%x GFF "
701 "x%x x%x\n", phba->brd_no, 724 "NameServer Rsp Data: (init) "
702 vport->vpi, did, fbits, 725 "x%x x%x\n", did, fbits,
703 vport->fc_rscn_id_cnt); 726 vport->fc_rscn_id_cnt);
704 goto out; 727 goto out;
705 } 728 }
706 } 729 }
707 } 730 }
708 else { 731 else {
709 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 732 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
710 "%d (%d):0267 NameServer GFF Rsp" 733 "0267 NameServer GFF Rsp "
711 " x%x Error (%d %d) Data: x%x x%x\n", 734 "x%x Error (%d %d) Data: x%x x%x\n",
712 phba->brd_no, vport->vpi, did, 735 did, irsp->ulpStatus, irsp->un.ulpWord[4],
713 irsp->ulpStatus, irsp->un.ulpWord[4], 736 vport->fc_flag, vport->fc_rscn_id_cnt)
714 vport->fc_flag, vport->fc_rscn_id_cnt)
715 } 737 }
716 738
717 /* This is a target port, unregistered port, or the GFF_ID failed */ 739 /* This is a target port, unregistered port, or the GFF_ID failed */
718 ndlp = lpfc_setup_disc_node(vport, did); 740 ndlp = lpfc_setup_disc_node(vport, did);
719 if (ndlp) { 741 if (ndlp) {
720 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 742 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
721 "%d (%d):0242 Process x%x GFF " 743 "0242 Process x%x GFF "
722 "NameServer Rsp Data: x%x x%x x%x\n", 744 "NameServer Rsp Data: x%x x%x x%x\n",
723 phba->brd_no, vport->vpi, 745 did, ndlp->nlp_flag, vport->fc_flag,
724 did, ndlp->nlp_flag, vport->fc_flag, 746 vport->fc_rscn_id_cnt);
725 vport->fc_rscn_id_cnt);
726 } else { 747 } else {
727 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 748 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
728 "%d (%d):0243 Skip x%x GFF " 749 "0243 Skip x%x GFF "
729 "NameServer Rsp Data: x%x x%x\n", 750 "NameServer Rsp Data: x%x x%x\n", did,
730 phba->brd_no, vport->vpi, did, 751 vport->fc_flag, vport->fc_rscn_id_cnt);
731 vport->fc_flag, vport->fc_rscn_id_cnt);
732 } 752 }
733out: 753out:
734 /* Link up / RSCN discovery */ 754 /* Link up / RSCN discovery */
@@ -766,10 +786,14 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
766 struct lpfc_dmabuf *outp; 786 struct lpfc_dmabuf *outp;
767 IOCB_t *irsp; 787 IOCB_t *irsp;
768 struct lpfc_sli_ct_request *CTrsp; 788 struct lpfc_sli_ct_request *CTrsp;
789 struct lpfc_nodelist *ndlp;
769 int cmdcode, rc; 790 int cmdcode, rc;
770 uint8_t retry; 791 uint8_t retry;
771 uint32_t latt; 792 uint32_t latt;
772 793
794 /* First save ndlp, before we overwrite it */
795 ndlp = cmdiocb->context_un.ndlp;
796
773 /* we pass cmdiocb to state machine which needs rspiocb as well */ 797 /* we pass cmdiocb to state machine which needs rspiocb as well */
774 cmdiocb->context_un.rsp_iocb = rspiocb; 798 cmdiocb->context_un.rsp_iocb = rspiocb;
775 799
@@ -784,22 +808,21 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
784 latt = lpfc_els_chk_latt(vport); 808 latt = lpfc_els_chk_latt(vport);
785 809
786 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */ 810 /* RFT request completes status <ulpStatus> CmdRsp <CmdRsp> */
787 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 811 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
788 "%d (%d):0209 RFT request completes, latt %d, " 812 "0209 RFT request completes, latt %d, "
789 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n", 813 "ulpStatus x%x CmdRsp x%x, Context x%x, Tag x%x\n",
790 phba->brd_no, vport->vpi, latt, irsp->ulpStatus, 814 latt, irsp->ulpStatus,
791 CTrsp->CommandResponse.bits.CmdRsp, 815 CTrsp->CommandResponse.bits.CmdRsp,
792 cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag); 816 cmdiocb->iocb.ulpContext, cmdiocb->iocb.ulpIoTag);
793 817
794 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT, 818 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
795 "CT cmd cmpl: status:x%x/x%x cmd:x%x", 819 "CT cmd cmpl: status:x%x/x%x cmd:x%x",
796 irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode); 820 irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode);
797 821
798 if (irsp->ulpStatus) { 822 if (irsp->ulpStatus) {
799 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 823 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
800 "%d (%d):0268 NS cmd %x Error (%d %d)\n", 824 "0268 NS cmd %x Error (%d %d)\n",
801 phba->brd_no, vport->vpi, cmdcode, 825 cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]);
802 irsp->ulpStatus, irsp->un.ulpWord[4]);
803 826
804 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 827 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
805 ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) || 828 ((irsp->un.ulpWord[4] == IOERR_SLI_DOWN) ||
@@ -811,15 +834,15 @@ lpfc_cmpl_ct_cmd_rft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
811 goto out; 834 goto out;
812 835
813 retry++; 836 retry++;
814 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 837 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
815 "%d (%d):0216 Retrying NS cmd %x\n", 838 "0216 Retrying NS cmd %x\n", cmdcode);
816 phba->brd_no, vport->vpi, cmdcode);
817 rc = lpfc_ns_cmd(vport, cmdcode, retry, 0); 839 rc = lpfc_ns_cmd(vport, cmdcode, retry, 0);
818 if (rc == 0) 840 if (rc == 0)
819 goto out; 841 goto out;
820 } 842 }
821 843
822out: 844out:
845 cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */
823 lpfc_ct_free_iocb(phba, cmdiocb); 846 lpfc_ct_free_iocb(phba, cmdiocb);
824 return; 847 return;
825} 848}
@@ -862,7 +885,7 @@ lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
862 return; 885 return;
863} 886}
864 887
865int 888static int
866lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol, 889lpfc_vport_symbolic_port_name(struct lpfc_vport *vport, char *symbol,
867 size_t size) 890 size_t size)
868{ 891{
@@ -957,10 +980,9 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
957 } 980 }
958 981
959 /* NameServer Req */ 982 /* NameServer Req */
960 lpfc_printf_log(phba, KERN_INFO ,LOG_DISCOVERY, 983 lpfc_printf_vlog(vport, KERN_INFO ,LOG_DISCOVERY,
961 "%d (%d):0236 NameServer Req Data: x%x x%x x%x\n", 984 "0236 NameServer Req Data: x%x x%x x%x\n",
962 phba->brd_no, vport->vpi, cmdcode, vport->fc_flag, 985 cmdcode, vport->fc_flag, vport->fc_rscn_id_cnt);
963 vport->fc_rscn_id_cnt);
964 986
965 bpl = (struct ulp_bde64 *) bmp->virt; 987 bpl = (struct ulp_bde64 *) bmp->virt;
966 memset(bpl, 0, sizeof(struct ulp_bde64)); 988 memset(bpl, 0, sizeof(struct ulp_bde64));
@@ -1059,6 +1081,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1059 cmpl = lpfc_cmpl_ct_cmd_rff_id; 1081 cmpl = lpfc_cmpl_ct_cmd_rff_id;
1060 break; 1082 break;
1061 } 1083 }
1084 lpfc_nlp_get(ndlp);
1062 1085
1063 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) { 1086 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, rsp_size, retry)) {
1064 /* On success, The cmpl function will free the buffers */ 1087 /* On success, The cmpl function will free the buffers */
@@ -1069,6 +1092,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
1069 } 1092 }
1070 1093
1071 rc=6; 1094 rc=6;
1095 lpfc_nlp_put(ndlp);
1072 lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 1096 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
1073ns_cmd_free_bmp: 1097ns_cmd_free_bmp:
1074 kfree(bmp); 1098 kfree(bmp);
@@ -1077,10 +1101,9 @@ ns_cmd_free_mpvirt:
1077ns_cmd_free_mp: 1101ns_cmd_free_mp:
1078 kfree(mp); 1102 kfree(mp);
1079ns_cmd_exit: 1103ns_cmd_exit:
1080 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 1104 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1081 "%d (%d):0266 Issue NameServer Req x%x err %d Data: x%x x%x\n", 1105 "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
1082 phba->brd_no, vport->vpi, cmdcode, rc, vport->fc_flag, 1106 cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt);
1083 vport->fc_rscn_id_cnt);
1084 return 1; 1107 return 1;
1085} 1108}
1086 1109
@@ -1106,12 +1129,11 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1106 irsp->ulpStatus, irsp->un.ulpWord[4], latt); 1129 irsp->ulpStatus, irsp->un.ulpWord[4], latt);
1107 1130
1108 if (latt || irsp->ulpStatus) { 1131 if (latt || irsp->ulpStatus) {
1109 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1132 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1110 "%d (%d):0229 FDMI cmd %04x failed, latt = %d " 1133 "0229 FDMI cmd %04x failed, latt = %d "
1111 "ulpStatus: x%x, rid x%x\n", 1134 "ulpStatus: x%x, rid x%x\n",
1112 phba->brd_no, vport->vpi, 1135 be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus,
1113 be16_to_cpu(fdmi_cmd), latt, irsp->ulpStatus, 1136 irsp->un.ulpWord[4]);
1114 irsp->un.ulpWord[4]);
1115 lpfc_ct_free_iocb(phba, cmdiocb); 1137 lpfc_ct_free_iocb(phba, cmdiocb);
1116 return; 1138 return;
1117 } 1139 }
@@ -1119,10 +1141,9 @@ lpfc_cmpl_ct_cmd_fdmi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1119 ndlp = lpfc_findnode_did(vport, FDMI_DID); 1141 ndlp = lpfc_findnode_did(vport, FDMI_DID);
1120 if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) { 1142 if (fdmi_rsp == be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
1121 /* FDMI rsp failed */ 1143 /* FDMI rsp failed */
1122 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1144 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1123 "%d (%d):0220 FDMI rsp failed Data: x%x\n", 1145 "0220 FDMI rsp failed Data: x%x\n",
1124 phba->brd_no, vport->vpi, 1146 be16_to_cpu(fdmi_cmd));
1125 be16_to_cpu(fdmi_cmd));
1126 } 1147 }
1127 1148
1128 switch (be16_to_cpu(fdmi_cmd)) { 1149 switch (be16_to_cpu(fdmi_cmd)) {
@@ -1185,11 +1206,9 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1185 INIT_LIST_HEAD(&bmp->list); 1206 INIT_LIST_HEAD(&bmp->list);
1186 1207
1187 /* FDMI request */ 1208 /* FDMI request */
1188 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1209 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1189 "%d (%d):0218 FDMI Request Data: x%x x%x x%x\n", 1210 "0218 FDMI Request Data: x%x x%x x%x\n",
1190 phba->brd_no, vport->vpi, vport->fc_flag, 1211 vport->fc_flag, vport->port_state, cmdcode);
1191 vport->port_state, cmdcode);
1192
1193 CtReq = (struct lpfc_sli_ct_request *) mp->virt; 1212 CtReq = (struct lpfc_sli_ct_request *) mp->virt;
1194 1213
1195 memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request)); 1214 memset(CtReq, 0, sizeof(struct lpfc_sli_ct_request));
@@ -1449,7 +1468,7 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1449 pab->ab.EntryCnt++; 1468 pab->ab.EntryCnt++;
1450 size += FOURBYTES + len; 1469 size += FOURBYTES + len;
1451 1470
1452 if (phba->cfg_fdmi_on == 2) { 1471 if (vport->cfg_fdmi_on == 2) {
1453 /* #6 Port attribute entry */ 1472 /* #6 Port attribute entry */
1454 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab + 1473 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) pab +
1455 size); 1474 size);
@@ -1499,10 +1518,12 @@ lpfc_fdmi_cmd(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, int cmdcode)
1499 bpl->tus.w = le32_to_cpu(bpl->tus.w); 1518 bpl->tus.w = le32_to_cpu(bpl->tus.w);
1500 1519
1501 cmpl = lpfc_cmpl_ct_cmd_fdmi; 1520 cmpl = lpfc_cmpl_ct_cmd_fdmi;
1521 lpfc_nlp_get(ndlp);
1502 1522
1503 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0)) 1523 if (!lpfc_ct_cmd(vport, mp, bmp, ndlp, cmpl, FC_MAX_NS_RSP, 0))
1504 return 0; 1524 return 0;
1505 1525
1526 lpfc_nlp_put(ndlp);
1506 lpfc_mbuf_free(phba, bmp->virt, bmp->phys); 1527 lpfc_mbuf_free(phba, bmp->virt, bmp->phys);
1507fdmi_cmd_free_bmp: 1528fdmi_cmd_free_bmp:
1508 kfree(bmp); 1529 kfree(bmp);
@@ -1512,9 +1533,9 @@ fdmi_cmd_free_mp:
1512 kfree(mp); 1533 kfree(mp);
1513fdmi_cmd_exit: 1534fdmi_cmd_exit:
1514 /* Issue FDMI request failed */ 1535 /* Issue FDMI request failed */
1515 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1536 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1516 "%d (%d):0244 Issue FDMI request failed Data: x%x\n", 1537 "0244 Issue FDMI request failed Data: x%x\n",
1517 phba->brd_no, vport->vpi, cmdcode); 1538 cmdcode);
1518 return 1; 1539 return 1;
1519} 1540}
1520 1541
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 673cfe11cc2b..2e3c01bebed6 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -71,15 +71,22 @@
71 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in 71 * lpfc_debugfs_mask_disc_trc=Y Where Y is an event mask as defined in
72 * lpfc_debugfs.h . 72 * lpfc_debugfs.h .
73 */ 73 */
74static int lpfc_debugfs_enable = 0; 74static int lpfc_debugfs_enable = 1;
75module_param(lpfc_debugfs_enable, int, 0); 75module_param(lpfc_debugfs_enable, int, 0);
76MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services"); 76MODULE_PARM_DESC(lpfc_debugfs_enable, "Enable debugfs services");
77 77
78static int lpfc_debugfs_max_disc_trc = 0; /* This MUST be a power of 2 */ 78/* This MUST be a power of 2 */
79static int lpfc_debugfs_max_disc_trc = 0;
79module_param(lpfc_debugfs_max_disc_trc, int, 0); 80module_param(lpfc_debugfs_max_disc_trc, int, 0);
80MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc, 81MODULE_PARM_DESC(lpfc_debugfs_max_disc_trc,
81 "Set debugfs discovery trace depth"); 82 "Set debugfs discovery trace depth");
82 83
84/* This MUST be a power of 2 */
85static int lpfc_debugfs_max_slow_ring_trc = 0;
86module_param(lpfc_debugfs_max_slow_ring_trc, int, 0);
87MODULE_PARM_DESC(lpfc_debugfs_max_slow_ring_trc,
88 "Set debugfs slow ring trace depth");
89
83static int lpfc_debugfs_mask_disc_trc = 0; 90static int lpfc_debugfs_mask_disc_trc = 0;
84module_param(lpfc_debugfs_mask_disc_trc, int, 0); 91module_param(lpfc_debugfs_mask_disc_trc, int, 0);
85MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc, 92MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
@@ -87,28 +94,34 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
87 94
88#include <linux/debugfs.h> 95#include <linux/debugfs.h>
89 96
90/* size of discovery_trace output line */ 97/* size of output line, for discovery_trace and slow_ring_trace */
91#define LPFC_DISC_TRC_ENTRY_SIZE 80 98#define LPFC_DEBUG_TRC_ENTRY_SIZE 100
92 99
93/* nodelist output buffer size */ 100/* nodelist output buffer size */
94#define LPFC_NODELIST_SIZE 8192 101#define LPFC_NODELIST_SIZE 8192
95#define LPFC_NODELIST_ENTRY_SIZE 120 102#define LPFC_NODELIST_ENTRY_SIZE 120
96 103
104/* dumpslim output buffer size */
105#define LPFC_DUMPSLIM_SIZE 4096
106
107/* hbqinfo output buffer size */
108#define LPFC_HBQINFO_SIZE 8192
109
97struct lpfc_debug { 110struct lpfc_debug {
98 char *buffer; 111 char *buffer;
99 int len; 112 int len;
100}; 113};
101 114
102atomic_t lpfc_debugfs_disc_trc_cnt = ATOMIC_INIT(0); 115static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
103unsigned long lpfc_debugfs_start_time = 0L; 116static unsigned long lpfc_debugfs_start_time = 0L;
104 117
105static int 118static int
106lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size) 119lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
107{ 120{
108 int i, index, len, enable; 121 int i, index, len, enable;
109 uint32_t ms; 122 uint32_t ms;
110 struct lpfc_disc_trc *dtp; 123 struct lpfc_debugfs_trc *dtp;
111 char buffer[80]; 124 char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE];
112 125
113 126
114 enable = lpfc_debugfs_enable; 127 enable = lpfc_debugfs_enable;
@@ -122,7 +135,8 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
122 if (!dtp->fmt) 135 if (!dtp->fmt)
123 continue; 136 continue;
124 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); 137 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
125 snprintf(buffer, 80, "%010d:%010d ms:%s\n", 138 snprintf(buffer,
139 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
126 dtp->seq_cnt, ms, dtp->fmt); 140 dtp->seq_cnt, ms, dtp->fmt);
127 len += snprintf(buf+len, size-len, buffer, 141 len += snprintf(buf+len, size-len, buffer,
128 dtp->data1, dtp->data2, dtp->data3); 142 dtp->data1, dtp->data2, dtp->data3);
@@ -132,7 +146,8 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
132 if (!dtp->fmt) 146 if (!dtp->fmt)
133 continue; 147 continue;
134 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time); 148 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
135 snprintf(buffer, 80, "%010d:%010d ms:%s\n", 149 snprintf(buffer,
150 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
136 dtp->seq_cnt, ms, dtp->fmt); 151 dtp->seq_cnt, ms, dtp->fmt);
137 len += snprintf(buf+len, size-len, buffer, 152 len += snprintf(buf+len, size-len, buffer,
138 dtp->data1, dtp->data2, dtp->data3); 153 dtp->data1, dtp->data2, dtp->data3);
@@ -143,6 +158,236 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
143} 158}
144 159
145static int 160static int
161lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
162{
163 int i, index, len, enable;
164 uint32_t ms;
165 struct lpfc_debugfs_trc *dtp;
166 char buffer[LPFC_DEBUG_TRC_ENTRY_SIZE];
167
168
169 enable = lpfc_debugfs_enable;
170 lpfc_debugfs_enable = 0;
171
172 len = 0;
173 index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
174 (lpfc_debugfs_max_slow_ring_trc - 1);
175 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
176 dtp = phba->slow_ring_trc + i;
177 if (!dtp->fmt)
178 continue;
179 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
180 snprintf(buffer,
181 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
182 dtp->seq_cnt, ms, dtp->fmt);
183 len += snprintf(buf+len, size-len, buffer,
184 dtp->data1, dtp->data2, dtp->data3);
185 }
186 for (i = 0; i < index; i++) {
187 dtp = phba->slow_ring_trc + i;
188 if (!dtp->fmt)
189 continue;
190 ms = jiffies_to_msecs(dtp->jif - lpfc_debugfs_start_time);
191 snprintf(buffer,
192 LPFC_DEBUG_TRC_ENTRY_SIZE, "%010d:%010d ms:%s\n",
193 dtp->seq_cnt, ms, dtp->fmt);
194 len += snprintf(buf+len, size-len, buffer,
195 dtp->data1, dtp->data2, dtp->data3);
196 }
197
198 lpfc_debugfs_enable = enable;
199 return len;
200}
201
202static int lpfc_debugfs_last_hbq = -1;
203
204static int
205lpfc_debugfs_hbqinfo_data(struct lpfc_hba *phba, char *buf, int size)
206{
207 int len = 0;
208 int cnt, i, j, found, posted, low;
209 uint32_t phys, raw_index, getidx;
210 struct lpfc_hbq_init *hip;
211 struct hbq_s *hbqs;
212 struct lpfc_hbq_entry *hbqe;
213 struct lpfc_dmabuf *d_buf;
214 struct hbq_dmabuf *hbq_buf;
215
216 cnt = LPFC_HBQINFO_SIZE;
217 spin_lock_irq(&phba->hbalock);
218
219 /* toggle between multiple hbqs, if any */
220 i = lpfc_sli_hbq_count();
221 if (i > 1) {
222 lpfc_debugfs_last_hbq++;
223 if (lpfc_debugfs_last_hbq >= i)
224 lpfc_debugfs_last_hbq = 0;
225 }
226 else
227 lpfc_debugfs_last_hbq = 0;
228
229 i = lpfc_debugfs_last_hbq;
230
231 len += snprintf(buf+len, size-len, "HBQ %d Info\n", i);
232
233 hbqs = &phba->hbqs[i];
234 posted = 0;
235 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list)
236 posted++;
237
238 hip = lpfc_hbq_defs[i];
239 len += snprintf(buf+len, size-len,
240 "idx:%d prof:%d rn:%d bufcnt:%d icnt:%d acnt:%d posted %d\n",
241 hip->hbq_index, hip->profile, hip->rn,
242 hip->buffer_count, hip->init_count, hip->add_count, posted);
243
244 raw_index = phba->hbq_get[i];
245 getidx = le32_to_cpu(raw_index);
246 len += snprintf(buf+len, size-len,
247 "entrys:%d Put:%d nPut:%d localGet:%d hbaGet:%d\n",
248 hbqs->entry_count, hbqs->hbqPutIdx, hbqs->next_hbqPutIdx,
249 hbqs->local_hbqGetIdx, getidx);
250
251 hbqe = (struct lpfc_hbq_entry *) phba->hbqs[i].hbq_virt;
252 for (j=0; j<hbqs->entry_count; j++) {
253 len += snprintf(buf+len, size-len,
254 "%03d: %08x %04x %05x ", j,
255 hbqe->bde.addrLow, hbqe->bde.tus.w, hbqe->buffer_tag);
256
257 i = 0;
258 found = 0;
259
260 /* First calculate if slot has an associated posted buffer */
261 low = hbqs->hbqPutIdx - posted;
262 if (low >= 0) {
263 if ((j >= hbqs->hbqPutIdx) || (j < low)) {
264 len += snprintf(buf+len, size-len, "Unused\n");
265 goto skipit;
266 }
267 }
268 else {
269 if ((j >= hbqs->hbqPutIdx) &&
270 (j < (hbqs->entry_count+low))) {
271 len += snprintf(buf+len, size-len, "Unused\n");
272 goto skipit;
273 }
274 }
275
276 /* Get the Buffer info for the posted buffer */
277 list_for_each_entry(d_buf, &hbqs->hbq_buffer_list, list) {
278 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
279 phys = ((uint64_t)hbq_buf->dbuf.phys & 0xffffffff);
280 if (phys == hbqe->bde.addrLow) {
281 len += snprintf(buf+len, size-len,
282 "Buf%d: %p %06x\n", i,
283 hbq_buf->dbuf.virt, hbq_buf->tag);
284 found = 1;
285 break;
286 }
287 i++;
288 }
289 if (!found) {
290 len += snprintf(buf+len, size-len, "No DMAinfo?\n");
291 }
292skipit:
293 hbqe++;
294 if (len > LPFC_HBQINFO_SIZE - 54)
295 break;
296 }
297 spin_unlock_irq(&phba->hbalock);
298 return len;
299}
300
301static int
302lpfc_debugfs_dumpslim_data(struct lpfc_hba *phba, char *buf, int size)
303{
304 int len = 0;
305 int cnt, i, off;
306 uint32_t word0, word1, word2, word3;
307 uint32_t *ptr;
308 struct lpfc_pgp *pgpp;
309 struct lpfc_sli *psli = &phba->sli;
310 struct lpfc_sli_ring *pring;
311
312 cnt = LPFC_DUMPSLIM_SIZE;
313 off = 0;
314 spin_lock_irq(&phba->hbalock);
315
316 len += snprintf(buf+len, size-len, "SLIM Mailbox\n");
317 ptr = (uint32_t *)phba->slim2p;
318 i = sizeof(MAILBOX_t);
319 while (i > 0) {
320 len += snprintf(buf+len, size-len,
321 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
322 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
323 *(ptr+5), *(ptr+6), *(ptr+7));
324 ptr += 8;
325 i -= (8 * sizeof(uint32_t));
326 off += (8 * sizeof(uint32_t));
327 }
328
329 len += snprintf(buf+len, size-len, "SLIM PCB\n");
330 ptr = (uint32_t *)&phba->slim2p->pcb;
331 i = sizeof(PCB_t);
332 while (i > 0) {
333 len += snprintf(buf+len, size-len,
334 "%08x: %08x %08x %08x %08x %08x %08x %08x %08x\n",
335 off, *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4),
336 *(ptr+5), *(ptr+6), *(ptr+7));
337 ptr += 8;
338 i -= (8 * sizeof(uint32_t));
339 off += (8 * sizeof(uint32_t));
340 }
341
342 pgpp = (struct lpfc_pgp *)&phba->slim2p->mbx.us.s3_pgp.port;
343 pring = &psli->ring[0];
344 len += snprintf(buf+len, size-len,
345 "Ring 0: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
346 "RSP PutInx:%d Max:%d\n",
347 pgpp->cmdGetInx, pring->numCiocb,
348 pring->next_cmdidx, pring->local_getidx, pring->flag,
349 pgpp->rspPutInx, pring->numRiocb);
350 pgpp++;
351
352 pring = &psli->ring[1];
353 len += snprintf(buf+len, size-len,
354 "Ring 1: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
355 "RSP PutInx:%d Max:%d\n",
356 pgpp->cmdGetInx, pring->numCiocb,
357 pring->next_cmdidx, pring->local_getidx, pring->flag,
358 pgpp->rspPutInx, pring->numRiocb);
359 pgpp++;
360
361 pring = &psli->ring[2];
362 len += snprintf(buf+len, size-len,
363 "Ring 2: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
364 "RSP PutInx:%d Max:%d\n",
365 pgpp->cmdGetInx, pring->numCiocb,
366 pring->next_cmdidx, pring->local_getidx, pring->flag,
367 pgpp->rspPutInx, pring->numRiocb);
368 pgpp++;
369
370 pring = &psli->ring[3];
371 len += snprintf(buf+len, size-len,
372 "Ring 3: CMD GetInx:%d (Max:%d Next:%d Local:%d flg:x%x) "
373 "RSP PutInx:%d Max:%d\n",
374 pgpp->cmdGetInx, pring->numCiocb,
375 pring->next_cmdidx, pring->local_getidx, pring->flag,
376 pgpp->rspPutInx, pring->numRiocb);
377
378
379 ptr = (uint32_t *)&phba->slim2p->mbx.us.s3_pgp.hbq_get;
380 word0 = readl(phba->HAregaddr);
381 word1 = readl(phba->CAregaddr);
382 word2 = readl(phba->HSregaddr);
383 word3 = readl(phba->HCregaddr);
384 len += snprintf(buf+len, size-len, "HA:%08x CA:%08x HS:%08x HC:%08x\n",
385 word0, word1, word2, word3);
386 spin_unlock_irq(&phba->hbalock);
387 return len;
388}
389
390static int
146lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size) 391lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
147{ 392{
148 int len = 0; 393 int len = 0;
@@ -204,7 +449,7 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
204 len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ", 449 len += snprintf(buf+len, size-len, "RPI:%03d flag:x%08x ",
205 ndlp->nlp_rpi, ndlp->nlp_flag); 450 ndlp->nlp_rpi, ndlp->nlp_flag);
206 if (!ndlp->nlp_type) 451 if (!ndlp->nlp_type)
207 len += snprintf(buf+len, size-len, "UNKNOWN_TYPE"); 452 len += snprintf(buf+len, size-len, "UNKNOWN_TYPE ");
208 if (ndlp->nlp_type & NLP_FC_NODE) 453 if (ndlp->nlp_type & NLP_FC_NODE)
209 len += snprintf(buf+len, size-len, "FC_NODE "); 454 len += snprintf(buf+len, size-len, "FC_NODE ");
210 if (ndlp->nlp_type & NLP_FABRIC) 455 if (ndlp->nlp_type & NLP_FABRIC)
@@ -213,7 +458,9 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
213 len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ", 458 len += snprintf(buf+len, size-len, "FCP_TGT sid:%d ",
214 ndlp->nlp_sid); 459 ndlp->nlp_sid);
215 if (ndlp->nlp_type & NLP_FCP_INITIATOR) 460 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
216 len += snprintf(buf+len, size-len, "FCP_INITIATOR"); 461 len += snprintf(buf+len, size-len, "FCP_INITIATOR ");
462 len += snprintf(buf+len, size-len, "refcnt:%x",
463 atomic_read(&ndlp->kref.refcount));
217 len += snprintf(buf+len, size-len, "\n"); 464 len += snprintf(buf+len, size-len, "\n");
218 } 465 }
219 spin_unlock_irq(shost->host_lock); 466 spin_unlock_irq(shost->host_lock);
@@ -227,7 +474,7 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
227 uint32_t data1, uint32_t data2, uint32_t data3) 474 uint32_t data1, uint32_t data2, uint32_t data3)
228{ 475{
229#ifdef CONFIG_LPFC_DEBUG_FS 476#ifdef CONFIG_LPFC_DEBUG_FS
230 struct lpfc_disc_trc *dtp; 477 struct lpfc_debugfs_trc *dtp;
231 int index; 478 int index;
232 479
233 if (!(lpfc_debugfs_mask_disc_trc & mask)) 480 if (!(lpfc_debugfs_mask_disc_trc & mask))
@@ -244,7 +491,32 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
244 dtp->data1 = data1; 491 dtp->data1 = data1;
245 dtp->data2 = data2; 492 dtp->data2 = data2;
246 dtp->data3 = data3; 493 dtp->data3 = data3;
247 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_disc_trc_cnt); 494 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
495 dtp->jif = jiffies;
496#endif
497 return;
498}
499
500inline void
501lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
502 uint32_t data1, uint32_t data2, uint32_t data3)
503{
504#ifdef CONFIG_LPFC_DEBUG_FS
505 struct lpfc_debugfs_trc *dtp;
506 int index;
507
508 if (!lpfc_debugfs_enable || !lpfc_debugfs_max_slow_ring_trc ||
509 !phba || !phba->slow_ring_trc)
510 return;
511
512 index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
513 (lpfc_debugfs_max_slow_ring_trc - 1);
514 dtp = phba->slow_ring_trc + index;
515 dtp->fmt = fmt;
516 dtp->data1 = data1;
517 dtp->data2 = data2;
518 dtp->data3 = data3;
519 dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
248 dtp->jif = jiffies; 520 dtp->jif = jiffies;
249#endif 521#endif
250 return; 522 return;
@@ -269,7 +541,7 @@ lpfc_debugfs_disc_trc_open(struct inode *inode, struct file *file)
269 goto out; 541 goto out;
270 542
271 /* Round to page boundry */ 543 /* Round to page boundry */
272 size = (lpfc_debugfs_max_disc_trc * LPFC_DISC_TRC_ENTRY_SIZE); 544 size = (lpfc_debugfs_max_disc_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
273 size = PAGE_ALIGN(size); 545 size = PAGE_ALIGN(size);
274 546
275 debug->buffer = kmalloc(size, GFP_KERNEL); 547 debug->buffer = kmalloc(size, GFP_KERNEL);
@@ -287,6 +559,95 @@ out:
287} 559}
288 560
289static int 561static int
562lpfc_debugfs_slow_ring_trc_open(struct inode *inode, struct file *file)
563{
564 struct lpfc_hba *phba = inode->i_private;
565 struct lpfc_debug *debug;
566 int size;
567 int rc = -ENOMEM;
568
569 if (!lpfc_debugfs_max_slow_ring_trc) {
570 rc = -ENOSPC;
571 goto out;
572 }
573
574 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
575 if (!debug)
576 goto out;
577
578 /* Round to page boundry */
579 size = (lpfc_debugfs_max_slow_ring_trc * LPFC_DEBUG_TRC_ENTRY_SIZE);
580 size = PAGE_ALIGN(size);
581
582 debug->buffer = kmalloc(size, GFP_KERNEL);
583 if (!debug->buffer) {
584 kfree(debug);
585 goto out;
586 }
587
588 debug->len = lpfc_debugfs_slow_ring_trc_data(phba, debug->buffer, size);
589 file->private_data = debug;
590
591 rc = 0;
592out:
593 return rc;
594}
595
596static int
597lpfc_debugfs_hbqinfo_open(struct inode *inode, struct file *file)
598{
599 struct lpfc_hba *phba = inode->i_private;
600 struct lpfc_debug *debug;
601 int rc = -ENOMEM;
602
603 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
604 if (!debug)
605 goto out;
606
607 /* Round to page boundry */
608 debug->buffer = kmalloc(LPFC_HBQINFO_SIZE, GFP_KERNEL);
609 if (!debug->buffer) {
610 kfree(debug);
611 goto out;
612 }
613
614 debug->len = lpfc_debugfs_hbqinfo_data(phba, debug->buffer,
615 LPFC_HBQINFO_SIZE);
616 file->private_data = debug;
617
618 rc = 0;
619out:
620 return rc;
621}
622
623static int
624lpfc_debugfs_dumpslim_open(struct inode *inode, struct file *file)
625{
626 struct lpfc_hba *phba = inode->i_private;
627 struct lpfc_debug *debug;
628 int rc = -ENOMEM;
629
630 debug = kmalloc(sizeof(*debug), GFP_KERNEL);
631 if (!debug)
632 goto out;
633
634 /* Round to page boundry */
635 debug->buffer = kmalloc(LPFC_DUMPSLIM_SIZE, GFP_KERNEL);
636 if (!debug->buffer) {
637 kfree(debug);
638 goto out;
639 }
640
641 debug->len = lpfc_debugfs_dumpslim_data(phba, debug->buffer,
642 LPFC_DUMPSLIM_SIZE);
643 file->private_data = debug;
644
645 rc = 0;
646out:
647 return rc;
648}
649
650static int
290lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file) 651lpfc_debugfs_nodelist_open(struct inode *inode, struct file *file)
291{ 652{
292 struct lpfc_vport *vport = inode->i_private; 653 struct lpfc_vport *vport = inode->i_private;
@@ -372,6 +733,33 @@ static struct file_operations lpfc_debugfs_op_nodelist = {
372 .release = lpfc_debugfs_release, 733 .release = lpfc_debugfs_release,
373}; 734};
374 735
736#undef lpfc_debugfs_op_hbqinfo
737static struct file_operations lpfc_debugfs_op_hbqinfo = {
738 .owner = THIS_MODULE,
739 .open = lpfc_debugfs_hbqinfo_open,
740 .llseek = lpfc_debugfs_lseek,
741 .read = lpfc_debugfs_read,
742 .release = lpfc_debugfs_release,
743};
744
745#undef lpfc_debugfs_op_dumpslim
746static struct file_operations lpfc_debugfs_op_dumpslim = {
747 .owner = THIS_MODULE,
748 .open = lpfc_debugfs_dumpslim_open,
749 .llseek = lpfc_debugfs_lseek,
750 .read = lpfc_debugfs_read,
751 .release = lpfc_debugfs_release,
752};
753
754#undef lpfc_debugfs_op_slow_ring_trc
755static struct file_operations lpfc_debugfs_op_slow_ring_trc = {
756 .owner = THIS_MODULE,
757 .open = lpfc_debugfs_slow_ring_trc_open,
758 .llseek = lpfc_debugfs_lseek,
759 .read = lpfc_debugfs_read,
760 .release = lpfc_debugfs_release,
761};
762
375static struct dentry *lpfc_debugfs_root = NULL; 763static struct dentry *lpfc_debugfs_root = NULL;
376static atomic_t lpfc_debugfs_hba_count; 764static atomic_t lpfc_debugfs_hba_count;
377#endif 765#endif
@@ -387,60 +775,146 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
387 if (!lpfc_debugfs_enable) 775 if (!lpfc_debugfs_enable)
388 return; 776 return;
389 777
390 if (lpfc_debugfs_max_disc_trc) { 778 /* Setup lpfc root directory */
391 num = lpfc_debugfs_max_disc_trc - 1;
392 if (num & lpfc_debugfs_max_disc_trc) {
393 /* Change to be a power of 2 */
394 num = lpfc_debugfs_max_disc_trc;
395 i = 0;
396 while (num > 1) {
397 num = num >> 1;
398 i++;
399 }
400 lpfc_debugfs_max_disc_trc = (1 << i);
401 printk(KERN_ERR
402 "lpfc_debugfs_max_disc_trc changed to %d\n",
403 lpfc_debugfs_max_disc_trc);
404 }
405 }
406
407 if (!lpfc_debugfs_root) { 779 if (!lpfc_debugfs_root) {
408 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); 780 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
409 atomic_set(&lpfc_debugfs_hba_count, 0); 781 atomic_set(&lpfc_debugfs_hba_count, 0);
410 if (!lpfc_debugfs_root) 782 if (!lpfc_debugfs_root) {
783 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
784 "0409 Cannot create debugfs root\n");
411 goto debug_failed; 785 goto debug_failed;
786 }
412 } 787 }
788 if (!lpfc_debugfs_start_time)
789 lpfc_debugfs_start_time = jiffies;
413 790
791 /* Setup lpfcX directory for specific HBA */
414 snprintf(name, sizeof(name), "lpfc%d", phba->brd_no); 792 snprintf(name, sizeof(name), "lpfc%d", phba->brd_no);
415 if (!phba->hba_debugfs_root) { 793 if (!phba->hba_debugfs_root) {
416 phba->hba_debugfs_root = 794 phba->hba_debugfs_root =
417 debugfs_create_dir(name, lpfc_debugfs_root); 795 debugfs_create_dir(name, lpfc_debugfs_root);
418 if (!phba->hba_debugfs_root) 796 if (!phba->hba_debugfs_root) {
797 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
798 "0409 Cannot create debugfs hba\n");
419 goto debug_failed; 799 goto debug_failed;
800 }
420 atomic_inc(&lpfc_debugfs_hba_count); 801 atomic_inc(&lpfc_debugfs_hba_count);
421 atomic_set(&phba->debugfs_vport_count, 0); 802 atomic_set(&phba->debugfs_vport_count, 0);
803
804 /* Setup hbqinfo */
805 snprintf(name, sizeof(name), "hbqinfo");
806 phba->debug_hbqinfo =
807 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
808 phba->hba_debugfs_root,
809 phba, &lpfc_debugfs_op_hbqinfo);
810 if (!phba->debug_hbqinfo) {
811 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
812 "0409 Cannot create debugfs hbqinfo\n");
813 goto debug_failed;
814 }
815
816 /* Setup dumpslim */
817 snprintf(name, sizeof(name), "dumpslim");
818 phba->debug_dumpslim =
819 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
820 phba->hba_debugfs_root,
821 phba, &lpfc_debugfs_op_dumpslim);
822 if (!phba->debug_dumpslim) {
823 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
824 "0409 Cannot create debugfs dumpslim\n");
825 goto debug_failed;
826 }
827
828 /* Setup slow ring trace */
829 if (lpfc_debugfs_max_slow_ring_trc) {
830 num = lpfc_debugfs_max_slow_ring_trc - 1;
831 if (num & lpfc_debugfs_max_slow_ring_trc) {
832 /* Change to be a power of 2 */
833 num = lpfc_debugfs_max_slow_ring_trc;
834 i = 0;
835 while (num > 1) {
836 num = num >> 1;
837 i++;
838 }
839 lpfc_debugfs_max_slow_ring_trc = (1 << i);
840 printk(KERN_ERR
841 "lpfc_debugfs_max_disc_trc changed to "
842 "%d\n", lpfc_debugfs_max_disc_trc);
843 }
844 }
845
846
847 snprintf(name, sizeof(name), "slow_ring_trace");
848 phba->debug_slow_ring_trc =
849 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
850 phba->hba_debugfs_root,
851 phba, &lpfc_debugfs_op_slow_ring_trc);
852 if (!phba->debug_slow_ring_trc) {
853 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
854 "0409 Cannot create debugfs "
855 "slow_ring_trace\n");
856 goto debug_failed;
857 }
858 if (!phba->slow_ring_trc) {
859 phba->slow_ring_trc = kmalloc(
860 (sizeof(struct lpfc_debugfs_trc) *
861 lpfc_debugfs_max_slow_ring_trc),
862 GFP_KERNEL);
863 if (!phba->slow_ring_trc) {
864 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
865 "0409 Cannot create debugfs "
866 "slow_ring buffer\n");
867 goto debug_failed;
868 }
869 atomic_set(&phba->slow_ring_trc_cnt, 0);
870 memset(phba->slow_ring_trc, 0,
871 (sizeof(struct lpfc_debugfs_trc) *
872 lpfc_debugfs_max_slow_ring_trc));
873 }
422 } 874 }
423 875
424 snprintf(name, sizeof(name), "vport%d", vport->vpi); 876 snprintf(name, sizeof(name), "vport%d", vport->vpi);
425 if (!vport->vport_debugfs_root) { 877 if (!vport->vport_debugfs_root) {
426 vport->vport_debugfs_root = 878 vport->vport_debugfs_root =
427 debugfs_create_dir(name, phba->hba_debugfs_root); 879 debugfs_create_dir(name, phba->hba_debugfs_root);
428 if (!vport->vport_debugfs_root) 880 if (!vport->vport_debugfs_root) {
881 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
882 "0409 Cant create debugfs");
429 goto debug_failed; 883 goto debug_failed;
884 }
430 atomic_inc(&phba->debugfs_vport_count); 885 atomic_inc(&phba->debugfs_vport_count);
431 } 886 }
432 887
433 if (!lpfc_debugfs_start_time) 888 if (lpfc_debugfs_max_disc_trc) {
434 lpfc_debugfs_start_time = jiffies; 889 num = lpfc_debugfs_max_disc_trc - 1;
890 if (num & lpfc_debugfs_max_disc_trc) {
891 /* Change to be a power of 2 */
892 num = lpfc_debugfs_max_disc_trc;
893 i = 0;
894 while (num > 1) {
895 num = num >> 1;
896 i++;
897 }
898 lpfc_debugfs_max_disc_trc = (1 << i);
899 printk(KERN_ERR
900 "lpfc_debugfs_max_disc_trc changed to %d\n",
901 lpfc_debugfs_max_disc_trc);
902 }
903 }
435 904
436 vport->disc_trc = kmalloc( 905 vport->disc_trc = kmalloc(
437 (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc), 906 (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc),
438 GFP_KERNEL); 907 GFP_KERNEL);
439 908
440 if (!vport->disc_trc) 909 if (!vport->disc_trc) {
910 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
911 "0409 Cannot create debugfs disc trace "
912 "buffer\n");
441 goto debug_failed; 913 goto debug_failed;
914 }
915 atomic_set(&vport->disc_trc_cnt, 0);
442 memset(vport->disc_trc, 0, 916 memset(vport->disc_trc, 0,
443 (sizeof(struct lpfc_disc_trc) * lpfc_debugfs_max_disc_trc)); 917 (sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_disc_trc));
444 918
445 snprintf(name, sizeof(name), "discovery_trace"); 919 snprintf(name, sizeof(name), "discovery_trace");
446 vport->debug_disc_trc = 920 vport->debug_disc_trc =
@@ -448,9 +922,9 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
448 vport->vport_debugfs_root, 922 vport->vport_debugfs_root,
449 vport, &lpfc_debugfs_op_disc_trc); 923 vport, &lpfc_debugfs_op_disc_trc);
450 if (!vport->debug_disc_trc) { 924 if (!vport->debug_disc_trc) {
451 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 925 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
452 "%d:0409 Cannot create debugfs", 926 "0409 Cannot create debugfs "
453 phba->brd_no); 927 "discovery_trace\n");
454 goto debug_failed; 928 goto debug_failed;
455 } 929 }
456 snprintf(name, sizeof(name), "nodelist"); 930 snprintf(name, sizeof(name), "nodelist");
@@ -459,9 +933,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
459 vport->vport_debugfs_root, 933 vport->vport_debugfs_root,
460 vport, &lpfc_debugfs_op_nodelist); 934 vport, &lpfc_debugfs_op_nodelist);
461 if (!vport->debug_nodelist) { 935 if (!vport->debug_nodelist) {
462 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 936 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
463 "%d:0409 Cannot create debugfs", 937 "0409 Cant create debugfs nodelist");
464 phba->brd_no);
465 goto debug_failed; 938 goto debug_failed;
466 } 939 }
467debug_failed: 940debug_failed:
@@ -488,21 +961,45 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
488 debugfs_remove(vport->debug_nodelist); /* nodelist */ 961 debugfs_remove(vport->debug_nodelist); /* nodelist */
489 vport->debug_nodelist = NULL; 962 vport->debug_nodelist = NULL;
490 } 963 }
964
491 if (vport->vport_debugfs_root) { 965 if (vport->vport_debugfs_root) {
492 debugfs_remove(vport->vport_debugfs_root); /* vportX */ 966 debugfs_remove(vport->vport_debugfs_root); /* vportX */
493 vport->vport_debugfs_root = NULL; 967 vport->vport_debugfs_root = NULL;
494 atomic_dec(&phba->debugfs_vport_count); 968 atomic_dec(&phba->debugfs_vport_count);
495 } 969 }
496 if (atomic_read(&phba->debugfs_vport_count) == 0) { 970 if (atomic_read(&phba->debugfs_vport_count) == 0) {
497 debugfs_remove(vport->phba->hba_debugfs_root); /* lpfcX */ 971
498 vport->phba->hba_debugfs_root = NULL; 972 if (phba->debug_hbqinfo) {
499 atomic_dec(&lpfc_debugfs_hba_count); 973 debugfs_remove(phba->debug_hbqinfo); /* hbqinfo */
974 phba->debug_hbqinfo = NULL;
975 }
976 if (phba->debug_dumpslim) {
977 debugfs_remove(phba->debug_dumpslim); /* dumpslim */
978 phba->debug_dumpslim = NULL;
979 }
980 if (phba->slow_ring_trc) {
981 kfree(phba->slow_ring_trc);
982 phba->slow_ring_trc = NULL;
983 }
984 if (phba->debug_slow_ring_trc) {
985 /* slow_ring_trace */
986 debugfs_remove(phba->debug_slow_ring_trc);
987 phba->debug_slow_ring_trc = NULL;
988 }
989
990 if (phba->hba_debugfs_root) {
991 debugfs_remove(phba->hba_debugfs_root); /* lpfcX */
992 phba->hba_debugfs_root = NULL;
993 atomic_dec(&lpfc_debugfs_hba_count);
994 }
995
500 if (atomic_read(&lpfc_debugfs_hba_count) == 0) { 996 if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
501 debugfs_remove(lpfc_debugfs_root); /* lpfc */ 997 debugfs_remove(lpfc_debugfs_root); /* lpfc */
502 lpfc_debugfs_root = NULL; 998 lpfc_debugfs_root = NULL;
503 } 999 }
504 } 1000 }
505#endif 1001#endif
1002 return;
506} 1003}
507 1004
508 1005
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
index fffb678426a4..31e86a55391d 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.h
+++ b/drivers/scsi/lpfc/lpfc_debugfs.h
@@ -22,7 +22,7 @@
22#define _H_LPFC_DEBUG_FS 22#define _H_LPFC_DEBUG_FS
23 23
24#ifdef CONFIG_LPFC_DEBUG_FS 24#ifdef CONFIG_LPFC_DEBUG_FS
25struct lpfc_disc_trc { 25struct lpfc_debugfs_trc {
26 char *fmt; 26 char *fmt;
27 uint32_t data1; 27 uint32_t data1;
28 uint32_t data2; 28 uint32_t data2;
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 33fbc1666946..8085900635d4 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -63,10 +63,10 @@ lpfc_els_chk_latt(struct lpfc_vport *vport)
63 return 0; 63 return 0;
64 64
65 /* Pending Link Event during Discovery */ 65 /* Pending Link Event during Discovery */
66 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 66 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
67 "%d (%d):0237 Pending Link Event during " 67 "0237 Pending Link Event during "
68 "Discovery: State x%x\n", 68 "Discovery: State x%x\n",
69 phba->brd_no, vport->vpi, phba->pport->port_state); 69 phba->pport->port_state);
70 70
71 /* CLEAR_LA should re-enable link attention events and 71 /* CLEAR_LA should re-enable link attention events and
72 * we should then imediately take a LATT event. The 72 * we should then imediately take a LATT event. The
@@ -196,9 +196,7 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
196 bpl->tus.w = le32_to_cpu(bpl->tus.w); 196 bpl->tus.w = le32_to_cpu(bpl->tus.w);
197 } 197 }
198 198
199 /* Save for completion so we can release these resources */ 199 elsiocb->context1 = lpfc_nlp_get(ndlp);
200 if (elscmd != ELS_CMD_LS_RJT)
201 elsiocb->context1 = lpfc_nlp_get(ndlp);
202 elsiocb->context2 = pcmd; 200 elsiocb->context2 = pcmd;
203 elsiocb->context3 = pbuflist; 201 elsiocb->context3 = pbuflist;
204 elsiocb->retry = retry; 202 elsiocb->retry = retry;
@@ -208,23 +206,21 @@ lpfc_prep_els_iocb(struct lpfc_vport *vport, uint8_t expectRsp,
208 if (prsp) { 206 if (prsp) {
209 list_add(&prsp->list, &pcmd->list); 207 list_add(&prsp->list, &pcmd->list);
210 } 208 }
211
212 if (expectRsp) { 209 if (expectRsp) {
213 /* Xmit ELS command <elsCmd> to remote NPORT <did> */ 210 /* Xmit ELS command <elsCmd> to remote NPORT <did> */
214 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 211 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
215 "%d (%d):0116 Xmit ELS command x%x to remote " 212 "0116 Xmit ELS command x%x to remote "
216 "NPORT x%x I/O tag: x%x, port state: x%x\n", 213 "NPORT x%x I/O tag: x%x, port state: x%x\n",
217 phba->brd_no, vport->vpi, elscmd, did, 214 elscmd, did, elsiocb->iotag,
218 elsiocb->iotag, vport->port_state); 215 vport->port_state);
219 } else { 216 } else {
220 /* Xmit ELS response <elsCmd> to remote NPORT <did> */ 217 /* Xmit ELS response <elsCmd> to remote NPORT <did> */
221 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 218 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
222 "%d (%d):0117 Xmit ELS response x%x to remote " 219 "0117 Xmit ELS response x%x to remote "
223 "NPORT x%x I/O tag: x%x, size: x%x\n", 220 "NPORT x%x I/O tag: x%x, size: x%x\n",
224 phba->brd_no, vport->vpi, elscmd, 221 elscmd, ndlp->nlp_DID, elsiocb->iotag,
225 ndlp->nlp_DID, elsiocb->iotag, cmdSize); 222 cmdSize);
226 } 223 }
227
228 return elsiocb; 224 return elsiocb;
229} 225}
230 226
@@ -285,9 +281,8 @@ fail_free_mbox:
285 281
286fail: 282fail:
287 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 283 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
288 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 284 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
289 "%d (%d):0249 Cannot issue Register Fabric login\n", 285 "0249 Cannot issue Register Fabric login\n");
290 phba->brd_no, vport->vpi);
291 return -ENXIO; 286 return -ENXIO;
292} 287}
293 288
@@ -340,20 +335,19 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
340 335
341 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { 336 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) {
342 if (sp->cmn.response_multiple_NPort) { 337 if (sp->cmn.response_multiple_NPort) {
343 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_VPORT, 338 lpfc_printf_vlog(vport, KERN_WARNING,
344 "%d:1816 FLOGI NPIV supported, " 339 LOG_ELS | LOG_VPORT,
345 "response data 0x%x\n", 340 "1816 FLOGI NPIV supported, "
346 phba->brd_no, 341 "response data 0x%x\n",
347 sp->cmn.response_multiple_NPort); 342 sp->cmn.response_multiple_NPort);
348 phba->link_flag |= LS_NPIV_FAB_SUPPORTED; 343 phba->link_flag |= LS_NPIV_FAB_SUPPORTED;
349
350 } else { 344 } else {
351 /* Because we asked f/w for NPIV it still expects us 345 /* Because we asked f/w for NPIV it still expects us
352 to call reg_vnpid atleast for the physcial host */ 346 to call reg_vnpid atleast for the physcial host */
353 lpfc_printf_log(phba, KERN_WARNING, LOG_ELS | LOG_VPORT, 347 lpfc_printf_vlog(vport, KERN_WARNING,
354 "%d:1817 Fabric does not support NPIV " 348 LOG_ELS | LOG_VPORT,
355 "- configuring single port mode.\n", 349 "1817 Fabric does not support NPIV "
356 phba->brd_no); 350 "- configuring single port mode.\n");
357 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED; 351 phba->link_flag &= ~LS_NPIV_FAB_SUPPORTED;
358 } 352 }
359 } 353 }
@@ -518,16 +512,15 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
518 * alpa map would take too long otherwise. 512 * alpa map would take too long otherwise.
519 */ 513 */
520 if (phba->alpa_map[0] == 0) { 514 if (phba->alpa_map[0] == 0) {
521 phba->cfg_discovery_threads = LPFC_MAX_DISC_THREADS; 515 vport->cfg_discovery_threads = LPFC_MAX_DISC_THREADS;
522 } 516 }
523 517
524 /* FLOGI failure */ 518 /* FLOGI failure */
525 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 519 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
526 "%d (%d):0100 FLOGI failure Data: x%x x%x " 520 "0100 FLOGI failure Data: x%x x%x "
527 "x%x\n", 521 "x%x\n",
528 phba->brd_no, vport->vpi, 522 irsp->ulpStatus, irsp->un.ulpWord[4],
529 irsp->ulpStatus, irsp->un.ulpWord[4], 523 irsp->ulpTimeout);
530 irsp->ulpTimeout);
531 goto flogifail; 524 goto flogifail;
532 } 525 }
533 526
@@ -540,12 +533,11 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
540 sp = prsp->virt + sizeof(uint32_t); 533 sp = prsp->virt + sizeof(uint32_t);
541 534
542 /* FLOGI completes successfully */ 535 /* FLOGI completes successfully */
543 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 536 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
544 "%d (%d):0101 FLOGI completes sucessfully " 537 "0101 FLOGI completes sucessfully "
545 "Data: x%x x%x x%x x%x\n", 538 "Data: x%x x%x x%x x%x\n",
546 phba->brd_no, vport->vpi, 539 irsp->un.ulpWord[4], sp->cmn.e_d_tov,
547 irsp->un.ulpWord[4], sp->cmn.e_d_tov, 540 sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution);
548 sp->cmn.w2.r_a_tov, sp->cmn.edtovResolution);
549 541
550 if (vport->port_state == LPFC_FLOGI) { 542 if (vport->port_state == LPFC_FLOGI) {
551 /* 543 /*
@@ -662,8 +654,8 @@ lpfc_els_abort_flogi(struct lpfc_hba *phba)
662 654
663 /* Abort outstanding I/O on NPort <nlp_DID> */ 655 /* Abort outstanding I/O on NPort <nlp_DID> */
664 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 656 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
665 "%d:0201 Abort outstanding I/O on NPort x%x\n", 657 "0201 Abort outstanding I/O on NPort x%x\n",
666 phba->brd_no, Fabric_DID); 658 Fabric_DID);
667 659
668 pring = &phba->sli.ring[LPFC_ELS_RING]; 660 pring = &phba->sli.ring[LPFC_ELS_RING];
669 661
@@ -736,18 +728,16 @@ static void
736lpfc_more_plogi(struct lpfc_vport *vport) 728lpfc_more_plogi(struct lpfc_vport *vport)
737{ 729{
738 int sentplogi; 730 int sentplogi;
739 struct lpfc_hba *phba = vport->phba;
740 731
741 if (vport->num_disc_nodes) 732 if (vport->num_disc_nodes)
742 vport->num_disc_nodes--; 733 vport->num_disc_nodes--;
743 734
744 /* Continue discovery with <num_disc_nodes> PLOGIs to go */ 735 /* Continue discovery with <num_disc_nodes> PLOGIs to go */
745 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 736 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
746 "%d (%d):0232 Continue discovery with %d PLOGIs to go " 737 "0232 Continue discovery with %d PLOGIs to go "
747 "Data: x%x x%x x%x\n", 738 "Data: x%x x%x x%x\n",
748 phba->brd_no, vport->vpi, vport->num_disc_nodes, 739 vport->num_disc_nodes, vport->fc_plogi_cnt,
749 vport->fc_plogi_cnt, vport->fc_flag, vport->port_state); 740 vport->fc_flag, vport->port_state);
750
751 /* Check to see if there are more PLOGIs to be sent */ 741 /* Check to see if there are more PLOGIs to be sent */
752 if (vport->fc_flag & FC_NLP_MORE) 742 if (vport->fc_flag & FC_NLP_MORE)
753 /* go thru NPR nodes and issue any remaining ELS PLOGIs */ 743 /* go thru NPR nodes and issue any remaining ELS PLOGIs */
@@ -833,11 +823,12 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
833 823
834 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID); 824 ndlp = lpfc_findnode_did(vport, irsp->un.elsreq64.remoteID);
835 if (!ndlp) { 825 if (!ndlp) {
836 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 826 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
837 "%d (%d):0136 PLOGI completes to NPort x%x " 827 "0136 PLOGI completes to NPort x%x "
838 "with no ndlp. Data: x%x x%x x%x\n", 828 "with no ndlp. Data: x%x x%x x%x\n",
839 phba->brd_no, vport->vpi, irsp->un.elsreq64.remoteID, 829 irsp->un.elsreq64.remoteID,
840 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpIoTag); 830 irsp->ulpStatus, irsp->un.ulpWord[4],
831 irsp->ulpIoTag);
841 goto out; 832 goto out;
842 } 833 }
843 834
@@ -851,13 +842,11 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
851 rc = 0; 842 rc = 0;
852 843
853 /* PLOGI completes to NPort <nlp_DID> */ 844 /* PLOGI completes to NPort <nlp_DID> */
854 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 845 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
855 "%d (%d):0102 PLOGI completes to NPort x%x " 846 "0102 PLOGI completes to NPort x%x "
856 "Data: x%x x%x x%x x%x x%x\n", 847 "Data: x%x x%x x%x x%x x%x\n",
857 phba->brd_no, vport->vpi, ndlp->nlp_DID, 848 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
858 irsp->ulpStatus, irsp->un.ulpWord[4], 849 irsp->ulpTimeout, disc, vport->num_disc_nodes);
859 irsp->ulpTimeout, disc, vport->num_disc_nodes);
860
861 /* Check to see if link went down during discovery */ 850 /* Check to see if link went down during discovery */
862 if (lpfc_els_chk_latt(vport)) { 851 if (lpfc_els_chk_latt(vport)) {
863 spin_lock_irq(shost->host_lock); 852 spin_lock_irq(shost->host_lock);
@@ -881,17 +870,14 @@ lpfc_cmpl_els_plogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
881 } 870 }
882 goto out; 871 goto out;
883 } 872 }
884
885 /* PLOGI failed */ 873 /* PLOGI failed */
886 if (ndlp->nlp_DID == NameServer_DID) { 874 if (ndlp->nlp_DID == NameServer_DID) {
887 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 875 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
888 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 876 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
889 "%d (%d):0250 Nameserver login error: " 877 "0250 Nameserver login error: "
890 "0x%x / 0x%x\n", 878 "0x%x / 0x%x\n",
891 phba->brd_no, vport->vpi, 879 irsp->ulpStatus, irsp->un.ulpWord[4]);
892 irsp->ulpStatus, irsp->un.ulpWord[4]);
893 } 880 }
894
895 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 881 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
896 if (lpfc_error_lost_link(irsp)) { 882 if (lpfc_error_lost_link(irsp)) {
897 rc = NLP_STE_FREED_NODE; 883 rc = NLP_STE_FREED_NODE;
@@ -1017,14 +1003,12 @@ lpfc_cmpl_els_prli(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1017 "PRLI cmpl: status:x%x/x%x did:x%x", 1003 "PRLI cmpl: status:x%x/x%x did:x%x",
1018 irsp->ulpStatus, irsp->un.ulpWord[4], 1004 irsp->ulpStatus, irsp->un.ulpWord[4],
1019 ndlp->nlp_DID); 1005 ndlp->nlp_DID);
1020
1021 /* PRLI completes to NPort <nlp_DID> */ 1006 /* PRLI completes to NPort <nlp_DID> */
1022 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1007 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1023 "%d (%d):0103 PRLI completes to NPort x%x " 1008 "0103 PRLI completes to NPort x%x "
1024 "Data: x%x x%x x%x x%x\n", 1009 "Data: x%x x%x x%x x%x\n",
1025 phba->brd_no, vport->vpi, ndlp->nlp_DID, 1010 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
1026 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout, 1011 irsp->ulpTimeout, vport->num_disc_nodes);
1027 vport->num_disc_nodes);
1028 1012
1029 vport->fc_prli_sent--; 1013 vport->fc_prli_sent--;
1030 /* Check to see if link went down during discovery */ 1014 /* Check to see if link went down during discovery */
@@ -1129,18 +1113,15 @@ static void
1129lpfc_more_adisc(struct lpfc_vport *vport) 1113lpfc_more_adisc(struct lpfc_vport *vport)
1130{ 1114{
1131 int sentadisc; 1115 int sentadisc;
1132 struct lpfc_hba *phba = vport->phba;
1133 1116
1134 if (vport->num_disc_nodes) 1117 if (vport->num_disc_nodes)
1135 vport->num_disc_nodes--; 1118 vport->num_disc_nodes--;
1136
1137 /* Continue discovery with <num_disc_nodes> ADISCs to go */ 1119 /* Continue discovery with <num_disc_nodes> ADISCs to go */
1138 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1120 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1139 "%d (%d):0210 Continue discovery with %d ADISCs to go " 1121 "0210 Continue discovery with %d ADISCs to go "
1140 "Data: x%x x%x x%x\n", 1122 "Data: x%x x%x x%x\n",
1141 phba->brd_no, vport->vpi, vport->num_disc_nodes, 1123 vport->num_disc_nodes, vport->fc_adisc_cnt,
1142 vport->fc_adisc_cnt, vport->fc_flag, vport->port_state); 1124 vport->fc_flag, vport->port_state);
1143
1144 /* Check to see if there are more ADISCs to be sent */ 1125 /* Check to see if there are more ADISCs to be sent */
1145 if (vport->fc_flag & FC_NLP_MORE) { 1126 if (vport->fc_flag & FC_NLP_MORE) {
1146 lpfc_set_disctmo(vport); 1127 lpfc_set_disctmo(vport);
@@ -1206,15 +1187,12 @@ lpfc_cmpl_els_adisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1206 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 1187 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
1207 ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC); 1188 ndlp->nlp_flag &= ~(NLP_ADISC_SND | NLP_NPR_2B_DISC);
1208 spin_unlock_irq(shost->host_lock); 1189 spin_unlock_irq(shost->host_lock);
1209
1210 /* ADISC completes to NPort <nlp_DID> */ 1190 /* ADISC completes to NPort <nlp_DID> */
1211 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1191 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1212 "%d (%d):0104 ADISC completes to NPort x%x " 1192 "0104 ADISC completes to NPort x%x "
1213 "Data: x%x x%x x%x x%x x%x\n", 1193 "Data: x%x x%x x%x x%x x%x\n",
1214 phba->brd_no, vport->vpi, ndlp->nlp_DID, 1194 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
1215 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout, 1195 irsp->ulpTimeout, disc, vport->num_disc_nodes);
1216 disc, vport->num_disc_nodes);
1217
1218 /* Check to see if link went down during discovery */ 1196 /* Check to see if link went down during discovery */
1219 if (lpfc_els_chk_latt(vport)) { 1197 if (lpfc_els_chk_latt(vport)) {
1220 spin_lock_irq(shost->host_lock); 1198 spin_lock_irq(shost->host_lock);
@@ -1374,15 +1352,12 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1374 "LOGO cmpl: status:x%x/x%x did:x%x", 1352 "LOGO cmpl: status:x%x/x%x did:x%x",
1375 irsp->ulpStatus, irsp->un.ulpWord[4], 1353 irsp->ulpStatus, irsp->un.ulpWord[4],
1376 ndlp->nlp_DID); 1354 ndlp->nlp_DID);
1377
1378 /* LOGO completes to NPort <nlp_DID> */ 1355 /* LOGO completes to NPort <nlp_DID> */
1379 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1356 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1380 "%d (%d):0105 LOGO completes to NPort x%x " 1357 "0105 LOGO completes to NPort x%x "
1381 "Data: x%x x%x x%x x%x\n", 1358 "Data: x%x x%x x%x x%x\n",
1382 phba->brd_no, vport->vpi, ndlp->nlp_DID, 1359 ndlp->nlp_DID, irsp->ulpStatus, irsp->un.ulpWord[4],
1383 irsp->ulpStatus, irsp->un.ulpWord[4], irsp->ulpTimeout, 1360 irsp->ulpTimeout, vport->num_disc_nodes);
1384 vport->num_disc_nodes);
1385
1386 /* Check to see if link went down during discovery */ 1361 /* Check to see if link went down during discovery */
1387 if (lpfc_els_chk_latt(vport)) 1362 if (lpfc_els_chk_latt(vport))
1388 goto out; 1363 goto out;
@@ -1488,15 +1463,11 @@ lpfc_cmpl_els_cmd(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1488 "ELS cmd cmpl: status:x%x/x%x did:x%x", 1463 "ELS cmd cmpl: status:x%x/x%x did:x%x",
1489 irsp->ulpStatus, irsp->un.ulpWord[4], 1464 irsp->ulpStatus, irsp->un.ulpWord[4],
1490 irsp->un.elsreq64.remoteID); 1465 irsp->un.elsreq64.remoteID);
1491
1492 /* ELS cmd tag <ulpIoTag> completes */ 1466 /* ELS cmd tag <ulpIoTag> completes */
1493 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1467 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1494 "%d (%d):0106 ELS cmd tag x%x completes Data: x%x x%x " 1468 "0106 ELS cmd tag x%x completes Data: x%x x%x x%x\n",
1495 "x%x\n", 1469 irsp->ulpIoTag, irsp->ulpStatus,
1496 phba->brd_no, vport->vpi, 1470 irsp->un.ulpWord[4], irsp->ulpTimeout);
1497 irsp->ulpIoTag, irsp->ulpStatus,
1498 irsp->un.ulpWord[4], irsp->ulpTimeout);
1499
1500 /* Check to see if link went down during discovery */ 1471 /* Check to see if link went down during discovery */
1501 lpfc_els_chk_latt(vport); 1472 lpfc_els_chk_latt(vport);
1502 lpfc_els_free_iocb(phba, cmdiocb); 1473 lpfc_els_free_iocb(phba, cmdiocb);
@@ -1831,13 +1802,15 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1831 case IOERR_ILLEGAL_COMMAND: 1802 case IOERR_ILLEGAL_COMMAND:
1832 if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) && 1803 if ((phba->sli3_options & LPFC_SLI3_VPORT_TEARDOWN) &&
1833 (cmd == ELS_CMD_FDISC)) { 1804 (cmd == ELS_CMD_FDISC)) {
1834 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1805 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1835 "%d (%d):0124 FDISC failed (3/6) retrying...\n", 1806 "0124 FDISC failed (3/6) "
1836 phba->brd_no, vport->vpi); 1807 "retrying...\n");
1837 lpfc_mbx_unreg_vpi(vport); 1808 lpfc_mbx_unreg_vpi(vport);
1838 retry = 1; 1809 retry = 1;
1839 /* Always retry for this case */ 1810 /* FDISC retry policy */
1840 cmdiocb->retry = 0; 1811 maxretry = 48;
1812 if (cmdiocb->retry >= 32)
1813 delay = 1000;
1841 } 1814 }
1842 break; 1815 break;
1843 1816
@@ -1898,10 +1871,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1898 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && 1871 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
1899 (cmd == ELS_CMD_FDISC) && 1872 (cmd == ELS_CMD_FDISC) &&
1900 (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){ 1873 (stat.un.b.lsRjtRsnCodeExp == LSEXP_OUT_OF_RESOURCE)){
1901 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1874 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1902 "%d (%d):0125 FDISC Failed (x%x)." 1875 "0125 FDISC Failed (x%x). "
1903 " Fabric out of resources\n", 1876 "Fabric out of resources\n",
1904 phba->brd_no, vport->vpi, stat.un.lsRjtError); 1877 stat.un.lsRjtError);
1905 lpfc_vport_set_state(vport, 1878 lpfc_vport_set_state(vport,
1906 FC_VPORT_NO_FABRIC_RSCS); 1879 FC_VPORT_NO_FABRIC_RSCS);
1907 } 1880 }
@@ -1913,8 +1886,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1913 delay = 1000; 1886 delay = 1000;
1914 maxretry = 48; 1887 maxretry = 48;
1915 } else if (cmd == ELS_CMD_FDISC) { 1888 } else if (cmd == ELS_CMD_FDISC) {
1916 /* Always retry for this case */ 1889 /* FDISC retry policy */
1917 cmdiocb->retry = 0; 1890 maxretry = 48;
1891 if (cmdiocb->retry >= 32)
1892 delay = 1000;
1918 } 1893 }
1919 retry = 1; 1894 retry = 1;
1920 break; 1895 break;
@@ -1926,10 +1901,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1926 ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) || 1901 ((stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_PNAME) ||
1927 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID)) 1902 (stat.un.b.lsRjtRsnCodeExp == LSEXP_INVALID_NPORT_ID))
1928 ) { 1903 ) {
1929 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1904 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1930 "%d (%d):0123 FDISC Failed (x%x)." 1905 "0123 FDISC Failed (x%x). "
1931 " Fabric Detected Bad WWN\n", 1906 "Fabric Detected Bad WWN\n",
1932 phba->brd_no, vport->vpi, stat.un.lsRjtError); 1907 stat.un.lsRjtError);
1933 lpfc_vport_set_state(vport, 1908 lpfc_vport_set_state(vport,
1934 FC_VPORT_FABRIC_REJ_WWN); 1909 FC_VPORT_FABRIC_REJ_WWN);
1935 } 1910 }
@@ -1959,11 +1934,10 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1959 if (retry) { 1934 if (retry) {
1960 1935
1961 /* Retry ELS command <elsCmd> to remote NPORT <did> */ 1936 /* Retry ELS command <elsCmd> to remote NPORT <did> */
1962 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 1937 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
1963 "%d (%d):0107 Retry ELS command x%x to remote " 1938 "0107 Retry ELS command x%x to remote "
1964 "NPORT x%x Data: x%x x%x\n", 1939 "NPORT x%x Data: x%x x%x\n",
1965 phba->brd_no, vport->vpi, 1940 cmd, did, cmdiocb->retry, delay);
1966 cmd, did, cmdiocb->retry, delay);
1967 1941
1968 if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) && 1942 if (((cmd == ELS_CMD_PLOGI) || (cmd == ELS_CMD_ADISC)) &&
1969 ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) || 1943 ((irsp->ulpStatus != IOSTAT_LOCAL_REJECT) ||
@@ -2031,14 +2005,12 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2031 return 1; 2005 return 1;
2032 } 2006 }
2033 } 2007 }
2034
2035 /* No retry ELS command <elsCmd> to remote NPORT <did> */ 2008 /* No retry ELS command <elsCmd> to remote NPORT <did> */
2036 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2009 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
2037 "%d (%d):0108 No retry ELS command x%x to remote " 2010 "0108 No retry ELS command x%x to remote "
2038 "NPORT x%x Data: x%x\n", 2011 "NPORT x%x Retried:%d Error:x%x/%x\n",
2039 phba->brd_no, vport->vpi, 2012 cmd, did, cmdiocb->retry, irsp->ulpStatus,
2040 cmd, did, cmdiocb->retry); 2013 irsp->un.ulpWord[4]);
2041
2042 return 0; 2014 return 0;
2043} 2015}
2044 2016
@@ -2087,14 +2059,12 @@ lpfc_cmpl_els_logo_acc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2087 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2059 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
2088 "ACC LOGO cmpl: status:x%x/x%x did:x%x", 2060 "ACC LOGO cmpl: status:x%x/x%x did:x%x",
2089 irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID); 2061 irsp->ulpStatus, irsp->un.ulpWord[4], ndlp->nlp_DID);
2090
2091 /* ACC to LOGO completes to NPort <nlp_DID> */ 2062 /* ACC to LOGO completes to NPort <nlp_DID> */
2092 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2063 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2093 "%d (%d):0109 ACC to LOGO completes to NPort x%x " 2064 "0109 ACC to LOGO completes to NPort x%x "
2094 "Data: x%x x%x x%x\n", 2065 "Data: x%x x%x x%x\n",
2095 phba->brd_no, vport->vpi, ndlp->nlp_DID, 2066 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2096 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2067 ndlp->nlp_rpi);
2097
2098 switch (ndlp->nlp_state) { 2068 switch (ndlp->nlp_state) {
2099 case NLP_STE_UNUSED_NODE: /* node is just allocated */ 2069 case NLP_STE_UNUSED_NODE: /* node is just allocated */
2100 lpfc_drop_node(vport, ndlp); 2070 lpfc_drop_node(vport, ndlp);
@@ -2153,20 +2123,17 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
2153 } 2123 }
2154 2124
2155 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2125 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
2156 "ACC cmpl: status:x%x/x%x did:x%x", 2126 "ELS rsp cmpl: status:x%x/x%x did:x%x",
2157 irsp->ulpStatus, irsp->un.ulpWord[4], 2127 irsp->ulpStatus, irsp->un.ulpWord[4],
2158 irsp->un.rcvels.remoteID); 2128 cmdiocb->iocb.un.elsreq64.remoteID);
2159
2160 /* ELS response tag <ulpIoTag> completes */ 2129 /* ELS response tag <ulpIoTag> completes */
2161 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2130 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2162 "%d (%d):0110 ELS response tag x%x completes " 2131 "0110 ELS response tag x%x completes "
2163 "Data: x%x x%x x%x x%x x%x x%x x%x\n", 2132 "Data: x%x x%x x%x x%x x%x x%x x%x\n",
2164 phba->brd_no, vport->vpi, 2133 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus,
2165 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus, 2134 rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout,
2166 rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout, 2135 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2167 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state, 2136 ndlp->nlp_rpi);
2168 ndlp->nlp_rpi);
2169
2170 if (mbox) { 2137 if (mbox) {
2171 if ((rspiocb->iocb.ulpStatus == 0) 2138 if ((rspiocb->iocb.ulpStatus == 0)
2172 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { 2139 && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) {
@@ -2219,7 +2186,7 @@ out:
2219int 2186int
2220lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag, 2187lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
2221 struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp, 2188 struct lpfc_iocbq *oldiocb, struct lpfc_nodelist *ndlp,
2222 LPFC_MBOXQ_t *mbox, uint8_t newnode) 2189 LPFC_MBOXQ_t *mbox)
2223{ 2190{
2224 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2191 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2225 struct lpfc_hba *phba = vport->phba; 2192 struct lpfc_hba *phba = vport->phba;
@@ -2305,20 +2272,13 @@ lpfc_els_rsp_acc(struct lpfc_vport *vport, uint32_t flag,
2305 default: 2272 default:
2306 return 1; 2273 return 1;
2307 } 2274 }
2308
2309 if (newnode) {
2310 lpfc_nlp_put(ndlp);
2311 elsiocb->context1 = NULL;
2312 }
2313
2314 /* Xmit ELS ACC response tag <ulpIoTag> */ 2275 /* Xmit ELS ACC response tag <ulpIoTag> */
2315 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2276 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2316 "%d (%d):0128 Xmit ELS ACC response tag x%x, XRI: x%x, " 2277 "0128 Xmit ELS ACC response tag x%x, XRI: x%x, "
2317 "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x\n", 2278 "DID: x%x, nlp_flag: x%x nlp_state: x%x RPI: x%x\n",
2318 phba->brd_no, vport->vpi, elsiocb->iotag, 2279 elsiocb->iotag, elsiocb->iocb.ulpContext,
2319 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2280 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2320 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2281 ndlp->nlp_rpi);
2321
2322 if (ndlp->nlp_flag & NLP_LOGO_ACC) { 2282 if (ndlp->nlp_flag & NLP_LOGO_ACC) {
2323 spin_lock_irq(shost->host_lock); 2283 spin_lock_irq(shost->host_lock);
2324 ndlp->nlp_flag &= ~NLP_LOGO_ACC; 2284 ndlp->nlp_flag &= ~NLP_LOGO_ACC;
@@ -2370,20 +2330,17 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
2370 pcmd += sizeof(uint32_t); 2330 pcmd += sizeof(uint32_t);
2371 *((uint32_t *) (pcmd)) = rejectError; 2331 *((uint32_t *) (pcmd)) = rejectError;
2372 2332
2373 if (mbox) { 2333 if (mbox)
2374 elsiocb->context_un.mbox = mbox; 2334 elsiocb->context_un.mbox = mbox;
2375 elsiocb->context1 = lpfc_nlp_get(ndlp);
2376 }
2377 2335
2378 /* Xmit ELS RJT <err> response tag <ulpIoTag> */ 2336 /* Xmit ELS RJT <err> response tag <ulpIoTag> */
2379 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2337 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2380 "%d (%d):0129 Xmit ELS RJT x%x response tag x%x " 2338 "0129 Xmit ELS RJT x%x response tag x%x "
2381 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " 2339 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, "
2382 "rpi x%x\n", 2340 "rpi x%x\n",
2383 phba->brd_no, vport->vpi, rejectError, elsiocb->iotag, 2341 rejectError, elsiocb->iotag,
2384 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2342 elsiocb->iocb.ulpContext, ndlp->nlp_DID,
2385 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2343 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
2386
2387 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP, 2344 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
2388 "Issue LS_RJT: did:x%x flg:x%x err:x%x", 2345 "Issue LS_RJT: did:x%x flg:x%x err:x%x",
2389 ndlp->nlp_DID, ndlp->nlp_flag, rejectError); 2346 ndlp->nlp_DID, ndlp->nlp_flag, rejectError);
@@ -2391,6 +2348,15 @@ lpfc_els_rsp_reject(struct lpfc_vport *vport, uint32_t rejectError,
2391 phba->fc_stat.elsXmitLSRJT++; 2348 phba->fc_stat.elsXmitLSRJT++;
2392 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 2349 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
2393 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0); 2350 rc = lpfc_sli_issue_iocb(phba, pring, elsiocb, 0);
2351
2352 /* If the node is in the UNUSED state, and we are sending
2353 * a reject, we are done with it. Release driver reference
2354 * count here. The outstanding els will release its reference on
2355 * completion and the node can be freed then.
2356 */
2357 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
2358 lpfc_nlp_put(ndlp);
2359
2394 if (rc == IOCB_ERROR) { 2360 if (rc == IOCB_ERROR) {
2395 lpfc_els_free_iocb(phba, elsiocb); 2361 lpfc_els_free_iocb(phba, elsiocb);
2396 return 1; 2362 return 1;
@@ -2423,13 +2389,12 @@ lpfc_els_rsp_adisc_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
2423 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 2389 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2424 2390
2425 /* Xmit ADISC ACC response tag <ulpIoTag> */ 2391 /* Xmit ADISC ACC response tag <ulpIoTag> */
2426 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2392 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2427 "%d (%d):0130 Xmit ADISC ACC response iotag x%x xri: " 2393 "0130 Xmit ADISC ACC response iotag x%x xri: "
2428 "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n", 2394 "x%x, did x%x, nlp_flag x%x, nlp_state x%x rpi x%x\n",
2429 phba->brd_no, vport->vpi, elsiocb->iotag, 2395 elsiocb->iotag, elsiocb->iocb.ulpContext,
2430 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2396 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2431 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2397 ndlp->nlp_rpi);
2432
2433 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2398 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2434 2399
2435 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2400 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
@@ -2483,15 +2448,13 @@ lpfc_els_rsp_prli_acc(struct lpfc_vport *vport, struct lpfc_iocbq *oldiocb,
2483 icmd = &elsiocb->iocb; 2448 icmd = &elsiocb->iocb;
2484 oldcmd = &oldiocb->iocb; 2449 oldcmd = &oldiocb->iocb;
2485 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 2450 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2486
2487 /* Xmit PRLI ACC response tag <ulpIoTag> */ 2451 /* Xmit PRLI ACC response tag <ulpIoTag> */
2488 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2452 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2489 "%d (%d):0131 Xmit PRLI ACC response tag x%x xri x%x, " 2453 "0131 Xmit PRLI ACC response tag x%x xri x%x, "
2490 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n", 2454 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
2491 phba->brd_no, vport->vpi, elsiocb->iotag, 2455 elsiocb->iotag, elsiocb->iocb.ulpContext,
2492 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 2456 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
2493 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 2457 ndlp->nlp_rpi);
2494
2495 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2458 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2496 2459
2497 *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK)); 2460 *((uint32_t *) (pcmd)) = (ELS_CMD_ACC | (ELS_CMD_PRLI & ~ELS_RSP_MASK));
@@ -2565,16 +2528,11 @@ lpfc_els_rsp_rnid_acc(struct lpfc_vport *vport, uint8_t format,
2565 icmd = &elsiocb->iocb; 2528 icmd = &elsiocb->iocb;
2566 oldcmd = &oldiocb->iocb; 2529 oldcmd = &oldiocb->iocb;
2567 icmd->ulpContext = oldcmd->ulpContext; /* Xri */ 2530 icmd->ulpContext = oldcmd->ulpContext; /* Xri */
2568
2569 /* Xmit RNID ACC response tag <ulpIoTag> */ 2531 /* Xmit RNID ACC response tag <ulpIoTag> */
2570 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 2532 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
2571 "%d (%d):0132 Xmit RNID ACC response tag x%x " 2533 "0132 Xmit RNID ACC response tag x%x xri x%x\n",
2572 "xri x%x\n", 2534 elsiocb->iotag, elsiocb->iocb.ulpContext);
2573 phba->brd_no, vport->vpi, elsiocb->iotag,
2574 elsiocb->iocb.ulpContext);
2575
2576 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt); 2535 pcmd = (uint8_t *) (((struct lpfc_dmabuf *) elsiocb->context2)->virt);
2577
2578 *((uint32_t *) (pcmd)) = ELS_CMD_ACC; 2536 *((uint32_t *) (pcmd)) = ELS_CMD_ACC;
2579 pcmd += sizeof(uint32_t); 2537 pcmd += sizeof(uint32_t);
2580 2538
@@ -2641,7 +2599,7 @@ lpfc_els_disc_adisc(struct lpfc_vport *vport)
2641 sentadisc++; 2599 sentadisc++;
2642 vport->num_disc_nodes++; 2600 vport->num_disc_nodes++;
2643 if (vport->num_disc_nodes >= 2601 if (vport->num_disc_nodes >=
2644 vport->phba->cfg_discovery_threads) { 2602 vport->cfg_discovery_threads) {
2645 spin_lock_irq(shost->host_lock); 2603 spin_lock_irq(shost->host_lock);
2646 vport->fc_flag |= FC_NLP_MORE; 2604 vport->fc_flag |= FC_NLP_MORE;
2647 spin_unlock_irq(shost->host_lock); 2605 spin_unlock_irq(shost->host_lock);
@@ -2676,7 +2634,7 @@ lpfc_els_disc_plogi(struct lpfc_vport *vport)
2676 sentplogi++; 2634 sentplogi++;
2677 vport->num_disc_nodes++; 2635 vport->num_disc_nodes++;
2678 if (vport->num_disc_nodes >= 2636 if (vport->num_disc_nodes >=
2679 vport->phba->cfg_discovery_threads) { 2637 vport->cfg_discovery_threads) {
2680 spin_lock_irq(shost->host_lock); 2638 spin_lock_irq(shost->host_lock);
2681 vport->fc_flag |= FC_NLP_MORE; 2639 vport->fc_flag |= FC_NLP_MORE;
2682 spin_unlock_irq(shost->host_lock); 2640 spin_unlock_irq(shost->host_lock);
@@ -2717,7 +2675,6 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
2717 D_ID rscn_did; 2675 D_ID rscn_did;
2718 uint32_t *lp; 2676 uint32_t *lp;
2719 uint32_t payload_len, i; 2677 uint32_t payload_len, i;
2720 struct lpfc_hba *phba = vport->phba;
2721 2678
2722 ns_did.un.word = did; 2679 ns_did.un.word = did;
2723 2680
@@ -2752,12 +2709,10 @@ lpfc_rscn_payload_check(struct lpfc_vport *vport, uint32_t did)
2752 break; 2709 break;
2753 default: 2710 default:
2754 /* Unknown Identifier in RSCN node */ 2711 /* Unknown Identifier in RSCN node */
2755 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2712 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2756 "%d (%d):0217 Unknown " 2713 "0217 Unknown Identifier in "
2757 "Identifier in RSCN payload " 2714 "RSCN payload Data: x%x\n",
2758 "Data: x%x\n", 2715 rscn_did.un.word);
2759 phba->brd_no, vport->vpi,
2760 rscn_did.un.word);
2761 case 3: /* Whole Fabric effected */ 2716 case 3: /* Whole Fabric effected */
2762 return did; 2717 return did;
2763 } 2718 }
@@ -2796,12 +2751,11 @@ lpfc_rscn_recovery_check(struct lpfc_vport *vport)
2796 2751
2797static int 2752static int
2798lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, 2753lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2799 struct lpfc_nodelist *ndlp, uint8_t newnode) 2754 struct lpfc_nodelist *ndlp)
2800{ 2755{
2801 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2756 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
2802 struct lpfc_hba *phba = vport->phba; 2757 struct lpfc_hba *phba = vport->phba;
2803 struct lpfc_dmabuf *pcmd; 2758 struct lpfc_dmabuf *pcmd;
2804 struct lpfc_vport *next_vport;
2805 uint32_t *lp, *datap; 2759 uint32_t *lp, *datap;
2806 IOCB_t *icmd; 2760 IOCB_t *icmd;
2807 uint32_t payload_len, length, nportid, *cmd; 2761 uint32_t payload_len, length, nportid, *cmd;
@@ -2815,13 +2769,10 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2815 2769
2816 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK); 2770 payload_len = be32_to_cpu(*lp++ & ~ELS_CMD_MASK);
2817 payload_len -= sizeof(uint32_t); /* take off word 0 */ 2771 payload_len -= sizeof(uint32_t); /* take off word 0 */
2818
2819 /* RSCN received */ 2772 /* RSCN received */
2820 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2773 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2821 "%d (%d):0214 RSCN received Data: x%x x%x x%x x%x\n", 2774 "0214 RSCN received Data: x%x x%x x%x x%x\n",
2822 phba->brd_no, vport->vpi, vport->fc_flag, payload_len, 2775 vport->fc_flag, payload_len, *lp, rscn_cnt);
2823 *lp, rscn_cnt);
2824
2825 for (i = 0; i < payload_len/sizeof(uint32_t); i++) 2776 for (i = 0; i < payload_len/sizeof(uint32_t); i++)
2826 fc_host_post_event(shost, fc_get_event_number(), 2777 fc_host_post_event(shost, fc_get_event_number(),
2827 FCH_EVT_RSCN, lp[i]); 2778 FCH_EVT_RSCN, lp[i]);
@@ -2834,8 +2785,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2834 "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x", 2785 "RCV RSCN ignore: did:x%x/ste:x%x flg:x%x",
2835 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag); 2786 ndlp->nlp_DID, vport->port_state, ndlp->nlp_flag);
2836 2787
2837 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 2788 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2838 newnode);
2839 return 0; 2789 return 0;
2840 } 2790 }
2841 2791
@@ -2843,7 +2793,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2843 * just ACC and ignore it. 2793 * just ACC and ignore it.
2844 */ 2794 */
2845 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && 2795 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) &&
2846 !(phba->cfg_peer_port_login)) { 2796 !(vport->cfg_peer_port_login)) {
2847 i = payload_len; 2797 i = payload_len;
2848 datap = lp; 2798 datap = lp;
2849 while (i > 0) { 2799 while (i > 0) {
@@ -2851,28 +2801,23 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2851 nportid = ((be32_to_cpu(nportid)) & Mask_DID); 2801 nportid = ((be32_to_cpu(nportid)) & Mask_DID);
2852 i -= sizeof(uint32_t); 2802 i -= sizeof(uint32_t);
2853 rscn_id++; 2803 rscn_id++;
2854 list_for_each_entry(next_vport, &phba->port_list, 2804 if (lpfc_find_vport_by_did(phba, nportid))
2855 listentry) { 2805 hba_id++;
2856 if (nportid == next_vport->fc_myDID) {
2857 hba_id++;
2858 break;
2859 }
2860 }
2861 } 2806 }
2862 if (rscn_id == hba_id) { 2807 if (rscn_id == hba_id) {
2863 /* ALL NPortIDs in RSCN are on HBA */ 2808 /* ALL NPortIDs in RSCN are on HBA */
2864 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2809 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2865 "%d (%d):0214 Ignore RSCN Data: x%x x%x x%x x%x\n", 2810 "0214 Ignore RSCN "
2866 phba->brd_no, vport->vpi, vport->fc_flag, payload_len, 2811 "Data: x%x x%x x%x x%x\n",
2867 *lp, rscn_cnt); 2812 vport->fc_flag, payload_len,
2868 2813 *lp, rscn_cnt);
2869 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 2814 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
2870 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x", 2815 "RCV RSCN vport: did:x%x/ste:x%x flg:x%x",
2871 ndlp->nlp_DID, vport->port_state, 2816 ndlp->nlp_DID, vport->port_state,
2872 ndlp->nlp_flag); 2817 ndlp->nlp_flag);
2873 2818
2874 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, 2819 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb,
2875 ndlp, NULL, newnode); 2820 ndlp, NULL);
2876 return 0; 2821 return 0;
2877 } 2822 }
2878 } 2823 }
@@ -2911,27 +2856,24 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2911 } 2856 }
2912 2857
2913 /* Deferred RSCN */ 2858 /* Deferred RSCN */
2914 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2859 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2915 "%d (%d):0235 Deferred RSCN " 2860 "0235 Deferred RSCN "
2916 "Data: x%x x%x x%x\n", 2861 "Data: x%x x%x x%x\n",
2917 phba->brd_no, vport->vpi, 2862 vport->fc_rscn_id_cnt, vport->fc_flag,
2918 vport->fc_rscn_id_cnt, vport->fc_flag, 2863 vport->port_state);
2919 vport->port_state);
2920 } else { 2864 } else {
2921 spin_lock_irq(shost->host_lock); 2865 spin_lock_irq(shost->host_lock);
2922 vport->fc_flag |= FC_RSCN_DISCOVERY; 2866 vport->fc_flag |= FC_RSCN_DISCOVERY;
2923 spin_unlock_irq(shost->host_lock); 2867 spin_unlock_irq(shost->host_lock);
2924 /* ReDiscovery RSCN */ 2868 /* ReDiscovery RSCN */
2925 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2869 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2926 "%d (%d):0234 ReDiscovery RSCN " 2870 "0234 ReDiscovery RSCN "
2927 "Data: x%x x%x x%x\n", 2871 "Data: x%x x%x x%x\n",
2928 phba->brd_no, vport->vpi, 2872 vport->fc_rscn_id_cnt, vport->fc_flag,
2929 vport->fc_rscn_id_cnt, vport->fc_flag, 2873 vport->port_state);
2930 vport->port_state);
2931 } 2874 }
2932 /* Send back ACC */ 2875 /* Send back ACC */
2933 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 2876 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2934 newnode);
2935 2877
2936 /* send RECOVERY event for ALL nodes that match RSCN payload */ 2878 /* send RECOVERY event for ALL nodes that match RSCN payload */
2937 lpfc_rscn_recovery_check(vport); 2879 lpfc_rscn_recovery_check(vport);
@@ -2956,7 +2898,7 @@ lpfc_els_rcv_rscn(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
2956 lpfc_set_disctmo(vport); 2898 lpfc_set_disctmo(vport);
2957 2899
2958 /* Send back ACC */ 2900 /* Send back ACC */
2959 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, newnode); 2901 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
2960 2902
2961 /* send RECOVERY event for ALL nodes that match RSCN payload */ 2903 /* send RECOVERY event for ALL nodes that match RSCN payload */
2962 lpfc_rscn_recovery_check(vport); 2904 lpfc_rscn_recovery_check(vport);
@@ -2980,11 +2922,10 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport)
2980 lpfc_set_disctmo(vport); 2922 lpfc_set_disctmo(vport);
2981 2923
2982 /* RSCN processed */ 2924 /* RSCN processed */
2983 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2925 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2984 "%d (%d):0215 RSCN processed Data: x%x x%x x%x x%x\n", 2926 "0215 RSCN processed Data: x%x x%x x%x x%x\n",
2985 phba->brd_no, vport->vpi, 2927 vport->fc_flag, 0, vport->fc_rscn_id_cnt,
2986 vport->fc_flag, 0, vport->fc_rscn_id_cnt, 2928 vport->port_state);
2987 vport->port_state);
2988 2929
2989 /* To process RSCN, first compare RSCN data with NameServer */ 2930 /* To process RSCN, first compare RSCN data with NameServer */
2990 vport->fc_ns_retry = 0; 2931 vport->fc_ns_retry = 0;
@@ -3026,7 +2967,7 @@ lpfc_els_handle_rscn(struct lpfc_vport *vport)
3026 2967
3027static int 2968static int
3028lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, 2969lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3029 struct lpfc_nodelist *ndlp, uint8_t newnode) 2970 struct lpfc_nodelist *ndlp)
3030{ 2971{
3031 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 2972 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3032 struct lpfc_hba *phba = vport->phba; 2973 struct lpfc_hba *phba = vport->phba;
@@ -3052,10 +2993,10 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3052 2993
3053 /* An FLOGI ELS command <elsCmd> was received from DID <did> in 2994 /* An FLOGI ELS command <elsCmd> was received from DID <did> in
3054 Loop Mode */ 2995 Loop Mode */
3055 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 2996 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3056 "%d (%d):0113 An FLOGI ELS command x%x was " 2997 "0113 An FLOGI ELS command x%x was "
3057 "received from DID x%x in Loop Mode\n", 2998 "received from DID x%x in Loop Mode\n",
3058 phba->brd_no, vport->vpi, cmd, did); 2999 cmd, did);
3059 return 1; 3000 return 1;
3060 } 3001 }
3061 3002
@@ -3109,7 +3050,7 @@ lpfc_els_rcv_flogi(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3109 } 3050 }
3110 3051
3111 /* Send back ACC */ 3052 /* Send back ACC */
3112 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, newnode); 3053 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL);
3113 3054
3114 return 0; 3055 return 0;
3115} 3056}
@@ -3226,16 +3167,13 @@ lpfc_els_rsp_rps_acc(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
3226 rps_rsp->primSeqErrCnt = be32_to_cpu(mb->un.varRdLnk.primSeqErrCnt); 3167 rps_rsp->primSeqErrCnt = be32_to_cpu(mb->un.varRdLnk.primSeqErrCnt);
3227 rps_rsp->invalidXmitWord = be32_to_cpu(mb->un.varRdLnk.invalidXmitWord); 3168 rps_rsp->invalidXmitWord = be32_to_cpu(mb->un.varRdLnk.invalidXmitWord);
3228 rps_rsp->crcCnt = be32_to_cpu(mb->un.varRdLnk.crcCnt); 3169 rps_rsp->crcCnt = be32_to_cpu(mb->un.varRdLnk.crcCnt);
3229
3230 /* Xmit ELS RPS ACC response tag <ulpIoTag> */ 3170 /* Xmit ELS RPS ACC response tag <ulpIoTag> */
3231 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3171 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_ELS,
3232 "%d (%d):0118 Xmit ELS RPS ACC response tag x%x " 3172 "0118 Xmit ELS RPS ACC response tag x%x xri x%x, "
3233 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " 3173 "did x%x, nlp_flag x%x, nlp_state x%x, rpi x%x\n",
3234 "rpi x%x\n", 3174 elsiocb->iotag, elsiocb->iocb.ulpContext,
3235 phba->brd_no, ndlp->vport->vpi, elsiocb->iotag, 3175 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
3236 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 3176 ndlp->nlp_rpi);
3237 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi);
3238
3239 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 3177 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
3240 phba->fc_stat.elsXmitACC++; 3178 phba->fc_stat.elsXmitACC++;
3241 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) 3179 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR)
@@ -3337,21 +3275,16 @@ lpfc_els_rsp_rpl_acc(struct lpfc_vport *vport, uint16_t cmdsize,
3337 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID); 3275 rpl_rsp.port_num_blk.portID = be32_to_cpu(vport->fc_myDID);
3338 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname, 3276 memcpy(&rpl_rsp.port_num_blk.portName, &vport->fc_portname,
3339 sizeof(struct lpfc_name)); 3277 sizeof(struct lpfc_name));
3340
3341 memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); 3278 memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t));
3342
3343
3344 /* Xmit ELS RPL ACC response tag <ulpIoTag> */ 3279 /* Xmit ELS RPL ACC response tag <ulpIoTag> */
3345 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3280 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3346 "%d (%d):0120 Xmit ELS RPL ACC response tag x%x " 3281 "0120 Xmit ELS RPL ACC response tag x%x "
3347 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, " 3282 "xri x%x, did x%x, nlp_flag x%x, nlp_state x%x, "
3348 "rpi x%x\n", 3283 "rpi x%x\n",
3349 phba->brd_no, vport->vpi, elsiocb->iotag, 3284 elsiocb->iotag, elsiocb->iocb.ulpContext,
3350 elsiocb->iocb.ulpContext, ndlp->nlp_DID, 3285 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
3351 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 3286 ndlp->nlp_rpi);
3352
3353 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp; 3287 elsiocb->iocb_cmpl = lpfc_cmpl_els_rsp;
3354
3355 phba->fc_stat.elsXmitACC++; 3288 phba->fc_stat.elsXmitACC++;
3356 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) { 3289 if (lpfc_sli_issue_iocb(phba, pring, elsiocb, 0) == IOCB_ERROR) {
3357 lpfc_els_free_iocb(phba, elsiocb); 3290 lpfc_els_free_iocb(phba, elsiocb);
@@ -3404,7 +3337,6 @@ static int
3404lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, 3337lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3405 struct lpfc_nodelist *ndlp) 3338 struct lpfc_nodelist *ndlp)
3406{ 3339{
3407 struct lpfc_hba *phba = vport->phba;
3408 struct lpfc_dmabuf *pcmd; 3340 struct lpfc_dmabuf *pcmd;
3409 uint32_t *lp; 3341 uint32_t *lp;
3410 IOCB_t *icmd; 3342 IOCB_t *icmd;
@@ -3418,12 +3350,9 @@ lpfc_els_rcv_farp(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3418 3350
3419 cmd = *lp++; 3351 cmd = *lp++;
3420 fp = (FARP *) lp; 3352 fp = (FARP *) lp;
3421
3422 /* FARP-REQ received from DID <did> */ 3353 /* FARP-REQ received from DID <did> */
3423 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3354 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3424 "%d (%d):0601 FARP-REQ received from DID x%x\n", 3355 "0601 FARP-REQ received from DID x%x\n", did);
3425 phba->brd_no, vport->vpi, did);
3426
3427 /* We will only support match on WWPN or WWNN */ 3356 /* We will only support match on WWPN or WWNN */
3428 if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) { 3357 if (fp->Mflags & ~(FARP_MATCH_NODE | FARP_MATCH_PORT)) {
3429 return 0; 3358 return 0;
@@ -3471,7 +3400,6 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3471 uint32_t *lp; 3400 uint32_t *lp;
3472 IOCB_t *icmd; 3401 IOCB_t *icmd;
3473 uint32_t cmd, did; 3402 uint32_t cmd, did;
3474 struct lpfc_hba *phba = vport->phba;
3475 3403
3476 icmd = &cmdiocb->iocb; 3404 icmd = &cmdiocb->iocb;
3477 did = icmd->un.elsreq64.remoteID; 3405 did = icmd->un.elsreq64.remoteID;
@@ -3480,11 +3408,10 @@ lpfc_els_rcv_farpr(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3480 3408
3481 cmd = *lp++; 3409 cmd = *lp++;
3482 /* FARP-RSP received from DID <did> */ 3410 /* FARP-RSP received from DID <did> */
3483 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3411 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3484 "%d (%d):0600 FARP-RSP received from DID x%x\n", 3412 "0600 FARP-RSP received from DID x%x\n", did);
3485 phba->brd_no, vport->vpi, did);
3486 /* ACCEPT the Farp resp request */ 3413 /* ACCEPT the Farp resp request */
3487 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 3414 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
3488 3415
3489 return 0; 3416 return 0;
3490} 3417}
@@ -3502,10 +3429,8 @@ lpfc_els_rcv_fan(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb,
3502 struct lpfc_hba *phba = vport->phba; 3429 struct lpfc_hba *phba = vport->phba;
3503 3430
3504 /* FAN received */ 3431 /* FAN received */
3505 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3432 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3506 "%d (%d):0265 FAN received\n", 3433 "0265 FAN received\n");
3507 phba->brd_no, vport->vpi);
3508
3509 icmd = &cmdiocb->iocb; 3434 icmd = &cmdiocb->iocb;
3510 did = icmd->un.elsreq64.remoteID; 3435 did = icmd->un.elsreq64.remoteID;
3511 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2; 3436 pcmd = (struct lpfc_dmabuf *)cmdiocb->context2;
@@ -3664,13 +3589,10 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport)
3664 if (ndlp) 3589 if (ndlp)
3665 remote_ID = ndlp->nlp_DID; 3590 remote_ID = ndlp->nlp_DID;
3666 } 3591 }
3667 3592 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3668 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3593 "0127 ELS timeout Data: x%x x%x x%x "
3669 "%d (%d):0127 ELS timeout Data: x%x x%x x%x " 3594 "x%x\n", els_command,
3670 "x%x\n", 3595 remote_ID, cmd->ulpCommand, cmd->ulpIoTag);
3671 phba->brd_no, vport->vpi, els_command,
3672 remote_ID, cmd->ulpCommand, cmd->ulpIoTag);
3673
3674 lpfc_sli_issue_abort_iotag(phba, pring, piocb); 3596 lpfc_sli_issue_abort_iotag(phba, pring, piocb);
3675 } 3597 }
3676 spin_unlock_irq(&phba->hbalock); 3598 spin_unlock_irq(&phba->hbalock);
@@ -3741,6 +3663,50 @@ lpfc_els_flush_cmd(struct lpfc_vport *vport)
3741 return; 3663 return;
3742} 3664}
3743 3665
3666void
3667lpfc_els_flush_all_cmd(struct lpfc_hba *phba)
3668{
3669 LIST_HEAD(completions);
3670 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
3671 struct lpfc_iocbq *tmp_iocb, *piocb;
3672 IOCB_t *cmd = NULL;
3673
3674 lpfc_fabric_abort_hba(phba);
3675 spin_lock_irq(&phba->hbalock);
3676 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txq, list) {
3677 cmd = &piocb->iocb;
3678 if (piocb->iocb_flag & LPFC_IO_LIBDFC)
3679 continue;
3680 /* Do not flush out the QUE_RING and ABORT/CLOSE iocbs */
3681 if (cmd->ulpCommand == CMD_QUE_RING_BUF_CN ||
3682 cmd->ulpCommand == CMD_QUE_RING_BUF64_CN ||
3683 cmd->ulpCommand == CMD_CLOSE_XRI_CN ||
3684 cmd->ulpCommand == CMD_ABORT_XRI_CN)
3685 continue;
3686 list_move_tail(&piocb->list, &completions);
3687 pring->txq_cnt--;
3688 }
3689 list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) {
3690 if (piocb->iocb_flag & LPFC_IO_LIBDFC)
3691 continue;
3692 lpfc_sli_issue_abort_iotag(phba, pring, piocb);
3693 }
3694 spin_unlock_irq(&phba->hbalock);
3695 while (!list_empty(&completions)) {
3696 piocb = list_get_first(&completions, struct lpfc_iocbq, list);
3697 cmd = &piocb->iocb;
3698 list_del_init(&piocb->list);
3699 if (!piocb->iocb_cmpl)
3700 lpfc_sli_release_iocbq(phba, piocb);
3701 else {
3702 cmd->ulpStatus = IOSTAT_LOCAL_REJECT;
3703 cmd->un.ulpWord[4] = IOERR_SLI_ABORTED;
3704 (piocb->iocb_cmpl) (phba, piocb, piocb);
3705 }
3706 }
3707 return;
3708}
3709
3744static void 3710static void
3745lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 3711lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3746 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb) 3712 struct lpfc_vport *vport, struct lpfc_iocbq *elsiocb)
@@ -3801,11 +3767,9 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3801 cmd &= ELS_CMD_MASK; 3767 cmd &= ELS_CMD_MASK;
3802 } 3768 }
3803 /* ELS command <elsCmd> received from NPORT <did> */ 3769 /* ELS command <elsCmd> received from NPORT <did> */
3804 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3770 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
3805 "%d (%d):0112 ELS command x%x received from NPORT x%x " 3771 "0112 ELS command x%x received from NPORT x%x "
3806 "Data: x%x\n", phba->brd_no, vport->vpi, cmd, did, 3772 "Data: x%x\n", cmd, did, vport->port_state);
3807 vport->port_state);
3808
3809 switch (cmd) { 3773 switch (cmd) {
3810 case ELS_CMD_PLOGI: 3774 case ELS_CMD_PLOGI:
3811 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL, 3775 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_UNSOL,
@@ -3829,7 +3793,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3829 did, vport->port_state, ndlp->nlp_flag); 3793 did, vport->port_state, ndlp->nlp_flag);
3830 3794
3831 phba->fc_stat.elsRcvFLOGI++; 3795 phba->fc_stat.elsRcvFLOGI++;
3832 lpfc_els_rcv_flogi(vport, elsiocb, ndlp, newnode); 3796 lpfc_els_rcv_flogi(vport, elsiocb, ndlp);
3833 if (newnode) 3797 if (newnode)
3834 lpfc_drop_node(vport, ndlp); 3798 lpfc_drop_node(vport, ndlp);
3835 break; 3799 break;
@@ -3859,7 +3823,7 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3859 break; 3823 break;
3860 case ELS_CMD_RSCN: 3824 case ELS_CMD_RSCN:
3861 phba->fc_stat.elsRcvRSCN++; 3825 phba->fc_stat.elsRcvRSCN++;
3862 lpfc_els_rcv_rscn(vport, elsiocb, ndlp, newnode); 3826 lpfc_els_rcv_rscn(vport, elsiocb, ndlp);
3863 if (newnode) 3827 if (newnode)
3864 lpfc_drop_node(vport, ndlp); 3828 lpfc_drop_node(vport, ndlp);
3865 break; 3829 break;
@@ -3974,10 +3938,9 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3974 rjt_err = LSRJT_INVALID_CMD; 3938 rjt_err = LSRJT_INVALID_CMD;
3975 3939
3976 /* Unknown ELS command <elsCmd> received from NPORT <did> */ 3940 /* Unknown ELS command <elsCmd> received from NPORT <did> */
3977 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3941 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
3978 "%d (%d):0115 Unknown ELS command x%x " 3942 "0115 Unknown ELS command x%x "
3979 "received from NPORT x%x\n", 3943 "received from NPORT x%x\n", cmd, did);
3980 phba->brd_no, vport->vpi, cmd, did);
3981 if (newnode) 3944 if (newnode)
3982 lpfc_drop_node(vport, ndlp); 3945 lpfc_drop_node(vport, ndlp);
3983 break; 3946 break;
@@ -3990,19 +3953,16 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3990 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE; 3953 stat.un.b.lsRjtRsnCodeExp = LSEXP_NOTHING_MORE;
3991 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp, 3954 lpfc_els_rsp_reject(vport, stat.un.lsRjtError, elsiocb, ndlp,
3992 NULL); 3955 NULL);
3993 if (newnode)
3994 lpfc_drop_node(vport, ndlp);
3995 } 3956 }
3996 3957
3997 return; 3958 return;
3998 3959
3999dropit: 3960dropit:
4000 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 3961 lpfc_printf_log(phba, KERN_ERR, LOG_ELS,
4001 "%d (%d):0111 Dropping received ELS cmd " 3962 "(%d):0111 Dropping received ELS cmd "
4002 "Data: x%x x%x x%x\n", 3963 "Data: x%x x%x x%x\n",
4003 phba->brd_no, vport ? vport->vpi : 0xffff, 3964 vport ? vport->vpi : 0xffff, icmd->ulpStatus,
4004 icmd->ulpStatus, icmd->un.ulpWord[4], 3965 icmd->un.ulpWord[4], icmd->ulpTimeout);
4005 icmd->ulpTimeout);
4006 phba->fc_stat.elsRcvDrop++; 3966 phba->fc_stat.elsRcvDrop++;
4007} 3967}
4008 3968
@@ -4010,11 +3970,16 @@ static struct lpfc_vport *
4010lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi) 3970lpfc_find_vport_by_vpid(struct lpfc_hba *phba, uint16_t vpi)
4011{ 3971{
4012 struct lpfc_vport *vport; 3972 struct lpfc_vport *vport;
3973 unsigned long flags;
4013 3974
3975 spin_lock_irqsave(&phba->hbalock, flags);
4014 list_for_each_entry(vport, &phba->port_list, listentry) { 3976 list_for_each_entry(vport, &phba->port_list, listentry) {
4015 if (vport->vpi == vpi) 3977 if (vport->vpi == vpi) {
3978 spin_unlock_irqrestore(&phba->hbalock, flags);
4016 return vport; 3979 return vport;
3980 }
4017 } 3981 }
3982 spin_unlock_irqrestore(&phba->hbalock, flags);
4018 return NULL; 3983 return NULL;
4019} 3984}
4020 3985
@@ -4109,9 +4074,8 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
4109 return; 4074 return;
4110 } 4075 }
4111 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4076 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4112 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4077 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4113 "%d (%d):0251 NameServer login: no memory\n", 4078 "0251 NameServer login: no memory\n");
4114 phba->brd_no, vport->vpi);
4115 return; 4079 return;
4116 } 4080 }
4117 lpfc_nlp_init(vport, ndlp, NameServer_DID); 4081 lpfc_nlp_init(vport, ndlp, NameServer_DID);
@@ -4122,13 +4086,12 @@ lpfc_do_scr_ns_plogi(struct lpfc_hba *phba, struct lpfc_vport *vport)
4122 4086
4123 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) { 4087 if (lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0)) {
4124 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4088 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4125 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4089 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4126 "%d (%d):0252 Cannot issue NameServer login\n", 4090 "0252 Cannot issue NameServer login\n");
4127 phba->brd_no, vport->vpi);
4128 return; 4091 return;
4129 } 4092 }
4130 4093
4131 if (phba->cfg_fdmi_on) { 4094 if (vport->cfg_fdmi_on) {
4132 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool, 4095 ndlp_fdmi = mempool_alloc(phba->nlp_mem_pool,
4133 GFP_KERNEL); 4096 GFP_KERNEL);
4134 if (ndlp_fdmi) { 4097 if (ndlp_fdmi) {
@@ -4155,9 +4118,9 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
4155 lpfc_nlp_put(ndlp); 4118 lpfc_nlp_put(ndlp);
4156 4119
4157 if (mb->mbxStatus) { 4120 if (mb->mbxStatus) {
4158 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 4121 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4159 "%d (%d):0915 Register VPI failed: 0x%x\n", 4122 "0915 Register VPI failed: 0x%x\n",
4160 phba->brd_no, vport->vpi, mb->mbxStatus); 4123 mb->mbxStatus);
4161 4124
4162 switch (mb->mbxStatus) { 4125 switch (mb->mbxStatus) {
4163 case 0x11: /* unsupported feature */ 4126 case 0x11: /* unsupported feature */
@@ -4206,17 +4169,14 @@ lpfc_register_new_vport(struct lpfc_hba *phba, struct lpfc_vport *vport,
4206 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 4169 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4207 4170
4208 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4171 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4209 4172 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4210 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 4173 "0253 Register VPI: Can't send mbox\n");
4211 "%d (%d):0253 Register VPI: Cannot send mbox\n",
4212 phba->brd_no, vport->vpi);
4213 } 4174 }
4214 } else { 4175 } else {
4215 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4176 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4216 4177
4217 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 4178 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
4218 "%d (%d):0254 Register VPI: no memory\n", 4179 "0254 Register VPI: no memory\n");
4219 phba->brd_no, vport->vpi);
4220 4180
4221 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; 4181 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI;
4222 lpfc_nlp_put(ndlp); 4182 lpfc_nlp_put(ndlp);
@@ -4235,11 +4195,10 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4235 IOCB_t *irsp = &rspiocb->iocb; 4195 IOCB_t *irsp = &rspiocb->iocb;
4236 struct lpfc_iocbq *piocb; 4196 struct lpfc_iocbq *piocb;
4237 4197
4238 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 4198 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
4239 "%d (%d):0123 FDISC completes. x%x/x%x prevDID: x%x\n", 4199 "0123 FDISC completes. x%x/x%x prevDID: x%x\n",
4240 phba->brd_no, vport->vpi, 4200 irsp->ulpStatus, irsp->un.ulpWord[4],
4241 irsp->ulpStatus, irsp->un.ulpWord[4], vport->fc_prevDID); 4201 vport->fc_prevDID);
4242
4243 /* Since all FDISCs are being single threaded, we 4202 /* Since all FDISCs are being single threaded, we
4244 * must reset the discovery timer for ALL vports 4203 * must reset the discovery timer for ALL vports
4245 * waiting to send FDISC when one completes. 4204 * waiting to send FDISC when one completes.
@@ -4256,13 +4215,10 @@ lpfc_cmpl_els_fdisc(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
4256 /* Check for retry */ 4215 /* Check for retry */
4257 if (lpfc_els_retry(phba, cmdiocb, rspiocb)) 4216 if (lpfc_els_retry(phba, cmdiocb, rspiocb))
4258 goto out; 4217 goto out;
4259
4260 /* FDISC failed */ 4218 /* FDISC failed */
4261 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4219 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4262 "%d (%d):0124 FDISC failed. (%d/%d)\n", 4220 "0124 FDISC failed. (%d/%d)\n",
4263 phba->brd_no, vport->vpi, 4221 irsp->ulpStatus, irsp->un.ulpWord[4]);
4264 irsp->ulpStatus, irsp->un.ulpWord[4]);
4265
4266 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING) 4222 if (vport->fc_vport->vport_state == FC_VPORT_INITIALIZING)
4267 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4223 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4268 4224
@@ -4328,10 +4284,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
4328 ELS_CMD_FDISC); 4284 ELS_CMD_FDISC);
4329 if (!elsiocb) { 4285 if (!elsiocb) {
4330 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4286 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4331 4287 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4332 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4288 "0255 Issue FDISC: no IOCB\n");
4333 "%d (%d):0255 Issue FDISC: no IOCB\n",
4334 phba->brd_no, vport->vpi);
4335 return 1; 4289 return 1;
4336 } 4290 }
4337 4291
@@ -4377,11 +4331,8 @@ lpfc_issue_els_fdisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
4377 if (rc == IOCB_ERROR) { 4331 if (rc == IOCB_ERROR) {
4378 lpfc_els_free_iocb(phba, elsiocb); 4332 lpfc_els_free_iocb(phba, elsiocb);
4379 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 4333 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
4380 4334 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
4381 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 4335 "0256 Issue FDISC: Cannot send IOCB\n");
4382 "%d (%d):0256 Issue FDISC: Cannot send IOCB\n",
4383 phba->brd_no, vport->vpi);
4384
4385 return 1; 4336 return 1;
4386 } 4337 }
4387 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING); 4338 lpfc_vport_set_state(vport, FC_VPORT_INITIALIZING);
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index f2f4639eab59..c81c2b3228d6 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -83,10 +83,17 @@ lpfc_terminate_rport_io(struct fc_rport *rport)
83 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag); 83 ndlp->nlp_sid, ndlp->nlp_DID, ndlp->nlp_flag);
84 84
85 if (ndlp->nlp_sid != NLP_NO_SID) { 85 if (ndlp->nlp_sid != NLP_NO_SID) {
86 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 86 lpfc_sli_abort_iocb(ndlp->vport,
87 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); 87 &phba->sli.ring[phba->sli.fcp_ring],
88 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
88 } 89 }
89 90
91 /*
92 * A device is normally blocked for rediscovery and unblocked when
93 * devloss timeout happens. In case a vport is removed or driver
94 * unloaded before devloss timeout happens, we need to unblock here.
95 */
96 scsi_target_unblock(&rport->dev);
90 return; 97 return;
91} 98}
92 99
@@ -194,32 +201,30 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
194 if (ndlp->nlp_sid != NLP_NO_SID) { 201 if (ndlp->nlp_sid != NLP_NO_SID) {
195 warn_on = 1; 202 warn_on = 1;
196 /* flush the target */ 203 /* flush the target */
197 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 204 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
198 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); 205 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
199 } 206 }
200 if (vport->load_flag & FC_UNLOADING) 207 if (vport->load_flag & FC_UNLOADING)
201 warn_on = 0; 208 warn_on = 0;
202 209
203 if (warn_on) { 210 if (warn_on) {
204 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 211 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
205 "%d (%d):0203 Devloss timeout on " 212 "0203 Devloss timeout on "
206 "WWPN %x:%x:%x:%x:%x:%x:%x:%x " 213 "WWPN %x:%x:%x:%x:%x:%x:%x:%x "
207 "NPort x%x Data: x%x x%x x%x\n", 214 "NPort x%x Data: x%x x%x x%x\n",
208 phba->brd_no, vport->vpi, 215 *name, *(name+1), *(name+2), *(name+3),
209 *name, *(name+1), *(name+2), *(name+3), 216 *(name+4), *(name+5), *(name+6), *(name+7),
210 *(name+4), *(name+5), *(name+6), *(name+7), 217 ndlp->nlp_DID, ndlp->nlp_flag,
211 ndlp->nlp_DID, ndlp->nlp_flag, 218 ndlp->nlp_state, ndlp->nlp_rpi);
212 ndlp->nlp_state, ndlp->nlp_rpi);
213 } else { 219 } else {
214 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 220 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
215 "%d (%d):0204 Devloss timeout on " 221 "0204 Devloss timeout on "
216 "WWPN %x:%x:%x:%x:%x:%x:%x:%x " 222 "WWPN %x:%x:%x:%x:%x:%x:%x:%x "
217 "NPort x%x Data: x%x x%x x%x\n", 223 "NPort x%x Data: x%x x%x x%x\n",
218 phba->brd_no, vport->vpi, 224 *name, *(name+1), *(name+2), *(name+3),
219 *name, *(name+1), *(name+2), *(name+3), 225 *(name+4), *(name+5), *(name+6), *(name+7),
220 *(name+4), *(name+5), *(name+6), *(name+7), 226 ndlp->nlp_DID, ndlp->nlp_flag,
221 ndlp->nlp_DID, ndlp->nlp_flag, 227 ndlp->nlp_state, ndlp->nlp_rpi);
222 ndlp->nlp_state, ndlp->nlp_rpi);
223 } 228 }
224 229
225 if (!(vport->load_flag & FC_UNLOADING) && 230 if (!(vport->load_flag & FC_UNLOADING) &&
@@ -344,12 +349,14 @@ lpfc_work_list_done(struct lpfc_hba *phba)
344 349
345} 350}
346 351
347void 352static void
348lpfc_work_done(struct lpfc_hba *phba) 353lpfc_work_done(struct lpfc_hba *phba)
349{ 354{
350 struct lpfc_sli_ring *pring; 355 struct lpfc_sli_ring *pring;
351 uint32_t ha_copy, status, control, work_port_events; 356 uint32_t ha_copy, status, control, work_port_events;
357 struct lpfc_vport **vports;
352 struct lpfc_vport *vport; 358 struct lpfc_vport *vport;
359 int i;
353 360
354 spin_lock_irq(&phba->hbalock); 361 spin_lock_irq(&phba->hbalock);
355 ha_copy = phba->work_ha; 362 ha_copy = phba->work_ha;
@@ -364,48 +371,41 @@ lpfc_work_done(struct lpfc_hba *phba)
364 371
365 if (ha_copy & HA_LATT) 372 if (ha_copy & HA_LATT)
366 lpfc_handle_latt(phba); 373 lpfc_handle_latt(phba);
367 374 vports = lpfc_create_vport_work_array(phba);
368 spin_lock_irq(&phba->hbalock); 375 if (vports != NULL)
369 list_for_each_entry(vport, &phba->port_list, listentry) { 376 for(i = 0; i < LPFC_MAX_VPORTS; i++) {
370 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 377 /*
371 378 * We could have no vports in array if unloading, so if
372 if (!scsi_host_get(shost)) { 379 * this happens then just use the pport
373 continue; 380 */
381 if (vports[i] == NULL && i == 0)
382 vport = phba->pport;
383 else
384 vport = vports[i];
385 if (vport == NULL)
386 break;
387 work_port_events = vport->work_port_events;
388 if (work_port_events & WORKER_DISC_TMO)
389 lpfc_disc_timeout_handler(vport);
390 if (work_port_events & WORKER_ELS_TMO)
391 lpfc_els_timeout_handler(vport);
392 if (work_port_events & WORKER_HB_TMO)
393 lpfc_hb_timeout_handler(phba);
394 if (work_port_events & WORKER_MBOX_TMO)
395 lpfc_mbox_timeout_handler(phba);
396 if (work_port_events & WORKER_FABRIC_BLOCK_TMO)
397 lpfc_unblock_fabric_iocbs(phba);
398 if (work_port_events & WORKER_FDMI_TMO)
399 lpfc_fdmi_timeout_handler(vport);
400 if (work_port_events & WORKER_RAMP_DOWN_QUEUE)
401 lpfc_ramp_down_queue_handler(phba);
402 if (work_port_events & WORKER_RAMP_UP_QUEUE)
403 lpfc_ramp_up_queue_handler(phba);
404 spin_lock_irq(&vport->work_port_lock);
405 vport->work_port_events &= ~work_port_events;
406 spin_unlock_irq(&vport->work_port_lock);
374 } 407 }
375 spin_unlock_irq(&phba->hbalock); 408 lpfc_destroy_vport_work_array(vports);
376 work_port_events = vport->work_port_events;
377
378 if (work_port_events & WORKER_DISC_TMO)
379 lpfc_disc_timeout_handler(vport);
380
381 if (work_port_events & WORKER_ELS_TMO)
382 lpfc_els_timeout_handler(vport);
383
384 if (work_port_events & WORKER_HB_TMO)
385 lpfc_hb_timeout_handler(phba);
386
387 if (work_port_events & WORKER_MBOX_TMO)
388 lpfc_mbox_timeout_handler(phba);
389
390 if (work_port_events & WORKER_FABRIC_BLOCK_TMO)
391 lpfc_unblock_fabric_iocbs(phba);
392
393 if (work_port_events & WORKER_FDMI_TMO)
394 lpfc_fdmi_timeout_handler(vport);
395
396 if (work_port_events & WORKER_RAMP_DOWN_QUEUE)
397 lpfc_ramp_down_queue_handler(phba);
398
399 if (work_port_events & WORKER_RAMP_UP_QUEUE)
400 lpfc_ramp_up_queue_handler(phba);
401
402 spin_lock_irq(&vport->work_port_lock);
403 vport->work_port_events &= ~work_port_events;
404 spin_unlock_irq(&vport->work_port_lock);
405 scsi_host_put(shost);
406 spin_lock_irq(&phba->hbalock);
407 }
408 spin_unlock_irq(&phba->hbalock);
409 409
410 pring = &phba->sli.ring[LPFC_ELS_RING]; 410 pring = &phba->sli.ring[LPFC_ELS_RING];
411 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); 411 status = (ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING)));
@@ -426,10 +426,19 @@ lpfc_work_done(struct lpfc_hba *phba)
426 spin_lock_irq(&phba->hbalock); 426 spin_lock_irq(&phba->hbalock);
427 control = readl(phba->HCregaddr); 427 control = readl(phba->HCregaddr);
428 if (!(control & (HC_R0INT_ENA << LPFC_ELS_RING))) { 428 if (!(control & (HC_R0INT_ENA << LPFC_ELS_RING))) {
429 lpfc_debugfs_slow_ring_trc(phba,
430 "WRK Enable ring: cntl:x%x hacopy:x%x",
431 control, ha_copy, 0);
432
429 control |= (HC_R0INT_ENA << LPFC_ELS_RING); 433 control |= (HC_R0INT_ENA << LPFC_ELS_RING);
430 writel(control, phba->HCregaddr); 434 writel(control, phba->HCregaddr);
431 readl(phba->HCregaddr); /* flush */ 435 readl(phba->HCregaddr); /* flush */
432 } 436 }
437 else {
438 lpfc_debugfs_slow_ring_trc(phba,
439 "WRK Ring ok: cntl:x%x hacopy:x%x",
440 control, ha_copy, 0);
441 }
433 spin_unlock_irq(&phba->hbalock); 442 spin_unlock_irq(&phba->hbalock);
434 } 443 }
435 lpfc_work_list_done(phba); 444 lpfc_work_list_done(phba);
@@ -439,32 +448,22 @@ static int
439check_work_wait_done(struct lpfc_hba *phba) 448check_work_wait_done(struct lpfc_hba *phba)
440{ 449{
441 struct lpfc_vport *vport; 450 struct lpfc_vport *vport;
442 struct lpfc_sli_ring *pring; 451 struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
443 int rc = 0; 452 int rc = 0;
444 453
445 spin_lock_irq(&phba->hbalock); 454 spin_lock_irq(&phba->hbalock);
446 list_for_each_entry(vport, &phba->port_list, listentry) { 455 list_for_each_entry(vport, &phba->port_list, listentry) {
447 if (vport->work_port_events) { 456 if (vport->work_port_events) {
448 rc = 1; 457 rc = 1;
449 goto exit; 458 break;
450 } 459 }
451 } 460 }
452 461 if (rc || phba->work_ha || (!list_empty(&phba->work_list)) ||
453 if (phba->work_ha || (!list_empty(&phba->work_list)) || 462 kthread_should_stop() || pring->flag & LPFC_DEFERRED_RING_EVENT) {
454 kthread_should_stop()) {
455 rc = 1;
456 goto exit;
457 }
458
459 pring = &phba->sli.ring[LPFC_ELS_RING];
460 if (pring->flag & LPFC_DEFERRED_RING_EVENT)
461 rc = 1; 463 rc = 1;
462exit:
463 if (rc)
464 phba->work_found++; 464 phba->work_found++;
465 else 465 } else
466 phba->work_found = 0; 466 phba->work_found = 0;
467
468 spin_unlock_irq(&phba->hbalock); 467 spin_unlock_irq(&phba->hbalock);
469 return rc; 468 return rc;
470} 469}
@@ -592,7 +591,6 @@ lpfc_linkdown_port(struct lpfc_vport *vport)
592 591
593 /* free any ndlp's on unused list */ 592 /* free any ndlp's on unused list */
594 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) 593 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp)
595 /* free any ndlp's in unused state */
596 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) 594 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE)
597 lpfc_drop_node(vport, ndlp); 595 lpfc_drop_node(vport, ndlp);
598 596
@@ -605,8 +603,9 @@ lpfc_linkdown(struct lpfc_hba *phba)
605{ 603{
606 struct lpfc_vport *vport = phba->pport; 604 struct lpfc_vport *vport = phba->pport;
607 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 605 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
608 struct lpfc_vport *port_iterator; 606 struct lpfc_vport **vports;
609 LPFC_MBOXQ_t *mb; 607 LPFC_MBOXQ_t *mb;
608 int i;
610 609
611 if (phba->link_state == LPFC_LINK_DOWN) { 610 if (phba->link_state == LPFC_LINK_DOWN) {
612 return 0; 611 return 0;
@@ -617,13 +616,13 @@ lpfc_linkdown(struct lpfc_hba *phba)
617 phba->pport->fc_flag &= ~FC_LBIT; 616 phba->pport->fc_flag &= ~FC_LBIT;
618 } 617 }
619 spin_unlock_irq(&phba->hbalock); 618 spin_unlock_irq(&phba->hbalock);
620 619 vports = lpfc_create_vport_work_array(phba);
621 list_for_each_entry(port_iterator, &phba->port_list, listentry) { 620 if (vports != NULL)
622 621 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
623 /* Issue a LINK DOWN event to all nodes */ 622 /* Issue a LINK DOWN event to all nodes */
624 lpfc_linkdown_port(port_iterator); 623 lpfc_linkdown_port(vports[i]);
625 } 624 }
626 625 lpfc_destroy_vport_work_array(vports);
627 /* Clean up any firmware default rpi's */ 626 /* Clean up any firmware default rpi's */
628 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 627 mb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
629 if (mb) { 628 if (mb) {
@@ -724,7 +723,8 @@ lpfc_linkup_port(struct lpfc_vport *vport)
724static int 723static int
725lpfc_linkup(struct lpfc_hba *phba) 724lpfc_linkup(struct lpfc_hba *phba)
726{ 725{
727 struct lpfc_vport *vport; 726 struct lpfc_vport **vports;
727 int i;
728 728
729 phba->link_state = LPFC_LINK_UP; 729 phba->link_state = LPFC_LINK_UP;
730 730
@@ -732,9 +732,11 @@ lpfc_linkup(struct lpfc_hba *phba)
732 clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags); 732 clear_bit(FABRIC_COMANDS_BLOCKED, &phba->bit_flags);
733 del_timer_sync(&phba->fabric_block_timer); 733 del_timer_sync(&phba->fabric_block_timer);
734 734
735 list_for_each_entry(vport, &phba->port_list, listentry) { 735 vports = lpfc_create_vport_work_array(phba);
736 lpfc_linkup_port(vport); 736 if (vports != NULL)
737 } 737 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++)
738 lpfc_linkup_port(vports[i]);
739 lpfc_destroy_vport_work_array(vports);
738 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) 740 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)
739 lpfc_issue_clear_la(phba, phba->pport); 741 lpfc_issue_clear_la(phba, phba->pport);
740 742
@@ -764,12 +766,10 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
764 /* Check for error */ 766 /* Check for error */
765 if ((mb->mbxStatus) && (mb->mbxStatus != 0x1601)) { 767 if ((mb->mbxStatus) && (mb->mbxStatus != 0x1601)) {
766 /* CLEAR_LA mbox error <mbxStatus> state <hba_state> */ 768 /* CLEAR_LA mbox error <mbxStatus> state <hba_state> */
767 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 769 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
768 "%d (%d):0320 CLEAR_LA mbxStatus error x%x hba " 770 "0320 CLEAR_LA mbxStatus error x%x hba "
769 "state x%x\n", 771 "state x%x\n",
770 phba->brd_no, vport->vpi, mb->mbxStatus, 772 mb->mbxStatus, vport->port_state);
771 vport->port_state);
772
773 phba->link_state = LPFC_HBA_ERROR; 773 phba->link_state = LPFC_HBA_ERROR;
774 goto out; 774 goto out;
775 } 775 }
@@ -801,10 +801,8 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
801 801
802out: 802out:
803 /* Device Discovery completes */ 803 /* Device Discovery completes */
804 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 804 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
805 "%d (%d):0225 Device Discovery completes\n", 805 "0225 Device Discovery completes\n");
806 phba->brd_no, vport->vpi);
807
808 mempool_free(pmb, phba->mbox_mem_pool); 806 mempool_free(pmb, phba->mbox_mem_pool);
809 807
810 spin_lock_irq(shost->host_lock); 808 spin_lock_irq(shost->host_lock);
@@ -861,19 +859,17 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
861 return; 859 return;
862 860
863out: 861out:
864 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 862 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
865 "%d (%d):0306 CONFIG_LINK mbxStatus error x%x " 863 "0306 CONFIG_LINK mbxStatus error x%x "
866 "HBA state x%x\n", 864 "HBA state x%x\n",
867 phba->brd_no, vport->vpi, pmb->mb.mbxStatus, 865 pmb->mb.mbxStatus, vport->port_state);
868 vport->port_state);
869
870 mempool_free(pmb, phba->mbox_mem_pool); 866 mempool_free(pmb, phba->mbox_mem_pool);
871 867
872 lpfc_linkdown(phba); 868 lpfc_linkdown(phba);
873 869
874 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 870 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
875 "%d (%d):0200 CONFIG_LINK bad hba state x%x\n", 871 "0200 CONFIG_LINK bad hba state x%x\n",
876 phba->brd_no, vport->vpi, vport->port_state); 872 vport->port_state);
877 873
878 lpfc_issue_clear_la(phba, vport); 874 lpfc_issue_clear_la(phba, vport);
879 return; 875 return;
@@ -890,12 +886,10 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
890 /* Check for error */ 886 /* Check for error */
891 if (mb->mbxStatus) { 887 if (mb->mbxStatus) {
892 /* READ_SPARAM mbox error <mbxStatus> state <hba_state> */ 888 /* READ_SPARAM mbox error <mbxStatus> state <hba_state> */
893 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 889 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
894 "%d (%d):0319 READ_SPARAM mbxStatus error x%x " 890 "0319 READ_SPARAM mbxStatus error x%x "
895 "hba state x%x>\n", 891 "hba state x%x>\n",
896 phba->brd_no, vport->vpi, mb->mbxStatus, 892 mb->mbxStatus, vport->port_state);
897 vport->port_state);
898
899 lpfc_linkdown(phba); 893 lpfc_linkdown(phba);
900 goto out; 894 goto out;
901 } 895 }
@@ -978,7 +972,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
978 if (i == 0) { 972 if (i == 0) {
979 phba->alpa_map[0] = 0; 973 phba->alpa_map[0] = 0;
980 } else { 974 } else {
981 if (phba->cfg_log_verbose & LOG_LINK_EVENT) { 975 if (vport->cfg_log_verbose & LOG_LINK_EVENT) {
982 int numalpa, j, k; 976 int numalpa, j, k;
983 union { 977 union {
984 uint8_t pamap[16]; 978 uint8_t pamap[16];
@@ -1004,10 +998,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
1004 lpfc_printf_log(phba, 998 lpfc_printf_log(phba,
1005 KERN_WARNING, 999 KERN_WARNING,
1006 LOG_LINK_EVENT, 1000 LOG_LINK_EVENT,
1007 "%d:1304 Link Up Event " 1001 "1304 Link Up Event "
1008 "ALPA map Data: x%x " 1002 "ALPA map Data: x%x "
1009 "x%x x%x x%x\n", 1003 "x%x x%x x%x\n",
1010 phba->brd_no,
1011 un.pa.wd1, un.pa.wd2, 1004 un.pa.wd1, un.pa.wd2,
1012 un.pa.wd3, un.pa.wd4); 1005 un.pa.wd3, un.pa.wd4);
1013 } 1006 }
@@ -1015,7 +1008,7 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
1015 } 1008 }
1016 } else { 1009 } else {
1017 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) { 1010 if (!(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) {
1018 if (phba->max_vpi && phba->cfg_npiv_enable && 1011 if (phba->max_vpi && phba->cfg_enable_npiv &&
1019 (phba->sli_rev == 3)) 1012 (phba->sli_rev == 3))
1020 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; 1013 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED;
1021 } 1014 }
@@ -1055,11 +1048,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
1055 } 1048 }
1056out: 1049out:
1057 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1050 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1058 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 1051 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
1059 "%d (%d):0263 Discovery Mailbox error: state: 0x%x : %p %p\n", 1052 "0263 Discovery Mailbox error: state: 0x%x : %p %p\n",
1060 phba->brd_no, vport->vpi, 1053 vport->port_state, sparam_mbox, cfglink_mbox);
1061 vport->port_state, sparam_mbox, cfglink_mbox);
1062
1063 lpfc_issue_clear_la(phba, vport); 1054 lpfc_issue_clear_la(phba, vport);
1064 return; 1055 return;
1065} 1056}
@@ -1100,8 +1091,8 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1100 /* Check for error */ 1091 /* Check for error */
1101 if (mb->mbxStatus) { 1092 if (mb->mbxStatus) {
1102 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 1093 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
1103 "%d:1307 READ_LA mbox error x%x state x%x\n", 1094 "1307 READ_LA mbox error x%x state x%x\n",
1104 phba->brd_no, mb->mbxStatus, vport->port_state); 1095 mb->mbxStatus, vport->port_state);
1105 lpfc_mbx_issue_link_down(phba); 1096 lpfc_mbx_issue_link_down(phba);
1106 phba->link_state = LPFC_HBA_ERROR; 1097 phba->link_state = LPFC_HBA_ERROR;
1107 goto lpfc_mbx_cmpl_read_la_free_mbuf; 1098 goto lpfc_mbx_cmpl_read_la_free_mbuf;
@@ -1132,26 +1123,26 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1132 phba->fc_stat.LinkUp++; 1123 phba->fc_stat.LinkUp++;
1133 if (phba->link_flag & LS_LOOPBACK_MODE) { 1124 if (phba->link_flag & LS_LOOPBACK_MODE) {
1134 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 1125 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
1135 "%d:1306 Link Up Event in loop back mode " 1126 "1306 Link Up Event in loop back mode "
1136 "x%x received Data: x%x x%x x%x x%x\n", 1127 "x%x received Data: x%x x%x x%x x%x\n",
1137 phba->brd_no, la->eventTag, phba->fc_eventTag, 1128 la->eventTag, phba->fc_eventTag,
1138 la->granted_AL_PA, la->UlnkSpeed, 1129 la->granted_AL_PA, la->UlnkSpeed,
1139 phba->alpa_map[0]); 1130 phba->alpa_map[0]);
1140 } else { 1131 } else {
1141 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 1132 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
1142 "%d:1303 Link Up Event x%x received " 1133 "1303 Link Up Event x%x received "
1143 "Data: x%x x%x x%x x%x\n", 1134 "Data: x%x x%x x%x x%x\n",
1144 phba->brd_no, la->eventTag, phba->fc_eventTag, 1135 la->eventTag, phba->fc_eventTag,
1145 la->granted_AL_PA, la->UlnkSpeed, 1136 la->granted_AL_PA, la->UlnkSpeed,
1146 phba->alpa_map[0]); 1137 phba->alpa_map[0]);
1147 } 1138 }
1148 lpfc_mbx_process_link_up(phba, la); 1139 lpfc_mbx_process_link_up(phba, la);
1149 } else { 1140 } else {
1150 phba->fc_stat.LinkDown++; 1141 phba->fc_stat.LinkDown++;
1151 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 1142 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
1152 "%d:1305 Link Down Event x%x received " 1143 "1305 Link Down Event x%x received "
1153 "Data: x%x x%x x%x\n", 1144 "Data: x%x x%x x%x\n",
1154 phba->brd_no, la->eventTag, phba->fc_eventTag, 1145 la->eventTag, phba->fc_eventTag,
1155 phba->pport->port_state, vport->fc_flag); 1146 phba->pport->port_state, vport->fc_flag);
1156 lpfc_mbx_issue_link_down(phba); 1147 lpfc_mbx_issue_link_down(phba);
1157 } 1148 }
@@ -1199,10 +1190,9 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1199 case 0x0011: 1190 case 0x0011:
1200 case 0x0020: 1191 case 0x0020:
1201 case 0x9700: 1192 case 0x9700:
1202 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1193 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1203 "%d (%d):0911 cmpl_unreg_vpi, " 1194 "0911 cmpl_unreg_vpi, mb status = 0x%x\n",
1204 "mb status = 0x%x\n", 1195 mb->mbxStatus);
1205 phba->brd_no, vport->vpi, mb->mbxStatus);
1206 break; 1196 break;
1207 } 1197 }
1208 vport->unreg_vpi_cmpl = VPORT_OK; 1198 vport->unreg_vpi_cmpl = VPORT_OK;
@@ -1231,9 +1221,8 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport)
1231 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi; 1221 mbox->mbox_cmpl = lpfc_mbx_cmpl_unreg_vpi;
1232 rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB)); 1222 rc = lpfc_sli_issue_mbox(phba, mbox, (MBX_NOWAIT | MBX_STOP_IOCB));
1233 if (rc == MBX_NOT_FINISHED) { 1223 if (rc == MBX_NOT_FINISHED) {
1234 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_VPORT, 1224 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
1235 "%d (%d):1800 Could not issue unreg_vpi\n", 1225 "1800 Could not issue unreg_vpi\n");
1236 phba->brd_no, vport->vpi);
1237 mempool_free(mbox, phba->mbox_mem_pool); 1226 mempool_free(mbox, phba->mbox_mem_pool);
1238 vport->unreg_vpi_cmpl = VPORT_ERROR; 1227 vport->unreg_vpi_cmpl = VPORT_ERROR;
1239 } 1228 }
@@ -1250,9 +1239,9 @@ lpfc_mbx_cmpl_reg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1250 case 0x0011: 1239 case 0x0011:
1251 case 0x9601: 1240 case 0x9601:
1252 case 0x9602: 1241 case 0x9602:
1253 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1242 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1254 "%d (%d):0912 cmpl_reg_vpi, mb status = 0x%x\n", 1243 "0912 cmpl_reg_vpi, mb status = 0x%x\n",
1255 phba->brd_no, vport->vpi, mb->mbxStatus); 1244 mb->mbxStatus);
1256 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1245 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1257 spin_lock_irq(shost->host_lock); 1246 spin_lock_irq(shost->host_lock);
1258 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP); 1247 vport->fc_flag &= ~(FC_FABRIC | FC_PUBLIC_LOOP);
@@ -1289,15 +1278,15 @@ void
1289lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) 1278lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1290{ 1279{
1291 struct lpfc_vport *vport = pmb->vport; 1280 struct lpfc_vport *vport = pmb->vport;
1292 struct lpfc_vport *next_vport;
1293 MAILBOX_t *mb = &pmb->mb; 1281 MAILBOX_t *mb = &pmb->mb;
1294 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1); 1282 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *) (pmb->context1);
1295 struct lpfc_nodelist *ndlp; 1283 struct lpfc_nodelist *ndlp;
1296 ndlp = (struct lpfc_nodelist *) pmb->context2; 1284 struct lpfc_vport **vports;
1285 int i;
1297 1286
1287 ndlp = (struct lpfc_nodelist *) pmb->context2;
1298 pmb->context1 = NULL; 1288 pmb->context1 = NULL;
1299 pmb->context2 = NULL; 1289 pmb->context2 = NULL;
1300
1301 if (mb->mbxStatus) { 1290 if (mb->mbxStatus) {
1302 lpfc_mbuf_free(phba, mp->virt, mp->phys); 1291 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1303 kfree(mp); 1292 kfree(mp);
@@ -1314,10 +1303,9 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1314 } 1303 }
1315 1304
1316 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1305 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1317 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 1306 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX,
1318 "%d (%d):0258 Register Fabric login error: 0x%x\n", 1307 "0258 Register Fabric login error: 0x%x\n",
1319 phba->brd_no, vport->vpi, mb->mbxStatus); 1308 mb->mbxStatus);
1320
1321 return; 1309 return;
1322 } 1310 }
1323 1311
@@ -1328,21 +1316,26 @@ lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
1328 lpfc_nlp_put(ndlp); /* Drop the reference from the mbox */ 1316 lpfc_nlp_put(ndlp); /* Drop the reference from the mbox */
1329 1317
1330 if (vport->port_state == LPFC_FABRIC_CFG_LINK) { 1318 if (vport->port_state == LPFC_FABRIC_CFG_LINK) {
1331 list_for_each_entry(next_vport, &phba->port_list, listentry) { 1319 vports = lpfc_create_vport_work_array(phba);
1332 if (next_vport->port_type == LPFC_PHYSICAL_PORT) 1320 if (vports != NULL)
1333 continue; 1321 for(i = 0;
1334 1322 i < LPFC_MAX_VPORTS && vports[i] != NULL;
1335 if (phba->link_flag & LS_NPIV_FAB_SUPPORTED) 1323 i++) {
1336 lpfc_initial_fdisc(next_vport); 1324 if (vports[i]->port_type == LPFC_PHYSICAL_PORT)
1337 else if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { 1325 continue;
1338 lpfc_vport_set_state(vport, 1326 if (phba->link_flag & LS_NPIV_FAB_SUPPORTED)
1339 FC_VPORT_NO_FABRIC_SUPP); 1327 lpfc_initial_fdisc(vports[i]);
1340 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1328 else if (phba->sli3_options &
1341 "%d (%d):0259 No NPIV Fabric " 1329 LPFC_SLI3_NPIV_ENABLED) {
1342 "support\n", 1330 lpfc_vport_set_state(vports[i],
1343 phba->brd_no, vport->vpi); 1331 FC_VPORT_NO_FABRIC_SUPP);
1332 lpfc_printf_vlog(vport, KERN_ERR,
1333 LOG_ELS,
1334 "0259 No NPIV "
1335 "Fabric support\n");
1336 }
1344 } 1337 }
1345 } 1338 lpfc_destroy_vport_work_array(vports);
1346 lpfc_do_scr_ns_plogi(phba, vport); 1339 lpfc_do_scr_ns_plogi(phba, vport);
1347 } 1340 }
1348 1341
@@ -1386,9 +1379,9 @@ out:
1386 return; 1379 return;
1387 } 1380 }
1388 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 1381 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
1389 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 1382 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
1390 "%d (%d):0260 Register NameServer error: 0x%x\n", 1383 "0260 Register NameServer error: 0x%x\n",
1391 phba->brd_no, vport->vpi, mb->mbxStatus); 1384 mb->mbxStatus);
1392 return; 1385 return;
1393 } 1386 }
1394 1387
@@ -1598,7 +1591,7 @@ lpfc_nlp_state_name(char *buffer, size_t size, int state)
1598 [NLP_STE_NPR_NODE] = "NPR", 1591 [NLP_STE_NPR_NODE] = "NPR",
1599 }; 1592 };
1600 1593
1601 if (state < ARRAY_SIZE(states) && states[state]) 1594 if (state < NLP_STE_MAX_STATE && states[state])
1602 strlcpy(buffer, states[state], size); 1595 strlcpy(buffer, states[state], size);
1603 else 1596 else
1604 snprintf(buffer, size, "unknown (%d)", state); 1597 snprintf(buffer, size, "unknown (%d)", state);
@@ -1613,12 +1606,11 @@ lpfc_nlp_set_state(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1613 int old_state = ndlp->nlp_state; 1606 int old_state = ndlp->nlp_state;
1614 char name1[16], name2[16]; 1607 char name1[16], name2[16];
1615 1608
1616 lpfc_printf_log(vport->phba, KERN_INFO, LOG_NODE, 1609 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1617 "%d (%d):0904 NPort state transition x%06x, %s -> %s\n", 1610 "0904 NPort state transition x%06x, %s -> %s\n",
1618 vport->phba->brd_no, vport->vpi, 1611 ndlp->nlp_DID,
1619 ndlp->nlp_DID, 1612 lpfc_nlp_state_name(name1, sizeof(name1), old_state),
1620 lpfc_nlp_state_name(name1, sizeof(name1), old_state), 1613 lpfc_nlp_state_name(name2, sizeof(name2), state));
1621 lpfc_nlp_state_name(name2, sizeof(name2), state));
1622 1614
1623 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE, 1615 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_NODE,
1624 "node statechg did:x%x old:%d ste:%d", 1616 "node statechg did:x%x old:%d ste:%d",
@@ -1664,16 +1656,7 @@ lpfc_dequeue_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1664void 1656void
1665lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 1657lpfc_drop_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1666{ 1658{
1667 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1659 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
1668
1669 if ((ndlp->nlp_flag & NLP_DELAY_TMO) != 0)
1670 lpfc_cancel_retry_delay_tmo(vport, ndlp);
1671 if (ndlp->nlp_state && !list_empty(&ndlp->nlp_listp))
1672 lpfc_nlp_counters(vport, ndlp->nlp_state, -1);
1673 spin_lock_irq(shost->host_lock);
1674 list_del_init(&ndlp->nlp_listp);
1675 ndlp->nlp_flag &= ~NLP_TARGET_REMOVE;
1676 spin_unlock_irq(shost->host_lock);
1677 lpfc_nlp_put(ndlp); 1660 lpfc_nlp_put(ndlp);
1678} 1661}
1679 1662
@@ -1710,12 +1693,12 @@ lpfc_set_disctmo(struct lpfc_vport *vport)
1710 spin_unlock_irq(shost->host_lock); 1693 spin_unlock_irq(shost->host_lock);
1711 1694
1712 /* Start Discovery Timer state <hba_state> */ 1695 /* Start Discovery Timer state <hba_state> */
1713 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1696 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1714 "%d (%d):0247 Start Discovery Timer state x%x " 1697 "0247 Start Discovery Timer state x%x "
1715 "Data: x%x x%lx x%x x%x\n", 1698 "Data: x%x x%lx x%x x%x\n",
1716 phba->brd_no, vport->vpi, vport->port_state, tmo, 1699 vport->port_state, tmo,
1717 (unsigned long)&vport->fc_disctmo, vport->fc_plogi_cnt, 1700 (unsigned long)&vport->fc_disctmo, vport->fc_plogi_cnt,
1718 vport->fc_adisc_cnt); 1701 vport->fc_adisc_cnt);
1719 1702
1720 return; 1703 return;
1721} 1704}
@@ -1727,7 +1710,6 @@ int
1727lpfc_can_disctmo(struct lpfc_vport *vport) 1710lpfc_can_disctmo(struct lpfc_vport *vport)
1728{ 1711{
1729 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1712 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1730 struct lpfc_hba *phba = vport->phba;
1731 unsigned long iflags; 1713 unsigned long iflags;
1732 1714
1733 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD, 1715 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
@@ -1746,13 +1728,11 @@ lpfc_can_disctmo(struct lpfc_vport *vport)
1746 } 1728 }
1747 1729
1748 /* Cancel Discovery Timer state <hba_state> */ 1730 /* Cancel Discovery Timer state <hba_state> */
1749 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 1731 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1750 "%d (%d):0248 Cancel Discovery Timer state x%x " 1732 "0248 Cancel Discovery Timer state x%x "
1751 "Data: x%x x%x x%x\n", 1733 "Data: x%x x%x x%x\n",
1752 phba->brd_no, vport->vpi, vport->port_state, 1734 vport->port_state, vport->fc_flag,
1753 vport->fc_flag, vport->fc_plogi_cnt, 1735 vport->fc_plogi_cnt, vport->fc_adisc_cnt);
1754 vport->fc_adisc_cnt);
1755
1756 return 0; 1736 return 0;
1757} 1737}
1758 1738
@@ -1935,10 +1915,9 @@ lpfc_unreg_default_rpis(struct lpfc_vport *vport)
1935 rc = lpfc_sli_issue_mbox(phba, mbox, 1915 rc = lpfc_sli_issue_mbox(phba, mbox,
1936 (MBX_NOWAIT | MBX_STOP_IOCB)); 1916 (MBX_NOWAIT | MBX_STOP_IOCB));
1937 if (rc == MBX_NOT_FINISHED) { 1917 if (rc == MBX_NOT_FINISHED) {
1938 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_VPORT, 1918 lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX | LOG_VPORT,
1939 "%d (%d):1815 Could not issue " 1919 "1815 Could not issue "
1940 "unreg_did (default rpis)\n", 1920 "unreg_did (default rpis)\n");
1941 phba->brd_no, vport->vpi);
1942 mempool_free(mbox, phba->mbox_mem_pool); 1921 mempool_free(mbox, phba->mbox_mem_pool);
1943 } 1922 }
1944 } 1923 }
@@ -1957,12 +1936,11 @@ lpfc_cleanup_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
1957 struct lpfc_dmabuf *mp; 1936 struct lpfc_dmabuf *mp;
1958 1937
1959 /* Cleanup node for NPort <nlp_DID> */ 1938 /* Cleanup node for NPort <nlp_DID> */
1960 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1939 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
1961 "%d (%d):0900 Cleanup node for NPort x%x " 1940 "0900 Cleanup node for NPort x%x "
1962 "Data: x%x x%x x%x\n", 1941 "Data: x%x x%x x%x\n",
1963 phba->brd_no, vport->vpi, ndlp->nlp_DID, ndlp->nlp_flag, 1942 ndlp->nlp_DID, ndlp->nlp_flag,
1964 ndlp->nlp_state, ndlp->nlp_rpi); 1943 ndlp->nlp_state, ndlp->nlp_rpi);
1965
1966 lpfc_dequeue_node(vport, ndlp); 1944 lpfc_dequeue_node(vport, ndlp);
1967 1945
1968 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */ 1946 /* cleanup any ndlp on mbox q waiting for reglogin cmpl */
@@ -2094,7 +2072,6 @@ lpfc_matchdid(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2094static struct lpfc_nodelist * 2072static struct lpfc_nodelist *
2095__lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did) 2073__lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did)
2096{ 2074{
2097 struct lpfc_hba *phba = vport->phba;
2098 struct lpfc_nodelist *ndlp; 2075 struct lpfc_nodelist *ndlp;
2099 uint32_t data1; 2076 uint32_t data1;
2100 2077
@@ -2104,20 +2081,18 @@ __lpfc_findnode_did(struct lpfc_vport *vport, uint32_t did)
2104 ((uint32_t) ndlp->nlp_xri << 16) | 2081 ((uint32_t) ndlp->nlp_xri << 16) |
2105 ((uint32_t) ndlp->nlp_type << 8) | 2082 ((uint32_t) ndlp->nlp_type << 8) |
2106 ((uint32_t) ndlp->nlp_rpi & 0xff)); 2083 ((uint32_t) ndlp->nlp_rpi & 0xff));
2107 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 2084 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
2108 "%d (%d):0929 FIND node DID " 2085 "0929 FIND node DID "
2109 " Data: x%p x%x x%x x%x\n", 2086 "Data: x%p x%x x%x x%x\n",
2110 phba->brd_no, vport->vpi, 2087 ndlp, ndlp->nlp_DID,
2111 ndlp, ndlp->nlp_DID, 2088 ndlp->nlp_flag, data1);
2112 ndlp->nlp_flag, data1);
2113 return ndlp; 2089 return ndlp;
2114 } 2090 }
2115 } 2091 }
2116 2092
2117 /* FIND node did <did> NOT FOUND */ 2093 /* FIND node did <did> NOT FOUND */
2118 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 2094 lpfc_printf_vlog(vport, KERN_INFO, LOG_NODE,
2119 "%d (%d):0932 FIND node did x%x NOT FOUND.\n", 2095 "0932 FIND node did x%x NOT FOUND.\n", did);
2120 phba->brd_no, vport->vpi, did);
2121 return NULL; 2096 return NULL;
2122} 2097}
2123 2098
@@ -2208,7 +2183,7 @@ lpfc_disc_list_loopmap(struct lpfc_vport *vport)
2208 /* If cfg_scan_down is set, start from highest 2183 /* If cfg_scan_down is set, start from highest
2209 * ALPA (0xef) to lowest (0x1). 2184 * ALPA (0xef) to lowest (0x1).
2210 */ 2185 */
2211 if (phba->cfg_scan_down) 2186 if (vport->cfg_scan_down)
2212 index = j; 2187 index = j;
2213 else 2188 else
2214 index = FC_MAXLOOP - j - 1; 2189 index = FC_MAXLOOP - j - 1;
@@ -2309,12 +2284,11 @@ lpfc_disc_start(struct lpfc_vport *vport)
2309 vport->num_disc_nodes = 0; 2284 vport->num_disc_nodes = 0;
2310 2285
2311 /* Start Discovery state <hba_state> */ 2286 /* Start Discovery state <hba_state> */
2312 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2287 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2313 "%d (%d):0202 Start Discovery hba state x%x " 2288 "0202 Start Discovery hba state x%x "
2314 "Data: x%x x%x x%x\n", 2289 "Data: x%x x%x x%x\n",
2315 phba->brd_no, vport->vpi, vport->port_state, 2290 vport->port_state, vport->fc_flag, vport->fc_plogi_cnt,
2316 vport->fc_flag, vport->fc_plogi_cnt, 2291 vport->fc_adisc_cnt);
2317 vport->fc_adisc_cnt);
2318 2292
2319 /* First do ADISCs - if any */ 2293 /* First do ADISCs - if any */
2320 num_sent = lpfc_els_disc_adisc(vport); 2294 num_sent = lpfc_els_disc_adisc(vport);
@@ -2532,10 +2506,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2532 * FAN 2506 * FAN
2533 */ 2507 */
2534 /* FAN timeout */ 2508 /* FAN timeout */
2535 lpfc_printf_log(phba, KERN_WARNING, LOG_DISCOVERY, 2509 lpfc_printf_vlog(vport, KERN_WARNING, LOG_DISCOVERY,
2536 "%d (%d):0221 FAN timeout\n", 2510 "0221 FAN timeout\n");
2537 phba->brd_no, vport->vpi);
2538
2539 /* Start discovery by sending FLOGI, clean up old rpis */ 2511 /* Start discovery by sending FLOGI, clean up old rpis */
2540 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, 2512 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes,
2541 nlp_listp) { 2513 nlp_listp) {
@@ -2562,10 +2534,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2562 case LPFC_FLOGI: 2534 case LPFC_FLOGI:
2563 /* port_state is identically LPFC_FLOGI while waiting for FLOGI cmpl */ 2535 /* port_state is identically LPFC_FLOGI while waiting for FLOGI cmpl */
2564 /* Initial FLOGI timeout */ 2536 /* Initial FLOGI timeout */
2565 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2537 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2566 "%d (%d):0222 Initial %s timeout\n", 2538 "0222 Initial %s timeout\n",
2567 phba->brd_no, vport->vpi, 2539 vport->vpi ? "FLOGI" : "FDISC");
2568 vport->vpi ? "FLOGI" : "FDISC");
2569 2540
2570 /* Assume no Fabric and go on with discovery. 2541 /* Assume no Fabric and go on with discovery.
2571 * Check for outstanding ELS FLOGI to abort. 2542 * Check for outstanding ELS FLOGI to abort.
@@ -2581,11 +2552,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2581 case LPFC_FABRIC_CFG_LINK: 2552 case LPFC_FABRIC_CFG_LINK:
2582 /* hba_state is identically LPFC_FABRIC_CFG_LINK while waiting for 2553 /* hba_state is identically LPFC_FABRIC_CFG_LINK while waiting for
2583 NameServer login */ 2554 NameServer login */
2584 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2555 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2585 "%d (%d):0223 Timeout while waiting for " 2556 "0223 Timeout while waiting for "
2586 "NameServer login\n", 2557 "NameServer login\n");
2587 phba->brd_no, vport->vpi);
2588
2589 /* Next look for NameServer ndlp */ 2558 /* Next look for NameServer ndlp */
2590 ndlp = lpfc_findnode_did(vport, NameServer_DID); 2559 ndlp = lpfc_findnode_did(vport, NameServer_DID);
2591 if (ndlp) 2560 if (ndlp)
@@ -2596,11 +2565,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2596 2565
2597 case LPFC_NS_QRY: 2566 case LPFC_NS_QRY:
2598 /* Check for wait for NameServer Rsp timeout */ 2567 /* Check for wait for NameServer Rsp timeout */
2599 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2568 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2600 "%d (%d):0224 NameServer Query timeout " 2569 "0224 NameServer Query timeout "
2601 "Data: x%x x%x\n", 2570 "Data: x%x x%x\n",
2602 phba->brd_no, vport->vpi, 2571 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2603 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2604 2572
2605 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) { 2573 if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
2606 /* Try it one more time */ 2574 /* Try it one more time */
@@ -2627,10 +2595,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2627 /* Setup and issue mailbox INITIALIZE LINK command */ 2595 /* Setup and issue mailbox INITIALIZE LINK command */
2628 initlinkmbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 2596 initlinkmbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2629 if (!initlinkmbox) { 2597 if (!initlinkmbox) {
2630 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2598 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2631 "%d (%d):0206 Device Discovery " 2599 "0206 Device Discovery "
2632 "completion error\n", 2600 "completion error\n");
2633 phba->brd_no, vport->vpi);
2634 phba->link_state = LPFC_HBA_ERROR; 2601 phba->link_state = LPFC_HBA_ERROR;
2635 break; 2602 break;
2636 } 2603 }
@@ -2651,9 +2618,8 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2651 2618
2652 case LPFC_DISC_AUTH: 2619 case LPFC_DISC_AUTH:
2653 /* Node Authentication timeout */ 2620 /* Node Authentication timeout */
2654 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2621 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2655 "%d (%d):0227 Node Authentication timeout\n", 2622 "0227 Node Authentication timeout\n");
2656 phba->brd_no, vport->vpi);
2657 lpfc_disc_flush_list(vport); 2623 lpfc_disc_flush_list(vport);
2658 2624
2659 /* 2625 /*
@@ -2670,11 +2636,10 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2670 2636
2671 case LPFC_VPORT_READY: 2637 case LPFC_VPORT_READY:
2672 if (vport->fc_flag & FC_RSCN_MODE) { 2638 if (vport->fc_flag & FC_RSCN_MODE) {
2673 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2639 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2674 "%d (%d):0231 RSCN timeout Data: x%x " 2640 "0231 RSCN timeout Data: x%x "
2675 "x%x\n", 2641 "x%x\n",
2676 phba->brd_no, vport->vpi, 2642 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2677 vport->fc_ns_retry, LPFC_MAX_NS_RETRY);
2678 2643
2679 /* Cleanup any outstanding ELS commands */ 2644 /* Cleanup any outstanding ELS commands */
2680 lpfc_els_flush_cmd(vport); 2645 lpfc_els_flush_cmd(vport);
@@ -2685,20 +2650,17 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2685 break; 2650 break;
2686 2651
2687 default: 2652 default:
2688 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2653 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2689 "%d (%d):0229 Unexpected discovery timeout, " 2654 "0229 Unexpected discovery timeout, "
2690 "vport State x%x\n", 2655 "vport State x%x\n", vport->port_state);
2691 phba->brd_no, vport->vpi, vport->port_state);
2692
2693 break; 2656 break;
2694 } 2657 }
2695 2658
2696 switch (phba->link_state) { 2659 switch (phba->link_state) {
2697 case LPFC_CLEAR_LA: 2660 case LPFC_CLEAR_LA:
2698 /* CLEAR LA timeout */ 2661 /* CLEAR LA timeout */
2699 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2662 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2700 "%d (%d):0228 CLEAR LA timeout\n", 2663 "0228 CLEAR LA timeout\n");
2701 phba->brd_no, vport->vpi);
2702 clrlaerr = 1; 2664 clrlaerr = 1;
2703 break; 2665 break;
2704 2666
@@ -2709,10 +2671,9 @@ lpfc_disc_timeout_handler(struct lpfc_vport *vport)
2709 case LPFC_LINK_DOWN: 2671 case LPFC_LINK_DOWN:
2710 case LPFC_LINK_UP: 2672 case LPFC_LINK_UP:
2711 case LPFC_HBA_ERROR: 2673 case LPFC_HBA_ERROR:
2712 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 2674 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
2713 "%d (%d):0230 Unexpected timeout, hba link " 2675 "0230 Unexpected timeout, hba link "
2714 "state x%x\n", 2676 "state x%x\n", phba->link_state);
2715 phba->brd_no, vport->vpi, phba->link_state);
2716 clrlaerr = 1; 2677 clrlaerr = 1;
2717 break; 2678 break;
2718 2679
@@ -2757,7 +2718,7 @@ lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
2757 * fdmi-on=2 (supporting RPA/hostnmae) 2718 * fdmi-on=2 (supporting RPA/hostnmae)
2758 */ 2719 */
2759 2720
2760 if (phba->cfg_fdmi_on == 1) 2721 if (vport->cfg_fdmi_on == 1)
2761 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA); 2722 lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA);
2762 else 2723 else
2763 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60); 2724 mod_timer(&vport->fc_fdmitmo, jiffies + HZ * 60);
@@ -2854,32 +2815,6 @@ lpfc_findnode_wwpn(struct lpfc_vport *vport, struct lpfc_name *wwpn)
2854} 2815}
2855 2816
2856void 2817void
2857lpfc_dev_loss_delay(unsigned long ptr)
2858{
2859 struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) ptr;
2860 struct lpfc_vport *vport = ndlp->vport;
2861 struct lpfc_hba *phba = vport->phba;
2862 struct lpfc_work_evt *evtp = &ndlp->dev_loss_evt;
2863 unsigned long flags;
2864
2865 evtp = &ndlp->dev_loss_evt;
2866
2867 spin_lock_irqsave(&phba->hbalock, flags);
2868 if (!list_empty(&evtp->evt_listp)) {
2869 spin_unlock_irqrestore(&phba->hbalock, flags);
2870 return;
2871 }
2872
2873 evtp->evt_arg1 = ndlp;
2874 evtp->evt = LPFC_EVT_DEV_LOSS_DELAY;
2875 list_add_tail(&evtp->evt_listp, &phba->work_list);
2876 if (phba->work_wait)
2877 lpfc_worker_wake_up(phba);
2878 spin_unlock_irqrestore(&phba->hbalock, flags);
2879 return;
2880}
2881
2882void
2883lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 2818lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2884 uint32_t did) 2819 uint32_t did)
2885{ 2820{
@@ -2902,7 +2837,7 @@ lpfc_nlp_init(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2902 return; 2837 return;
2903} 2838}
2904 2839
2905void 2840static void
2906lpfc_nlp_release(struct kref *kref) 2841lpfc_nlp_release(struct kref *kref)
2907{ 2842{
2908 struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist, 2843 struct lpfc_nodelist *ndlp = container_of(kref, struct lpfc_nodelist,
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index c2fb59f595f3..451accd5564b 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -150,7 +150,11 @@ struct lpfc_sli_ct_request {
150 struct gff_acc { 150 struct gff_acc {
151 uint8_t fbits[128]; 151 uint8_t fbits[128];
152 } gff_acc; 152 } gff_acc;
153#ifdef __BIG_ENDIAN_BITFIELD
154#define FCP_TYPE_FEATURE_OFFSET 7
155#else /* __LITTLE_ENDIAN_BITFIELD */
153#define FCP_TYPE_FEATURE_OFFSET 4 156#define FCP_TYPE_FEATURE_OFFSET 4
157#endif
154 struct rff { 158 struct rff {
155 uint32_t PortId; 159 uint32_t PortId;
156 uint8_t reserved[2]; 160 uint8_t reserved[2];
@@ -805,7 +809,7 @@ typedef struct _RNID { /* Structure is in Big Endian format */
805 } un; 809 } un;
806} RNID; 810} RNID;
807 811
808typedef struct _RPS { /* Structure is in Big Endian format */ 812typedef struct _RPS { /* Structure is in Big Endian format */
809 union { 813 union {
810 uint32_t portNum; 814 uint32_t portNum;
811 struct lpfc_name portName; 815 struct lpfc_name portName;
@@ -823,7 +827,7 @@ typedef struct _RPS_RSP { /* Structure is in Big Endian format */
823 uint32_t crcCnt; 827 uint32_t crcCnt;
824} RPS_RSP; 828} RPS_RSP;
825 829
826typedef struct _RPL { /* Structure is in Big Endian format */ 830typedef struct _RPL { /* Structure is in Big Endian format */
827 uint32_t maxsize; 831 uint32_t maxsize;
828 uint32_t index; 832 uint32_t index;
829} RPL; 833} RPL;
@@ -834,7 +838,7 @@ typedef struct _PORT_NUM_BLK {
834 struct lpfc_name portName; 838 struct lpfc_name portName;
835} PORT_NUM_BLK; 839} PORT_NUM_BLK;
836 840
837typedef struct _RPL_RSP { /* Structure is in Big Endian format */ 841typedef struct _RPL_RSP { /* Structure is in Big Endian format */
838 uint32_t listLen; 842 uint32_t listLen;
839 uint32_t index; 843 uint32_t index;
840 PORT_NUM_BLK port_num_blk; 844 PORT_NUM_BLK port_num_blk;
@@ -2613,8 +2617,8 @@ typedef union {
2613 LOAD_SM_VAR varLdSM; /* cmd = 1 (LOAD_SM) */ 2617 LOAD_SM_VAR varLdSM; /* cmd = 1 (LOAD_SM) */
2614 READ_NV_VAR varRDnvp; /* cmd = 2 (READ_NVPARMS) */ 2618 READ_NV_VAR varRDnvp; /* cmd = 2 (READ_NVPARMS) */
2615 WRITE_NV_VAR varWTnvp; /* cmd = 3 (WRITE_NVPARMS) */ 2619 WRITE_NV_VAR varWTnvp; /* cmd = 3 (WRITE_NVPARMS) */
2616 BIU_DIAG_VAR varBIUdiag; /* cmd = 4 (RUN_BIU_DIAG) */ 2620 BIU_DIAG_VAR varBIUdiag; /* cmd = 4 (RUN_BIU_DIAG) */
2617 INIT_LINK_VAR varInitLnk; /* cmd = 5 (INIT_LINK) */ 2621 INIT_LINK_VAR varInitLnk; /* cmd = 5 (INIT_LINK) */
2618 DOWN_LINK_VAR varDwnLnk; /* cmd = 6 (DOWN_LINK) */ 2622 DOWN_LINK_VAR varDwnLnk; /* cmd = 6 (DOWN_LINK) */
2619 CONFIG_LINK varCfgLnk; /* cmd = 7 (CONFIG_LINK) */ 2623 CONFIG_LINK varCfgLnk; /* cmd = 7 (CONFIG_LINK) */
2620 PART_SLIM_VAR varSlim; /* cmd = 8 (PART_SLIM) */ 2624 PART_SLIM_VAR varSlim; /* cmd = 8 (PART_SLIM) */
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 07bd0dcdf0d6..414350ab584e 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -53,8 +53,6 @@ static struct scsi_transport_template *lpfc_transport_template = NULL;
53static struct scsi_transport_template *lpfc_vport_transport_template = NULL; 53static struct scsi_transport_template *lpfc_vport_transport_template = NULL;
54static DEFINE_IDR(lpfc_hba_index); 54static DEFINE_IDR(lpfc_hba_index);
55 55
56
57
58/************************************************************************/ 56/************************************************************************/
59/* */ 57/* */
60/* lpfc_config_port_prep */ 58/* lpfc_config_port_prep */
@@ -107,10 +105,9 @@ lpfc_config_port_prep(struct lpfc_hba *phba)
107 105
108 if (rc != MBX_SUCCESS) { 106 if (rc != MBX_SUCCESS) {
109 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, 107 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX,
110 "%d:0324 Config Port initialization " 108 "0324 Config Port initialization "
111 "error, mbxCmd x%x READ_NVPARM, " 109 "error, mbxCmd x%x READ_NVPARM, "
112 "mbxStatus x%x\n", 110 "mbxStatus x%x\n",
113 phba->brd_no,
114 mb->mbxCommand, mb->mbxStatus); 111 mb->mbxCommand, mb->mbxStatus);
115 mempool_free(pmb, phba->mbox_mem_pool); 112 mempool_free(pmb, phba->mbox_mem_pool);
116 return -ERESTART; 113 return -ERESTART;
@@ -128,9 +125,8 @@ lpfc_config_port_prep(struct lpfc_hba *phba)
128 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); 125 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
129 if (rc != MBX_SUCCESS) { 126 if (rc != MBX_SUCCESS) {
130 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 127 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
131 "%d:0439 Adapter failed to init, mbxCmd x%x " 128 "0439 Adapter failed to init, mbxCmd x%x "
132 "READ_REV, mbxStatus x%x\n", 129 "READ_REV, mbxStatus x%x\n",
133 phba->brd_no,
134 mb->mbxCommand, mb->mbxStatus); 130 mb->mbxCommand, mb->mbxStatus);
135 mempool_free( pmb, phba->mbox_mem_pool); 131 mempool_free( pmb, phba->mbox_mem_pool);
136 return -ERESTART; 132 return -ERESTART;
@@ -144,9 +140,8 @@ lpfc_config_port_prep(struct lpfc_hba *phba)
144 if (mb->un.varRdRev.rr == 0) { 140 if (mb->un.varRdRev.rr == 0) {
145 vp->rev.rBit = 0; 141 vp->rev.rBit = 0;
146 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 142 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
147 "%d:0440 Adapter failed to init, READ_REV has " 143 "0440 Adapter failed to init, READ_REV has "
148 "missing revision information.\n", 144 "missing revision information.\n");
149 phba->brd_no);
150 mempool_free(pmb, phba->mbox_mem_pool); 145 mempool_free(pmb, phba->mbox_mem_pool);
151 return -ERESTART; 146 return -ERESTART;
152 } 147 }
@@ -197,9 +192,8 @@ lpfc_config_port_prep(struct lpfc_hba *phba)
197 192
198 if (rc != MBX_SUCCESS) { 193 if (rc != MBX_SUCCESS) {
199 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 194 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
200 "%d:0441 VPD not present on adapter, " 195 "0441 VPD not present on adapter, "
201 "mbxCmd x%x DUMP VPD, mbxStatus x%x\n", 196 "mbxCmd x%x DUMP VPD, mbxStatus x%x\n",
202 phba->brd_no,
203 mb->mbxCommand, mb->mbxStatus); 197 mb->mbxCommand, mb->mbxStatus);
204 mb->un.varDmp.word_cnt = 0; 198 mb->un.varDmp.word_cnt = 0;
205 } 199 }
@@ -253,9 +247,8 @@ lpfc_config_port_post(struct lpfc_hba *phba)
253 pmb->vport = vport; 247 pmb->vport = vport;
254 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { 248 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
255 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 249 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
256 "%d:0448 Adapter failed init, mbxCmd x%x " 250 "0448 Adapter failed init, mbxCmd x%x "
257 "READ_SPARM mbxStatus x%x\n", 251 "READ_SPARM mbxStatus x%x\n",
258 phba->brd_no,
259 mb->mbxCommand, mb->mbxStatus); 252 mb->mbxCommand, mb->mbxStatus);
260 phba->link_state = LPFC_HBA_ERROR; 253 phba->link_state = LPFC_HBA_ERROR;
261 mp = (struct lpfc_dmabuf *) pmb->context1; 254 mp = (struct lpfc_dmabuf *) pmb->context1;
@@ -312,9 +305,8 @@ lpfc_config_port_post(struct lpfc_hba *phba)
312 pmb->vport = vport; 305 pmb->vport = vport;
313 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { 306 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
314 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 307 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
315 "%d:0453 Adapter failed to init, mbxCmd x%x " 308 "0453 Adapter failed to init, mbxCmd x%x "
316 "READ_CONFIG, mbxStatus x%x\n", 309 "READ_CONFIG, mbxStatus x%x\n",
317 phba->brd_no,
318 mb->mbxCommand, mb->mbxStatus); 310 mb->mbxCommand, mb->mbxStatus);
319 phba->link_state = LPFC_HBA_ERROR; 311 phba->link_state = LPFC_HBA_ERROR;
320 mempool_free( pmb, phba->mbox_mem_pool); 312 mempool_free( pmb, phba->mbox_mem_pool);
@@ -344,9 +336,8 @@ lpfc_config_port_post(struct lpfc_hba *phba)
344 && !(phba->lmt & LMT_10Gb))) { 336 && !(phba->lmt & LMT_10Gb))) {
345 /* Reset link speed to auto */ 337 /* Reset link speed to auto */
346 lpfc_printf_log(phba, KERN_WARNING, LOG_LINK_EVENT, 338 lpfc_printf_log(phba, KERN_WARNING, LOG_LINK_EVENT,
347 "%d:1302 Invalid speed for this board: " 339 "1302 Invalid speed for this board: "
348 "Reset link speed to auto: x%x\n", 340 "Reset link speed to auto: x%x\n",
349 phba->brd_no,
350 phba->cfg_link_speed); 341 phba->cfg_link_speed);
351 phba->cfg_link_speed = LINK_SPEED_AUTO; 342 phba->cfg_link_speed = LINK_SPEED_AUTO;
352 } 343 }
@@ -402,9 +393,8 @@ lpfc_config_port_post(struct lpfc_hba *phba)
402 lpfc_set_loopback_flag(phba); 393 lpfc_set_loopback_flag(phba);
403 if (rc != MBX_SUCCESS) { 394 if (rc != MBX_SUCCESS) {
404 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 395 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
405 "%d:0454 Adapter failed to init, mbxCmd x%x " 396 "0454 Adapter failed to init, mbxCmd x%x "
406 "INIT_LINK, mbxStatus x%x\n", 397 "INIT_LINK, mbxStatus x%x\n",
407 phba->brd_no,
408 mb->mbxCommand, mb->mbxStatus); 398 mb->mbxCommand, mb->mbxStatus);
409 399
410 /* Clear all interrupt enable conditions */ 400 /* Clear all interrupt enable conditions */
@@ -437,16 +427,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)
437int 427int
438lpfc_hba_down_prep(struct lpfc_hba *phba) 428lpfc_hba_down_prep(struct lpfc_hba *phba)
439{ 429{
440 struct lpfc_vport *vport = phba->pport;
441
442 /* Disable interrupts */ 430 /* Disable interrupts */
443 writel(0, phba->HCregaddr); 431 writel(0, phba->HCregaddr);
444 readl(phba->HCregaddr); /* flush */ 432 readl(phba->HCregaddr); /* flush */
445 433
446 list_for_each_entry(vport, &phba->port_list, listentry) { 434 lpfc_cleanup_discovery_resources(phba->pport);
447 lpfc_cleanup_discovery_resources(vport);
448 }
449
450 return 0; 435 return 0;
451} 436}
452 437
@@ -518,7 +503,7 @@ lpfc_hb_mbox_cmpl(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq)
518 mempool_free(pmboxq, phba->mbox_mem_pool); 503 mempool_free(pmboxq, phba->mbox_mem_pool);
519 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && 504 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) &&
520 !(phba->link_state == LPFC_HBA_ERROR) && 505 !(phba->link_state == LPFC_HBA_ERROR) &&
521 !(phba->pport->fc_flag & FC_UNLOADING)) 506 !(phba->pport->load_flag & FC_UNLOADING))
522 mod_timer(&phba->hb_tmofunc, 507 mod_timer(&phba->hb_tmofunc,
523 jiffies + HZ * LPFC_HB_MBOX_INTERVAL); 508 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
524 return; 509 return;
@@ -532,7 +517,7 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba)
532 struct lpfc_sli *psli = &phba->sli; 517 struct lpfc_sli *psli = &phba->sli;
533 518
534 if ((phba->link_state == LPFC_HBA_ERROR) || 519 if ((phba->link_state == LPFC_HBA_ERROR) ||
535 (phba->pport->fc_flag & FC_UNLOADING) || 520 (phba->pport->load_flag & FC_UNLOADING) ||
536 (phba->pport->fc_flag & FC_OFFLINE_MODE)) 521 (phba->pport->fc_flag & FC_OFFLINE_MODE))
537 return; 522 return;
538 523
@@ -586,8 +571,8 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba)
586 * need to take the HBA offline. 571 * need to take the HBA offline.
587 */ 572 */
588 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 573 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
589 "%d:0459 Adapter heartbeat failure, taking " 574 "0459 Adapter heartbeat failure, taking "
590 "this port offline.\n", phba->brd_no); 575 "this port offline.\n");
591 576
592 spin_lock_irq(&phba->hbalock); 577 spin_lock_irq(&phba->hbalock);
593 psli->sli_flag &= ~LPFC_SLI2_ACTIVE; 578 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
@@ -615,9 +600,10 @@ lpfc_handle_eratt(struct lpfc_hba *phba)
615 struct lpfc_vport *vport = phba->pport; 600 struct lpfc_vport *vport = phba->pport;
616 struct lpfc_sli *psli = &phba->sli; 601 struct lpfc_sli *psli = &phba->sli;
617 struct lpfc_sli_ring *pring; 602 struct lpfc_sli_ring *pring;
618 struct lpfc_vport *port_iterator; 603 struct lpfc_vport **vports;
619 uint32_t event_data; 604 uint32_t event_data;
620 struct Scsi_Host *shost; 605 struct Scsi_Host *shost;
606 int i;
621 607
622 /* If the pci channel is offline, ignore possible errors, 608 /* If the pci channel is offline, ignore possible errors,
623 * since we cannot communicate with the pci card anyway. */ 609 * since we cannot communicate with the pci card anyway. */
@@ -628,18 +614,21 @@ lpfc_handle_eratt(struct lpfc_hba *phba)
628 phba->work_hs & HS_FFER5) { 614 phba->work_hs & HS_FFER5) {
629 /* Re-establishing Link */ 615 /* Re-establishing Link */
630 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 616 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
631 "%d:1301 Re-establishing Link " 617 "1301 Re-establishing Link "
632 "Data: x%x x%x x%x\n", 618 "Data: x%x x%x x%x\n",
633 phba->brd_no, phba->work_hs, 619 phba->work_hs,
634 phba->work_status[0], phba->work_status[1]); 620 phba->work_status[0], phba->work_status[1]);
635 list_for_each_entry(port_iterator, &phba->port_list, 621 vports = lpfc_create_vport_work_array(phba);
636 listentry) { 622 if (vports != NULL)
637 shost = lpfc_shost_from_vport(port_iterator); 623 for(i = 0;
638 624 i < LPFC_MAX_VPORTS && vports[i] != NULL;
639 spin_lock_irq(shost->host_lock); 625 i++){
640 port_iterator->fc_flag |= FC_ESTABLISH_LINK; 626 shost = lpfc_shost_from_vport(vports[i]);
641 spin_unlock_irq(shost->host_lock); 627 spin_lock_irq(shost->host_lock);
642 } 628 vports[i]->fc_flag |= FC_ESTABLISH_LINK;
629 spin_unlock_irq(shost->host_lock);
630 }
631 lpfc_destroy_vport_work_array(vports);
643 spin_lock_irq(&phba->hbalock); 632 spin_lock_irq(&phba->hbalock);
644 psli->sli_flag &= ~LPFC_SLI2_ACTIVE; 633 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
645 spin_unlock_irq(&phba->hbalock); 634 spin_unlock_irq(&phba->hbalock);
@@ -673,9 +662,9 @@ lpfc_handle_eratt(struct lpfc_hba *phba)
673 * twice. This is the adapter hardware error path. 662 * twice. This is the adapter hardware error path.
674 */ 663 */
675 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 664 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
676 "%d:0457 Adapter Hardware Error " 665 "0457 Adapter Hardware Error "
677 "Data: x%x x%x x%x\n", 666 "Data: x%x x%x x%x\n",
678 phba->brd_no, phba->work_hs, 667 phba->work_hs,
679 phba->work_status[0], phba->work_status[1]); 668 phba->work_status[0], phba->work_status[1]);
680 669
681 event_data = FC_REG_DUMP_EVENT; 670 event_data = FC_REG_DUMP_EVENT;
@@ -708,7 +697,6 @@ lpfc_handle_latt(struct lpfc_hba *phba)
708{ 697{
709 struct lpfc_vport *vport = phba->pport; 698 struct lpfc_vport *vport = phba->pport;
710 struct lpfc_sli *psli = &phba->sli; 699 struct lpfc_sli *psli = &phba->sli;
711 struct lpfc_vport *port_iterator;
712 LPFC_MBOXQ_t *pmb; 700 LPFC_MBOXQ_t *pmb;
713 volatile uint32_t control; 701 volatile uint32_t control;
714 struct lpfc_dmabuf *mp; 702 struct lpfc_dmabuf *mp;
@@ -729,8 +717,7 @@ lpfc_handle_latt(struct lpfc_hba *phba)
729 rc = -EIO; 717 rc = -EIO;
730 718
731 /* Cleanup any outstanding ELS commands */ 719 /* Cleanup any outstanding ELS commands */
732 list_for_each_entry(port_iterator, &phba->port_list, listentry) 720 lpfc_els_flush_all_cmd(phba);
733 lpfc_els_flush_cmd(port_iterator);
734 721
735 psli->slistat.link_event++; 722 psli->slistat.link_event++;
736 lpfc_read_la(phba, pmb, mp); 723 lpfc_read_la(phba, pmb, mp);
@@ -773,8 +760,7 @@ lpfc_handle_latt_err_exit:
773 /* The other case is an error from issue_mbox */ 760 /* The other case is an error from issue_mbox */
774 if (rc == -ENOMEM) 761 if (rc == -ENOMEM)
775 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, 762 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
776 "%d:0300 READ_LA: no buffers\n", 763 "0300 READ_LA: no buffers\n");
777 phba->brd_no);
778 764
779 return; 765 return;
780} 766}
@@ -799,8 +785,7 @@ lpfc_parse_vpd(struct lpfc_hba *phba, uint8_t *vpd, int len)
799 785
800 /* Vital Product */ 786 /* Vital Product */
801 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 787 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
802 "%d:0455 Vital Product Data: x%x x%x x%x x%x\n", 788 "0455 Vital Product Data: x%x x%x x%x x%x\n",
803 phba->brd_no,
804 (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2], 789 (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2],
805 (uint32_t) vpd[3]); 790 (uint32_t) vpd[3]);
806 while (!finished && (index < (len - 4))) { 791 while (!finished && (index < (len - 4))) {
@@ -1313,22 +1298,25 @@ static void
1313lpfc_establish_link_tmo(unsigned long ptr) 1298lpfc_establish_link_tmo(unsigned long ptr)
1314{ 1299{
1315 struct lpfc_hba *phba = (struct lpfc_hba *) ptr; 1300 struct lpfc_hba *phba = (struct lpfc_hba *) ptr;
1316 struct lpfc_vport *vport = phba->pport; 1301 struct lpfc_vport **vports;
1317 unsigned long iflag; 1302 unsigned long iflag;
1303 int i;
1318 1304
1319 /* Re-establishing Link, timer expired */ 1305 /* Re-establishing Link, timer expired */
1320 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT, 1306 lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
1321 "%d:1300 Re-establishing Link, timer expired " 1307 "1300 Re-establishing Link, timer expired "
1322 "Data: x%x x%x\n", 1308 "Data: x%x x%x\n",
1323 phba->brd_no, vport->fc_flag, 1309 phba->pport->fc_flag, phba->pport->port_state);
1324 vport->port_state); 1310 vports = lpfc_create_vport_work_array(phba);
1325 list_for_each_entry(vport, &phba->port_list, listentry) { 1311 if (vports != NULL)
1326 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1312 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
1327 1313 struct Scsi_Host *shost;
1328 spin_lock_irqsave(shost->host_lock, iflag); 1314 shost = lpfc_shost_from_vport(vports[i]);
1329 vport->fc_flag &= ~FC_ESTABLISH_LINK; 1315 spin_lock_irqsave(shost->host_lock, iflag);
1330 spin_unlock_irqrestore(shost->host_lock, iflag); 1316 vports[i]->fc_flag &= ~FC_ESTABLISH_LINK;
1331 } 1317 spin_unlock_irqrestore(shost->host_lock, iflag);
1318 }
1319 lpfc_destroy_vport_work_array(vports);
1332} 1320}
1333 1321
1334void 1322void
@@ -1343,12 +1331,9 @@ lpfc_stop_vport_timers(struct lpfc_vport *vport)
1343static void 1331static void
1344lpfc_stop_phba_timers(struct lpfc_hba *phba) 1332lpfc_stop_phba_timers(struct lpfc_hba *phba)
1345{ 1333{
1346 struct lpfc_vport *vport;
1347
1348 del_timer_sync(&phba->fcp_poll_timer); 1334 del_timer_sync(&phba->fcp_poll_timer);
1349 del_timer_sync(&phba->fc_estabtmo); 1335 del_timer_sync(&phba->fc_estabtmo);
1350 list_for_each_entry(vport, &phba->port_list, listentry) 1336 lpfc_stop_vport_timers(phba->pport);
1351 lpfc_stop_vport_timers(vport);
1352 del_timer_sync(&phba->sli.mbox_tmo); 1337 del_timer_sync(&phba->sli.mbox_tmo);
1353 del_timer_sync(&phba->fabric_block_timer); 1338 del_timer_sync(&phba->fabric_block_timer);
1354 phba->hb_outstanding = 0; 1339 phba->hb_outstanding = 0;
@@ -1360,6 +1345,8 @@ int
1360lpfc_online(struct lpfc_hba *phba) 1345lpfc_online(struct lpfc_hba *phba)
1361{ 1346{
1362 struct lpfc_vport *vport = phba->pport; 1347 struct lpfc_vport *vport = phba->pport;
1348 struct lpfc_vport **vports;
1349 int i;
1363 1350
1364 if (!phba) 1351 if (!phba)
1365 return 0; 1352 return 0;
@@ -1368,8 +1355,7 @@ lpfc_online(struct lpfc_hba *phba)
1368 return 0; 1355 return 0;
1369 1356
1370 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, 1357 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
1371 "%d:0458 Bring Adapter online\n", 1358 "0458 Bring Adapter online\n");
1372 phba->brd_no);
1373 1359
1374 lpfc_block_mgmt_io(phba); 1360 lpfc_block_mgmt_io(phba);
1375 1361
@@ -1383,14 +1369,18 @@ lpfc_online(struct lpfc_hba *phba)
1383 return 1; 1369 return 1;
1384 } 1370 }
1385 1371
1386 list_for_each_entry(vport, &phba->port_list, listentry) { 1372 vports = lpfc_create_vport_work_array(phba);
1387 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1373 if (vports != NULL)
1388 spin_lock_irq(shost->host_lock); 1374 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
1389 vport->fc_flag &= ~FC_OFFLINE_MODE; 1375 struct Scsi_Host *shost;
1390 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) 1376 shost = lpfc_shost_from_vport(vports[i]);
1391 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 1377 spin_lock_irq(shost->host_lock);
1392 spin_unlock_irq(shost->host_lock); 1378 vports[i]->fc_flag &= ~FC_OFFLINE_MODE;
1393 } 1379 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)
1380 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
1381 spin_unlock_irq(shost->host_lock);
1382 }
1383 lpfc_destroy_vport_work_array(vports);
1394 1384
1395 lpfc_unblock_mgmt_io(phba); 1385 lpfc_unblock_mgmt_io(phba);
1396 return 0; 1386 return 0;
@@ -1440,39 +1430,39 @@ lpfc_offline_prep(struct lpfc_hba * phba)
1440void 1430void
1441lpfc_offline(struct lpfc_hba *phba) 1431lpfc_offline(struct lpfc_hba *phba)
1442{ 1432{
1443 struct lpfc_vport *vport = phba->pport; 1433 struct Scsi_Host *shost;
1444 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1434 struct lpfc_vport **vports;
1445 struct lpfc_vport *port_iterator; 1435 int i;
1446 1436
1447 if (vport->fc_flag & FC_OFFLINE_MODE) 1437 if (phba->pport->fc_flag & FC_OFFLINE_MODE)
1448 return; 1438 return;
1449 1439
1450 /* stop all timers associated with this hba */ 1440 /* stop all timers associated with this hba */
1451 lpfc_stop_phba_timers(phba); 1441 lpfc_stop_phba_timers(phba);
1452 list_for_each_entry(port_iterator, &phba->port_list, listentry) { 1442 vports = lpfc_create_vport_work_array(phba);
1453 port_iterator->work_port_events = 0; 1443 if (vports != NULL)
1454 } 1444 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++)
1455 1445 lpfc_stop_vport_timers(vports[i]);
1446 lpfc_destroy_vport_work_array(vports);
1456 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT, 1447 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
1457 "%d:0460 Bring Adapter offline\n", 1448 "0460 Bring Adapter offline\n");
1458 phba->brd_no);
1459
1460 /* Bring down the SLI Layer and cleanup. The HBA is offline 1449 /* Bring down the SLI Layer and cleanup. The HBA is offline
1461 now. */ 1450 now. */
1462 lpfc_sli_hba_down(phba); 1451 lpfc_sli_hba_down(phba);
1463 spin_lock_irq(&phba->hbalock); 1452 spin_lock_irq(&phba->hbalock);
1464 phba->work_ha = 0; 1453 phba->work_ha = 0;
1465 vport->fc_flag |= FC_OFFLINE_MODE;
1466 spin_unlock_irq(&phba->hbalock); 1454 spin_unlock_irq(&phba->hbalock);
1467 list_for_each_entry(port_iterator, &phba->port_list, listentry) { 1455 vports = lpfc_create_vport_work_array(phba);
1468 shost = lpfc_shost_from_vport(port_iterator); 1456 if (vports != NULL)
1469 1457 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
1470 lpfc_cleanup(port_iterator); 1458 shost = lpfc_shost_from_vport(vports[i]);
1471 spin_lock_irq(shost->host_lock); 1459 lpfc_cleanup(vports[i]);
1472 vport->work_port_events = 0; 1460 spin_lock_irq(shost->host_lock);
1473 vport->fc_flag |= FC_OFFLINE_MODE; 1461 vports[i]->work_port_events = 0;
1474 spin_unlock_irq(shost->host_lock); 1462 vports[i]->fc_flag |= FC_OFFLINE_MODE;
1475 } 1463 spin_unlock_irq(shost->host_lock);
1464 }
1465 lpfc_destroy_vport_work_array(vports);
1476} 1466}
1477 1467
1478/****************************************************************************** 1468/******************************************************************************
@@ -1509,15 +1499,19 @@ lpfc_scsi_free(struct lpfc_hba *phba)
1509 return 0; 1499 return 0;
1510} 1500}
1511 1501
1512
1513struct lpfc_vport * 1502struct lpfc_vport *
1514lpfc_create_port(struct lpfc_hba *phba, int instance, struct fc_vport *fc_vport) 1503lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
1515{ 1504{
1516 struct lpfc_vport *vport; 1505 struct lpfc_vport *vport;
1517 struct Scsi_Host *shost; 1506 struct Scsi_Host *shost;
1518 int error = 0; 1507 int error = 0;
1519 1508
1520 shost = scsi_host_alloc(&lpfc_template, sizeof(struct lpfc_vport)); 1509 if (dev != &phba->pcidev->dev)
1510 shost = scsi_host_alloc(&lpfc_vport_template,
1511 sizeof(struct lpfc_vport));
1512 else
1513 shost = scsi_host_alloc(&lpfc_template,
1514 sizeof(struct lpfc_vport));
1521 if (!shost) 1515 if (!shost)
1522 goto out; 1516 goto out;
1523 1517
@@ -1527,9 +1521,10 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct fc_vport *fc_vport)
1527 vport->load_flag |= FC_LOADING; 1521 vport->load_flag |= FC_LOADING;
1528 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 1522 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
1529 1523
1524 lpfc_get_vport_cfgparam(vport);
1530 shost->unique_id = instance; 1525 shost->unique_id = instance;
1531 shost->max_id = LPFC_MAX_TARGET; 1526 shost->max_id = LPFC_MAX_TARGET;
1532 shost->max_lun = phba->cfg_max_luns; 1527 shost->max_lun = vport->cfg_max_luns;
1533 shost->this_id = -1; 1528 shost->this_id = -1;
1534 shost->max_cmd_len = 16; 1529 shost->max_cmd_len = 16;
1535 /* 1530 /*
@@ -1538,7 +1533,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct fc_vport *fc_vport)
1538 * max xri value determined in hba setup. 1533 * max xri value determined in hba setup.
1539 */ 1534 */
1540 shost->can_queue = phba->cfg_hba_queue_depth - 10; 1535 shost->can_queue = phba->cfg_hba_queue_depth - 10;
1541 if (fc_vport != NULL) { 1536 if (dev != &phba->pcidev->dev) {
1542 shost->transportt = lpfc_vport_transport_template; 1537 shost->transportt = lpfc_vport_transport_template;
1543 vport->port_type = LPFC_NPIV_PORT; 1538 vport->port_type = LPFC_NPIV_PORT;
1544 } else { 1539 } else {
@@ -1562,15 +1557,13 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct fc_vport *fc_vport)
1562 vport->els_tmofunc.function = lpfc_els_timeout; 1557 vport->els_tmofunc.function = lpfc_els_timeout;
1563 vport->els_tmofunc.data = (unsigned long)vport; 1558 vport->els_tmofunc.data = (unsigned long)vport;
1564 1559
1565 if (fc_vport != NULL) { 1560 error = scsi_add_host(shost, dev);
1566 error = scsi_add_host(shost, &fc_vport->dev);
1567 } else {
1568 error = scsi_add_host(shost, &phba->pcidev->dev);
1569 }
1570 if (error) 1561 if (error)
1571 goto out_put_shost; 1562 goto out_put_shost;
1572 1563
1564 spin_lock_irq(&phba->hbalock);
1573 list_add_tail(&vport->listentry, &phba->port_list); 1565 list_add_tail(&vport->listentry, &phba->port_list);
1566 spin_unlock_irq(&phba->hbalock);
1574 return vport; 1567 return vport;
1575 1568
1576out_put_shost: 1569out_put_shost:
@@ -1625,23 +1618,21 @@ int lpfc_scan_finished(struct Scsi_Host *shost, unsigned long time)
1625 1618
1626 spin_lock_irq(shost->host_lock); 1619 spin_lock_irq(shost->host_lock);
1627 1620
1628 if (vport->fc_flag & FC_UNLOADING) { 1621 if (vport->load_flag & FC_UNLOADING) {
1629 stat = 1; 1622 stat = 1;
1630 goto finished; 1623 goto finished;
1631 } 1624 }
1632 if (time >= 30 * HZ) { 1625 if (time >= 30 * HZ) {
1633 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 1626 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1634 "%d:0461 Scanning longer than 30 " 1627 "0461 Scanning longer than 30 "
1635 "seconds. Continuing initialization\n", 1628 "seconds. Continuing initialization\n");
1636 phba->brd_no);
1637 stat = 1; 1629 stat = 1;
1638 goto finished; 1630 goto finished;
1639 } 1631 }
1640 if (time >= 15 * HZ && phba->link_state <= LPFC_LINK_DOWN) { 1632 if (time >= 15 * HZ && phba->link_state <= LPFC_LINK_DOWN) {
1641 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 1633 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1642 "%d:0465 Link down longer than 15 " 1634 "0465 Link down longer than 15 "
1643 "seconds. Continuing initialization\n", 1635 "seconds. Continuing initialization\n");
1644 phba->brd_no);
1645 stat = 1; 1636 stat = 1;
1646 goto finished; 1637 goto finished;
1647 } 1638 }
@@ -1704,7 +1695,7 @@ void lpfc_host_attrib_init(struct Scsi_Host *shost)
1704 1695
1705 fc_host_max_npiv_vports(shost) = phba->max_vpi; 1696 fc_host_max_npiv_vports(shost) = phba->max_vpi;
1706 spin_lock_irq(shost->host_lock); 1697 spin_lock_irq(shost->host_lock);
1707 vport->fc_flag &= ~FC_LOADING; 1698 vport->load_flag &= ~FC_LOADING;
1708 spin_unlock_irq(shost->host_lock); 1699 spin_unlock_irq(shost->host_lock);
1709} 1700}
1710 1701
@@ -1716,9 +1707,10 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1716 struct lpfc_sli *psli; 1707 struct lpfc_sli *psli;
1717 struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL; 1708 struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL;
1718 struct Scsi_Host *shost = NULL; 1709 struct Scsi_Host *shost = NULL;
1710 void *ptr;
1719 unsigned long bar0map_len, bar2map_len; 1711 unsigned long bar0map_len, bar2map_len;
1720 int error = -ENODEV; 1712 int error = -ENODEV;
1721 int i; 1713 int i, hbq_count;
1722 uint16_t iotag; 1714 uint16_t iotag;
1723 1715
1724 if (pci_enable_device(pdev)) 1716 if (pci_enable_device(pdev))
@@ -1739,7 +1731,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1739 goto out_free_phba; 1731 goto out_free_phba;
1740 1732
1741 INIT_LIST_HEAD(&phba->port_list); 1733 INIT_LIST_HEAD(&phba->port_list);
1742 INIT_LIST_HEAD(&phba->hbq_buffer_list);
1743 /* 1734 /*
1744 * Get all the module params for configuring this host and then 1735 * Get all the module params for configuring this host and then
1745 * establish the host. 1736 * establish the host.
@@ -1817,6 +1808,17 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1817 if (!phba->hbqslimp.virt) 1808 if (!phba->hbqslimp.virt)
1818 goto out_free_slim; 1809 goto out_free_slim;
1819 1810
1811 hbq_count = lpfc_sli_hbq_count();
1812 ptr = phba->hbqslimp.virt;
1813 for (i = 0; i < hbq_count; ++i) {
1814 phba->hbqs[i].hbq_virt = ptr;
1815 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list);
1816 ptr += (lpfc_hbq_defs[i]->entry_count *
1817 sizeof(struct lpfc_hbq_entry));
1818 }
1819 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc;
1820 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free;
1821
1820 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); 1822 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size());
1821 1823
1822 /* Initialize the SLI Layer to run with lpfc HBAs. */ 1824 /* Initialize the SLI Layer to run with lpfc HBAs. */
@@ -1880,7 +1882,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1880 /* Initialize list of fabric iocbs */ 1882 /* Initialize list of fabric iocbs */
1881 INIT_LIST_HEAD(&phba->fabric_iocb_list); 1883 INIT_LIST_HEAD(&phba->fabric_iocb_list);
1882 1884
1883 vport = lpfc_create_port(phba, phba->brd_no, NULL); 1885 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev);
1884 if (!vport) 1886 if (!vport)
1885 goto out_kthread_stop; 1887 goto out_kthread_stop;
1886 1888
@@ -1892,18 +1894,19 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1892 1894
1893 if (phba->cfg_use_msi) { 1895 if (phba->cfg_use_msi) {
1894 error = pci_enable_msi(phba->pcidev); 1896 error = pci_enable_msi(phba->pcidev);
1895 if (error) 1897 if (!error)
1896 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 " 1898 phba->using_msi = 1;
1897 "Enable MSI failed, continuing with " 1899 else
1898 "IRQ\n", phba->brd_no); 1900 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1901 "0452 Enable MSI failed, continuing "
1902 "with IRQ\n");
1899 } 1903 }
1900 1904
1901 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, 1905 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED,
1902 LPFC_DRIVER_NAME, phba); 1906 LPFC_DRIVER_NAME, phba);
1903 if (error) { 1907 if (error) {
1904 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1908 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1905 "%d:0451 Enable interrupt handler failed\n", 1909 "0451 Enable interrupt handler failed\n");
1906 phba->brd_no);
1907 goto out_disable_msi; 1910 goto out_disable_msi;
1908 } 1911 }
1909 1912
@@ -1940,14 +1943,15 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1940out_remove_device: 1943out_remove_device:
1941 lpfc_free_sysfs_attr(vport); 1944 lpfc_free_sysfs_attr(vport);
1942 spin_lock_irq(shost->host_lock); 1945 spin_lock_irq(shost->host_lock);
1943 vport->fc_flag |= FC_UNLOADING; 1946 vport->load_flag |= FC_UNLOADING;
1944 spin_unlock_irq(shost->host_lock); 1947 spin_unlock_irq(shost->host_lock);
1945out_free_irq: 1948out_free_irq:
1946 lpfc_stop_phba_timers(phba); 1949 lpfc_stop_phba_timers(phba);
1947 phba->pport->work_port_events = 0; 1950 phba->pport->work_port_events = 0;
1948 free_irq(phba->pcidev->irq, phba); 1951 free_irq(phba->pcidev->irq, phba);
1949out_disable_msi: 1952out_disable_msi:
1950 pci_disable_msi(phba->pcidev); 1953 if (phba->using_msi)
1954 pci_disable_msi(phba->pcidev);
1951 destroy_port(vport); 1955 destroy_port(vport);
1952out_kthread_stop: 1956out_kthread_stop:
1953 kthread_stop(phba->worker_thread); 1957 kthread_stop(phba->worker_thread);
@@ -1989,16 +1993,15 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
1989 struct Scsi_Host *shost = pci_get_drvdata(pdev); 1993 struct Scsi_Host *shost = pci_get_drvdata(pdev);
1990 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 1994 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
1991 struct lpfc_hba *phba = vport->phba; 1995 struct lpfc_hba *phba = vport->phba;
1992 struct lpfc_vport *port_iterator; 1996 spin_lock_irq(&phba->hbalock);
1993 list_for_each_entry(port_iterator, &phba->port_list, listentry) 1997 vport->load_flag |= FC_UNLOADING;
1994 port_iterator->load_flag |= FC_UNLOADING; 1998 spin_unlock_irq(&phba->hbalock);
1995 1999
1996 kfree(vport->vname); 2000 kfree(vport->vname);
1997 lpfc_free_sysfs_attr(vport); 2001 lpfc_free_sysfs_attr(vport);
1998 2002
1999 fc_remove_host(shost); 2003 fc_remove_host(shost);
2000 scsi_remove_host(shost); 2004 scsi_remove_host(shost);
2001
2002 /* 2005 /*
2003 * Bring down the SLI Layer. This step disable all interrupts, 2006 * Bring down the SLI Layer. This step disable all interrupts,
2004 * clears the rings, discards all mailbox commands, and resets 2007 * clears the rings, discards all mailbox commands, and resets
@@ -2012,7 +2015,6 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
2012 list_del_init(&vport->listentry); 2015 list_del_init(&vport->listentry);
2013 spin_unlock_irq(&phba->hbalock); 2016 spin_unlock_irq(&phba->hbalock);
2014 2017
2015
2016 lpfc_debugfs_terminate(vport); 2018 lpfc_debugfs_terminate(vport);
2017 lpfc_cleanup(vport); 2019 lpfc_cleanup(vport);
2018 2020
@@ -2020,7 +2022,8 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
2020 2022
2021 /* Release the irq reservation */ 2023 /* Release the irq reservation */
2022 free_irq(phba->pcidev->irq, phba); 2024 free_irq(phba->pcidev->irq, phba);
2023 pci_disable_msi(phba->pcidev); 2025 if (phba->using_msi)
2026 pci_disable_msi(phba->pcidev);
2024 2027
2025 pci_set_drvdata(pdev, NULL); 2028 pci_set_drvdata(pdev, NULL);
2026 scsi_host_put(shost); 2029 scsi_host_put(shost);
@@ -2062,8 +2065,8 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
2062static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev, 2065static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev,
2063 pci_channel_state_t state) 2066 pci_channel_state_t state)
2064{ 2067{
2065 struct Scsi_Host *host = pci_get_drvdata(pdev); 2068 struct Scsi_Host *shost = pci_get_drvdata(pdev);
2066 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; 2069 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2067 struct lpfc_sli *psli = &phba->sli; 2070 struct lpfc_sli *psli = &phba->sli;
2068 struct lpfc_sli_ring *pring; 2071 struct lpfc_sli_ring *pring;
2069 2072
@@ -2079,6 +2082,11 @@ static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev,
2079 pring = &psli->ring[psli->fcp_ring]; 2082 pring = &psli->ring[psli->fcp_ring];
2080 lpfc_sli_abort_iocb_ring(phba, pring); 2083 lpfc_sli_abort_iocb_ring(phba, pring);
2081 2084
2085 /* Release the irq reservation */
2086 free_irq(phba->pcidev->irq, phba);
2087 if (phba->using_msi)
2088 pci_disable_msi(phba->pcidev);
2089
2082 /* Request a slot reset. */ 2090 /* Request a slot reset. */
2083 return PCI_ERS_RESULT_NEED_RESET; 2091 return PCI_ERS_RESULT_NEED_RESET;
2084} 2092}
@@ -2091,8 +2099,8 @@ static pci_ers_result_t lpfc_io_error_detected(struct pci_dev *pdev,
2091 */ 2099 */
2092static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev) 2100static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev)
2093{ 2101{
2094 struct Scsi_Host *host = pci_get_drvdata(pdev); 2102 struct Scsi_Host *shost = pci_get_drvdata(pdev);
2095 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; 2103 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2096 struct lpfc_sli *psli = &phba->sli; 2104 struct lpfc_sli *psli = &phba->sli;
2097 int bars = pci_select_bars(pdev, IORESOURCE_MEM); 2105 int bars = pci_select_bars(pdev, IORESOURCE_MEM);
2098 2106
@@ -2106,9 +2114,9 @@ static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev)
2106 pci_set_master(pdev); 2114 pci_set_master(pdev);
2107 2115
2108 /* Re-establishing Link */ 2116 /* Re-establishing Link */
2109 spin_lock_irq(host->host_lock); 2117 spin_lock_irq(shost->host_lock);
2110 phba->pport->fc_flag |= FC_ESTABLISH_LINK; 2118 phba->pport->fc_flag |= FC_ESTABLISH_LINK;
2111 spin_unlock_irq(host->host_lock); 2119 spin_unlock_irq(shost->host_lock);
2112 2120
2113 spin_lock_irq(&phba->hbalock); 2121 spin_lock_irq(&phba->hbalock);
2114 psli->sli_flag &= ~LPFC_SLI2_ACTIVE; 2122 psli->sli_flag &= ~LPFC_SLI2_ACTIVE;
@@ -2131,8 +2139,8 @@ static pci_ers_result_t lpfc_io_slot_reset(struct pci_dev *pdev)
2131 */ 2139 */
2132static void lpfc_io_resume(struct pci_dev *pdev) 2140static void lpfc_io_resume(struct pci_dev *pdev)
2133{ 2141{
2134 struct Scsi_Host *host = pci_get_drvdata(pdev); 2142 struct Scsi_Host *shost = pci_get_drvdata(pdev);
2135 struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata; 2143 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba;
2136 2144
2137 if (lpfc_online(phba) == 0) { 2145 if (lpfc_online(phba) == 0) {
2138 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60); 2146 mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h
index 8a6ceffeabcf..626e4d878725 100644
--- a/drivers/scsi/lpfc/lpfc_logmsg.h
+++ b/drivers/scsi/lpfc/lpfc_logmsg.h
@@ -33,6 +33,12 @@
33#define LOG_VPORT 0x4000 /* NPIV events */ 33#define LOG_VPORT 0x4000 /* NPIV events */
34#define LOG_ALL_MSG 0xffff /* LOG all messages */ 34#define LOG_ALL_MSG 0xffff /* LOG all messages */
35 35
36#define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \
37 { if (((mask) &(vport)->cfg_log_verbose) || (level[1] <= '3')) \
38 dev_printk(level, &((vport)->phba->pcidev)->dev, "%d:(%d):" \
39 fmt, (vport)->phba->brd_no, vport->vpi, ##arg); }
40
36#define lpfc_printf_log(phba, level, mask, fmt, arg...) \ 41#define lpfc_printf_log(phba, level, mask, fmt, arg...) \
37 { if (((mask) &(phba)->cfg_log_verbose) || (level[1] <= '3')) \ 42 { if (((mask) &(phba)->pport->cfg_log_verbose) || (level[1] <= '3')) \
38 dev_printk(level, &((phba)->pcidev)->dev, fmt, ##arg); } 43 dev_printk(level, &((phba)->pcidev)->dev, "%d:" \
44 fmt, phba->brd_no, ##arg); }
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 8f42fbfdd29e..a592733664e9 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -275,11 +275,8 @@ lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi)
275 kfree(mp); 275 kfree(mp);
276 mb->mbxCommand = MBX_READ_SPARM64; 276 mb->mbxCommand = MBX_READ_SPARM64;
277 /* READ_SPARAM: no buffers */ 277 /* READ_SPARAM: no buffers */
278 lpfc_printf_log(phba, 278 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
279 KERN_WARNING, 279 "0301 READ_SPARAM: no buffers\n");
280 LOG_MBOX,
281 "%d:0301 READ_SPARAM: no buffers\n",
282 phba->brd_no);
283 return (1); 280 return (1);
284 } 281 }
285 INIT_LIST_HEAD(&mp->list); 282 INIT_LIST_HEAD(&mp->list);
@@ -378,9 +375,8 @@ lpfc_reg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t did,
378 mb->mbxCommand = MBX_REG_LOGIN64; 375 mb->mbxCommand = MBX_REG_LOGIN64;
379 /* REG_LOGIN: no buffers */ 376 /* REG_LOGIN: no buffers */
380 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX, 377 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
381 "%d (%d):0302 REG_LOGIN: no buffers, DID x%x, " 378 "0302 REG_LOGIN: no buffers, VPI:%d DID:x%x, "
382 "flag x%x\n", 379 "flag x%x\n", vpi, did, flag);
383 phba->brd_no, vpi, did, flag);
384 return (1); 380 return (1);
385 } 381 }
386 INIT_LIST_HEAD(&mp->list); 382 INIT_LIST_HEAD(&mp->list);
@@ -564,7 +560,8 @@ lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb,
564} 560}
565 561
566void 562void
567lpfc_config_hbq(struct lpfc_hba *phba, struct lpfc_hbq_init *hbq_desc, 563lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id,
564 struct lpfc_hbq_init *hbq_desc,
568 uint32_t hbq_entry_index, LPFC_MBOXQ_t *pmb) 565 uint32_t hbq_entry_index, LPFC_MBOXQ_t *pmb)
569{ 566{
570 int i; 567 int i;
@@ -572,6 +569,7 @@ lpfc_config_hbq(struct lpfc_hba *phba, struct lpfc_hbq_init *hbq_desc,
572 struct config_hbq_var *hbqmb = &mb->un.varCfgHbq; 569 struct config_hbq_var *hbqmb = &mb->un.varCfgHbq;
573 570
574 memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); 571 memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
572 hbqmb->hbqId = id;
575 hbqmb->entry_count = hbq_desc->entry_count; /* # entries in HBQ */ 573 hbqmb->entry_count = hbq_desc->entry_count; /* # entries in HBQ */
576 hbqmb->recvNotify = hbq_desc->rn; /* Receive 574 hbqmb->recvNotify = hbq_desc->rn; /* Receive
577 * Notification */ 575 * Notification */
@@ -691,8 +689,8 @@ lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
691 689
692 if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) { 690 if (phba->sli_rev == 3 && phba->vpd.sli3Feat.cerbm) {
693 mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ 691 mb->un.varCfgPort.cerbm = 1; /* Request HBQs */
694 mb->un.varCfgPort.max_hbq = 1; /* Requesting 2 HBQs */ 692 mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count();
695 if (phba->max_vpi && phba->cfg_npiv_enable && 693 if (phba->max_vpi && phba->cfg_enable_npiv &&
696 phba->vpd.sli3Feat.cmv) { 694 phba->vpd.sli3Feat.cmv) {
697 mb->un.varCfgPort.max_vpi = phba->max_vpi; 695 mb->un.varCfgPort.max_vpi = phba->max_vpi;
698 mb->un.varCfgPort.cmv = 1; 696 mb->un.varCfgPort.cmv = 1;
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index 3594c469494f..43c3b8a0d76a 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -231,21 +231,34 @@ lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma)
231 return; 231 return;
232} 232}
233 233
234void * 234struct hbq_dmabuf *
235lpfc_hbq_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle) 235lpfc_els_hbq_alloc(struct lpfc_hba *phba)
236{ 236{
237 void *ret; 237 struct hbq_dmabuf *hbqbp;
238 ret = pci_pool_alloc(phba->lpfc_hbq_pool, GFP_ATOMIC, handle); 238
239 return ret; 239 hbqbp = kmalloc(sizeof(struct hbq_dmabuf), GFP_KERNEL);
240 if (!hbqbp)
241 return NULL;
242
243 hbqbp->dbuf.virt = pci_pool_alloc(phba->lpfc_hbq_pool, GFP_KERNEL,
244 &hbqbp->dbuf.phys);
245 if (!hbqbp->dbuf.virt) {
246 kfree(hbqbp);
247 return NULL;
248 }
249 hbqbp->size = LPFC_BPL_SIZE;
250 return hbqbp;
240} 251}
241 252
242void 253void
243lpfc_hbq_free(struct lpfc_hba *phba, void *virt, dma_addr_t dma) 254lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp)
244{ 255{
245 pci_pool_free(phba->lpfc_hbq_pool, virt, dma); 256 pci_pool_free(phba->lpfc_hbq_pool, hbqbp->dbuf.virt, hbqbp->dbuf.phys);
257 kfree(hbqbp);
246 return; 258 return;
247} 259}
248 260
261/* This is ONLY called for the LPFC_ELS_HBQ */
249void 262void
250lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp) 263lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp)
251{ 264{
@@ -254,9 +267,8 @@ lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp)
254 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { 267 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
255 hbq_entry = container_of(mp, struct hbq_dmabuf, dbuf); 268 hbq_entry = container_of(mp, struct hbq_dmabuf, dbuf);
256 if (hbq_entry->tag == -1) { 269 if (hbq_entry->tag == -1) {
257 lpfc_hbq_free(phba, hbq_entry->dbuf.virt, 270 (phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer)
258 hbq_entry->dbuf.phys); 271 (phba, hbq_entry);
259 kfree(hbq_entry);
260 } else { 272 } else {
261 lpfc_sli_free_hbq(phba, hbq_entry); 273 lpfc_sli_free_hbq(phba, hbq_entry);
262 } 274 }
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index bca2f5c9b4ba..880af0cd463d 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -133,15 +133,15 @@ lpfc_check_sparm(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
133 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name)); 133 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
134 return 1; 134 return 1;
135bad_service_param: 135bad_service_param:
136 lpfc_printf_log(vport->phba, KERN_ERR, LOG_DISCOVERY, 136 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
137 "%d (%d):0207 Device %x " 137 "0207 Device %x "
138 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent " 138 "(%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x) sent "
139 "invalid service parameters. Ignoring device.\n", 139 "invalid service parameters. Ignoring device.\n",
140 vport->phba->brd_no, ndlp->vport->vpi, ndlp->nlp_DID, 140 ndlp->nlp_DID,
141 sp->nodeName.u.wwn[0], sp->nodeName.u.wwn[1], 141 sp->nodeName.u.wwn[0], sp->nodeName.u.wwn[1],
142 sp->nodeName.u.wwn[2], sp->nodeName.u.wwn[3], 142 sp->nodeName.u.wwn[2], sp->nodeName.u.wwn[3],
143 sp->nodeName.u.wwn[4], sp->nodeName.u.wwn[5], 143 sp->nodeName.u.wwn[4], sp->nodeName.u.wwn[5],
144 sp->nodeName.u.wwn[6], sp->nodeName.u.wwn[7]); 144 sp->nodeName.u.wwn[6], sp->nodeName.u.wwn[7]);
145 return 0; 145 return 0;
146} 146}
147 147
@@ -194,11 +194,11 @@ lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
194 IOCB_t *cmd; 194 IOCB_t *cmd;
195 195
196 /* Abort outstanding I/O on NPort <nlp_DID> */ 196 /* Abort outstanding I/O on NPort <nlp_DID> */
197 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 197 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_DISCOVERY,
198 "%d (%d):0205 Abort outstanding I/O on NPort x%x " 198 "0205 Abort outstanding I/O on NPort x%x "
199 "Data: x%x x%x x%x\n", 199 "Data: x%x x%x x%x\n",
200 phba->brd_no, ndlp->vport->vpi, ndlp->nlp_DID, 200 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
201 ndlp->nlp_flag, ndlp->nlp_state, ndlp->nlp_rpi); 201 ndlp->nlp_rpi);
202 202
203 lpfc_fabric_abort_nport(ndlp); 203 lpfc_fabric_abort_nport(ndlp);
204 204
@@ -298,13 +298,12 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
298 icmd = &cmdiocb->iocb; 298 icmd = &cmdiocb->iocb;
299 299
300 /* PLOGI chkparm OK */ 300 /* PLOGI chkparm OK */
301 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 301 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
302 "%d (%d):0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n", 302 "0114 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
303 phba->brd_no, vport->vpi, 303 ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag,
304 ndlp->nlp_DID, ndlp->nlp_state, ndlp->nlp_flag, 304 ndlp->nlp_rpi);
305 ndlp->nlp_rpi);
306 305
307 if (phba->cfg_fcp_class == 2 && sp->cls2.classValid) 306 if (vport->cfg_fcp_class == 2 && sp->cls2.classValid)
308 ndlp->nlp_fcp_info |= CLASS2; 307 ndlp->nlp_fcp_info |= CLASS2;
309 else 308 else
310 ndlp->nlp_fcp_info |= CLASS3; 309 ndlp->nlp_fcp_info |= CLASS3;
@@ -330,7 +329,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
330 case NLP_STE_PRLI_ISSUE: 329 case NLP_STE_PRLI_ISSUE:
331 case NLP_STE_UNMAPPED_NODE: 330 case NLP_STE_UNMAPPED_NODE:
332 case NLP_STE_MAPPED_NODE: 331 case NLP_STE_MAPPED_NODE:
333 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL, 0); 332 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, NULL);
334 return 1; 333 return 1;
335 } 334 }
336 335
@@ -392,7 +391,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
392 } 391 }
393 392
394 if ((vport->port_type == LPFC_NPIV_PORT && 393 if ((vport->port_type == LPFC_NPIV_PORT &&
395 phba->cfg_vport_restrict_login)) { 394 vport->cfg_restrict_login)) {
396 395
397 /* In order to preserve RPIs, we want to cleanup 396 /* In order to preserve RPIs, we want to cleanup
398 * the default RPI the firmware created to rcv 397 * the default RPI the firmware created to rcv
@@ -408,7 +407,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
408 ndlp, mbox); 407 ndlp, mbox);
409 return 1; 408 return 1;
410 } 409 }
411 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0); 410 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox);
412 return 1; 411 return 1;
413 412
414out: 413out:
@@ -452,7 +451,7 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
452 lpfc_els_rsp_adisc_acc(vport, cmdiocb, ndlp); 451 lpfc_els_rsp_adisc_acc(vport, cmdiocb, ndlp);
453 } else { 452 } else {
454 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp, 453 lpfc_els_rsp_acc(vport, ELS_CMD_PLOGI, cmdiocb, ndlp,
455 NULL, 0); 454 NULL);
456 } 455 }
457 return 1; 456 return 1;
458 } 457 }
@@ -489,9 +488,9 @@ lpfc_rcv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
489 ndlp->nlp_flag |= NLP_LOGO_ACC; 488 ndlp->nlp_flag |= NLP_LOGO_ACC;
490 spin_unlock_irq(shost->host_lock); 489 spin_unlock_irq(shost->host_lock);
491 if (els_cmd == ELS_CMD_PRLO) 490 if (els_cmd == ELS_CMD_PRLO)
492 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); 491 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
493 else 492 else
494 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 493 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
495 494
496 if (!(ndlp->nlp_type & NLP_FABRIC) || 495 if (!(ndlp->nlp_type & NLP_FABRIC) ||
497 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) { 496 (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) {
@@ -564,10 +563,14 @@ static uint32_t
564lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) 563lpfc_disc_set_adisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
565{ 564{
566 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 565 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
567 struct lpfc_hba *phba = vport->phba; 566
567 if (!ndlp->nlp_rpi) {
568 ndlp->nlp_flag &= ~NLP_NPR_ADISC;
569 return 0;
570 }
568 571
569 /* Check config parameter use-adisc or FCP-2 */ 572 /* Check config parameter use-adisc or FCP-2 */
570 if ((phba->cfg_use_adisc && (vport->fc_flag & FC_RSCN_MODE)) || 573 if ((vport->cfg_use_adisc && (vport->fc_flag & FC_RSCN_MODE)) ||
571 ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) { 574 ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) {
572 spin_lock_irq(shost->host_lock); 575 spin_lock_irq(shost->host_lock);
573 ndlp->nlp_flag |= NLP_NPR_ADISC; 576 ndlp->nlp_flag |= NLP_NPR_ADISC;
@@ -583,12 +586,11 @@ static uint32_t
583lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 586lpfc_disc_illegal(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
584 void *arg, uint32_t evt) 587 void *arg, uint32_t evt)
585{ 588{
586 lpfc_printf_log(vport->phba, KERN_ERR, LOG_DISCOVERY, 589 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
587 "%d (%d):0253 Illegal State Transition: node x%x " 590 "0253 Illegal State Transition: node x%x "
588 "event x%x, state x%x Data: x%x x%x\n", 591 "event x%x, state x%x Data: x%x x%x\n",
589 vport->phba->brd_no, vport->vpi, 592 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi,
590 ndlp->nlp_DID, evt, ndlp->nlp_state, ndlp->nlp_rpi, 593 ndlp->nlp_flag);
591 ndlp->nlp_flag);
592 return ndlp->nlp_state; 594 return ndlp->nlp_state;
593} 595}
594 596
@@ -630,7 +632,7 @@ lpfc_rcv_logo_unused_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
630 spin_lock_irq(shost->host_lock); 632 spin_lock_irq(shost->host_lock);
631 ndlp->nlp_flag |= NLP_LOGO_ACC; 633 ndlp->nlp_flag |= NLP_LOGO_ACC;
632 spin_unlock_irq(shost->host_lock); 634 spin_unlock_irq(shost->host_lock);
633 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 635 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
634 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE); 636 lpfc_nlp_set_state(vport, ndlp, NLP_STE_UNUSED_NODE);
635 637
636 return ndlp->nlp_state; 638 return ndlp->nlp_state;
@@ -726,7 +728,7 @@ lpfc_rcv_els_plogi_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
726 lpfc_els_abort(phba, ndlp); 728 lpfc_els_abort(phba, ndlp);
727 729
728 if (evt == NLP_EVT_RCV_LOGO) { 730 if (evt == NLP_EVT_RCV_LOGO) {
729 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 731 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
730 } else { 732 } else {
731 lpfc_issue_els_logo(vport, ndlp, 0); 733 lpfc_issue_els_logo(vport, ndlp, 0);
732 } 734 }
@@ -778,16 +780,12 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
778 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); 780 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
779 if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3)) 781 if (!lpfc_check_sparm(vport, ndlp, sp, CLASS3))
780 goto out; 782 goto out;
781
782 /* PLOGI chkparm OK */ 783 /* PLOGI chkparm OK */
783 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 784 lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
784 "%d (%d):0121 PLOGI chkparm OK " 785 "0121 PLOGI chkparm OK Data: x%x x%x x%x x%x\n",
785 "Data: x%x x%x x%x x%x\n", 786 ndlp->nlp_DID, ndlp->nlp_state,
786 phba->brd_no, vport->vpi, 787 ndlp->nlp_flag, ndlp->nlp_rpi);
787 ndlp->nlp_DID, ndlp->nlp_state, 788 if (vport->cfg_fcp_class == 2 && (sp->cls2.classValid))
788 ndlp->nlp_flag, ndlp->nlp_rpi);
789
790 if (phba->cfg_fcp_class == 2 && (sp->cls2.classValid))
791 ndlp->nlp_fcp_info |= CLASS2; 789 ndlp->nlp_fcp_info |= CLASS2;
792 else 790 else
793 ndlp->nlp_fcp_info |= CLASS3; 791 ndlp->nlp_fcp_info |= CLASS3;
@@ -806,10 +804,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
806 804
807 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 805 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
808 if (!mbox) { 806 if (!mbox) {
809 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 807 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
810 "%d (%d):0133 PLOGI: no memory for reg_login " 808 "0133 PLOGI: no memory for reg_login "
811 "Data: x%x x%x x%x x%x\n", 809 "Data: x%x x%x x%x x%x\n",
812 phba->brd_no, vport->vpi,
813 ndlp->nlp_DID, ndlp->nlp_state, 810 ndlp->nlp_DID, ndlp->nlp_state,
814 ndlp->nlp_flag, ndlp->nlp_rpi); 811 ndlp->nlp_flag, ndlp->nlp_rpi);
815 goto out; 812 goto out;
@@ -844,30 +841,27 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_vport *vport,
844 kfree(mp); 841 kfree(mp);
845 mempool_free(mbox, phba->mbox_mem_pool); 842 mempool_free(mbox, phba->mbox_mem_pool);
846 843
847 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 844 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
848 "%d (%d):0134 PLOGI: cannot issue reg_login " 845 "0134 PLOGI: cannot issue reg_login "
849 "Data: x%x x%x x%x x%x\n", 846 "Data: x%x x%x x%x x%x\n",
850 phba->brd_no, vport->vpi, 847 ndlp->nlp_DID, ndlp->nlp_state,
851 ndlp->nlp_DID, ndlp->nlp_state, 848 ndlp->nlp_flag, ndlp->nlp_rpi);
852 ndlp->nlp_flag, ndlp->nlp_rpi);
853 } else { 849 } else {
854 mempool_free(mbox, phba->mbox_mem_pool); 850 mempool_free(mbox, phba->mbox_mem_pool);
855 851
856 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 852 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
857 "%d (%d):0135 PLOGI: cannot format reg_login " 853 "0135 PLOGI: cannot format reg_login "
858 "Data: x%x x%x x%x x%x\n", 854 "Data: x%x x%x x%x x%x\n",
859 phba->brd_no, vport->vpi, 855 ndlp->nlp_DID, ndlp->nlp_state,
860 ndlp->nlp_DID, ndlp->nlp_state, 856 ndlp->nlp_flag, ndlp->nlp_rpi);
861 ndlp->nlp_flag, ndlp->nlp_rpi);
862 } 857 }
863 858
864 859
865out: 860out:
866 if (ndlp->nlp_DID == NameServer_DID) { 861 if (ndlp->nlp_DID == NameServer_DID) {
867 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 862 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
868 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 863 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
869 "%d (%d):0261 Cannot Register NameServer login\n", 864 "0261 Cannot Register NameServer login\n");
870 phba->brd_no, vport->vpi);
871 } 865 }
872 866
873 /* Free this node since the driver cannot login or has the wrong 867 /* Free this node since the driver cannot login or has the wrong
@@ -1178,7 +1172,7 @@ lpfc_rcv_prlo_reglogin_issue(struct lpfc_vport *vport,
1178 struct lpfc_iocbq *cmdiocb; 1172 struct lpfc_iocbq *cmdiocb;
1179 1173
1180 cmdiocb = (struct lpfc_iocbq *) arg; 1174 cmdiocb = (struct lpfc_iocbq *) arg;
1181 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); 1175 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1182 return ndlp->nlp_state; 1176 return ndlp->nlp_state;
1183} 1177}
1184 1178
@@ -1189,19 +1183,15 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
1189 uint32_t evt) 1183 uint32_t evt)
1190{ 1184{
1191 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 1185 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
1192 struct lpfc_hba *phba = vport->phba;
1193 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg; 1186 LPFC_MBOXQ_t *pmb = (LPFC_MBOXQ_t *) arg;
1194 MAILBOX_t *mb = &pmb->mb; 1187 MAILBOX_t *mb = &pmb->mb;
1195 uint32_t did = mb->un.varWords[1]; 1188 uint32_t did = mb->un.varWords[1];
1196 1189
1197 if (mb->mbxStatus) { 1190 if (mb->mbxStatus) {
1198 /* RegLogin failed */ 1191 /* RegLogin failed */
1199 lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, 1192 lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1200 "%d (%d):0246 RegLogin failed Data: x%x x%x " 1193 "0246 RegLogin failed Data: x%x x%x x%x\n",
1201 "x%x\n",
1202 phba->brd_no, vport->vpi,
1203 did, mb->mbxStatus, vport->port_state); 1194 did, mb->mbxStatus, vport->port_state);
1204
1205 /* 1195 /*
1206 * If RegLogin failed due to lack of HBA resources do not 1196 * If RegLogin failed due to lack of HBA resources do not
1207 * retry discovery. 1197 * retry discovery.
@@ -1337,7 +1327,7 @@ lpfc_rcv_prlo_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1337{ 1327{
1338 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; 1328 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1339 1329
1340 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); 1330 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1341 return ndlp->nlp_state; 1331 return ndlp->nlp_state;
1342} 1332}
1343 1333
@@ -1358,7 +1348,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1358 irsp = &rspiocb->iocb; 1348 irsp = &rspiocb->iocb;
1359 if (irsp->ulpStatus) { 1349 if (irsp->ulpStatus) {
1360 if ((vport->port_type == LPFC_NPIV_PORT) && 1350 if ((vport->port_type == LPFC_NPIV_PORT) &&
1361 phba->cfg_vport_restrict_login) { 1351 vport->cfg_restrict_login) {
1362 goto out; 1352 goto out;
1363 } 1353 }
1364 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE; 1354 ndlp->nlp_prev_state = NLP_STE_PRLI_ISSUE;
@@ -1380,7 +1370,7 @@ lpfc_cmpl_prli_prli_issue(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1380 } 1370 }
1381 if (!(ndlp->nlp_type & NLP_FCP_TARGET) && 1371 if (!(ndlp->nlp_type & NLP_FCP_TARGET) &&
1382 (vport->port_type == LPFC_NPIV_PORT) && 1372 (vport->port_type == LPFC_NPIV_PORT) &&
1383 phba->cfg_vport_restrict_login) { 1373 vport->cfg_restrict_login) {
1384out: 1374out:
1385 spin_lock_irq(shost->host_lock); 1375 spin_lock_irq(shost->host_lock);
1386 ndlp->nlp_flag |= NLP_TARGET_REMOVE; 1376 ndlp->nlp_flag |= NLP_TARGET_REMOVE;
@@ -1529,7 +1519,7 @@ lpfc_rcv_prlo_unmap_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1529{ 1519{
1530 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; 1520 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1531 1521
1532 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); 1522 lpfc_els_rsp_acc(vport, ELS_CMD_PRLO, cmdiocb, ndlp, NULL);
1533 return ndlp->nlp_state; 1523 return ndlp->nlp_state;
1534} 1524}
1535 1525
@@ -1600,8 +1590,8 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1600 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg; 1590 struct lpfc_iocbq *cmdiocb = (struct lpfc_iocbq *) arg;
1601 1591
1602 /* flush the target */ 1592 /* flush the target */
1603 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1593 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
1604 ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT); 1594 ndlp->nlp_sid, 0, LPFC_CTX_TGT);
1605 1595
1606 /* Treat like rcv logo */ 1596 /* Treat like rcv logo */
1607 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO); 1597 lpfc_rcv_logo(vport, ndlp, cmdiocb, ELS_CMD_PRLO);
@@ -1734,7 +1724,7 @@ lpfc_rcv_prlo_npr_node(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
1734 ndlp->nlp_flag |= NLP_LOGO_ACC; 1724 ndlp->nlp_flag |= NLP_LOGO_ACC;
1735 spin_unlock_irq(shost->host_lock); 1725 spin_unlock_irq(shost->host_lock);
1736 1726
1737 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); 1727 lpfc_els_rsp_acc(vport, ELS_CMD_ACC, cmdiocb, ndlp, NULL);
1738 1728
1739 if ((ndlp->nlp_flag & NLP_DELAY_TMO) == 0) { 1729 if ((ndlp->nlp_flag & NLP_DELAY_TMO) == 0) {
1740 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1); 1730 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ * 1);
@@ -2047,7 +2037,6 @@ int
2047lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, 2037lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2048 void *arg, uint32_t evt) 2038 void *arg, uint32_t evt)
2049{ 2039{
2050 struct lpfc_hba *phba = vport->phba;
2051 uint32_t cur_state, rc; 2040 uint32_t cur_state, rc;
2052 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *, 2041 uint32_t(*func) (struct lpfc_vport *, struct lpfc_nodelist *, void *,
2053 uint32_t); 2042 uint32_t);
@@ -2056,11 +2045,10 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2056 cur_state = ndlp->nlp_state; 2045 cur_state = ndlp->nlp_state;
2057 2046
2058 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */ 2047 /* DSM in event <evt> on NPort <nlp_DID> in state <cur_state> */
2059 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2048 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2060 "%d (%d):0211 DSM in event x%x on NPort x%x in " 2049 "0211 DSM in event x%x on NPort x%x in "
2061 "state %d Data: x%x\n", 2050 "state %d Data: x%x\n",
2062 phba->brd_no, vport->vpi, 2051 evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag);
2063 evt, ndlp->nlp_DID, cur_state, ndlp->nlp_flag);
2064 2052
2065 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, 2053 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2066 "DSM in: evt:%d ste:%d did:x%x", 2054 "DSM in: evt:%d ste:%d did:x%x",
@@ -2070,11 +2058,9 @@ lpfc_disc_state_machine(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
2070 rc = (func) (vport, ndlp, arg, evt); 2058 rc = (func) (vport, ndlp, arg, evt);
2071 2059
2072 /* DSM out state <rc> on NPort <nlp_DID> */ 2060 /* DSM out state <rc> on NPort <nlp_DID> */
2073 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY, 2061 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
2074 "%d (%d):0212 DSM out state %d on NPort x%x " 2062 "0212 DSM out state %d on NPort x%x Data: x%x\n",
2075 "Data: x%x\n", 2063 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2076 phba->brd_no, vport->vpi,
2077 rc, ndlp->nlp_DID, ndlp->nlp_flag);
2078 2064
2079 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM, 2065 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_DSM,
2080 "DSM out: ste:%d did:x%x flg:x%x", 2066 "DSM out: ste:%d did:x%x flg:x%x",
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 8f45bbc42126..17d7dc05149b 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -84,22 +84,21 @@ lpfc_adjust_queue_depth(struct lpfc_hba *phba)
84 * SCSI command completion. 84 * SCSI command completion.
85 */ 85 */
86static inline void 86static inline void
87lpfc_rampup_queue_depth(struct lpfc_hba *phba, 87lpfc_rampup_queue_depth(struct lpfc_vport *vport,
88 struct scsi_device *sdev) 88 struct scsi_device *sdev)
89{ 89{
90 unsigned long flags; 90 unsigned long flags;
91 struct lpfc_hba *phba = vport->phba;
91 atomic_inc(&phba->num_cmd_success); 92 atomic_inc(&phba->num_cmd_success);
92 93
93 if (phba->cfg_lun_queue_depth <= sdev->queue_depth) 94 if (vport->cfg_lun_queue_depth <= sdev->queue_depth)
94 return; 95 return;
95
96 spin_lock_irqsave(&phba->hbalock, flags); 96 spin_lock_irqsave(&phba->hbalock, flags);
97 if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || 97 if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) ||
98 ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) { 98 ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) {
99 spin_unlock_irqrestore(&phba->hbalock, flags); 99 spin_unlock_irqrestore(&phba->hbalock, flags);
100 return; 100 return;
101 } 101 }
102
103 phba->last_ramp_up_time = jiffies; 102 phba->last_ramp_up_time = jiffies;
104 spin_unlock_irqrestore(&phba->hbalock, flags); 103 spin_unlock_irqrestore(&phba->hbalock, flags);
105 104
@@ -119,43 +118,40 @@ lpfc_rampup_queue_depth(struct lpfc_hba *phba,
119void 118void
120lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) 119lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
121{ 120{
122 struct lpfc_vport *vport; 121 struct lpfc_vport **vports;
123 struct Scsi_Host *host; 122 struct Scsi_Host *shost;
124 struct scsi_device *sdev; 123 struct scsi_device *sdev;
125 unsigned long new_queue_depth; 124 unsigned long new_queue_depth;
126 unsigned long num_rsrc_err, num_cmd_success; 125 unsigned long num_rsrc_err, num_cmd_success;
126 int i;
127 127
128 num_rsrc_err = atomic_read(&phba->num_rsrc_err); 128 num_rsrc_err = atomic_read(&phba->num_rsrc_err);
129 num_cmd_success = atomic_read(&phba->num_cmd_success); 129 num_cmd_success = atomic_read(&phba->num_cmd_success);
130 130
131 spin_lock_irq(&phba->hbalock); 131 vports = lpfc_create_vport_work_array(phba);
132 list_for_each_entry(vport, &phba->port_list, listentry) { 132 if (vports != NULL)
133 host = lpfc_shost_from_vport(vport); 133 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
134 if (!scsi_host_get(host)) 134 shost = lpfc_shost_from_vport(vports[i]);
135 continue; 135 shost_for_each_device(sdev, shost) {
136
137 spin_unlock_irq(&phba->hbalock);
138
139 shost_for_each_device(sdev, host) {
140 new_queue_depth = sdev->queue_depth * num_rsrc_err /
141 (num_rsrc_err + num_cmd_success);
142 if (!new_queue_depth)
143 new_queue_depth = sdev->queue_depth - 1;
144 else
145 new_queue_depth = 136 new_queue_depth =
146 sdev->queue_depth - new_queue_depth; 137 sdev->queue_depth * num_rsrc_err /
147 138 (num_rsrc_err + num_cmd_success);
148 if (sdev->ordered_tags) 139 if (!new_queue_depth)
149 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 140 new_queue_depth = sdev->queue_depth - 1;
150 new_queue_depth); 141 else
151 else 142 new_queue_depth = sdev->queue_depth -
152 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 143 new_queue_depth;
153 new_queue_depth); 144 if (sdev->ordered_tags)
145 scsi_adjust_queue_depth(sdev,
146 MSG_ORDERED_TAG,
147 new_queue_depth);
148 else
149 scsi_adjust_queue_depth(sdev,
150 MSG_SIMPLE_TAG,
151 new_queue_depth);
152 }
154 } 153 }
155 spin_lock_irq(&phba->hbalock); 154 lpfc_destroy_vport_work_array(vports);
156 scsi_host_put(host);
157 }
158 spin_unlock_irq(&phba->hbalock);
159 atomic_set(&phba->num_rsrc_err, 0); 155 atomic_set(&phba->num_rsrc_err, 0);
160 atomic_set(&phba->num_cmd_success, 0); 156 atomic_set(&phba->num_cmd_success, 0);
161} 157}
@@ -163,29 +159,27 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
163void 159void
164lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) 160lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
165{ 161{
166 struct lpfc_vport *vport; 162 struct lpfc_vport **vports;
167 struct Scsi_Host *host; 163 struct Scsi_Host *shost;
168 struct scsi_device *sdev; 164 struct scsi_device *sdev;
169 165 int i;
170 spin_lock_irq(&phba->hbalock); 166
171 list_for_each_entry(vport, &phba->port_list, listentry) { 167 vports = lpfc_create_vport_work_array(phba);
172 host = lpfc_shost_from_vport(vport); 168 if (vports != NULL)
173 if (!scsi_host_get(host)) 169 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
174 continue; 170 shost = lpfc_shost_from_vport(vports[i]);
175 171 shost_for_each_device(sdev, shost) {
176 spin_unlock_irq(&phba->hbalock); 172 if (sdev->ordered_tags)
177 shost_for_each_device(sdev, host) { 173 scsi_adjust_queue_depth(sdev,
178 if (sdev->ordered_tags) 174 MSG_ORDERED_TAG,
179 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 175 sdev->queue_depth+1);
180 sdev->queue_depth+1); 176 else
181 else 177 scsi_adjust_queue_depth(sdev,
182 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 178 MSG_SIMPLE_TAG,
183 sdev->queue_depth+1); 179 sdev->queue_depth+1);
180 }
184 } 181 }
185 spin_lock_irq(&phba->hbalock); 182 lpfc_destroy_vport_work_array(vports);
186 scsi_host_put(host);
187 }
188 spin_unlock_irq(&phba->hbalock);
189 atomic_set(&phba->num_rsrc_err, 0); 183 atomic_set(&phba->num_rsrc_err, 0);
190 atomic_set(&phba->num_cmd_success, 0); 184 atomic_set(&phba->num_cmd_success, 0);
191} 185}
@@ -411,9 +405,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
411 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; 405 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
412 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd; 406 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd;
413 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; 407 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
414 struct lpfc_hba *phba = vport->phba;
415 uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm; 408 uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm;
416 uint32_t vpi = vport->vpi;
417 uint32_t resp_info = fcprsp->rspStatus2; 409 uint32_t resp_info = fcprsp->rspStatus2;
418 uint32_t scsi_status = fcprsp->rspStatus3; 410 uint32_t scsi_status = fcprsp->rspStatus3;
419 uint32_t *lp; 411 uint32_t *lp;
@@ -445,15 +437,15 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
445 if (!scsi_status && (resp_info & RESID_UNDER)) 437 if (!scsi_status && (resp_info & RESID_UNDER))
446 logit = LOG_FCP; 438 logit = LOG_FCP;
447 439
448 lpfc_printf_log(phba, KERN_WARNING, logit, 440 lpfc_printf_vlog(vport, KERN_WARNING, logit,
449 "%d (%d):0730 FCP command x%x failed: x%x SNS x%x x%x " 441 "0730 FCP command x%x failed: x%x SNS x%x x%x "
450 "Data: x%x x%x x%x x%x x%x\n", 442 "Data: x%x x%x x%x x%x x%x\n",
451 phba->brd_no, vpi, cmnd->cmnd[0], scsi_status, 443 cmnd->cmnd[0], scsi_status,
452 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info, 444 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
453 be32_to_cpu(fcprsp->rspResId), 445 be32_to_cpu(fcprsp->rspResId),
454 be32_to_cpu(fcprsp->rspSnsLen), 446 be32_to_cpu(fcprsp->rspSnsLen),
455 be32_to_cpu(fcprsp->rspRspLen), 447 be32_to_cpu(fcprsp->rspRspLen),
456 fcprsp->rspInfo3); 448 fcprsp->rspInfo3);
457 449
458 if (resp_info & RSP_LEN_VALID) { 450 if (resp_info & RSP_LEN_VALID) {
459 rsplen = be32_to_cpu(fcprsp->rspRspLen); 451 rsplen = be32_to_cpu(fcprsp->rspRspLen);
@@ -468,12 +460,12 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
468 if (resp_info & RESID_UNDER) { 460 if (resp_info & RESID_UNDER) {
469 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId)); 461 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId));
470 462
471 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 463 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
472 "%d (%d):0716 FCP Read Underrun, expected %d, " 464 "0716 FCP Read Underrun, expected %d, "
473 "residual %d Data: x%x x%x x%x\n", 465 "residual %d Data: x%x x%x x%x\n",
474 phba->brd_no, vpi, be32_to_cpu(fcpcmd->fcpDl), 466 be32_to_cpu(fcpcmd->fcpDl),
475 scsi_get_resid(cmnd), fcpi_parm, cmnd->cmnd[0], 467 scsi_get_resid(cmnd), fcpi_parm, cmnd->cmnd[0],
476 cmnd->underflow); 468 cmnd->underflow);
477 469
478 /* 470 /*
479 * If there is an under run check if under run reported by 471 * If there is an under run check if under run reported by
@@ -483,14 +475,13 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
483 if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) && 475 if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) &&
484 fcpi_parm && 476 fcpi_parm &&
485 (scsi_get_resid(cmnd) != fcpi_parm)) { 477 (scsi_get_resid(cmnd) != fcpi_parm)) {
486 lpfc_printf_log(phba, KERN_WARNING, 478 lpfc_printf_vlog(vport, KERN_WARNING,
487 LOG_FCP | LOG_FCP_ERROR, 479 LOG_FCP | LOG_FCP_ERROR,
488 "%d (%d):0735 FCP Read Check Error " 480 "0735 FCP Read Check Error "
489 "and Underrun Data: x%x x%x x%x x%x\n", 481 "and Underrun Data: x%x x%x x%x x%x\n",
490 phba->brd_no, vpi, 482 be32_to_cpu(fcpcmd->fcpDl),
491 be32_to_cpu(fcpcmd->fcpDl), 483 scsi_get_resid(cmnd), fcpi_parm,
492 scsi_get_resid(cmnd), fcpi_parm, 484 cmnd->cmnd[0]);
493 cmnd->cmnd[0]);
494 scsi_set_resid(cmnd, scsi_bufflen(cmnd)); 485 scsi_set_resid(cmnd, scsi_bufflen(cmnd));
495 host_status = DID_ERROR; 486 host_status = DID_ERROR;
496 } 487 }
@@ -504,21 +495,19 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
504 (scsi_status == SAM_STAT_GOOD) && 495 (scsi_status == SAM_STAT_GOOD) &&
505 (scsi_bufflen(cmnd) - scsi_get_resid(cmnd) 496 (scsi_bufflen(cmnd) - scsi_get_resid(cmnd)
506 < cmnd->underflow)) { 497 < cmnd->underflow)) {
507 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 498 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
508 "%d (%d):0717 FCP command x%x residual " 499 "0717 FCP command x%x residual "
509 "underrun converted to error " 500 "underrun converted to error "
510 "Data: x%x x%x x%x\n", 501 "Data: x%x x%x x%x\n",
511 phba->brd_no, vpi, cmnd->cmnd[0], 502 cmnd->cmnd[0], scsi_bufflen(cmnd),
512 scsi_bufflen(cmnd), 503 scsi_get_resid(cmnd), cmnd->underflow);
513 scsi_get_resid(cmnd), cmnd->underflow);
514 host_status = DID_ERROR; 504 host_status = DID_ERROR;
515 } 505 }
516 } else if (resp_info & RESID_OVER) { 506 } else if (resp_info & RESID_OVER) {
517 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 507 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
518 "%d (%d):0720 FCP command x%x residual " 508 "0720 FCP command x%x residual overrun error. "
519 "overrun error. Data: x%x x%x \n", 509 "Data: x%x x%x \n", cmnd->cmnd[0],
520 phba->brd_no, vpi, cmnd->cmnd[0], 510 scsi_bufflen(cmnd), scsi_get_resid(cmnd));
521 scsi_bufflen(cmnd), scsi_get_resid(cmnd));
522 host_status = DID_ERROR; 511 host_status = DID_ERROR;
523 512
524 /* 513 /*
@@ -527,13 +516,12 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
527 */ 516 */
528 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm && 517 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm &&
529 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) { 518 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) {
530 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR, 519 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
531 "%d (%d):0734 FCP Read Check Error Data: " 520 "0734 FCP Read Check Error Data: "
532 "x%x x%x x%x x%x\n", 521 "x%x x%x x%x x%x\n",
533 phba->brd_no, vpi, 522 be32_to_cpu(fcpcmd->fcpDl),
534 be32_to_cpu(fcpcmd->fcpDl), 523 be32_to_cpu(fcprsp->rspResId),
535 be32_to_cpu(fcprsp->rspResId), 524 fcpi_parm, cmnd->cmnd[0]);
536 fcpi_parm, cmnd->cmnd[0]);
537 host_status = DID_ERROR; 525 host_status = DID_ERROR;
538 scsi_set_resid(cmnd, scsi_bufflen(cmnd)); 526 scsi_set_resid(cmnd, scsi_bufflen(cmnd));
539 } 527 }
@@ -552,9 +540,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
552 struct lpfc_rport_data *rdata = lpfc_cmd->rdata; 540 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
553 struct lpfc_nodelist *pnode = rdata->pnode; 541 struct lpfc_nodelist *pnode = rdata->pnode;
554 struct scsi_cmnd *cmd = lpfc_cmd->pCmd; 542 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
555 uint32_t vpi = (lpfc_cmd->cur_iocbq.vport
556 ? lpfc_cmd->cur_iocbq.vport->vpi
557 : 0);
558 int result; 543 int result;
559 struct scsi_device *sdev, *tmp_sdev; 544 struct scsi_device *sdev, *tmp_sdev;
560 int depth = 0; 545 int depth = 0;
@@ -569,15 +554,15 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
569 else if (lpfc_cmd->status >= IOSTAT_CNT) 554 else if (lpfc_cmd->status >= IOSTAT_CNT)
570 lpfc_cmd->status = IOSTAT_DEFAULT; 555 lpfc_cmd->status = IOSTAT_DEFAULT;
571 556
572 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 557 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
573 "%d (%d):0729 FCP cmd x%x failed <%d/%d> " 558 "0729 FCP cmd x%x failed <%d/%d> "
574 "status: x%x result: x%x Data: x%x x%x\n", 559 "status: x%x result: x%x Data: x%x x%x\n",
575 phba->brd_no, vpi, cmd->cmnd[0], 560 cmd->cmnd[0],
576 cmd->device ? cmd->device->id : 0xffff, 561 cmd->device ? cmd->device->id : 0xffff,
577 cmd->device ? cmd->device->lun : 0xffff, 562 cmd->device ? cmd->device->lun : 0xffff,
578 lpfc_cmd->status, lpfc_cmd->result, 563 lpfc_cmd->status, lpfc_cmd->result,
579 pIocbOut->iocb.ulpContext, 564 pIocbOut->iocb.ulpContext,
580 lpfc_cmd->cur_iocbq.iocb.ulpIoTag); 565 lpfc_cmd->cur_iocbq.iocb.ulpIoTag);
581 566
582 switch (lpfc_cmd->status) { 567 switch (lpfc_cmd->status) {
583 case IOSTAT_FCP_RSP_ERROR: 568 case IOSTAT_FCP_RSP_ERROR:
@@ -610,13 +595,12 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
610 if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) { 595 if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) {
611 uint32_t *lp = (uint32_t *)cmd->sense_buffer; 596 uint32_t *lp = (uint32_t *)cmd->sense_buffer;
612 597
613 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 598 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
614 "%d (%d):0710 Iodone <%d/%d> cmd %p, error " 599 "0710 Iodone <%d/%d> cmd %p, error "
615 "x%x SNS x%x x%x Data: x%x x%x\n", 600 "x%x SNS x%x x%x Data: x%x x%x\n",
616 phba->brd_no, vpi, cmd->device->id, 601 cmd->device->id, cmd->device->lun, cmd,
617 cmd->device->lun, cmd, cmd->result, 602 cmd->result, *lp, *(lp + 3), cmd->retries,
618 *lp, *(lp + 3), cmd->retries, 603 scsi_get_resid(cmd));
619 scsi_get_resid(cmd));
620 } 604 }
621 605
622 result = cmd->result; 606 result = cmd->result;
@@ -631,16 +615,16 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
631 615
632 616
633 if (!result) 617 if (!result)
634 lpfc_rampup_queue_depth(phba, sdev); 618 lpfc_rampup_queue_depth(vport, sdev);
635 619
636 if (!result && pnode != NULL && 620 if (!result && pnode != NULL &&
637 ((jiffies - pnode->last_ramp_up_time) > 621 ((jiffies - pnode->last_ramp_up_time) >
638 LPFC_Q_RAMP_UP_INTERVAL * HZ) && 622 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
639 ((jiffies - pnode->last_q_full_time) > 623 ((jiffies - pnode->last_q_full_time) >
640 LPFC_Q_RAMP_UP_INTERVAL * HZ) && 624 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
641 (phba->cfg_lun_queue_depth > sdev->queue_depth)) { 625 (vport->cfg_lun_queue_depth > sdev->queue_depth)) {
642 shost_for_each_device(tmp_sdev, sdev->host) { 626 shost_for_each_device(tmp_sdev, sdev->host) {
643 if (phba->cfg_lun_queue_depth > tmp_sdev->queue_depth) { 627 if (vport->cfg_lun_queue_depth > tmp_sdev->queue_depth){
644 if (tmp_sdev->id != sdev->id) 628 if (tmp_sdev->id != sdev->id)
645 continue; 629 continue;
646 if (tmp_sdev->ordered_tags) 630 if (tmp_sdev->ordered_tags)
@@ -680,10 +664,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
680 depth = sdev->host->cmd_per_lun; 664 depth = sdev->host->cmd_per_lun;
681 665
682 if (depth) { 666 if (depth) {
683 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 667 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
684 "%d (%d):0711 detected queue full - " 668 "0711 detected queue full - lun queue "
685 "lun queue depth adjusted to %d.\n", 669 "depth adjusted to %d.\n", depth);
686 phba->brd_no, vpi, depth);
687 } 670 }
688 } 671 }
689 672
@@ -853,12 +836,9 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,
853 return FAILED; 836 return FAILED;
854 837
855 /* Issue Target Reset to TGT <num> */ 838 /* Issue Target Reset to TGT <num> */
856 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 839 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
857 "%d (%d):0702 Issue Target Reset to TGT %d " 840 "0702 Issue Target Reset to TGT %d Data: x%x x%x\n",
858 "Data: x%x x%x\n", 841 tgt_id, rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag);
859 phba->brd_no, vport->vpi, tgt_id,
860 rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag);
861
862 ret = lpfc_sli_issue_iocb_wait(phba, 842 ret = lpfc_sli_issue_iocb_wait(phba,
863 &phba->sli.ring[phba->sli.fcp_ring], 843 &phba->sli.ring[phba->sli.fcp_ring],
864 iocbq, iocbqrsp, lpfc_cmd->timeout); 844 iocbq, iocbqrsp, lpfc_cmd->timeout);
@@ -965,10 +945,9 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
965 if (lpfc_cmd == NULL) { 945 if (lpfc_cmd == NULL) {
966 lpfc_adjust_queue_depth(phba); 946 lpfc_adjust_queue_depth(phba);
967 947
968 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 948 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
969 "%d (%d):0707 driver's buffer pool is empty, " 949 "0707 driver's buffer pool is empty, "
970 "IO busied\n", 950 "IO busied\n");
971 phba->brd_no, vport->vpi);
972 goto out_host_busy; 951 goto out_host_busy;
973 } 952 }
974 953
@@ -1103,28 +1082,25 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
1103 1082
1104 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT * HZ); 1083 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT * HZ);
1105 if (++loop_count 1084 if (++loop_count
1106 > (2 * phba->cfg_devloss_tmo)/LPFC_ABORT_WAIT) 1085 > (2 * vport->cfg_devloss_tmo)/LPFC_ABORT_WAIT)
1107 break; 1086 break;
1108 } 1087 }
1109 1088
1110 if (lpfc_cmd->pCmd == cmnd) { 1089 if (lpfc_cmd->pCmd == cmnd) {
1111 ret = FAILED; 1090 ret = FAILED;
1112 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1091 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1113 "%d (%d):0748 abort handler timed out waiting " 1092 "0748 abort handler timed out waiting "
1114 "for abort to complete: ret %#x, ID %d, " 1093 "for abort to complete: ret %#x, ID %d, "
1115 "LUN %d, snum %#lx\n", 1094 "LUN %d, snum %#lx\n",
1116 phba->brd_no, vport->vpi, ret, 1095 ret, cmnd->device->id, cmnd->device->lun,
1117 cmnd->device->id, cmnd->device->lun, 1096 cmnd->serial_number);
1118 cmnd->serial_number);
1119 } 1097 }
1120 1098
1121 out: 1099 out:
1122 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 1100 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
1123 "%d (%d):0749 SCSI Layer I/O Abort Request " 1101 "0749 SCSI Layer I/O Abort Request Status x%x ID %d "
1124 "Status x%x ID %d LUN %d snum %#lx\n", 1102 "LUN %d snum %#lx\n", ret, cmnd->device->id,
1125 phba->brd_no, vport->vpi, ret, cmnd->device->id, 1103 cmnd->device->lun, cmnd->serial_number);
1126 cmnd->device->lun, cmnd->serial_number);
1127
1128 return ret; 1104 return ret;
1129} 1105}
1130 1106
@@ -1158,12 +1134,11 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1158 loopcnt++; 1134 loopcnt++;
1159 rdata = cmnd->device->hostdata; 1135 rdata = cmnd->device->hostdata;
1160 if (!rdata || 1136 if (!rdata ||
1161 (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) { 1137 (loopcnt > ((vport->cfg_devloss_tmo * 2) + 1))){
1162 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1138 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1163 "%d (%d):0721 LUN Reset rport " 1139 "0721 LUN Reset rport "
1164 "failure: cnt x%x rdata x%p\n", 1140 "failure: cnt x%x rdata x%p\n",
1165 phba->brd_no, vport->vpi, 1141 loopcnt, rdata);
1166 loopcnt, rdata);
1167 goto out; 1142 goto out;
1168 } 1143 }
1169 pnode = rdata->pnode; 1144 pnode = rdata->pnode;
@@ -1193,12 +1168,10 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1193 if (iocbqrsp == NULL) 1168 if (iocbqrsp == NULL)
1194 goto out_free_scsi_buf; 1169 goto out_free_scsi_buf;
1195 1170
1196 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 1171 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
1197 "%d (%d):0703 Issue target reset to TGT %d LUN %d " 1172 "0703 Issue target reset to TGT %d LUN %d "
1198 "rpi x%x nlp_flag x%x\n", 1173 "rpi x%x nlp_flag x%x\n", cmnd->device->id,
1199 phba->brd_no, vport->vpi, cmnd->device->id, 1174 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
1200 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
1201
1202 iocb_status = lpfc_sli_issue_iocb_wait(phba, 1175 iocb_status = lpfc_sli_issue_iocb_wait(phba,
1203 &phba->sli.ring[phba->sli.fcp_ring], 1176 &phba->sli.ring[phba->sli.fcp_ring],
1204 iocbq, iocbqrsp, lpfc_cmd->timeout); 1177 iocbq, iocbqrsp, lpfc_cmd->timeout);
@@ -1221,33 +1194,28 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1221 * Unfortunately, some targets do not abide by this forcing the driver 1194 * Unfortunately, some targets do not abide by this forcing the driver
1222 * to double check. 1195 * to double check.
1223 */ 1196 */
1224 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1197 cnt = lpfc_sli_sum_iocb(vport, cmnd->device->id, cmnd->device->lun,
1225 cmnd->device->id, cmnd->device->lun,
1226 LPFC_CTX_LUN); 1198 LPFC_CTX_LUN);
1227 if (cnt) 1199 if (cnt)
1228 lpfc_sli_abort_iocb(phba, 1200 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
1229 &phba->sli.ring[phba->sli.fcp_ring],
1230 cmnd->device->id, cmnd->device->lun, 1201 cmnd->device->id, cmnd->device->lun,
1231 0, LPFC_CTX_LUN); 1202 LPFC_CTX_LUN);
1232 loopcnt = 0; 1203 loopcnt = 0;
1233 while(cnt) { 1204 while(cnt) {
1234 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); 1205 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1235 1206
1236 if (++loopcnt 1207 if (++loopcnt
1237 > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT) 1208 > (2 * vport->cfg_devloss_tmo)/LPFC_RESET_WAIT)
1238 break; 1209 break;
1239 1210
1240 cnt = lpfc_sli_sum_iocb(phba, 1211 cnt = lpfc_sli_sum_iocb(vport, cmnd->device->id,
1241 &phba->sli.ring[phba->sli.fcp_ring], 1212 cmnd->device->lun, LPFC_CTX_LUN);
1242 cmnd->device->id, cmnd->device->lun,
1243 LPFC_CTX_LUN);
1244 } 1213 }
1245 1214
1246 if (cnt) { 1215 if (cnt) {
1247 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1216 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1248 "%d (%d):0719 device reset I/O flush failure: " 1217 "0719 device reset I/O flush failure: "
1249 "cnt x%x\n", 1218 "cnt x%x\n", cnt);
1250 phba->brd_no, vport->vpi, cnt);
1251 ret = FAILED; 1219 ret = FAILED;
1252 } 1220 }
1253 1221
@@ -1255,12 +1223,11 @@ out_free_scsi_buf:
1255 if (iocb_status != IOCB_TIMEDOUT) { 1223 if (iocb_status != IOCB_TIMEDOUT) {
1256 lpfc_release_scsi_buf(phba, lpfc_cmd); 1224 lpfc_release_scsi_buf(phba, lpfc_cmd);
1257 } 1225 }
1258 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1226 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1259 "%d (%d):0713 SCSI layer issued device reset (%d, %d) " 1227 "0713 SCSI layer issued device reset (%d, %d) "
1260 "return x%x status x%x result x%x\n", 1228 "return x%x status x%x result x%x\n",
1261 phba->brd_no, vport->vpi, cmnd->device->id, 1229 cmnd->device->id, cmnd->device->lun, ret,
1262 cmnd->device->lun, ret, cmd_status, cmd_result); 1230 cmd_status, cmd_result);
1263
1264out: 1231out:
1265 return ret; 1232 return ret;
1266} 1233}
@@ -1311,10 +1278,9 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1311 cmnd->device->lun, 1278 cmnd->device->lun,
1312 ndlp->rport->dd_data); 1279 ndlp->rport->dd_data);
1313 if (ret != SUCCESS) { 1280 if (ret != SUCCESS) {
1314 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1281 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1315 "%d (%d):0700 Bus Reset on target %d " 1282 "0700 Bus Reset on target %d failed\n",
1316 "failed\n", 1283 i);
1317 phba->brd_no, vport->vpi, i);
1318 err_count++; 1284 err_count++;
1319 break; 1285 break;
1320 } 1286 }
@@ -1333,35 +1299,30 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1333 * the targets. Unfortunately, some targets do not abide by 1299 * the targets. Unfortunately, some targets do not abide by
1334 * this forcing the driver to double check. 1300 * this forcing the driver to double check.
1335 */ 1301 */
1336 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1302 cnt = lpfc_sli_sum_iocb(vport, 0, 0, LPFC_CTX_HOST);
1337 0, 0, LPFC_CTX_HOST);
1338 if (cnt) 1303 if (cnt)
1339 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1304 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
1340 0, 0, 0, LPFC_CTX_HOST); 1305 0, 0, LPFC_CTX_HOST);
1341 loopcnt = 0; 1306 loopcnt = 0;
1342 while(cnt) { 1307 while(cnt) {
1343 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); 1308 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1344 1309
1345 if (++loopcnt 1310 if (++loopcnt
1346 > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT) 1311 > (2 * vport->cfg_devloss_tmo)/LPFC_RESET_WAIT)
1347 break; 1312 break;
1348 1313
1349 cnt = lpfc_sli_sum_iocb(phba, 1314 cnt = lpfc_sli_sum_iocb(vport, 0, 0, LPFC_CTX_HOST);
1350 &phba->sli.ring[phba->sli.fcp_ring],
1351 0, 0, LPFC_CTX_HOST);
1352 } 1315 }
1353 1316
1354 if (cnt) { 1317 if (cnt) {
1355 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1318 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1356 "%d (%d):0715 Bus Reset I/O flush failure: " 1319 "0715 Bus Reset I/O flush failure: "
1357 "cnt x%x left x%x\n", 1320 "cnt x%x left x%x\n", cnt, i);
1358 phba->brd_no, vport->vpi, cnt, i);
1359 ret = FAILED; 1321 ret = FAILED;
1360 } 1322 }
1361 1323
1362 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1324 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1363 "%d (%d):0714 SCSI layer issued Bus Reset Data: x%x\n", 1325 "0714 SCSI layer issued Bus Reset Data: x%x\n", ret);
1364 phba->brd_no, vport->vpi, ret);
1365out: 1326out:
1366 return ret; 1327 return ret;
1367} 1328}
@@ -1390,36 +1351,32 @@ lpfc_slave_alloc(struct scsi_device *sdev)
1390 * extra. This list of scsi bufs exists for the lifetime of the driver. 1351 * extra. This list of scsi bufs exists for the lifetime of the driver.
1391 */ 1352 */
1392 total = phba->total_scsi_bufs; 1353 total = phba->total_scsi_bufs;
1393 num_to_alloc = phba->cfg_lun_queue_depth + 2; 1354 num_to_alloc = vport->cfg_lun_queue_depth + 2;
1394 1355
1395 /* Allow some exchanges to be available always to complete discovery */ 1356 /* Allow some exchanges to be available always to complete discovery */
1396 if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { 1357 if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) {
1397 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 1358 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
1398 "%d (%d):0704 At limitation of %d " 1359 "0704 At limitation of %d preallocated "
1399 "preallocated command buffers\n", 1360 "command buffers\n", total);
1400 phba->brd_no, vport->vpi, total);
1401 return 0; 1361 return 0;
1402
1403 /* Allow some exchanges to be available always to complete discovery */ 1362 /* Allow some exchanges to be available always to complete discovery */
1404 } else if (total + num_to_alloc > 1363 } else if (total + num_to_alloc >
1405 phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { 1364 phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) {
1406 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 1365 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
1407 "%d (%d):0705 Allocation request of %d " 1366 "0705 Allocation request of %d "
1408 "command buffers will exceed max of %d. " 1367 "command buffers will exceed max of %d. "
1409 "Reducing allocation request to %d.\n", 1368 "Reducing allocation request to %d.\n",
1410 phba->brd_no, vport->vpi, num_to_alloc, 1369 num_to_alloc, phba->cfg_hba_queue_depth,
1411 phba->cfg_hba_queue_depth, 1370 (phba->cfg_hba_queue_depth - total));
1412 (phba->cfg_hba_queue_depth - total));
1413 num_to_alloc = phba->cfg_hba_queue_depth - total; 1371 num_to_alloc = phba->cfg_hba_queue_depth - total;
1414 } 1372 }
1415 1373
1416 for (i = 0; i < num_to_alloc; i++) { 1374 for (i = 0; i < num_to_alloc; i++) {
1417 scsi_buf = lpfc_new_scsi_buf(vport); 1375 scsi_buf = lpfc_new_scsi_buf(vport);
1418 if (!scsi_buf) { 1376 if (!scsi_buf) {
1419 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1377 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1420 "%d (%d):0706 Failed to allocate " 1378 "0706 Failed to allocate "
1421 "command buffer\n", 1379 "command buffer\n");
1422 phba->brd_no, vport->vpi);
1423 break; 1380 break;
1424 } 1381 }
1425 1382
@@ -1439,9 +1396,9 @@ lpfc_slave_configure(struct scsi_device *sdev)
1439 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1396 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1440 1397
1441 if (sdev->tagged_supported) 1398 if (sdev->tagged_supported)
1442 scsi_activate_tcq(sdev, phba->cfg_lun_queue_depth); 1399 scsi_activate_tcq(sdev, vport->cfg_lun_queue_depth);
1443 else 1400 else
1444 scsi_deactivate_tcq(sdev, phba->cfg_lun_queue_depth); 1401 scsi_deactivate_tcq(sdev, vport->cfg_lun_queue_depth);
1445 1402
1446 /* 1403 /*
1447 * Initialize the fc transport attributes for the target 1404 * Initialize the fc transport attributes for the target
@@ -1449,7 +1406,7 @@ lpfc_slave_configure(struct scsi_device *sdev)
1449 * target pointer is stored in the starget_data for the 1406 * target pointer is stored in the starget_data for the
1450 * driver's sysfs entry point functions. 1407 * driver's sysfs entry point functions.
1451 */ 1408 */
1452 rport->dev_loss_tmo = phba->cfg_devloss_tmo; 1409 rport->dev_loss_tmo = vport->cfg_devloss_tmo;
1453 1410
1454 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 1411 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
1455 lpfc_sli_poll_fcp_ring(phba); 1412 lpfc_sli_poll_fcp_ring(phba);
@@ -1487,3 +1444,23 @@ struct scsi_host_template lpfc_template = {
1487 .shost_attrs = lpfc_hba_attrs, 1444 .shost_attrs = lpfc_hba_attrs,
1488 .max_sectors = 0xFFFF, 1445 .max_sectors = 0xFFFF,
1489}; 1446};
1447
1448struct scsi_host_template lpfc_vport_template = {
1449 .module = THIS_MODULE,
1450 .name = LPFC_DRIVER_NAME,
1451 .info = lpfc_info,
1452 .queuecommand = lpfc_queuecommand,
1453 .eh_abort_handler = lpfc_abort_handler,
1454 .eh_device_reset_handler= lpfc_device_reset_handler,
1455 .eh_bus_reset_handler = lpfc_bus_reset_handler,
1456 .slave_alloc = lpfc_slave_alloc,
1457 .slave_configure = lpfc_slave_configure,
1458 .slave_destroy = lpfc_slave_destroy,
1459 .scan_finished = lpfc_scan_finished,
1460 .this_id = -1,
1461 .sg_tablesize = LPFC_SG_SEG_CNT,
1462 .cmd_per_lun = LPFC_CMD_PER_LUN,
1463 .use_clustering = ENABLE_CLUSTERING,
1464 .shost_attrs = lpfc_vport_attrs,
1465 .max_sectors = 0xFFFF,
1466};
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index f4d5a6b00fde..ce5ff2bccba6 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -49,9 +49,8 @@
49 lpfc_printf_log(phba, \ 49 lpfc_printf_log(phba, \
50 KERN_INFO, \ 50 KERN_INFO, \
51 LOG_MBOX | LOG_SLI, \ 51 LOG_MBOX | LOG_SLI, \
52 "%d (%d):0311 Mailbox command x%x cannot " \ 52 "(%d):0311 Mailbox command x%x cannot " \
53 "issue Data: x%x x%x x%x\n", \ 53 "issue Data: x%x x%x x%x\n", \
54 phba->brd_no, \
55 pmbox->vport ? pmbox->vport->vpi : 0, \ 54 pmbox->vport ? pmbox->vport->vpi : 0, \
56 pmbox->mb.mbxCommand, \ 55 pmbox->mb.mbxCommand, \
57 phba->pport->port_state, \ 56 phba->pport->port_state, \
@@ -231,13 +230,11 @@ lpfc_sli_ring_map(struct lpfc_hba *phba)
231 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); 230 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
232 if (rc != MBX_SUCCESS) { 231 if (rc != MBX_SUCCESS) {
233 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 232 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
234 "%d:0446 Adapter failed to init (%d), " 233 "0446 Adapter failed to init (%d), "
235 "mbxCmd x%x CFG_RING, mbxStatus x%x, " 234 "mbxCmd x%x CFG_RING, mbxStatus x%x, "
236 "ring %d\n", 235 "ring %d\n",
237 phba->brd_no, rc, 236 rc, pmbox->mbxCommand,
238 pmbox->mbxCommand, 237 pmbox->mbxStatus, i);
239 pmbox->mbxStatus,
240 i);
241 phba->link_state = LPFC_HBA_ERROR; 238 phba->link_state = LPFC_HBA_ERROR;
242 ret = -ENXIO; 239 ret = -ENXIO;
243 break; 240 break;
@@ -296,9 +293,9 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
296 293
297 if (unlikely(pring->local_getidx >= max_cmd_idx)) { 294 if (unlikely(pring->local_getidx >= max_cmd_idx)) {
298 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 295 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
299 "%d:0315 Ring %d issue: portCmdGet %d " 296 "0315 Ring %d issue: portCmdGet %d "
300 "is bigger then cmd ring %d\n", 297 "is bigger then cmd ring %d\n",
301 phba->brd_no, pring->ringno, 298 pring->ringno,
302 pring->local_getidx, max_cmd_idx); 299 pring->local_getidx, max_cmd_idx);
303 300
304 phba->link_state = LPFC_HBA_ERROR; 301 phba->link_state = LPFC_HBA_ERROR;
@@ -366,7 +363,7 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
366 if (psli->iocbq_lookup) 363 if (psli->iocbq_lookup)
367 memcpy(new_arr, old_arr, 364 memcpy(new_arr, old_arr,
368 ((psli->last_iotag + 1) * 365 ((psli->last_iotag + 1) *
369 sizeof (struct lpfc_iocbq *))); 366 sizeof (struct lpfc_iocbq *)));
370 psli->iocbq_lookup = new_arr; 367 psli->iocbq_lookup = new_arr;
371 psli->iocbq_lookup_len = new_len; 368 psli->iocbq_lookup_len = new_len;
372 psli->last_iotag = iotag; 369 psli->last_iotag = iotag;
@@ -380,8 +377,8 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
380 spin_unlock_irq(&phba->hbalock); 377 spin_unlock_irq(&phba->hbalock);
381 378
382 lpfc_printf_log(phba, KERN_ERR,LOG_SLI, 379 lpfc_printf_log(phba, KERN_ERR,LOG_SLI,
383 "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n", 380 "0318 Failed to allocate IOTAG.last IOTAG is %d\n",
384 phba->brd_no, psli->last_iotag); 381 psli->last_iotag);
385 382
386 return 0; 383 return 0;
387} 384}
@@ -395,6 +392,14 @@ lpfc_sli_submit_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
395 */ 392 */
396 nextiocb->iocb.ulpIoTag = (nextiocb->iocb_cmpl) ? nextiocb->iotag : 0; 393 nextiocb->iocb.ulpIoTag = (nextiocb->iocb_cmpl) ? nextiocb->iotag : 0;
397 394
395 if (pring->ringno == LPFC_ELS_RING) {
396 lpfc_debugfs_slow_ring_trc(phba,
397 "IOCB cmd ring: wd4:x%08x wd6:x%08x wd7:x%08x",
398 *(((uint32_t *) &nextiocb->iocb) + 4),
399 *(((uint32_t *) &nextiocb->iocb) + 6),
400 *(((uint32_t *) &nextiocb->iocb) + 7));
401 }
402
398 /* 403 /*
399 * Issue iocb command to adapter 404 * Issue iocb command to adapter
400 */ 405 */
@@ -527,10 +532,9 @@ lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno)
527 if (unlikely(hbqp->local_hbqGetIdx >= hbqp->entry_count)) { 532 if (unlikely(hbqp->local_hbqGetIdx >= hbqp->entry_count)) {
528 lpfc_printf_log(phba, KERN_ERR, 533 lpfc_printf_log(phba, KERN_ERR,
529 LOG_SLI | LOG_VPORT, 534 LOG_SLI | LOG_VPORT,
530 "%d:1802 HBQ %d: local_hbqGetIdx " 535 "1802 HBQ %d: local_hbqGetIdx "
531 "%u is > than hbqp->entry_count %u\n", 536 "%u is > than hbqp->entry_count %u\n",
532 phba->brd_no, hbqno, 537 hbqno, hbqp->local_hbqGetIdx,
533 hbqp->local_hbqGetIdx,
534 hbqp->entry_count); 538 hbqp->entry_count);
535 539
536 phba->link_state = LPFC_HBA_ERROR; 540 phba->link_state = LPFC_HBA_ERROR;
@@ -541,7 +545,8 @@ lpfc_sli_next_hbq_slot(struct lpfc_hba *phba, uint32_t hbqno)
541 return NULL; 545 return NULL;
542 } 546 }
543 547
544 return (struct lpfc_hbq_entry *) phba->hbqslimp.virt + hbqp->hbqPutIdx; 548 return (struct lpfc_hbq_entry *) phba->hbqs[hbqno].hbq_virt +
549 hbqp->hbqPutIdx;
545} 550}
546 551
547void 552void
@@ -549,18 +554,21 @@ lpfc_sli_hbqbuf_free_all(struct lpfc_hba *phba)
549{ 554{
550 struct lpfc_dmabuf *dmabuf, *next_dmabuf; 555 struct lpfc_dmabuf *dmabuf, *next_dmabuf;
551 struct hbq_dmabuf *hbq_buf; 556 struct hbq_dmabuf *hbq_buf;
557 int i, hbq_count;
552 558
559 hbq_count = lpfc_sli_hbq_count();
553 /* Return all memory used by all HBQs */ 560 /* Return all memory used by all HBQs */
554 list_for_each_entry_safe(dmabuf, next_dmabuf, 561 for (i = 0; i < hbq_count; ++i) {
555 &phba->hbq_buffer_list, list) { 562 list_for_each_entry_safe(dmabuf, next_dmabuf,
556 hbq_buf = container_of(dmabuf, struct hbq_dmabuf, dbuf); 563 &phba->hbqs[i].hbq_buffer_list, list) {
557 list_del(&hbq_buf->dbuf.list); 564 hbq_buf = container_of(dmabuf, struct hbq_dmabuf, dbuf);
558 lpfc_hbq_free(phba, hbq_buf->dbuf.virt, hbq_buf->dbuf.phys); 565 list_del(&hbq_buf->dbuf.list);
559 kfree(hbq_buf); 566 (phba->hbqs[i].hbq_free_buffer)(phba, hbq_buf);
567 }
560 } 568 }
561} 569}
562 570
563static void 571static struct lpfc_hbq_entry *
564lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno, 572lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno,
565 struct hbq_dmabuf *hbq_buf) 573 struct hbq_dmabuf *hbq_buf)
566{ 574{
@@ -574,7 +582,7 @@ lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno,
574 582
575 hbqe->bde.addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); 583 hbqe->bde.addrHigh = le32_to_cpu(putPaddrHigh(physaddr));
576 hbqe->bde.addrLow = le32_to_cpu(putPaddrLow(physaddr)); 584 hbqe->bde.addrLow = le32_to_cpu(putPaddrLow(physaddr));
577 hbqe->bde.tus.f.bdeSize = FCELSSIZE; 585 hbqe->bde.tus.f.bdeSize = hbq_buf->size;
578 hbqe->bde.tus.f.bdeFlags = 0; 586 hbqe->bde.tus.f.bdeFlags = 0;
579 hbqe->bde.tus.w = le32_to_cpu(hbqe->bde.tus.w); 587 hbqe->bde.tus.w = le32_to_cpu(hbqe->bde.tus.w);
580 hbqe->buffer_tag = le32_to_cpu(hbq_buf->tag); 588 hbqe->buffer_tag = le32_to_cpu(hbq_buf->tag);
@@ -583,8 +591,9 @@ lpfc_sli_hbq_to_firmware(struct lpfc_hba *phba, uint32_t hbqno,
583 writel(hbqp->hbqPutIdx, phba->hbq_put + hbqno); 591 writel(hbqp->hbqPutIdx, phba->hbq_put + hbqno);
584 /* flush */ 592 /* flush */
585 readl(phba->hbq_put + hbqno); 593 readl(phba->hbq_put + hbqno);
586 list_add_tail(&hbq_buf->dbuf.list, &phba->hbq_buffer_list); 594 list_add_tail(&hbq_buf->dbuf.list, &hbqp->hbq_buffer_list);
587 } 595 }
596 return hbqe;
588} 597}
589 598
590static struct lpfc_hbq_init lpfc_els_hbq = { 599static struct lpfc_hbq_init lpfc_els_hbq = {
@@ -592,22 +601,38 @@ static struct lpfc_hbq_init lpfc_els_hbq = {
592 .entry_count = 200, 601 .entry_count = 200,
593 .mask_count = 0, 602 .mask_count = 0,
594 .profile = 0, 603 .profile = 0,
595 .ring_mask = 1 << LPFC_ELS_RING, 604 .ring_mask = (1 << LPFC_ELS_RING),
596 .buffer_count = 0, 605 .buffer_count = 0,
597 .init_count = 20, 606 .init_count = 20,
598 .add_count = 5, 607 .add_count = 5,
599}; 608};
600 609
601static struct lpfc_hbq_init *lpfc_hbq_defs[] = { 610static struct lpfc_hbq_init lpfc_extra_hbq = {
611 .rn = 1,
612 .entry_count = 200,
613 .mask_count = 0,
614 .profile = 0,
615 .ring_mask = (1 << LPFC_EXTRA_RING),
616 .buffer_count = 0,
617 .init_count = 0,
618 .add_count = 5,
619};
620
621struct lpfc_hbq_init *lpfc_hbq_defs[] = {
602 &lpfc_els_hbq, 622 &lpfc_els_hbq,
623 &lpfc_extra_hbq,
603}; 624};
604 625
605int 626static int
606lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count) 627lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count)
607{ 628{
608 uint32_t i, start, end; 629 uint32_t i, start, end;
609 struct hbq_dmabuf *hbq_buffer; 630 struct hbq_dmabuf *hbq_buffer;
610 631
632 if (!phba->hbqs[hbqno].hbq_alloc_buffer) {
633 return 0;
634 }
635
611 start = lpfc_hbq_defs[hbqno]->buffer_count; 636 start = lpfc_hbq_defs[hbqno]->buffer_count;
612 end = count + lpfc_hbq_defs[hbqno]->buffer_count; 637 end = count + lpfc_hbq_defs[hbqno]->buffer_count;
613 if (end > lpfc_hbq_defs[hbqno]->entry_count) { 638 if (end > lpfc_hbq_defs[hbqno]->entry_count) {
@@ -616,17 +641,14 @@ lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count)
616 641
617 /* Populate HBQ entries */ 642 /* Populate HBQ entries */
618 for (i = start; i < end; i++) { 643 for (i = start; i < end; i++) {
619 hbq_buffer = kmalloc(sizeof(struct hbq_dmabuf), 644 hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba);
620 GFP_KERNEL);
621 if (!hbq_buffer) 645 if (!hbq_buffer)
622 return 1; 646 return 1;
623 hbq_buffer->dbuf.virt = lpfc_hbq_alloc(phba, MEM_PRI,
624 &hbq_buffer->dbuf.phys);
625 if (hbq_buffer->dbuf.virt == NULL)
626 return 1;
627 hbq_buffer->tag = (i | (hbqno << 16)); 647 hbq_buffer->tag = (i | (hbqno << 16));
628 lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer); 648 if (lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer))
629 lpfc_hbq_defs[hbqno]->buffer_count++; 649 lpfc_hbq_defs[hbqno]->buffer_count++;
650 else
651 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer);
630 } 652 }
631 return 0; 653 return 0;
632} 654}
@@ -650,28 +672,34 @@ lpfc_sli_hbqbuf_find(struct lpfc_hba *phba, uint32_t tag)
650{ 672{
651 struct lpfc_dmabuf *d_buf; 673 struct lpfc_dmabuf *d_buf;
652 struct hbq_dmabuf *hbq_buf; 674 struct hbq_dmabuf *hbq_buf;
675 uint32_t hbqno;
676
677 hbqno = tag >> 16;
678 if (hbqno > LPFC_MAX_HBQS)
679 return NULL;
653 680
654 list_for_each_entry(d_buf, &phba->hbq_buffer_list, list) { 681 list_for_each_entry(d_buf, &phba->hbqs[hbqno].hbq_buffer_list, list) {
655 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf); 682 hbq_buf = container_of(d_buf, struct hbq_dmabuf, dbuf);
656 if ((hbq_buf->tag & 0xffff) == tag) { 683 if (hbq_buf->tag == tag) {
657 return hbq_buf; 684 return hbq_buf;
658 } 685 }
659 } 686 }
660 lpfc_printf_log(phba, KERN_ERR, LOG_SLI | LOG_VPORT, 687 lpfc_printf_log(phba, KERN_ERR, LOG_SLI | LOG_VPORT,
661 "%d:1803 Bad hbq tag. Data: x%x x%x\n", 688 "1803 Bad hbq tag. Data: x%x x%x\n",
662 phba->brd_no, tag, 689 tag, lpfc_hbq_defs[tag >> 16]->buffer_count);
663 lpfc_hbq_defs[tag >> 16]->buffer_count);
664 return NULL; 690 return NULL;
665} 691}
666 692
667void 693void
668lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *sp) 694lpfc_sli_free_hbq(struct lpfc_hba *phba, struct hbq_dmabuf *hbq_buffer)
669{ 695{
670 uint32_t hbqno; 696 uint32_t hbqno;
671 697
672 if (sp) { 698 if (hbq_buffer) {
673 hbqno = sp->tag >> 16; 699 hbqno = hbq_buffer->tag >> 16;
674 lpfc_sli_hbq_to_firmware(phba, hbqno, sp); 700 if (!lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer)) {
701 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer);
702 }
675 } 703 }
676} 704}
677 705
@@ -837,12 +865,10 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
837 */ 865 */
838 if (lpfc_sli_chk_mbx_command(pmbox->mbxCommand) == 866 if (lpfc_sli_chk_mbx_command(pmbox->mbxCommand) ==
839 MBX_SHUTDOWN) { 867 MBX_SHUTDOWN) {
840
841 /* Unknow mailbox command compl */ 868 /* Unknow mailbox command compl */
842 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 869 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
843 "%d (%d):0323 Unknown Mailbox command " 870 "(%d):0323 Unknown Mailbox command "
844 "%x Cmpl\n", 871 "%x Cmpl\n",
845 phba->brd_no,
846 pmb->vport ? pmb->vport->vpi : 0, 872 pmb->vport ? pmb->vport->vpi : 0,
847 pmbox->mbxCommand); 873 pmbox->mbxCommand);
848 phba->link_state = LPFC_HBA_ERROR; 874 phba->link_state = LPFC_HBA_ERROR;
@@ -857,10 +883,9 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
857 /* Mbox cmd cmpl error - RETRYing */ 883 /* Mbox cmd cmpl error - RETRYing */
858 lpfc_printf_log(phba, KERN_INFO, 884 lpfc_printf_log(phba, KERN_INFO,
859 LOG_MBOX | LOG_SLI, 885 LOG_MBOX | LOG_SLI,
860 "%d (%d):0305 Mbox cmd cmpl " 886 "(%d):0305 Mbox cmd cmpl "
861 "error - RETRYing Data: x%x " 887 "error - RETRYing Data: x%x "
862 "x%x x%x x%x\n", 888 "x%x x%x x%x\n",
863 phba->brd_no,
864 pmb->vport ? pmb->vport->vpi :0, 889 pmb->vport ? pmb->vport->vpi :0,
865 pmbox->mbxCommand, 890 pmbox->mbxCommand,
866 pmbox->mbxStatus, 891 pmbox->mbxStatus,
@@ -879,9 +904,8 @@ lpfc_sli_handle_mb_event(struct lpfc_hba *phba)
879 904
880 /* Mailbox cmd <cmd> Cmpl <cmpl> */ 905 /* Mailbox cmd <cmd> Cmpl <cmpl> */
881 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 906 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
882 "%d (%d):0307 Mailbox cmd x%x Cmpl x%p " 907 "(%d):0307 Mailbox cmd x%x Cmpl x%p "
883 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n", 908 "Data: x%x x%x x%x x%x x%x x%x x%x x%x x%x\n",
884 phba->brd_no,
885 pmb->vport ? pmb->vport->vpi : 0, 909 pmb->vport ? pmb->vport->vpi : 0,
886 pmbox->mbxCommand, 910 pmbox->mbxCommand,
887 pmb->mbox_cmpl, 911 pmb->mbox_cmpl,
@@ -905,21 +929,26 @@ static struct lpfc_dmabuf *
905lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag) 929lpfc_sli_replace_hbqbuff(struct lpfc_hba *phba, uint32_t tag)
906{ 930{
907 struct hbq_dmabuf *hbq_entry, *new_hbq_entry; 931 struct hbq_dmabuf *hbq_entry, *new_hbq_entry;
932 uint32_t hbqno;
933 void *virt; /* virtual address ptr */
934 dma_addr_t phys; /* mapped address */
908 935
909 hbq_entry = lpfc_sli_hbqbuf_find(phba, tag); 936 hbq_entry = lpfc_sli_hbqbuf_find(phba, tag);
910 if (hbq_entry == NULL) 937 if (hbq_entry == NULL)
911 return NULL; 938 return NULL;
912 list_del(&hbq_entry->dbuf.list); 939 list_del(&hbq_entry->dbuf.list);
913 new_hbq_entry = kmalloc(sizeof(struct hbq_dmabuf), GFP_ATOMIC); 940
941 hbqno = tag >> 16;
942 new_hbq_entry = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba);
914 if (new_hbq_entry == NULL) 943 if (new_hbq_entry == NULL)
915 return &hbq_entry->dbuf; 944 return &hbq_entry->dbuf;
916 new_hbq_entry->dbuf = hbq_entry->dbuf;
917 new_hbq_entry->tag = -1; 945 new_hbq_entry->tag = -1;
918 hbq_entry->dbuf.virt = lpfc_hbq_alloc(phba, 0, &hbq_entry->dbuf.phys); 946 phys = new_hbq_entry->dbuf.phys;
919 if (hbq_entry->dbuf.virt == NULL) { 947 virt = new_hbq_entry->dbuf.virt;
920 kfree(new_hbq_entry); 948 new_hbq_entry->dbuf.phys = hbq_entry->dbuf.phys;
921 return &hbq_entry->dbuf; 949 new_hbq_entry->dbuf.virt = hbq_entry->dbuf.virt;
922 } 950 hbq_entry->dbuf.phys = phys;
951 hbq_entry->dbuf.virt = virt;
923 lpfc_sli_free_hbq(phba, hbq_entry); 952 lpfc_sli_free_hbq(phba, hbq_entry);
924 return &new_hbq_entry->dbuf; 953 return &new_hbq_entry->dbuf;
925} 954}
@@ -965,7 +994,7 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
965 irsp->un.ulpWord[3]); 994 irsp->un.ulpWord[3]);
966 if (irsp->ulpBdeCount == 2) 995 if (irsp->ulpBdeCount == 2)
967 saveq->context3 = lpfc_sli_replace_hbqbuff(phba, 996 saveq->context3 = lpfc_sli_replace_hbqbuff(phba,
968 irsp->un.ulpWord[15]); 997 irsp->unsli3.sli3Words[7]);
969 } 998 }
970 999
971 /* unSolicited Responses */ 1000 /* unSolicited Responses */
@@ -996,12 +1025,9 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
996 /* Ring <ringno> handler: unexpected 1025 /* Ring <ringno> handler: unexpected
997 Rctl <Rctl> Type <Type> received */ 1026 Rctl <Rctl> Type <Type> received */
998 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 1027 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
999 "%d:0313 Ring %d handler: unexpected Rctl x%x " 1028 "0313 Ring %d handler: unexpected Rctl x%x "
1000 "Type x%x received\n", 1029 "Type x%x received\n",
1001 phba->brd_no, 1030 pring->ringno, Rctl, Type);
1002 pring->ringno,
1003 Rctl,
1004 Type);
1005 } 1031 }
1006 return 1; 1032 return 1;
1007} 1033}
@@ -1024,10 +1050,9 @@ lpfc_sli_iocbq_lookup(struct lpfc_hba *phba,
1024 } 1050 }
1025 1051
1026 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1052 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1027 "%d:0317 iotag x%x is out off " 1053 "0317 iotag x%x is out off "
1028 "range: max iotag x%x wd0 x%x\n", 1054 "range: max iotag x%x wd0 x%x\n",
1029 phba->brd_no, iotag, 1055 iotag, phba->sli.last_iotag,
1030 phba->sli.last_iotag,
1031 *(((uint32_t *) &prspiocb->iocb) + 7)); 1056 *(((uint32_t *) &prspiocb->iocb) + 7));
1032 return NULL; 1057 return NULL;
1033} 1058}
@@ -1075,18 +1100,16 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
1075 * Ring <ringno> handler: unexpected completion IoTag 1100 * Ring <ringno> handler: unexpected completion IoTag
1076 * <IoTag> 1101 * <IoTag>
1077 */ 1102 */
1078 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 1103 lpfc_printf_vlog(cmdiocbp->vport, KERN_WARNING, LOG_SLI,
1079 "%d (%d):0322 Ring %d handler: " 1104 "0322 Ring %d handler: "
1080 "unexpected completion IoTag x%x " 1105 "unexpected completion IoTag x%x "
1081 "Data: x%x x%x x%x x%x\n", 1106 "Data: x%x x%x x%x x%x\n",
1082 phba->brd_no, 1107 pring->ringno,
1083 cmdiocbp->vport->vpi, 1108 saveq->iocb.ulpIoTag,
1084 pring->ringno, 1109 saveq->iocb.ulpStatus,
1085 saveq->iocb.ulpIoTag, 1110 saveq->iocb.un.ulpWord[4],
1086 saveq->iocb.ulpStatus, 1111 saveq->iocb.ulpCommand,
1087 saveq->iocb.un.ulpWord[4], 1112 saveq->iocb.ulpContext);
1088 saveq->iocb.ulpCommand,
1089 saveq->iocb.ulpContext);
1090 } 1113 }
1091 } 1114 }
1092 1115
@@ -1104,10 +1127,9 @@ lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
1104 * rsp ring <portRspMax> 1127 * rsp ring <portRspMax>
1105 */ 1128 */
1106 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1129 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1107 "%d:0312 Ring %d handler: portRspPut %d " 1130 "0312 Ring %d handler: portRspPut %d "
1108 "is bigger then rsp ring %d\n", 1131 "is bigger then rsp ring %d\n",
1109 phba->brd_no, pring->ringno, 1132 pring->ringno, le32_to_cpu(pgp->rspPutInx),
1110 le32_to_cpu(pgp->rspPutInx),
1111 pring->numRiocb); 1133 pring->numRiocb);
1112 1134
1113 phba->link_state = LPFC_HBA_ERROR; 1135 phba->link_state = LPFC_HBA_ERROR;
@@ -1177,9 +1199,9 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba)
1177 if (unlikely(irsp->ulpStatus)) { 1199 if (unlikely(irsp->ulpStatus)) {
1178 /* Rsp ring <ringno> error: IOCB */ 1200 /* Rsp ring <ringno> error: IOCB */
1179 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 1201 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
1180 "%d:0326 Rsp Ring %d error: IOCB Data: " 1202 "0326 Rsp Ring %d error: IOCB Data: "
1181 "x%x x%x x%x x%x x%x x%x x%x x%x\n", 1203 "x%x x%x x%x x%x x%x x%x x%x x%x\n",
1182 phba->brd_no, pring->ringno, 1204 pring->ringno,
1183 irsp->un.ulpWord[0], 1205 irsp->un.ulpWord[0],
1184 irsp->un.ulpWord[1], 1206 irsp->un.ulpWord[1],
1185 irsp->un.ulpWord[2], 1207 irsp->un.ulpWord[2],
@@ -1199,9 +1221,9 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba)
1199 */ 1221 */
1200 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { 1222 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {
1201 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 1223 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
1202 "%d:0314 IOCB cmd 0x%x" 1224 "0314 IOCB cmd 0x%x "
1203 " processed. Skipping" 1225 "processed. Skipping "
1204 " completion", phba->brd_no, 1226 "completion",
1205 irsp->ulpCommand); 1227 irsp->ulpCommand);
1206 break; 1228 break;
1207 } 1229 }
@@ -1226,10 +1248,9 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba)
1226 } else { 1248 } else {
1227 /* Unknown IOCB command */ 1249 /* Unknown IOCB command */
1228 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1250 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1229 "%d:0321 Unknown IOCB command " 1251 "0321 Unknown IOCB command "
1230 "Data: x%x, x%x x%x x%x x%x\n", 1252 "Data: x%x, x%x x%x x%x x%x\n",
1231 phba->brd_no, type, 1253 type, irsp->ulpCommand,
1232 irsp->ulpCommand,
1233 irsp->ulpStatus, 1254 irsp->ulpStatus,
1234 irsp->ulpIoTag, 1255 irsp->ulpIoTag,
1235 irsp->ulpContext); 1256 irsp->ulpContext);
@@ -1353,9 +1374,9 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba,
1353 1374
1354 /* Rsp ring <ringno> error: IOCB */ 1375 /* Rsp ring <ringno> error: IOCB */
1355 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 1376 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
1356 "%d:0336 Rsp Ring %d error: IOCB Data: " 1377 "0336 Rsp Ring %d error: IOCB Data: "
1357 "x%x x%x x%x x%x x%x x%x x%x x%x\n", 1378 "x%x x%x x%x x%x x%x x%x x%x x%x\n",
1358 phba->brd_no, pring->ringno, 1379 pring->ringno,
1359 irsp->un.ulpWord[0], 1380 irsp->un.ulpWord[0],
1360 irsp->un.ulpWord[1], 1381 irsp->un.ulpWord[1],
1361 irsp->un.ulpWord[2], 1382 irsp->un.ulpWord[2],
@@ -1375,10 +1396,9 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba,
1375 */ 1396 */
1376 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { 1397 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {
1377 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 1398 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
1378 "%d:0333 IOCB cmd 0x%x" 1399 "0333 IOCB cmd 0x%x"
1379 " processed. Skipping" 1400 " processed. Skipping"
1380 " completion\n", 1401 " completion\n",
1381 phba->brd_no,
1382 irsp->ulpCommand); 1402 irsp->ulpCommand);
1383 break; 1403 break;
1384 } 1404 }
@@ -1415,10 +1435,9 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba,
1415 } else { 1435 } else {
1416 /* Unknown IOCB command */ 1436 /* Unknown IOCB command */
1417 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1437 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1418 "%d:0334 Unknown IOCB command " 1438 "0334 Unknown IOCB command "
1419 "Data: x%x, x%x x%x x%x x%x\n", 1439 "Data: x%x, x%x x%x x%x x%x\n",
1420 phba->brd_no, type, 1440 type, irsp->ulpCommand,
1421 irsp->ulpCommand,
1422 irsp->ulpStatus, 1441 irsp->ulpStatus,
1423 irsp->ulpIoTag, 1442 irsp->ulpIoTag,
1424 irsp->ulpContext); 1443 irsp->ulpContext);
@@ -1496,10 +1515,9 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
1496 * rsp ring <portRspMax> 1515 * rsp ring <portRspMax>
1497 */ 1516 */
1498 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1517 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1499 "%d:0303 Ring %d handler: portRspPut %d " 1518 "0303 Ring %d handler: portRspPut %d "
1500 "is bigger then rsp ring %d\n", 1519 "is bigger then rsp ring %d\n",
1501 phba->brd_no, pring->ringno, portRspPut, 1520 pring->ringno, portRspPut, portRspMax);
1502 portRspMax);
1503 1521
1504 phba->link_state = LPFC_HBA_ERROR; 1522 phba->link_state = LPFC_HBA_ERROR;
1505 spin_unlock_irqrestore(&phba->hbalock, iflag); 1523 spin_unlock_irqrestore(&phba->hbalock, iflag);
@@ -1542,6 +1560,14 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
1542 if (++pring->rspidx >= portRspMax) 1560 if (++pring->rspidx >= portRspMax)
1543 pring->rspidx = 0; 1561 pring->rspidx = 0;
1544 1562
1563 if (pring->ringno == LPFC_ELS_RING) {
1564 lpfc_debugfs_slow_ring_trc(phba,
1565 "IOCB rsp ring: wd4:x%08x wd6:x%08x wd7:x%08x",
1566 *(((uint32_t *) irsp) + 4),
1567 *(((uint32_t *) irsp) + 6),
1568 *(((uint32_t *) irsp) + 7));
1569 }
1570
1545 writel(pring->rspidx, &phba->host_gp[pring->ringno].rspGetInx); 1571 writel(pring->rspidx, &phba->host_gp[pring->ringno].rspGetInx);
1546 1572
1547 if (list_empty(&(pring->iocb_continueq))) { 1573 if (list_empty(&(pring->iocb_continueq))) {
@@ -1580,13 +1606,12 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
1580 if (irsp->ulpStatus) { 1606 if (irsp->ulpStatus) {
1581 /* Rsp ring <ringno> error: IOCB */ 1607 /* Rsp ring <ringno> error: IOCB */
1582 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, 1608 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
1583 "%d:0328 Rsp Ring %d error: " 1609 "0328 Rsp Ring %d error: "
1584 "IOCB Data: " 1610 "IOCB Data: "
1585 "x%x x%x x%x x%x " 1611 "x%x x%x x%x x%x "
1586 "x%x x%x x%x x%x " 1612 "x%x x%x x%x x%x "
1587 "x%x x%x x%x x%x " 1613 "x%x x%x x%x x%x "
1588 "x%x x%x x%x x%x\n", 1614 "x%x x%x x%x x%x\n",
1589 phba->brd_no,
1590 pring->ringno, 1615 pring->ringno,
1591 irsp->un.ulpWord[0], 1616 irsp->un.ulpWord[0],
1592 irsp->un.ulpWord[1], 1617 irsp->un.ulpWord[1],
@@ -1661,10 +1686,9 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
1661 } else { 1686 } else {
1662 /* Unknown IOCB command */ 1687 /* Unknown IOCB command */
1663 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1688 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1664 "%d:0335 Unknown IOCB " 1689 "0335 Unknown IOCB "
1665 "command Data: x%x " 1690 "command Data: x%x "
1666 "x%x x%x x%x\n", 1691 "x%x x%x x%x\n",
1667 phba->brd_no,
1668 irsp->ulpCommand, 1692 irsp->ulpCommand,
1669 irsp->ulpStatus, 1693 irsp->ulpStatus,
1670 irsp->ulpIoTag, 1694 irsp->ulpIoTag,
@@ -1892,8 +1916,8 @@ lpfc_sli_brdkill(struct lpfc_hba *phba)
1892 1916
1893 /* Kill HBA */ 1917 /* Kill HBA */
1894 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 1918 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
1895 "%d:0329 Kill HBA Data: x%x x%x\n", 1919 "0329 Kill HBA Data: x%x x%x\n",
1896 phba->brd_no, phba->pport->port_state, psli->sli_flag); 1920 phba->pport->port_state, psli->sli_flag);
1897 1921
1898 if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, 1922 if ((pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
1899 GFP_KERNEL)) == 0) 1923 GFP_KERNEL)) == 0)
@@ -1966,7 +1990,7 @@ lpfc_sli_brdreset(struct lpfc_hba *phba)
1966 1990
1967 /* Reset HBA */ 1991 /* Reset HBA */
1968 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 1992 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
1969 "%d:0325 Reset HBA Data: x%x x%x\n", phba->brd_no, 1993 "0325 Reset HBA Data: x%x x%x\n",
1970 phba->pport->port_state, psli->sli_flag); 1994 phba->pport->port_state, psli->sli_flag);
1971 1995
1972 /* perform board reset */ 1996 /* perform board reset */
@@ -2021,7 +2045,7 @@ lpfc_sli_brdrestart(struct lpfc_hba *phba)
2021 2045
2022 /* Restart HBA */ 2046 /* Restart HBA */
2023 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 2047 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
2024 "%d:0337 Restart HBA Data: x%x x%x\n", phba->brd_no, 2048 "0337 Restart HBA Data: x%x x%x\n",
2025 phba->pport->port_state, psli->sli_flag); 2049 phba->pport->port_state, psli->sli_flag);
2026 2050
2027 word0 = 0; 2051 word0 = 0;
@@ -2086,9 +2110,8 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba)
2086 /* Adapter failed to init, timeout, status reg 2110 /* Adapter failed to init, timeout, status reg
2087 <status> */ 2111 <status> */
2088 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2112 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2089 "%d:0436 Adapter failed to init, " 2113 "0436 Adapter failed to init, "
2090 "timeout, status reg x%x\n", 2114 "timeout, status reg x%x\n", status);
2091 phba->brd_no, status);
2092 phba->link_state = LPFC_HBA_ERROR; 2115 phba->link_state = LPFC_HBA_ERROR;
2093 return -ETIMEDOUT; 2116 return -ETIMEDOUT;
2094 } 2117 }
@@ -2099,10 +2122,8 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba)
2099 /* Adapter failed to init, chipset, status reg 2122 /* Adapter failed to init, chipset, status reg
2100 <status> */ 2123 <status> */
2101 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2124 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2102 "%d:0437 Adapter failed to init, " 2125 "0437 Adapter failed to init, "
2103 "chipset, status reg x%x\n", 2126 "chipset, status reg x%x\n", status);
2104 phba->brd_no,
2105 status);
2106 phba->link_state = LPFC_HBA_ERROR; 2127 phba->link_state = LPFC_HBA_ERROR;
2107 return -EIO; 2128 return -EIO;
2108 } 2129 }
@@ -2129,10 +2150,8 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba)
2129 /* ERROR: During chipset initialization */ 2150 /* ERROR: During chipset initialization */
2130 /* Adapter failed to init, chipset, status reg <status> */ 2151 /* Adapter failed to init, chipset, status reg <status> */
2131 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2152 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2132 "%d:0438 Adapter failed to init, chipset, " 2153 "0438 Adapter failed to init, chipset, "
2133 "status reg x%x\n", 2154 "status reg x%x\n", status);
2134 phba->brd_no,
2135 status);
2136 phba->link_state = LPFC_HBA_ERROR; 2155 phba->link_state = LPFC_HBA_ERROR;
2137 return -EIO; 2156 return -EIO;
2138 } 2157 }
@@ -2147,7 +2166,7 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba)
2147 return 0; 2166 return 0;
2148} 2167}
2149 2168
2150static int 2169int
2151lpfc_sli_hbq_count(void) 2170lpfc_sli_hbq_count(void)
2152{ 2171{
2153 return ARRAY_SIZE(lpfc_hbq_defs); 2172 return ARRAY_SIZE(lpfc_hbq_defs);
@@ -2200,8 +2219,8 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba)
2200 phba->hbqs[hbqno].local_hbqGetIdx = 0; 2219 phba->hbqs[hbqno].local_hbqGetIdx = 0;
2201 phba->hbqs[hbqno].entry_count = 2220 phba->hbqs[hbqno].entry_count =
2202 lpfc_hbq_defs[hbqno]->entry_count; 2221 lpfc_hbq_defs[hbqno]->entry_count;
2203 lpfc_config_hbq(phba, lpfc_hbq_defs[hbqno], hbq_entry_index, 2222 lpfc_config_hbq(phba, hbqno, lpfc_hbq_defs[hbqno],
2204 pmb); 2223 hbq_entry_index, pmb);
2205 hbq_entry_index += phba->hbqs[hbqno].entry_count; 2224 hbq_entry_index += phba->hbqs[hbqno].entry_count;
2206 2225
2207 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { 2226 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
@@ -2210,9 +2229,9 @@ lpfc_sli_hbq_setup(struct lpfc_hba *phba)
2210 2229
2211 lpfc_printf_log(phba, KERN_ERR, 2230 lpfc_printf_log(phba, KERN_ERR,
2212 LOG_SLI | LOG_VPORT, 2231 LOG_SLI | LOG_VPORT,
2213 "%d:1805 Adapter failed to init. " 2232 "1805 Adapter failed to init. "
2214 "Data: x%x x%x x%x\n", 2233 "Data: x%x x%x x%x\n",
2215 phba->brd_no, pmbox->mbxCommand, 2234 pmbox->mbxCommand,
2216 pmbox->mbxStatus, hbqno); 2235 pmbox->mbxStatus, hbqno);
2217 2236
2218 phba->link_state = LPFC_HBA_ERROR; 2237 phba->link_state = LPFC_HBA_ERROR;
@@ -2279,10 +2298,9 @@ lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode)
2279 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); 2298 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
2280 if (rc != MBX_SUCCESS) { 2299 if (rc != MBX_SUCCESS) {
2281 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2300 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
2282 "%d:0442 Adapter failed to init, mbxCmd x%x " 2301 "0442 Adapter failed to init, mbxCmd x%x "
2283 "CONFIG_PORT, mbxStatus x%x Data: x%x\n", 2302 "CONFIG_PORT, mbxStatus x%x Data: x%x\n",
2284 phba->brd_no, pmb->mb.mbxCommand, 2303 pmb->mb.mbxCommand, pmb->mb.mbxStatus, 0);
2285 pmb->mb.mbxStatus, 0);
2286 spin_lock_irq(&phba->hbalock); 2304 spin_lock_irq(&phba->hbalock);
2287 phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE; 2305 phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE;
2288 spin_unlock_irq(&phba->hbalock); 2306 spin_unlock_irq(&phba->hbalock);
@@ -2321,11 +2339,11 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
2321 2339
2322 switch (lpfc_sli_mode) { 2340 switch (lpfc_sli_mode) {
2323 case 2: 2341 case 2:
2324 if (phba->cfg_npiv_enable) { 2342 if (phba->cfg_enable_npiv) {
2325 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, 2343 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT,
2326 "%d:1824 NPIV enabled: Override lpfc_sli_mode " 2344 "1824 NPIV enabled: Override lpfc_sli_mode "
2327 "parameter (%d) to auto (0).\n", 2345 "parameter (%d) to auto (0).\n",
2328 phba->brd_no, lpfc_sli_mode); 2346 lpfc_sli_mode);
2329 break; 2347 break;
2330 } 2348 }
2331 mode = 2; 2349 mode = 2;
@@ -2335,9 +2353,8 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
2335 break; 2353 break;
2336 default: 2354 default:
2337 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, 2355 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT,
2338 "%d:1819 Unrecognized lpfc_sli_mode " 2356 "1819 Unrecognized lpfc_sli_mode "
2339 "parameter: %d.\n", 2357 "parameter: %d.\n", lpfc_sli_mode);
2340 phba->brd_no, lpfc_sli_mode);
2341 2358
2342 break; 2359 break;
2343 } 2360 }
@@ -2345,9 +2362,8 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
2345 rc = lpfc_do_config_port(phba, mode); 2362 rc = lpfc_do_config_port(phba, mode);
2346 if (rc && lpfc_sli_mode == 3) 2363 if (rc && lpfc_sli_mode == 3)
2347 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, 2364 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT,
2348 "%d:1820 Unable to select SLI-3. " 2365 "1820 Unable to select SLI-3. "
2349 "Not supported by adapter.\n", 2366 "Not supported by adapter.\n");
2350 phba->brd_no);
2351 if (rc && mode != 2) 2367 if (rc && mode != 2)
2352 rc = lpfc_do_config_port(phba, 2); 2368 rc = lpfc_do_config_port(phba, 2);
2353 if (rc) 2369 if (rc)
@@ -2366,8 +2382,8 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
2366 } 2382 }
2367 2383
2368 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 2384 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
2369 "%d:0444 Firmware in SLI %x mode. Max_vpi %d\n", 2385 "0444 Firmware in SLI %x mode. Max_vpi %d\n",
2370 phba->brd_no, phba->sli_rev, phba->max_vpi); 2386 phba->sli_rev, phba->max_vpi);
2371 rc = lpfc_sli_ring_map(phba); 2387 rc = lpfc_sli_ring_map(phba);
2372 2388
2373 if (rc) 2389 if (rc)
@@ -2392,8 +2408,7 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
2392lpfc_sli_hba_setup_error: 2408lpfc_sli_hba_setup_error:
2393 phba->link_state = LPFC_HBA_ERROR; 2409 phba->link_state = LPFC_HBA_ERROR;
2394 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 2410 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
2395 "%d:0445 Firmware initialization failed\n", 2411 "0445 Firmware initialization failed\n");
2396 phba->brd_no);
2397 return rc; 2412 return rc;
2398} 2413}
2399 2414
@@ -2445,9 +2460,7 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
2445 2460
2446 /* Mbox cmd <mbxCommand> timeout */ 2461 /* Mbox cmd <mbxCommand> timeout */
2447 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 2462 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
2448 "%d:0310 Mailbox command x%x timeout Data: x%x x%x " 2463 "0310 Mailbox command x%x timeout Data: x%x x%x x%p\n",
2449 "x%p\n",
2450 phba->brd_no,
2451 mb->mbxCommand, 2464 mb->mbxCommand,
2452 phba->pport->port_state, 2465 phba->pport->port_state,
2453 phba->sli.sli_flag, 2466 phba->sli.sli_flag,
@@ -2470,8 +2483,7 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
2470 lpfc_sli_abort_iocb_ring(phba, pring); 2483 lpfc_sli_abort_iocb_ring(phba, pring);
2471 2484
2472 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI, 2485 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,
2473 "%d:0316 Resetting board due to mailbox timeout\n", 2486 "0316 Resetting board due to mailbox timeout\n");
2474 phba->brd_no);
2475 /* 2487 /*
2476 * lpfc_offline calls lpfc_sli_hba_down which will clean up 2488 * lpfc_offline calls lpfc_sli_hba_down which will clean up
2477 * on oustanding mailbox commands. 2489 * on oustanding mailbox commands.
@@ -2502,8 +2514,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
2502 if(!pmbox->vport) { 2514 if(!pmbox->vport) {
2503 lpfc_printf_log(phba, KERN_ERR, 2515 lpfc_printf_log(phba, KERN_ERR,
2504 LOG_MBOX | LOG_VPORT, 2516 LOG_MBOX | LOG_VPORT,
2505 "%d:1806 Mbox x%x failed. No vport\n", 2517 "1806 Mbox x%x failed. No vport\n",
2506 phba->brd_no,
2507 pmbox->mb.mbxCommand); 2518 pmbox->mb.mbxCommand);
2508 dump_stack(); 2519 dump_stack();
2509 return MBXERR_ERROR; 2520 return MBXERR_ERROR;
@@ -2580,9 +2591,8 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
2580 2591
2581 /* Mbox cmd issue - BUSY */ 2592 /* Mbox cmd issue - BUSY */
2582 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 2593 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
2583 "%d (%d):0308 Mbox cmd issue - BUSY Data: " 2594 "(%d):0308 Mbox cmd issue - BUSY Data: "
2584 "x%x x%x x%x x%x\n", 2595 "x%x x%x x%x x%x\n",
2585 phba->brd_no,
2586 pmbox->vport ? pmbox->vport->vpi : 0xffffff, 2596 pmbox->vport ? pmbox->vport->vpi : 0xffffff,
2587 mb->mbxCommand, phba->pport->port_state, 2597 mb->mbxCommand, phba->pport->port_state,
2588 psli->sli_flag, flag); 2598 psli->sli_flag, flag);
@@ -2644,9 +2654,9 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
2644 2654
2645 /* Mailbox cmd <cmd> issue */ 2655 /* Mailbox cmd <cmd> issue */
2646 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI, 2656 lpfc_printf_log(phba, KERN_INFO, LOG_MBOX | LOG_SLI,
2647 "%d (%d):0309 Mailbox cmd x%x issue Data: x%x x%x " 2657 "(%d):0309 Mailbox cmd x%x issue Data: x%x x%x "
2648 "x%x\n", 2658 "x%x\n",
2649 phba->brd_no, pmbox->vport ? pmbox->vport->vpi : 0, 2659 pmbox->vport ? pmbox->vport->vpi : 0,
2650 mb->mbxCommand, phba->pport->port_state, 2660 mb->mbxCommand, phba->pport->port_state,
2651 psli->sli_flag, flag); 2661 psli->sli_flag, flag);
2652 2662
@@ -2848,8 +2858,7 @@ __lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2848 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { 2858 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) {
2849 lpfc_printf_log(phba, KERN_ERR, 2859 lpfc_printf_log(phba, KERN_ERR,
2850 LOG_SLI | LOG_VPORT, 2860 LOG_SLI | LOG_VPORT,
2851 "%d:1807 IOCB x%x failed. No vport\n", 2861 "1807 IOCB x%x failed. No vport\n",
2852 phba->brd_no,
2853 piocb->iocb.ulpCommand); 2862 piocb->iocb.ulpCommand);
2854 dump_stack(); 2863 dump_stack();
2855 return IOCB_ERROR; 2864 return IOCB_ERROR;
@@ -3080,11 +3089,10 @@ lpfc_sli_setup(struct lpfc_hba *phba)
3080 } 3089 }
3081 if (totiocbsize > MAX_SLIM_IOCB_SIZE) { 3090 if (totiocbsize > MAX_SLIM_IOCB_SIZE) {
3082 /* Too many cmd / rsp ring entries in SLI2 SLIM */ 3091 /* Too many cmd / rsp ring entries in SLI2 SLIM */
3083 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 3092 printk(KERN_ERR "%d:0462 Too many cmd / rsp ring entries in "
3084 "%d:0462 Too many cmd / rsp ring entries in " 3093 "SLI2 SLIM Data: x%x x%lx\n",
3085 "SLI2 SLIM Data: x%x x%lx\n", 3094 phba->brd_no, totiocbsize,
3086 phba->brd_no, totiocbsize, 3095 (unsigned long) MAX_SLIM_IOCB_SIZE);
3087 (unsigned long) MAX_SLIM_IOCB_SIZE);
3088 } 3096 }
3089 if (phba->cfg_multi_ring_support == 2) 3097 if (phba->cfg_multi_ring_support == 2)
3090 lpfc_extra_ring_setup(phba); 3098 lpfc_extra_ring_setup(phba);
@@ -3305,9 +3313,9 @@ lpfc_sli_ringpostbuf_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3305 3313
3306 spin_unlock_irq(&phba->hbalock); 3314 spin_unlock_irq(&phba->hbalock);
3307 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 3315 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3308 "%d:0410 Cannot find virtual addr for mapped buf on " 3316 "0410 Cannot find virtual addr for mapped buf on "
3309 "ring %d Data x%llx x%p x%p x%x\n", 3317 "ring %d Data x%llx x%p x%p x%x\n",
3310 phba->brd_no, pring->ringno, (unsigned long long)phys, 3318 pring->ringno, (unsigned long long)phys,
3311 slp->next, slp->prev, pring->postbufq_cnt); 3319 slp->next, slp->prev, pring->postbufq_cnt);
3312 return NULL; 3320 return NULL;
3313} 3321}
@@ -3332,12 +3340,11 @@ lpfc_sli_abort_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3332 abort_iocb = phba->sli.iocbq_lookup[abort_iotag]; 3340 abort_iocb = phba->sli.iocbq_lookup[abort_iotag];
3333 3341
3334 lpfc_printf_log(phba, KERN_INFO, LOG_ELS | LOG_SLI, 3342 lpfc_printf_log(phba, KERN_INFO, LOG_ELS | LOG_SLI,
3335 "%d:0327 Cannot abort els iocb %p " 3343 "0327 Cannot abort els iocb %p "
3336 "with tag %x context %x, abort status %x, " 3344 "with tag %x context %x, abort status %x, "
3337 "abort code %x\n", 3345 "abort code %x\n",
3338 phba->brd_no, abort_iocb, abort_iotag, 3346 abort_iocb, abort_iotag, abort_context,
3339 abort_context, irsp->ulpStatus, 3347 irsp->ulpStatus, irsp->un.ulpWord[4]);
3340 irsp->un.ulpWord[4]);
3341 3348
3342 /* 3349 /*
3343 * make sure we have the right iocbq before taking it 3350 * make sure we have the right iocbq before taking it
@@ -3371,9 +3378,9 @@ lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3371 3378
3372 /* ELS cmd tag <ulpIoTag> completes */ 3379 /* ELS cmd tag <ulpIoTag> completes */
3373 lpfc_printf_log(phba, KERN_INFO, LOG_ELS, 3380 lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
3374 "%d (X):0133 Ignoring ELS cmd tag x%x completion Data: " 3381 "0133 Ignoring ELS cmd tag x%x completion Data: "
3375 "x%x x%x x%x\n", 3382 "x%x x%x x%x\n",
3376 phba->brd_no, irsp->ulpIoTag, irsp->ulpStatus, 3383 irsp->ulpIoTag, irsp->ulpStatus,
3377 irsp->un.ulpWord[4], irsp->ulpTimeout); 3384 irsp->un.ulpWord[4], irsp->ulpTimeout);
3378 if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) 3385 if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR)
3379 lpfc_ct_free_iocb(phba, cmdiocb); 3386 lpfc_ct_free_iocb(phba, cmdiocb);
@@ -3439,12 +3446,11 @@ lpfc_sli_issue_abort_iotag(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3439 3446
3440 abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl; 3447 abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl;
3441 3448
3442 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3449 lpfc_printf_vlog(vport, KERN_INFO, LOG_SLI,
3443 "%d (%d):0339 Abort xri x%x, original iotag x%x, " 3450 "0339 Abort xri x%x, original iotag x%x, "
3444 "abort cmd iotag x%x\n", 3451 "abort cmd iotag x%x\n",
3445 phba->brd_no, vport->vpi, 3452 iabt->un.acxri.abortContextTag,
3446 iabt->un.acxri.abortContextTag, 3453 iabt->un.acxri.abortIoTag, abtsiocbp->iotag);
3447 iabt->un.acxri.abortIoTag, abtsiocbp->iotag);
3448 retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0); 3454 retval = __lpfc_sli_issue_iocb(phba, pring, abtsiocbp, 0);
3449 3455
3450abort_iotag_exit: 3456abort_iotag_exit:
@@ -3457,8 +3463,8 @@ abort_iotag_exit:
3457} 3463}
3458 3464
3459static int 3465static int
3460lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, uint16_t tgt_id, 3466lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, struct lpfc_vport *vport,
3461 uint64_t lun_id, uint32_t ctx, 3467 uint16_t tgt_id, uint64_t lun_id,
3462 lpfc_ctx_cmd ctx_cmd) 3468 lpfc_ctx_cmd ctx_cmd)
3463{ 3469{
3464 struct lpfc_scsi_buf *lpfc_cmd; 3470 struct lpfc_scsi_buf *lpfc_cmd;
@@ -3468,6 +3474,9 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, uint16_t tgt_id,
3468 if (!(iocbq->iocb_flag & LPFC_IO_FCP)) 3474 if (!(iocbq->iocb_flag & LPFC_IO_FCP))
3469 return rc; 3475 return rc;
3470 3476
3477 if (iocbq->vport != vport)
3478 return rc;
3479
3471 lpfc_cmd = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq); 3480 lpfc_cmd = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq);
3472 cmnd = lpfc_cmd->pCmd; 3481 cmnd = lpfc_cmd->pCmd;
3473 3482
@@ -3484,10 +3493,6 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, uint16_t tgt_id,
3484 if (cmnd->device->id == tgt_id) 3493 if (cmnd->device->id == tgt_id)
3485 rc = 0; 3494 rc = 0;
3486 break; 3495 break;
3487 case LPFC_CTX_CTX:
3488 if (iocbq->iocb.ulpContext == ctx)
3489 rc = 0;
3490 break;
3491 case LPFC_CTX_HOST: 3496 case LPFC_CTX_HOST:
3492 rc = 0; 3497 rc = 0;
3493 break; 3498 break;
@@ -3501,17 +3506,18 @@ lpfc_sli_validate_fcp_iocb(struct lpfc_iocbq *iocbq, uint16_t tgt_id,
3501} 3506}
3502 3507
3503int 3508int
3504lpfc_sli_sum_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 3509lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id,
3505 uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd ctx_cmd) 3510 lpfc_ctx_cmd ctx_cmd)
3506{ 3511{
3512 struct lpfc_hba *phba = vport->phba;
3507 struct lpfc_iocbq *iocbq; 3513 struct lpfc_iocbq *iocbq;
3508 int sum, i; 3514 int sum, i;
3509 3515
3510 for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) { 3516 for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) {
3511 iocbq = phba->sli.iocbq_lookup[i]; 3517 iocbq = phba->sli.iocbq_lookup[i];
3512 3518
3513 if (lpfc_sli_validate_fcp_iocb (iocbq, tgt_id, lun_id, 3519 if (lpfc_sli_validate_fcp_iocb (iocbq, vport, tgt_id, lun_id,
3514 0, ctx_cmd) == 0) 3520 ctx_cmd) == 0)
3515 sum++; 3521 sum++;
3516 } 3522 }
3517 3523
@@ -3527,10 +3533,10 @@ lpfc_sli_abort_fcp_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
3527} 3533}
3528 3534
3529int 3535int
3530lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 3536lpfc_sli_abort_iocb(struct lpfc_vport *vport, struct lpfc_sli_ring *pring,
3531 uint16_t tgt_id, uint64_t lun_id, uint32_t ctx, 3537 uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd abort_cmd)
3532 lpfc_ctx_cmd abort_cmd)
3533{ 3538{
3539 struct lpfc_hba *phba = vport->phba;
3534 struct lpfc_iocbq *iocbq; 3540 struct lpfc_iocbq *iocbq;
3535 struct lpfc_iocbq *abtsiocb; 3541 struct lpfc_iocbq *abtsiocb;
3536 IOCB_t *cmd = NULL; 3542 IOCB_t *cmd = NULL;
@@ -3540,7 +3546,7 @@ lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
3540 for (i = 1; i <= phba->sli.last_iotag; i++) { 3546 for (i = 1; i <= phba->sli.last_iotag; i++) {
3541 iocbq = phba->sli.iocbq_lookup[i]; 3547 iocbq = phba->sli.iocbq_lookup[i];
3542 3548
3543 if (lpfc_sli_validate_fcp_iocb(iocbq, tgt_id, lun_id, 0, 3549 if (lpfc_sli_validate_fcp_iocb(iocbq, vport, tgt_id, lun_id,
3544 abort_cmd) != 0) 3550 abort_cmd) != 0)
3545 continue; 3551 continue;
3546 3552
@@ -3647,25 +3653,23 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba *phba,
3647 3653
3648 if (piocb->iocb_flag & LPFC_IO_WAKE) { 3654 if (piocb->iocb_flag & LPFC_IO_WAKE) {
3649 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3655 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
3650 "%d:0331 IOCB wake signaled\n", 3656 "0331 IOCB wake signaled\n");
3651 phba->brd_no);
3652 } else if (timeleft == 0) { 3657 } else if (timeleft == 0) {
3653 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3658 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3654 "%d:0338 IOCB wait timeout error - no " 3659 "0338 IOCB wait timeout error - no "
3655 "wake response Data x%x\n", 3660 "wake response Data x%x\n", timeout);
3656 phba->brd_no, timeout);
3657 retval = IOCB_TIMEDOUT; 3661 retval = IOCB_TIMEDOUT;
3658 } else { 3662 } else {
3659 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 3663 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
3660 "%d:0330 IOCB wake NOT set, " 3664 "0330 IOCB wake NOT set, "
3661 "Data x%x x%lx\n", phba->brd_no, 3665 "Data x%x x%lx\n",
3662 timeout, (timeleft / jiffies)); 3666 timeout, (timeleft / jiffies));
3663 retval = IOCB_TIMEDOUT; 3667 retval = IOCB_TIMEDOUT;
3664 } 3668 }
3665 } else { 3669 } else {
3666 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 3670 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
3667 "%d:0332 IOCB wait issue failed, Data x%x\n", 3671 ":0332 IOCB wait issue failed, Data x%x\n",
3668 phba->brd_no, retval); 3672 retval);
3669 retval = IOCB_ERROR; 3673 retval = IOCB_ERROR;
3670 } 3674 }
3671 3675
@@ -3850,12 +3854,33 @@ lpfc_intr_handler(int irq, void *dev_id)
3850 if (status & HA_RXMASK) { 3854 if (status & HA_RXMASK) {
3851 spin_lock(&phba->hbalock); 3855 spin_lock(&phba->hbalock);
3852 control = readl(phba->HCregaddr); 3856 control = readl(phba->HCregaddr);
3857
3858 lpfc_debugfs_slow_ring_trc(phba,
3859 "ISR slow ring: ctl:x%x stat:x%x isrcnt:x%x",
3860 control, status,
3861 (uint32_t)phba->sli.slistat.sli_intr);
3862
3853 if (control & (HC_R0INT_ENA << LPFC_ELS_RING)) { 3863 if (control & (HC_R0INT_ENA << LPFC_ELS_RING)) {
3864 lpfc_debugfs_slow_ring_trc(phba,
3865 "ISR Disable ring:"
3866 "pwork:x%x hawork:x%x wait:x%x",
3867 phba->work_ha, work_ha_copy,
3868 (uint32_t)((unsigned long)
3869 phba->work_wait));
3870
3854 control &= 3871 control &=
3855 ~(HC_R0INT_ENA << LPFC_ELS_RING); 3872 ~(HC_R0INT_ENA << LPFC_ELS_RING);
3856 writel(control, phba->HCregaddr); 3873 writel(control, phba->HCregaddr);
3857 readl(phba->HCregaddr); /* flush */ 3874 readl(phba->HCregaddr); /* flush */
3858 } 3875 }
3876 else {
3877 lpfc_debugfs_slow_ring_trc(phba,
3878 "ISR slow ring: pwork:"
3879 "x%x hawork:x%x wait:x%x",
3880 phba->work_ha, work_ha_copy,
3881 (uint32_t)((unsigned long)
3882 phba->work_wait));
3883 }
3859 spin_unlock(&phba->hbalock); 3884 spin_unlock(&phba->hbalock);
3860 } 3885 }
3861 } 3886 }
@@ -3895,12 +3920,10 @@ lpfc_intr_handler(int irq, void *dev_id)
3895 */ 3920 */
3896 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX | 3921 lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX |
3897 LOG_SLI, 3922 LOG_SLI,
3898 "%d (%d):0304 Stray Mailbox " 3923 "(%d):0304 Stray Mailbox "
3899 "Interrupt mbxCommand x%x " 3924 "Interrupt mbxCommand x%x "
3900 "mbxStatus x%x\n", 3925 "mbxStatus x%x\n",
3901 phba->brd_no, 3926 (vport ? vport->vpi : 0),
3902 (vport
3903 ? vport->vpi : 0),
3904 pmbox->mbxCommand, 3927 pmbox->mbxCommand,
3905 pmbox->mbxStatus); 3928 pmbox->mbxStatus);
3906 } 3929 }
diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h
index 76058505795e..51b2b6b949be 100644
--- a/drivers/scsi/lpfc/lpfc_sli.h
+++ b/drivers/scsi/lpfc/lpfc_sli.h
@@ -26,7 +26,6 @@ struct lpfc_vport;
26typedef enum _lpfc_ctx_cmd { 26typedef enum _lpfc_ctx_cmd {
27 LPFC_CTX_LUN, 27 LPFC_CTX_LUN,
28 LPFC_CTX_TGT, 28 LPFC_CTX_TGT,
29 LPFC_CTX_CTX,
30 LPFC_CTX_HOST 29 LPFC_CTX_HOST
31} lpfc_ctx_cmd; 30} lpfc_ctx_cmd;
32 31
@@ -54,9 +53,10 @@ struct lpfc_iocbq {
54 void *context2; /* caller context information */ 53 void *context2; /* caller context information */
55 void *context3; /* caller context information */ 54 void *context3; /* caller context information */
56 union { 55 union {
57 wait_queue_head_t *wait_queue; 56 wait_queue_head_t *wait_queue;
58 struct lpfc_iocbq *rsp_iocb; 57 struct lpfc_iocbq *rsp_iocb;
59 struct lpfcMboxq *mbox; 58 struct lpfcMboxq *mbox;
59 struct lpfc_nodelist *ndlp;
60 } context_un; 60 } context_un;
61 61
62 void (*fabric_iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *, 62 void (*fabric_iocb_cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
@@ -143,7 +143,7 @@ struct lpfc_sli_ring {
143 uint16_t numCiocb; /* number of command iocb's per ring */ 143 uint16_t numCiocb; /* number of command iocb's per ring */
144 uint16_t numRiocb; /* number of rsp iocb's per ring */ 144 uint16_t numRiocb; /* number of rsp iocb's per ring */
145 uint16_t sizeCiocb; /* Size of command iocb's in this ring */ 145 uint16_t sizeCiocb; /* Size of command iocb's in this ring */
146 uint16_t sizeRiocb; /* Size of response iocb's in this ring */ 146 uint16_t sizeRiocb; /* Size of response iocb's in this ring */
147 147
148 uint32_t fast_iotag; /* max fastlookup based iotag */ 148 uint32_t fast_iotag; /* max fastlookup based iotag */
149 uint32_t iotag_ctr; /* keeps track of the next iotag to use */ 149 uint32_t iotag_ctr; /* keeps track of the next iotag to use */
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index a5bc79eef052..0081f49286bc 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,12 +18,10 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21#define LPFC_DRIVER_VERSION "8.2.1" 21#define LPFC_DRIVER_VERSION "8.2.2"
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-2007 Emulex. All rights reserved." 27#define LPFC_COPYRIGHT "Copyright(c) 2004-2007 Emulex. All rights reserved."
28
29#define DFC_API_VERSION "0.0.0"
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
index 85797dbf5478..dcb415e717c3 100644
--- a/drivers/scsi/lpfc/lpfc_vport.c
+++ b/drivers/scsi/lpfc/lpfc_vport.c
@@ -125,11 +125,10 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport)
125 pmb->vport = vport; 125 pmb->vport = vport;
126 rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2); 126 rc = lpfc_sli_issue_mbox_wait(phba, pmb, phba->fc_ratov * 2);
127 if (rc != MBX_SUCCESS) { 127 if (rc != MBX_SUCCESS) {
128 lpfc_printf_log(phba, KERN_ERR, LOG_INIT | LOG_VPORT, 128 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT | LOG_VPORT,
129 "%d (%d):1818 VPort failed init, mbxCmd x%x " 129 "1818 VPort failed init, mbxCmd x%x "
130 "READ_SPARM mbxStatus x%x, rc = x%x\n", 130 "READ_SPARM mbxStatus x%x, rc = x%x\n",
131 phba->brd_no, vport->vpi, 131 mb->mbxCommand, mb->mbxStatus, rc);
132 mb->mbxCommand, mb->mbxStatus, rc);
133 lpfc_mbuf_free(phba, mp->virt, mp->phys); 132 lpfc_mbuf_free(phba, mp->virt, mp->phys);
134 kfree(mp); 133 kfree(mp);
135 if (rc != MBX_TIMEOUT) 134 if (rc != MBX_TIMEOUT)
@@ -162,9 +161,9 @@ lpfc_valid_wwn_format(struct lpfc_hba *phba, struct lpfc_name *wwn,
162 return 1; 161 return 1;
163 162
164 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 163 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
165 "%d:1822 Invalid %s: %02x:%02x:%02x:%02x:" 164 "1822 Invalid %s: %02x:%02x:%02x:%02x:"
166 "%02x:%02x:%02x:%02x\n", 165 "%02x:%02x:%02x:%02x\n",
167 phba->brd_no, name_type, 166 name_type,
168 wwn->u.wwn[0], wwn->u.wwn[1], 167 wwn->u.wwn[0], wwn->u.wwn[1],
169 wwn->u.wwn[2], wwn->u.wwn[3], 168 wwn->u.wwn[2], wwn->u.wwn[3],
170 wwn->u.wwn[4], wwn->u.wwn[5], 169 wwn->u.wwn[4], wwn->u.wwn[5],
@@ -176,16 +175,21 @@ static int
176lpfc_unique_wwpn(struct lpfc_hba *phba, struct lpfc_vport *new_vport) 175lpfc_unique_wwpn(struct lpfc_hba *phba, struct lpfc_vport *new_vport)
177{ 176{
178 struct lpfc_vport *vport; 177 struct lpfc_vport *vport;
178 unsigned long flags;
179 179
180 spin_lock_irqsave(&phba->hbalock, flags);
180 list_for_each_entry(vport, &phba->port_list, listentry) { 181 list_for_each_entry(vport, &phba->port_list, listentry) {
181 if (vport == new_vport) 182 if (vport == new_vport)
182 continue; 183 continue;
183 /* If they match, return not unique */ 184 /* If they match, return not unique */
184 if (memcmp(&vport->fc_sparam.portName, 185 if (memcmp(&vport->fc_sparam.portName,
185 &new_vport->fc_sparam.portName, 186 &new_vport->fc_sparam.portName,
186 sizeof(struct lpfc_name)) == 0) 187 sizeof(struct lpfc_name)) == 0) {
188 spin_unlock_irqrestore(&phba->hbalock, flags);
187 return 0; 189 return 0;
190 }
188 } 191 }
192 spin_unlock_irqrestore(&phba->hbalock, flags);
189 return 1; 193 return 1;
190} 194}
191 195
@@ -193,8 +197,8 @@ int
193lpfc_vport_create(struct fc_vport *fc_vport, bool disable) 197lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
194{ 198{
195 struct lpfc_nodelist *ndlp; 199 struct lpfc_nodelist *ndlp;
196 struct lpfc_vport *pport = 200 struct Scsi_Host *shost = fc_vport->shost;
197 (struct lpfc_vport *) fc_vport->shost->hostdata; 201 struct lpfc_vport *pport = (struct lpfc_vport *) shost->hostdata;
198 struct lpfc_hba *phba = pport->phba; 202 struct lpfc_hba *phba = pport->phba;
199 struct lpfc_vport *vport = NULL; 203 struct lpfc_vport *vport = NULL;
200 int instance; 204 int instance;
@@ -204,9 +208,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
204 if ((phba->sli_rev < 3) || 208 if ((phba->sli_rev < 3) ||
205 !(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) { 209 !(phba->sli3_options & LPFC_SLI3_NPIV_ENABLED)) {
206 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 210 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
207 "%d:1808 Create VPORT failed: " 211 "1808 Create VPORT failed: "
208 "NPIV is not enabled: SLImode:%d\n", 212 "NPIV is not enabled: SLImode:%d\n",
209 phba->brd_no, phba->sli_rev); 213 phba->sli_rev);
210 rc = VPORT_INVAL; 214 rc = VPORT_INVAL;
211 goto error_out; 215 goto error_out;
212 } 216 }
@@ -214,9 +218,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
214 vpi = lpfc_alloc_vpi(phba); 218 vpi = lpfc_alloc_vpi(phba);
215 if (vpi == 0) { 219 if (vpi == 0) {
216 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 220 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
217 "%d:1809 Create VPORT failed: " 221 "1809 Create VPORT failed: "
218 "Max VPORTs (%d) exceeded\n", 222 "Max VPORTs (%d) exceeded\n",
219 phba->brd_no, phba->max_vpi); 223 phba->max_vpi);
220 rc = VPORT_NORESOURCES; 224 rc = VPORT_NORESOURCES;
221 goto error_out; 225 goto error_out;
222 } 226 }
@@ -225,18 +229,17 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
225 /* Assign an unused board number */ 229 /* Assign an unused board number */
226 if ((instance = lpfc_get_instance()) < 0) { 230 if ((instance = lpfc_get_instance()) < 0) {
227 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 231 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
228 "%d:1810 Create VPORT failed: Cannot get " 232 "1810 Create VPORT failed: Cannot get "
229 "instance number\n", phba->brd_no); 233 "instance number\n");
230 lpfc_free_vpi(phba, vpi); 234 lpfc_free_vpi(phba, vpi);
231 rc = VPORT_NORESOURCES; 235 rc = VPORT_NORESOURCES;
232 goto error_out; 236 goto error_out;
233 } 237 }
234 238
235 vport = lpfc_create_port(phba, instance, fc_vport); 239 vport = lpfc_create_port(phba, instance, &fc_vport->dev);
236 if (!vport) { 240 if (!vport) {
237 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 241 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
238 "%d:1811 Create VPORT failed: vpi x%x\n", 242 "1811 Create VPORT failed: vpi x%x\n", vpi);
239 phba->brd_no, vpi);
240 lpfc_free_vpi(phba, vpi); 243 lpfc_free_vpi(phba, vpi);
241 rc = VPORT_NORESOURCES; 244 rc = VPORT_NORESOURCES;
242 goto error_out; 245 goto error_out;
@@ -246,10 +249,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
246 lpfc_debugfs_initialize(vport); 249 lpfc_debugfs_initialize(vport);
247 250
248 if (lpfc_vport_sparm(phba, vport)) { 251 if (lpfc_vport_sparm(phba, vport)) {
249 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 252 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
250 "%d:1813 Create VPORT failed: vpi:%d " 253 "1813 Create VPORT failed. "
251 "Cannot get sparam\n", 254 "Cannot get sparam\n");
252 phba->brd_no, vpi);
253 lpfc_free_vpi(phba, vpi); 255 lpfc_free_vpi(phba, vpi);
254 destroy_port(vport); 256 destroy_port(vport);
255 rc = VPORT_NORESOURCES; 257 rc = VPORT_NORESOURCES;
@@ -269,10 +271,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
269 271
270 if (!lpfc_valid_wwn_format(phba, &vport->fc_sparam.nodeName, "WWNN") || 272 if (!lpfc_valid_wwn_format(phba, &vport->fc_sparam.nodeName, "WWNN") ||
271 !lpfc_valid_wwn_format(phba, &vport->fc_sparam.portName, "WWPN")) { 273 !lpfc_valid_wwn_format(phba, &vport->fc_sparam.portName, "WWPN")) {
272 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 274 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
273 "%d:1821 Create VPORT failed: vpi:%d " 275 "1821 Create VPORT failed. "
274 "Invalid WWN format\n", 276 "Invalid WWN format\n");
275 phba->brd_no, vpi);
276 lpfc_free_vpi(phba, vpi); 277 lpfc_free_vpi(phba, vpi);
277 destroy_port(vport); 278 destroy_port(vport);
278 rc = VPORT_INVAL; 279 rc = VPORT_INVAL;
@@ -280,10 +281,9 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
280 } 281 }
281 282
282 if (!lpfc_unique_wwpn(phba, vport)) { 283 if (!lpfc_unique_wwpn(phba, vport)) {
283 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT, 284 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
284 "%d:1823 Create VPORT failed: vpi:%d " 285 "1823 Create VPORT failed. "
285 "Duplicate WWN on HBA\n", 286 "Duplicate WWN on HBA\n");
286 phba->brd_no, vpi);
287 lpfc_free_vpi(phba, vpi); 287 lpfc_free_vpi(phba, vpi);
288 destroy_port(vport); 288 destroy_port(vport);
289 rc = VPORT_INVAL; 289 rc = VPORT_INVAL;
@@ -315,10 +315,8 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
315 lpfc_initial_fdisc(vport); 315 lpfc_initial_fdisc(vport);
316 } else { 316 } else {
317 lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); 317 lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP);
318 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 318 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
319 "%d (%d):0262 No NPIV Fabric " 319 "0262 No NPIV Fabric support\n");
320 "support\n",
321 phba->brd_no, vport->vpi);
322 } 320 }
323 } else { 321 } else {
324 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 322 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
@@ -326,12 +324,14 @@ lpfc_vport_create(struct fc_vport *fc_vport, bool disable)
326 rc = VPORT_OK; 324 rc = VPORT_OK;
327 325
328out: 326out:
327 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
328 "1825 Vport Created.\n");
329 lpfc_host_attrib_init(lpfc_shost_from_vport(vport)); 329 lpfc_host_attrib_init(lpfc_shost_from_vport(vport));
330error_out: 330error_out:
331 return rc; 331 return rc;
332} 332}
333 333
334int 334static int
335disable_vport(struct fc_vport *fc_vport) 335disable_vport(struct fc_vport *fc_vport)
336{ 336{
337 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 337 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
@@ -371,10 +371,12 @@ disable_vport(struct fc_vport *fc_vport)
371 lpfc_mbx_unreg_vpi(vport); 371 lpfc_mbx_unreg_vpi(vport);
372 372
373 lpfc_vport_set_state(vport, FC_VPORT_DISABLED); 373 lpfc_vport_set_state(vport, FC_VPORT_DISABLED);
374 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
375 "1826 Vport Disabled.\n");
374 return VPORT_OK; 376 return VPORT_OK;
375} 377}
376 378
377int 379static int
378enable_vport(struct fc_vport *fc_vport) 380enable_vport(struct fc_vport *fc_vport)
379{ 381{
380 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 382 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
@@ -400,15 +402,14 @@ enable_vport(struct fc_vport *fc_vport)
400 lpfc_initial_fdisc(vport); 402 lpfc_initial_fdisc(vport);
401 } else { 403 } else {
402 lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP); 404 lpfc_vport_set_state(vport, FC_VPORT_NO_FABRIC_SUPP);
403 lpfc_printf_log(phba, KERN_ERR, LOG_ELS, 405 lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
404 "%d (%d):0264 No NPIV Fabric " 406 "0264 No NPIV Fabric support\n");
405 "support\n",
406 phba->brd_no, vport->vpi);
407 } 407 }
408 } else { 408 } else {
409 lpfc_vport_set_state(vport, FC_VPORT_FAILED); 409 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
410 } 410 }
411 411 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
412 "1827 Vport Enabled.\n");
412 return VPORT_OK; 413 return VPORT_OK;
413} 414}
414 415
@@ -431,8 +432,29 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
431 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 432 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
432 struct lpfc_hba *phba = vport->phba; 433 struct lpfc_hba *phba = vport->phba;
433 long timeout; 434 long timeout;
434 int rc = VPORT_ERROR;
435 435
436 if (vport->port_type == LPFC_PHYSICAL_PORT) {
437 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
438 "1812 vport_delete failed: Cannot delete "
439 "physical host\n");
440 return VPORT_ERROR;
441 }
442 /*
443 * If we are not unloading the driver then prevent the vport_delete
444 * from happening until after this vport's discovery is finished.
445 */
446 if (!(phba->pport->load_flag & FC_UNLOADING)) {
447 int check_count = 0;
448 while (check_count < ((phba->fc_ratov * 3) + 3) &&
449 vport->port_state > LPFC_VPORT_FAILED &&
450 vport->port_state < LPFC_VPORT_READY) {
451 check_count++;
452 msleep(1000);
453 }
454 if (vport->port_state > LPFC_VPORT_FAILED &&
455 vport->port_state < LPFC_VPORT_READY)
456 return -EAGAIN;
457 }
436 /* 458 /*
437 * This is a bit of a mess. We want to ensure the shost doesn't get 459 * This is a bit of a mess. We want to ensure the shost doesn't get
438 * torn down until we're done with the embedded lpfc_vport structure. 460 * torn down until we're done with the embedded lpfc_vport structure.
@@ -450,16 +472,9 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
450 */ 472 */
451 if (!scsi_host_get(shost) || !scsi_host_get(shost)) 473 if (!scsi_host_get(shost) || !scsi_host_get(shost))
452 return VPORT_INVAL; 474 return VPORT_INVAL;
453 475 spin_lock_irq(&phba->hbalock);
454 if (vport->port_type == LPFC_PHYSICAL_PORT) {
455 lpfc_printf_log(phba, KERN_ERR, LOG_VPORT,
456 "%d:1812 vport_delete failed: Cannot delete "
457 "physical host\n", phba->brd_no);
458 goto out;
459 }
460
461 vport->load_flag |= FC_UNLOADING; 476 vport->load_flag |= FC_UNLOADING;
462 477 spin_unlock_irq(&phba->hbalock);
463 kfree(vport->vname); 478 kfree(vport->vname);
464 lpfc_debugfs_terminate(vport); 479 lpfc_debugfs_terminate(vport);
465 fc_remove_host(lpfc_shost_from_vport(vport)); 480 fc_remove_host(lpfc_shost_from_vport(vport));
@@ -511,13 +526,46 @@ skip_logo:
511 spin_lock_irq(&phba->hbalock); 526 spin_lock_irq(&phba->hbalock);
512 list_del_init(&vport->listentry); 527 list_del_init(&vport->listentry);
513 spin_unlock_irq(&phba->hbalock); 528 spin_unlock_irq(&phba->hbalock);
514 529 lpfc_printf_vlog(vport, KERN_ERR, LOG_VPORT,
515 rc = VPORT_OK; 530 "1828 Vport Deleted.\n");
516out:
517 scsi_host_put(shost); 531 scsi_host_put(shost);
518 return rc; 532 return VPORT_OK;
519} 533}
520 534
521
522EXPORT_SYMBOL(lpfc_vport_create); 535EXPORT_SYMBOL(lpfc_vport_create);
523EXPORT_SYMBOL(lpfc_vport_delete); 536EXPORT_SYMBOL(lpfc_vport_delete);
537
538struct lpfc_vport **
539lpfc_create_vport_work_array(struct lpfc_hba *phba)
540{
541 struct lpfc_vport *port_iterator;
542 struct lpfc_vport **vports;
543 int index = 0;
544 vports = kzalloc(LPFC_MAX_VPORTS * sizeof(struct lpfc_vport *),
545 GFP_KERNEL);
546 if (vports == NULL)
547 return NULL;
548 spin_lock_irq(&phba->hbalock);
549 list_for_each_entry(port_iterator, &phba->port_list, listentry) {
550 if (!scsi_host_get(lpfc_shost_from_vport(port_iterator))) {
551 lpfc_printf_vlog(port_iterator, KERN_WARNING, LOG_VPORT,
552 "1801 Create vport work array FAILED: "
553 "cannot do scsi_host_get\n");
554 continue;
555 }
556 vports[index++] = port_iterator;
557 }
558 spin_unlock_irq(&phba->hbalock);
559 return vports;
560}
561
562void
563lpfc_destroy_vport_work_array(struct lpfc_vport **vports)
564{
565 int i;
566 if (vports == NULL)
567 return;
568 for (i=0; vports[i] != NULL && i < LPFC_MAX_VPORTS; i++)
569 scsi_host_put(lpfc_shost_from_vport(vports[i]));
570 kfree(vports);
571}
diff --git a/drivers/scsi/lpfc/lpfc_vport.h b/drivers/scsi/lpfc/lpfc_vport.h
index f223550f8cba..91da17751a37 100644
--- a/drivers/scsi/lpfc/lpfc_vport.h
+++ b/drivers/scsi/lpfc/lpfc_vport.h
@@ -88,6 +88,8 @@ int lpfc_vport_create(struct fc_vport *, bool);
88int lpfc_vport_delete(struct fc_vport *); 88int lpfc_vport_delete(struct fc_vport *);
89int lpfc_vport_getinfo(struct Scsi_Host *, struct vport_info *); 89int lpfc_vport_getinfo(struct Scsi_Host *, struct vport_info *);
90int lpfc_vport_tgt_remove(struct Scsi_Host *, uint, uint); 90int lpfc_vport_tgt_remove(struct Scsi_Host *, uint, uint);
91struct lpfc_vport **lpfc_create_vport_work_array(struct lpfc_hba *);
92void lpfc_destroy_vport_work_array(struct lpfc_vport **);
91 93
92/* 94/*
93 * queuecommand VPORT-specific return codes. Specified in the host byte code. 95 * queuecommand VPORT-specific return codes. Specified in the host byte code.
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index c488996cb958..93c0c7e4f08f 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -2154,6 +2154,19 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
2154 } 2154 }
2155 } 2155 }
2156 2156
2157 /* Get memory for cached NVRAM */
2158 ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL);
2159 if (ha->nvram == NULL) {
2160 /* error */
2161 qla_printk(KERN_WARNING, ha,
2162 "Memory Allocation failed - nvram cache\n");
2163
2164 qla2x00_mem_free(ha);
2165 msleep(100);
2166
2167 continue;
2168 }
2169
2157 /* Done all allocations without any error. */ 2170 /* Done all allocations without any error. */
2158 status = 0; 2171 status = 0;
2159 2172
@@ -2266,6 +2279,7 @@ qla2x00_mem_free(scsi_qla_host_t *ha)
2266 ha->fw_dump_reading = 0; 2279 ha->fw_dump_reading = 0;
2267 2280
2268 vfree(ha->optrom_buffer); 2281 vfree(ha->optrom_buffer);
2282 kfree(ha->nvram);
2269} 2283}
2270 2284
2271/* 2285/*
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index c4195ea869e9..594887205b0f 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -193,7 +193,8 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f
193 cpu_relax(); 193 cpu_relax();
194 } 194 }
195 if (!loop_count) 195 if (!loop_count)
196 printk(KERN_EMERG "qlogicpti: mbox_command loop timeout #1\n"); 196 printk(KERN_EMERG "qlogicpti%d: mbox_command loop timeout #1\n",
197 qpti->qpti_id);
197 198
198 /* Write mailbox command registers. */ 199 /* Write mailbox command registers. */
199 switch (mbox_param[param[0]] >> 4) { 200 switch (mbox_param[param[0]] >> 4) {
@@ -224,8 +225,8 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f
224 (sbus_readw(qpti->qregs + HCCTRL) & HCCTRL_CRIRQ)) 225 (sbus_readw(qpti->qregs + HCCTRL) & HCCTRL_CRIRQ))
225 udelay(20); 226 udelay(20);
226 if (!loop_count) 227 if (!loop_count)
227 printk(KERN_EMERG "qlogicpti: mbox_command[%04x] loop timeout #2\n", 228 printk(KERN_EMERG "qlogicpti%d: mbox_command[%04x] loop timeout #2\n",
228 param[0]); 229 qpti->qpti_id, param[0]);
229 230
230 /* Wait for SBUS semaphore to get set. */ 231 /* Wait for SBUS semaphore to get set. */
231 loop_count = DEFAULT_LOOP_COUNT; 232 loop_count = DEFAULT_LOOP_COUNT;
@@ -238,16 +239,16 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f
238 break; 239 break;
239 } 240 }
240 if (!loop_count) 241 if (!loop_count)
241 printk(KERN_EMERG "qlogicpti: mbox_command[%04x] loop timeout #3\n", 242 printk(KERN_EMERG "qlogicpti%d: mbox_command[%04x] loop timeout #3\n",
242 param[0]); 243 qpti->qpti_id, param[0]);
243 244
244 /* Wait for MBOX busy condition to go away. */ 245 /* Wait for MBOX busy condition to go away. */
245 loop_count = DEFAULT_LOOP_COUNT; 246 loop_count = DEFAULT_LOOP_COUNT;
246 while (--loop_count && (sbus_readw(qpti->qregs + MBOX0) == 0x04)) 247 while (--loop_count && (sbus_readw(qpti->qregs + MBOX0) == 0x04))
247 udelay(20); 248 udelay(20);
248 if (!loop_count) 249 if (!loop_count)
249 printk(KERN_EMERG "qlogicpti: mbox_command[%04x] loop timeout #4\n", 250 printk(KERN_EMERG "qlogicpti%d: mbox_command[%04x] loop timeout #4\n",
250 param[0]); 251 qpti->qpti_id, param[0]);
251 252
252 /* Read back output parameters. */ 253 /* Read back output parameters. */
253 switch (mbox_param[param[0]] & 0xf) { 254 switch (mbox_param[param[0]] & 0xf) {
@@ -342,7 +343,8 @@ static int qlogicpti_reset_hardware(struct Scsi_Host *host)
342 while (--loop_count && ((sbus_readw(qpti->qregs + MBOX0) & 0xff) == 0x04)) 343 while (--loop_count && ((sbus_readw(qpti->qregs + MBOX0) & 0xff) == 0x04))
343 udelay(20); 344 udelay(20);
344 if (!loop_count) 345 if (!loop_count)
345 printk(KERN_EMERG "qlogicpti: reset_hardware loop timeout\n"); 346 printk(KERN_EMERG "qlogicpti%d: reset_hardware loop timeout\n",
347 qpti->qpti_id);
346 348
347 sbus_writew(HCCTRL_PAUSE, qpti->qregs + HCCTRL); 349 sbus_writew(HCCTRL_PAUSE, qpti->qregs + HCCTRL);
348 set_sbus_cfg1(qpti); 350 set_sbus_cfg1(qpti);
@@ -721,12 +723,12 @@ static int __init qpti_register_irq(struct qlogicpti *qpti)
721 IRQF_SHARED, "Qlogic/PTI", qpti)) 723 IRQF_SHARED, "Qlogic/PTI", qpti))
722 goto fail; 724 goto fail;
723 725
724 printk("qpti%d: IRQ %d ", qpti->qpti_id, qpti->irq); 726 printk("qlogicpti%d: IRQ %d ", qpti->qpti_id, qpti->irq);
725 727
726 return 0; 728 return 0;
727 729
728fail: 730fail:
729 printk("qpti%d: Cannot acquire irq line\n", qpti->qpti_id); 731 printk("qlogicpti%d: Cannot acquire irq line\n", qpti->qpti_id);
730 return -1; 732 return -1;
731} 733}
732 734
@@ -1210,7 +1212,7 @@ static int qlogicpti_return_status(struct Status_Entry *sts, int id)
1210 host_status = DID_OK; 1212 host_status = DID_OK;
1211 break; 1213 break;
1212 default: 1214 default:
1213 printk(KERN_EMERG "qpti%d: unknown completion status 0x%04x\n", 1215 printk(KERN_EMERG "qlogicpti%d: unknown completion status 0x%04x\n",
1214 id, sts->completion_status); 1216 id, sts->completion_status);
1215 host_status = DID_ERROR; 1217 host_status = DID_ERROR;
1216 break; 1218 break;
@@ -1329,8 +1331,8 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd)
1329 u32 cmd_cookie; 1331 u32 cmd_cookie;
1330 int i; 1332 int i;
1331 1333
1332 printk(KERN_WARNING "qlogicpti : Aborting cmd for tgt[%d] lun[%d]\n", 1334 printk(KERN_WARNING "qlogicpti%d: Aborting cmd for tgt[%d] lun[%d]\n",
1333 (int)Cmnd->device->id, (int)Cmnd->device->lun); 1335 qpti->qpti_id, (int)Cmnd->device->id, (int)Cmnd->device->lun);
1334 1336
1335 qlogicpti_disable_irqs(qpti); 1337 qlogicpti_disable_irqs(qpti);
1336 1338
@@ -1348,7 +1350,8 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd)
1348 param[3] = cmd_cookie & 0xffff; 1350 param[3] = cmd_cookie & 0xffff;
1349 if (qlogicpti_mbox_command(qpti, param, 0) || 1351 if (qlogicpti_mbox_command(qpti, param, 0) ||
1350 (param[0] != MBOX_COMMAND_COMPLETE)) { 1352 (param[0] != MBOX_COMMAND_COMPLETE)) {
1351 printk(KERN_EMERG "qlogicpti : scsi abort failure: %x\n", param[0]); 1353 printk(KERN_EMERG "qlogicpti%d: scsi abort failure: %x\n",
1354 qpti->qpti_id, param[0]);
1352 return_status = FAILED; 1355 return_status = FAILED;
1353 } 1356 }
1354 1357
@@ -1364,7 +1367,8 @@ static int qlogicpti_reset(struct scsi_cmnd *Cmnd)
1364 struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata; 1367 struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
1365 int return_status = SUCCESS; 1368 int return_status = SUCCESS;
1366 1369
1367 printk(KERN_WARNING "qlogicpti : Resetting SCSI bus!\n"); 1370 printk(KERN_WARNING "qlogicpti%d: Resetting SCSI bus!\n",
1371 qpti->qpti_id);
1368 1372
1369 qlogicpti_disable_irqs(qpti); 1373 qlogicpti_disable_irqs(qpti);
1370 1374
@@ -1372,7 +1376,8 @@ static int qlogicpti_reset(struct scsi_cmnd *Cmnd)
1372 param[1] = qpti->host_param.bus_reset_delay; 1376 param[1] = qpti->host_param.bus_reset_delay;
1373 if (qlogicpti_mbox_command(qpti, param, 0) || 1377 if (qlogicpti_mbox_command(qpti, param, 0) ||
1374 (param[0] != MBOX_COMMAND_COMPLETE)) { 1378 (param[0] != MBOX_COMMAND_COMPLETE)) {
1375 printk(KERN_EMERG "qlogicisp : scsi bus reset failure: %x\n", param[0]); 1379 printk(KERN_EMERG "qlogicisp%d: scsi bus reset failure: %x\n",
1380 qpti->qpti_id, param[0]);
1376 return_status = FAILED; 1381 return_status = FAILED;
1377 } 1382 }
1378 1383
@@ -1454,22 +1459,25 @@ static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_devi
1454 if (qlogicpti_reset_hardware(host)) 1459 if (qlogicpti_reset_hardware(host))
1455 goto fail_unmap_queues; 1460 goto fail_unmap_queues;
1456 1461
1457 if (scsi_add_host(host, &dev->dev))
1458 goto fail_unmap_queues;
1459
1460 printk("(Firmware v%d.%d.%d)", qpti->fware_majrev, 1462 printk("(Firmware v%d.%d.%d)", qpti->fware_majrev,
1461 qpti->fware_minrev, qpti->fware_micrev); 1463 qpti->fware_minrev, qpti->fware_micrev);
1462 1464
1463 fcode = of_get_property(dp, "isp-fcode", NULL); 1465 fcode = of_get_property(dp, "isp-fcode", NULL);
1464 if (fcode && fcode[0]) 1466 if (fcode && fcode[0])
1465 printk("(Firmware %s)", fcode); 1467 printk("(FCode %s)", fcode);
1466 if (of_find_property(dp, "differential", NULL) != NULL) 1468 if (of_find_property(dp, "differential", NULL) != NULL)
1467 qpti->differential = 1; 1469 qpti->differential = 1;
1468 1470
1469 printk (" [%s Wide, using %s interface]\n", 1471 printk("\nqlogicpti%d: [%s Wide, using %s interface]\n",
1472 qpti->qpti_id,
1470 (qpti->ultra ? "Ultra" : "Fast"), 1473 (qpti->ultra ? "Ultra" : "Fast"),
1471 (qpti->differential ? "differential" : "single ended")); 1474 (qpti->differential ? "differential" : "single ended"));
1472 1475
1476 if (scsi_add_host(host, &dev->dev)) {
1477 printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id);
1478 goto fail_unmap_queues;
1479 }
1480
1473 dev_set_drvdata(&sdev->ofdev.dev, qpti); 1481 dev_set_drvdata(&sdev->ofdev.dev, qpti);
1474 1482
1475 qpti_chain_add(qpti); 1483 qpti_chain_add(qpti);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 21c075d44db1..a417a6ff9f97 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1038,22 +1038,6 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1038 return BLKPREP_KILL; 1038 return BLKPREP_KILL;
1039} 1039}
1040 1040
1041static int scsi_issue_flush_fn(struct request_queue *q, struct gendisk *disk,
1042 sector_t *error_sector)
1043{
1044 struct scsi_device *sdev = q->queuedata;
1045 struct scsi_driver *drv;
1046
1047 if (sdev->sdev_state != SDEV_RUNNING)
1048 return -ENXIO;
1049
1050 drv = *(struct scsi_driver **) disk->private_data;
1051 if (drv->issue_flush)
1052 return drv->issue_flush(&sdev->sdev_gendev, error_sector);
1053
1054 return -EOPNOTSUPP;
1055}
1056
1057static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, 1041static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
1058 struct request *req) 1042 struct request *req)
1059{ 1043{
@@ -1596,7 +1580,6 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
1596 return NULL; 1580 return NULL;
1597 1581
1598 blk_queue_prep_rq(q, scsi_prep_fn); 1582 blk_queue_prep_rq(q, scsi_prep_fn);
1599 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
1600 blk_queue_softirq_done(q, scsi_softirq_done); 1583 blk_queue_softirq_done(q, scsi_softirq_done);
1601 return q; 1584 return q;
1602} 1585}
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index e21c7142a3ea..2c6116fd4578 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -241,7 +241,6 @@ static struct scsi_driver sd_template = {
241 }, 241 },
242 .rescan = sd_rescan, 242 .rescan = sd_rescan,
243 .init_command = sd_init_command, 243 .init_command = sd_init_command,
244 .issue_flush = sd_issue_flush,
245}; 244};
246 245
247/* 246/*
@@ -800,10 +799,17 @@ static int sd_sync_cache(struct scsi_disk *sdkp)
800 return 0; 799 return 0;
801} 800}
802 801
803static int sd_issue_flush(struct device *dev, sector_t *error_sector) 802static int sd_issue_flush(struct request_queue *q, struct gendisk *disk,
803 sector_t *error_sector)
804{ 804{
805 int ret = 0; 805 int ret = 0;
806 struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 806 struct scsi_device *sdp = q->queuedata;
807 struct scsi_disk *sdkp;
808
809 if (sdp->sdev_state != SDEV_RUNNING)
810 return -ENXIO;
811
812 sdkp = scsi_disk_get_from_dev(&sdp->sdev_gendev);
807 813
808 if (!sdkp) 814 if (!sdkp)
809 return -ENODEV; 815 return -ENODEV;
@@ -1663,6 +1669,8 @@ static int sd_probe(struct device *dev)
1663 1669
1664 sd_revalidate_disk(gd); 1670 sd_revalidate_disk(gd);
1665 1671
1672 blk_queue_issue_flush_fn(sdp->request_queue, sd_issue_flush);
1673
1666 gd->driverfs_dev = &sdp->sdev_gendev; 1674 gd->driverfs_dev = &sdp->sdev_gendev;
1667 gd->flags = GENHD_FL_DRIVERFS; 1675 gd->flags = GENHD_FL_DRIVERFS;
1668 if (sdp->removable) 1676 if (sdp->removable)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index a4f7b8465773..73c44cbdea47 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -1485,7 +1485,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1485 struct st_buffer *STbp; 1485 struct st_buffer *STbp;
1486 char *name = tape_name(STp); 1486 char *name = tape_name(STp);
1487 1487
1488 if (down_interruptible(&STp->lock)) 1488 if (mutex_lock_interruptible(&STp->lock))
1489 return -ERESTARTSYS; 1489 return -ERESTARTSYS;
1490 1490
1491 retval = rw_checks(STp, filp, count); 1491 retval = rw_checks(STp, filp, count);
@@ -1736,7 +1736,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1736 if (SRpnt != NULL) 1736 if (SRpnt != NULL)
1737 st_release_request(SRpnt); 1737 st_release_request(SRpnt);
1738 release_buffering(STp, 0); 1738 release_buffering(STp, 0);
1739 up(&STp->lock); 1739 mutex_unlock(&STp->lock);
1740 1740
1741 return retval; 1741 return retval;
1742} 1742}
@@ -1942,7 +1942,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
1942 struct st_buffer *STbp = STp->buffer; 1942 struct st_buffer *STbp = STp->buffer;
1943 DEB( char *name = tape_name(STp); ) 1943 DEB( char *name = tape_name(STp); )
1944 1944
1945 if (down_interruptible(&STp->lock)) 1945 if (mutex_lock_interruptible(&STp->lock))
1946 return -ERESTARTSYS; 1946 return -ERESTARTSYS;
1947 1947
1948 retval = rw_checks(STp, filp, count); 1948 retval = rw_checks(STp, filp, count);
@@ -2069,7 +2069,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
2069 release_buffering(STp, 1); 2069 release_buffering(STp, 1);
2070 STbp->buffer_bytes = 0; 2070 STbp->buffer_bytes = 0;
2071 } 2071 }
2072 up(&STp->lock); 2072 mutex_unlock(&STp->lock);
2073 2073
2074 return retval; 2074 return retval;
2075} 2075}
@@ -3226,7 +3226,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
3226 char *name = tape_name(STp); 3226 char *name = tape_name(STp);
3227 void __user *p = (void __user *)arg; 3227 void __user *p = (void __user *)arg;
3228 3228
3229 if (down_interruptible(&STp->lock)) 3229 if (mutex_lock_interruptible(&STp->lock))
3230 return -ERESTARTSYS; 3230 return -ERESTARTSYS;
3231 3231
3232 DEB( 3232 DEB(
@@ -3537,7 +3537,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
3537 retval = (-EFAULT); 3537 retval = (-EFAULT);
3538 goto out; 3538 goto out;
3539 } 3539 }
3540 up(&STp->lock); 3540 mutex_unlock(&STp->lock);
3541 switch (cmd_in) { 3541 switch (cmd_in) {
3542 case SCSI_IOCTL_GET_IDLUN: 3542 case SCSI_IOCTL_GET_IDLUN:
3543 case SCSI_IOCTL_GET_BUS_NUMBER: 3543 case SCSI_IOCTL_GET_BUS_NUMBER:
@@ -3563,7 +3563,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
3563 return retval; 3563 return retval;
3564 3564
3565 out: 3565 out:
3566 up(&STp->lock); 3566 mutex_unlock(&STp->lock);
3567 return retval; 3567 return retval;
3568} 3568}
3569 3569
@@ -4029,7 +4029,7 @@ static int st_probe(struct device *dev)
4029 4029
4030 tpnt->density_changed = tpnt->compression_changed = 4030 tpnt->density_changed = tpnt->compression_changed =
4031 tpnt->blksize_changed = 0; 4031 tpnt->blksize_changed = 0;
4032 init_MUTEX(&tpnt->lock); 4032 mutex_init(&tpnt->lock);
4033 4033
4034 st_nr_dev++; 4034 st_nr_dev++;
4035 write_unlock(&st_dev_arr_lock); 4035 write_unlock(&st_dev_arr_lock);
diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h
index 50f3deb1f9ed..6c8075712974 100644
--- a/drivers/scsi/st.h
+++ b/drivers/scsi/st.h
@@ -3,6 +3,7 @@
3#define _ST_H 3#define _ST_H
4 4
5#include <linux/completion.h> 5#include <linux/completion.h>
6#include <linux/mutex.h>
6#include <linux/kref.h> 7#include <linux/kref.h>
7#include <scsi/scsi_cmnd.h> 8#include <scsi/scsi_cmnd.h>
8 9
@@ -98,7 +99,7 @@ struct st_partstat {
98struct scsi_tape { 99struct scsi_tape {
99 struct scsi_driver *driver; 100 struct scsi_driver *driver;
100 struct scsi_device *device; 101 struct scsi_device *device;
101 struct semaphore lock; /* For serialization */ 102 struct mutex lock; /* For serialization */
102 struct completion wait; /* For SCSI commands */ 103 struct completion wait; /* For SCSI commands */
103 struct st_buffer *buffer; 104 struct st_buffer *buffer;
104 105