27 #include <linux/module.h>
29 #include <linux/pci.h>
31 #include <linux/ctype.h>
33 #include <linux/slab.h>
37 #include <scsi/scsi.h>
62 static int lpfc_post_rcv_buf(
struct lpfc_hba *);
63 static int lpfc_sli4_queue_verify(
struct lpfc_hba *);
64 static int lpfc_create_bootstrap_mbox(
struct lpfc_hba *);
65 static int lpfc_setup_endian_order(
struct lpfc_hba *);
66 static void lpfc_destroy_bootstrap_mbox(
struct lpfc_hba *);
67 static void lpfc_free_els_sgl_list(
struct lpfc_hba *);
68 static void lpfc_init_sgl_list(
struct lpfc_hba *);
69 static int lpfc_init_active_sgl_array(
struct lpfc_hba *);
70 static void lpfc_free_active_sgl(
struct lpfc_hba *);
71 static int lpfc_hba_down_post_s3(
struct lpfc_hba *phba);
72 static int lpfc_hba_down_post_s4(
struct lpfc_hba *phba);
73 static int lpfc_sli4_cq_event_pool_create(
struct lpfc_hba *);
74 static void lpfc_sli4_cq_event_pool_destroy(
struct lpfc_hba *);
75 static void lpfc_sli4_cq_event_release_all(
struct lpfc_hba *);
76 static void lpfc_sli4_disable_intr(
struct lpfc_hba *);
104 char *lpfc_vpd_data =
NULL;
106 static char licensed[56] =
107 "key unlock for use with gnu public licensed code only\0";
108 static int init_key = 1;
119 if (lpfc_is_LC_HBA(phba->
pcidev->device)) {
123 for (i = 0; i < 56; i +=
sizeof (
uint32_t), ptext++)
138 "0324 Config Port initialization "
139 "error, mbxCmd x%x READ_NVPARM, "
158 "0439 Adapter failed to init, mbxCmd x%x "
159 "READ_REV, mbxStatus x%x\n",
173 "0440 Adapter failed to init, READ_REV has "
174 "missing revision information.\n");
206 if (vp->
rev.feaLevelHigh < 9)
209 if (lpfc_is_LC_HBA(phba->
pcidev->device))
223 "0441 VPD not present on adapter, "
224 "mbxCmd x%x DUMP VPD, mbxStatus x%x\n",
236 lpfc_vpd_data + offset,
242 kfree(lpfc_vpd_data);
286 char dist_char[] =
"nabx";
293 prg = (
struct prog_id *) &prog_id_word;
300 dist = dist_char[prg->
dist];
302 if ((prg->
dist == 3) && (prg->
num == 0))
326 if (vport->
phba->cfg_soft_wwnn)
327 u64_to_wwn(vport->
phba->cfg_soft_wwnn,
329 if (vport->
phba->cfg_soft_wwpn)
330 u64_to_wwn(vport->
phba->cfg_soft_wwpn,
385 spin_unlock_irq(&phba->
hbalock);
404 "0448 Adapter failed init, mbxCmd x%x "
405 "READ_SPARM mbxStatus x%x\n",
434 for (i = 0; i < 12; i++) {
436 j = ((status & 0xf0) >> 4);
458 "0453 Adapter failed to init, mbxCmd x%x "
459 "READ_CONFIG, mbxStatus x%x\n",
492 lpfc_post_rcv_buf(phba);
506 "0352 Config MSI mailbox command "
507 "failed, mbxCmd x%x, mbxStatus x%x\n",
520 if (lpfc_readl(phba->
HCregaddr, &status)) {
521 spin_unlock_irq(&phba->
hbalock);
540 spin_unlock_irq(&phba->
hbalock);
555 "2598 Adapter Link is disabled.\n");
562 "2599 Adapter failed to issue DOWN_LINK"
563 " mbox command rc 0x%x\n", rc);
590 "0456 Adapter failed to issue "
591 "ASYNCEVT_ENABLE mbox status x%x\n",
604 pmb->
mbox_cmpl = lpfc_dump_wakeup_param_cmpl;
610 "to get Option ROM version status x%x\n", rc);
684 "1302 Invalid speed for this board:%d "
685 "Reset link speed to auto.\n",
692 lpfc_set_loopback_flag(phba);
696 "0498 Adapter failed to init, mbxCmd x%x "
697 "INIT_LINK, mbxStatus x%x\n",
746 "0491 Adapter Link is disabled.\n");
753 "2522 Adapter failed to issue DOWN_LINK"
754 " mbox command rc 0x%x\n", rc);
794 vports[
i] !=
NULL; i++)
813 lpfc_hba_down_post_s3(
struct lpfc_hba *phba)
836 pring = &psli->
ring[
i];
841 list_splice_init(&pring->
txcmplq, &completions);
843 spin_unlock_irq(&phba->
hbalock);
852 spin_unlock_irq(&phba->
hbalock);
869 lpfc_hba_down_post_s4(
struct lpfc_hba *phba)
874 unsigned long iflag = 0;
877 ret = lpfc_hba_down_post_s3(phba);
891 spin_lock(&phba->
sli4_hba.abts_sgl_list_lock);
896 list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list,
897 &phba->sli4_hba.lpfc_sgl_list);
898 spin_unlock(&phba->sli4_hba.abts_sgl_list_lock);
902 spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock);
903 list_splice_init(&phba->sli4_hba.lpfc_abts_scsi_buf_list,
905 spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock);
906 spin_unlock_irq(&phba->hbalock);
948 lpfc_hb_timeout(
unsigned long ptr)
961 spin_unlock_irqrestore(&phba->
pport->work_port_lock, iflag);
982 lpfc_rrq_timeout(
unsigned long ptr)
990 spin_unlock_irqrestore(&phba->
pport->work_port_lock, iflag);
1013 unsigned long drvr_flag;
1017 spin_unlock_irqrestore(&phba->
hbalock, drvr_flag);
1066 spin_lock_irq(&phba->
pport->work_port_lock);
1070 spin_unlock_irq(&phba->
pport->work_port_lock);
1079 spin_unlock_irq(&phba->
pport->work_port_lock);
1083 spin_lock_irq(&phba->
hbalock);
1084 list_splice_init(&phba->
elsbuf, &completions);
1087 spin_unlock_irq(&phba->
hbalock);
1089 while (!list_empty(&completions)) {
1102 (list_empty(&psli->
mboxq))) {
1132 "2857 Last completion time not "
1133 " updated in %d ms\n",
1149 "0459 Adapter heartbeat still out"
1150 "standing:last compl time was %d ms.\n",
1167 lpfc_offline_eratt(
struct lpfc_hba *phba)
1171 spin_lock_irq(&phba->
hbalock);
1173 spin_unlock_irq(&phba->
hbalock);
1178 spin_lock_irq(&phba->
hbalock);
1180 spin_unlock_irq(&phba->
hbalock);
1196 lpfc_sli4_offline_eratt(
struct lpfc_hba *phba)
1217 lpfc_handle_deferred_eratt(
struct lpfc_hba *phba)
1226 if (pci_channel_offline(phba->
pcidev)) {
1227 spin_lock_irq(&phba->
hbalock);
1229 spin_unlock_irq(&phba->
hbalock);
1234 "0479 Deferred Adapter Hardware Error "
1235 "Data: x%x x%x x%x\n",
1239 spin_lock_irq(&phba->
hbalock);
1241 spin_unlock_irq(&phba->
hbalock);
1281 spin_lock_irq(&phba->
hbalock);
1283 spin_unlock_irq(&phba->
hbalock);
1289 lpfc_board_errevt_to_mgmt(
struct lpfc_hba *phba)
1296 shost = lpfc_shost_from_vport(phba->
pport);
1298 sizeof(board_event),
1299 (
char *) &board_event,
1314 lpfc_handle_eratt_s3(
struct lpfc_hba *phba)
1327 if (pci_channel_offline(phba->
pcidev)) {
1328 spin_lock_irq(&phba->
hbalock);
1330 spin_unlock_irq(&phba->
hbalock);
1339 lpfc_board_errevt_to_mgmt(phba);
1342 lpfc_handle_deferred_eratt(phba);
1348 "1301 Re-establishing Link "
1349 "Data: x%x x%x x%x\n",
1355 "2861 Host Authentication device "
1356 "zeroization Data:x%x x%x x%x\n",
1360 spin_lock_irq(&phba->
hbalock);
1362 spin_unlock_irq(&phba->
hbalock);
1389 temp_event_data.data = (
uint32_t)temperature;
1392 "0406 Adapter maximum temperature exceeded "
1393 "(%ld), taking this port offline "
1394 "Data: x%x x%x x%x\n",
1398 shost = lpfc_shost_from_vport(phba->
pport);
1400 sizeof(temp_event_data),
1401 (
char *) &temp_event_data,
1405 spin_lock_irq(&phba->
hbalock);
1407 spin_unlock_irq(&phba->
hbalock);
1408 lpfc_offline_eratt(phba);
1416 "0457 Adapter Hardware Error "
1417 "Data: x%x x%x x%x\n",
1422 shost = lpfc_shost_from_vport(vport);
1424 sizeof(event_data), (
char *) &event_data,
1427 lpfc_offline_eratt(phba);
1444 lpfc_sli4_port_sta_fn_reset(
struct lpfc_hba *phba,
int mbx_action)
1457 "2887 Reset Needed: Attempting Port "
1462 lpfc_sli4_disable_intr(phba);
1465 intr_mode = lpfc_sli4_enable_intr(phba, phba->
intr_mode);
1468 "3175 Failed to enable interrupt\n");
1488 lpfc_handle_eratt_s4(
struct lpfc_hba *phba)
1503 if (pci_channel_offline(phba->
pcidev))
1509 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
1512 pci_rd_rc1 = lpfc_readl(
1513 phba->
sli4_hba.u.if_type0.UERRLOregaddr,
1515 pci_rd_rc2 = lpfc_readl(
1516 phba->
sli4_hba.u.if_type0.UEMASKLOregaddr,
1519 if (pci_rd_rc1 == -
EIO && pci_rd_rc2 == -
EIO)
1521 lpfc_sli4_offline_eratt(phba);
1524 pci_rd_rc1 = lpfc_readl(
1525 phba->
sli4_hba.u.if_type2.STATUSregaddr,
1526 &portstat_reg.
word0);
1528 if (pci_rd_rc1 == -
EIO) {
1530 "3151 PCI bus read access failure: x%x\n",
1536 if (
bf_get(lpfc_sliport_status_oti, &portstat_reg)) {
1539 "2889 Port Overtemperature event, "
1540 "taking port offline\n");
1541 spin_lock_irq(&phba->
hbalock);
1543 spin_unlock_irq(&phba->
hbalock);
1544 lpfc_sli4_offline_eratt(phba);
1550 "3143 Port Down: Firmware Restarted\n");
1554 "3144 Port Down: Debug Dump\n");
1558 "3145 Port Down: Provisioning\n");
1572 "3152 Unrecoverable error, bring the port "
1574 lpfc_sli4_offline_eratt(phba);
1581 "3123 Report dump event to upper layer\n");
1583 lpfc_board_errevt_to_mgmt(phba);
1586 shost = lpfc_shost_from_vport(vport);
1588 sizeof(event_data), (
char *) &event_data,
1629 goto lpfc_handle_latt_err_exit;
1635 goto lpfc_handle_latt_free_pmb;
1641 goto lpfc_handle_latt_free_mp;
1656 goto lpfc_handle_latt_free_mbuf;
1660 spin_lock_irq(&phba->
hbalock);
1663 spin_unlock_irq(&phba->
hbalock);
1667 lpfc_handle_latt_free_mbuf:
1670 lpfc_handle_latt_free_mp:
1672 lpfc_handle_latt_free_pmb:
1674 lpfc_handle_latt_err_exit:
1676 spin_lock_irq(&phba->
hbalock);
1686 spin_unlock_irq(&phba->
hbalock);
1691 "0300 LATT: Cannot issue READ_LA: Data:%d\n", rc);
1724 "0455 Vital Product Data: x%x x%x x%x x%x\n",
1727 while (!finished && (index < (len - 4))) {
1728 switch (vpd[index]) {
1736 i = ((((
unsigned short)lenhi) << 8) + lenlo);
1745 Length = ((((
unsigned short)lenhi) << 8) + lenlo);
1746 if (Length > len - index)
1747 Length = len -
index;
1748 while (Length > 0) {
1750 if ((vpd[index] ==
'S') && (vpd[index+1] ==
'N')) {
1764 else if ((vpd[index] ==
'V') && (vpd[index+1] ==
'1')) {
1779 else if ((vpd[index] ==
'V') && (vpd[index+1] ==
'2')) {
1794 else if ((vpd[index] ==
'V') && (vpd[index+1] ==
'3')) {
1809 else if ((vpd[index] ==
'V') && (vpd[index+1] ==
'4')) {
1823 phba->
Port[j++] = vpd[index++];
1879 }
m = {
"<Unknown>",
"",
""};
1881 if (mdp && mdp[0] !=
'\0'
1882 && descp && descp[0] !=
'\0')
1904 m = (
typeof(
m)){
"LP6000",
"PCI",
"Fibre Channel Adapter"};
1907 if (vp->
rev.biuRev >= 1 && vp->
rev.biuRev <= 3)
1909 "Fibre Channel Adapter"};
1912 "Fibre Channel Adapter"};
1916 "Fibre Channel Adapter"};
1921 "Fibre Channel Adapter"};
1924 "Fibre Channel Adapter"};
1928 "Fibre Channel Adapter"};
1932 "Fibre Channel Adapter"};
1935 m = (
typeof(
m)){
"LP10000",
"PCI-X",
1936 "Fibre Channel Adapter"};
1939 m = (
typeof(
m)){
"LPX1000",
"PCI-X",
1940 "Fibre Channel Adapter"};
1944 "Fibre Channel Adapter"};
1948 "Fibre Channel Adapter"};
1951 m = (
typeof(
m)){
"LP11000",
"PCI-X2",
1952 "Fibre Channel Adapter"};
1955 m = (
typeof(
m)){
"LP11000-SP",
"PCI-X2",
1956 "Fibre Channel Adapter"};
1959 m = (
typeof(
m)){
"LP11002-SP",
"PCI-X2",
1960 "Fibre Channel Adapter"};
1963 m = (
typeof(
m)){
"LPe1000",
"PCIe",
"Fibre Channel Adapter"};
1966 m = (
typeof(
m)){
"LPe1000-SP",
"PCIe",
"Fibre Channel Adapter"};
1969 m = (
typeof(
m)){
"LPe1002-SP",
"PCIe",
"Fibre Channel Adapter"};
1972 m = (
typeof(
m)){
"LP1150",
"PCI-X2",
"Fibre Channel Adapter"};
1975 m = (
typeof(
m)){
"LP111",
"PCI-X2",
"Fibre Channel Adapter"};
1978 m = (
typeof(
m)){
"LPe11000",
"PCIe",
"Fibre Channel Adapter"};
1981 m = (
typeof(
m)){
"LPe11000",
"PCIe",
"Fibre Channel Adapter"};
1984 m = (
typeof(
m)){
"LP2105",
"PCIe",
"FCoE Adapter"};
1988 m = (
typeof(
m)){
"LPe1150",
"PCIe",
"Fibre Channel Adapter"};
1991 m = (
typeof(
m)){
"LPe111",
"PCIe",
"Fibre Channel Adapter"};
1994 m = (
typeof(
m)){
"LP101",
"PCI-X",
"Fibre Channel Adapter"};
1997 m = (
typeof(
m)){
"LP10000-S",
"PCI",
"Fibre Channel Adapter"};
2000 m = (
typeof(
m)){
"LP11000-S",
"PCI-X2",
"Fibre Channel Adapter"};
2003 m = (
typeof(
m)){
"LPe11000-S",
"PCIe",
"Fibre Channel Adapter"};
2006 m = (
typeof(
m)){
"LPe12000",
"PCIe",
"Fibre Channel Adapter"};
2009 m = (
typeof(
m)){
"LPe1250",
"PCIe",
"Fibre Channel Adapter"};
2012 m = (
typeof(
m)){
"LPe121",
"PCIe",
"Fibre Channel Adapter"};
2015 m = (
typeof(
m)){
"LPe12002-SP",
"PCIe",
"Fibre Channel Adapter"};
2018 m = (
typeof(
m)){
"LPe12000-SP",
"PCIe",
"Fibre Channel Adapter"};
2021 m = (
typeof(
m)){
"LPe12000-S",
"PCIe",
"Fibre Channel Adapter"};
2024 m = (
typeof(
m)){
"LP21000",
"PCIe",
"FCoE Adapter"};
2028 m = (
typeof(
m)){
"LPev12000",
"PCIe IOV",
2029 "Fibre Channel Adapter"};
2032 m = (
typeof(
m)){
"LPev12000",
"PCIe IOV",
2033 "Fibre Channel Adapter"};
2036 m = (
typeof(
m)){
"LPemv12002-S",
"PCIe IOV",
2037 "Fibre Channel Adapter"};
2041 m = (
typeof(
m)){
"OCe10100",
"PCIe",
"FCoE"};
2045 m = (
typeof(
m)){
"OCe11100",
"PCIe",
"FCoE"};
2048 m = (
typeof(
m)){
"LPSe12002-ML1-E",
"PCIe",
2049 "EmulexSecure Fibre"};
2052 m = (
typeof(
m)){
"LPVe12002",
"PCIe Shared I/O",
2053 "Fibre Channel Adapter"};
2057 m = (
typeof(
m)){
"LPe16000",
"PCIe",
"Fibre Channel Adapter"};
2062 m = (
typeof(
m)){
"OCe15100",
"PCIe",
"FCoE"};
2067 m = (
typeof(
m)){
"OCe14000",
"PCIe",
"FCoE"};
2070 m = (
typeof(
m)){
"Unknown",
"",
""};
2074 if (mdp && mdp[0] ==
'\0')
2080 if (descp && descp[0] ==
'\0') {
2083 "Emulex OneConnect %s, %s Initiator %s",
2086 else if (max_speed == 0)
2089 m.name,
m.bus,
m.function);
2092 "Emulex %s %d%s %s %s",
2093 m.name, max_speed, (GE) ?
"GE" :
"Gb",
2134 if (!mp1 || !mp1->
virt) {
2141 INIT_LIST_HEAD(&mp1->
list);
2148 if (!mp2 || !mp2->
virt) {
2157 INIT_LIST_HEAD(&mp2->
list);
2212 lpfc_post_rcv_buf(
struct lpfc_hba *phba)
2223 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2233 lpfc_sha_init(
uint32_t * HashResultPointer)
2235 HashResultPointer[0] = 0x67452301;
2236 HashResultPointer[1] = 0xEFCDAB89;
2237 HashResultPointer[2] = 0x98BADCFE;
2238 HashResultPointer[3] = 0x10325476;
2239 HashResultPointer[4] = 0xC3D2E1F0;
2253 lpfc_sha_iterate(
uint32_t * HashResultPointer,
uint32_t * HashWorkingPointer)
2260 HashWorkingPointer[
t] =
2262 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t -
2264 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]);
2265 }
while (++t <= 79);
2267 A = HashResultPointer[0];
2268 B = HashResultPointer[1];
2269 C = HashResultPointer[2];
2270 D = HashResultPointer[3];
2271 E = HashResultPointer[4];
2275 TEMP = ((B &
C) | ((~B) &
D)) + 0x5A827999;
2276 }
else if (t < 40) {
2277 TEMP = (B ^ C ^
D) + 0x6ED9EBA1;
2278 }
else if (t < 60) {
2279 TEMP = ((B &
C) | (B & D) | (C &
D)) + 0x8F1BBCDC;
2281 TEMP = (B ^ C ^
D) + 0xCA62C1D6;
2283 TEMP +=
S(5, A) + E + HashWorkingPointer[
t];
2289 }
while (++t <= 79);
2291 HashResultPointer[0] +=
A;
2292 HashResultPointer[1] +=
B;
2293 HashResultPointer[2] +=
C;
2294 HashResultPointer[3] +=
D;
2295 HashResultPointer[4] += E;
2312 *HashWorking = (*RandomChallenge ^ *HashWorking);
2333 HashWorking[0] = HashWorking[78] = *pwwnn++;
2334 HashWorking[1] = HashWorking[79] = *pwwnn;
2336 for (t = 0; t < 7; t++)
2337 lpfc_challenge_key(phba->
RandomData + t, HashWorking + t);
2339 lpfc_sha_init(hbainit);
2340 lpfc_sha_iterate(hbainit, HashWorking);
2413 while (!list_empty(&vport->
fc_nodes)) {
2416 "0233 Nodelist not empty\n");
2421 "0282 did:x%x ndlp:x%p "
2422 "usgmap:x%x refcnt:%d\n",
2426 &ndlp->
kref.refcount));
2484 spin_lock_irq(&phba->
hbalock);
2487 spin_unlock_irq(&phba->
hbalock);
2493 spin_unlock_irq(&phba->
hbalock);
2528 "0297 Invalid device group (x%x)\n",
2546 lpfc_block_mgmt_io(
struct lpfc_hba *phba,
int mbx_action)
2548 unsigned long iflag;
2554 spin_unlock_irqrestore(&phba->
hbalock, iflag);
2559 if (phba->
sli.mbox_active) {
2560 actcmd = phba->
sli.mbox_active->u.mb.mbxCommand;
2567 spin_unlock_irqrestore(&phba->
hbalock, iflag);
2570 while (phba->
sli.mbox_active) {
2575 "2813 Mgmt IO is Blocked %x "
2576 "- mbox cmd %x still active\n",
2577 phba->
sli.sli_flag, actcmd);
2602 if (vports !=
NULL) {
2640 vport = phba->
pport;
2646 "0458 Bring Adapter online\n");
2671 shost = lpfc_shost_from_vport(vports[i]);
2700 unsigned long iflag;
2704 spin_unlock_irqrestore(&phba->
hbalock, iflag);
2727 lpfc_block_mgmt_io(phba, mbx_action);
2733 if (vports !=
NULL) {
2737 shost = lpfc_shost_from_vport(vports[i]);
2744 shost = lpfc_shost_from_vport(vports[i]);
2746 &vports[i]->fc_nodes,
2803 "0460 Bring Adapter offline\n");
2807 spin_lock_irq(&phba->
hbalock);
2809 spin_unlock_irq(&phba->
hbalock);
2813 shost = lpfc_shost_from_vport(vports[i]);
2831 lpfc_scsi_free(
struct lpfc_hba *phba)
2836 spin_lock_irq(&phba->
hbalock);
2855 spin_unlock_irq(&phba->
hbalock);
2875 uint16_t i, lxri, xri_cnt, els_xri_cnt, scsi_xri_cnt;
2884 if (els_xri_cnt > phba->
sli4_hba.els_xri_cnt) {
2886 xri_cnt = els_xri_cnt - phba->
sli4_hba.els_xri_cnt;
2888 "3157 ELS xri-sgl count increased from "
2889 "%d to %d\n", phba->
sli4_hba.els_xri_cnt,
2892 for (i = 0; i < xri_cnt; i++) {
2893 sglq_entry = kzalloc(
sizeof(
struct lpfc_sglq),
2895 if (sglq_entry ==
NULL) {
2897 "2562 Failure to allocate an "
2898 "ELS sgl entry:%d\n", i);
2908 "2563 Failure to allocate an "
2909 "ELS mbuf:%d\n", i);
2913 sglq_entry->
sgl = sglq_entry->
virt;
2919 list_splice_init(&els_sgl_list, &phba->
sli4_hba.lpfc_sgl_list);
2921 }
else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) {
2923 xri_cnt = phba->
sli4_hba.els_xri_cnt - els_xri_cnt;
2925 "3158 ELS xri-sgl count decreased from "
2926 "%d to %d\n", phba->
sli4_hba.els_xri_cnt,
2928 spin_lock_irq(&phba->
hbalock);
2929 list_splice_init(&phba->
sli4_hba.lpfc_sgl_list, &els_sgl_list);
2930 spin_unlock_irq(&phba->
hbalock);
2932 for (i = 0; i < xri_cnt; i++) {
2941 spin_lock_irq(&phba->
hbalock);
2942 list_splice_init(&els_sgl_list, &phba->
sli4_hba.lpfc_sgl_list);
2943 spin_unlock_irq(&phba->
hbalock);
2946 "3163 ELS xri-sgl count unchanged: %d\n",
2948 phba->
sli4_hba.els_xri_cnt = els_xri_cnt;
2952 sglq_entry_next =
NULL;
2958 "2400 Failed to allocate xri for "
2977 "2401 Current allocated SCSI xri-sgl count:%d, "
2978 "maximum SCSI xri count:%d\n",
2988 scsi_xri_cnt = phba->
sli4_hba.scsi_xri_cnt -
2991 for (i = 0; i < scsi_xri_cnt; i++) {
2999 phba->
sli4_hba.scsi_xri_cnt -= scsi_xri_cnt;
3010 "2560 Failed to allocate xri for "
3025 lpfc_free_els_sgl_list(phba);
3026 lpfc_scsi_free(phba);
3053 if (dev != &phba->
pcidev->dev)
3062 vport = (
struct lpfc_vport *) shost->hostdata;
3076 phba->
sli4_hba.pc_sli4_params.sge_supp_len-1;
3086 if (dev != &phba->
pcidev->dev) {
3087 shost->
transportt = lpfc_vport_transport_template;
3119 spin_lock_irq(&phba->
hbalock);
3121 spin_unlock_irq(&phba->
hbalock);
3140 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
3147 spin_lock_irq(&phba->
hbalock);
3149 spin_unlock_irq(&phba->
hbalock);
3205 if (time >= 30 *
HZ) {
3207 "0461 Scanning longer than 30 "
3208 "seconds. Continuing initialization\n");
3214 "0465 Link down longer than 15 "
3215 "seconds. Continuing initialization\n");
3304 lpfc_stop_port_s3(
struct lpfc_hba *phba)
3315 phba->
pport->work_port_events = 0;
3327 lpfc_stop_port_s4(
struct lpfc_hba *phba)
3331 phba->
pport->work_port_events = 0;
3357 unsigned long fcf_redisc_wait_tmo =
3360 mod_timer(&phba->
fcf.redisc_wait, fcf_redisc_wait_tmo);
3361 spin_lock_irq(&phba->
hbalock);
3366 spin_unlock_irq(&phba->
hbalock);
3385 spin_lock_irq(&phba->
hbalock);
3387 spin_unlock_irq(&phba->
hbalock);
3394 spin_unlock_irq(&phba->
hbalock);
3396 "2776 FCF rediscover quiescent timer expired\n");
3413 lpfc_sli4_parse_latt_fault(
struct lpfc_hba *phba,
3418 switch (
bf_get(lpfc_acqe_link_fault, acqe_link)) {
3426 "0398 Invalid link fault code: x%x\n",
3427 bf_get(lpfc_acqe_link_fault, acqe_link));
3445 lpfc_sli4_parse_latt_type(
struct lpfc_hba *phba,
3450 switch (
bf_get(lpfc_acqe_link_status, acqe_link)) {
3464 "0399 Invalid link attention type: x%x\n",
3465 bf_get(lpfc_acqe_link_status, acqe_link));
3483 lpfc_sli4_parse_latt_link_speed(
struct lpfc_hba *phba,
3488 switch (
bf_get(lpfc_acqe_link_speed, acqe_link)) {
3502 "0483 Invalid link-attention link speed: x%x\n",
3503 bf_get(lpfc_acqe_link_speed, acqe_link));
3523 if (!lpfc_is_link_up(phba))
3570 switch (speed_code) {
3591 switch (speed_code) {
3631 lpfc_sli4_async_link_evt(
struct lpfc_hba *phba,
3641 att_type = lpfc_sli4_parse_latt_type(phba, acqe_link);
3648 "0395 The mboxq allocation failed\n");
3654 "0396 The lpfc_dmabuf allocation failed\n");
3660 "0397 The mbuf allocation failed\n");
3661 goto out_free_dmabuf;
3671 phba->
sli.slistat.link_event++;
3681 bf_get(lpfc_acqe_link_speed, acqe_link));
3683 bf_get(lpfc_acqe_link_duplex, acqe_link);
3685 bf_get(lpfc_acqe_link_status, acqe_link);
3687 bf_get(lpfc_acqe_link_type, acqe_link);
3689 bf_get(lpfc_acqe_link_number, acqe_link);
3691 bf_get(lpfc_acqe_link_fault, acqe_link);
3692 phba->
sli4_hba.link_state.logical_speed =
3693 bf_get(lpfc_acqe_logical_link_speed, acqe_link) * 10;
3696 "2900 Async FC/FCoE Link event - Speed:%dGBit "
3697 "duplex:x%x LA Type:x%x Port Type:%d Port Number:%d "
3698 "Logical speed:%dMbps Fault:%d\n",
3700 phba->
sli4_hba.link_state.topology,
3704 phba->
sli4_hba.link_state.logical_speed,
3713 goto out_free_dmabuf;
3723 mb->
mbxStatus = lpfc_sli4_parse_latt_fault(phba, acqe_link);
3728 bf_set(lpfc_mbx_read_top_att_type, la, att_type);
3729 bf_set(lpfc_mbx_read_top_link_spd, la,
3730 lpfc_sli4_parse_latt_link_speed(phba, acqe_link));
3734 bf_set(lpfc_mbx_read_top_alpa_granted, la, 0);
3735 bf_set(lpfc_mbx_read_top_il, la, 0);
3736 bf_set(lpfc_mbx_read_top_pb, la, 0);
3737 bf_set(lpfc_mbx_read_top_fa, la, 0);
3738 bf_set(lpfc_mbx_read_top_mm, la, 0);
3767 if (
bf_get(lpfc_trailer_type, acqe_fc) !=
3770 "2895 Non FC link Event detected.(%d)\n",
3771 bf_get(lpfc_trailer_type, acqe_fc));
3777 bf_get(lpfc_acqe_fc_la_speed, acqe_fc));
3779 phba->
sli4_hba.link_state.topology =
3780 bf_get(lpfc_acqe_fc_la_topology, acqe_fc);
3782 bf_get(lpfc_acqe_fc_la_att_type, acqe_fc);
3784 bf_get(lpfc_acqe_fc_la_port_type, acqe_fc);
3786 bf_get(lpfc_acqe_fc_la_port_number, acqe_fc);
3788 bf_get(lpfc_acqe_link_fault, acqe_fc);
3789 phba->
sli4_hba.link_state.logical_speed =
3790 bf_get(lpfc_acqe_fc_la_llink_spd, acqe_fc) * 10;
3792 "2896 Async FC event - Speed:%dGBaud Topology:x%x "
3793 "LA Type:x%x Port Type:%d Port Number:%d Logical speed:"
3794 "%dMbps Fault:%d\n",
3796 phba->
sli4_hba.link_state.topology,
3800 phba->
sli4_hba.link_state.logical_speed,
3805 "2897 The mboxq allocation failed\n");
3811 "2898 The lpfc_dmabuf allocation failed\n");
3817 "2899 The mbuf allocation failed\n");
3818 goto out_free_dmabuf;
3828 phba->
sli.slistat.link_event++;
3837 goto out_free_dmabuf;
3864 (
bf_get(lpfc_trailer_type, acqe_sli) !=
3867 "2901 Async SLI event - Event Data1:x%08x Event Data2:"
3868 "x%08x SLI Event Type:%d\n",
3870 bf_get(lpfc_trailer_type, acqe_sli));
3874 port_name = phba->
Port[0];
3875 if (port_name == 0x00)
3882 switch (phba->
sli4_hba.lnk_info.lnk_no) {
3884 status =
bf_get(lpfc_sli_misconfigured_port0,
3888 status =
bf_get(lpfc_sli_misconfigured_port1,
3892 status =
bf_get(lpfc_sli_misconfigured_port2,
3896 status =
bf_get(lpfc_sli_misconfigured_port3,
3908 sprintf(message,
"Optics faulted/incorrectly installed/not " \
3909 "installed - Reseat optics, if issue not "
3910 "resolved, replace.");
3914 "Optics of two types installed - Remove one optic or " \
3915 "install matching pair of optics.");
3918 sprintf(message,
"Incompatible optics - Replace with " \
3919 "compatible optics for card to function.");
3923 sprintf(message,
"Unknown event status x%02x", status);
3928 "3176 Misconfigured Physical Port - "
3929 "Port Name %c %s\n", port_name, message);
3943 lpfc_sli4_perform_vport_cvl(
struct lpfc_vport *vport)
3978 shost = lpfc_shost_from_vport(vport);
3998 lpfc_sli4_perform_all_vport_cvl(
struct lpfc_hba *phba)
4006 lpfc_sli4_perform_vport_cvl(vports[i]);
4018 lpfc_sli4_async_fip_evt(
struct lpfc_hba *phba,
4026 int active_vlink_present;
4032 switch (event_type) {
4038 "2546 New FCF event, evt_tag:x%x, "
4045 "2788 FCF param modified event, "
4046 "evt_tag:x%x, index:x%x\n",
4057 "2779 Read FCF (x%x) for updating "
4058 "roundrobin FCF failover bmask\n",
4064 spin_lock_irq(&phba->
hbalock);
4066 spin_unlock_irq(&phba->
hbalock);
4071 spin_unlock_irq(&phba->
hbalock);
4077 spin_unlock_irq(&phba->
hbalock);
4080 spin_unlock_irq(&phba->
hbalock);
4084 "2770 Start FCF table scan per async FCF "
4085 "event, evt_tag:x%x, index:x%x\n",
4091 "2547 Issue FCF scan read FCF mailbox "
4092 "command failed (x%x)\n", rc);
4097 "2548 FCF Table full count 0x%x tag 0x%x\n",
4098 bf_get(lpfc_acqe_fip_fcf_count, acqe_fip),
4105 "2549 FCF (x%x) disconnected from network, "
4111 spin_lock_irq(&phba->
hbalock);
4113 spin_unlock_irq(&phba->
hbalock);
4118 spin_unlock_irq(&phba->
hbalock);
4121 if (phba->
fcf.current_rec.fcf_indx != acqe_fip->
index)
4130 spin_lock_irq(&phba->
hbalock);
4133 spin_unlock_irq(&phba->
hbalock);
4136 "2771 Start FCF fast failover process due to "
4137 "FCF DEAD event: evt_tag:x%x, fcf_index:x%x "
4143 "2772 Issue FCF rediscover mabilbox "
4144 "command failed, fail through to FCF "
4146 spin_lock_irq(&phba->
hbalock);
4148 spin_unlock_irq(&phba->
hbalock);
4161 lpfc_sli4_perform_all_vport_cvl(phba);
4167 "2718 Clear Virtual Link Received for VPI 0x%x"
4172 ndlp = lpfc_sli4_perform_vport_cvl(vport);
4175 active_vlink_present = 0;
4184 active_vlink_present = 1;
4191 if (active_vlink_present) {
4197 shost = lpfc_shost_from_vport(vport);
4211 spin_lock_irq(&phba->
hbalock);
4213 spin_unlock_irq(&phba->
hbalock);
4218 spin_unlock_irq(&phba->
hbalock);
4221 "2773 Start FCF failover per CVL, "
4227 "2774 Issue FCF rediscover "
4228 "mabilbox command failed, "
4229 "through to CVL event\n");
4230 spin_lock_irq(&phba->
hbalock);
4232 spin_unlock_irq(&phba->
hbalock);
4248 "0288 Unknown FCoE event type 0x%x event tag "
4249 "0x%x\n", event_type, acqe_fip->
event_tag);
4262 lpfc_sli4_async_dcbx_evt(
struct lpfc_hba *phba,
4267 "0290 The SLI4 DCBX asynchronous event is not "
4281 lpfc_sli4_async_grp5_evt(
struct lpfc_hba *phba,
4288 prev_ll_spd = phba->
sli4_hba.link_state.logical_speed;
4289 phba->
sli4_hba.link_state.logical_speed =
4290 (
bf_get(lpfc_acqe_grp5_llink_spd, acqe_grp5)) * 10;
4292 "2789 GRP5 Async Event: Updating logical link speed "
4293 "from %dMbps to %dMbps\n", prev_ll_spd,
4294 phba->
sli4_hba.link_state.logical_speed);
4309 spin_lock_irq(&phba->
hbalock);
4311 spin_unlock_irq(&phba->
hbalock);
4313 while (!list_empty(&phba->
sli4_hba.sp_asynce_work_queue)) {
4315 spin_lock_irq(&phba->
hbalock);
4318 spin_unlock_irq(&phba->
hbalock);
4322 lpfc_sli4_async_link_evt(phba,
4326 lpfc_sli4_async_fip_evt(phba, &cq_event->
cqe.
acqe_fip);
4329 lpfc_sli4_async_dcbx_evt(phba,
4333 lpfc_sli4_async_grp5_evt(phba,
4337 lpfc_sli4_async_fc_evt(phba, &cq_event->
cqe.
acqe_fc);
4340 lpfc_sli4_async_sli_evt(phba, &cq_event->
cqe.
acqe_sli);
4344 "1804 Invalid asynchrous event code: "
4345 "x%x\n",
bf_get(lpfc_trailer_code,
4365 spin_lock_irq(&phba->
hbalock);
4369 phba->
fcf.failover_rec.flag = 0;
4372 spin_unlock_irq(&phba->
hbalock);
4376 "2777 Start post-quiescent FCF table scan\n");
4380 "2747 Issue FCF scan read FCF mailbox "
4381 "command failed 0x%x\n", rc);
4436 switch (intr_mode) {
4439 "0470 Enable INTx interrupt mode.\n");
4443 "0481 Enabled MSI interrupt mode.\n");
4447 "0480 Enabled MSI-X interrupt mode.\n");
4451 "0482 Illegal interrupt mode.\n");
4469 lpfc_enable_pci_dev(
struct lpfc_hba *phba)
4486 goto out_disable_device;
4502 "1401 Failed to enable pci device, bars:x%x\n", bars);
4514 lpfc_disable_pci_dev(
struct lpfc_hba *phba)
4530 pci_set_drvdata(pdev,
NULL);
4603 if (nr_vfn > max_nr_vfn) {
4605 "3057 Requested vfs (%d) greater than "
4606 "supported vfs (%d)", nr_vfn, max_nr_vfn);
4613 "2806 Failed to enable sriov on this device "
4614 "with vfn number nr_vf:%d, rc:%d\n",
4618 "2807 Successful enable sriov on this device "
4619 "with vfn number nr_vf:%d\n", nr_vfn);
4635 lpfc_sli_driver_resource_setup(
struct lpfc_hba *phba)
4680 if (!phba->
sli.ring)
4684 if (!phba->
sli.ring)
4694 ((phba->cfg_sg_seg_cnt + 2) *
sizeof(
struct ulp_bde64));
4729 "2808 Requested number of SR-IOV "
4730 "virtual functions (%d) is not "
4748 lpfc_sli_driver_resource_unset(
struct lpfc_hba *phba)
4768 lpfc_sli4_driver_resource_setup(
struct lpfc_hba *phba)
4772 int rc,
i, hbq_count,
buf_size, dma_buf_size, max_buf_size;
4775 int longs, sli_family;
4776 int sges_per_segment;
4792 phba->
rrq_tmr.function = lpfc_rrq_timeout;
4811 phba->
fcf.redisc_wait.data = (
unsigned long)phba;
4845 sges_per_segment = 1;
4847 sges_per_segment = 2;
4853 if (!phba->
sli.ring)
4854 phba->
sli.ring = kzalloc(
4857 if (!phba->
sli.ring)
4867 (((phba->cfg_sg_seg_cnt * sges_per_segment) + 2) *
4870 sli_family =
bf_get(lpfc_sli_intf_sli_family, &phba->
sli4_hba.sli_intf);
4872 switch (sli_family) {
4887 dma_buf_size < max_buf_size && buf_size > dma_buf_size;
4888 dma_buf_size = dma_buf_size << 1)
4890 if (dma_buf_size == max_buf_size)
4899 for (i = 0; i < hbq_count; ++
i)
4900 INIT_LIST_HEAD(&phba->
hbqs[i].hbq_buffer_list);
4910 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_abts_scsi_buf_list);
4919 INIT_LIST_HEAD(&phba->
sli4_hba.sp_cqe_event_pool);
4921 INIT_LIST_HEAD(&phba->
sli4_hba.sp_queue_event);
4923 INIT_LIST_HEAD(&phba->
sli4_hba.sp_asynce_work_queue);
4925 INIT_LIST_HEAD(&phba->
sli4_hba.sp_fcp_xri_aborted_work_queue);
4927 INIT_LIST_HEAD(&phba->
sli4_hba.sp_els_xri_aborted_work_queue);
4929 INIT_LIST_HEAD(&phba->
sli4_hba.sp_unsol_work_queue);
4932 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_rpi_blk_list);
4933 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_xri_blk_list);
4934 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_vfi_blk_list);
4955 rc = lpfc_create_bootstrap_mbox(phba);
4960 rc = lpfc_setup_endian_order(phba);
4962 goto out_free_bsmbx;
4967 goto out_free_bsmbx;
4974 goto out_free_bsmbx;
4981 goto out_free_bsmbx;
4988 mqe = &mboxq->
u.
mqe;
4992 switch (pn_page[i]) {
4994 phba->
sli4_hba.pc_sli4_params.supported = 1;
5001 if (phba->
sli4_hba.pc_sli4_params.supported)
5006 goto out_free_bsmbx;
5016 if (phba->
sli4_hba.extents_in_use &&
5019 "2999 Unsupported SLI4 Parameters "
5020 "Extents and RPI headers enabled.\n");
5021 goto out_free_bsmbx;
5026 rc = lpfc_sli4_queue_verify(phba);
5028 goto out_free_bsmbx;
5031 rc = lpfc_sli4_cq_event_pool_create(phba);
5033 goto out_free_bsmbx;
5036 lpfc_init_sgl_list(phba);
5039 rc = lpfc_init_active_sgl_array(phba);
5042 "1430 Failed to initialize sgl list.\n");
5043 goto out_destroy_cq_event_pool;
5048 "1432 Failed to initialize rpi headers.\n");
5049 goto out_free_active_sgl;
5054 phba->
fcf.fcf_rr_bmask = kzalloc(longs *
sizeof(
unsigned long),
5056 if (!phba->
fcf.fcf_rr_bmask) {
5058 "2759 Failed allocate memory for FCF round "
5059 "robin failover bmask\n");
5061 goto out_remove_rpi_hdrs;
5069 "2572 Failed allocate memory for "
5070 "fast-path per-EQ handle array\n");
5072 goto out_free_fcf_rr_bmask;
5075 phba->
sli4_hba.msix_entries = kzalloc((
sizeof(
struct msix_entry) *
5077 if (!phba->
sli4_hba.msix_entries) {
5079 "2573 Failed allocate memory for msi-x "
5080 "interrupt vector entries\n");
5082 goto out_free_fcp_eq_hdl;
5094 "3020 Requested number of SR-IOV "
5095 "virtual functions (%d) is not "
5104 out_free_fcp_eq_hdl:
5106 out_free_fcf_rr_bmask:
5108 out_remove_rpi_hdrs:
5110 out_free_active_sgl:
5111 lpfc_free_active_sgl(phba);
5112 out_destroy_cq_event_pool:
5113 lpfc_sli4_cq_event_pool_destroy(phba);
5115 lpfc_destroy_bootstrap_mbox(phba);
5129 lpfc_sli4_driver_resource_unset(
struct lpfc_hba *phba)
5147 lpfc_free_active_sgl(phba);
5148 lpfc_free_els_sgl_list(phba);
5151 lpfc_sli4_cq_event_release_all(phba);
5152 lpfc_sli4_cq_event_pool_destroy(phba);
5158 lpfc_destroy_bootstrap_mbox(phba);
5166 list_del_init(&conn_entry->
list);
5202 "1431 Invalid HBA PCI-device group: 0x%x\n",
5222 lpfc_setup_driver_resource_phase1(
struct lpfc_hba *phba)
5248 INIT_LIST_HEAD(&phba->
elsbuf);
5268 lpfc_setup_driver_resource_phase2(
struct lpfc_hba *phba)
5274 "lpfc_worker_%d", phba->
brd_no);
5292 lpfc_unset_driver_resource_phase2(
struct lpfc_hba *phba)
5305 lpfc_free_iocb_list(
struct lpfc_hba *phba)
5309 spin_lock_irq(&phba->
hbalock);
5316 spin_unlock_irq(&phba->
hbalock);
5333 lpfc_init_iocb_list(
struct lpfc_hba *phba,
int iocb_count)
5341 for (i = 0; i < iocb_count; i++) {
5343 if (iocbq_entry ==
NULL) {
5345 "expected %d count. Unloading driver.\n",
5347 goto out_free_iocbq;
5354 "Unloading driver.\n", __func__);
5355 goto out_free_iocbq;
5360 spin_lock_irq(&phba->
hbalock);
5363 spin_unlock_irq(&phba->
hbalock);
5369 lpfc_free_iocb_list(phba);
5400 lpfc_free_els_sgl_list(
struct lpfc_hba *phba)
5405 spin_lock_irq(&phba->
hbalock);
5406 list_splice_init(&phba->
sli4_hba.lpfc_sgl_list, &sglq_list);
5407 spin_unlock_irq(&phba->
hbalock);
5421 lpfc_init_active_sgl_array(
struct lpfc_hba *phba)
5425 size *= phba->
sli4_hba.max_cfg_param.max_xri;
5427 phba->
sli4_hba.lpfc_sglq_active_list =
5429 if (!phba->
sli4_hba.lpfc_sglq_active_list)
5443 lpfc_free_active_sgl(
struct lpfc_hba *phba)
5457 lpfc_init_sgl_list(
struct lpfc_hba *phba)
5460 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_sgl_list);
5461 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_abts_els_sgl_list);
5490 INIT_LIST_HEAD(&phba->
sli4_hba.lpfc_rpi_hdr_list);
5491 if (!phba->
sli4_hba.rpi_hdrs_in_use)
5499 "0391 Error during rpi post operation\n");
5523 uint16_t rpi_limit, curr_rpi_range;
5533 if (!phba->
sli4_hba.rpi_hdrs_in_use)
5539 rpi_limit = phba->
sli4_hba.max_cfg_param.rpi_base +
5540 phba->
sli4_hba.max_cfg_param.max_rpi - 1;
5542 spin_lock_irq(&phba->
hbalock);
5548 curr_rpi_range = phba->
sli4_hba.next_rpi;
5549 spin_unlock_irq(&phba->
hbalock);
5557 rpi_count = rpi_limit - curr_rpi_range;
5575 if (!dmabuf->
virt) {
5577 goto err_free_dmabuf;
5583 goto err_free_coherent;
5589 goto err_free_coherent;
5594 spin_lock_irq(&phba->
hbalock);
5604 phba->
sli4_hba.next_rpi += rpi_count;
5605 spin_unlock_irq(&phba->
hbalock);
5630 if (!phba->
sli4_hba.rpi_hdrs_in_use)
5659 lpfc_hba_alloc(
struct pci_dev *pdev)
5666 dev_err(&pdev->
dev,
"failed to allocate hba struct\n");
5694 lpfc_hba_free(
struct lpfc_hba *phba)
5719 lpfc_create_shost(
struct lpfc_hba *phba)
5735 shost = lpfc_shost_from_vport(vport);
5736 phba->
pport = vport;
5739 pci_set_drvdata(phba->
pcidev, shost);
5752 lpfc_destroy_shost(
struct lpfc_hba *phba)
5779 "1478 Registering BlockGuard with the "
5799 "1475 Registering BlockGuard with the "
5800 "SCSI layer: mask %d guard %d\n",
5807 "1479 Not Registering BlockGuard with the SCSI "
5808 "layer, Bad protection parameters: %d %d\n",
5809 old_mask, old_guard);
5819 "9043 BLKGRD: allocated %d pages for "
5820 "_dump_buf_data at 0x%p\n",
5831 "9044 BLKGRD: ERROR unable to allocate "
5832 "memory for hexdump\n");
5835 "9045 BLKGRD: already allocated _dump_buf_data=0x%p"
5843 "9046 BLKGRD: allocated %d pages for "
5844 "_dump_buf_dif at 0x%p\n",
5855 "9047 BLKGRD: ERROR unable to allocate "
5856 "memory for hexdump\n");
5859 "9048 BLKGRD: already allocated _dump_buf_dif=0x%p\n",
5871 lpfc_post_init_setup(
struct lpfc_hba *phba)
5883 shost = pci_get_drvdata(phba->
pcidev);
5886 lpfc_setup_bg(phba, shost);
5897 "0428 Perform SCSI scan\n");
5902 sizeof(adapter_event),
5903 (
char *) &adapter_event,
5920 lpfc_sli_pci_mem_setup(
struct lpfc_hba *phba)
5923 unsigned long bar0map_len, bar2map_len;
5936 || pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(64)) != 0) {
5938 || pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32)) != 0) {
5956 "ioremap failed for SLIM memory.\n");
5964 "ioremap failed for HBA control registers.\n");
5965 goto out_iounmap_slim;
5993 for (i = 0; i < hbq_count; ++
i) {
5995 INIT_LIST_HEAD(&phba->
hbqs[i].hbq_buffer_list);
6033 lpfc_sli_pci_mem_unset(
struct lpfc_hba *phba)
6070 int i, port_error = 0;
6073 memset(&portsmphr_reg, 0,
sizeof(portsmphr_reg));
6074 memset(®_data, 0,
sizeof(reg_data));
6079 for (i = 0; i < 3000; i++) {
6080 if (lpfc_readl(phba->
sli4_hba.PSMPHRregaddr,
6081 &portsmphr_reg.
word0) ||
6082 (
bf_get(lpfc_port_smphr_perr, &portsmphr_reg))) {
6088 bf_get(lpfc_port_smphr_port_status, &portsmphr_reg))
6099 "1408 Port Failed POST - portsmphr=0x%x, "
6100 "perr=x%x, sfi=x%x, nip=x%x, ipc=x%x, scr1=x%x, "
6101 "scr2=x%x, hscratch=x%x, pstatus=x%x\n",
6102 portsmphr_reg.
word0,
6103 bf_get(lpfc_port_smphr_perr, &portsmphr_reg),
6104 bf_get(lpfc_port_smphr_sfi, &portsmphr_reg),
6105 bf_get(lpfc_port_smphr_nip, &portsmphr_reg),
6106 bf_get(lpfc_port_smphr_ipc, &portsmphr_reg),
6107 bf_get(lpfc_port_smphr_scr1, &portsmphr_reg),
6108 bf_get(lpfc_port_smphr_scr2, &portsmphr_reg),
6109 bf_get(lpfc_port_smphr_host_scratch, &portsmphr_reg),
6110 bf_get(lpfc_port_smphr_port_status, &portsmphr_reg));
6113 "2534 Device Info: SLIFamily=0x%x, "
6114 "SLIRev=0x%x, IFType=0x%x, SLIHint_1=0x%x, "
6115 "SLIHint_2=0x%x, FT=0x%x\n",
6116 bf_get(lpfc_sli_intf_sli_family,
6118 bf_get(lpfc_sli_intf_slirev,
6120 bf_get(lpfc_sli_intf_if_type,
6122 bf_get(lpfc_sli_intf_sli_hint1,
6124 bf_get(lpfc_sli_intf_sli_hint2,
6126 bf_get(lpfc_sli_intf_func_type,
6133 if_type =
bf_get(lpfc_sli_intf_if_type,
6148 "1422 Unrecoverable Error "
6149 "Detected during POST "
6150 "uerr_lo_reg=0x%x, "
6151 "uerr_hi_reg=0x%x, "
6152 "ue_mask_lo_reg=0x%x, "
6153 "ue_mask_hi_reg=0x%x\n",
6163 if (lpfc_readl(phba->
sli4_hba.u.if_type2.STATUSregaddr,
6165 (
bf_get(lpfc_sliport_status_err, ®_data) &&
6166 !
bf_get(lpfc_sliport_status_rn, ®_data))) {
6174 "2888 Unrecoverable port error "
6175 "following POST: port status reg "
6176 "0x%x, port_smphr reg 0x%x, "
6177 "error 1=0x%x, error 2=0x%x\n",
6179 portsmphr_reg.
word0,
6206 phba->
sli4_hba.u.if_type0.UERRLOregaddr =
6208 phba->
sli4_hba.u.if_type0.UERRHIregaddr =
6210 phba->
sli4_hba.u.if_type0.UEMASKLOregaddr =
6212 phba->
sli4_hba.u.if_type0.UEMASKHIregaddr =
6218 phba->
sli4_hba.u.if_type2.ERR1regaddr =
6219 phba->
sli4_hba.conf_regs_memmap_p +
6221 phba->
sli4_hba.u.if_type2.ERR2regaddr =
6222 phba->
sli4_hba.conf_regs_memmap_p +
6224 phba->
sli4_hba.u.if_type2.CTRLregaddr =
6225 phba->
sli4_hba.conf_regs_memmap_p +
6227 phba->
sli4_hba.u.if_type2.STATUSregaddr =
6228 phba->
sli4_hba.conf_regs_memmap_p +
6233 phba->
sli4_hba.conf_regs_memmap_p +
6249 "FATAL - unsupported SLI4 interface type - %d\n",
6263 lpfc_sli4_bar1_register_memmap(
struct lpfc_hba *phba)
6320 lpfc_create_bootstrap_mbox(
struct lpfc_hba *phba)
6341 if (!dmabuf->
virt) {
6354 phba->
sli4_hba.bmbx.dmabuf = dmabuf;
6355 phba->
sli4_hba.bmbx.bmbx_size = bmbx_size;
6370 dma_address = &phba->
sli4_hba.bmbx.dma_address;
6372 pa_addr = (
uint32_t) ((phys_addr >> 34) & 0x3fffffff);
6394 lpfc_destroy_bootstrap_mbox(
struct lpfc_hba *phba)
6425 uint32_t shdr_status, shdr_add_status;
6435 "2011 Unable to allocate memory for issuing "
6436 "SLI_CONFIG_SPECIAL mailbox command\n");
6445 "2012 Mailbox failed , mbxCmd x%x "
6446 "READ_CONFIG, mbxStatus x%x\n",
6451 rd_config = &pmb->
u.
mqe.un.rd_config;
6452 if (
bf_get(lpfc_mbx_rd_conf_lnk_ldv, rd_config)) {
6455 bf_get(lpfc_mbx_rd_conf_lnk_type, rd_config);
6457 bf_get(lpfc_mbx_rd_conf_lnk_numb, rd_config);
6459 "3081 lnk_type:%d, lnk_numb:%d\n",
6464 "3082 Mailbox (x%x) returned ldv:x0\n",
6467 bf_get(lpfc_mbx_rd_conf_extnts_inuse, rd_config);
6468 phba->
sli4_hba.max_cfg_param.max_xri =
6469 bf_get(lpfc_mbx_rd_conf_xri_count, rd_config);
6470 phba->
sli4_hba.max_cfg_param.xri_base =
6471 bf_get(lpfc_mbx_rd_conf_xri_base, rd_config);
6472 phba->
sli4_hba.max_cfg_param.max_vpi =
6473 bf_get(lpfc_mbx_rd_conf_vpi_count, rd_config);
6474 phba->
sli4_hba.max_cfg_param.vpi_base =
6475 bf_get(lpfc_mbx_rd_conf_vpi_base, rd_config);
6476 phba->
sli4_hba.max_cfg_param.max_rpi =
6477 bf_get(lpfc_mbx_rd_conf_rpi_count, rd_config);
6478 phba->
sli4_hba.max_cfg_param.rpi_base =
6479 bf_get(lpfc_mbx_rd_conf_rpi_base, rd_config);
6480 phba->
sli4_hba.max_cfg_param.max_vfi =
6481 bf_get(lpfc_mbx_rd_conf_vfi_count, rd_config);
6482 phba->
sli4_hba.max_cfg_param.vfi_base =
6483 bf_get(lpfc_mbx_rd_conf_vfi_base, rd_config);
6484 phba->
sli4_hba.max_cfg_param.max_fcfi =
6485 bf_get(lpfc_mbx_rd_conf_fcfi_count, rd_config);
6486 phba->
sli4_hba.max_cfg_param.max_eq =
6487 bf_get(lpfc_mbx_rd_conf_eq_count, rd_config);
6488 phba->
sli4_hba.max_cfg_param.max_rq =
6489 bf_get(lpfc_mbx_rd_conf_rq_count, rd_config);
6490 phba->
sli4_hba.max_cfg_param.max_wq =
6491 bf_get(lpfc_mbx_rd_conf_wq_count, rd_config);
6492 phba->
sli4_hba.max_cfg_param.max_cq =
6493 bf_get(lpfc_mbx_rd_conf_cq_count, rd_config);
6494 phba->
lmt =
bf_get(lpfc_mbx_rd_conf_lmt, rd_config);
6499 (phba->
sli4_hba.max_cfg_param.max_vpi - 1) : 0;
6502 "2003 cfg params Extents? %d "
6509 phba->
sli4_hba.max_cfg_param.xri_base,
6510 phba->
sli4_hba.max_cfg_param.max_xri,
6511 phba->
sli4_hba.max_cfg_param.vpi_base,
6512 phba->
sli4_hba.max_cfg_param.max_vpi,
6513 phba->
sli4_hba.max_cfg_param.vfi_base,
6514 phba->
sli4_hba.max_cfg_param.max_vfi,
6515 phba->
sli4_hba.max_cfg_param.rpi_base,
6516 phba->
sli4_hba.max_cfg_param.max_rpi,
6517 phba->
sli4_hba.max_cfg_param.max_fcfi);
6525 (phba->
sli4_hba.max_cfg_param.max_xri -
6528 phba->
sli4_hba.max_cfg_param.max_xri -
6537 sizeof(struct lpfc_sli4_cfg_mhdr));
6544 &pmb->
u.
mqe.un.sli4_config.header.cfg_shdr;
6546 shdr_add_status =
bf_get(lpfc_mbox_hdr_add_status, &shdr->
response);
6547 if (rc2 || shdr_status || shdr_add_status) {
6549 "3026 Mailbox failed , mbxCmd x%x "
6550 "GET_FUNCTION_CONFIG, mbxStatus x%x\n",
6557 get_func_cfg = &pmb->
u.
mqe.un.get_func_cfg;
6558 desc_count = get_func_cfg->
func_cfg.rsrc_desc_count;
6560 pdesc_0 = (
char *)&get_func_cfg->
func_cfg.desc[0];
6562 length =
bf_get(lpfc_rsrc_desc_fcfcoe_length, desc);
6571 bf_get(lpfc_rsrc_desc_fcfcoe_type, desc)) {
6573 bf_get(lpfc_rsrc_desc_fcfcoe_pfnum, desc);
6575 bf_get(lpfc_rsrc_desc_fcfcoe_vfnum, desc);
6580 if (i < LPFC_RSRC_DESC_MAX_NUM)
6582 "3027 GET_FUNCTION_CONFIG: pf_number:%d, "
6583 "vf_number:%d\n", phba->
sli4_hba.iov.pf_number,
6587 "3028 GET_FUNCTION_CONFIG: failed to find "
6588 "Resrouce Descriptor:x%x\n",
6610 lpfc_setup_endian_order(
struct lpfc_hba *phba)
6617 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
6624 "0492 Unable to allocate memory for "
6625 "issuing SLI_CONFIG_SPECIAL mailbox "
6635 memcpy(&mboxq->
u.
mqe, &endian_mb_data,
sizeof(endian_mb_data));
6639 "0493 SLI_CONFIG_SPECIAL mailbox "
6640 "failed with status x%x\n",
6668 lpfc_sli4_queue_verify(
struct lpfc_hba *phba)
6670 int cfg_fcp_io_channel;
6687 if (i < cfg_fcp_io_channel) {
6690 "3188 Reducing IO channels to match number of "
6691 "CPUs: from %d to %d\n", cfg_fcp_io_channel, i);
6692 cfg_fcp_io_channel =
i;
6695 if (cfg_fcp_io_channel >
6696 phba->
sli4_hba.max_cfg_param.max_eq) {
6697 if (phba->
sli4_hba.max_cfg_param.max_eq <
6700 "2574 Not enough EQs (%d) from the "
6701 "pci function for supporting FCP "
6703 phba->
sli4_hba.max_cfg_param.max_eq,
6708 "2575 Reducing IO channels to match number of "
6709 "available EQs: from %d to %d\n",
6711 phba->
sli4_hba.max_cfg_param.max_eq);
6712 cfg_fcp_io_channel = phba->
sli4_hba.max_cfg_param.max_eq;
6772 "2576 Failed allocate memory for "
6773 "fast-path EQ record array\n");
6781 "2577 Failed allocate memory for fast-path "
6782 "CQ record array\n");
6790 "2578 Failed allocate memory for fast-path "
6791 "WQ record array\n");
6804 "2545 Failed allocate memory for fast-path "
6820 "0497 Failed allocate EQ (%d)\n", idx);
6830 "0499 Failed allocate fast-path FCP "
6841 "0503 Failed allocate fast-path FCP "
6858 "0500 Failed allocate slow-path mailbox CQ\n");
6868 "0501 Failed allocate slow-path ELS CQ\n");
6884 "0505 Failed allocate slow-path MQ\n");
6898 "0504 Failed allocate slow-path ELS WQ\n");
6912 "0506 Failed allocate receive HRQ\n");
6922 "0507 Failed allocate receive DRQ\n");
7051 int fcp_eqidx, fcp_cqidx, fcp_wqidx;
7052 int fcp_cq_index = 0;
7061 "3147 Fast-path EQs not allocated\n");
7066 if (!phba->
sli4_hba.hba_eq[fcp_eqidx]) {
7068 "0522 Fast-path EQ (%d) not "
7069 "allocated\n", fcp_eqidx);
7071 goto out_destroy_hba_eq;
7077 "0523 Failed setup of fast-path EQ "
7078 "(%d), rc = 0x%x\n", fcp_eqidx, rc);
7079 goto out_destroy_hba_eq;
7082 "2584 HBA EQ setup: "
7083 "queue[%d]-id=%d\n", fcp_eqidx,
7084 phba->
sli4_hba.hba_eq[fcp_eqidx]->queue_id);
7090 "3148 Fast-path FCP CQ array not "
7093 goto out_destroy_hba_eq;
7097 if (!phba->
sli4_hba.fcp_cq[fcp_cqidx]) {
7099 "0526 Fast-path FCP CQ (%d) not "
7100 "allocated\n", fcp_cqidx);
7102 goto out_destroy_fcp_cq;
7108 "0527 Failed setup of fast-path FCP "
7109 "CQ (%d), rc = 0x%x\n", fcp_cqidx, rc);
7110 goto out_destroy_fcp_cq;
7114 phba->
sli4_hba.fcp_cq_map[fcp_cqidx] =
7115 phba->
sli4_hba.fcp_cq[fcp_cqidx]->queue_id;
7118 "2588 FCP CQ setup: cq[%d]-id=%d, "
7119 "parent seq[%d]-id=%d\n",
7121 phba->
sli4_hba.fcp_cq[fcp_cqidx]->queue_id,
7123 phba->
sli4_hba.hba_eq[fcp_cqidx]->queue_id);
7129 "3149 Fast-path FCP WQ array not "
7132 goto out_destroy_fcp_cq;
7136 if (!phba->
sli4_hba.fcp_wq[fcp_wqidx]) {
7138 "0534 Fast-path FCP WQ (%d) not "
7139 "allocated\n", fcp_wqidx);
7141 goto out_destroy_fcp_wq;
7148 "0535 Failed setup of fast-path FCP "
7149 "WQ (%d), rc = 0x%x\n", fcp_wqidx, rc);
7150 goto out_destroy_fcp_wq;
7156 phba->
sli4_hba.fcp_cq[fcp_wqidx]->pring = pring;
7159 "2591 FCP WQ setup: wq[%d]-id=%d, "
7160 "parent cq[%d]-id=%d\n",
7162 phba->
sli4_hba.fcp_wq[fcp_wqidx]->queue_id,
7164 phba->
sli4_hba.fcp_cq[fcp_wqidx]->queue_id);
7173 "0528 Mailbox CQ not allocated\n");
7175 goto out_destroy_fcp_wq;
7181 "0529 Failed setup of slow-path mailbox CQ: "
7183 goto out_destroy_fcp_wq;
7186 "2585 MBX CQ setup: cq-id=%d, parent eq-id=%d\n",
7188 phba->
sli4_hba.hba_eq[0]->queue_id);
7193 "0530 ELS CQ not allocated\n");
7195 goto out_destroy_mbx_cq;
7201 "0531 Failed setup of slow-path ELS CQ: "
7203 goto out_destroy_mbx_cq;
7206 "2586 ELS CQ setup: cq-id=%d, parent eq-id=%d\n",
7208 phba->
sli4_hba.hba_eq[0]->queue_id);
7217 "0538 Slow-path MQ not allocated\n");
7219 goto out_destroy_els_cq;
7225 "0539 Failed setup of slow-path MQ: "
7227 goto out_destroy_els_cq;
7230 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n",
7237 "0536 Slow-path ELS WQ not allocated\n");
7239 goto out_destroy_mbx_wq;
7245 "0537 Failed setup of slow-path ELS WQ: "
7247 goto out_destroy_mbx_wq;
7253 phba->
sli4_hba.els_cq->pring = pring;
7256 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n",
7265 "0540 Receive Queue not allocated\n");
7267 goto out_destroy_els_wq;
7277 "0541 Failed setup of Receive Queue: "
7279 goto out_destroy_fcp_wq;
7283 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d "
7284 "parent cq-id=%d\n",
7299 for (--fcp_wqidx; fcp_wqidx >= 0; fcp_wqidx--)
7302 for (--fcp_cqidx; fcp_cqidx >= 0; fcp_cqidx--)
7305 for (--fcp_eqidx; fcp_eqidx >= 0; fcp_eqidx--)
7375 lpfc_sli4_cq_event_pool_create(
struct lpfc_hba *phba)
7380 for (i = 0; i < (4 * phba->
sli4_hba.cq_ecount); i++) {
7383 goto out_pool_create_fail;
7385 &phba->
sli4_hba.sp_cqe_event_pool);
7389 out_pool_create_fail:
7390 lpfc_sli4_cq_event_pool_destroy(phba);
7405 lpfc_sli4_cq_event_pool_destroy(
struct lpfc_hba *phba)
7450 unsigned long iflags;
7454 spin_unlock_irqrestore(&phba->
hbalock, iflags);
7485 unsigned long iflags;
7488 spin_unlock_irqrestore(&phba->
hbalock, iflags);
7499 lpfc_sli4_cq_event_release_all(
struct lpfc_hba *phba)
7503 unsigned long iflags;
7508 list_splice_init(&phba->
sli4_hba.sp_fcp_xri_aborted_work_queue,
7511 list_splice_init(&phba->
sli4_hba.sp_els_xri_aborted_work_queue,
7514 list_splice_init(&phba->
sli4_hba.sp_asynce_work_queue,
7516 spin_unlock_irqrestore(&phba->
hbalock, iflags);
7518 while (!list_empty(&cqelist)) {
7541 uint32_t shdr_status, shdr_add_status;
7542 uint32_t rdy_chk, num_resets = 0, reset_again = 0;
7547 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
7554 "0494 Unable to allocate memory for "
7555 "issuing SLI_FUNCTION_RESET mailbox "
7566 &mboxq->
u.
mqe.un.sli4_config.header.cfg_shdr;
7568 shdr_add_status =
bf_get(lpfc_mbox_hdr_add_status,
7572 if (shdr_status || shdr_add_status || rc) {
7574 "0495 SLI_FUNCTION_RESET mailbox "
7575 "failed with status x%x add_status x%x,"
7576 " mbx status x%x\n",
7577 shdr_status, shdr_add_status, rc);
7582 for (num_resets = 0;
7586 bf_set(lpfc_sliport_ctrl_end, ®_data,
7588 bf_set(lpfc_sliport_ctrl_ip, ®_data,
7593 pci_read_config_word(phba->
pcidev,
7601 for (rdy_chk = 0; rdy_chk < 1000; rdy_chk++) {
7603 if (lpfc_readl(phba->
sli4_hba.u.if_type2.
7604 STATUSregaddr, ®_data.
word0)) {
7608 if (
bf_get(lpfc_sliport_status_rn, ®_data))
7610 if (
bf_get(lpfc_sliport_status_rdy, ®_data))
7618 if (reset_again && (rdy_chk < 1000)) {
7625 if ((
bf_get(lpfc_sliport_status_err, ®_data)) ||
7626 (rdy_chk >= 1000)) {
7628 phba->
sli4_hba.u.if_type2.ERR1regaddr);
7630 phba->
sli4_hba.u.if_type2.ERR2regaddr);
7632 "2890 Port error detected during port "
7633 "reset(%d): wait_tmo:%d ms, "
7634 "port status reg 0x%x, "
7635 "error 1=0x%x, error 2=0x%x\n",
7636 num_resets, rdy_chk*10,
7683 uint32_t shdr_status, shdr_add_status;
7688 "2518 Requested to send 0 NOP mailbox cmd\n");
7695 "2519 Unable to allocate memory for issuing "
7696 "NOP mailbox command\n");
7704 for (cmdsent = 0; cmdsent <
cnt; cmdsent++) {
7718 &mboxq->
u.
mqe.un.sli4_config.header.cfg_shdr;
7720 shdr_add_status =
bf_get(lpfc_mbox_hdr_add_status,
7722 if (shdr_status || shdr_add_status || rc) {
7724 "2520 NOP mailbox command failed "
7725 "status x%x add_status x%x mbx "
7726 "status x%x\n", shdr_status,
7727 shdr_add_status, rc);
7750 lpfc_sli4_pci_mem_setup(
struct lpfc_hba *phba)
7753 unsigned long bar0map_len, bar1map_len, bar2map_len;
7765 || pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(64)) != 0) {
7767 || pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32)) != 0) {
7785 "2894 SLI_INTF reg contents invalid "
7786 "sli_intf reg 0x%x\n",
7791 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
7806 phba->
sli4_hba.conf_regs_memmap_p =
7808 if (!phba->
sli4_hba.conf_regs_memmap_p) {
7810 "ioremap failed for SLI4 PCI config "
7815 lpfc_sli4_bar0_register_memmap(phba, if_type);
7821 "FATAL - No BAR0 mapping for SLI4, if_type 2\n");
7824 phba->
sli4_hba.conf_regs_memmap_p =
7826 if (!phba->
sli4_hba.conf_regs_memmap_p) {
7828 "ioremap failed for SLI4 PCI config "
7832 lpfc_sli4_bar0_register_memmap(phba, if_type);
7843 phba->
sli4_hba.ctrl_regs_memmap_p =
7845 if (!phba->
sli4_hba.ctrl_regs_memmap_p) {
7847 "ioremap failed for SLI4 HBA control registers.\n");
7848 goto out_iounmap_conf;
7850 lpfc_sli4_bar1_register_memmap(phba);
7861 phba->
sli4_hba.drbl_regs_memmap_p =
7863 if (!phba->
sli4_hba.drbl_regs_memmap_p) {
7865 "ioremap failed for SLI4 HBA doorbell registers.\n");
7866 goto out_iounmap_ctrl;
7868 error = lpfc_sli4_bar2_register_memmap(phba,
LPFC_VF0);
7870 goto out_iounmap_all;
7893 lpfc_sli4_pci_mem_unset(
struct lpfc_hba *phba)
7896 if_type =
bf_get(lpfc_sli_intf_if_type, &phba->
sli4_hba.sli_intf);
7910 "FATAL - unsupported SLI4 interface type - %d\n",
7937 lpfc_sli_enable_msix(
struct lpfc_hba *phba)
7951 "0420 PCI enable MSI-X failed (%d)\n", rc);
7956 "0477 MSI-X entry[%d]: vector=x%x "
7970 "0421 MSI-X slow-path request_irq failed "
7982 "0429 MSI-X fast-path request_irq failed "
7995 "0474 Unable to allocate memory for issuing "
7996 "MBOX_CONFIG_MSI command\n");
8005 "0351 Config MSI mailbox command failed, "
8006 "mbxCmd x%x, mbxStatus x%x\n",
8041 lpfc_sli_disable_msix(
struct lpfc_hba *phba)
8069 lpfc_sli_enable_msi(
struct lpfc_hba *phba)
8073 rc = pci_enable_msi(phba->
pcidev);
8076 "0462 PCI enable MSI mode success.\n");
8079 "0471 PCI enable MSI mode failed (%d)\n", rc);
8088 "0478 MSI request_irq failed (%d)\n", rc);
8104 lpfc_sli_disable_msi(
struct lpfc_hba *phba)
8133 if (cfg_mode == 2) {
8138 retval = lpfc_sli_enable_msix(phba);
8149 retval = lpfc_sli_enable_msi(phba);
8180 lpfc_sli_disable_intr(
struct lpfc_hba *phba)
8184 lpfc_sli_disable_msix(phba);
8186 lpfc_sli_disable_msi(phba);
8192 phba->
sli.slistat.sli_intr = 0;
8218 lpfc_sli4_enable_msix(
struct lpfc_hba *phba)
8224 phba->
sli4_hba.msix_entries[index].entry = index;
8228 enable_msix_vectors:
8233 goto enable_msix_vectors;
8236 "0484 PCI enable MSI-X failed (%d)\n", rc);
8241 for (index = 0; index <
vectors; index++)
8243 "0489 MSI-X entry[%d]: vector=x%x "
8244 "message=%d\n", index,
8245 phba->
sli4_hba.msix_entries[index].vector,
8246 phba->
sli4_hba.msix_entries[index].entry);
8251 for (index = 0; index <
vectors; index++) {
8261 (
char *)&phba->
sli4_hba.handler_name[index],
8262 &phba->
sli4_hba.fcp_eq_hdl[index]);
8265 "0486 MSI-X fast-path (%d) "
8266 "request_irq failed (%d)\n", index, rc);
8273 "3238 Reducing IO channels to match number of "
8274 "MSI-X vectors, requested %d got %d\n",
8282 for (--index; index >= 0; index--)
8284 &phba->
sli4_hba.fcp_eq_hdl[index]);
8300 lpfc_sli4_disable_msix(
struct lpfc_hba *phba)
8307 &phba->
sli4_hba.fcp_eq_hdl[index]);
8330 lpfc_sli4_enable_msi(
struct lpfc_hba *phba)
8334 rc = pci_enable_msi(phba->
pcidev);
8337 "0487 PCI enable MSI mode success.\n");
8340 "0488 PCI enable MSI mode failed (%d)\n", rc);
8349 "0490 MSI request_irq failed (%d)\n", rc);
8372 lpfc_sli4_disable_msi(
struct lpfc_hba *phba)
8401 if (cfg_mode == 2) {
8406 retval = lpfc_sli4_enable_msix(phba);
8417 retval = lpfc_sli4_enable_msi(phba);
8455 lpfc_sli4_disable_intr(
struct lpfc_hba *phba)
8459 lpfc_sli4_disable_msix(phba);
8461 lpfc_sli4_disable_msi(phba);
8467 phba->
sli.slistat.sli_intr = 0;
8480 lpfc_unset_hba(
struct lpfc_hba *phba)
8483 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8494 phba->
pport->work_port_events = 0;
8500 lpfc_sli_disable_intr(phba);
8513 lpfc_sli4_unset_hba(
struct lpfc_hba *phba)
8516 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
8522 phba->
pport->work_port_events = 0;
8527 lpfc_sli4_disable_intr(phba);
8550 lpfc_sli4_xri_exchange_busy_wait(
struct lpfc_hba *phba)
8553 int fcp_xri_cmpl = list_empty(&phba->
sli4_hba.lpfc_abts_scsi_buf_list);
8554 int els_xri_cmpl = list_empty(&phba->
sli4_hba.lpfc_abts_els_sgl_list);
8556 while (!fcp_xri_cmpl || !els_xri_cmpl) {
8560 "2877 FCP XRI exchange busy "
8561 "wait time: %d seconds.\n",
8565 "2878 ELS XRI exchange busy "
8566 "wait time: %d seconds.\n",
8575 list_empty(&phba->
sli4_hba.lpfc_abts_scsi_buf_list);
8577 list_empty(&phba->
sli4_hba.lpfc_abts_els_sgl_list);
8592 lpfc_sli4_hba_unset(
struct lpfc_hba *phba)
8607 spin_lock_irq(&phba->
hbalock);
8609 spin_unlock_irq(&phba->
hbalock);
8618 spin_lock_irq(&phba->
hbalock);
8619 mboxq = phba->
sli.mbox_active;
8624 spin_unlock_irq(&phba->
hbalock);
8631 lpfc_sli4_xri_exchange_busy_wait(phba);
8634 lpfc_sli4_disable_intr(phba);
8648 phba->
pport->work_port_events = 0;
8672 mqe = &mboxq->
u.
mqe;
8686 sli4_params = &phba->
sli4_hba.pc_sli4_params;
8750 phba->
sli4_hba.rpi_hdrs_in_use = 1;
8754 sizeof(struct lpfc_sli4_cfg_mhdr));
8766 sli4_params = &phba->
sli4_hba.pc_sli4_params;
8768 sli4_params->
if_type =
bf_get(cfg_if_type, mbx_sli4_parameters);
8769 sli4_params->
sli_rev =
bf_get(cfg_sli_rev, mbx_sli4_parameters);
8772 mbx_sli4_parameters);
8774 mbx_sli4_parameters);
8775 if (
bf_get(cfg_phwq, mbx_sli4_parameters))
8781 sli4_params->
cqv =
bf_get(cfg_cqv, mbx_sli4_parameters);
8782 sli4_params->
mqv =
bf_get(cfg_mqv, mbx_sli4_parameters);
8783 sli4_params->
wqv =
bf_get(cfg_wqv, mbx_sli4_parameters);
8784 sli4_params->
rqv =
bf_get(cfg_rqv, mbx_sli4_parameters);
8786 mbx_sli4_parameters);
8788 mbx_sli4_parameters);
8789 phba->
sli4_hba.extents_in_use =
bf_get(cfg_ext, mbx_sli4_parameters);
8790 phba->
sli4_hba.rpi_hdrs_in_use =
bf_get(cfg_hdrr, mbx_sli4_parameters);
8826 phba = lpfc_hba_alloc(pdev);
8831 error = lpfc_enable_pci_dev(phba);
8838 goto out_disable_pci_dev;
8841 error = lpfc_sli_pci_mem_setup(phba);
8844 "1402 Failed to set up pci memory space.\n");
8845 goto out_disable_pci_dev;
8849 error = lpfc_setup_driver_resource_phase1(phba);
8852 "1403 Failed to set up driver resource.\n");
8853 goto out_unset_pci_mem_s3;
8857 error = lpfc_sli_driver_resource_setup(phba);
8860 "1404 Failed to set up driver resource.\n");
8861 goto out_unset_pci_mem_s3;
8868 "1405 Failed to initialize iocb list.\n");
8869 goto out_unset_driver_resource_s3;
8873 error = lpfc_setup_driver_resource_phase2(phba);
8876 "1406 Failed to set up driver resource.\n");
8877 goto out_free_iocb_list;
8884 error = lpfc_create_shost(phba);
8887 "1407 Failed to create scsi host.\n");
8888 goto out_unset_driver_resource;
8892 vport = phba->
pport;
8896 "1476 Failed to allocate sysfs attr\n");
8897 goto out_destroy_shost;
8900 shost = lpfc_shost_from_vport(vport);
8907 intr_mode = lpfc_sli_enable_intr(phba, cfg_mode);
8910 "0431 Failed to enable interrupt.\n");
8912 goto out_free_sysfs_attr;
8917 "1477 Failed to set up hba\n");
8919 goto out_remove_device;
8925 if (intr_mode == 0 ||
8926 phba->
sli.slistat.sli_intr > LPFC_MSIX_VECTORS) {
8929 lpfc_log_intr_mode(phba, intr_mode);
8933 "0447 Configure interrupt mode (%d) "
8934 "failed active interrupt test.\n",
8937 lpfc_sli_disable_intr(phba);
8939 cfg_mode = --intr_mode;
8944 lpfc_post_init_setup(phba);
8952 lpfc_unset_hba(phba);
8953 out_free_sysfs_attr:
8956 lpfc_destroy_shost(phba);
8957 out_unset_driver_resource:
8958 lpfc_unset_driver_resource_phase2(phba);
8960 lpfc_free_iocb_list(phba);
8961 out_unset_driver_resource_s3:
8962 lpfc_sli_driver_resource_unset(phba);
8963 out_unset_pci_mem_s3:
8964 lpfc_sli_pci_mem_unset(phba);
8965 out_disable_pci_dev:
8966 lpfc_disable_pci_dev(phba);
8970 lpfc_hba_free(phba);
8984 lpfc_pci_remove_one_s3(
struct pci_dev *pdev)
8986 struct Scsi_Host *shost = pci_get_drvdata(pdev);
8993 spin_lock_irq(&phba->
hbalock);
8995 spin_unlock_irq(&phba->
hbalock);
9031 spin_lock_irq(&phba->
hbalock);
9033 spin_unlock_irq(&phba->
hbalock);
9042 lpfc_sli_disable_intr(phba);
9044 pci_set_drvdata(pdev,
NULL);
9051 lpfc_scsi_free(phba);
9065 lpfc_hba_free(phba);
9095 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9099 "0473 PCI device Power Management suspend.\n");
9107 lpfc_sli_disable_intr(phba);
9136 lpfc_pci_resume_one_s3(
struct pci_dev *pdev)
9138 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9144 "0452 PCI device Power Management resume.\n");
9161 "lpfc_worker_%d", phba->
brd_no);
9165 "0434 PM resume failed to start worker "
9166 "thread: error=x%x.\n", error);
9171 intr_mode = lpfc_sli_enable_intr(phba, phba->
intr_mode);
9174 "0430 PM resume Failed to enable interrupt\n");
9184 lpfc_log_intr_mode(phba, phba->
intr_mode);
9197 lpfc_sli_prep_dev_for_recover(
struct lpfc_hba *phba)
9203 "2723 PCI channel I/O abort preparing for recovery\n");
9222 lpfc_sli_prep_dev_for_reset(
struct lpfc_hba *phba)
9225 "2710 PCI channel disable preparing for reset\n");
9237 lpfc_sli_disable_intr(phba);
9253 lpfc_sli_prep_dev_for_perm_failure(
struct lpfc_hba *phba)
9256 "2711 PCI channel permanent disable for failure\n");
9288 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9294 lpfc_sli_prep_dev_for_recover(phba);
9298 lpfc_sli_prep_dev_for_reset(phba);
9302 lpfc_sli_prep_dev_for_perm_failure(phba);
9307 "0472 Unknown PCI error state: x%x\n", state);
9308 lpfc_sli_prep_dev_for_reset(phba);
9332 lpfc_io_slot_reset_s3(
struct pci_dev *pdev)
9334 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9339 dev_printk(
KERN_INFO, &pdev->
dev,
"recovering from a slot reset.\n");
9342 "PCI device after reset.\n");
9357 spin_lock_irq(&phba->
hbalock);
9359 spin_unlock_irq(&phba->
hbalock);
9362 intr_mode = lpfc_sli_enable_intr(phba, phba->
intr_mode);
9365 "0427 Cannot re-enable interrupt after "
9377 lpfc_log_intr_mode(phba, phba->
intr_mode);
9393 lpfc_io_resume_s3(
struct pci_dev *pdev)
9395 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9415 int max_xri = phba->
sli4_hba.max_cfg_param.max_xri;
9420 else if (max_xri <= 256)
9422 else if (max_xri <= 512)
9424 else if (max_xri <= 1024)
9426 else if (max_xri <= 1536)
9428 else if (max_xri <= 2048)
9460 INIT_LIST_HEAD(&dma_buffer_list);
9467 "3022 Invalid FW image found. "
9468 "Magic:%x Type:%x ID:%x\n",
9478 "3023 Updating Firmware, Current Version:%s "
9492 if (!dmabuf->
virt) {
9504 fw->
data + temp_offset,
9505 fw->
size - temp_offset);
9506 temp_offset = fw->
size;
9514 (fw->
size - offset), &offset);
9531 "3024 Firmware update done: %d.", rc);
9562 int adjusted_fcp_io_channel;
9566 phba = lpfc_hba_alloc(pdev);
9571 error = lpfc_enable_pci_dev(phba);
9578 goto out_disable_pci_dev;
9581 error = lpfc_sli4_pci_mem_setup(phba);
9584 "1410 Failed to set up pci memory space.\n");
9585 goto out_disable_pci_dev;
9589 error = lpfc_setup_driver_resource_phase1(phba);
9592 "1411 Failed to set up driver resource.\n");
9593 goto out_unset_pci_mem_s4;
9597 error = lpfc_sli4_driver_resource_setup(phba);
9600 "1412 Failed to set up driver resource.\n");
9601 goto out_unset_pci_mem_s4;
9607 "2821 initialize iocb list %d.\n",
9609 error = lpfc_init_iocb_list(phba, phba->
cfg_iocb_cnt*1024);
9613 "1413 Failed to initialize iocb list.\n");
9614 goto out_unset_driver_resource_s4;
9618 INIT_LIST_HEAD(&phba->
fcf.fcf_pri_list);
9621 error = lpfc_setup_driver_resource_phase2(phba);
9624 "1414 Failed to set up driver resource.\n");
9625 goto out_free_iocb_list;
9632 error = lpfc_create_shost(phba);
9635 "1415 Failed to create scsi host.\n");
9636 goto out_unset_driver_resource;
9640 vport = phba->
pport;
9644 "1416 Failed to allocate sysfs attr\n");
9645 goto out_destroy_shost;
9648 shost = lpfc_shost_from_vport(vport);
9655 intr_mode = lpfc_sli4_enable_intr(phba, cfg_mode);
9658 "0426 Failed to enable interrupt.\n");
9660 goto out_free_sysfs_attr;
9664 adjusted_fcp_io_channel = 1;
9671 "1421 Failed to set up hba\n");
9673 goto out_disable_intr;
9678 mcnt = lpfc_sli4_send_nop_mbox_cmds(phba,
9682 if (intr_mode == 0 ||
9686 lpfc_log_intr_mode(phba, intr_mode);
9690 "0451 Configure interrupt mode (%d) "
9691 "failed active interrupt test.\n",
9698 lpfc_sli4_unset_hba(phba);
9700 cfg_mode = --intr_mode;
9704 lpfc_post_init_setup(phba);
9712 file_name, &phba->
pcidev->dev,
9714 lpfc_write_firmware);
9722 lpfc_sli4_disable_intr(phba);
9723 out_free_sysfs_attr:
9726 lpfc_destroy_shost(phba);
9727 out_unset_driver_resource:
9728 lpfc_unset_driver_resource_phase2(phba);
9730 lpfc_free_iocb_list(phba);
9731 out_unset_driver_resource_s4:
9732 lpfc_sli4_driver_resource_unset(phba);
9733 out_unset_pci_mem_s4:
9734 lpfc_sli4_pci_mem_unset(phba);
9735 out_disable_pci_dev:
9736 lpfc_disable_pci_dev(phba);
9740 lpfc_hba_free(phba);
9754 lpfc_pci_remove_one_s4(
struct pci_dev *pdev)
9756 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9763 spin_lock_irq(&phba->
hbalock);
9765 spin_unlock_irq(&phba->
hbalock);
9793 lpfc_sli4_hba_unset(phba);
9795 spin_lock_irq(&phba->
hbalock);
9797 spin_unlock_irq(&phba->
hbalock);
9802 lpfc_scsi_free(phba);
9804 lpfc_sli4_driver_resource_unset(phba);
9807 lpfc_sli4_pci_mem_unset(phba);
9811 lpfc_disable_pci_dev(phba);
9814 lpfc_hba_free(phba);
9843 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9847 "2843 PCI device Power Management suspend.\n");
9855 lpfc_sli4_disable_intr(phba);
9885 lpfc_pci_resume_one_s4(
struct pci_dev *pdev)
9887 struct Scsi_Host *shost = pci_get_drvdata(pdev);
9893 "0292 PCI device Power Management resume.\n");
9910 "lpfc_worker_%d", phba->
brd_no);
9914 "0293 PM resume failed to start worker "
9915 "thread: error=x%x.\n", error);
9920 intr_mode = lpfc_sli4_enable_intr(phba, phba->
intr_mode);
9923 "0294 PM resume Failed to enable interrupt\n");
9933 lpfc_log_intr_mode(phba, phba->
intr_mode);
9946 lpfc_sli4_prep_dev_for_recover(
struct lpfc_hba *phba)
9952 "2828 PCI channel I/O abort preparing for recovery\n");
9970 lpfc_sli4_prep_dev_for_reset(
struct lpfc_hba *phba)
9973 "2826 PCI channel disable preparing for reset\n");
9985 lpfc_sli4_disable_intr(phba);
10002 lpfc_sli4_prep_dev_for_perm_failure(
struct lpfc_hba *phba)
10005 "2827 PCI channel permanent disable for failure\n");
10036 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10042 lpfc_sli4_prep_dev_for_recover(phba);
10046 lpfc_sli4_prep_dev_for_reset(phba);
10050 lpfc_sli4_prep_dev_for_perm_failure(phba);
10055 "2825 Unknown PCI error state: x%x\n", state);
10056 lpfc_sli4_prep_dev_for_reset(phba);
10080 lpfc_io_slot_reset_s4(
struct pci_dev *pdev)
10082 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10087 dev_printk(
KERN_INFO, &pdev->
dev,
"recovering from a slot reset.\n");
10090 "PCI device after reset.\n");
10105 spin_lock_irq(&phba->
hbalock);
10107 spin_unlock_irq(&phba->
hbalock);
10110 intr_mode = lpfc_sli4_enable_intr(phba, phba->
intr_mode);
10113 "2824 Cannot re-enable interrupt after "
10120 lpfc_log_intr_mode(phba, phba->
intr_mode);
10136 lpfc_io_resume_s4(
struct pci_dev *pdev)
10138 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10190 rc = lpfc_pci_probe_one_s4(pdev, pid);
10192 rc = lpfc_pci_probe_one_s3(pdev, pid);
10208 lpfc_pci_remove_one(
struct pci_dev *pdev)
10210 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10215 lpfc_pci_remove_one_s3(pdev);
10218 lpfc_pci_remove_one_s4(pdev);
10222 "1424 Invalid PCI device group: 0x%x\n",
10246 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10252 rc = lpfc_pci_suspend_one_s3(pdev, msg);
10255 rc = lpfc_pci_suspend_one_s4(pdev, msg);
10259 "1425 Invalid PCI device group: 0x%x\n",
10280 lpfc_pci_resume_one(
struct pci_dev *pdev)
10282 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10288 rc = lpfc_pci_resume_one_s3(pdev);
10291 rc = lpfc_pci_resume_one_s4(pdev);
10295 "1426 Invalid PCI device group: 0x%x\n",
10320 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10326 rc = lpfc_io_error_detected_s3(pdev, state);
10329 rc = lpfc_io_error_detected_s4(pdev, state);
10333 "1427 Invalid PCI device group: 0x%x\n",
10355 lpfc_io_slot_reset(
struct pci_dev *pdev)
10357 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10363 rc = lpfc_io_slot_reset_s3(pdev);
10366 rc = lpfc_io_slot_reset_s4(pdev);
10370 "1428 Invalid PCI device group: 0x%x\n",
10388 lpfc_io_resume(
struct pci_dev *pdev)
10390 struct Scsi_Host *shost = pci_get_drvdata(pdev);
10395 lpfc_io_resume_s3(pdev);
10398 lpfc_io_resume_s4(pdev);
10402 "1429 Invalid PCI device group: 0x%x\n",
10540 .error_detected = lpfc_io_error_detected,
10541 .slot_reset = lpfc_io_slot_reset,
10542 .resume = lpfc_io_resume,
10547 .id_table = lpfc_id_table,
10548 .probe = lpfc_pci_probe_one,
10550 .suspend = lpfc_pci_suspend_one,
10551 .resume = lpfc_pci_resume_one,
10552 .err_handler = &lpfc_err_handler,
10556 .open = lpfc_mgmt_open,
10557 .release = lpfc_mgmt_release,
10562 .name =
"lpfcmgmt",
10563 .fops = &lpfc_mgmt_fop,
10589 "misc_register returned with status %d", error);
10595 lpfc_transport_template =
10597 if (lpfc_transport_template ==
NULL)
10600 lpfc_vport_transport_template =
10602 if (lpfc_vport_transport_template ==
NULL) {
10607 error = pci_register_driver(&lpfc_driver);
10634 "_dump_buf_data at 0x%p\n",
10641 "_dump_buf_dif at 0x%p\n",