lpfc_init.c 49 KB

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