lpfc_mbox.c 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2009 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/pci.h>
  23. #include <linux/interrupt.h>
  24. #include <scsi/scsi_device.h>
  25. #include <scsi/scsi_transport_fc.h>
  26. #include <scsi/scsi.h>
  27. #include "lpfc_hw4.h"
  28. #include "lpfc_hw.h"
  29. #include "lpfc_sli.h"
  30. #include "lpfc_sli4.h"
  31. #include "lpfc_nl.h"
  32. #include "lpfc_disc.h"
  33. #include "lpfc_scsi.h"
  34. #include "lpfc.h"
  35. #include "lpfc_logmsg.h"
  36. #include "lpfc_crtn.h"
  37. #include "lpfc_compat.h"
  38. /**
  39. * lpfc_dump_static_vport - Dump HBA's static vport information.
  40. * @phba: pointer to lpfc hba data structure.
  41. * @pmb: pointer to the driver internal queue element for mailbox command.
  42. * @offset: offset for dumping vport info.
  43. *
  44. * The dump mailbox command provides a method for the device driver to obtain
  45. * various types of information from the HBA device.
  46. *
  47. * This routine prepares the mailbox command for dumping list of static
  48. * vports to be created.
  49. **/
  50. void
  51. lpfc_dump_static_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb,
  52. uint16_t offset)
  53. {
  54. MAILBOX_t *mb;
  55. void *ctx;
  56. mb = &pmb->u.mb;
  57. ctx = pmb->context2;
  58. /* Setup to dump vport info region */
  59. memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
  60. mb->mbxCommand = MBX_DUMP_MEMORY;
  61. mb->un.varDmp.cv = 1;
  62. mb->un.varDmp.type = DMP_NV_PARAMS;
  63. mb->un.varDmp.entry_index = offset;
  64. mb->un.varDmp.region_id = DMP_REGION_VPORT;
  65. mb->un.varDmp.word_cnt = DMP_RSP_SIZE/sizeof(uint32_t);
  66. mb->un.varDmp.co = 0;
  67. mb->un.varDmp.resp_offset = 0;
  68. pmb->context2 = ctx;
  69. mb->mbxOwner = OWN_HOST;
  70. return;
  71. }
  72. /**
  73. * lpfc_down_link - Bring down HBAs link.
  74. * @phba: pointer to lpfc hba data structure.
  75. * @pmb: pointer to the driver internal queue element for mailbox command.
  76. *
  77. * This routine prepares a mailbox command to bring down HBA link.
  78. **/
  79. void
  80. lpfc_down_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
  81. {
  82. MAILBOX_t *mb;
  83. memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
  84. mb = &pmb->u.mb;
  85. mb->mbxCommand = MBX_DOWN_LINK;
  86. mb->mbxOwner = OWN_HOST;
  87. }
  88. /**
  89. * lpfc_dump_mem - Prepare a mailbox command for reading a region.
  90. * @phba: pointer to lpfc hba data structure.
  91. * @pmb: pointer to the driver internal queue element for mailbox command.
  92. * @offset: offset into the region.
  93. * @region_id: config region id.
  94. *
  95. * The dump mailbox command provides a method for the device driver to obtain
  96. * various types of information from the HBA device.
  97. *
  98. * This routine prepares the mailbox command for dumping HBA's config region.
  99. **/
  100. void
  101. lpfc_dump_mem(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, uint16_t offset,
  102. uint16_t region_id)
  103. {
  104. MAILBOX_t *mb;
  105. void *ctx;
  106. mb = &pmb->u.mb;
  107. ctx = pmb->context2;
  108. /* Setup to dump VPD region */
  109. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  110. mb->mbxCommand = MBX_DUMP_MEMORY;
  111. mb->un.varDmp.cv = 1;
  112. mb->un.varDmp.type = DMP_NV_PARAMS;
  113. mb->un.varDmp.entry_index = offset;
  114. mb->un.varDmp.region_id = region_id;
  115. mb->un.varDmp.word_cnt = (DMP_RSP_SIZE / sizeof (uint32_t));
  116. mb->un.varDmp.co = 0;
  117. mb->un.varDmp.resp_offset = 0;
  118. pmb->context2 = ctx;
  119. mb->mbxOwner = OWN_HOST;
  120. return;
  121. }
  122. /**
  123. * lpfc_dump_wakeup_param - Prepare mailbox command for retrieving wakeup params
  124. * @phba: pointer to lpfc hba data structure.
  125. * @pmb: pointer to the driver internal queue element for mailbox command.
  126. *
  127. * This function create a dump memory mailbox command to dump wake up
  128. * parameters.
  129. */
  130. void
  131. lpfc_dump_wakeup_param(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
  132. {
  133. MAILBOX_t *mb;
  134. void *ctx;
  135. mb = &pmb->u.mb;
  136. /* Save context so that we can restore after memset */
  137. ctx = pmb->context2;
  138. /* Setup to dump VPD region */
  139. memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
  140. mb->mbxCommand = MBX_DUMP_MEMORY;
  141. mb->mbxOwner = OWN_HOST;
  142. mb->un.varDmp.cv = 1;
  143. mb->un.varDmp.type = DMP_NV_PARAMS;
  144. mb->un.varDmp.entry_index = 0;
  145. mb->un.varDmp.region_id = WAKE_UP_PARMS_REGION_ID;
  146. mb->un.varDmp.word_cnt = WAKE_UP_PARMS_WORD_SIZE;
  147. mb->un.varDmp.co = 0;
  148. mb->un.varDmp.resp_offset = 0;
  149. pmb->context2 = ctx;
  150. return;
  151. }
  152. /**
  153. * lpfc_read_nv - Prepare a mailbox command for reading HBA's NVRAM param
  154. * @phba: pointer to lpfc hba data structure.
  155. * @pmb: pointer to the driver internal queue element for mailbox command.
  156. *
  157. * The read NVRAM mailbox command returns the HBA's non-volatile parameters
  158. * that are used as defaults when the Fibre Channel link is brought on-line.
  159. *
  160. * This routine prepares the mailbox command for reading information stored
  161. * in the HBA's NVRAM. Specifically, the HBA's WWNN and WWPN.
  162. **/
  163. void
  164. lpfc_read_nv(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  165. {
  166. MAILBOX_t *mb;
  167. mb = &pmb->u.mb;
  168. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  169. mb->mbxCommand = MBX_READ_NV;
  170. mb->mbxOwner = OWN_HOST;
  171. return;
  172. }
  173. /**
  174. * lpfc_config_async - Prepare a mailbox command for enabling HBA async event
  175. * @phba: pointer to lpfc hba data structure.
  176. * @pmb: pointer to the driver internal queue element for mailbox command.
  177. * @ring: ring number for the asynchronous event to be configured.
  178. *
  179. * The asynchronous event enable mailbox command is used to enable the
  180. * asynchronous event posting via the ASYNC_STATUS_CN IOCB response and
  181. * specifies the default ring to which events are posted.
  182. *
  183. * This routine prepares the mailbox command for enabling HBA asynchronous
  184. * event support on a IOCB ring.
  185. **/
  186. void
  187. lpfc_config_async(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb,
  188. uint32_t ring)
  189. {
  190. MAILBOX_t *mb;
  191. mb = &pmb->u.mb;
  192. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  193. mb->mbxCommand = MBX_ASYNCEVT_ENABLE;
  194. mb->un.varCfgAsyncEvent.ring = ring;
  195. mb->mbxOwner = OWN_HOST;
  196. return;
  197. }
  198. /**
  199. * lpfc_heart_beat - Prepare a mailbox command for heart beat
  200. * @phba: pointer to lpfc hba data structure.
  201. * @pmb: pointer to the driver internal queue element for mailbox command.
  202. *
  203. * The heart beat mailbox command is used to detect an unresponsive HBA, which
  204. * is defined as any device where no error attention is sent and both mailbox
  205. * and rings are not processed.
  206. *
  207. * This routine prepares the mailbox command for issuing a heart beat in the
  208. * form of mailbox command to the HBA. The timely completion of the heart
  209. * beat mailbox command indicates the health of the HBA.
  210. **/
  211. void
  212. lpfc_heart_beat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  213. {
  214. MAILBOX_t *mb;
  215. mb = &pmb->u.mb;
  216. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  217. mb->mbxCommand = MBX_HEARTBEAT;
  218. mb->mbxOwner = OWN_HOST;
  219. return;
  220. }
  221. /**
  222. * lpfc_read_la - Prepare a mailbox command for reading HBA link attention
  223. * @phba: pointer to lpfc hba data structure.
  224. * @pmb: pointer to the driver internal queue element for mailbox command.
  225. * @mp: DMA buffer memory for reading the link attention information into.
  226. *
  227. * The read link attention mailbox command is issued to read the Link Event
  228. * Attention information indicated by the HBA port when the Link Event bit
  229. * of the Host Attention (HSTATT) register is set to 1. A Link Event
  230. * Attention occurs based on an exception detected at the Fibre Channel link
  231. * interface.
  232. *
  233. * This routine prepares the mailbox command for reading HBA link attention
  234. * information. A DMA memory has been set aside and address passed to the
  235. * HBA through @mp for the HBA to DMA link attention information into the
  236. * memory as part of the execution of the mailbox command.
  237. *
  238. * Return codes
  239. * 0 - Success (currently always return 0)
  240. **/
  241. int
  242. lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, struct lpfc_dmabuf *mp)
  243. {
  244. MAILBOX_t *mb;
  245. struct lpfc_sli *psli;
  246. psli = &phba->sli;
  247. mb = &pmb->u.mb;
  248. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  249. INIT_LIST_HEAD(&mp->list);
  250. mb->mbxCommand = MBX_READ_LA64;
  251. mb->un.varReadLA.un.lilpBde64.tus.f.bdeSize = 128;
  252. mb->un.varReadLA.un.lilpBde64.addrHigh = putPaddrHigh(mp->phys);
  253. mb->un.varReadLA.un.lilpBde64.addrLow = putPaddrLow(mp->phys);
  254. /* Save address for later completion and set the owner to host so that
  255. * the FW knows this mailbox is available for processing.
  256. */
  257. pmb->context1 = (uint8_t *) mp;
  258. mb->mbxOwner = OWN_HOST;
  259. return (0);
  260. }
  261. /**
  262. * lpfc_clear_la - Prepare a mailbox command for clearing HBA link attention
  263. * @phba: pointer to lpfc hba data structure.
  264. * @pmb: pointer to the driver internal queue element for mailbox command.
  265. *
  266. * The clear link attention mailbox command is issued to clear the link event
  267. * attention condition indicated by the Link Event bit of the Host Attention
  268. * (HSTATT) register. The link event attention condition is cleared only if
  269. * the event tag specified matches that of the current link event counter.
  270. * The current event tag is read using the read link attention event mailbox
  271. * command.
  272. *
  273. * This routine prepares the mailbox command for clearing HBA link attention
  274. * information.
  275. **/
  276. void
  277. lpfc_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  278. {
  279. MAILBOX_t *mb;
  280. mb = &pmb->u.mb;
  281. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  282. mb->un.varClearLA.eventTag = phba->fc_eventTag;
  283. mb->mbxCommand = MBX_CLEAR_LA;
  284. mb->mbxOwner = OWN_HOST;
  285. return;
  286. }
  287. /**
  288. * lpfc_config_link - Prepare a mailbox command for configuring link on a HBA
  289. * @phba: pointer to lpfc hba data structure.
  290. * @pmb: pointer to the driver internal queue element for mailbox command.
  291. *
  292. * The configure link mailbox command is used before the initialize link
  293. * mailbox command to override default value and to configure link-oriented
  294. * parameters such as DID address and various timers. Typically, this
  295. * command would be used after an F_Port login to set the returned DID address
  296. * and the fabric timeout values. This command is not valid before a configure
  297. * port command has configured the HBA port.
  298. *
  299. * This routine prepares the mailbox command for configuring link on a HBA.
  300. **/
  301. void
  302. lpfc_config_link(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  303. {
  304. struct lpfc_vport *vport = phba->pport;
  305. MAILBOX_t *mb = &pmb->u.mb;
  306. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  307. /* NEW_FEATURE
  308. * SLI-2, Coalescing Response Feature.
  309. */
  310. if (phba->cfg_cr_delay) {
  311. mb->un.varCfgLnk.cr = 1;
  312. mb->un.varCfgLnk.ci = 1;
  313. mb->un.varCfgLnk.cr_delay = phba->cfg_cr_delay;
  314. mb->un.varCfgLnk.cr_count = phba->cfg_cr_count;
  315. }
  316. mb->un.varCfgLnk.myId = vport->fc_myDID;
  317. mb->un.varCfgLnk.edtov = phba->fc_edtov;
  318. mb->un.varCfgLnk.arbtov = phba->fc_arbtov;
  319. mb->un.varCfgLnk.ratov = phba->fc_ratov;
  320. mb->un.varCfgLnk.rttov = phba->fc_rttov;
  321. mb->un.varCfgLnk.altov = phba->fc_altov;
  322. mb->un.varCfgLnk.crtov = phba->fc_crtov;
  323. mb->un.varCfgLnk.citov = phba->fc_citov;
  324. if (phba->cfg_ack0)
  325. mb->un.varCfgLnk.ack0_enable = 1;
  326. mb->mbxCommand = MBX_CONFIG_LINK;
  327. mb->mbxOwner = OWN_HOST;
  328. return;
  329. }
  330. /**
  331. * lpfc_config_msi - Prepare a mailbox command for configuring msi-x
  332. * @phba: pointer to lpfc hba data structure.
  333. * @pmb: pointer to the driver internal queue element for mailbox command.
  334. *
  335. * The configure MSI-X mailbox command is used to configure the HBA's SLI-3
  336. * MSI-X multi-message interrupt vector association to interrupt attention
  337. * conditions.
  338. *
  339. * Return codes
  340. * 0 - Success
  341. * -EINVAL - Failure
  342. **/
  343. int
  344. lpfc_config_msi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
  345. {
  346. MAILBOX_t *mb = &pmb->u.mb;
  347. uint32_t attentionConditions[2];
  348. /* Sanity check */
  349. if (phba->cfg_use_msi != 2) {
  350. lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
  351. "0475 Not configured for supporting MSI-X "
  352. "cfg_use_msi: 0x%x\n", phba->cfg_use_msi);
  353. return -EINVAL;
  354. }
  355. if (phba->sli_rev < 3) {
  356. lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
  357. "0476 HBA not supporting SLI-3 or later "
  358. "SLI Revision: 0x%x\n", phba->sli_rev);
  359. return -EINVAL;
  360. }
  361. /* Clear mailbox command fields */
  362. memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
  363. /*
  364. * SLI-3, Message Signaled Interrupt Fearure.
  365. */
  366. /* Multi-message attention configuration */
  367. attentionConditions[0] = (HA_R0ATT | HA_R1ATT | HA_R2ATT | HA_ERATT |
  368. HA_LATT | HA_MBATT);
  369. attentionConditions[1] = 0;
  370. mb->un.varCfgMSI.attentionConditions[0] = attentionConditions[0];
  371. mb->un.varCfgMSI.attentionConditions[1] = attentionConditions[1];
  372. /*
  373. * Set up message number to HA bit association
  374. */
  375. #ifdef __BIG_ENDIAN_BITFIELD
  376. /* RA0 (FCP Ring) */
  377. mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS] = 1;
  378. /* RA1 (Other Protocol Extra Ring) */
  379. mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS] = 1;
  380. #else /* __LITTLE_ENDIAN_BITFIELD */
  381. /* RA0 (FCP Ring) */
  382. mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS^3] = 1;
  383. /* RA1 (Other Protocol Extra Ring) */
  384. mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS^3] = 1;
  385. #endif
  386. /* Multi-message interrupt autoclear configuration*/
  387. mb->un.varCfgMSI.autoClearHA[0] = attentionConditions[0];
  388. mb->un.varCfgMSI.autoClearHA[1] = attentionConditions[1];
  389. /* For now, HBA autoclear does not work reliably, disable it */
  390. mb->un.varCfgMSI.autoClearHA[0] = 0;
  391. mb->un.varCfgMSI.autoClearHA[1] = 0;
  392. /* Set command and owner bit */
  393. mb->mbxCommand = MBX_CONFIG_MSI;
  394. mb->mbxOwner = OWN_HOST;
  395. return 0;
  396. }
  397. /**
  398. * lpfc_init_link - Prepare a mailbox command for initialize link on a HBA
  399. * @phba: pointer to lpfc hba data structure.
  400. * @pmb: pointer to the driver internal queue element for mailbox command.
  401. * @topology: the link topology for the link to be initialized to.
  402. * @linkspeed: the link speed for the link to be initialized to.
  403. *
  404. * The initialize link mailbox command is used to initialize the Fibre
  405. * Channel link. This command must follow a configure port command that
  406. * establishes the mode of operation.
  407. *
  408. * This routine prepares the mailbox command for initializing link on a HBA
  409. * with the specified link topology and speed.
  410. **/
  411. void
  412. lpfc_init_link(struct lpfc_hba * phba,
  413. LPFC_MBOXQ_t * pmb, uint32_t topology, uint32_t linkspeed)
  414. {
  415. lpfc_vpd_t *vpd;
  416. struct lpfc_sli *psli;
  417. MAILBOX_t *mb;
  418. mb = &pmb->u.mb;
  419. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  420. psli = &phba->sli;
  421. switch (topology) {
  422. case FLAGS_TOPOLOGY_MODE_LOOP_PT:
  423. mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
  424. mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER;
  425. break;
  426. case FLAGS_TOPOLOGY_MODE_PT_PT:
  427. mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT;
  428. break;
  429. case FLAGS_TOPOLOGY_MODE_LOOP:
  430. mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP;
  431. break;
  432. case FLAGS_TOPOLOGY_MODE_PT_LOOP:
  433. mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT;
  434. mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER;
  435. break;
  436. case FLAGS_LOCAL_LB:
  437. mb->un.varInitLnk.link_flags = FLAGS_LOCAL_LB;
  438. break;
  439. }
  440. /* Enable asynchronous ABTS responses from firmware */
  441. mb->un.varInitLnk.link_flags |= FLAGS_IMED_ABORT;
  442. /* NEW_FEATURE
  443. * Setting up the link speed
  444. */
  445. vpd = &phba->vpd;
  446. if (vpd->rev.feaLevelHigh >= 0x02){
  447. switch(linkspeed){
  448. case LINK_SPEED_1G:
  449. case LINK_SPEED_2G:
  450. case LINK_SPEED_4G:
  451. case LINK_SPEED_8G:
  452. mb->un.varInitLnk.link_flags |=
  453. FLAGS_LINK_SPEED;
  454. mb->un.varInitLnk.link_speed = linkspeed;
  455. break;
  456. case LINK_SPEED_AUTO:
  457. default:
  458. mb->un.varInitLnk.link_speed =
  459. LINK_SPEED_AUTO;
  460. break;
  461. }
  462. }
  463. else
  464. mb->un.varInitLnk.link_speed = LINK_SPEED_AUTO;
  465. mb->mbxCommand = (volatile uint8_t)MBX_INIT_LINK;
  466. mb->mbxOwner = OWN_HOST;
  467. mb->un.varInitLnk.fabric_AL_PA = phba->fc_pref_ALPA;
  468. return;
  469. }
  470. /**
  471. * lpfc_read_sparam - Prepare a mailbox command for reading HBA parameters
  472. * @phba: pointer to lpfc hba data structure.
  473. * @pmb: pointer to the driver internal queue element for mailbox command.
  474. * @vpi: virtual N_Port identifier.
  475. *
  476. * The read service parameter mailbox command is used to read the HBA port
  477. * service parameters. The service parameters are read into the buffer
  478. * specified directly by a BDE in the mailbox command. These service
  479. * parameters may then be used to build the payload of an N_Port/F_POrt
  480. * login request and reply (LOGI/ACC).
  481. *
  482. * This routine prepares the mailbox command for reading HBA port service
  483. * parameters. The DMA memory is allocated in this function and the addresses
  484. * are populated into the mailbox command for the HBA to DMA the service
  485. * parameters into.
  486. *
  487. * Return codes
  488. * 0 - Success
  489. * 1 - DMA memory allocation failed
  490. **/
  491. int
  492. lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi)
  493. {
  494. struct lpfc_dmabuf *mp;
  495. MAILBOX_t *mb;
  496. struct lpfc_sli *psli;
  497. psli = &phba->sli;
  498. mb = &pmb->u.mb;
  499. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  500. mb->mbxOwner = OWN_HOST;
  501. /* Get a buffer to hold the HBAs Service Parameters */
  502. mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
  503. if (mp)
  504. mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
  505. if (!mp || !mp->virt) {
  506. kfree(mp);
  507. mb->mbxCommand = MBX_READ_SPARM64;
  508. /* READ_SPARAM: no buffers */
  509. lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
  510. "0301 READ_SPARAM: no buffers\n");
  511. return (1);
  512. }
  513. INIT_LIST_HEAD(&mp->list);
  514. mb->mbxCommand = MBX_READ_SPARM64;
  515. mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
  516. mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys);
  517. mb->un.varRdSparm.un.sp64.addrLow = putPaddrLow(mp->phys);
  518. mb->un.varRdSparm.vpi = vpi + phba->vpi_base;
  519. /* save address for completion */
  520. pmb->context1 = mp;
  521. return (0);
  522. }
  523. /**
  524. * lpfc_unreg_did - Prepare a mailbox command for unregistering DID
  525. * @phba: pointer to lpfc hba data structure.
  526. * @vpi: virtual N_Port identifier.
  527. * @did: remote port identifier.
  528. * @pmb: pointer to the driver internal queue element for mailbox command.
  529. *
  530. * The unregister DID mailbox command is used to unregister an N_Port/F_Port
  531. * login for an unknown RPI by specifying the DID of a remote port. This
  532. * command frees an RPI context in the HBA port. This has the effect of
  533. * performing an implicit N_Port/F_Port logout.
  534. *
  535. * This routine prepares the mailbox command for unregistering a remote
  536. * N_Port/F_Port (DID) login.
  537. **/
  538. void
  539. lpfc_unreg_did(struct lpfc_hba * phba, uint16_t vpi, uint32_t did,
  540. LPFC_MBOXQ_t * pmb)
  541. {
  542. MAILBOX_t *mb;
  543. mb = &pmb->u.mb;
  544. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  545. mb->un.varUnregDID.did = did;
  546. if (vpi != 0xffff)
  547. vpi += phba->vpi_base;
  548. mb->un.varUnregDID.vpi = vpi;
  549. mb->mbxCommand = MBX_UNREG_D_ID;
  550. mb->mbxOwner = OWN_HOST;
  551. return;
  552. }
  553. /**
  554. * lpfc_read_config - Prepare a mailbox command for reading HBA configuration
  555. * @phba: pointer to lpfc hba data structure.
  556. * @pmb: pointer to the driver internal queue element for mailbox command.
  557. *
  558. * The read configuration mailbox command is used to read the HBA port
  559. * configuration parameters. This mailbox command provides a method for
  560. * seeing any parameters that may have changed via various configuration
  561. * mailbox commands.
  562. *
  563. * This routine prepares the mailbox command for reading out HBA configuration
  564. * parameters.
  565. **/
  566. void
  567. lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  568. {
  569. MAILBOX_t *mb;
  570. mb = &pmb->u.mb;
  571. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  572. mb->mbxCommand = MBX_READ_CONFIG;
  573. mb->mbxOwner = OWN_HOST;
  574. return;
  575. }
  576. /**
  577. * lpfc_read_lnk_stat - Prepare a mailbox command for reading HBA link stats
  578. * @phba: pointer to lpfc hba data structure.
  579. * @pmb: pointer to the driver internal queue element for mailbox command.
  580. *
  581. * The read link status mailbox command is used to read the link status from
  582. * the HBA. Link status includes all link-related error counters. These
  583. * counters are maintained by the HBA and originated in the link hardware
  584. * unit. Note that all of these counters wrap.
  585. *
  586. * This routine prepares the mailbox command for reading out HBA link status.
  587. **/
  588. void
  589. lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  590. {
  591. MAILBOX_t *mb;
  592. mb = &pmb->u.mb;
  593. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  594. mb->mbxCommand = MBX_READ_LNK_STAT;
  595. mb->mbxOwner = OWN_HOST;
  596. return;
  597. }
  598. /**
  599. * lpfc_reg_rpi - Prepare a mailbox command for registering remote login
  600. * @phba: pointer to lpfc hba data structure.
  601. * @vpi: virtual N_Port identifier.
  602. * @did: remote port identifier.
  603. * @param: pointer to memory holding the server parameters.
  604. * @pmb: pointer to the driver internal queue element for mailbox command.
  605. * @flag: action flag to be passed back for the complete function.
  606. *
  607. * The registration login mailbox command is used to register an N_Port or
  608. * F_Port login. This registration allows the HBA to cache the remote N_Port
  609. * service parameters internally and thereby make the appropriate FC-2
  610. * decisions. The remote port service parameters are handed off by the driver
  611. * to the HBA using a descriptor entry that directly identifies a buffer in
  612. * host memory. In exchange, the HBA returns an RPI identifier.
  613. *
  614. * This routine prepares the mailbox command for registering remote port login.
  615. * The function allocates DMA buffer for passing the service parameters to the
  616. * HBA with the mailbox command.
  617. *
  618. * Return codes
  619. * 0 - Success
  620. * 1 - DMA memory allocation failed
  621. **/
  622. int
  623. lpfc_reg_rpi(struct lpfc_hba *phba, uint16_t vpi, uint32_t did,
  624. uint8_t *param, LPFC_MBOXQ_t *pmb, uint32_t flag)
  625. {
  626. MAILBOX_t *mb = &pmb->u.mb;
  627. uint8_t *sparam;
  628. struct lpfc_dmabuf *mp;
  629. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  630. mb->un.varRegLogin.rpi = 0;
  631. if (phba->sli_rev == LPFC_SLI_REV4) {
  632. mb->un.varRegLogin.rpi = lpfc_sli4_alloc_rpi(phba);
  633. if (mb->un.varRegLogin.rpi == LPFC_RPI_ALLOC_ERROR)
  634. return 1;
  635. }
  636. mb->un.varRegLogin.vpi = vpi + phba->vpi_base;
  637. mb->un.varRegLogin.did = did;
  638. mb->un.varWords[30] = flag; /* Set flag to issue action on cmpl */
  639. mb->mbxOwner = OWN_HOST;
  640. /* Get a buffer to hold NPorts Service Parameters */
  641. mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL);
  642. if (mp)
  643. mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
  644. if (!mp || !mp->virt) {
  645. kfree(mp);
  646. mb->mbxCommand = MBX_REG_LOGIN64;
  647. /* REG_LOGIN: no buffers */
  648. lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
  649. "0302 REG_LOGIN: no buffers, VPI:%d DID:x%x, "
  650. "flag x%x\n", vpi, did, flag);
  651. return (1);
  652. }
  653. INIT_LIST_HEAD(&mp->list);
  654. sparam = mp->virt;
  655. /* Copy param's into a new buffer */
  656. memcpy(sparam, param, sizeof (struct serv_parm));
  657. /* save address for completion */
  658. pmb->context1 = (uint8_t *) mp;
  659. mb->mbxCommand = MBX_REG_LOGIN64;
  660. mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm);
  661. mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys);
  662. mb->un.varRegLogin.un.sp64.addrLow = putPaddrLow(mp->phys);
  663. return (0);
  664. }
  665. /**
  666. * lpfc_unreg_login - Prepare a mailbox command for unregistering remote login
  667. * @phba: pointer to lpfc hba data structure.
  668. * @vpi: virtual N_Port identifier.
  669. * @rpi: remote port identifier
  670. * @pmb: pointer to the driver internal queue element for mailbox command.
  671. *
  672. * The unregistration login mailbox command is used to unregister an N_Port
  673. * or F_Port login. This command frees an RPI context in the HBA. It has the
  674. * effect of performing an implicit N_Port/F_Port logout.
  675. *
  676. * This routine prepares the mailbox command for unregistering remote port
  677. * login.
  678. **/
  679. void
  680. lpfc_unreg_login(struct lpfc_hba *phba, uint16_t vpi, uint32_t rpi,
  681. LPFC_MBOXQ_t * pmb)
  682. {
  683. MAILBOX_t *mb;
  684. mb = &pmb->u.mb;
  685. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  686. mb->un.varUnregLogin.rpi = (uint16_t) rpi;
  687. mb->un.varUnregLogin.rsvd1 = 0;
  688. mb->un.varUnregLogin.vpi = vpi + phba->vpi_base;
  689. mb->mbxCommand = MBX_UNREG_LOGIN;
  690. mb->mbxOwner = OWN_HOST;
  691. return;
  692. }
  693. /**
  694. * lpfc_reg_vpi - Prepare a mailbox command for registering vport identifier
  695. * @phba: pointer to lpfc hba data structure.
  696. * @vpi: virtual N_Port identifier.
  697. * @sid: Fibre Channel S_ID (N_Port_ID assigned to a virtual N_Port).
  698. * @pmb: pointer to the driver internal queue element for mailbox command.
  699. *
  700. * The registration vport identifier mailbox command is used to activate a
  701. * virtual N_Port after it has acquired an N_Port_ID. The HBA validates the
  702. * N_Port_ID against the information in the selected virtual N_Port context
  703. * block and marks it active to allow normal processing of IOCB commands and
  704. * received unsolicited exchanges.
  705. *
  706. * This routine prepares the mailbox command for registering a virtual N_Port.
  707. **/
  708. void
  709. lpfc_reg_vpi(struct lpfc_vport *vport, LPFC_MBOXQ_t *pmb)
  710. {
  711. MAILBOX_t *mb = &pmb->u.mb;
  712. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  713. mb->un.varRegVpi.vpi = vport->vpi + vport->phba->vpi_base;
  714. mb->un.varRegVpi.sid = vport->fc_myDID;
  715. mb->un.varRegVpi.vfi = vport->vfi + vport->phba->vfi_base;
  716. mb->mbxCommand = MBX_REG_VPI;
  717. mb->mbxOwner = OWN_HOST;
  718. return;
  719. }
  720. /**
  721. * lpfc_unreg_vpi - Prepare a mailbox command for unregistering vport id
  722. * @phba: pointer to lpfc hba data structure.
  723. * @vpi: virtual N_Port identifier.
  724. * @pmb: pointer to the driver internal queue element for mailbox command.
  725. *
  726. * The unregistration vport identifier mailbox command is used to inactivate
  727. * a virtual N_Port. The driver must have logged out and unregistered all
  728. * remote N_Ports to abort any activity on the virtual N_Port. The HBA will
  729. * unregisters any default RPIs associated with the specified vpi, aborting
  730. * any active exchanges. The HBA will post the mailbox response after making
  731. * the virtual N_Port inactive.
  732. *
  733. * This routine prepares the mailbox command for unregistering a virtual
  734. * N_Port.
  735. **/
  736. void
  737. lpfc_unreg_vpi(struct lpfc_hba *phba, uint16_t vpi, LPFC_MBOXQ_t *pmb)
  738. {
  739. MAILBOX_t *mb = &pmb->u.mb;
  740. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  741. mb->un.varUnregVpi.vpi = vpi + phba->vpi_base;
  742. mb->mbxCommand = MBX_UNREG_VPI;
  743. mb->mbxOwner = OWN_HOST;
  744. return;
  745. }
  746. /**
  747. * lpfc_config_pcb_setup - Set up IOCB rings in the Port Control Block (PCB)
  748. * @phba: pointer to lpfc hba data structure.
  749. *
  750. * This routine sets up and initializes the IOCB rings in the Port Control
  751. * Block (PCB).
  752. **/
  753. static void
  754. lpfc_config_pcb_setup(struct lpfc_hba * phba)
  755. {
  756. struct lpfc_sli *psli = &phba->sli;
  757. struct lpfc_sli_ring *pring;
  758. PCB_t *pcbp = phba->pcb;
  759. dma_addr_t pdma_addr;
  760. uint32_t offset;
  761. uint32_t iocbCnt = 0;
  762. int i;
  763. pcbp->maxRing = (psli->num_rings - 1);
  764. for (i = 0; i < psli->num_rings; i++) {
  765. pring = &psli->ring[i];
  766. pring->sizeCiocb = phba->sli_rev == 3 ? SLI3_IOCB_CMD_SIZE:
  767. SLI2_IOCB_CMD_SIZE;
  768. pring->sizeRiocb = phba->sli_rev == 3 ? SLI3_IOCB_RSP_SIZE:
  769. SLI2_IOCB_RSP_SIZE;
  770. /* A ring MUST have both cmd and rsp entries defined to be
  771. valid */
  772. if ((pring->numCiocb == 0) || (pring->numRiocb == 0)) {
  773. pcbp->rdsc[i].cmdEntries = 0;
  774. pcbp->rdsc[i].rspEntries = 0;
  775. pcbp->rdsc[i].cmdAddrHigh = 0;
  776. pcbp->rdsc[i].rspAddrHigh = 0;
  777. pcbp->rdsc[i].cmdAddrLow = 0;
  778. pcbp->rdsc[i].rspAddrLow = 0;
  779. pring->cmdringaddr = NULL;
  780. pring->rspringaddr = NULL;
  781. continue;
  782. }
  783. /* Command ring setup for ring */
  784. pring->cmdringaddr = (void *)&phba->IOCBs[iocbCnt];
  785. pcbp->rdsc[i].cmdEntries = pring->numCiocb;
  786. offset = (uint8_t *) &phba->IOCBs[iocbCnt] -
  787. (uint8_t *) phba->slim2p.virt;
  788. pdma_addr = phba->slim2p.phys + offset;
  789. pcbp->rdsc[i].cmdAddrHigh = putPaddrHigh(pdma_addr);
  790. pcbp->rdsc[i].cmdAddrLow = putPaddrLow(pdma_addr);
  791. iocbCnt += pring->numCiocb;
  792. /* Response ring setup for ring */
  793. pring->rspringaddr = (void *) &phba->IOCBs[iocbCnt];
  794. pcbp->rdsc[i].rspEntries = pring->numRiocb;
  795. offset = (uint8_t *)&phba->IOCBs[iocbCnt] -
  796. (uint8_t *)phba->slim2p.virt;
  797. pdma_addr = phba->slim2p.phys + offset;
  798. pcbp->rdsc[i].rspAddrHigh = putPaddrHigh(pdma_addr);
  799. pcbp->rdsc[i].rspAddrLow = putPaddrLow(pdma_addr);
  800. iocbCnt += pring->numRiocb;
  801. }
  802. }
  803. /**
  804. * lpfc_read_rev - Prepare a mailbox command for reading HBA revision
  805. * @phba: pointer to lpfc hba data structure.
  806. * @pmb: pointer to the driver internal queue element for mailbox command.
  807. *
  808. * The read revision mailbox command is used to read the revision levels of
  809. * the HBA components. These components include hardware units, resident
  810. * firmware, and available firmware. HBAs that supports SLI-3 mode of
  811. * operation provide different response information depending on the version
  812. * requested by the driver.
  813. *
  814. * This routine prepares the mailbox command for reading HBA revision
  815. * information.
  816. **/
  817. void
  818. lpfc_read_rev(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  819. {
  820. MAILBOX_t *mb = &pmb->u.mb;
  821. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  822. mb->un.varRdRev.cv = 1;
  823. mb->un.varRdRev.v3req = 1; /* Request SLI3 info */
  824. mb->mbxCommand = MBX_READ_REV;
  825. mb->mbxOwner = OWN_HOST;
  826. return;
  827. }
  828. /**
  829. * lpfc_build_hbq_profile2 - Set up the HBQ Selection Profile 2
  830. * @hbqmb: pointer to the HBQ configuration data structure in mailbox command.
  831. * @hbq_desc: pointer to the HBQ selection profile descriptor.
  832. *
  833. * The Host Buffer Queue (HBQ) Selection Profile 2 specifies that the HBA
  834. * tests the incoming frames' R_CTL/TYPE fields with works 10:15 and performs
  835. * the Sequence Length Test using the fields in the Selection Profile 2
  836. * extension in words 20:31.
  837. **/
  838. static void
  839. lpfc_build_hbq_profile2(struct config_hbq_var *hbqmb,
  840. struct lpfc_hbq_init *hbq_desc)
  841. {
  842. hbqmb->profiles.profile2.seqlenbcnt = hbq_desc->seqlenbcnt;
  843. hbqmb->profiles.profile2.maxlen = hbq_desc->maxlen;
  844. hbqmb->profiles.profile2.seqlenoff = hbq_desc->seqlenoff;
  845. }
  846. /**
  847. * lpfc_build_hbq_profile3 - Set up the HBQ Selection Profile 3
  848. * @hbqmb: pointer to the HBQ configuration data structure in mailbox command.
  849. * @hbq_desc: pointer to the HBQ selection profile descriptor.
  850. *
  851. * The Host Buffer Queue (HBQ) Selection Profile 3 specifies that the HBA
  852. * tests the incoming frame's R_CTL/TYPE fields with words 10:15 and performs
  853. * the Sequence Length Test and Byte Field Test using the fields in the
  854. * Selection Profile 3 extension in words 20:31.
  855. **/
  856. static void
  857. lpfc_build_hbq_profile3(struct config_hbq_var *hbqmb,
  858. struct lpfc_hbq_init *hbq_desc)
  859. {
  860. hbqmb->profiles.profile3.seqlenbcnt = hbq_desc->seqlenbcnt;
  861. hbqmb->profiles.profile3.maxlen = hbq_desc->maxlen;
  862. hbqmb->profiles.profile3.cmdcodeoff = hbq_desc->cmdcodeoff;
  863. hbqmb->profiles.profile3.seqlenoff = hbq_desc->seqlenoff;
  864. memcpy(&hbqmb->profiles.profile3.cmdmatch, hbq_desc->cmdmatch,
  865. sizeof(hbqmb->profiles.profile3.cmdmatch));
  866. }
  867. /**
  868. * lpfc_build_hbq_profile5 - Set up the HBQ Selection Profile 5
  869. * @hbqmb: pointer to the HBQ configuration data structure in mailbox command.
  870. * @hbq_desc: pointer to the HBQ selection profile descriptor.
  871. *
  872. * The Host Buffer Queue (HBQ) Selection Profile 5 specifies a header HBQ. The
  873. * HBA tests the initial frame of an incoming sequence using the frame's
  874. * R_CTL/TYPE fields with words 10:15 and performs the Sequence Length Test
  875. * and Byte Field Test using the fields in the Selection Profile 5 extension
  876. * words 20:31.
  877. **/
  878. static void
  879. lpfc_build_hbq_profile5(struct config_hbq_var *hbqmb,
  880. struct lpfc_hbq_init *hbq_desc)
  881. {
  882. hbqmb->profiles.profile5.seqlenbcnt = hbq_desc->seqlenbcnt;
  883. hbqmb->profiles.profile5.maxlen = hbq_desc->maxlen;
  884. hbqmb->profiles.profile5.cmdcodeoff = hbq_desc->cmdcodeoff;
  885. hbqmb->profiles.profile5.seqlenoff = hbq_desc->seqlenoff;
  886. memcpy(&hbqmb->profiles.profile5.cmdmatch, hbq_desc->cmdmatch,
  887. sizeof(hbqmb->profiles.profile5.cmdmatch));
  888. }
  889. /**
  890. * lpfc_config_hbq - Prepare a mailbox command for configuring an HBQ
  891. * @phba: pointer to lpfc hba data structure.
  892. * @id: HBQ identifier.
  893. * @hbq_desc: pointer to the HBA descriptor data structure.
  894. * @hbq_entry_index: index of the HBQ entry data structures.
  895. * @pmb: pointer to the driver internal queue element for mailbox command.
  896. *
  897. * The configure HBQ (Host Buffer Queue) mailbox command is used to configure
  898. * an HBQ. The configuration binds events that require buffers to a particular
  899. * ring and HBQ based on a selection profile.
  900. *
  901. * This routine prepares the mailbox command for configuring an HBQ.
  902. **/
  903. void
  904. lpfc_config_hbq(struct lpfc_hba *phba, uint32_t id,
  905. struct lpfc_hbq_init *hbq_desc,
  906. uint32_t hbq_entry_index, LPFC_MBOXQ_t *pmb)
  907. {
  908. int i;
  909. MAILBOX_t *mb = &pmb->u.mb;
  910. struct config_hbq_var *hbqmb = &mb->un.varCfgHbq;
  911. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  912. hbqmb->hbqId = id;
  913. hbqmb->entry_count = hbq_desc->entry_count; /* # entries in HBQ */
  914. hbqmb->recvNotify = hbq_desc->rn; /* Receive
  915. * Notification */
  916. hbqmb->numMask = hbq_desc->mask_count; /* # R_CTL/TYPE masks
  917. * # in words 0-19 */
  918. hbqmb->profile = hbq_desc->profile; /* Selection profile:
  919. * 0 = all,
  920. * 7 = logentry */
  921. hbqmb->ringMask = hbq_desc->ring_mask; /* Binds HBQ to a ring
  922. * e.g. Ring0=b0001,
  923. * ring2=b0100 */
  924. hbqmb->headerLen = hbq_desc->headerLen; /* 0 if not profile 4
  925. * or 5 */
  926. hbqmb->logEntry = hbq_desc->logEntry; /* Set to 1 if this
  927. * HBQ will be used
  928. * for LogEntry
  929. * buffers */
  930. hbqmb->hbqaddrLow = putPaddrLow(phba->hbqslimp.phys) +
  931. hbq_entry_index * sizeof(struct lpfc_hbq_entry);
  932. hbqmb->hbqaddrHigh = putPaddrHigh(phba->hbqslimp.phys);
  933. mb->mbxCommand = MBX_CONFIG_HBQ;
  934. mb->mbxOwner = OWN_HOST;
  935. /* Copy info for profiles 2,3,5. Other
  936. * profiles this area is reserved
  937. */
  938. if (hbq_desc->profile == 2)
  939. lpfc_build_hbq_profile2(hbqmb, hbq_desc);
  940. else if (hbq_desc->profile == 3)
  941. lpfc_build_hbq_profile3(hbqmb, hbq_desc);
  942. else if (hbq_desc->profile == 5)
  943. lpfc_build_hbq_profile5(hbqmb, hbq_desc);
  944. /* Return if no rctl / type masks for this HBQ */
  945. if (!hbq_desc->mask_count)
  946. return;
  947. /* Otherwise we setup specific rctl / type masks for this HBQ */
  948. for (i = 0; i < hbq_desc->mask_count; i++) {
  949. hbqmb->hbqMasks[i].tmatch = hbq_desc->hbqMasks[i].tmatch;
  950. hbqmb->hbqMasks[i].tmask = hbq_desc->hbqMasks[i].tmask;
  951. hbqmb->hbqMasks[i].rctlmatch = hbq_desc->hbqMasks[i].rctlmatch;
  952. hbqmb->hbqMasks[i].rctlmask = hbq_desc->hbqMasks[i].rctlmask;
  953. }
  954. return;
  955. }
  956. /**
  957. * lpfc_config_ring - Prepare a mailbox command for configuring an IOCB ring
  958. * @phba: pointer to lpfc hba data structure.
  959. * @ring:
  960. * @pmb: pointer to the driver internal queue element for mailbox command.
  961. *
  962. * The configure ring mailbox command is used to configure an IOCB ring. This
  963. * configuration binds from one to six of HBA RC_CTL/TYPE mask entries to the
  964. * ring. This is used to map incoming sequences to a particular ring whose
  965. * RC_CTL/TYPE mask entry matches that of the sequence. The driver should not
  966. * attempt to configure a ring whose number is greater than the number
  967. * specified in the Port Control Block (PCB). It is an error to issue the
  968. * configure ring command more than once with the same ring number. The HBA
  969. * returns an error if the driver attempts this.
  970. *
  971. * This routine prepares the mailbox command for configuring IOCB ring.
  972. **/
  973. void
  974. lpfc_config_ring(struct lpfc_hba * phba, int ring, LPFC_MBOXQ_t * pmb)
  975. {
  976. int i;
  977. MAILBOX_t *mb = &pmb->u.mb;
  978. struct lpfc_sli *psli;
  979. struct lpfc_sli_ring *pring;
  980. memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
  981. mb->un.varCfgRing.ring = ring;
  982. mb->un.varCfgRing.maxOrigXchg = 0;
  983. mb->un.varCfgRing.maxRespXchg = 0;
  984. mb->un.varCfgRing.recvNotify = 1;
  985. psli = &phba->sli;
  986. pring = &psli->ring[ring];
  987. mb->un.varCfgRing.numMask = pring->num_mask;
  988. mb->mbxCommand = MBX_CONFIG_RING;
  989. mb->mbxOwner = OWN_HOST;
  990. /* Is this ring configured for a specific profile */
  991. if (pring->prt[0].profile) {
  992. mb->un.varCfgRing.profile = pring->prt[0].profile;
  993. return;
  994. }
  995. /* Otherwise we setup specific rctl / type masks for this ring */
  996. for (i = 0; i < pring->num_mask; i++) {
  997. mb->un.varCfgRing.rrRegs[i].rval = pring->prt[i].rctl;
  998. if (mb->un.varCfgRing.rrRegs[i].rval != FC_ELS_REQ)
  999. mb->un.varCfgRing.rrRegs[i].rmask = 0xff;
  1000. else
  1001. mb->un.varCfgRing.rrRegs[i].rmask = 0xfe;
  1002. mb->un.varCfgRing.rrRegs[i].tval = pring->prt[i].type;
  1003. mb->un.varCfgRing.rrRegs[i].tmask = 0xff;
  1004. }
  1005. return;
  1006. }
  1007. /**
  1008. * lpfc_config_port - Prepare a mailbox command for configuring port
  1009. * @phba: pointer to lpfc hba data structure.
  1010. * @pmb: pointer to the driver internal queue element for mailbox command.
  1011. *
  1012. * The configure port mailbox command is used to identify the Port Control
  1013. * Block (PCB) in the driver memory. After this command is issued, the
  1014. * driver must not access the mailbox in the HBA without first resetting
  1015. * the HBA. The HBA may copy the PCB information to internal storage for
  1016. * subsequent use; the driver can not change the PCB information unless it
  1017. * resets the HBA.
  1018. *
  1019. * This routine prepares the mailbox command for configuring port.
  1020. **/
  1021. void
  1022. lpfc_config_port(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
  1023. {
  1024. MAILBOX_t __iomem *mb_slim = (MAILBOX_t __iomem *) phba->MBslimaddr;
  1025. MAILBOX_t *mb = &pmb->u.mb;
  1026. dma_addr_t pdma_addr;
  1027. uint32_t bar_low, bar_high;
  1028. size_t offset;
  1029. struct lpfc_hgp hgp;
  1030. int i;
  1031. uint32_t pgp_offset;
  1032. memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
  1033. mb->mbxCommand = MBX_CONFIG_PORT;
  1034. mb->mbxOwner = OWN_HOST;
  1035. mb->un.varCfgPort.pcbLen = sizeof(PCB_t);
  1036. offset = (uint8_t *)phba->pcb - (uint8_t *)phba->slim2p.virt;
  1037. pdma_addr = phba->slim2p.phys + offset;
  1038. mb->un.varCfgPort.pcbLow = putPaddrLow(pdma_addr);
  1039. mb->un.varCfgPort.pcbHigh = putPaddrHigh(pdma_addr);
  1040. /* Always Host Group Pointer is in SLIM */
  1041. mb->un.varCfgPort.hps = 1;
  1042. /* If HBA supports SLI=3 ask for it */
  1043. if (phba->sli_rev == LPFC_SLI_REV3 && phba->vpd.sli3Feat.cerbm) {
  1044. if (phba->cfg_enable_bg)
  1045. mb->un.varCfgPort.cbg = 1; /* configure BlockGuard */
  1046. mb->un.varCfgPort.cdss = 1; /* Configure Security */
  1047. mb->un.varCfgPort.cerbm = 1; /* Request HBQs */
  1048. mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */
  1049. mb->un.varCfgPort.cinb = 1; /* Interrupt Notification Block */
  1050. mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count();
  1051. if (phba->max_vpi && phba->cfg_enable_npiv &&
  1052. phba->vpd.sli3Feat.cmv) {
  1053. mb->un.varCfgPort.max_vpi = LPFC_MAX_VPI;
  1054. mb->un.varCfgPort.cmv = 1;
  1055. } else
  1056. mb->un.varCfgPort.max_vpi = phba->max_vpi = 0;
  1057. } else
  1058. phba->sli_rev = LPFC_SLI_REV2;
  1059. mb->un.varCfgPort.sli_mode = phba->sli_rev;
  1060. /* Now setup pcb */
  1061. phba->pcb->type = TYPE_NATIVE_SLI2;
  1062. phba->pcb->feature = FEATURE_INITIAL_SLI2;
  1063. /* Setup Mailbox pointers */
  1064. phba->pcb->mailBoxSize = sizeof(MAILBOX_t);
  1065. offset = (uint8_t *)phba->mbox - (uint8_t *)phba->slim2p.virt;
  1066. pdma_addr = phba->slim2p.phys + offset;
  1067. phba->pcb->mbAddrHigh = putPaddrHigh(pdma_addr);
  1068. phba->pcb->mbAddrLow = putPaddrLow(pdma_addr);
  1069. /*
  1070. * Setup Host Group ring pointer.
  1071. *
  1072. * For efficiency reasons, the ring get/put pointers can be
  1073. * placed in adapter memory (SLIM) rather than in host memory.
  1074. * This allows firmware to avoid PCI reads/writes when updating
  1075. * and checking pointers.
  1076. *
  1077. * The firmware recognizes the use of SLIM memory by comparing
  1078. * the address of the get/put pointers structure with that of
  1079. * the SLIM BAR (BAR0).
  1080. *
  1081. * Caution: be sure to use the PCI config space value of BAR0/BAR1
  1082. * (the hardware's view of the base address), not the OS's
  1083. * value of pci_resource_start() as the OS value may be a cookie
  1084. * for ioremap/iomap.
  1085. */
  1086. pci_read_config_dword(phba->pcidev, PCI_BASE_ADDRESS_0, &bar_low);
  1087. pci_read_config_dword(phba->pcidev, PCI_BASE_ADDRESS_1, &bar_high);
  1088. /*
  1089. * Set up HGP - Port Memory
  1090. *
  1091. * The port expects the host get/put pointers to reside in memory
  1092. * following the "non-diagnostic" mode mailbox (32 words, 0x80 bytes)
  1093. * area of SLIM. In SLI-2 mode, there's an additional 16 reserved
  1094. * words (0x40 bytes). This area is not reserved if HBQs are
  1095. * configured in SLI-3.
  1096. *
  1097. * CR0Put - SLI2(no HBQs) = 0xc0, With HBQs = 0x80
  1098. * RR0Get 0xc4 0x84
  1099. * CR1Put 0xc8 0x88
  1100. * RR1Get 0xcc 0x8c
  1101. * CR2Put 0xd0 0x90
  1102. * RR2Get 0xd4 0x94
  1103. * CR3Put 0xd8 0x98
  1104. * RR3Get 0xdc 0x9c
  1105. *
  1106. * Reserved 0xa0-0xbf
  1107. * If HBQs configured:
  1108. * HBQ 0 Put ptr 0xc0
  1109. * HBQ 1 Put ptr 0xc4
  1110. * HBQ 2 Put ptr 0xc8
  1111. * ......
  1112. * HBQ(M-1)Put Pointer 0xc0+(M-1)*4
  1113. *
  1114. */
  1115. if (phba->sli_rev == 3) {
  1116. phba->host_gp = &mb_slim->us.s3.host[0];
  1117. phba->hbq_put = &mb_slim->us.s3.hbq_put[0];
  1118. } else {
  1119. phba->host_gp = &mb_slim->us.s2.host[0];
  1120. phba->hbq_put = NULL;
  1121. }
  1122. /* mask off BAR0's flag bits 0 - 3 */
  1123. phba->pcb->hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) +
  1124. (void __iomem *)phba->host_gp -
  1125. (void __iomem *)phba->MBslimaddr;
  1126. if (bar_low & PCI_BASE_ADDRESS_MEM_TYPE_64)
  1127. phba->pcb->hgpAddrHigh = bar_high;
  1128. else
  1129. phba->pcb->hgpAddrHigh = 0;
  1130. /* write HGP data to SLIM at the required longword offset */
  1131. memset(&hgp, 0, sizeof(struct lpfc_hgp));
  1132. for (i=0; i < phba->sli.num_rings; i++) {
  1133. lpfc_memcpy_to_slim(phba->host_gp + i, &hgp,
  1134. sizeof(*phba->host_gp));
  1135. }
  1136. /* Setup Port Group offset */
  1137. if (phba->sli_rev == 3)
  1138. pgp_offset = offsetof(struct lpfc_sli2_slim,
  1139. mbx.us.s3_pgp.port);
  1140. else
  1141. pgp_offset = offsetof(struct lpfc_sli2_slim, mbx.us.s2.port);
  1142. pdma_addr = phba->slim2p.phys + pgp_offset;
  1143. phba->pcb->pgpAddrHigh = putPaddrHigh(pdma_addr);
  1144. phba->pcb->pgpAddrLow = putPaddrLow(pdma_addr);
  1145. /* Use callback routine to setp rings in the pcb */
  1146. lpfc_config_pcb_setup(phba);
  1147. /* special handling for LC HBAs */
  1148. if (lpfc_is_LC_HBA(phba->pcidev->device)) {
  1149. uint32_t hbainit[5];
  1150. lpfc_hba_init(phba, hbainit);
  1151. memcpy(&mb->un.varCfgPort.hbainit, hbainit, 20);
  1152. }
  1153. /* Swap PCB if needed */
  1154. lpfc_sli_pcimem_bcopy(phba->pcb, phba->pcb, sizeof(PCB_t));
  1155. }
  1156. /**
  1157. * lpfc_kill_board - Prepare a mailbox command for killing board
  1158. * @phba: pointer to lpfc hba data structure.
  1159. * @pmb: pointer to the driver internal queue element for mailbox command.
  1160. *
  1161. * The kill board mailbox command is used to tell firmware to perform a
  1162. * graceful shutdown of a channel on a specified board to prepare for reset.
  1163. * When the kill board mailbox command is received, the ER3 bit is set to 1
  1164. * in the Host Status register and the ER Attention bit is set to 1 in the
  1165. * Host Attention register of the HBA function that received the kill board
  1166. * command.
  1167. *
  1168. * This routine prepares the mailbox command for killing the board in
  1169. * preparation for a graceful shutdown.
  1170. **/
  1171. void
  1172. lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
  1173. {
  1174. MAILBOX_t *mb = &pmb->u.mb;
  1175. memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
  1176. mb->mbxCommand = MBX_KILL_BOARD;
  1177. mb->mbxOwner = OWN_HOST;
  1178. return;
  1179. }
  1180. /**
  1181. * lpfc_mbox_put - Put a mailbox cmd into the tail of driver's mailbox queue
  1182. * @phba: pointer to lpfc hba data structure.
  1183. * @mbq: pointer to the driver internal queue element for mailbox command.
  1184. *
  1185. * Driver maintains a internal mailbox command queue implemented as a linked
  1186. * list. When a mailbox command is issued, it shall be put into the mailbox
  1187. * command queue such that they shall be processed orderly as HBA can process
  1188. * one mailbox command at a time.
  1189. **/
  1190. void
  1191. lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq)
  1192. {
  1193. struct lpfc_sli *psli;
  1194. psli = &phba->sli;
  1195. list_add_tail(&mbq->list, &psli->mboxq);
  1196. psli->mboxq_cnt++;
  1197. return;
  1198. }
  1199. /**
  1200. * lpfc_mbox_get - Remove a mailbox cmd from the head of driver's mailbox queue
  1201. * @phba: pointer to lpfc hba data structure.
  1202. *
  1203. * Driver maintains a internal mailbox command queue implemented as a linked
  1204. * list. When a mailbox command is issued, it shall be put into the mailbox
  1205. * command queue such that they shall be processed orderly as HBA can process
  1206. * one mailbox command at a time. After HBA finished processing a mailbox
  1207. * command, the driver will remove a pending mailbox command from the head of
  1208. * the mailbox command queue and send to the HBA for processing.
  1209. *
  1210. * Return codes
  1211. * pointer to the driver internal queue element for mailbox command.
  1212. **/
  1213. LPFC_MBOXQ_t *
  1214. lpfc_mbox_get(struct lpfc_hba * phba)
  1215. {
  1216. LPFC_MBOXQ_t *mbq = NULL;
  1217. struct lpfc_sli *psli = &phba->sli;
  1218. list_remove_head((&psli->mboxq), mbq, LPFC_MBOXQ_t, list);
  1219. if (mbq)
  1220. psli->mboxq_cnt--;
  1221. return mbq;
  1222. }
  1223. /**
  1224. * __lpfc_mbox_cmpl_put - Put mailbox cmd into mailbox cmd complete list
  1225. * @phba: pointer to lpfc hba data structure.
  1226. * @mbq: pointer to the driver internal queue element for mailbox command.
  1227. *
  1228. * This routine put the completed mailbox command into the mailbox command
  1229. * complete list. This is the unlocked version of the routine. The mailbox
  1230. * complete list is used by the driver worker thread to process mailbox
  1231. * complete callback functions outside the driver interrupt handler.
  1232. **/
  1233. void
  1234. __lpfc_mbox_cmpl_put(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbq)
  1235. {
  1236. list_add_tail(&mbq->list, &phba->sli.mboxq_cmpl);
  1237. }
  1238. /**
  1239. * lpfc_mbox_cmpl_put - Put mailbox command into mailbox command complete list
  1240. * @phba: pointer to lpfc hba data structure.
  1241. * @mbq: pointer to the driver internal queue element for mailbox command.
  1242. *
  1243. * This routine put the completed mailbox command into the mailbox command
  1244. * complete list. This is the locked version of the routine. The mailbox
  1245. * complete list is used by the driver worker thread to process mailbox
  1246. * complete callback functions outside the driver interrupt handler.
  1247. **/
  1248. void
  1249. lpfc_mbox_cmpl_put(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbq)
  1250. {
  1251. unsigned long iflag;
  1252. /* This function expects to be called from interrupt context */
  1253. spin_lock_irqsave(&phba->hbalock, iflag);
  1254. __lpfc_mbox_cmpl_put(phba, mbq);
  1255. spin_unlock_irqrestore(&phba->hbalock, iflag);
  1256. return;
  1257. }
  1258. /**
  1259. * lpfc_mbox_cmd_check - Check the validality of a mailbox command
  1260. * @phba: pointer to lpfc hba data structure.
  1261. * @mboxq: pointer to the driver internal queue element for mailbox command.
  1262. *
  1263. * This routine is to check whether a mailbox command is valid to be issued.
  1264. * This check will be performed by both the mailbox issue API when a client
  1265. * is to issue a mailbox command to the mailbox transport.
  1266. *
  1267. * Return 0 - pass the check, -ENODEV - fail the check
  1268. **/
  1269. int
  1270. lpfc_mbox_cmd_check(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq)
  1271. {
  1272. /* Mailbox command that have a completion handler must also have a
  1273. * vport specified.
  1274. */
  1275. if (mboxq->mbox_cmpl && mboxq->mbox_cmpl != lpfc_sli_def_mbox_cmpl &&
  1276. mboxq->mbox_cmpl != lpfc_sli_wake_mbox_wait) {
  1277. if (!mboxq->vport) {
  1278. lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_VPORT,
  1279. "1814 Mbox x%x failed, no vport\n",
  1280. mboxq->u.mb.mbxCommand);
  1281. dump_stack();
  1282. return -ENODEV;
  1283. }
  1284. }
  1285. return 0;
  1286. }
  1287. /**
  1288. * lpfc_mbox_dev_check - Check the device state for issuing a mailbox command
  1289. * @phba: pointer to lpfc hba data structure.
  1290. *
  1291. * This routine is to check whether the HBA device is ready for posting a
  1292. * mailbox command. It is used by the mailbox transport API at the time the
  1293. * to post a mailbox command to the device.
  1294. *
  1295. * Return 0 - pass the check, -ENODEV - fail the check
  1296. **/
  1297. int
  1298. lpfc_mbox_dev_check(struct lpfc_hba *phba)
  1299. {
  1300. /* If the PCI channel is in offline state, do not issue mbox */
  1301. if (unlikely(pci_channel_offline(phba->pcidev)))
  1302. return -ENODEV;
  1303. /* If the HBA is in error state, do not issue mbox */
  1304. if (phba->link_state == LPFC_HBA_ERROR)
  1305. return -ENODEV;
  1306. return 0;
  1307. }
  1308. /**
  1309. * lpfc_mbox_tmo_val - Retrieve mailbox command timeout value
  1310. * @phba: pointer to lpfc hba data structure.
  1311. * @cmd: mailbox command code.
  1312. *
  1313. * This routine retrieves the proper timeout value according to the mailbox
  1314. * command code.
  1315. *
  1316. * Return codes
  1317. * Timeout value to be used for the given mailbox command
  1318. **/
  1319. int
  1320. lpfc_mbox_tmo_val(struct lpfc_hba *phba, int cmd)
  1321. {
  1322. switch (cmd) {
  1323. case MBX_WRITE_NV: /* 0x03 */
  1324. case MBX_UPDATE_CFG: /* 0x1B */
  1325. case MBX_DOWN_LOAD: /* 0x1C */
  1326. case MBX_DEL_LD_ENTRY: /* 0x1D */
  1327. case MBX_LOAD_AREA: /* 0x81 */
  1328. case MBX_WRITE_WWN: /* 0x98 */
  1329. case MBX_LOAD_EXP_ROM: /* 0x9C */
  1330. return LPFC_MBOX_TMO_FLASH_CMD;
  1331. case MBX_SLI4_CONFIG: /* 0x9b */
  1332. return LPFC_MBOX_SLI4_CONFIG_TMO;
  1333. }
  1334. return LPFC_MBOX_TMO;
  1335. }
  1336. /**
  1337. * lpfc_sli4_mbx_sge_set - Set a sge entry in non-embedded mailbox command
  1338. * @mbox: pointer to lpfc mbox command.
  1339. * @sgentry: sge entry index.
  1340. * @phyaddr: physical address for the sge
  1341. * @length: Length of the sge.
  1342. *
  1343. * This routine sets up an entry in the non-embedded mailbox command at the sge
  1344. * index location.
  1345. **/
  1346. void
  1347. lpfc_sli4_mbx_sge_set(struct lpfcMboxq *mbox, uint32_t sgentry,
  1348. dma_addr_t phyaddr, uint32_t length)
  1349. {
  1350. struct lpfc_mbx_nembed_cmd *nembed_sge;
  1351. nembed_sge = (struct lpfc_mbx_nembed_cmd *)
  1352. &mbox->u.mqe.un.nembed_cmd;
  1353. nembed_sge->sge[sgentry].pa_lo = putPaddrLow(phyaddr);
  1354. nembed_sge->sge[sgentry].pa_hi = putPaddrHigh(phyaddr);
  1355. nembed_sge->sge[sgentry].length = length;
  1356. }
  1357. /**
  1358. * lpfc_sli4_mbx_sge_get - Get a sge entry from non-embedded mailbox command
  1359. * @mbox: pointer to lpfc mbox command.
  1360. * @sgentry: sge entry index.
  1361. *
  1362. * This routine gets an entry from the non-embedded mailbox command at the sge
  1363. * index location.
  1364. **/
  1365. void
  1366. lpfc_sli4_mbx_sge_get(struct lpfcMboxq *mbox, uint32_t sgentry,
  1367. struct lpfc_mbx_sge *sge)
  1368. {
  1369. struct lpfc_mbx_nembed_cmd *nembed_sge;
  1370. nembed_sge = (struct lpfc_mbx_nembed_cmd *)
  1371. &mbox->u.mqe.un.nembed_cmd;
  1372. sge->pa_lo = nembed_sge->sge[sgentry].pa_lo;
  1373. sge->pa_hi = nembed_sge->sge[sgentry].pa_hi;
  1374. sge->length = nembed_sge->sge[sgentry].length;
  1375. }
  1376. /**
  1377. * lpfc_sli4_mbox_cmd_free - Free a sli4 mailbox command
  1378. * @phba: pointer to lpfc hba data structure.
  1379. * @mbox: pointer to lpfc mbox command.
  1380. *
  1381. * This routine frees SLI4 specific mailbox command for sending IOCTL command.
  1382. **/
  1383. void
  1384. lpfc_sli4_mbox_cmd_free(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
  1385. {
  1386. struct lpfc_mbx_sli4_config *sli4_cfg;
  1387. struct lpfc_mbx_sge sge;
  1388. dma_addr_t phyaddr;
  1389. uint32_t sgecount, sgentry;
  1390. sli4_cfg = &mbox->u.mqe.un.sli4_config;
  1391. /* For embedded mbox command, just free the mbox command */
  1392. if (bf_get(lpfc_mbox_hdr_emb, &sli4_cfg->header.cfg_mhdr)) {
  1393. mempool_free(mbox, phba->mbox_mem_pool);
  1394. return;
  1395. }
  1396. /* For non-embedded mbox command, we need to free the pages first */
  1397. sgecount = bf_get(lpfc_mbox_hdr_sge_cnt, &sli4_cfg->header.cfg_mhdr);
  1398. /* There is nothing we can do if there is no sge address array */
  1399. if (unlikely(!mbox->sge_array)) {
  1400. mempool_free(mbox, phba->mbox_mem_pool);
  1401. return;
  1402. }
  1403. /* Each non-embedded DMA memory was allocated in the length of a page */
  1404. for (sgentry = 0; sgentry < sgecount; sgentry++) {
  1405. lpfc_sli4_mbx_sge_get(mbox, sgentry, &sge);
  1406. phyaddr = getPaddr(sge.pa_hi, sge.pa_lo);
  1407. dma_free_coherent(&phba->pcidev->dev, PAGE_SIZE,
  1408. mbox->sge_array->addr[sgentry], phyaddr);
  1409. }
  1410. /* Free the sge address array memory */
  1411. kfree(mbox->sge_array);
  1412. /* Finally, free the mailbox command itself */
  1413. mempool_free(mbox, phba->mbox_mem_pool);
  1414. }
  1415. /**
  1416. * lpfc_sli4_config - Initialize the SLI4 Config Mailbox command
  1417. * @phba: pointer to lpfc hba data structure.
  1418. * @mbox: pointer to lpfc mbox command.
  1419. * @subsystem: The sli4 config sub mailbox subsystem.
  1420. * @opcode: The sli4 config sub mailbox command opcode.
  1421. * @length: Length of the sli4 config mailbox command.
  1422. *
  1423. * This routine sets up the header fields of SLI4 specific mailbox command
  1424. * for sending IOCTL command.
  1425. *
  1426. * Return: the actual length of the mbox command allocated (mostly useful
  1427. * for none embedded mailbox command).
  1428. **/
  1429. int
  1430. lpfc_sli4_config(struct lpfc_hba *phba, struct lpfcMboxq *mbox,
  1431. uint8_t subsystem, uint8_t opcode, uint32_t length, bool emb)
  1432. {
  1433. struct lpfc_mbx_sli4_config *sli4_config;
  1434. union lpfc_sli4_cfg_shdr *cfg_shdr = NULL;
  1435. uint32_t alloc_len;
  1436. uint32_t resid_len;
  1437. uint32_t pagen, pcount;
  1438. void *viraddr;
  1439. dma_addr_t phyaddr;
  1440. /* Set up SLI4 mailbox command header fields */
  1441. memset(mbox, 0, sizeof(*mbox));
  1442. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_SLI4_CONFIG);
  1443. /* Set up SLI4 ioctl command header fields */
  1444. sli4_config = &mbox->u.mqe.un.sli4_config;
  1445. /* Setup for the embedded mbox command */
  1446. if (emb) {
  1447. /* Set up main header fields */
  1448. bf_set(lpfc_mbox_hdr_emb, &sli4_config->header.cfg_mhdr, 1);
  1449. sli4_config->header.cfg_mhdr.payload_length =
  1450. LPFC_MBX_CMD_HDR_LENGTH + length;
  1451. /* Set up sub-header fields following main header */
  1452. bf_set(lpfc_mbox_hdr_opcode,
  1453. &sli4_config->header.cfg_shdr.request, opcode);
  1454. bf_set(lpfc_mbox_hdr_subsystem,
  1455. &sli4_config->header.cfg_shdr.request, subsystem);
  1456. sli4_config->header.cfg_shdr.request.request_length = length;
  1457. return length;
  1458. }
  1459. /* Setup for the none-embedded mbox command */
  1460. pcount = (PAGE_ALIGN(length))/PAGE_SIZE;
  1461. pcount = (pcount > LPFC_SLI4_MBX_SGE_MAX_PAGES) ?
  1462. LPFC_SLI4_MBX_SGE_MAX_PAGES : pcount;
  1463. /* Allocate record for keeping SGE virtual addresses */
  1464. mbox->sge_array = kmalloc(sizeof(struct lpfc_mbx_nembed_sge_virt),
  1465. GFP_KERNEL);
  1466. if (!mbox->sge_array)
  1467. return 0;
  1468. for (pagen = 0, alloc_len = 0; pagen < pcount; pagen++) {
  1469. /* The DMA memory is always allocated in the length of a
  1470. * page even though the last SGE might not fill up to a
  1471. * page, this is used as a priori size of PAGE_SIZE for
  1472. * the later DMA memory free.
  1473. */
  1474. viraddr = dma_alloc_coherent(&phba->pcidev->dev, PAGE_SIZE,
  1475. &phyaddr, GFP_KERNEL);
  1476. /* In case of malloc fails, proceed with whatever we have */
  1477. if (!viraddr)
  1478. break;
  1479. memset(viraddr, 0, PAGE_SIZE);
  1480. mbox->sge_array->addr[pagen] = viraddr;
  1481. /* Keep the first page for later sub-header construction */
  1482. if (pagen == 0)
  1483. cfg_shdr = (union lpfc_sli4_cfg_shdr *)viraddr;
  1484. resid_len = length - alloc_len;
  1485. if (resid_len > PAGE_SIZE) {
  1486. lpfc_sli4_mbx_sge_set(mbox, pagen, phyaddr,
  1487. PAGE_SIZE);
  1488. alloc_len += PAGE_SIZE;
  1489. } else {
  1490. lpfc_sli4_mbx_sge_set(mbox, pagen, phyaddr,
  1491. resid_len);
  1492. alloc_len = length;
  1493. }
  1494. }
  1495. /* Set up main header fields in mailbox command */
  1496. sli4_config->header.cfg_mhdr.payload_length = alloc_len;
  1497. bf_set(lpfc_mbox_hdr_sge_cnt, &sli4_config->header.cfg_mhdr, pagen);
  1498. /* Set up sub-header fields into the first page */
  1499. if (pagen > 0) {
  1500. bf_set(lpfc_mbox_hdr_opcode, &cfg_shdr->request, opcode);
  1501. bf_set(lpfc_mbox_hdr_subsystem, &cfg_shdr->request, subsystem);
  1502. cfg_shdr->request.request_length =
  1503. alloc_len - sizeof(union lpfc_sli4_cfg_shdr);
  1504. }
  1505. /* The sub-header is in DMA memory, which needs endian converstion */
  1506. lpfc_sli_pcimem_bcopy(cfg_shdr, cfg_shdr,
  1507. sizeof(union lpfc_sli4_cfg_shdr));
  1508. return alloc_len;
  1509. }
  1510. /**
  1511. * lpfc_sli4_mbox_opcode_get - Get the opcode from a sli4 mailbox command
  1512. * @phba: pointer to lpfc hba data structure.
  1513. * @mbox: pointer to lpfc mbox command.
  1514. *
  1515. * This routine gets the opcode from a SLI4 specific mailbox command for
  1516. * sending IOCTL command. If the mailbox command is not MBX_SLI4_CONFIG
  1517. * (0x9B) or if the IOCTL sub-header is not present, opcode 0x0 shall be
  1518. * returned.
  1519. **/
  1520. uint8_t
  1521. lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
  1522. {
  1523. struct lpfc_mbx_sli4_config *sli4_cfg;
  1524. union lpfc_sli4_cfg_shdr *cfg_shdr;
  1525. if (mbox->u.mb.mbxCommand != MBX_SLI4_CONFIG)
  1526. return 0;
  1527. sli4_cfg = &mbox->u.mqe.un.sli4_config;
  1528. /* For embedded mbox command, get opcode from embedded sub-header*/
  1529. if (bf_get(lpfc_mbox_hdr_emb, &sli4_cfg->header.cfg_mhdr)) {
  1530. cfg_shdr = &mbox->u.mqe.un.sli4_config.header.cfg_shdr;
  1531. return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request);
  1532. }
  1533. /* For non-embedded mbox command, get opcode from first dma page */
  1534. if (unlikely(!mbox->sge_array))
  1535. return 0;
  1536. cfg_shdr = (union lpfc_sli4_cfg_shdr *)mbox->sge_array->addr[0];
  1537. return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request);
  1538. }
  1539. /**
  1540. * lpfc_request_features: Configure SLI4 REQUEST_FEATURES mailbox
  1541. * @mboxq: pointer to lpfc mbox command.
  1542. *
  1543. * This routine sets up the mailbox for an SLI4 REQUEST_FEATURES
  1544. * mailbox command.
  1545. **/
  1546. void
  1547. lpfc_request_features(struct lpfc_hba *phba, struct lpfcMboxq *mboxq)
  1548. {
  1549. /* Set up SLI4 mailbox command header fields */
  1550. memset(mboxq, 0, sizeof(LPFC_MBOXQ_t));
  1551. bf_set(lpfc_mqe_command, &mboxq->u.mqe, MBX_SLI4_REQ_FTRS);
  1552. /* Set up host requested features. */
  1553. bf_set(lpfc_mbx_rq_ftr_rq_fcpi, &mboxq->u.mqe.un.req_ftrs, 1);
  1554. if (phba->cfg_enable_fip)
  1555. bf_set(lpfc_mbx_rq_ftr_rq_ifip, &mboxq->u.mqe.un.req_ftrs, 0);
  1556. else
  1557. bf_set(lpfc_mbx_rq_ftr_rq_ifip, &mboxq->u.mqe.un.req_ftrs, 1);
  1558. /* Enable DIF (block guard) only if configured to do so. */
  1559. if (phba->cfg_enable_bg)
  1560. bf_set(lpfc_mbx_rq_ftr_rq_dif, &mboxq->u.mqe.un.req_ftrs, 1);
  1561. /* Enable NPIV only if configured to do so. */
  1562. if (phba->max_vpi && phba->cfg_enable_npiv)
  1563. bf_set(lpfc_mbx_rq_ftr_rq_npiv, &mboxq->u.mqe.un.req_ftrs, 1);
  1564. return;
  1565. }
  1566. /**
  1567. * lpfc_init_vfi - Initialize the INIT_VFI mailbox command
  1568. * @mbox: pointer to lpfc mbox command to initialize.
  1569. * @vport: Vport associated with the VF.
  1570. *
  1571. * This routine initializes @mbox to all zeros and then fills in the mailbox
  1572. * fields from @vport. INIT_VFI configures virtual fabrics identified by VFI
  1573. * in the context of an FCF. The driver issues this command to setup a VFI
  1574. * before issuing a FLOGI to login to the VSAN. The driver should also issue a
  1575. * REG_VFI after a successful VSAN login.
  1576. **/
  1577. void
  1578. lpfc_init_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport)
  1579. {
  1580. struct lpfc_mbx_init_vfi *init_vfi;
  1581. memset(mbox, 0, sizeof(*mbox));
  1582. init_vfi = &mbox->u.mqe.un.init_vfi;
  1583. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VFI);
  1584. bf_set(lpfc_init_vfi_vr, init_vfi, 1);
  1585. bf_set(lpfc_init_vfi_vt, init_vfi, 1);
  1586. bf_set(lpfc_init_vfi_vfi, init_vfi, vport->vfi + vport->phba->vfi_base);
  1587. bf_set(lpfc_init_vfi_fcfi, init_vfi, vport->phba->fcf.fcfi);
  1588. }
  1589. /**
  1590. * lpfc_reg_vfi - Initialize the REG_VFI mailbox command
  1591. * @mbox: pointer to lpfc mbox command to initialize.
  1592. * @vport: vport associated with the VF.
  1593. * @phys: BDE DMA bus address used to send the service parameters to the HBA.
  1594. *
  1595. * This routine initializes @mbox to all zeros and then fills in the mailbox
  1596. * fields from @vport, and uses @buf as a DMAable buffer to send the vport's
  1597. * fc service parameters to the HBA for this VFI. REG_VFI configures virtual
  1598. * fabrics identified by VFI in the context of an FCF.
  1599. **/
  1600. void
  1601. lpfc_reg_vfi(struct lpfcMboxq *mbox, struct lpfc_vport *vport, dma_addr_t phys)
  1602. {
  1603. struct lpfc_mbx_reg_vfi *reg_vfi;
  1604. memset(mbox, 0, sizeof(*mbox));
  1605. reg_vfi = &mbox->u.mqe.un.reg_vfi;
  1606. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_REG_VFI);
  1607. bf_set(lpfc_reg_vfi_vp, reg_vfi, 1);
  1608. bf_set(lpfc_reg_vfi_vfi, reg_vfi, vport->vfi + vport->phba->vfi_base);
  1609. bf_set(lpfc_reg_vfi_fcfi, reg_vfi, vport->phba->fcf.fcfi);
  1610. bf_set(lpfc_reg_vfi_vpi, reg_vfi, vport->vpi + vport->phba->vpi_base);
  1611. reg_vfi->bde.addrHigh = putPaddrHigh(phys);
  1612. reg_vfi->bde.addrLow = putPaddrLow(phys);
  1613. reg_vfi->bde.tus.f.bdeSize = sizeof(vport->fc_sparam);
  1614. reg_vfi->bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64;
  1615. bf_set(lpfc_reg_vfi_nport_id, reg_vfi, vport->fc_myDID);
  1616. }
  1617. /**
  1618. * lpfc_init_vpi - Initialize the INIT_VPI mailbox command
  1619. * @mbox: pointer to lpfc mbox command to initialize.
  1620. * @vpi: VPI to be initialized.
  1621. *
  1622. * The INIT_VPI mailbox command supports virtual N_Ports. The driver uses the
  1623. * command to activate a virtual N_Port. The HBA assigns a MAC address to use
  1624. * with the virtual N Port. The SLI Host issues this command before issuing a
  1625. * FDISC to connect to the Fabric. The SLI Host should issue a REG_VPI after a
  1626. * successful virtual NPort login.
  1627. **/
  1628. void
  1629. lpfc_init_vpi(struct lpfcMboxq *mbox, uint16_t vpi)
  1630. {
  1631. memset(mbox, 0, sizeof(*mbox));
  1632. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VPI);
  1633. bf_set(lpfc_init_vpi_vpi, &mbox->u.mqe.un.init_vpi, vpi);
  1634. }
  1635. /**
  1636. * lpfc_unreg_vfi - Initialize the UNREG_VFI mailbox command
  1637. * @mbox: pointer to lpfc mbox command to initialize.
  1638. * @vfi: VFI to be unregistered.
  1639. *
  1640. * The UNREG_VFI mailbox command causes the SLI Host to put a virtual fabric
  1641. * (logical NPort) into the inactive state. The SLI Host must have logged out
  1642. * and unregistered all remote N_Ports to abort any activity on the virtual
  1643. * fabric. The SLI Port posts the mailbox response after marking the virtual
  1644. * fabric inactive.
  1645. **/
  1646. void
  1647. lpfc_unreg_vfi(struct lpfcMboxq *mbox, uint16_t vfi)
  1648. {
  1649. memset(mbox, 0, sizeof(*mbox));
  1650. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_UNREG_VFI);
  1651. bf_set(lpfc_unreg_vfi_vfi, &mbox->u.mqe.un.unreg_vfi, vfi);
  1652. }
  1653. /**
  1654. * lpfc_dump_fcoe_param - Dump config region 23 to get FCoe parameters.
  1655. * @phba: pointer to the hba structure containing.
  1656. * @mbox: pointer to lpfc mbox command to initialize.
  1657. *
  1658. * This function create a SLI4 dump mailbox command to dump FCoE
  1659. * parameters stored in region 23.
  1660. **/
  1661. int
  1662. lpfc_dump_fcoe_param(struct lpfc_hba *phba,
  1663. struct lpfcMboxq *mbox)
  1664. {
  1665. struct lpfc_dmabuf *mp = NULL;
  1666. MAILBOX_t *mb;
  1667. memset(mbox, 0, sizeof(*mbox));
  1668. mb = &mbox->u.mb;
  1669. mp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
  1670. if (mp)
  1671. mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys);
  1672. if (!mp || !mp->virt) {
  1673. kfree(mp);
  1674. /* dump_fcoe_param failed to allocate memory */
  1675. lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
  1676. "2569 lpfc_dump_fcoe_param: memory"
  1677. " allocation failed \n");
  1678. return 1;
  1679. }
  1680. memset(mp->virt, 0, LPFC_BPL_SIZE);
  1681. INIT_LIST_HEAD(&mp->list);
  1682. /* save address for completion */
  1683. mbox->context1 = (uint8_t *) mp;
  1684. mb->mbxCommand = MBX_DUMP_MEMORY;
  1685. mb->un.varDmp.type = DMP_NV_PARAMS;
  1686. mb->un.varDmp.region_id = DMP_REGION_23;
  1687. mb->un.varDmp.sli4_length = DMP_RGN23_SIZE;
  1688. mb->un.varWords[3] = putPaddrLow(mp->phys);
  1689. mb->un.varWords[4] = putPaddrHigh(mp->phys);
  1690. return 0;
  1691. }
  1692. /**
  1693. * lpfc_reg_fcfi - Initialize the REG_FCFI mailbox command
  1694. * @phba: pointer to the hba structure containing the FCF index and RQ ID.
  1695. * @mbox: pointer to lpfc mbox command to initialize.
  1696. *
  1697. * The REG_FCFI mailbox command supports Fibre Channel Forwarders (FCFs). The
  1698. * SLI Host uses the command to activate an FCF after it has acquired FCF
  1699. * information via a READ_FCF mailbox command. This mailbox command also is used
  1700. * to indicate where received unsolicited frames from this FCF will be sent. By
  1701. * default this routine will set up the FCF to forward all unsolicited frames
  1702. * the the RQ ID passed in the @phba. This can be overridden by the caller for
  1703. * more complicated setups.
  1704. **/
  1705. void
  1706. lpfc_reg_fcfi(struct lpfc_hba *phba, struct lpfcMboxq *mbox)
  1707. {
  1708. struct lpfc_mbx_reg_fcfi *reg_fcfi;
  1709. memset(mbox, 0, sizeof(*mbox));
  1710. reg_fcfi = &mbox->u.mqe.un.reg_fcfi;
  1711. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_REG_FCFI);
  1712. bf_set(lpfc_reg_fcfi_rq_id0, reg_fcfi, phba->sli4_hba.hdr_rq->queue_id);
  1713. bf_set(lpfc_reg_fcfi_rq_id1, reg_fcfi, REG_FCF_INVALID_QID);
  1714. bf_set(lpfc_reg_fcfi_rq_id2, reg_fcfi, REG_FCF_INVALID_QID);
  1715. bf_set(lpfc_reg_fcfi_rq_id3, reg_fcfi, REG_FCF_INVALID_QID);
  1716. bf_set(lpfc_reg_fcfi_info_index, reg_fcfi, phba->fcf.fcf_indx);
  1717. /* reg_fcf addr mode is bit wise inverted value of fcf addr_mode */
  1718. bf_set(lpfc_reg_fcfi_mam, reg_fcfi,
  1719. (~phba->fcf.addr_mode) & 0x3);
  1720. if (phba->fcf.fcf_flag & FCF_VALID_VLAN) {
  1721. bf_set(lpfc_reg_fcfi_vv, reg_fcfi, 1);
  1722. bf_set(lpfc_reg_fcfi_vlan_tag, reg_fcfi, phba->fcf.vlan_id);
  1723. }
  1724. }
  1725. /**
  1726. * lpfc_unreg_fcfi - Initialize the UNREG_FCFI mailbox command
  1727. * @mbox: pointer to lpfc mbox command to initialize.
  1728. * @fcfi: FCFI to be unregistered.
  1729. *
  1730. * The UNREG_FCFI mailbox command supports Fibre Channel Forwarders (FCFs).
  1731. * The SLI Host uses the command to inactivate an FCFI.
  1732. **/
  1733. void
  1734. lpfc_unreg_fcfi(struct lpfcMboxq *mbox, uint16_t fcfi)
  1735. {
  1736. memset(mbox, 0, sizeof(*mbox));
  1737. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_UNREG_FCFI);
  1738. bf_set(lpfc_unreg_fcfi, &mbox->u.mqe.un.unreg_fcfi, fcfi);
  1739. }
  1740. /**
  1741. * lpfc_resume_rpi - Initialize the RESUME_RPI mailbox command
  1742. * @mbox: pointer to lpfc mbox command to initialize.
  1743. * @ndlp: The nodelist structure that describes the RPI to resume.
  1744. *
  1745. * The RESUME_RPI mailbox command is used to restart I/O to an RPI after a
  1746. * link event.
  1747. **/
  1748. void
  1749. lpfc_resume_rpi(struct lpfcMboxq *mbox, struct lpfc_nodelist *ndlp)
  1750. {
  1751. struct lpfc_mbx_resume_rpi *resume_rpi;
  1752. memset(mbox, 0, sizeof(*mbox));
  1753. resume_rpi = &mbox->u.mqe.un.resume_rpi;
  1754. bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_RESUME_RPI);
  1755. bf_set(lpfc_resume_rpi_index, resume_rpi, ndlp->nlp_rpi);
  1756. bf_set(lpfc_resume_rpi_ii, resume_rpi, RESUME_INDEX_RPI);
  1757. resume_rpi->event_tag = ndlp->phba->fc_eventTag;
  1758. }