lpfc_init.c 49 KB

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