lpfc_init.c 49 KB

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