lpfc_init.c 49 KB

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