lpfc_init.c 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2005 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * Portions Copyright (C) 2004-2005 Christoph Hellwig *
  8. * *
  9. * This program is free software; you can redistribute it and/or *
  10. * modify it under the terms of version 2 of the GNU General *
  11. * Public License as published by the Free Software Foundation. *
  12. * This program is distributed in the hope that it will be useful. *
  13. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  14. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  15. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  16. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  17. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  18. * more details, a copy of which can be found in the file COPYING *
  19. * included with this package. *
  20. *******************************************************************/
  21. #include <linux/blkdev.h>
  22. #include <linux/delay.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/idr.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/kthread.h>
  27. #include <linux/pci.h>
  28. #include <linux/spinlock.h>
  29. #include <scsi/scsi.h>
  30. #include <scsi/scsi_device.h>
  31. #include <scsi/scsi_host.h>
  32. #include <scsi/scsi_transport_fc.h>
  33. #include "lpfc_hw.h"
  34. #include "lpfc_sli.h"
  35. #include "lpfc_disc.h"
  36. #include "lpfc_scsi.h"
  37. #include "lpfc.h"
  38. #include "lpfc_logmsg.h"
  39. #include "lpfc_crtn.h"
  40. #include "lpfc_version.h"
  41. static int lpfc_parse_vpd(struct lpfc_hba *, uint8_t *);
  42. static void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
  43. static int lpfc_post_rcv_buf(struct lpfc_hba *);
  44. static struct scsi_transport_template *lpfc_transport_template = NULL;
  45. static DEFINE_IDR(lpfc_hba_index);
  46. /************************************************************************/
  47. /* */
  48. /* lpfc_config_port_prep */
  49. /* This routine will do LPFC initialization prior to the */
  50. /* CONFIG_PORT mailbox command. This will be initialized */
  51. /* as a SLI layer callback routine. */
  52. /* This routine returns 0 on success or -ERESTART if it wants */
  53. /* the SLI layer to reset the HBA and try again. Any */
  54. /* other return value indicates an error. */
  55. /* */
  56. /************************************************************************/
  57. int
  58. lpfc_config_port_prep(struct lpfc_hba * phba)
  59. {
  60. lpfc_vpd_t *vp = &phba->vpd;
  61. int i = 0, rc;
  62. LPFC_MBOXQ_t *pmb;
  63. MAILBOX_t *mb;
  64. char *lpfc_vpd_data = NULL;
  65. uint16_t offset = 0;
  66. static char licensed[56] =
  67. "key unlock for use with gnu public licensed code only\0";
  68. pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  69. if (!pmb) {
  70. phba->hba_state = LPFC_HBA_ERROR;
  71. return -ENOMEM;
  72. }
  73. mb = &pmb->mb;
  74. phba->hba_state = LPFC_INIT_MBX_CMDS;
  75. if (lpfc_is_LC_HBA(phba->pcidev->device)) {
  76. uint32_t *ptext = (uint32_t *) licensed;
  77. for (i = 0; i < 56; i += sizeof (uint32_t), ptext++)
  78. *ptext = cpu_to_be32(*ptext);
  79. lpfc_read_nv(phba, pmb);
  80. memset((char*)mb->un.varRDnvp.rsvd3, 0,
  81. sizeof (mb->un.varRDnvp.rsvd3));
  82. memcpy((char*)mb->un.varRDnvp.rsvd3, licensed,
  83. sizeof (licensed));
  84. rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
  85. if (rc != MBX_SUCCESS) {
  86. lpfc_printf_log(phba,
  87. KERN_ERR,
  88. LOG_MBOX,
  89. "%d:0324 Config Port initialization "
  90. "error, mbxCmd x%x READ_NVPARM, "
  91. "mbxStatus x%x\n",
  92. phba->brd_no,
  93. mb->mbxCommand, mb->mbxStatus);
  94. mempool_free(pmb, phba->mbox_mem_pool);
  95. return -ERESTART;
  96. }
  97. memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename,
  98. sizeof (mb->un.varRDnvp.nodename));
  99. }
  100. /* Setup and issue mailbox READ REV command */
  101. lpfc_read_rev(phba, pmb);
  102. rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
  103. if (rc != MBX_SUCCESS) {
  104. lpfc_printf_log(phba,
  105. KERN_ERR,
  106. LOG_INIT,
  107. "%d:0439 Adapter failed to init, mbxCmd x%x "
  108. "READ_REV, mbxStatus x%x\n",
  109. phba->brd_no,
  110. mb->mbxCommand, mb->mbxStatus);
  111. mempool_free( pmb, phba->mbox_mem_pool);
  112. return -ERESTART;
  113. }
  114. /* The HBA's current state is provided by the ProgType and rr fields.
  115. * Read and check the value of these fields before continuing to config
  116. * this port.
  117. */
  118. if (mb->un.varRdRev.rr == 0 || mb->un.varRdRev.un.b.ProgType != 2) {
  119. /* Old firmware */
  120. vp->rev.rBit = 0;
  121. lpfc_printf_log(phba,
  122. KERN_ERR,
  123. LOG_INIT,
  124. "%d:0440 Adapter failed to init, mbxCmd x%x "
  125. "READ_REV detected outdated firmware"
  126. "Data: x%x\n",
  127. phba->brd_no,
  128. mb->mbxCommand, 0);
  129. mempool_free(pmb, phba->mbox_mem_pool);
  130. return -ERESTART;
  131. } else {
  132. vp->rev.rBit = 1;
  133. vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev;
  134. memcpy(vp->rev.sli1FwName,
  135. (char*)mb->un.varRdRev.sli1FwName, 16);
  136. vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev;
  137. memcpy(vp->rev.sli2FwName,
  138. (char *)mb->un.varRdRev.sli2FwName, 16);
  139. }
  140. /* Save information as VPD data */
  141. vp->rev.biuRev = mb->un.varRdRev.biuRev;
  142. vp->rev.smRev = mb->un.varRdRev.smRev;
  143. vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev;
  144. vp->rev.endecRev = mb->un.varRdRev.endecRev;
  145. vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh;
  146. vp->rev.fcphLow = mb->un.varRdRev.fcphLow;
  147. vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh;
  148. vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow;
  149. vp->rev.postKernRev = mb->un.varRdRev.postKernRev;
  150. vp->rev.opFwRev = mb->un.varRdRev.opFwRev;
  151. if (lpfc_is_LC_HBA(phba->pcidev->device))
  152. memcpy(phba->RandomData, (char *)&mb->un.varWords[24],
  153. sizeof (phba->RandomData));
  154. /* Get the default values for Model Name and Description */
  155. lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc);
  156. /* Get adapter VPD information */
  157. pmb->context2 = kmalloc(DMP_RSP_SIZE, GFP_KERNEL);
  158. if (!pmb->context2)
  159. goto out_free_mbox;
  160. lpfc_vpd_data = kmalloc(DMP_VPD_SIZE, GFP_KERNEL);
  161. if (!lpfc_vpd_data)
  162. goto out_free_context2;
  163. do {
  164. lpfc_dump_mem(phba, pmb, offset);
  165. rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
  166. if (rc != MBX_SUCCESS) {
  167. lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
  168. "%d:0441 VPD not present on adapter, "
  169. "mbxCmd x%x DUMP VPD, mbxStatus x%x\n",
  170. phba->brd_no,
  171. mb->mbxCommand, mb->mbxStatus);
  172. kfree(lpfc_vpd_data);
  173. lpfc_vpd_data = NULL;
  174. break;
  175. }
  176. lpfc_sli_pcimem_bcopy(pmb->context2, lpfc_vpd_data + offset,
  177. mb->un.varDmp.word_cnt);
  178. offset += mb->un.varDmp.word_cnt;
  179. } while (mb->un.varDmp.word_cnt);
  180. lpfc_parse_vpd(phba, lpfc_vpd_data);
  181. kfree(lpfc_vpd_data);
  182. out_free_context2:
  183. kfree(pmb->context2);
  184. out_free_mbox:
  185. mempool_free(pmb, phba->mbox_mem_pool);
  186. return 0;
  187. }
  188. /************************************************************************/
  189. /* */
  190. /* lpfc_config_port_post */
  191. /* This routine will do LPFC initialization after the */
  192. /* CONFIG_PORT mailbox command. This will be initialized */
  193. /* as a SLI layer callback routine. */
  194. /* This routine returns 0 on success. Any other return value */
  195. /* indicates an error. */
  196. /* */
  197. /************************************************************************/
  198. int
  199. lpfc_config_port_post(struct lpfc_hba * phba)
  200. {
  201. LPFC_MBOXQ_t *pmb;
  202. MAILBOX_t *mb;
  203. struct lpfc_dmabuf *mp;
  204. struct lpfc_sli *psli = &phba->sli;
  205. uint32_t status, timeout;
  206. int i, j, rc;
  207. pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  208. if (!pmb) {
  209. phba->hba_state = LPFC_HBA_ERROR;
  210. return -ENOMEM;
  211. }
  212. mb = &pmb->mb;
  213. lpfc_config_link(phba, pmb);
  214. rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
  215. if (rc != MBX_SUCCESS) {
  216. lpfc_printf_log(phba,
  217. KERN_ERR,
  218. LOG_INIT,
  219. "%d:0447 Adapter failed init, mbxCmd x%x "
  220. "CONFIG_LINK mbxStatus x%x\n",
  221. phba->brd_no,
  222. mb->mbxCommand, mb->mbxStatus);
  223. phba->hba_state = LPFC_HBA_ERROR;
  224. mempool_free( pmb, phba->mbox_mem_pool);
  225. return -EIO;
  226. }
  227. /* Get login parameters for NID. */
  228. lpfc_read_sparam(phba, pmb);
  229. if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
  230. lpfc_printf_log(phba,
  231. KERN_ERR,
  232. LOG_INIT,
  233. "%d:0448 Adapter failed init, mbxCmd x%x "
  234. "READ_SPARM mbxStatus x%x\n",
  235. phba->brd_no,
  236. mb->mbxCommand, mb->mbxStatus);
  237. phba->hba_state = LPFC_HBA_ERROR;
  238. mp = (struct lpfc_dmabuf *) pmb->context1;
  239. mempool_free( pmb, phba->mbox_mem_pool);
  240. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  241. kfree(mp);
  242. return -EIO;
  243. }
  244. mp = (struct lpfc_dmabuf *) pmb->context1;
  245. memcpy(&phba->fc_sparam, mp->virt, sizeof (struct serv_parm));
  246. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  247. kfree(mp);
  248. pmb->context1 = NULL;
  249. memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName,
  250. sizeof (struct lpfc_name));
  251. memcpy(&phba->fc_portname, &phba->fc_sparam.portName,
  252. sizeof (struct lpfc_name));
  253. /* If no serial number in VPD data, use low 6 bytes of WWNN */
  254. /* This should be consolidated into parse_vpd ? - mr */
  255. if (phba->SerialNumber[0] == 0) {
  256. uint8_t *outptr;
  257. outptr = &phba->fc_nodename.u.s.IEEE[0];
  258. for (i = 0; i < 12; i++) {
  259. status = *outptr++;
  260. j = ((status & 0xf0) >> 4);
  261. if (j <= 9)
  262. phba->SerialNumber[i] =
  263. (char)((uint8_t) 0x30 + (uint8_t) j);
  264. else
  265. phba->SerialNumber[i] =
  266. (char)((uint8_t) 0x61 + (uint8_t) (j - 10));
  267. i++;
  268. j = (status & 0xf);
  269. if (j <= 9)
  270. phba->SerialNumber[i] =
  271. (char)((uint8_t) 0x30 + (uint8_t) j);
  272. else
  273. phba->SerialNumber[i] =
  274. (char)((uint8_t) 0x61 + (uint8_t) (j - 10));
  275. }
  276. }
  277. /* This should turn on DELAYED ABTS for ELS timeouts */
  278. lpfc_set_slim(phba, pmb, 0x052198, 0x1);
  279. if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
  280. phba->hba_state = LPFC_HBA_ERROR;
  281. mempool_free( pmb, phba->mbox_mem_pool);
  282. return -EIO;
  283. }
  284. lpfc_read_config(phba, pmb);
  285. if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
  286. lpfc_printf_log(phba,
  287. KERN_ERR,
  288. LOG_INIT,
  289. "%d:0453 Adapter failed to init, mbxCmd x%x "
  290. "READ_CONFIG, mbxStatus x%x\n",
  291. phba->brd_no,
  292. mb->mbxCommand, mb->mbxStatus);
  293. phba->hba_state = LPFC_HBA_ERROR;
  294. mempool_free( pmb, phba->mbox_mem_pool);
  295. return -EIO;
  296. }
  297. /* Reset the DFT_HBA_Q_DEPTH to the max xri */
  298. if (phba->cfg_hba_queue_depth > (mb->un.varRdConfig.max_xri+1))
  299. phba->cfg_hba_queue_depth =
  300. mb->un.varRdConfig.max_xri + 1;
  301. phba->lmt = mb->un.varRdConfig.lmt;
  302. /* HBA is not 4GB capable, or HBA is not 2GB capable,
  303. don't let link speed ask for it */
  304. if ((((phba->lmt & LMT_4250_10bit) != LMT_4250_10bit) &&
  305. (phba->cfg_link_speed > LINK_SPEED_2G)) ||
  306. (((phba->lmt & LMT_2125_10bit) != LMT_2125_10bit) &&
  307. (phba->cfg_link_speed > LINK_SPEED_1G))) {
  308. /* Reset link speed to auto. 1G/2GB HBA cfg'd for 4G */
  309. lpfc_printf_log(phba,
  310. KERN_WARNING,
  311. LOG_LINK_EVENT,
  312. "%d:1302 Invalid speed for this board: "
  313. "Reset link speed to auto: x%x\n",
  314. phba->brd_no,
  315. phba->cfg_link_speed);
  316. phba->cfg_link_speed = LINK_SPEED_AUTO;
  317. }
  318. phba->hba_state = LPFC_LINK_DOWN;
  319. /* Only process IOCBs on ring 0 till hba_state is READY */
  320. if (psli->ring[psli->ip_ring].cmdringaddr)
  321. psli->ring[psli->ip_ring].flag |= LPFC_STOP_IOCB_EVENT;
  322. if (psli->ring[psli->fcp_ring].cmdringaddr)
  323. psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT;
  324. if (psli->ring[psli->next_ring].cmdringaddr)
  325. psli->ring[psli->next_ring].flag |= LPFC_STOP_IOCB_EVENT;
  326. /* Post receive buffers for desired rings */
  327. lpfc_post_rcv_buf(phba);
  328. /* Enable appropriate host interrupts */
  329. spin_lock_irq(phba->host->host_lock);
  330. status = readl(phba->HCregaddr);
  331. status |= HC_MBINT_ENA | HC_ERINT_ENA | HC_LAINT_ENA;
  332. if (psli->num_rings > 0)
  333. status |= HC_R0INT_ENA;
  334. if (psli->num_rings > 1)
  335. status |= HC_R1INT_ENA;
  336. if (psli->num_rings > 2)
  337. status |= HC_R2INT_ENA;
  338. if (psli->num_rings > 3)
  339. status |= HC_R3INT_ENA;
  340. writel(status, phba->HCregaddr);
  341. readl(phba->HCregaddr); /* flush */
  342. spin_unlock_irq(phba->host->host_lock);
  343. /*
  344. * Setup the ring 0 (els) timeout handler
  345. */
  346. timeout = phba->fc_ratov << 1;
  347. phba->els_tmofunc.expires = jiffies + HZ * timeout;
  348. add_timer(&phba->els_tmofunc);
  349. lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed);
  350. pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  351. if (lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT) != MBX_SUCCESS) {
  352. lpfc_printf_log(phba,
  353. KERN_ERR,
  354. LOG_INIT,
  355. "%d:0454 Adapter failed to init, mbxCmd x%x "
  356. "INIT_LINK, mbxStatus x%x\n",
  357. phba->brd_no,
  358. mb->mbxCommand, mb->mbxStatus);
  359. /* Clear all interrupt enable conditions */
  360. writel(0, phba->HCregaddr);
  361. readl(phba->HCregaddr); /* flush */
  362. /* Clear all pending interrupts */
  363. writel(0xffffffff, phba->HAregaddr);
  364. readl(phba->HAregaddr); /* flush */
  365. phba->hba_state = LPFC_HBA_ERROR;
  366. mempool_free(pmb, phba->mbox_mem_pool);
  367. return -EIO;
  368. }
  369. /* MBOX buffer will be freed in mbox compl */
  370. i = 0;
  371. while ((phba->hba_state != LPFC_HBA_READY) ||
  372. (phba->num_disc_nodes) || (phba->fc_prli_sent) ||
  373. ((phba->fc_map_cnt == 0) && (i<2)) ||
  374. (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) {
  375. /* Check every second for 30 retries. */
  376. i++;
  377. if (i > 30) {
  378. break;
  379. }
  380. if ((i >= 15) && (phba->hba_state <= LPFC_LINK_DOWN)) {
  381. /* The link is down. Set linkdown timeout */
  382. break;
  383. }
  384. /* Delay for 1 second to give discovery time to complete. */
  385. msleep(1000);
  386. }
  387. /* Since num_disc_nodes keys off of PLOGI, delay a bit to let
  388. * any potential PRLIs to flush thru the SLI sub-system.
  389. */
  390. msleep(50);
  391. return (0);
  392. }
  393. /************************************************************************/
  394. /* */
  395. /* lpfc_hba_down_prep */
  396. /* This routine will do LPFC uninitialization before the */
  397. /* HBA is reset when bringing down the SLI Layer. This will be */
  398. /* initialized as a SLI layer callback routine. */
  399. /* This routine returns 0 on success. Any other return value */
  400. /* indicates an error. */
  401. /* */
  402. /************************************************************************/
  403. int
  404. lpfc_hba_down_prep(struct lpfc_hba * phba)
  405. {
  406. /* Disable interrupts */
  407. writel(0, phba->HCregaddr);
  408. readl(phba->HCregaddr); /* flush */
  409. /* Cleanup potential discovery resources */
  410. lpfc_els_flush_rscn(phba);
  411. lpfc_els_flush_cmd(phba);
  412. lpfc_disc_flush_list(phba);
  413. return (0);
  414. }
  415. /************************************************************************/
  416. /* */
  417. /* lpfc_handle_eratt */
  418. /* This routine will handle processing a Host Attention */
  419. /* Error Status event. This will be initialized */
  420. /* as a SLI layer callback routine. */
  421. /* */
  422. /************************************************************************/
  423. void
  424. lpfc_handle_eratt(struct lpfc_hba * phba)
  425. {
  426. struct lpfc_sli *psli = &phba->sli;
  427. struct lpfc_sli_ring *pring;
  428. /*
  429. * If a reset is sent to the HBA restore PCI configuration registers.
  430. */
  431. if ( phba->hba_state == LPFC_INIT_START ) {
  432. mdelay(1);
  433. readl(phba->HCregaddr); /* flush */
  434. writel(0, phba->HCregaddr);
  435. readl(phba->HCregaddr); /* flush */
  436. /* Restore PCI cmd register */
  437. pci_write_config_word(phba->pcidev,
  438. PCI_COMMAND, phba->pci_cfg_value);
  439. }
  440. if (phba->work_hs & HS_FFER6) {
  441. /* Re-establishing Link */
  442. lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
  443. "%d:1301 Re-establishing Link "
  444. "Data: x%x x%x x%x\n",
  445. phba->brd_no, phba->work_hs,
  446. phba->work_status[0], phba->work_status[1]);
  447. spin_lock_irq(phba->host->host_lock);
  448. phba->fc_flag |= FC_ESTABLISH_LINK;
  449. spin_unlock_irq(phba->host->host_lock);
  450. /*
  451. * Firmware stops when it triggled erratt with HS_FFER6.
  452. * That could cause the I/Os dropped by the firmware.
  453. * Error iocb (I/O) on txcmplq and let the SCSI layer
  454. * retry it after re-establishing link.
  455. */
  456. pring = &psli->ring[psli->fcp_ring];
  457. lpfc_sli_abort_iocb_ring(phba, pring);
  458. /*
  459. * There was a firmware error. Take the hba offline and then
  460. * attempt to restart it.
  461. */
  462. lpfc_offline(phba);
  463. if (lpfc_online(phba) == 0) { /* Initialize the HBA */
  464. mod_timer(&phba->fc_estabtmo, jiffies + HZ * 60);
  465. return;
  466. }
  467. } else {
  468. /* The if clause above forces this code path when the status
  469. * failure is a value other than FFER6. Do not call the offline
  470. * twice. This is the adapter hardware error path.
  471. */
  472. lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
  473. "%d:0457 Adapter Hardware Error "
  474. "Data: x%x x%x x%x\n",
  475. phba->brd_no, phba->work_hs,
  476. phba->work_status[0], phba->work_status[1]);
  477. lpfc_offline(phba);
  478. /*
  479. * Restart all traffic to this host. Since the fc_transport
  480. * block functions (future) were not called in lpfc_offline,
  481. * don't call them here.
  482. */
  483. scsi_unblock_requests(phba->host);
  484. }
  485. }
  486. /************************************************************************/
  487. /* */
  488. /* lpfc_handle_latt */
  489. /* This routine will handle processing a Host Attention */
  490. /* Link Status event. This will be initialized */
  491. /* as a SLI layer callback routine. */
  492. /* */
  493. /************************************************************************/
  494. void
  495. lpfc_handle_latt(struct lpfc_hba * phba)
  496. {
  497. struct lpfc_sli *psli = &phba->sli;
  498. LPFC_MBOXQ_t *pmb;
  499. volatile uint32_t control;
  500. struct lpfc_dmabuf *mp;
  501. int rc = -ENOMEM;
  502. pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  503. if (!pmb)
  504. goto lpfc_handle_latt_err_exit;
  505. mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
  506. if (!mp)
  507. goto lpfc_handle_latt_free_pmb;
  508. mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
  509. if (!mp->virt)
  510. goto lpfc_handle_latt_free_mp;
  511. rc = -EIO;
  512. psli->slistat.link_event++;
  513. lpfc_read_la(phba, pmb, mp);
  514. pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
  515. rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
  516. if (rc == MBX_NOT_FINISHED)
  517. goto lpfc_handle_latt_free_mp;
  518. /* Clear Link Attention in HA REG */
  519. spin_lock_irq(phba->host->host_lock);
  520. writel(HA_LATT, phba->HAregaddr);
  521. readl(phba->HAregaddr); /* flush */
  522. spin_unlock_irq(phba->host->host_lock);
  523. return;
  524. lpfc_handle_latt_free_mp:
  525. kfree(mp);
  526. lpfc_handle_latt_free_pmb:
  527. kfree(pmb);
  528. lpfc_handle_latt_err_exit:
  529. /* Enable Link attention interrupts */
  530. spin_lock_irq(phba->host->host_lock);
  531. psli->sli_flag |= LPFC_PROCESS_LA;
  532. control = readl(phba->HCregaddr);
  533. control |= HC_LAINT_ENA;
  534. writel(control, phba->HCregaddr);
  535. readl(phba->HCregaddr); /* flush */
  536. /* Clear Link Attention in HA REG */
  537. writel(HA_LATT, phba->HAregaddr);
  538. readl(phba->HAregaddr); /* flush */
  539. spin_unlock_irq(phba->host->host_lock);
  540. lpfc_linkdown(phba);
  541. phba->hba_state = LPFC_HBA_ERROR;
  542. /* The other case is an error from issue_mbox */
  543. if (rc == -ENOMEM)
  544. lpfc_printf_log(phba,
  545. KERN_WARNING,
  546. LOG_MBOX,
  547. "%d:0300 READ_LA: no buffers\n",
  548. phba->brd_no);
  549. return;
  550. }
  551. /************************************************************************/
  552. /* */
  553. /* lpfc_parse_vpd */
  554. /* This routine will parse the VPD data */
  555. /* */
  556. /************************************************************************/
  557. static int
  558. lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd)
  559. {
  560. uint8_t lenlo, lenhi;
  561. uint32_t Length;
  562. int i, j;
  563. int finished = 0;
  564. int index = 0;
  565. if (!vpd)
  566. return 0;
  567. /* Vital Product */
  568. lpfc_printf_log(phba,
  569. KERN_INFO,
  570. LOG_INIT,
  571. "%d:0455 Vital Product Data: x%x x%x x%x x%x\n",
  572. phba->brd_no,
  573. (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2],
  574. (uint32_t) vpd[3]);
  575. do {
  576. switch (vpd[index]) {
  577. case 0x82:
  578. index += 1;
  579. lenlo = vpd[index];
  580. index += 1;
  581. lenhi = vpd[index];
  582. index += 1;
  583. i = ((((unsigned short)lenhi) << 8) + lenlo);
  584. index += i;
  585. break;
  586. case 0x90:
  587. index += 1;
  588. lenlo = vpd[index];
  589. index += 1;
  590. lenhi = vpd[index];
  591. index += 1;
  592. Length = ((((unsigned short)lenhi) << 8) + lenlo);
  593. while (Length > 0) {
  594. /* Look for Serial Number */
  595. if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) {
  596. index += 2;
  597. i = vpd[index];
  598. index += 1;
  599. j = 0;
  600. Length -= (3+i);
  601. while(i--) {
  602. phba->SerialNumber[j++] = vpd[index++];
  603. if (j == 31)
  604. break;
  605. }
  606. phba->SerialNumber[j] = 0;
  607. continue;
  608. }
  609. else if ((vpd[index] == 'V') && (vpd[index+1] == '1')) {
  610. phba->vpd_flag |= VPD_MODEL_DESC;
  611. index += 2;
  612. i = vpd[index];
  613. index += 1;
  614. j = 0;
  615. Length -= (3+i);
  616. while(i--) {
  617. phba->ModelDesc[j++] = vpd[index++];
  618. if (j == 255)
  619. break;
  620. }
  621. phba->ModelDesc[j] = 0;
  622. continue;
  623. }
  624. else if ((vpd[index] == 'V') && (vpd[index+1] == '2')) {
  625. phba->vpd_flag |= VPD_MODEL_NAME;
  626. index += 2;
  627. i = vpd[index];
  628. index += 1;
  629. j = 0;
  630. Length -= (3+i);
  631. while(i--) {
  632. phba->ModelName[j++] = vpd[index++];
  633. if (j == 79)
  634. break;
  635. }
  636. phba->ModelName[j] = 0;
  637. continue;
  638. }
  639. else if ((vpd[index] == 'V') && (vpd[index+1] == '3')) {
  640. phba->vpd_flag |= VPD_PROGRAM_TYPE;
  641. index += 2;
  642. i = vpd[index];
  643. index += 1;
  644. j = 0;
  645. Length -= (3+i);
  646. while(i--) {
  647. phba->ProgramType[j++] = vpd[index++];
  648. if (j == 255)
  649. break;
  650. }
  651. phba->ProgramType[j] = 0;
  652. continue;
  653. }
  654. else if ((vpd[index] == 'V') && (vpd[index+1] == '4')) {
  655. phba->vpd_flag |= VPD_PORT;
  656. index += 2;
  657. i = vpd[index];
  658. index += 1;
  659. j = 0;
  660. Length -= (3+i);
  661. while(i--) {
  662. phba->Port[j++] = vpd[index++];
  663. if (j == 19)
  664. break;
  665. }
  666. phba->Port[j] = 0;
  667. continue;
  668. }
  669. else {
  670. index += 2;
  671. i = vpd[index];
  672. index += 1;
  673. index += i;
  674. Length -= (3 + i);
  675. }
  676. }
  677. finished = 0;
  678. break;
  679. case 0x78:
  680. finished = 1;
  681. break;
  682. default:
  683. index ++;
  684. break;
  685. }
  686. } while (!finished && (index < 108));
  687. return(1);
  688. }
  689. static void
  690. lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
  691. {
  692. lpfc_vpd_t *vp;
  693. uint32_t id;
  694. char str[16];
  695. vp = &phba->vpd;
  696. pci_read_config_dword(phba->pcidev, PCI_VENDOR_ID, &id);
  697. switch ((id >> 16) & 0xffff) {
  698. case PCI_DEVICE_ID_FIREFLY:
  699. strcpy(str, "LP6000 1");
  700. break;
  701. case PCI_DEVICE_ID_SUPERFLY:
  702. if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
  703. strcpy(str, "LP7000 1");
  704. else
  705. strcpy(str, "LP7000E 1");
  706. break;
  707. case PCI_DEVICE_ID_DRAGONFLY:
  708. strcpy(str, "LP8000 1");
  709. break;
  710. case PCI_DEVICE_ID_CENTAUR:
  711. if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
  712. strcpy(str, "LP9002 2");
  713. else
  714. strcpy(str, "LP9000 1");
  715. break;
  716. case PCI_DEVICE_ID_RFLY:
  717. strcpy(str, "LP952 2");
  718. break;
  719. case PCI_DEVICE_ID_PEGASUS:
  720. strcpy(str, "LP9802 2");
  721. break;
  722. case PCI_DEVICE_ID_THOR:
  723. strcpy(str, "LP10000 2");
  724. break;
  725. case PCI_DEVICE_ID_VIPER:
  726. strcpy(str, "LPX1000 10");
  727. break;
  728. case PCI_DEVICE_ID_PFLY:
  729. strcpy(str, "LP982 2");
  730. break;
  731. case PCI_DEVICE_ID_TFLY:
  732. strcpy(str, "LP1050 2");
  733. break;
  734. case PCI_DEVICE_ID_HELIOS:
  735. strcpy(str, "LP11000 4");
  736. break;
  737. case PCI_DEVICE_ID_BMID:
  738. strcpy(str, "LP1150 4");
  739. break;
  740. case PCI_DEVICE_ID_BSMB:
  741. strcpy(str, "LP111 4");
  742. break;
  743. case PCI_DEVICE_ID_ZEPHYR:
  744. strcpy(str, "LP11000e 4");
  745. break;
  746. case PCI_DEVICE_ID_ZMID:
  747. strcpy(str, "LP1150e 4");
  748. break;
  749. case PCI_DEVICE_ID_ZSMB:
  750. strcpy(str, "LP111e 4");
  751. break;
  752. case PCI_DEVICE_ID_LP101:
  753. strcpy(str, "LP101 2");
  754. break;
  755. case PCI_DEVICE_ID_LP10000S:
  756. strcpy(str, "LP10000-S 2");
  757. break;
  758. default:
  759. memset(str, 0, 16);
  760. break;
  761. }
  762. if (mdp)
  763. sscanf(str, "%s", mdp);
  764. if (descp)
  765. sprintf(descp, "Emulex LightPulse %s Gigabit PCI Fibre "
  766. "Channel Adapter", str);
  767. }
  768. /**************************************************/
  769. /* lpfc_post_buffer */
  770. /* */
  771. /* This routine will post count buffers to the */
  772. /* ring with the QUE_RING_BUF_CN command. This */
  773. /* allows 3 buffers / command to be posted. */
  774. /* Returns the number of buffers NOT posted. */
  775. /**************************************************/
  776. int
  777. lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
  778. int type)
  779. {
  780. IOCB_t *icmd;
  781. struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list;
  782. struct lpfc_iocbq *iocb = NULL;
  783. struct lpfc_dmabuf *mp1, *mp2;
  784. cnt += pring->missbufcnt;
  785. /* While there are buffers to post */
  786. while (cnt > 0) {
  787. /* Allocate buffer for command iocb */
  788. spin_lock_irq(phba->host->host_lock);
  789. list_remove_head(lpfc_iocb_list, iocb, struct lpfc_iocbq, list);
  790. spin_unlock_irq(phba->host->host_lock);
  791. if (iocb == NULL) {
  792. pring->missbufcnt = cnt;
  793. return cnt;
  794. }
  795. memset(iocb, 0, sizeof (struct lpfc_iocbq));
  796. icmd = &iocb->iocb;
  797. /* 2 buffers can be posted per command */
  798. /* Allocate buffer to post */
  799. mp1 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
  800. if (mp1)
  801. mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
  802. &mp1->phys);
  803. if (mp1 == 0 || mp1->virt == 0) {
  804. if (mp1)
  805. kfree(mp1);
  806. spin_lock_irq(phba->host->host_lock);
  807. list_add_tail(&iocb->list, lpfc_iocb_list);
  808. spin_unlock_irq(phba->host->host_lock);
  809. pring->missbufcnt = cnt;
  810. return cnt;
  811. }
  812. INIT_LIST_HEAD(&mp1->list);
  813. /* Allocate buffer to post */
  814. if (cnt > 1) {
  815. mp2 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
  816. if (mp2)
  817. mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
  818. &mp2->phys);
  819. if (mp2 == 0 || mp2->virt == 0) {
  820. if (mp2)
  821. kfree(mp2);
  822. lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
  823. kfree(mp1);
  824. spin_lock_irq(phba->host->host_lock);
  825. list_add_tail(&iocb->list, lpfc_iocb_list);
  826. spin_unlock_irq(phba->host->host_lock);
  827. pring->missbufcnt = cnt;
  828. return cnt;
  829. }
  830. INIT_LIST_HEAD(&mp2->list);
  831. } else {
  832. mp2 = NULL;
  833. }
  834. icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys);
  835. icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys);
  836. icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE;
  837. icmd->ulpBdeCount = 1;
  838. cnt--;
  839. if (mp2) {
  840. icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys);
  841. icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys);
  842. icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE;
  843. cnt--;
  844. icmd->ulpBdeCount = 2;
  845. }
  846. icmd->ulpCommand = CMD_QUE_RING_BUF64_CN;
  847. icmd->ulpLe = 1;
  848. spin_lock_irq(phba->host->host_lock);
  849. if (lpfc_sli_issue_iocb(phba, pring, iocb, 0) == IOCB_ERROR) {
  850. lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
  851. kfree(mp1);
  852. cnt++;
  853. if (mp2) {
  854. lpfc_mbuf_free(phba, mp2->virt, mp2->phys);
  855. kfree(mp2);
  856. cnt++;
  857. }
  858. list_add_tail(&iocb->list, lpfc_iocb_list);
  859. pring->missbufcnt = cnt;
  860. spin_unlock_irq(phba->host->host_lock);
  861. return cnt;
  862. }
  863. spin_unlock_irq(phba->host->host_lock);
  864. lpfc_sli_ringpostbuf_put(phba, pring, mp1);
  865. if (mp2) {
  866. lpfc_sli_ringpostbuf_put(phba, pring, mp2);
  867. }
  868. }
  869. pring->missbufcnt = 0;
  870. return 0;
  871. }
  872. /************************************************************************/
  873. /* */
  874. /* lpfc_post_rcv_buf */
  875. /* This routine post initial rcv buffers to the configured rings */
  876. /* */
  877. /************************************************************************/
  878. static int
  879. lpfc_post_rcv_buf(struct lpfc_hba * phba)
  880. {
  881. struct lpfc_sli *psli = &phba->sli;
  882. /* Ring 0, ELS / CT buffers */
  883. lpfc_post_buffer(phba, &psli->ring[LPFC_ELS_RING], LPFC_BUF_RING0, 1);
  884. /* Ring 2 - FCP no buffers needed */
  885. return 0;
  886. }
  887. #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
  888. /************************************************************************/
  889. /* */
  890. /* lpfc_sha_init */
  891. /* */
  892. /************************************************************************/
  893. static void
  894. lpfc_sha_init(uint32_t * HashResultPointer)
  895. {
  896. HashResultPointer[0] = 0x67452301;
  897. HashResultPointer[1] = 0xEFCDAB89;
  898. HashResultPointer[2] = 0x98BADCFE;
  899. HashResultPointer[3] = 0x10325476;
  900. HashResultPointer[4] = 0xC3D2E1F0;
  901. }
  902. /************************************************************************/
  903. /* */
  904. /* lpfc_sha_iterate */
  905. /* */
  906. /************************************************************************/
  907. static void
  908. lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer)
  909. {
  910. int t;
  911. uint32_t TEMP;
  912. uint32_t A, B, C, D, E;
  913. t = 16;
  914. do {
  915. HashWorkingPointer[t] =
  916. S(1,
  917. HashWorkingPointer[t - 3] ^ HashWorkingPointer[t -
  918. 8] ^
  919. HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]);
  920. } while (++t <= 79);
  921. t = 0;
  922. A = HashResultPointer[0];
  923. B = HashResultPointer[1];
  924. C = HashResultPointer[2];
  925. D = HashResultPointer[3];
  926. E = HashResultPointer[4];
  927. do {
  928. if (t < 20) {
  929. TEMP = ((B & C) | ((~B) & D)) + 0x5A827999;
  930. } else if (t < 40) {
  931. TEMP = (B ^ C ^ D) + 0x6ED9EBA1;
  932. } else if (t < 60) {
  933. TEMP = ((B & C) | (B & D) | (C & D)) + 0x8F1BBCDC;
  934. } else {
  935. TEMP = (B ^ C ^ D) + 0xCA62C1D6;
  936. }
  937. TEMP += S(5, A) + E + HashWorkingPointer[t];
  938. E = D;
  939. D = C;
  940. C = S(30, B);
  941. B = A;
  942. A = TEMP;
  943. } while (++t <= 79);
  944. HashResultPointer[0] += A;
  945. HashResultPointer[1] += B;
  946. HashResultPointer[2] += C;
  947. HashResultPointer[3] += D;
  948. HashResultPointer[4] += E;
  949. }
  950. /************************************************************************/
  951. /* */
  952. /* lpfc_challenge_key */
  953. /* */
  954. /************************************************************************/
  955. static void
  956. lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking)
  957. {
  958. *HashWorking = (*RandomChallenge ^ *HashWorking);
  959. }
  960. /************************************************************************/
  961. /* */
  962. /* lpfc_hba_init */
  963. /* */
  964. /************************************************************************/
  965. void
  966. lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
  967. {
  968. int t;
  969. uint32_t *HashWorking;
  970. uint32_t *pwwnn = phba->wwnn;
  971. HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL);
  972. if (!HashWorking)
  973. return;
  974. memset(HashWorking, 0, (80 * sizeof(uint32_t)));
  975. HashWorking[0] = HashWorking[78] = *pwwnn++;
  976. HashWorking[1] = HashWorking[79] = *pwwnn;
  977. for (t = 0; t < 7; t++)
  978. lpfc_challenge_key(phba->RandomData + t, HashWorking + t);
  979. lpfc_sha_init(hbainit);
  980. lpfc_sha_iterate(hbainit, HashWorking);
  981. kfree(HashWorking);
  982. }
  983. static void
  984. lpfc_cleanup(struct lpfc_hba * phba, uint32_t save_bind)
  985. {
  986. struct lpfc_nodelist *ndlp, *next_ndlp;
  987. /* clean up phba - lpfc specific */
  988. lpfc_can_disctmo(phba);
  989. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list,
  990. nlp_listp) {
  991. lpfc_nlp_remove(phba, ndlp);
  992. }
  993. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list,
  994. nlp_listp) {
  995. lpfc_nlp_remove(phba, ndlp);
  996. }
  997. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list,
  998. nlp_listp) {
  999. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  1000. }
  1001. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
  1002. nlp_listp) {
  1003. lpfc_nlp_remove(phba, ndlp);
  1004. }
  1005. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
  1006. nlp_listp) {
  1007. lpfc_nlp_remove(phba, ndlp);
  1008. }
  1009. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list,
  1010. nlp_listp) {
  1011. lpfc_nlp_remove(phba, ndlp);
  1012. }
  1013. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list,
  1014. nlp_listp) {
  1015. lpfc_nlp_remove(phba, ndlp);
  1016. }
  1017. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
  1018. nlp_listp) {
  1019. lpfc_nlp_remove(phba, ndlp);
  1020. }
  1021. INIT_LIST_HEAD(&phba->fc_nlpmap_list);
  1022. INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
  1023. INIT_LIST_HEAD(&phba->fc_unused_list);
  1024. INIT_LIST_HEAD(&phba->fc_plogi_list);
  1025. INIT_LIST_HEAD(&phba->fc_adisc_list);
  1026. INIT_LIST_HEAD(&phba->fc_reglogin_list);
  1027. INIT_LIST_HEAD(&phba->fc_prli_list);
  1028. INIT_LIST_HEAD(&phba->fc_npr_list);
  1029. phba->fc_map_cnt = 0;
  1030. phba->fc_unmap_cnt = 0;
  1031. phba->fc_plogi_cnt = 0;
  1032. phba->fc_adisc_cnt = 0;
  1033. phba->fc_reglogin_cnt = 0;
  1034. phba->fc_prli_cnt = 0;
  1035. phba->fc_npr_cnt = 0;
  1036. phba->fc_unused_cnt= 0;
  1037. return;
  1038. }
  1039. static void
  1040. lpfc_establish_link_tmo(unsigned long ptr)
  1041. {
  1042. struct lpfc_hba *phba = (struct lpfc_hba *)ptr;
  1043. unsigned long iflag;
  1044. /* Re-establishing Link, timer expired */
  1045. lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
  1046. "%d:1300 Re-establishing Link, timer expired "
  1047. "Data: x%x x%x\n",
  1048. phba->brd_no, phba->fc_flag, phba->hba_state);
  1049. spin_lock_irqsave(phba->host->host_lock, iflag);
  1050. phba->fc_flag &= ~FC_ESTABLISH_LINK;
  1051. spin_unlock_irqrestore(phba->host->host_lock, iflag);
  1052. }
  1053. static int
  1054. lpfc_stop_timer(struct lpfc_hba * phba)
  1055. {
  1056. struct lpfc_sli *psli = &phba->sli;
  1057. /* Instead of a timer, this has been converted to a
  1058. * deferred procedding list.
  1059. */
  1060. while (!list_empty(&phba->freebufList)) {
  1061. struct lpfc_dmabuf *mp = NULL;
  1062. list_remove_head((&phba->freebufList), mp,
  1063. struct lpfc_dmabuf, list);
  1064. if (mp) {
  1065. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  1066. kfree(mp);
  1067. }
  1068. }
  1069. del_timer_sync(&phba->fc_estabtmo);
  1070. del_timer_sync(&phba->fc_disctmo);
  1071. del_timer_sync(&phba->fc_fdmitmo);
  1072. del_timer_sync(&phba->els_tmofunc);
  1073. psli = &phba->sli;
  1074. del_timer_sync(&psli->mbox_tmo);
  1075. return(1);
  1076. }
  1077. int
  1078. lpfc_online(struct lpfc_hba * phba)
  1079. {
  1080. if (!phba)
  1081. return 0;
  1082. if (!(phba->fc_flag & FC_OFFLINE_MODE))
  1083. return 0;
  1084. lpfc_printf_log(phba,
  1085. KERN_WARNING,
  1086. LOG_INIT,
  1087. "%d:0458 Bring Adapter online\n",
  1088. phba->brd_no);
  1089. if (!lpfc_sli_queue_setup(phba))
  1090. return 1;
  1091. if (lpfc_sli_hba_setup(phba)) /* Initialize the HBA */
  1092. return 1;
  1093. spin_lock_irq(phba->host->host_lock);
  1094. phba->fc_flag &= ~FC_OFFLINE_MODE;
  1095. spin_unlock_irq(phba->host->host_lock);
  1096. /*
  1097. * Restart all traffic to this host. Since the fc_transport block
  1098. * functions (future) were not called in lpfc_offline, don't call them
  1099. * here.
  1100. */
  1101. scsi_unblock_requests(phba->host);
  1102. return 0;
  1103. }
  1104. int
  1105. lpfc_offline(struct lpfc_hba * phba)
  1106. {
  1107. struct lpfc_sli_ring *pring;
  1108. struct lpfc_sli *psli;
  1109. unsigned long iflag;
  1110. int i = 0;
  1111. if (!phba)
  1112. return 0;
  1113. if (phba->fc_flag & FC_OFFLINE_MODE)
  1114. return 0;
  1115. /*
  1116. * Don't call the fc_transport block api (future). The device is
  1117. * going offline and causing a timer to fire in the midlayer is
  1118. * unproductive. Just block all new requests until the driver
  1119. * comes back online.
  1120. */
  1121. scsi_block_requests(phba->host);
  1122. psli = &phba->sli;
  1123. pring = &psli->ring[psli->fcp_ring];
  1124. lpfc_linkdown(phba);
  1125. /* The linkdown event takes 30 seconds to timeout. */
  1126. while (pring->txcmplq_cnt) {
  1127. mdelay(10);
  1128. if (i++ > 3000)
  1129. break;
  1130. }
  1131. /* stop all timers associated with this hba */
  1132. lpfc_stop_timer(phba);
  1133. phba->work_hba_events = 0;
  1134. lpfc_printf_log(phba,
  1135. KERN_WARNING,
  1136. LOG_INIT,
  1137. "%d:0460 Bring Adapter offline\n",
  1138. phba->brd_no);
  1139. /* Bring down the SLI Layer and cleanup. The HBA is offline
  1140. now. */
  1141. lpfc_sli_hba_down(phba);
  1142. lpfc_cleanup(phba, 1);
  1143. spin_lock_irqsave(phba->host->host_lock, iflag);
  1144. phba->fc_flag |= FC_OFFLINE_MODE;
  1145. spin_unlock_irqrestore(phba->host->host_lock, iflag);
  1146. return 0;
  1147. }
  1148. /******************************************************************************
  1149. * Function name: lpfc_scsi_free
  1150. *
  1151. * Description: Called from lpfc_pci_remove_one free internal driver resources
  1152. *
  1153. ******************************************************************************/
  1154. static int
  1155. lpfc_scsi_free(struct lpfc_hba * phba)
  1156. {
  1157. struct lpfc_scsi_buf *sb, *sb_next;
  1158. struct lpfc_iocbq *io, *io_next;
  1159. spin_lock_irq(phba->host->host_lock);
  1160. /* Release all the lpfc_scsi_bufs maintained by this host. */
  1161. list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list, list) {
  1162. list_del(&sb->list);
  1163. pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
  1164. sb->dma_handle);
  1165. kfree(sb);
  1166. phba->total_scsi_bufs--;
  1167. }
  1168. /* Release all the lpfc_iocbq entries maintained by this host. */
  1169. list_for_each_entry_safe(io, io_next, &phba->lpfc_iocb_list, list) {
  1170. list_del(&io->list);
  1171. kfree(io);
  1172. phba->total_iocbq_bufs--;
  1173. }
  1174. spin_unlock_irq(phba->host->host_lock);
  1175. return 0;
  1176. }
  1177. static int __devinit
  1178. lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
  1179. {
  1180. struct Scsi_Host *host;
  1181. struct lpfc_hba *phba;
  1182. struct lpfc_sli *psli;
  1183. struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL;
  1184. unsigned long bar0map_len, bar2map_len;
  1185. int error = -ENODEV, retval;
  1186. int i;
  1187. if (pci_enable_device(pdev))
  1188. goto out;
  1189. if (pci_request_regions(pdev, LPFC_DRIVER_NAME))
  1190. goto out_disable_device;
  1191. host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba));
  1192. if (!host)
  1193. goto out_release_regions;
  1194. phba = (struct lpfc_hba*)host->hostdata;
  1195. memset(phba, 0, sizeof (struct lpfc_hba));
  1196. phba->host = host;
  1197. phba->fc_flag |= FC_LOADING;
  1198. phba->pcidev = pdev;
  1199. /* Assign an unused board number */
  1200. if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL))
  1201. goto out_put_host;
  1202. error = idr_get_new(&lpfc_hba_index, NULL, &phba->brd_no);
  1203. if (error)
  1204. goto out_put_host;
  1205. host->unique_id = phba->brd_no;
  1206. INIT_LIST_HEAD(&phba->ctrspbuflist);
  1207. INIT_LIST_HEAD(&phba->rnidrspbuflist);
  1208. INIT_LIST_HEAD(&phba->freebufList);
  1209. /* Initialize timers used by driver */
  1210. init_timer(&phba->fc_estabtmo);
  1211. phba->fc_estabtmo.function = lpfc_establish_link_tmo;
  1212. phba->fc_estabtmo.data = (unsigned long)phba;
  1213. init_timer(&phba->fc_disctmo);
  1214. phba->fc_disctmo.function = lpfc_disc_timeout;
  1215. phba->fc_disctmo.data = (unsigned long)phba;
  1216. init_timer(&phba->fc_fdmitmo);
  1217. phba->fc_fdmitmo.function = lpfc_fdmi_tmo;
  1218. phba->fc_fdmitmo.data = (unsigned long)phba;
  1219. init_timer(&phba->els_tmofunc);
  1220. phba->els_tmofunc.function = lpfc_els_timeout;
  1221. phba->els_tmofunc.data = (unsigned long)phba;
  1222. psli = &phba->sli;
  1223. init_timer(&psli->mbox_tmo);
  1224. psli->mbox_tmo.function = lpfc_mbox_timeout;
  1225. psli->mbox_tmo.data = (unsigned long)phba;
  1226. /*
  1227. * Get all the module params for configuring this host and then
  1228. * establish the host parameters.
  1229. */
  1230. lpfc_get_cfgparam(phba);
  1231. host->max_id = LPFC_MAX_TARGET;
  1232. host->max_lun = phba->cfg_max_luns;
  1233. host->this_id = -1;
  1234. /* Initialize all internally managed lists. */
  1235. INIT_LIST_HEAD(&phba->fc_nlpmap_list);
  1236. INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
  1237. INIT_LIST_HEAD(&phba->fc_unused_list);
  1238. INIT_LIST_HEAD(&phba->fc_plogi_list);
  1239. INIT_LIST_HEAD(&phba->fc_adisc_list);
  1240. INIT_LIST_HEAD(&phba->fc_reglogin_list);
  1241. INIT_LIST_HEAD(&phba->fc_prli_list);
  1242. INIT_LIST_HEAD(&phba->fc_npr_list);
  1243. pci_set_master(pdev);
  1244. retval = pci_set_mwi(pdev);
  1245. if (retval)
  1246. dev_printk(KERN_WARNING, &pdev->dev,
  1247. "Warning: pci_set_mwi returned %d\n", retval);
  1248. if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0)
  1249. if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0)
  1250. goto out_idr_remove;
  1251. /*
  1252. * Get the bus address of Bar0 and Bar2 and the number of bytes
  1253. * required by each mapping.
  1254. */
  1255. phba->pci_bar0_map = pci_resource_start(phba->pcidev, 0);
  1256. bar0map_len = pci_resource_len(phba->pcidev, 0);
  1257. phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2);
  1258. bar2map_len = pci_resource_len(phba->pcidev, 2);
  1259. /* Map HBA SLIM and Control Registers to a kernel virtual address. */
  1260. phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len);
  1261. phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len);
  1262. /* Allocate memory for SLI-2 structures */
  1263. phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE,
  1264. &phba->slim2p_mapping, GFP_KERNEL);
  1265. if (!phba->slim2p)
  1266. goto out_iounmap;
  1267. /* Initialize the SLI Layer to run with lpfc HBAs. */
  1268. lpfc_sli_setup(phba);
  1269. lpfc_sli_queue_setup(phba);
  1270. error = lpfc_mem_alloc(phba);
  1271. if (error)
  1272. goto out_free_slim;
  1273. /* Initialize and populate the iocb list per host. */
  1274. INIT_LIST_HEAD(&phba->lpfc_iocb_list);
  1275. for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) {
  1276. iocbq_entry = kmalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL);
  1277. if (iocbq_entry == NULL) {
  1278. printk(KERN_ERR "%s: only allocated %d iocbs of "
  1279. "expected %d count. Unloading driver.\n",
  1280. __FUNCTION__, i, LPFC_IOCB_LIST_CNT);
  1281. error = -ENOMEM;
  1282. goto out_free_iocbq;
  1283. }
  1284. memset(iocbq_entry, 0, sizeof(struct lpfc_iocbq));
  1285. spin_lock_irq(phba->host->host_lock);
  1286. list_add(&iocbq_entry->list, &phba->lpfc_iocb_list);
  1287. phba->total_iocbq_bufs++;
  1288. spin_unlock_irq(phba->host->host_lock);
  1289. }
  1290. /* Initialize HBA structure */
  1291. phba->fc_edtov = FF_DEF_EDTOV;
  1292. phba->fc_ratov = FF_DEF_RATOV;
  1293. phba->fc_altov = FF_DEF_ALTOV;
  1294. phba->fc_arbtov = FF_DEF_ARBTOV;
  1295. INIT_LIST_HEAD(&phba->work_list);
  1296. phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT);
  1297. phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4));
  1298. /* Startup the kernel thread for this host adapter. */
  1299. phba->worker_thread = kthread_run(lpfc_do_work, phba,
  1300. "lpfc_worker_%d", phba->brd_no);
  1301. if (IS_ERR(phba->worker_thread)) {
  1302. error = PTR_ERR(phba->worker_thread);
  1303. goto out_free_iocbq;
  1304. }
  1305. /* We can rely on a queue depth attribute only after SLI HBA setup */
  1306. host->can_queue = phba->cfg_hba_queue_depth - 10;
  1307. /* Tell the midlayer we support 16 byte commands */
  1308. host->max_cmd_len = 16;
  1309. /* Initialize the list of scsi buffers used by driver for scsi IO. */
  1310. INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list);
  1311. host->transportt = lpfc_transport_template;
  1312. host->hostdata[0] = (unsigned long)phba;
  1313. pci_set_drvdata(pdev, host);
  1314. error = scsi_add_host(host, &pdev->dev);
  1315. if (error)
  1316. goto out_kthread_stop;
  1317. error = lpfc_alloc_sysfs_attr(phba);
  1318. if (error)
  1319. goto out_kthread_stop;
  1320. error = request_irq(phba->pcidev->irq, lpfc_intr_handler, SA_SHIRQ,
  1321. LPFC_DRIVER_NAME, phba);
  1322. if (error) {
  1323. lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
  1324. "%d:0451 Enable interrupt handler failed\n",
  1325. phba->brd_no);
  1326. goto out_free_sysfs_attr;
  1327. }
  1328. phba->MBslimaddr = phba->slim_memmap_p;
  1329. phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET;
  1330. phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET;
  1331. phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET;
  1332. phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET;
  1333. error = lpfc_sli_hba_setup(phba);
  1334. if (error)
  1335. goto out_free_irq;
  1336. /*
  1337. * set fixed host attributes
  1338. * Must done after lpfc_sli_hba_setup()
  1339. */
  1340. fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn);
  1341. fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn);
  1342. fc_host_supported_classes(host) = FC_COS_CLASS3;
  1343. memset(fc_host_supported_fc4s(host), 0,
  1344. sizeof(fc_host_supported_fc4s(host)));
  1345. fc_host_supported_fc4s(host)[2] = 1;
  1346. fc_host_supported_fc4s(host)[7] = 1;
  1347. lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host));
  1348. fc_host_supported_speeds(host) = 0;
  1349. switch (FC_JEDEC_ID(phba->vpd.rev.biuRev)) {
  1350. case VIPER_JEDEC_ID:
  1351. fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT;
  1352. break;
  1353. case HELIOS_JEDEC_ID:
  1354. fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT;
  1355. /* Fall through */
  1356. case CENTAUR_2G_JEDEC_ID:
  1357. case PEGASUS_JEDEC_ID:
  1358. case THOR_JEDEC_ID:
  1359. fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT;
  1360. /* Fall through */
  1361. default:
  1362. fc_host_supported_speeds(host) = FC_PORTSPEED_1GBIT;
  1363. }
  1364. fc_host_maxframe_size(host) =
  1365. ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) |
  1366. (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb);
  1367. /* This value is also unchanging */
  1368. memset(fc_host_active_fc4s(host), 0,
  1369. sizeof(fc_host_active_fc4s(host)));
  1370. fc_host_active_fc4s(host)[2] = 1;
  1371. fc_host_active_fc4s(host)[7] = 1;
  1372. spin_lock_irq(phba->host->host_lock);
  1373. phba->fc_flag &= ~FC_LOADING;
  1374. spin_unlock_irq(phba->host->host_lock);
  1375. return 0;
  1376. out_free_irq:
  1377. lpfc_stop_timer(phba);
  1378. phba->work_hba_events = 0;
  1379. free_irq(phba->pcidev->irq, phba);
  1380. out_free_sysfs_attr:
  1381. lpfc_free_sysfs_attr(phba);
  1382. out_kthread_stop:
  1383. kthread_stop(phba->worker_thread);
  1384. out_free_iocbq:
  1385. list_for_each_entry_safe(iocbq_entry, iocbq_next,
  1386. &phba->lpfc_iocb_list, list) {
  1387. spin_lock_irq(phba->host->host_lock);
  1388. kfree(iocbq_entry);
  1389. phba->total_iocbq_bufs--;
  1390. spin_unlock_irq(phba->host->host_lock);
  1391. }
  1392. lpfc_mem_free(phba);
  1393. out_free_slim:
  1394. dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p,
  1395. phba->slim2p_mapping);
  1396. out_iounmap:
  1397. iounmap(phba->ctrl_regs_memmap_p);
  1398. iounmap(phba->slim_memmap_p);
  1399. out_idr_remove:
  1400. idr_remove(&lpfc_hba_index, phba->brd_no);
  1401. out_put_host:
  1402. scsi_host_put(host);
  1403. out_release_regions:
  1404. pci_release_regions(pdev);
  1405. out_disable_device:
  1406. pci_disable_device(pdev);
  1407. out:
  1408. return error;
  1409. }
  1410. static void __devexit
  1411. lpfc_pci_remove_one(struct pci_dev *pdev)
  1412. {
  1413. struct Scsi_Host *host = pci_get_drvdata(pdev);
  1414. struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata[0];
  1415. unsigned long iflag;
  1416. lpfc_free_sysfs_attr(phba);
  1417. spin_lock_irqsave(phba->host->host_lock, iflag);
  1418. phba->fc_flag |= FC_UNLOADING;
  1419. spin_unlock_irqrestore(phba->host->host_lock, iflag);
  1420. fc_remove_host(phba->host);
  1421. scsi_remove_host(phba->host);
  1422. kthread_stop(phba->worker_thread);
  1423. /*
  1424. * Bring down the SLI Layer. This step disable all interrupts,
  1425. * clears the rings, discards all mailbox commands, and resets
  1426. * the HBA.
  1427. */
  1428. lpfc_sli_hba_down(phba);
  1429. /* Release the irq reservation */
  1430. free_irq(phba->pcidev->irq, phba);
  1431. lpfc_cleanup(phba, 0);
  1432. lpfc_stop_timer(phba);
  1433. phba->work_hba_events = 0;
  1434. /*
  1435. * Call scsi_free before mem_free since scsi bufs are released to their
  1436. * corresponding pools here.
  1437. */
  1438. lpfc_scsi_free(phba);
  1439. lpfc_mem_free(phba);
  1440. /* Free resources associated with SLI2 interface */
  1441. dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE,
  1442. phba->slim2p, phba->slim2p_mapping);
  1443. /* unmap adapter SLIM and Control Registers */
  1444. iounmap(phba->ctrl_regs_memmap_p);
  1445. iounmap(phba->slim_memmap_p);
  1446. pci_release_regions(phba->pcidev);
  1447. pci_disable_device(phba->pcidev);
  1448. idr_remove(&lpfc_hba_index, phba->brd_no);
  1449. scsi_host_put(phba->host);
  1450. pci_set_drvdata(pdev, NULL);
  1451. }
  1452. static struct pci_device_id lpfc_id_table[] = {
  1453. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER,
  1454. PCI_ANY_ID, PCI_ANY_ID, },
  1455. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_FIREFLY,
  1456. PCI_ANY_ID, PCI_ANY_ID, },
  1457. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_THOR,
  1458. PCI_ANY_ID, PCI_ANY_ID, },
  1459. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PEGASUS,
  1460. PCI_ANY_ID, PCI_ANY_ID, },
  1461. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_CENTAUR,
  1462. PCI_ANY_ID, PCI_ANY_ID, },
  1463. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_DRAGONFLY,
  1464. PCI_ANY_ID, PCI_ANY_ID, },
  1465. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SUPERFLY,
  1466. PCI_ANY_ID, PCI_ANY_ID, },
  1467. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_RFLY,
  1468. PCI_ANY_ID, PCI_ANY_ID, },
  1469. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY,
  1470. PCI_ANY_ID, PCI_ANY_ID, },
  1471. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS,
  1472. PCI_ANY_ID, PCI_ANY_ID, },
  1473. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID,
  1474. PCI_ANY_ID, PCI_ANY_ID, },
  1475. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB,
  1476. PCI_ANY_ID, PCI_ANY_ID, },
  1477. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR,
  1478. PCI_ANY_ID, PCI_ANY_ID, },
  1479. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID,
  1480. PCI_ANY_ID, PCI_ANY_ID, },
  1481. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB,
  1482. PCI_ANY_ID, PCI_ANY_ID, },
  1483. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_TFLY,
  1484. PCI_ANY_ID, PCI_ANY_ID, },
  1485. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP101,
  1486. PCI_ANY_ID, PCI_ANY_ID, },
  1487. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S,
  1488. PCI_ANY_ID, PCI_ANY_ID, },
  1489. { 0 }
  1490. };
  1491. MODULE_DEVICE_TABLE(pci, lpfc_id_table);
  1492. static struct pci_driver lpfc_driver = {
  1493. .name = LPFC_DRIVER_NAME,
  1494. .id_table = lpfc_id_table,
  1495. .probe = lpfc_pci_probe_one,
  1496. .remove = __devexit_p(lpfc_pci_remove_one),
  1497. };
  1498. static int __init
  1499. lpfc_init(void)
  1500. {
  1501. int error = 0;
  1502. printk(LPFC_MODULE_DESC "\n");
  1503. printk(LPFC_COPYRIGHT "\n");
  1504. lpfc_transport_template =
  1505. fc_attach_transport(&lpfc_transport_functions);
  1506. if (!lpfc_transport_template)
  1507. return -ENOMEM;
  1508. error = pci_register_driver(&lpfc_driver);
  1509. if (error)
  1510. fc_release_transport(lpfc_transport_template);
  1511. return error;
  1512. }
  1513. static void __exit
  1514. lpfc_exit(void)
  1515. {
  1516. pci_unregister_driver(&lpfc_driver);
  1517. fc_release_transport(lpfc_transport_template);
  1518. }
  1519. module_init(lpfc_init);
  1520. module_exit(lpfc_exit);
  1521. MODULE_LICENSE("GPL");
  1522. MODULE_DESCRIPTION(LPFC_MODULE_DESC);
  1523. MODULE_AUTHOR("Emulex Corporation - tech.support@emulex.com");
  1524. MODULE_VERSION("0:" LPFC_DRIVER_VERSION);