lpfc_init.c 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737
  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. /* Cleanup any outstanding ELS commands */
  499. lpfc_els_flush_cmd(phba);
  500. psli->slistat.link_event++;
  501. lpfc_read_la(phba, pmb, mp);
  502. pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
  503. rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
  504. if (rc == MBX_NOT_FINISHED)
  505. goto lpfc_handle_latt_free_mp;
  506. /* Clear Link Attention in HA REG */
  507. spin_lock_irq(phba->host->host_lock);
  508. writel(HA_LATT, phba->HAregaddr);
  509. readl(phba->HAregaddr); /* flush */
  510. spin_unlock_irq(phba->host->host_lock);
  511. return;
  512. lpfc_handle_latt_free_mp:
  513. kfree(mp);
  514. lpfc_handle_latt_free_pmb:
  515. kfree(pmb);
  516. lpfc_handle_latt_err_exit:
  517. /* Enable Link attention interrupts */
  518. spin_lock_irq(phba->host->host_lock);
  519. psli->sli_flag |= LPFC_PROCESS_LA;
  520. control = readl(phba->HCregaddr);
  521. control |= HC_LAINT_ENA;
  522. writel(control, phba->HCregaddr);
  523. readl(phba->HCregaddr); /* flush */
  524. /* Clear Link Attention in HA REG */
  525. writel(HA_LATT, phba->HAregaddr);
  526. readl(phba->HAregaddr); /* flush */
  527. spin_unlock_irq(phba->host->host_lock);
  528. lpfc_linkdown(phba);
  529. phba->hba_state = LPFC_HBA_ERROR;
  530. /* The other case is an error from issue_mbox */
  531. if (rc == -ENOMEM)
  532. lpfc_printf_log(phba,
  533. KERN_WARNING,
  534. LOG_MBOX,
  535. "%d:0300 READ_LA: no buffers\n",
  536. phba->brd_no);
  537. return;
  538. }
  539. /************************************************************************/
  540. /* */
  541. /* lpfc_parse_vpd */
  542. /* This routine will parse the VPD data */
  543. /* */
  544. /************************************************************************/
  545. static int
  546. lpfc_parse_vpd(struct lpfc_hba * phba, uint8_t * vpd)
  547. {
  548. uint8_t lenlo, lenhi;
  549. uint32_t Length;
  550. int i, j;
  551. int finished = 0;
  552. int index = 0;
  553. if (!vpd)
  554. return 0;
  555. /* Vital Product */
  556. lpfc_printf_log(phba,
  557. KERN_INFO,
  558. LOG_INIT,
  559. "%d:0455 Vital Product Data: x%x x%x x%x x%x\n",
  560. phba->brd_no,
  561. (uint32_t) vpd[0], (uint32_t) vpd[1], (uint32_t) vpd[2],
  562. (uint32_t) vpd[3]);
  563. do {
  564. switch (vpd[index]) {
  565. case 0x82:
  566. index += 1;
  567. lenlo = vpd[index];
  568. index += 1;
  569. lenhi = vpd[index];
  570. index += 1;
  571. i = ((((unsigned short)lenhi) << 8) + lenlo);
  572. index += i;
  573. break;
  574. case 0x90:
  575. index += 1;
  576. lenlo = vpd[index];
  577. index += 1;
  578. lenhi = vpd[index];
  579. index += 1;
  580. Length = ((((unsigned short)lenhi) << 8) + lenlo);
  581. while (Length > 0) {
  582. /* Look for Serial Number */
  583. if ((vpd[index] == 'S') && (vpd[index+1] == 'N')) {
  584. index += 2;
  585. i = vpd[index];
  586. index += 1;
  587. j = 0;
  588. Length -= (3+i);
  589. while(i--) {
  590. phba->SerialNumber[j++] = vpd[index++];
  591. if (j == 31)
  592. break;
  593. }
  594. phba->SerialNumber[j] = 0;
  595. continue;
  596. }
  597. else if ((vpd[index] == 'V') && (vpd[index+1] == '1')) {
  598. phba->vpd_flag |= VPD_MODEL_DESC;
  599. index += 2;
  600. i = vpd[index];
  601. index += 1;
  602. j = 0;
  603. Length -= (3+i);
  604. while(i--) {
  605. phba->ModelDesc[j++] = vpd[index++];
  606. if (j == 255)
  607. break;
  608. }
  609. phba->ModelDesc[j] = 0;
  610. continue;
  611. }
  612. else if ((vpd[index] == 'V') && (vpd[index+1] == '2')) {
  613. phba->vpd_flag |= VPD_MODEL_NAME;
  614. index += 2;
  615. i = vpd[index];
  616. index += 1;
  617. j = 0;
  618. Length -= (3+i);
  619. while(i--) {
  620. phba->ModelName[j++] = vpd[index++];
  621. if (j == 79)
  622. break;
  623. }
  624. phba->ModelName[j] = 0;
  625. continue;
  626. }
  627. else if ((vpd[index] == 'V') && (vpd[index+1] == '3')) {
  628. phba->vpd_flag |= VPD_PROGRAM_TYPE;
  629. index += 2;
  630. i = vpd[index];
  631. index += 1;
  632. j = 0;
  633. Length -= (3+i);
  634. while(i--) {
  635. phba->ProgramType[j++] = vpd[index++];
  636. if (j == 255)
  637. break;
  638. }
  639. phba->ProgramType[j] = 0;
  640. continue;
  641. }
  642. else if ((vpd[index] == 'V') && (vpd[index+1] == '4')) {
  643. phba->vpd_flag |= VPD_PORT;
  644. index += 2;
  645. i = vpd[index];
  646. index += 1;
  647. j = 0;
  648. Length -= (3+i);
  649. while(i--) {
  650. phba->Port[j++] = vpd[index++];
  651. if (j == 19)
  652. break;
  653. }
  654. phba->Port[j] = 0;
  655. continue;
  656. }
  657. else {
  658. index += 2;
  659. i = vpd[index];
  660. index += 1;
  661. index += i;
  662. Length -= (3 + i);
  663. }
  664. }
  665. finished = 0;
  666. break;
  667. case 0x78:
  668. finished = 1;
  669. break;
  670. default:
  671. index ++;
  672. break;
  673. }
  674. } while (!finished && (index < 108));
  675. return(1);
  676. }
  677. static void
  678. lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
  679. {
  680. lpfc_vpd_t *vp;
  681. uint32_t id;
  682. uint8_t hdrtype;
  683. char str[16];
  684. vp = &phba->vpd;
  685. pci_read_config_dword(phba->pcidev, PCI_VENDOR_ID, &id);
  686. pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
  687. switch ((id >> 16) & 0xffff) {
  688. case PCI_DEVICE_ID_FIREFLY:
  689. strcpy(str, "LP6000 1");
  690. break;
  691. case PCI_DEVICE_ID_SUPERFLY:
  692. if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
  693. strcpy(str, "LP7000 1");
  694. else
  695. strcpy(str, "LP7000E 1");
  696. break;
  697. case PCI_DEVICE_ID_DRAGONFLY:
  698. strcpy(str, "LP8000 1");
  699. break;
  700. case PCI_DEVICE_ID_CENTAUR:
  701. if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
  702. strcpy(str, "LP9002 2");
  703. else
  704. strcpy(str, "LP9000 1");
  705. break;
  706. case PCI_DEVICE_ID_RFLY:
  707. strcpy(str, "LP952 2");
  708. break;
  709. case PCI_DEVICE_ID_PEGASUS:
  710. strcpy(str, "LP9802 2");
  711. break;
  712. case PCI_DEVICE_ID_THOR:
  713. if (hdrtype == 0x80)
  714. strcpy(str, "LP10000DC 2");
  715. else
  716. strcpy(str, "LP10000 2");
  717. break;
  718. case PCI_DEVICE_ID_VIPER:
  719. strcpy(str, "LPX1000 10");
  720. break;
  721. case PCI_DEVICE_ID_PFLY:
  722. strcpy(str, "LP982 2");
  723. break;
  724. case PCI_DEVICE_ID_TFLY:
  725. if (hdrtype == 0x80)
  726. strcpy(str, "LP1050DC 2");
  727. else
  728. strcpy(str, "LP1050 2");
  729. break;
  730. case PCI_DEVICE_ID_HELIOS:
  731. if (hdrtype == 0x80)
  732. strcpy(str, "LP11002 4");
  733. else
  734. strcpy(str, "LP11000 4");
  735. break;
  736. case PCI_DEVICE_ID_BMID:
  737. strcpy(str, "LP1150 4");
  738. break;
  739. case PCI_DEVICE_ID_BSMB:
  740. strcpy(str, "LP111 4");
  741. break;
  742. case PCI_DEVICE_ID_ZEPHYR:
  743. if (hdrtype == 0x80)
  744. strcpy(str, "LPe11002 4");
  745. else
  746. strcpy(str, "LPe11000 4");
  747. break;
  748. case PCI_DEVICE_ID_ZMID:
  749. strcpy(str, "LPe1150 4");
  750. break;
  751. case PCI_DEVICE_ID_ZSMB:
  752. strcpy(str, "LPe111 4");
  753. break;
  754. case PCI_DEVICE_ID_LP101:
  755. strcpy(str, "LP101 2");
  756. break;
  757. case PCI_DEVICE_ID_LP10000S:
  758. strcpy(str, "LP10000-S 2");
  759. break;
  760. default:
  761. memset(str, 0, 16);
  762. break;
  763. }
  764. if (mdp)
  765. sscanf(str, "%s", mdp);
  766. if (descp)
  767. sprintf(descp, "Emulex LightPulse %s Gigabit PCI Fibre "
  768. "Channel Adapter", str);
  769. }
  770. /**************************************************/
  771. /* lpfc_post_buffer */
  772. /* */
  773. /* This routine will post count buffers to the */
  774. /* ring with the QUE_RING_BUF_CN command. This */
  775. /* allows 3 buffers / command to be posted. */
  776. /* Returns the number of buffers NOT posted. */
  777. /**************************************************/
  778. int
  779. lpfc_post_buffer(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, int cnt,
  780. int type)
  781. {
  782. IOCB_t *icmd;
  783. struct lpfc_iocbq *iocb;
  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. iocb = lpfc_sli_get_iocbq(phba);
  791. spin_unlock_irq(phba->host->host_lock);
  792. if (iocb == NULL) {
  793. pring->missbufcnt = cnt;
  794. return cnt;
  795. }
  796. icmd = &iocb->iocb;
  797. /* 2 buffers can be posted per command */
  798. /* Allocate buffer to post */
  799. mp1 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
  800. if (mp1)
  801. mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
  802. &mp1->phys);
  803. if (mp1 == 0 || mp1->virt == 0) {
  804. kfree(mp1);
  805. spin_lock_irq(phba->host->host_lock);
  806. lpfc_sli_release_iocbq(phba, iocb);
  807. spin_unlock_irq(phba->host->host_lock);
  808. pring->missbufcnt = cnt;
  809. return cnt;
  810. }
  811. INIT_LIST_HEAD(&mp1->list);
  812. /* Allocate buffer to post */
  813. if (cnt > 1) {
  814. mp2 = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
  815. if (mp2)
  816. mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI,
  817. &mp2->phys);
  818. if (mp2 == 0 || mp2->virt == 0) {
  819. kfree(mp2);
  820. lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
  821. kfree(mp1);
  822. spin_lock_irq(phba->host->host_lock);
  823. lpfc_sli_release_iocbq(phba, iocb);
  824. spin_unlock_irq(phba->host->host_lock);
  825. pring->missbufcnt = cnt;
  826. return cnt;
  827. }
  828. INIT_LIST_HEAD(&mp2->list);
  829. } else {
  830. mp2 = NULL;
  831. }
  832. icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys);
  833. icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys);
  834. icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE;
  835. icmd->ulpBdeCount = 1;
  836. cnt--;
  837. if (mp2) {
  838. icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys);
  839. icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys);
  840. icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE;
  841. cnt--;
  842. icmd->ulpBdeCount = 2;
  843. }
  844. icmd->ulpCommand = CMD_QUE_RING_BUF64_CN;
  845. icmd->ulpLe = 1;
  846. spin_lock_irq(phba->host->host_lock);
  847. if (lpfc_sli_issue_iocb(phba, pring, iocb, 0) == IOCB_ERROR) {
  848. lpfc_mbuf_free(phba, mp1->virt, mp1->phys);
  849. kfree(mp1);
  850. cnt++;
  851. if (mp2) {
  852. lpfc_mbuf_free(phba, mp2->virt, mp2->phys);
  853. kfree(mp2);
  854. cnt++;
  855. }
  856. lpfc_sli_release_iocbq(phba, iocb);
  857. pring->missbufcnt = cnt;
  858. spin_unlock_irq(phba->host->host_lock);
  859. return cnt;
  860. }
  861. spin_unlock_irq(phba->host->host_lock);
  862. lpfc_sli_ringpostbuf_put(phba, pring, mp1);
  863. if (mp2) {
  864. lpfc_sli_ringpostbuf_put(phba, pring, mp2);
  865. }
  866. }
  867. pring->missbufcnt = 0;
  868. return 0;
  869. }
  870. /************************************************************************/
  871. /* */
  872. /* lpfc_post_rcv_buf */
  873. /* This routine post initial rcv buffers to the configured rings */
  874. /* */
  875. /************************************************************************/
  876. static int
  877. lpfc_post_rcv_buf(struct lpfc_hba * phba)
  878. {
  879. struct lpfc_sli *psli = &phba->sli;
  880. /* Ring 0, ELS / CT buffers */
  881. lpfc_post_buffer(phba, &psli->ring[LPFC_ELS_RING], LPFC_BUF_RING0, 1);
  882. /* Ring 2 - FCP no buffers needed */
  883. return 0;
  884. }
  885. #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
  886. /************************************************************************/
  887. /* */
  888. /* lpfc_sha_init */
  889. /* */
  890. /************************************************************************/
  891. static void
  892. lpfc_sha_init(uint32_t * HashResultPointer)
  893. {
  894. HashResultPointer[0] = 0x67452301;
  895. HashResultPointer[1] = 0xEFCDAB89;
  896. HashResultPointer[2] = 0x98BADCFE;
  897. HashResultPointer[3] = 0x10325476;
  898. HashResultPointer[4] = 0xC3D2E1F0;
  899. }
  900. /************************************************************************/
  901. /* */
  902. /* lpfc_sha_iterate */
  903. /* */
  904. /************************************************************************/
  905. static void
  906. lpfc_sha_iterate(uint32_t * HashResultPointer, uint32_t * HashWorkingPointer)
  907. {
  908. int t;
  909. uint32_t TEMP;
  910. uint32_t A, B, C, D, E;
  911. t = 16;
  912. do {
  913. HashWorkingPointer[t] =
  914. S(1,
  915. HashWorkingPointer[t - 3] ^ HashWorkingPointer[t -
  916. 8] ^
  917. HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]);
  918. } while (++t <= 79);
  919. t = 0;
  920. A = HashResultPointer[0];
  921. B = HashResultPointer[1];
  922. C = HashResultPointer[2];
  923. D = HashResultPointer[3];
  924. E = HashResultPointer[4];
  925. do {
  926. if (t < 20) {
  927. TEMP = ((B & C) | ((~B) & D)) + 0x5A827999;
  928. } else if (t < 40) {
  929. TEMP = (B ^ C ^ D) + 0x6ED9EBA1;
  930. } else if (t < 60) {
  931. TEMP = ((B & C) | (B & D) | (C & D)) + 0x8F1BBCDC;
  932. } else {
  933. TEMP = (B ^ C ^ D) + 0xCA62C1D6;
  934. }
  935. TEMP += S(5, A) + E + HashWorkingPointer[t];
  936. E = D;
  937. D = C;
  938. C = S(30, B);
  939. B = A;
  940. A = TEMP;
  941. } while (++t <= 79);
  942. HashResultPointer[0] += A;
  943. HashResultPointer[1] += B;
  944. HashResultPointer[2] += C;
  945. HashResultPointer[3] += D;
  946. HashResultPointer[4] += E;
  947. }
  948. /************************************************************************/
  949. /* */
  950. /* lpfc_challenge_key */
  951. /* */
  952. /************************************************************************/
  953. static void
  954. lpfc_challenge_key(uint32_t * RandomChallenge, uint32_t * HashWorking)
  955. {
  956. *HashWorking = (*RandomChallenge ^ *HashWorking);
  957. }
  958. /************************************************************************/
  959. /* */
  960. /* lpfc_hba_init */
  961. /* */
  962. /************************************************************************/
  963. void
  964. lpfc_hba_init(struct lpfc_hba *phba, uint32_t *hbainit)
  965. {
  966. int t;
  967. uint32_t *HashWorking;
  968. uint32_t *pwwnn = phba->wwnn;
  969. HashWorking = kmalloc(80 * sizeof(uint32_t), GFP_KERNEL);
  970. if (!HashWorking)
  971. return;
  972. memset(HashWorking, 0, (80 * sizeof(uint32_t)));
  973. HashWorking[0] = HashWorking[78] = *pwwnn++;
  974. HashWorking[1] = HashWorking[79] = *pwwnn;
  975. for (t = 0; t < 7; t++)
  976. lpfc_challenge_key(phba->RandomData + t, HashWorking + t);
  977. lpfc_sha_init(hbainit);
  978. lpfc_sha_iterate(hbainit, HashWorking);
  979. kfree(HashWorking);
  980. }
  981. static void
  982. lpfc_cleanup(struct lpfc_hba * phba, uint32_t save_bind)
  983. {
  984. struct lpfc_nodelist *ndlp, *next_ndlp;
  985. /* clean up phba - lpfc specific */
  986. lpfc_can_disctmo(phba);
  987. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpunmap_list,
  988. nlp_listp) {
  989. lpfc_nlp_remove(phba, ndlp);
  990. }
  991. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list,
  992. nlp_listp) {
  993. lpfc_nlp_remove(phba, ndlp);
  994. }
  995. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_unused_list,
  996. nlp_listp) {
  997. lpfc_nlp_list(phba, ndlp, NLP_NO_LIST);
  998. }
  999. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
  1000. nlp_listp) {
  1001. lpfc_nlp_remove(phba, ndlp);
  1002. }
  1003. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
  1004. nlp_listp) {
  1005. lpfc_nlp_remove(phba, ndlp);
  1006. }
  1007. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_reglogin_list,
  1008. nlp_listp) {
  1009. lpfc_nlp_remove(phba, ndlp);
  1010. }
  1011. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list,
  1012. nlp_listp) {
  1013. lpfc_nlp_remove(phba, ndlp);
  1014. }
  1015. list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
  1016. nlp_listp) {
  1017. lpfc_nlp_remove(phba, ndlp);
  1018. }
  1019. INIT_LIST_HEAD(&phba->fc_nlpmap_list);
  1020. INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
  1021. INIT_LIST_HEAD(&phba->fc_unused_list);
  1022. INIT_LIST_HEAD(&phba->fc_plogi_list);
  1023. INIT_LIST_HEAD(&phba->fc_adisc_list);
  1024. INIT_LIST_HEAD(&phba->fc_reglogin_list);
  1025. INIT_LIST_HEAD(&phba->fc_prli_list);
  1026. INIT_LIST_HEAD(&phba->fc_npr_list);
  1027. phba->fc_map_cnt = 0;
  1028. phba->fc_unmap_cnt = 0;
  1029. phba->fc_plogi_cnt = 0;
  1030. phba->fc_adisc_cnt = 0;
  1031. phba->fc_reglogin_cnt = 0;
  1032. phba->fc_prli_cnt = 0;
  1033. phba->fc_npr_cnt = 0;
  1034. phba->fc_unused_cnt= 0;
  1035. return;
  1036. }
  1037. static void
  1038. lpfc_establish_link_tmo(unsigned long ptr)
  1039. {
  1040. struct lpfc_hba *phba = (struct lpfc_hba *)ptr;
  1041. unsigned long iflag;
  1042. /* Re-establishing Link, timer expired */
  1043. lpfc_printf_log(phba, KERN_ERR, LOG_LINK_EVENT,
  1044. "%d:1300 Re-establishing Link, timer expired "
  1045. "Data: x%x x%x\n",
  1046. phba->brd_no, phba->fc_flag, phba->hba_state);
  1047. spin_lock_irqsave(phba->host->host_lock, iflag);
  1048. phba->fc_flag &= ~FC_ESTABLISH_LINK;
  1049. spin_unlock_irqrestore(phba->host->host_lock, iflag);
  1050. }
  1051. static int
  1052. lpfc_stop_timer(struct lpfc_hba * phba)
  1053. {
  1054. struct lpfc_sli *psli = &phba->sli;
  1055. /* Instead of a timer, this has been converted to a
  1056. * deferred procedding list.
  1057. */
  1058. while (!list_empty(&phba->freebufList)) {
  1059. struct lpfc_dmabuf *mp = NULL;
  1060. list_remove_head((&phba->freebufList), mp,
  1061. struct lpfc_dmabuf, list);
  1062. if (mp) {
  1063. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  1064. kfree(mp);
  1065. }
  1066. }
  1067. del_timer_sync(&phba->fc_estabtmo);
  1068. del_timer_sync(&phba->fc_disctmo);
  1069. del_timer_sync(&phba->fc_fdmitmo);
  1070. del_timer_sync(&phba->els_tmofunc);
  1071. psli = &phba->sli;
  1072. del_timer_sync(&psli->mbox_tmo);
  1073. return(1);
  1074. }
  1075. int
  1076. lpfc_online(struct lpfc_hba * phba)
  1077. {
  1078. if (!phba)
  1079. return 0;
  1080. if (!(phba->fc_flag & FC_OFFLINE_MODE))
  1081. return 0;
  1082. lpfc_printf_log(phba,
  1083. KERN_WARNING,
  1084. LOG_INIT,
  1085. "%d:0458 Bring Adapter online\n",
  1086. phba->brd_no);
  1087. if (!lpfc_sli_queue_setup(phba))
  1088. return 1;
  1089. if (lpfc_sli_hba_setup(phba)) /* Initialize the HBA */
  1090. return 1;
  1091. spin_lock_irq(phba->host->host_lock);
  1092. phba->fc_flag &= ~FC_OFFLINE_MODE;
  1093. spin_unlock_irq(phba->host->host_lock);
  1094. return 0;
  1095. }
  1096. int
  1097. lpfc_offline(struct lpfc_hba * phba)
  1098. {
  1099. struct lpfc_sli_ring *pring;
  1100. struct lpfc_sli *psli;
  1101. unsigned long iflag;
  1102. int i = 0;
  1103. if (!phba)
  1104. return 0;
  1105. if (phba->fc_flag & FC_OFFLINE_MODE)
  1106. return 0;
  1107. psli = &phba->sli;
  1108. pring = &psli->ring[psli->fcp_ring];
  1109. lpfc_linkdown(phba);
  1110. /* The linkdown event takes 30 seconds to timeout. */
  1111. while (pring->txcmplq_cnt) {
  1112. mdelay(10);
  1113. if (i++ > 3000)
  1114. break;
  1115. }
  1116. /* stop all timers associated with this hba */
  1117. lpfc_stop_timer(phba);
  1118. phba->work_hba_events = 0;
  1119. lpfc_printf_log(phba,
  1120. KERN_WARNING,
  1121. LOG_INIT,
  1122. "%d:0460 Bring Adapter offline\n",
  1123. phba->brd_no);
  1124. /* Bring down the SLI Layer and cleanup. The HBA is offline
  1125. now. */
  1126. lpfc_sli_hba_down(phba);
  1127. lpfc_cleanup(phba, 1);
  1128. spin_lock_irqsave(phba->host->host_lock, iflag);
  1129. phba->fc_flag |= FC_OFFLINE_MODE;
  1130. spin_unlock_irqrestore(phba->host->host_lock, iflag);
  1131. return 0;
  1132. }
  1133. /******************************************************************************
  1134. * Function name: lpfc_scsi_free
  1135. *
  1136. * Description: Called from lpfc_pci_remove_one free internal driver resources
  1137. *
  1138. ******************************************************************************/
  1139. static int
  1140. lpfc_scsi_free(struct lpfc_hba * phba)
  1141. {
  1142. struct lpfc_scsi_buf *sb, *sb_next;
  1143. struct lpfc_iocbq *io, *io_next;
  1144. spin_lock_irq(phba->host->host_lock);
  1145. /* Release all the lpfc_scsi_bufs maintained by this host. */
  1146. list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list, list) {
  1147. list_del(&sb->list);
  1148. pci_pool_free(phba->lpfc_scsi_dma_buf_pool, sb->data,
  1149. sb->dma_handle);
  1150. kfree(sb);
  1151. phba->total_scsi_bufs--;
  1152. }
  1153. /* Release all the lpfc_iocbq entries maintained by this host. */
  1154. list_for_each_entry_safe(io, io_next, &phba->lpfc_iocb_list, list) {
  1155. list_del(&io->list);
  1156. kfree(io);
  1157. phba->total_iocbq_bufs--;
  1158. }
  1159. spin_unlock_irq(phba->host->host_lock);
  1160. return 0;
  1161. }
  1162. static int __devinit
  1163. lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
  1164. {
  1165. struct Scsi_Host *host;
  1166. struct lpfc_hba *phba;
  1167. struct lpfc_sli *psli;
  1168. struct lpfc_iocbq *iocbq_entry = NULL, *iocbq_next = NULL;
  1169. unsigned long bar0map_len, bar2map_len;
  1170. int error = -ENODEV, retval;
  1171. int i;
  1172. uint16_t iotag;
  1173. if (pci_enable_device(pdev))
  1174. goto out;
  1175. if (pci_request_regions(pdev, LPFC_DRIVER_NAME))
  1176. goto out_disable_device;
  1177. host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba));
  1178. if (!host)
  1179. goto out_release_regions;
  1180. phba = (struct lpfc_hba*)host->hostdata;
  1181. memset(phba, 0, sizeof (struct lpfc_hba));
  1182. phba->host = host;
  1183. phba->fc_flag |= FC_LOADING;
  1184. phba->pcidev = pdev;
  1185. /* Assign an unused board number */
  1186. if (!idr_pre_get(&lpfc_hba_index, GFP_KERNEL))
  1187. goto out_put_host;
  1188. error = idr_get_new(&lpfc_hba_index, NULL, &phba->brd_no);
  1189. if (error)
  1190. goto out_put_host;
  1191. host->unique_id = phba->brd_no;
  1192. INIT_LIST_HEAD(&phba->ctrspbuflist);
  1193. INIT_LIST_HEAD(&phba->rnidrspbuflist);
  1194. INIT_LIST_HEAD(&phba->freebufList);
  1195. /* Initialize timers used by driver */
  1196. init_timer(&phba->fc_estabtmo);
  1197. phba->fc_estabtmo.function = lpfc_establish_link_tmo;
  1198. phba->fc_estabtmo.data = (unsigned long)phba;
  1199. init_timer(&phba->fc_disctmo);
  1200. phba->fc_disctmo.function = lpfc_disc_timeout;
  1201. phba->fc_disctmo.data = (unsigned long)phba;
  1202. init_timer(&phba->fc_fdmitmo);
  1203. phba->fc_fdmitmo.function = lpfc_fdmi_tmo;
  1204. phba->fc_fdmitmo.data = (unsigned long)phba;
  1205. init_timer(&phba->els_tmofunc);
  1206. phba->els_tmofunc.function = lpfc_els_timeout;
  1207. phba->els_tmofunc.data = (unsigned long)phba;
  1208. psli = &phba->sli;
  1209. init_timer(&psli->mbox_tmo);
  1210. psli->mbox_tmo.function = lpfc_mbox_timeout;
  1211. psli->mbox_tmo.data = (unsigned long)phba;
  1212. /*
  1213. * Get all the module params for configuring this host and then
  1214. * establish the host parameters.
  1215. */
  1216. lpfc_get_cfgparam(phba);
  1217. host->max_id = LPFC_MAX_TARGET;
  1218. host->max_lun = phba->cfg_max_luns;
  1219. host->this_id = -1;
  1220. /* Initialize all internally managed lists. */
  1221. INIT_LIST_HEAD(&phba->fc_nlpmap_list);
  1222. INIT_LIST_HEAD(&phba->fc_nlpunmap_list);
  1223. INIT_LIST_HEAD(&phba->fc_unused_list);
  1224. INIT_LIST_HEAD(&phba->fc_plogi_list);
  1225. INIT_LIST_HEAD(&phba->fc_adisc_list);
  1226. INIT_LIST_HEAD(&phba->fc_reglogin_list);
  1227. INIT_LIST_HEAD(&phba->fc_prli_list);
  1228. INIT_LIST_HEAD(&phba->fc_npr_list);
  1229. pci_set_master(pdev);
  1230. retval = pci_set_mwi(pdev);
  1231. if (retval)
  1232. dev_printk(KERN_WARNING, &pdev->dev,
  1233. "Warning: pci_set_mwi returned %d\n", retval);
  1234. if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0)
  1235. if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0)
  1236. goto out_idr_remove;
  1237. /*
  1238. * Get the bus address of Bar0 and Bar2 and the number of bytes
  1239. * required by each mapping.
  1240. */
  1241. phba->pci_bar0_map = pci_resource_start(phba->pcidev, 0);
  1242. bar0map_len = pci_resource_len(phba->pcidev, 0);
  1243. phba->pci_bar2_map = pci_resource_start(phba->pcidev, 2);
  1244. bar2map_len = pci_resource_len(phba->pcidev, 2);
  1245. /* Map HBA SLIM and Control Registers to a kernel virtual address. */
  1246. phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len);
  1247. phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len);
  1248. /* Allocate memory for SLI-2 structures */
  1249. phba->slim2p = dma_alloc_coherent(&phba->pcidev->dev, SLI2_SLIM_SIZE,
  1250. &phba->slim2p_mapping, GFP_KERNEL);
  1251. if (!phba->slim2p)
  1252. goto out_iounmap;
  1253. memset(phba->slim2p, 0, SLI2_SLIM_SIZE);
  1254. /* Initialize the SLI Layer to run with lpfc HBAs. */
  1255. lpfc_sli_setup(phba);
  1256. lpfc_sli_queue_setup(phba);
  1257. error = lpfc_mem_alloc(phba);
  1258. if (error)
  1259. goto out_free_slim;
  1260. /* Initialize and populate the iocb list per host. */
  1261. INIT_LIST_HEAD(&phba->lpfc_iocb_list);
  1262. for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) {
  1263. iocbq_entry = kmalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL);
  1264. if (iocbq_entry == NULL) {
  1265. printk(KERN_ERR "%s: only allocated %d iocbs of "
  1266. "expected %d count. Unloading driver.\n",
  1267. __FUNCTION__, i, LPFC_IOCB_LIST_CNT);
  1268. error = -ENOMEM;
  1269. goto out_free_iocbq;
  1270. }
  1271. memset(iocbq_entry, 0, sizeof(struct lpfc_iocbq));
  1272. iotag = lpfc_sli_next_iotag(phba, iocbq_entry);
  1273. if (iotag == 0) {
  1274. kfree (iocbq_entry);
  1275. printk(KERN_ERR "%s: failed to allocate IOTAG. "
  1276. "Unloading driver.\n",
  1277. __FUNCTION__);
  1278. error = -ENOMEM;
  1279. goto out_free_iocbq;
  1280. }
  1281. spin_lock_irq(phba->host->host_lock);
  1282. list_add(&iocbq_entry->list, &phba->lpfc_iocb_list);
  1283. phba->total_iocbq_bufs++;
  1284. spin_unlock_irq(phba->host->host_lock);
  1285. }
  1286. /* Initialize HBA structure */
  1287. phba->fc_edtov = FF_DEF_EDTOV;
  1288. phba->fc_ratov = FF_DEF_RATOV;
  1289. phba->fc_altov = FF_DEF_ALTOV;
  1290. phba->fc_arbtov = FF_DEF_ARBTOV;
  1291. INIT_LIST_HEAD(&phba->work_list);
  1292. phba->work_ha_mask = (HA_ERATT|HA_MBATT|HA_LATT);
  1293. phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4));
  1294. /* Startup the kernel thread for this host adapter. */
  1295. phba->worker_thread = kthread_run(lpfc_do_work, phba,
  1296. "lpfc_worker_%d", phba->brd_no);
  1297. if (IS_ERR(phba->worker_thread)) {
  1298. error = PTR_ERR(phba->worker_thread);
  1299. goto out_free_iocbq;
  1300. }
  1301. /* We can rely on a queue depth attribute only after SLI HBA setup */
  1302. host->can_queue = phba->cfg_hba_queue_depth - 10;
  1303. /* Tell the midlayer we support 16 byte commands */
  1304. host->max_cmd_len = 16;
  1305. /* Initialize the list of scsi buffers used by driver for scsi IO. */
  1306. INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list);
  1307. host->transportt = lpfc_transport_template;
  1308. host->hostdata[0] = (unsigned long)phba;
  1309. pci_set_drvdata(pdev, host);
  1310. error = scsi_add_host(host, &pdev->dev);
  1311. if (error)
  1312. goto out_kthread_stop;
  1313. error = lpfc_alloc_sysfs_attr(phba);
  1314. if (error)
  1315. goto out_kthread_stop;
  1316. error = request_irq(phba->pcidev->irq, lpfc_intr_handler, SA_SHIRQ,
  1317. LPFC_DRIVER_NAME, phba);
  1318. if (error) {
  1319. lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
  1320. "%d:0451 Enable interrupt handler failed\n",
  1321. phba->brd_no);
  1322. goto out_free_sysfs_attr;
  1323. }
  1324. phba->MBslimaddr = phba->slim_memmap_p;
  1325. phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET;
  1326. phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET;
  1327. phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET;
  1328. phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET;
  1329. error = lpfc_sli_hba_setup(phba);
  1330. if (error)
  1331. goto out_free_irq;
  1332. /*
  1333. * set fixed host attributes
  1334. * Must done after lpfc_sli_hba_setup()
  1335. */
  1336. fc_host_node_name(host) = wwn_to_u64(phba->fc_nodename.u.wwn);
  1337. fc_host_port_name(host) = wwn_to_u64(phba->fc_portname.u.wwn);
  1338. fc_host_supported_classes(host) = FC_COS_CLASS3;
  1339. memset(fc_host_supported_fc4s(host), 0,
  1340. sizeof(fc_host_supported_fc4s(host)));
  1341. fc_host_supported_fc4s(host)[2] = 1;
  1342. fc_host_supported_fc4s(host)[7] = 1;
  1343. lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(host));
  1344. fc_host_supported_speeds(host) = 0;
  1345. switch (FC_JEDEC_ID(phba->vpd.rev.biuRev)) {
  1346. case VIPER_JEDEC_ID:
  1347. fc_host_supported_speeds(host) |= FC_PORTSPEED_10GBIT;
  1348. break;
  1349. case HELIOS_JEDEC_ID:
  1350. fc_host_supported_speeds(host) |= FC_PORTSPEED_4GBIT;
  1351. /* Fall through */
  1352. case CENTAUR_2G_JEDEC_ID:
  1353. case PEGASUS_JEDEC_ID:
  1354. case THOR_JEDEC_ID:
  1355. fc_host_supported_speeds(host) |= FC_PORTSPEED_2GBIT;
  1356. /* Fall through */
  1357. default:
  1358. fc_host_supported_speeds(host) = FC_PORTSPEED_1GBIT;
  1359. }
  1360. fc_host_maxframe_size(host) =
  1361. ((((uint32_t) phba->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) |
  1362. (uint32_t) phba->fc_sparam.cmn.bbRcvSizeLsb);
  1363. /* This value is also unchanging */
  1364. memset(fc_host_active_fc4s(host), 0,
  1365. sizeof(fc_host_active_fc4s(host)));
  1366. fc_host_active_fc4s(host)[2] = 1;
  1367. fc_host_active_fc4s(host)[7] = 1;
  1368. spin_lock_irq(phba->host->host_lock);
  1369. phba->fc_flag &= ~FC_LOADING;
  1370. spin_unlock_irq(phba->host->host_lock);
  1371. return 0;
  1372. out_free_irq:
  1373. lpfc_stop_timer(phba);
  1374. phba->work_hba_events = 0;
  1375. free_irq(phba->pcidev->irq, phba);
  1376. out_free_sysfs_attr:
  1377. lpfc_free_sysfs_attr(phba);
  1378. out_kthread_stop:
  1379. kthread_stop(phba->worker_thread);
  1380. out_free_iocbq:
  1381. list_for_each_entry_safe(iocbq_entry, iocbq_next,
  1382. &phba->lpfc_iocb_list, list) {
  1383. spin_lock_irq(phba->host->host_lock);
  1384. kfree(iocbq_entry);
  1385. phba->total_iocbq_bufs--;
  1386. spin_unlock_irq(phba->host->host_lock);
  1387. }
  1388. lpfc_mem_free(phba);
  1389. out_free_slim:
  1390. dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, phba->slim2p,
  1391. phba->slim2p_mapping);
  1392. out_iounmap:
  1393. iounmap(phba->ctrl_regs_memmap_p);
  1394. iounmap(phba->slim_memmap_p);
  1395. out_idr_remove:
  1396. idr_remove(&lpfc_hba_index, phba->brd_no);
  1397. out_put_host:
  1398. scsi_host_put(host);
  1399. out_release_regions:
  1400. pci_release_regions(pdev);
  1401. out_disable_device:
  1402. pci_disable_device(pdev);
  1403. out:
  1404. return error;
  1405. }
  1406. static void __devexit
  1407. lpfc_pci_remove_one(struct pci_dev *pdev)
  1408. {
  1409. struct Scsi_Host *host = pci_get_drvdata(pdev);
  1410. struct lpfc_hba *phba = (struct lpfc_hba *)host->hostdata[0];
  1411. unsigned long iflag;
  1412. lpfc_free_sysfs_attr(phba);
  1413. spin_lock_irqsave(phba->host->host_lock, iflag);
  1414. phba->fc_flag |= FC_UNLOADING;
  1415. spin_unlock_irqrestore(phba->host->host_lock, iflag);
  1416. fc_remove_host(phba->host);
  1417. scsi_remove_host(phba->host);
  1418. kthread_stop(phba->worker_thread);
  1419. /*
  1420. * Bring down the SLI Layer. This step disable all interrupts,
  1421. * clears the rings, discards all mailbox commands, and resets
  1422. * the HBA.
  1423. */
  1424. lpfc_sli_hba_down(phba);
  1425. /* Release the irq reservation */
  1426. free_irq(phba->pcidev->irq, phba);
  1427. lpfc_cleanup(phba, 0);
  1428. lpfc_stop_timer(phba);
  1429. phba->work_hba_events = 0;
  1430. /*
  1431. * Call scsi_free before mem_free since scsi bufs are released to their
  1432. * corresponding pools here.
  1433. */
  1434. lpfc_scsi_free(phba);
  1435. lpfc_mem_free(phba);
  1436. /* Free resources associated with SLI2 interface */
  1437. dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE,
  1438. phba->slim2p, phba->slim2p_mapping);
  1439. /* unmap adapter SLIM and Control Registers */
  1440. iounmap(phba->ctrl_regs_memmap_p);
  1441. iounmap(phba->slim_memmap_p);
  1442. pci_release_regions(phba->pcidev);
  1443. pci_disable_device(phba->pcidev);
  1444. idr_remove(&lpfc_hba_index, phba->brd_no);
  1445. scsi_host_put(phba->host);
  1446. pci_set_drvdata(pdev, NULL);
  1447. }
  1448. static struct pci_device_id lpfc_id_table[] = {
  1449. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_VIPER,
  1450. PCI_ANY_ID, PCI_ANY_ID, },
  1451. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_FIREFLY,
  1452. PCI_ANY_ID, PCI_ANY_ID, },
  1453. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_THOR,
  1454. PCI_ANY_ID, PCI_ANY_ID, },
  1455. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PEGASUS,
  1456. PCI_ANY_ID, PCI_ANY_ID, },
  1457. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_CENTAUR,
  1458. PCI_ANY_ID, PCI_ANY_ID, },
  1459. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_DRAGONFLY,
  1460. PCI_ANY_ID, PCI_ANY_ID, },
  1461. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_SUPERFLY,
  1462. PCI_ANY_ID, PCI_ANY_ID, },
  1463. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_RFLY,
  1464. PCI_ANY_ID, PCI_ANY_ID, },
  1465. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY,
  1466. PCI_ANY_ID, PCI_ANY_ID, },
  1467. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS,
  1468. PCI_ANY_ID, PCI_ANY_ID, },
  1469. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID,
  1470. PCI_ANY_ID, PCI_ANY_ID, },
  1471. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB,
  1472. PCI_ANY_ID, PCI_ANY_ID, },
  1473. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR,
  1474. PCI_ANY_ID, PCI_ANY_ID, },
  1475. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID,
  1476. PCI_ANY_ID, PCI_ANY_ID, },
  1477. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB,
  1478. PCI_ANY_ID, PCI_ANY_ID, },
  1479. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_TFLY,
  1480. PCI_ANY_ID, PCI_ANY_ID, },
  1481. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP101,
  1482. PCI_ANY_ID, PCI_ANY_ID, },
  1483. {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S,
  1484. PCI_ANY_ID, PCI_ANY_ID, },
  1485. { 0 }
  1486. };
  1487. MODULE_DEVICE_TABLE(pci, lpfc_id_table);
  1488. static struct pci_driver lpfc_driver = {
  1489. .name = LPFC_DRIVER_NAME,
  1490. .id_table = lpfc_id_table,
  1491. .probe = lpfc_pci_probe_one,
  1492. .remove = __devexit_p(lpfc_pci_remove_one),
  1493. };
  1494. static int __init
  1495. lpfc_init(void)
  1496. {
  1497. int error = 0;
  1498. printk(LPFC_MODULE_DESC "\n");
  1499. printk(LPFC_COPYRIGHT "\n");
  1500. lpfc_transport_template =
  1501. fc_attach_transport(&lpfc_transport_functions);
  1502. if (!lpfc_transport_template)
  1503. return -ENOMEM;
  1504. error = pci_register_driver(&lpfc_driver);
  1505. if (error)
  1506. fc_release_transport(lpfc_transport_template);
  1507. return error;
  1508. }
  1509. static void __exit
  1510. lpfc_exit(void)
  1511. {
  1512. pci_unregister_driver(&lpfc_driver);
  1513. fc_release_transport(lpfc_transport_template);
  1514. }
  1515. module_init(lpfc_init);
  1516. module_exit(lpfc_exit);
  1517. MODULE_LICENSE("GPL");
  1518. MODULE_DESCRIPTION(LPFC_MODULE_DESC);
  1519. MODULE_AUTHOR("Emulex Corporation - tech.support@emulex.com");
  1520. MODULE_VERSION("0:" LPFC_DRIVER_VERSION);