lpfc.h 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2017-2022 Broadcom. All Rights Reserved. The term *
  5. * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
  6. * Copyright (C) 2004-2016 Emulex. All rights reserved. *
  7. * EMULEX and SLI are trademarks of Emulex. *
  8. * www.broadcom.com *
  9. * Portions Copyright (C) 2004-2005 Christoph Hellwig *
  10. * *
  11. * This program is free software; you can redistribute it and/or *
  12. * modify it under the terms of version 2 of the GNU General *
  13. * Public License as published by the Free Software Foundation. *
  14. * This program is distributed in the hope that it will be useful. *
  15. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  16. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  17. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  18. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  19. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  20. * more details, a copy of which can be found in the file COPYING *
  21. * included with this package. *
  22. *******************************************************************/
  23. #include <scsi/scsi_host.h>
  24. #include <linux/hashtable.h>
  25. #include <linux/ktime.h>
  26. #include <linux/workqueue.h>
  27. #if defined(CONFIG_DEBUG_FS) && !defined(CONFIG_SCSI_LPFC_DEBUG_FS)
  28. #define CONFIG_SCSI_LPFC_DEBUG_FS
  29. #endif
  30. struct lpfc_sli2_slim;
  31. #define ELX_MODEL_NAME_SIZE 80
  32. #define LPFC_PCI_DEV_LP 0x1
  33. #define LPFC_PCI_DEV_OC 0x2
  34. #define LPFC_SLI_REV2 2
  35. #define LPFC_SLI_REV3 3
  36. #define LPFC_SLI_REV4 4
  37. #define LPFC_MAX_TARGET 4096 /* max number of targets supported */
  38. #define LPFC_MAX_DISC_THREADS 64 /* max outstanding discovery els
  39. requests */
  40. #define LPFC_MAX_NS_RETRY 3 /* Number of retry attempts to contact
  41. the NameServer before giving up. */
  42. #define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
  43. #define LPFC_DEFAULT_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
  44. #define LPFC_DEFAULT_XPSGL_SIZE 256
  45. #define LPFC_MAX_SG_TABLESIZE 0xffff
  46. #define LPFC_MIN_SG_SLI4_BUF_SZ 0x800 /* based on LPFC_DEFAULT_SG_SEG_CNT */
  47. #define LPFC_MAX_BG_SLI4_SEG_CNT_DIF 128 /* sg element count for BlockGuard */
  48. #define LPFC_MAX_SG_SEG_CNT_DIF 512 /* sg element count per scsi cmnd */
  49. #define LPFC_MAX_SG_SEG_CNT 4096 /* sg element count per scsi cmnd */
  50. #define LPFC_MIN_SG_SEG_CNT 32 /* sg element count per scsi cmnd */
  51. #define LPFC_MAX_SGL_SEG_CNT 512 /* SGL element count per scsi cmnd */
  52. #define LPFC_MAX_BPL_SEG_CNT 4096 /* BPL element count per scsi cmnd */
  53. #define LPFC_MAX_NVME_SEG_CNT 256 /* max SGL element cnt per NVME cmnd */
  54. #define LPFC_MAX_SGE_SIZE 0x80000000 /* Maximum data allowed in a SGE */
  55. #define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
  56. #define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
  57. #define LPFC_VNAME_LEN 100 /* vport symbolic name length */
  58. #define LPFC_TGTQ_RAMPUP_PCENT 5 /* Target queue rampup in percentage */
  59. #define LPFC_MIN_TGT_QDEPTH 10
  60. #define LPFC_MAX_TGT_QDEPTH 0xFFFF
  61. /*
  62. * Following time intervals are used of adjusting SCSI device
  63. * queue depths when there are driver resource error or Firmware
  64. * resource error.
  65. */
  66. /* 1 Second */
  67. #define QUEUE_RAMP_DOWN_INTERVAL (msecs_to_jiffies(1000 * 1))
  68. /* Number of exchanges reserved for discovery to complete */
  69. #define LPFC_DISC_IOCB_BUFF_COUNT 20
  70. #define LPFC_HB_MBOX_INTERVAL 5 /* Heart beat interval in seconds. */
  71. #define LPFC_HB_MBOX_TIMEOUT 30 /* Heart beat timeout in seconds. */
  72. /* Error Attention event polling interval */
  73. #define LPFC_ERATT_POLL_INTERVAL 5 /* EATT poll interval in seconds */
  74. /* Define macros for 64 bit support */
  75. #define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
  76. #define putPaddrHigh(addr) ((uint32_t) (0xffffffff & (((u64)(addr))>>32)))
  77. #define getPaddr(high, low) ((dma_addr_t)( \
  78. (( (u64)(high)<<16 ) << 16)|( (u64)(low))))
  79. /* Provide maximum configuration definitions. */
  80. #define LPFC_DRVR_TIMEOUT 16 /* driver iocb timeout value in sec */
  81. #define FC_MAX_ADPTMSG 64
  82. #define MAX_HBAEVT 32
  83. #define MAX_HBAS_NO_RESET 16
  84. /* Number of MSI-X vectors the driver uses */
  85. #define LPFC_MSIX_VECTORS 2
  86. /* lpfc wait event data ready flag */
  87. #define LPFC_DATA_READY 0 /* bit 0 */
  88. /* queue dump line buffer size */
  89. #define LPFC_LBUF_SZ 128
  90. /* mailbox system shutdown options */
  91. #define LPFC_MBX_NO_WAIT 0
  92. #define LPFC_MBX_WAIT 1
  93. #define LPFC_CFG_PARAM_MAGIC_NUM 0xFEAA0005
  94. #define LPFC_PORT_CFG_NAME "/cfg/port.cfg"
  95. #define lpfc_rangecheck(val, min, max) \
  96. ((uint)(val) >= (uint)(min) && (val) <= (max))
  97. enum lpfc_polling_flags {
  98. ENABLE_FCP_RING_POLLING = 0x1,
  99. DISABLE_FCP_RING_INT = 0x2
  100. };
  101. struct perf_prof {
  102. uint16_t cmd_cpu[40];
  103. uint16_t rsp_cpu[40];
  104. uint16_t qh_cpu[40];
  105. uint16_t wqidx[40];
  106. };
  107. /*
  108. * Provide for FC4 TYPE x28 - NVME. The
  109. * bit mask for FCP and NVME is 0x8 identically
  110. * because they are 32 bit positions distance.
  111. */
  112. #define LPFC_FC4_TYPE_BITMASK 0x00000100
  113. /* Provide DMA memory definitions the driver uses per port instance. */
  114. struct lpfc_dmabuf {
  115. struct list_head list;
  116. void *virt; /* virtual address ptr */
  117. dma_addr_t phys; /* mapped address */
  118. uint32_t buffer_tag; /* used for tagged queue ring */
  119. };
  120. struct lpfc_nvmet_ctxbuf {
  121. struct list_head list;
  122. struct lpfc_async_xchg_ctx *context;
  123. struct lpfc_iocbq *iocbq;
  124. struct lpfc_sglq *sglq;
  125. struct work_struct defer_work;
  126. };
  127. struct lpfc_dma_pool {
  128. struct lpfc_dmabuf *elements;
  129. uint32_t max_count;
  130. uint32_t current_count;
  131. };
  132. struct hbq_dmabuf {
  133. struct lpfc_dmabuf hbuf;
  134. struct lpfc_dmabuf dbuf;
  135. uint16_t total_size;
  136. uint16_t bytes_recv;
  137. uint32_t tag;
  138. struct lpfc_cq_event cq_event;
  139. unsigned long time_stamp;
  140. void *context;
  141. };
  142. struct rqb_dmabuf {
  143. struct lpfc_dmabuf hbuf;
  144. struct lpfc_dmabuf dbuf;
  145. uint16_t total_size;
  146. uint16_t bytes_recv;
  147. uint16_t idx;
  148. struct lpfc_queue *hrq; /* ptr to associated Header RQ */
  149. struct lpfc_queue *drq; /* ptr to associated Data RQ */
  150. };
  151. /* Priority bit. Set value to exceed low water mark in lpfc_mem. */
  152. #define MEM_PRI 0x100
  153. /****************************************************************************/
  154. /* Device VPD save area */
  155. /****************************************************************************/
  156. typedef struct lpfc_vpd {
  157. uint32_t status; /* vpd status value */
  158. uint32_t length; /* number of bytes actually returned */
  159. struct {
  160. uint32_t rsvd1; /* Revision numbers */
  161. uint32_t biuRev;
  162. uint32_t smRev;
  163. uint32_t smFwRev;
  164. uint32_t endecRev;
  165. uint16_t rBit;
  166. uint8_t fcphHigh;
  167. uint8_t fcphLow;
  168. uint8_t feaLevelHigh;
  169. uint8_t feaLevelLow;
  170. uint32_t postKernRev;
  171. uint32_t opFwRev;
  172. uint8_t opFwName[16];
  173. uint32_t sli1FwRev;
  174. uint8_t sli1FwName[16];
  175. uint32_t sli2FwRev;
  176. uint8_t sli2FwName[16];
  177. } rev;
  178. struct {
  179. #ifdef __BIG_ENDIAN_BITFIELD
  180. uint32_t rsvd3 :20; /* Reserved */
  181. uint32_t rsvd2 : 3; /* Reserved */
  182. uint32_t cbg : 1; /* Configure BlockGuard */
  183. uint32_t cmv : 1; /* Configure Max VPIs */
  184. uint32_t ccrp : 1; /* Config Command Ring Polling */
  185. uint32_t csah : 1; /* Configure Synchronous Abort Handling */
  186. uint32_t chbs : 1; /* Cofigure Host Backing store */
  187. uint32_t cinb : 1; /* Enable Interrupt Notification Block */
  188. uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
  189. uint32_t cmx : 1; /* Configure Max XRIs */
  190. uint32_t cmr : 1; /* Configure Max RPIs */
  191. #else /* __LITTLE_ENDIAN */
  192. uint32_t cmr : 1; /* Configure Max RPIs */
  193. uint32_t cmx : 1; /* Configure Max XRIs */
  194. uint32_t cerbm : 1; /* Configure Enhanced Receive Buf Mgmt */
  195. uint32_t cinb : 1; /* Enable Interrupt Notification Block */
  196. uint32_t chbs : 1; /* Cofigure Host Backing store */
  197. uint32_t csah : 1; /* Configure Synchronous Abort Handling */
  198. uint32_t ccrp : 1; /* Config Command Ring Polling */
  199. uint32_t cmv : 1; /* Configure Max VPIs */
  200. uint32_t cbg : 1; /* Configure BlockGuard */
  201. uint32_t rsvd2 : 3; /* Reserved */
  202. uint32_t rsvd3 :20; /* Reserved */
  203. #endif
  204. } sli3Feat;
  205. } lpfc_vpd_t;
  206. /*
  207. * lpfc stat counters
  208. */
  209. struct lpfc_stats {
  210. /* Statistics for ELS commands */
  211. uint32_t elsLogiCol;
  212. uint32_t elsRetryExceeded;
  213. uint32_t elsXmitRetry;
  214. uint32_t elsDelayRetry;
  215. uint32_t elsRcvDrop;
  216. uint32_t elsRcvFrame;
  217. uint32_t elsRcvRSCN;
  218. uint32_t elsRcvRNID;
  219. uint32_t elsRcvFARP;
  220. uint32_t elsRcvFARPR;
  221. uint32_t elsRcvFLOGI;
  222. uint32_t elsRcvPLOGI;
  223. uint32_t elsRcvADISC;
  224. uint32_t elsRcvPDISC;
  225. uint32_t elsRcvFAN;
  226. uint32_t elsRcvLOGO;
  227. uint32_t elsRcvPRLO;
  228. uint32_t elsRcvPRLI;
  229. uint32_t elsRcvLIRR;
  230. uint32_t elsRcvRLS;
  231. uint32_t elsRcvRPL;
  232. uint32_t elsRcvRRQ;
  233. uint32_t elsRcvRTV;
  234. uint32_t elsRcvECHO;
  235. uint32_t elsRcvLCB;
  236. uint32_t elsRcvRDP;
  237. uint32_t elsRcvRDF;
  238. uint32_t elsXmitFLOGI;
  239. uint32_t elsXmitFDISC;
  240. uint32_t elsXmitPLOGI;
  241. uint32_t elsXmitPRLI;
  242. uint32_t elsXmitADISC;
  243. uint32_t elsXmitLOGO;
  244. uint32_t elsXmitSCR;
  245. uint32_t elsXmitRSCN;
  246. uint32_t elsXmitRNID;
  247. uint32_t elsXmitFARP;
  248. uint32_t elsXmitFARPR;
  249. uint32_t elsXmitACC;
  250. uint32_t elsXmitLSRJT;
  251. uint32_t frameRcvBcast;
  252. uint32_t frameRcvMulti;
  253. uint32_t strayXmitCmpl;
  254. uint32_t frameXmitDelay;
  255. uint32_t xriCmdCmpl;
  256. uint32_t xriStatErr;
  257. uint32_t LinkUp;
  258. uint32_t LinkDown;
  259. uint32_t LinkMultiEvent;
  260. uint32_t NoRcvBuf;
  261. uint32_t fcpCmd;
  262. uint32_t fcpCmpl;
  263. uint32_t fcpRspErr;
  264. uint32_t fcpRemoteStop;
  265. uint32_t fcpPortRjt;
  266. uint32_t fcpPortBusy;
  267. uint32_t fcpError;
  268. uint32_t fcpLocalErr;
  269. };
  270. struct lpfc_hba;
  271. #define LPFC_VMID_TIMER 300 /* timer interval in seconds */
  272. #define LPFC_MAX_VMID_SIZE 256
  273. #define LPFC_COMPRESS_VMID_SIZE 16
  274. union lpfc_vmid_io_tag {
  275. u32 app_id; /* App Id vmid */
  276. u8 cs_ctl_vmid; /* Priority tag vmid */
  277. };
  278. #define JIFFIES_PER_HR (HZ * 60 * 60)
  279. struct lpfc_vmid {
  280. u8 flag;
  281. #define LPFC_VMID_SLOT_FREE 0x0
  282. #define LPFC_VMID_SLOT_USED 0x1
  283. #define LPFC_VMID_REQ_REGISTER 0x2
  284. #define LPFC_VMID_REGISTERED 0x4
  285. #define LPFC_VMID_DE_REGISTER 0x8
  286. char host_vmid[LPFC_MAX_VMID_SIZE];
  287. union lpfc_vmid_io_tag un;
  288. struct hlist_node hnode;
  289. u64 io_rd_cnt;
  290. u64 io_wr_cnt;
  291. u8 vmid_len;
  292. u8 delete_inactive; /* Delete if inactive flag 0 = no, 1 = yes */
  293. u32 hash_index;
  294. u64 __percpu *last_io_time;
  295. };
  296. #define lpfc_vmid_is_type_priority_tag(vport)\
  297. (vport->vmid_priority_tagging ? 1 : 0)
  298. #define LPFC_VMID_HASH_SIZE 256
  299. #define LPFC_VMID_HASH_MASK 255
  300. #define LPFC_VMID_HASH_SHIFT 6
  301. struct lpfc_vmid_context {
  302. struct lpfc_vmid *vmp;
  303. struct lpfc_nodelist *nlp;
  304. bool instantiated;
  305. };
  306. struct lpfc_vmid_priority_range {
  307. u8 low;
  308. u8 high;
  309. u8 qos;
  310. };
  311. struct lpfc_vmid_priority_info {
  312. u32 num_descriptors;
  313. struct lpfc_vmid_priority_range *vmid_range;
  314. };
  315. #define QFPA_EVEN_ONLY 0x01
  316. #define QFPA_ODD_ONLY 0x02
  317. #define QFPA_EVEN_ODD 0x03
  318. enum discovery_state {
  319. LPFC_VPORT_UNKNOWN = 0, /* vport state is unknown */
  320. LPFC_VPORT_FAILED = 1, /* vport has failed */
  321. LPFC_LOCAL_CFG_LINK = 6, /* local NPORT Id configured */
  322. LPFC_FLOGI = 7, /* FLOGI sent to Fabric */
  323. LPFC_FDISC = 8, /* FDISC sent for vport */
  324. LPFC_FABRIC_CFG_LINK = 9, /* Fabric assigned NPORT Id
  325. * configured */
  326. LPFC_NS_REG = 10, /* Register with NameServer */
  327. LPFC_NS_QRY = 11, /* Query NameServer for NPort ID list */
  328. LPFC_BUILD_DISC_LIST = 12, /* Build ADISC and PLOGI lists for
  329. * device authentication / discovery */
  330. LPFC_DISC_AUTH = 13, /* Processing ADISC list */
  331. LPFC_VPORT_READY = 32,
  332. };
  333. enum hba_state {
  334. LPFC_LINK_UNKNOWN = 0, /* HBA state is unknown */
  335. LPFC_WARM_START = 1, /* HBA state after selective reset */
  336. LPFC_INIT_START = 2, /* Initial state after board reset */
  337. LPFC_INIT_MBX_CMDS = 3, /* Initialize HBA with mbox commands */
  338. LPFC_LINK_DOWN = 4, /* HBA initialized, link is down */
  339. LPFC_LINK_UP = 5, /* Link is up - issue READ_LA */
  340. LPFC_CLEAR_LA = 6, /* authentication cmplt - issue
  341. * CLEAR_LA */
  342. LPFC_HBA_READY = 32,
  343. LPFC_HBA_ERROR = -1
  344. };
  345. struct lpfc_trunk_link_state {
  346. enum hba_state state;
  347. uint8_t fault;
  348. };
  349. struct lpfc_trunk_link {
  350. struct lpfc_trunk_link_state link0,
  351. link1,
  352. link2,
  353. link3;
  354. u32 phy_lnk_speed;
  355. };
  356. /* Format of congestion module parameters */
  357. struct lpfc_cgn_param {
  358. uint32_t cgn_param_magic;
  359. uint8_t cgn_param_version; /* version 1 */
  360. uint8_t cgn_param_mode; /* 0=off 1=managed 2=monitor only */
  361. #define LPFC_CFG_OFF 0
  362. #define LPFC_CFG_MANAGED 1
  363. #define LPFC_CFG_MONITOR 2
  364. uint8_t cgn_rsvd1;
  365. uint8_t cgn_rsvd2;
  366. uint8_t cgn_param_level0;
  367. uint8_t cgn_param_level1;
  368. uint8_t cgn_param_level2;
  369. uint8_t byte11;
  370. uint8_t byte12;
  371. uint8_t byte13;
  372. uint8_t byte14;
  373. uint8_t byte15;
  374. };
  375. /* Max number of days of congestion data */
  376. #define LPFC_MAX_CGN_DAYS 10
  377. /* Format of congestion buffer info
  378. * This structure defines memory thats allocated and registered with
  379. * the HBA firmware. When adding or removing fields from this structure
  380. * the alignment must match the HBA firmware.
  381. */
  382. struct lpfc_cgn_info {
  383. /* Header */
  384. __le16 cgn_info_size; /* is sizeof(struct lpfc_cgn_info) */
  385. uint8_t cgn_info_version; /* represents format of structure */
  386. #define LPFC_CGN_INFO_V1 1
  387. #define LPFC_CGN_INFO_V2 2
  388. #define LPFC_CGN_INFO_V3 3
  389. uint8_t cgn_info_mode; /* 0=off 1=managed 2=monitor only */
  390. uint8_t cgn_info_detect;
  391. uint8_t cgn_info_action;
  392. uint8_t cgn_info_level0;
  393. uint8_t cgn_info_level1;
  394. uint8_t cgn_info_level2;
  395. /* Start Time */
  396. uint8_t cgn_info_month;
  397. uint8_t cgn_info_day;
  398. uint8_t cgn_info_year;
  399. uint8_t cgn_info_hour;
  400. uint8_t cgn_info_minute;
  401. uint8_t cgn_info_second;
  402. /* minute / hours / daily indices */
  403. uint8_t cgn_index_minute;
  404. uint8_t cgn_index_hour;
  405. uint8_t cgn_index_day;
  406. __le16 cgn_warn_freq;
  407. __le16 cgn_alarm_freq;
  408. __le16 cgn_lunq;
  409. uint8_t cgn_pad1[8];
  410. /* Driver Information */
  411. __le16 cgn_drvr_min[60];
  412. __le32 cgn_drvr_hr[24];
  413. __le32 cgn_drvr_day[LPFC_MAX_CGN_DAYS];
  414. /* Congestion Warnings */
  415. __le16 cgn_warn_min[60];
  416. __le32 cgn_warn_hr[24];
  417. __le32 cgn_warn_day[LPFC_MAX_CGN_DAYS];
  418. /* Latency Information */
  419. __le32 cgn_latency_min[60];
  420. __le32 cgn_latency_hr[24];
  421. __le32 cgn_latency_day[LPFC_MAX_CGN_DAYS];
  422. /* Bandwidth Information */
  423. __le16 cgn_bw_min[60];
  424. __le16 cgn_bw_hr[24];
  425. __le16 cgn_bw_day[LPFC_MAX_CGN_DAYS];
  426. /* Congestion Alarms */
  427. __le16 cgn_alarm_min[60];
  428. __le32 cgn_alarm_hr[24];
  429. __le32 cgn_alarm_day[LPFC_MAX_CGN_DAYS];
  430. struct_group(cgn_stat,
  431. uint8_t cgn_stat_npm; /* Notifications per minute */
  432. /* Start Time */
  433. uint8_t cgn_stat_month;
  434. uint8_t cgn_stat_day;
  435. uint8_t cgn_stat_year;
  436. uint8_t cgn_stat_hour;
  437. uint8_t cgn_stat_minute;
  438. uint8_t cgn_pad2[2];
  439. __le32 cgn_notification;
  440. __le32 cgn_peer_notification;
  441. __le32 link_integ_notification;
  442. __le32 delivery_notification;
  443. uint8_t cgn_stat_cgn_month; /* Last congestion notification FPIN */
  444. uint8_t cgn_stat_cgn_day;
  445. uint8_t cgn_stat_cgn_year;
  446. uint8_t cgn_stat_cgn_hour;
  447. uint8_t cgn_stat_cgn_min;
  448. uint8_t cgn_stat_cgn_sec;
  449. uint8_t cgn_stat_peer_month; /* Last peer congestion FPIN */
  450. uint8_t cgn_stat_peer_day;
  451. uint8_t cgn_stat_peer_year;
  452. uint8_t cgn_stat_peer_hour;
  453. uint8_t cgn_stat_peer_min;
  454. uint8_t cgn_stat_peer_sec;
  455. uint8_t cgn_stat_lnk_month; /* Last link integrity FPIN */
  456. uint8_t cgn_stat_lnk_day;
  457. uint8_t cgn_stat_lnk_year;
  458. uint8_t cgn_stat_lnk_hour;
  459. uint8_t cgn_stat_lnk_min;
  460. uint8_t cgn_stat_lnk_sec;
  461. uint8_t cgn_stat_del_month; /* Last delivery notification FPIN */
  462. uint8_t cgn_stat_del_day;
  463. uint8_t cgn_stat_del_year;
  464. uint8_t cgn_stat_del_hour;
  465. uint8_t cgn_stat_del_min;
  466. uint8_t cgn_stat_del_sec;
  467. );
  468. __le32 cgn_info_crc;
  469. #define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41
  470. #define LPFC_CGN_CRC32_SEED 0xFFFFFFFF
  471. };
  472. #define LPFC_CGN_INFO_SZ (sizeof(struct lpfc_cgn_info) - \
  473. sizeof(uint32_t))
  474. struct lpfc_cgn_stat {
  475. atomic64_t total_bytes;
  476. atomic64_t rcv_bytes;
  477. atomic64_t rx_latency;
  478. #define LPFC_CGN_NOT_SENT 0xFFFFFFFFFFFFFFFFLL
  479. atomic_t rx_io_cnt;
  480. };
  481. struct lpfc_cgn_acqe_stat {
  482. atomic64_t alarm;
  483. atomic64_t warn;
  484. };
  485. struct lpfc_vport {
  486. struct lpfc_hba *phba;
  487. struct list_head listentry;
  488. uint8_t port_type;
  489. #define LPFC_PHYSICAL_PORT 1
  490. #define LPFC_NPIV_PORT 2
  491. #define LPFC_FABRIC_PORT 3
  492. enum discovery_state port_state;
  493. uint16_t vpi;
  494. uint16_t vfi;
  495. uint8_t vpi_state;
  496. #define LPFC_VPI_REGISTERED 0x1
  497. uint32_t fc_flag; /* FC flags */
  498. /* Several of these flags are HBA centric and should be moved to
  499. * phba->link_flag (e.g. FC_PTP, FC_PUBLIC_LOOP)
  500. */
  501. #define FC_PT2PT 0x1 /* pt2pt with no fabric */
  502. #define FC_PT2PT_PLOGI 0x2 /* pt2pt initiate PLOGI */
  503. #define FC_DISC_TMO 0x4 /* Discovery timer running */
  504. #define FC_PUBLIC_LOOP 0x8 /* Public loop */
  505. #define FC_LBIT 0x10 /* LOGIN bit in loopinit set */
  506. #define FC_RSCN_MODE 0x20 /* RSCN cmd rcv'ed */
  507. #define FC_NLP_MORE 0x40 /* More node to process in node tbl */
  508. #define FC_OFFLINE_MODE 0x80 /* Interface is offline for diag */
  509. #define FC_FABRIC 0x100 /* We are fabric attached */
  510. #define FC_VPORT_LOGO_RCVD 0x200 /* LOGO received on vport */
  511. #define FC_RSCN_DISCOVERY 0x400 /* Auth all devices after RSCN */
  512. #define FC_LOGO_RCVD_DID_CHNG 0x800 /* FDISC on phys port detect DID chng*/
  513. #define FC_PT2PT_NO_NVME 0x1000 /* Don't send NVME PRLI */
  514. #define FC_SCSI_SCAN_TMO 0x4000 /* scsi scan timer running */
  515. #define FC_ABORT_DISCOVERY 0x8000 /* we want to abort discovery */
  516. #define FC_NDISC_ACTIVE 0x10000 /* NPort discovery active */
  517. #define FC_BYPASSED_MODE 0x20000 /* NPort is in bypassed mode */
  518. #define FC_VPORT_NEEDS_REG_VPI 0x80000 /* Needs to have its vpi registered */
  519. #define FC_RSCN_DEFERRED 0x100000 /* A deferred RSCN being processed */
  520. #define FC_VPORT_NEEDS_INIT_VPI 0x200000 /* Need to INIT_VPI before FDISC */
  521. #define FC_VPORT_CVL_RCVD 0x400000 /* VLink failed due to CVL */
  522. #define FC_VFI_REGISTERED 0x800000 /* VFI is registered */
  523. #define FC_FDISC_COMPLETED 0x1000000/* FDISC completed */
  524. #define FC_DISC_DELAYED 0x2000000/* Delay NPort discovery */
  525. uint32_t ct_flags;
  526. #define FC_CT_RFF_ID 0x1 /* RFF_ID accepted by switch */
  527. #define FC_CT_RNN_ID 0x2 /* RNN_ID accepted by switch */
  528. #define FC_CT_RSNN_NN 0x4 /* RSNN_NN accepted by switch */
  529. #define FC_CT_RSPN_ID 0x8 /* RSPN_ID accepted by switch */
  530. #define FC_CT_RFT_ID 0x10 /* RFT_ID accepted by switch */
  531. #define FC_CT_RPRT_DEFER 0x20 /* Defer issuing FDMI RPRT */
  532. struct list_head fc_nodes;
  533. /* Keep counters for the number of entries in each list. */
  534. uint16_t fc_plogi_cnt;
  535. uint16_t fc_adisc_cnt;
  536. uint16_t fc_reglogin_cnt;
  537. uint16_t fc_prli_cnt;
  538. uint16_t fc_unmap_cnt;
  539. uint16_t fc_map_cnt;
  540. uint16_t fc_npr_cnt;
  541. uint16_t fc_unused_cnt;
  542. struct serv_parm fc_sparam; /* buffer for our service parameters */
  543. uint32_t fc_myDID; /* fibre channel S_ID */
  544. uint32_t fc_prevDID; /* previous fibre channel S_ID */
  545. struct lpfc_name fabric_portname;
  546. struct lpfc_name fabric_nodename;
  547. int32_t stopped; /* HBA has not been restarted since last ERATT */
  548. uint8_t fc_linkspeed; /* Link speed after last READ_LA */
  549. uint32_t num_disc_nodes; /* in addition to hba_state */
  550. uint32_t gidft_inp; /* cnt of outstanding GID_FTs */
  551. uint32_t fc_nlp_cnt; /* outstanding NODELIST requests */
  552. uint32_t fc_rscn_id_cnt; /* count of RSCNs payloads in list */
  553. uint32_t fc_rscn_flush; /* flag use of fc_rscn_id_list */
  554. struct lpfc_dmabuf *fc_rscn_id_list[FC_MAX_HOLD_RSCN];
  555. struct lpfc_name fc_nodename; /* fc nodename */
  556. struct lpfc_name fc_portname; /* fc portname */
  557. struct lpfc_work_evt disc_timeout_evt;
  558. struct timer_list fc_disctmo; /* Discovery rescue timer */
  559. uint8_t fc_ns_retry; /* retries for fabric nameserver */
  560. uint32_t fc_prli_sent; /* cntr for outstanding PRLIs */
  561. spinlock_t work_port_lock;
  562. uint32_t work_port_events; /* Timeout to be handled */
  563. #define WORKER_DISC_TMO 0x1 /* vport: Discovery timeout */
  564. #define WORKER_ELS_TMO 0x2 /* vport: ELS timeout */
  565. #define WORKER_DELAYED_DISC_TMO 0x8 /* vport: delayed discovery */
  566. #define WORKER_MBOX_TMO 0x100 /* hba: MBOX timeout */
  567. #define WORKER_HB_TMO 0x200 /* hba: Heart beat timeout */
  568. #define WORKER_FABRIC_BLOCK_TMO 0x400 /* hba: fabric block timeout */
  569. #define WORKER_RAMP_DOWN_QUEUE 0x800 /* hba: Decrease Q depth */
  570. #define WORKER_RAMP_UP_QUEUE 0x1000 /* hba: Increase Q depth */
  571. #define WORKER_SERVICE_TXQ 0x2000 /* hba: IOCBs on the txq */
  572. #define WORKER_CHECK_INACTIVE_VMID 0x4000 /* hba: check inactive vmids */
  573. #define WORKER_CHECK_VMID_ISSUE_QFPA 0x8000 /* vport: Check if qfpa needs
  574. * to be issued */
  575. struct timer_list els_tmofunc;
  576. struct timer_list delayed_disc_tmo;
  577. uint8_t load_flag;
  578. #define FC_LOADING 0x1 /* HBA in process of loading drvr */
  579. #define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */
  580. #define FC_ALLOW_FDMI 0x4 /* port is ready for FDMI requests */
  581. #define FC_ALLOW_VMID 0x8 /* Allow VMID I/Os */
  582. #define FC_DEREGISTER_ALL_APP_ID 0x10 /* Deregister all VMIDs */
  583. /* Vport Config Parameters */
  584. uint32_t cfg_scan_down;
  585. uint32_t cfg_lun_queue_depth;
  586. uint32_t cfg_nodev_tmo;
  587. uint32_t cfg_devloss_tmo;
  588. uint32_t cfg_restrict_login;
  589. uint32_t cfg_peer_port_login;
  590. uint32_t cfg_fcp_class;
  591. uint32_t cfg_use_adisc;
  592. uint32_t cfg_discovery_threads;
  593. uint32_t cfg_log_verbose;
  594. uint32_t cfg_enable_fc4_type;
  595. uint32_t cfg_max_luns;
  596. uint32_t cfg_enable_da_id;
  597. uint32_t cfg_max_scsicmpl_time;
  598. uint32_t cfg_tgt_queue_depth;
  599. uint32_t cfg_first_burst_size;
  600. uint32_t dev_loss_tmo_changed;
  601. /* VMID parameters */
  602. u8 lpfc_vmid_host_uuid[LPFC_COMPRESS_VMID_SIZE];
  603. u32 max_vmid; /* maximum VMIDs allowed per port */
  604. u32 cur_vmid_cnt; /* Current VMID count */
  605. #define LPFC_MIN_VMID 4
  606. #define LPFC_MAX_VMID 255
  607. u32 vmid_inactivity_timeout; /* Time after which the VMID */
  608. /* deregisters from switch */
  609. u32 vmid_priority_tagging;
  610. #define LPFC_VMID_PRIO_TAG_DISABLE 0 /* Disable */
  611. #define LPFC_VMID_PRIO_TAG_SUP_TARGETS 1 /* Allow supported targets only */
  612. #define LPFC_VMID_PRIO_TAG_ALL_TARGETS 2 /* Allow all targets */
  613. unsigned long *vmid_priority_range;
  614. #define LPFC_VMID_MAX_PRIORITY_RANGE 256
  615. #define LPFC_VMID_PRIORITY_BITMAP_SIZE 32
  616. u8 vmid_flag;
  617. #define LPFC_VMID_IN_USE 0x1
  618. #define LPFC_VMID_ISSUE_QFPA 0x2
  619. #define LPFC_VMID_QFPA_CMPL 0x4
  620. #define LPFC_VMID_QOS_ENABLED 0x8
  621. #define LPFC_VMID_TIMER_ENBLD 0x10
  622. #define LPFC_VMID_TYPE_PRIO 0x20
  623. struct fc_qfpa_res *qfpa_res;
  624. struct fc_vport *fc_vport;
  625. struct lpfc_vmid *vmid;
  626. DECLARE_HASHTABLE(hash_table, 8);
  627. rwlock_t vmid_lock;
  628. struct lpfc_vmid_priority_info vmid_priority;
  629. #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
  630. struct dentry *debug_disc_trc;
  631. struct dentry *debug_nodelist;
  632. struct dentry *debug_nvmestat;
  633. struct dentry *debug_scsistat;
  634. struct dentry *debug_ioktime;
  635. struct dentry *debug_hdwqstat;
  636. struct dentry *vport_debugfs_root;
  637. struct lpfc_debugfs_trc *disc_trc;
  638. atomic_t disc_trc_cnt;
  639. #endif
  640. struct list_head rcv_buffer_list;
  641. unsigned long rcv_buffer_time_stamp;
  642. uint32_t vport_flag;
  643. #define STATIC_VPORT 0x1
  644. #define FAWWPN_PARAM_CHG 0x2
  645. uint16_t fdmi_num_disc;
  646. uint32_t fdmi_hba_mask;
  647. uint32_t fdmi_port_mask;
  648. /* There is a single nvme instance per vport. */
  649. struct nvme_fc_local_port *localport;
  650. uint8_t nvmei_support; /* driver supports NVME Initiator */
  651. uint32_t last_fcp_wqidx;
  652. uint32_t rcv_flogi_cnt; /* How many unsol FLOGIs ACK'd. */
  653. };
  654. struct hbq_s {
  655. uint16_t entry_count; /* Current number of HBQ slots */
  656. uint16_t buffer_count; /* Current number of buffers posted */
  657. uint32_t next_hbqPutIdx; /* Index to next HBQ slot to use */
  658. uint32_t hbqPutIdx; /* HBQ slot to use */
  659. uint32_t local_hbqGetIdx; /* Local copy of Get index from Port */
  660. void *hbq_virt; /* Virtual ptr to this hbq */
  661. struct list_head hbq_buffer_list; /* buffers assigned to this HBQ */
  662. /* Callback for HBQ buffer allocation */
  663. struct hbq_dmabuf *(*hbq_alloc_buffer) (struct lpfc_hba *);
  664. /* Callback for HBQ buffer free */
  665. void (*hbq_free_buffer) (struct lpfc_hba *,
  666. struct hbq_dmabuf *);
  667. };
  668. /* this matches the position in the lpfc_hbq_defs array */
  669. #define LPFC_ELS_HBQ 0
  670. #define LPFC_MAX_HBQS 1
  671. enum hba_temp_state {
  672. HBA_NORMAL_TEMP,
  673. HBA_OVER_TEMP
  674. };
  675. enum intr_type_t {
  676. NONE = 0,
  677. INTx,
  678. MSI,
  679. MSIX,
  680. };
  681. #define LPFC_CT_CTX_MAX 64
  682. struct unsol_rcv_ct_ctx {
  683. uint32_t ctxt_id;
  684. uint32_t SID;
  685. uint32_t valid;
  686. #define UNSOL_INVALID 0
  687. #define UNSOL_VALID 1
  688. uint16_t oxid;
  689. uint16_t rxid;
  690. };
  691. #define LPFC_USER_LINK_SPEED_AUTO 0 /* auto select (default)*/
  692. #define LPFC_USER_LINK_SPEED_1G 1 /* 1 Gigabaud */
  693. #define LPFC_USER_LINK_SPEED_2G 2 /* 2 Gigabaud */
  694. #define LPFC_USER_LINK_SPEED_4G 4 /* 4 Gigabaud */
  695. #define LPFC_USER_LINK_SPEED_8G 8 /* 8 Gigabaud */
  696. #define LPFC_USER_LINK_SPEED_10G 10 /* 10 Gigabaud */
  697. #define LPFC_USER_LINK_SPEED_16G 16 /* 16 Gigabaud */
  698. #define LPFC_USER_LINK_SPEED_32G 32 /* 32 Gigabaud */
  699. #define LPFC_USER_LINK_SPEED_64G 64 /* 64 Gigabaud */
  700. #define LPFC_USER_LINK_SPEED_MAX LPFC_USER_LINK_SPEED_64G
  701. #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8, 10, 16, 32, 64"
  702. enum nemb_type {
  703. nemb_mse = 1,
  704. nemb_hbd
  705. };
  706. enum mbox_type {
  707. mbox_rd = 1,
  708. mbox_wr
  709. };
  710. enum dma_type {
  711. dma_mbox = 1,
  712. dma_ebuf
  713. };
  714. enum sta_type {
  715. sta_pre_addr = 1,
  716. sta_pos_addr
  717. };
  718. struct lpfc_mbox_ext_buf_ctx {
  719. uint32_t state;
  720. #define LPFC_BSG_MBOX_IDLE 0
  721. #define LPFC_BSG_MBOX_HOST 1
  722. #define LPFC_BSG_MBOX_PORT 2
  723. #define LPFC_BSG_MBOX_DONE 3
  724. #define LPFC_BSG_MBOX_ABTS 4
  725. enum nemb_type nembType;
  726. enum mbox_type mboxType;
  727. uint32_t numBuf;
  728. uint32_t mbxTag;
  729. uint32_t seqNum;
  730. struct lpfc_dmabuf *mbx_dmabuf;
  731. struct list_head ext_dmabuf_list;
  732. };
  733. struct lpfc_epd_pool {
  734. /* Expedite pool */
  735. struct list_head list;
  736. u32 count;
  737. spinlock_t lock; /* lock for expedite pool */
  738. };
  739. enum ras_state {
  740. INACTIVE,
  741. REG_INPROGRESS,
  742. ACTIVE
  743. };
  744. struct lpfc_ras_fwlog {
  745. uint8_t *fwlog_buff;
  746. uint32_t fw_buffcount; /* Buffer size posted to FW */
  747. #define LPFC_RAS_BUFF_ENTERIES 16 /* Each entry can hold max of 64k */
  748. #define LPFC_RAS_MAX_ENTRY_SIZE (64 * 1024)
  749. #define LPFC_RAS_MIN_BUFF_POST_SIZE (256 * 1024)
  750. #define LPFC_RAS_MAX_BUFF_POST_SIZE (1024 * 1024)
  751. uint32_t fw_loglevel; /* Log level set */
  752. struct lpfc_dmabuf lwpd;
  753. struct list_head fwlog_buff_list;
  754. /* RAS support status on adapter */
  755. bool ras_hwsupport; /* RAS Support available on HW or not */
  756. bool ras_enabled; /* Ras Enabled for the function */
  757. #define LPFC_RAS_DISABLE_LOGGING 0x00
  758. #define LPFC_RAS_ENABLE_LOGGING 0x01
  759. enum ras_state state; /* RAS logging running state */
  760. };
  761. #define DBG_LOG_STR_SZ 256
  762. #define DBG_LOG_SZ 256
  763. struct dbg_log_ent {
  764. char log[DBG_LOG_STR_SZ];
  765. u64 t_ns;
  766. };
  767. enum lpfc_irq_chann_mode {
  768. /* Assign IRQs to all possible cpus that have hardware queues */
  769. NORMAL_MODE,
  770. /* Assign IRQs only to cpus on the same numa node as HBA */
  771. NUMA_MODE,
  772. /* Assign IRQs only on non-hyperthreaded CPUs. This is the
  773. * same as normal_mode, but assign IRQS only on physical CPUs.
  774. */
  775. NHT_MODE,
  776. };
  777. enum lpfc_hba_bit_flags {
  778. FABRIC_COMANDS_BLOCKED,
  779. HBA_PCI_ERR,
  780. MBX_TMO_ERR,
  781. };
  782. struct lpfc_hba {
  783. /* SCSI interface function jump table entries */
  784. struct lpfc_io_buf * (*lpfc_get_scsi_buf)
  785. (struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
  786. struct scsi_cmnd *cmnd);
  787. int (*lpfc_scsi_prep_dma_buf)
  788. (struct lpfc_hba *, struct lpfc_io_buf *);
  789. void (*lpfc_scsi_unprep_dma_buf)
  790. (struct lpfc_hba *, struct lpfc_io_buf *);
  791. void (*lpfc_release_scsi_buf)
  792. (struct lpfc_hba *, struct lpfc_io_buf *);
  793. void (*lpfc_rampdown_queue_depth)
  794. (struct lpfc_hba *);
  795. void (*lpfc_scsi_prep_cmnd)
  796. (struct lpfc_vport *, struct lpfc_io_buf *,
  797. struct lpfc_nodelist *);
  798. int (*lpfc_scsi_prep_cmnd_buf)
  799. (struct lpfc_vport *vport,
  800. struct lpfc_io_buf *lpfc_cmd,
  801. uint8_t tmo);
  802. int (*lpfc_scsi_prep_task_mgmt_cmd)
  803. (struct lpfc_vport *vport,
  804. struct lpfc_io_buf *lpfc_cmd,
  805. u64 lun, u8 task_mgmt_cmd);
  806. /* IOCB interface function jump table entries */
  807. int (*__lpfc_sli_issue_iocb)
  808. (struct lpfc_hba *, uint32_t,
  809. struct lpfc_iocbq *, uint32_t);
  810. int (*__lpfc_sli_issue_fcp_io)
  811. (struct lpfc_hba *phba, uint32_t ring_number,
  812. struct lpfc_iocbq *piocb, uint32_t flag);
  813. void (*__lpfc_sli_release_iocbq)(struct lpfc_hba *,
  814. struct lpfc_iocbq *);
  815. int (*lpfc_hba_down_post)(struct lpfc_hba *phba);
  816. void (*lpfc_scsi_cmd_iocb_cmpl)
  817. (struct lpfc_hba *, struct lpfc_iocbq *, struct lpfc_iocbq *);
  818. /* MBOX interface function jump table entries */
  819. int (*lpfc_sli_issue_mbox)
  820. (struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
  821. /* Slow-path IOCB process function jump table entries */
  822. void (*lpfc_sli_handle_slow_ring_event)
  823. (struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
  824. uint32_t mask);
  825. /* INIT device interface function jump table entries */
  826. int (*lpfc_sli_hbq_to_firmware)
  827. (struct lpfc_hba *, uint32_t, struct hbq_dmabuf *);
  828. int (*lpfc_sli_brdrestart)
  829. (struct lpfc_hba *);
  830. int (*lpfc_sli_brdready)
  831. (struct lpfc_hba *, uint32_t);
  832. void (*lpfc_handle_eratt)
  833. (struct lpfc_hba *);
  834. void (*lpfc_stop_port)
  835. (struct lpfc_hba *);
  836. int (*lpfc_hba_init_link)
  837. (struct lpfc_hba *, uint32_t);
  838. int (*lpfc_hba_down_link)
  839. (struct lpfc_hba *, uint32_t);
  840. int (*lpfc_selective_reset)
  841. (struct lpfc_hba *);
  842. int (*lpfc_bg_scsi_prep_dma_buf)
  843. (struct lpfc_hba *, struct lpfc_io_buf *);
  844. /* Prep SLI WQE/IOCB jump table entries */
  845. void (*__lpfc_sli_prep_els_req_rsp)(struct lpfc_iocbq *cmdiocbq,
  846. struct lpfc_vport *vport,
  847. struct lpfc_dmabuf *bmp,
  848. u16 cmd_size, u32 did, u32 elscmd,
  849. u8 tmo, u8 expect_rsp);
  850. void (*__lpfc_sli_prep_gen_req)(struct lpfc_iocbq *cmdiocbq,
  851. struct lpfc_dmabuf *bmp, u16 rpi,
  852. u32 num_entry, u8 tmo);
  853. void (*__lpfc_sli_prep_xmit_seq64)(struct lpfc_iocbq *cmdiocbq,
  854. struct lpfc_dmabuf *bmp, u16 rpi,
  855. u16 ox_id, u32 num_entry, u8 rctl,
  856. u8 last_seq, u8 cr_cx_cmd);
  857. void (*__lpfc_sli_prep_abort_xri)(struct lpfc_iocbq *cmdiocbq,
  858. u16 ulp_context, u16 iotag,
  859. u8 ulp_class, u16 cqid, bool ia,
  860. bool wqec);
  861. /* expedite pool */
  862. struct lpfc_epd_pool epd_pool;
  863. /* SLI4 specific HBA data structure */
  864. struct lpfc_sli4_hba sli4_hba;
  865. struct workqueue_struct *wq;
  866. struct delayed_work eq_delay_work;
  867. #define LPFC_IDLE_STAT_DELAY 1000
  868. struct delayed_work idle_stat_delay_work;
  869. struct lpfc_sli sli;
  870. uint8_t pci_dev_grp; /* lpfc PCI dev group: 0x0, 0x1, 0x2,... */
  871. uint32_t sli_rev; /* SLI2, SLI3, or SLI4 */
  872. uint32_t sli3_options; /* Mask of enabled SLI3 options */
  873. #define LPFC_SLI3_HBQ_ENABLED 0x01
  874. #define LPFC_SLI3_NPIV_ENABLED 0x02
  875. #define LPFC_SLI3_VPORT_TEARDOWN 0x04
  876. #define LPFC_SLI3_CRP_ENABLED 0x08
  877. #define LPFC_SLI3_BG_ENABLED 0x20
  878. #define LPFC_SLI3_DSS_ENABLED 0x40
  879. #define LPFC_SLI4_PERFH_ENABLED 0x80
  880. #define LPFC_SLI4_PHWQ_ENABLED 0x100
  881. uint32_t iocb_cmd_size;
  882. uint32_t iocb_rsp_size;
  883. struct lpfc_trunk_link trunk_link;
  884. enum hba_state link_state;
  885. uint32_t link_flag; /* link state flags */
  886. #define LS_LOOPBACK_MODE 0x1 /* NPort is in Loopback mode */
  887. /* This flag is set while issuing */
  888. /* INIT_LINK mailbox command */
  889. #define LS_NPIV_FAB_SUPPORTED 0x2 /* Fabric supports NPIV */
  890. #define LS_IGNORE_ERATT 0x4 /* intr handler should ignore ERATT */
  891. #define LS_MDS_LINK_DOWN 0x8 /* MDS Diagnostics Link Down */
  892. #define LS_MDS_LOOPBACK 0x10 /* MDS Diagnostics Link Up (Loopback) */
  893. #define LS_CT_VEN_RPA 0x20 /* Vendor RPA sent to switch */
  894. #define LS_EXTERNAL_LOOPBACK 0x40 /* External loopback plug inserted */
  895. uint32_t hba_flag; /* hba generic flags */
  896. #define HBA_ERATT_HANDLED 0x1 /* This flag is set when eratt handled */
  897. #define DEFER_ERATT 0x2 /* Deferred error attention in progress */
  898. #define HBA_FCOE_MODE 0x4 /* HBA function in FCoE Mode */
  899. #define HBA_SP_QUEUE_EVT 0x8 /* Slow-path qevt posted to worker thread*/
  900. #define HBA_POST_RECEIVE_BUFFER 0x10 /* Rcv buffers need to be posted */
  901. #define HBA_PERSISTENT_TOPO 0x20 /* Persistent topology support in hba */
  902. #define ELS_XRI_ABORT_EVENT 0x40 /* ELS_XRI abort event was queued */
  903. #define ASYNC_EVENT 0x80
  904. #define LINK_DISABLED 0x100 /* Link disabled by user */
  905. #define FCF_TS_INPROG 0x200 /* FCF table scan in progress */
  906. #define FCF_RR_INPROG 0x400 /* FCF roundrobin flogi in progress */
  907. #define HBA_FIP_SUPPORT 0x800 /* FIP support in HBA */
  908. #define HBA_AER_ENABLED 0x1000 /* AER enabled with HBA */
  909. #define HBA_DEVLOSS_TMO 0x2000 /* HBA in devloss timeout */
  910. #define HBA_RRQ_ACTIVE 0x4000 /* process the rrq active list */
  911. #define HBA_IOQ_FLUSH 0x8000 /* FCP/NVME I/O queues being flushed */
  912. #define HBA_RECOVERABLE_UE 0x20000 /* Firmware supports recoverable UE */
  913. #define HBA_FORCED_LINK_SPEED 0x40000 /*
  914. * Firmware supports Forced Link Speed
  915. * capability
  916. */
  917. #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */
  918. #define HBA_SHORT_CMF 0x200000 /* shorter CMF timer routine */
  919. #define HBA_CGN_DAY_WRAP 0x400000 /* HBA Congestion info day wraps */
  920. #define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */
  921. #define HBA_SETUP 0x1000000 /* Signifies HBA setup is completed */
  922. #define HBA_NEEDS_CFG_PORT 0x2000000 /* SLI3 - needs a CONFIG_PORT mbox */
  923. #define HBA_HBEAT_INP 0x4000000 /* mbox HBEAT is in progress */
  924. #define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */
  925. #define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */
  926. #define HBA_RHBA_CMPL 0x20000000 /* RHBA FDMI command is successful */
  927. struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
  928. uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
  929. struct lpfc_dmabuf slim2p;
  930. MAILBOX_t *mbox;
  931. uint32_t *mbox_ext;
  932. struct lpfc_mbox_ext_buf_ctx mbox_ext_buf_ctx;
  933. uint32_t ha_copy;
  934. struct _PCB *pcb;
  935. struct _IOCB *IOCBs;
  936. struct lpfc_dmabuf hbqslimp;
  937. uint16_t pci_cfg_value;
  938. uint8_t fc_linkspeed; /* Link speed after last READ_LA */
  939. uint32_t fc_eventTag; /* event tag for link attention */
  940. uint32_t link_events;
  941. /* These fields used to be binfo */
  942. uint32_t fc_pref_DID; /* preferred D_ID */
  943. uint8_t fc_pref_ALPA; /* preferred AL_PA */
  944. uint32_t fc_edtovResol; /* E_D_TOV timer resolution */
  945. uint32_t fc_edtov; /* E_D_TOV timer value */
  946. uint32_t fc_arbtov; /* ARB_TOV timer value */
  947. uint32_t fc_ratov; /* R_A_TOV timer value */
  948. uint32_t fc_rttov; /* R_T_TOV timer value */
  949. uint32_t fc_altov; /* AL_TOV timer value */
  950. uint32_t fc_crtov; /* C_R_TOV timer value */
  951. struct serv_parm fc_fabparam; /* fabric service parameters buffer */
  952. uint8_t alpa_map[128]; /* AL_PA map from READ_LA */
  953. uint32_t lmt;
  954. uint32_t fc_topology; /* link topology, from LINK INIT */
  955. uint32_t fc_topology_changed; /* link topology, from LINK INIT */
  956. struct lpfc_stats fc_stat;
  957. struct lpfc_nodelist fc_fcpnodev; /* nodelist entry for no device */
  958. uint32_t nport_event_cnt; /* timestamp for nlplist entry */
  959. uint8_t wwnn[8];
  960. uint8_t wwpn[8];
  961. uint32_t RandomData[7];
  962. uint8_t fcp_embed_io;
  963. uint8_t nvmet_support; /* driver supports NVMET */
  964. #define LPFC_NVMET_MAX_PORTS 32
  965. uint8_t mds_diags_support;
  966. uint8_t bbcredit_support;
  967. uint8_t enab_exp_wqcq_pages;
  968. u8 nsler; /* Firmware supports FC-NVMe-2 SLER */
  969. /* HBA Config Parameters */
  970. uint32_t cfg_ack0;
  971. uint32_t cfg_xri_rebalancing;
  972. uint32_t cfg_xpsgl;
  973. uint32_t cfg_enable_npiv;
  974. uint32_t cfg_enable_rrq;
  975. uint32_t cfg_topology;
  976. uint32_t cfg_link_speed;
  977. #define LPFC_FCF_FOV 1 /* Fast fcf failover */
  978. #define LPFC_FCF_PRIORITY 2 /* Priority fcf failover */
  979. uint32_t cfg_fcf_failover_policy;
  980. uint32_t cfg_fcp_io_sched;
  981. uint32_t cfg_ns_query;
  982. uint32_t cfg_fcp2_no_tgt_reset;
  983. uint32_t cfg_cr_delay;
  984. uint32_t cfg_cr_count;
  985. uint32_t cfg_multi_ring_support;
  986. uint32_t cfg_multi_ring_rctl;
  987. uint32_t cfg_multi_ring_type;
  988. uint32_t cfg_poll;
  989. uint32_t cfg_poll_tmo;
  990. uint32_t cfg_task_mgmt_tmo;
  991. uint32_t cfg_use_msi;
  992. uint32_t cfg_auto_imax;
  993. uint32_t cfg_fcp_imax;
  994. uint32_t cfg_force_rscn;
  995. uint32_t cfg_cq_poll_threshold;
  996. uint32_t cfg_cq_max_proc_limit;
  997. uint32_t cfg_fcp_cpu_map;
  998. uint32_t cfg_fcp_mq_threshold;
  999. uint32_t cfg_hdw_queue;
  1000. uint32_t cfg_irq_chann;
  1001. uint32_t cfg_suppress_rsp;
  1002. uint32_t cfg_nvme_oas;
  1003. uint32_t cfg_nvme_embed_cmd;
  1004. uint32_t cfg_nvmet_mrq_post;
  1005. uint32_t cfg_nvmet_mrq;
  1006. uint32_t cfg_enable_nvmet;
  1007. uint32_t cfg_nvme_enable_fb;
  1008. uint32_t cfg_nvmet_fb_size;
  1009. uint32_t cfg_total_seg_cnt;
  1010. uint32_t cfg_sg_seg_cnt;
  1011. uint32_t cfg_nvme_seg_cnt;
  1012. uint32_t cfg_scsi_seg_cnt;
  1013. uint32_t cfg_sg_dma_buf_size;
  1014. uint32_t cfg_hba_queue_depth;
  1015. uint32_t cfg_enable_hba_reset;
  1016. uint32_t cfg_enable_hba_heartbeat;
  1017. uint32_t cfg_fof;
  1018. uint32_t cfg_EnableXLane;
  1019. uint8_t cfg_oas_tgt_wwpn[8];
  1020. uint8_t cfg_oas_vpt_wwpn[8];
  1021. uint32_t cfg_oas_lun_state;
  1022. #define OAS_LUN_ENABLE 1
  1023. #define OAS_LUN_DISABLE 0
  1024. uint32_t cfg_oas_lun_status;
  1025. #define OAS_LUN_STATUS_EXISTS 0x01
  1026. uint32_t cfg_oas_flags;
  1027. #define OAS_FIND_ANY_VPORT 0x01
  1028. #define OAS_FIND_ANY_TARGET 0x02
  1029. #define OAS_LUN_VALID 0x04
  1030. uint32_t cfg_oas_priority;
  1031. uint32_t cfg_XLanePriority;
  1032. uint32_t cfg_enable_bg;
  1033. uint32_t cfg_prot_mask;
  1034. uint32_t cfg_prot_guard;
  1035. uint32_t cfg_hostmem_hgp;
  1036. uint32_t cfg_log_verbose;
  1037. uint32_t cfg_enable_fc4_type;
  1038. #define LPFC_ENABLE_FCP 1
  1039. #define LPFC_ENABLE_NVME 2
  1040. #define LPFC_ENABLE_BOTH 3
  1041. #if (IS_ENABLED(CONFIG_NVME_FC))
  1042. #define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
  1043. #define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_BOTH
  1044. #else
  1045. #define LPFC_MAX_ENBL_FC4_TYPE LPFC_ENABLE_FCP
  1046. #define LPFC_DEF_ENBL_FC4_TYPE LPFC_ENABLE_FCP
  1047. #endif
  1048. uint32_t cfg_aer_support;
  1049. uint32_t cfg_sriov_nr_virtfn;
  1050. uint32_t cfg_request_firmware_upgrade;
  1051. uint32_t cfg_suppress_link_up;
  1052. uint32_t cfg_rrq_xri_bitmap_sz;
  1053. u32 cfg_fcp_wait_abts_rsp;
  1054. uint32_t cfg_delay_discovery;
  1055. uint32_t cfg_sli_mode;
  1056. #define LPFC_INITIALIZE_LINK 0 /* do normal init_link mbox */
  1057. #define LPFC_DELAY_INIT_LINK 1 /* layered driver hold off */
  1058. #define LPFC_DELAY_INIT_LINK_INDEFINITELY 2 /* wait, manual intervention */
  1059. uint32_t cfg_fdmi_on;
  1060. #define LPFC_FDMI_NO_SUPPORT 0 /* FDMI not supported */
  1061. #define LPFC_FDMI_SUPPORT 1 /* FDMI supported? */
  1062. uint32_t cfg_enable_SmartSAN;
  1063. uint32_t cfg_enable_mds_diags;
  1064. uint32_t cfg_ras_fwlog_level;
  1065. uint32_t cfg_ras_fwlog_buffsize;
  1066. uint32_t cfg_ras_fwlog_func;
  1067. uint32_t cfg_enable_bbcr; /* Enable BB Credit Recovery */
  1068. uint32_t cfg_enable_dpp; /* Enable Direct Packet Push */
  1069. uint32_t cfg_enable_pbde;
  1070. uint32_t cfg_enable_mi;
  1071. struct nvmet_fc_target_port *targetport;
  1072. lpfc_vpd_t vpd; /* vital product data */
  1073. u32 cfg_max_vmid; /* maximum VMIDs allowed per port */
  1074. u32 cfg_vmid_app_header;
  1075. #define LPFC_VMID_APP_HEADER_DISABLE 0
  1076. #define LPFC_VMID_APP_HEADER_ENABLE 1
  1077. u32 cfg_vmid_priority_tagging;
  1078. u32 cfg_vmid_inactivity_timeout; /* Time after which the VMID */
  1079. /* deregisters from switch */
  1080. struct pci_dev *pcidev;
  1081. struct list_head work_list;
  1082. uint32_t work_ha; /* Host Attention Bits for WT */
  1083. uint32_t work_ha_mask; /* HA Bits owned by WT */
  1084. uint32_t work_hs; /* HS stored in case of ERRAT */
  1085. uint32_t work_status[2]; /* Extra status from SLIM */
  1086. wait_queue_head_t work_waitq;
  1087. struct task_struct *worker_thread;
  1088. unsigned long data_flags;
  1089. uint32_t border_sge_num;
  1090. uint32_t hbq_in_use; /* HBQs in use flag */
  1091. uint32_t hbq_count; /* Count of configured HBQs */
  1092. struct hbq_s hbqs[LPFC_MAX_HBQS]; /* local copy of hbq indicies */
  1093. atomic_t fcp_qidx; /* next FCP WQ (RR Policy) */
  1094. atomic_t nvme_qidx; /* next NVME WQ (RR Policy) */
  1095. phys_addr_t pci_bar0_map; /* Physical address for PCI BAR0 */
  1096. phys_addr_t pci_bar1_map; /* Physical address for PCI BAR1 */
  1097. phys_addr_t pci_bar2_map; /* Physical address for PCI BAR2 */
  1098. void __iomem *slim_memmap_p; /* Kernel memory mapped address for
  1099. PCI BAR0 */
  1100. void __iomem *ctrl_regs_memmap_p;/* Kernel memory mapped address for
  1101. PCI BAR2 */
  1102. void __iomem *pci_bar0_memmap_p; /* Kernel memory mapped address for
  1103. PCI BAR0 with dual-ULP support */
  1104. void __iomem *pci_bar2_memmap_p; /* Kernel memory mapped address for
  1105. PCI BAR2 with dual-ULP support */
  1106. void __iomem *pci_bar4_memmap_p; /* Kernel memory mapped address for
  1107. PCI BAR4 with dual-ULP support */
  1108. #define PCI_64BIT_BAR0 0
  1109. #define PCI_64BIT_BAR2 2
  1110. #define PCI_64BIT_BAR4 4
  1111. void __iomem *MBslimaddr; /* virtual address for mbox cmds */
  1112. void __iomem *HAregaddr; /* virtual address for host attn reg */
  1113. void __iomem *CAregaddr; /* virtual address for chip attn reg */
  1114. void __iomem *HSregaddr; /* virtual address for host status
  1115. reg */
  1116. void __iomem *HCregaddr; /* virtual address for host ctl reg */
  1117. struct lpfc_hgp __iomem *host_gp; /* Host side get/put pointers */
  1118. struct lpfc_pgp *port_gp;
  1119. uint32_t __iomem *hbq_put; /* Address in SLIM to HBQ put ptrs */
  1120. uint32_t *hbq_get; /* Host mem address of HBQ get ptrs */
  1121. int brd_no; /* FC board number */
  1122. char SerialNumber[32]; /* adapter Serial Number */
  1123. char OptionROMVersion[32]; /* adapter BIOS / Fcode version */
  1124. char BIOSVersion[16]; /* Boot BIOS version */
  1125. char ModelDesc[256]; /* Model Description */
  1126. char ModelName[80]; /* Model Name */
  1127. char ProgramType[256]; /* Program Type */
  1128. char Port[20]; /* Port No */
  1129. uint8_t vpd_flag; /* VPD data flag */
  1130. #define VPD_MODEL_DESC 0x1 /* valid vpd model description */
  1131. #define VPD_MODEL_NAME 0x2 /* valid vpd model name */
  1132. #define VPD_PROGRAM_TYPE 0x4 /* valid vpd program type */
  1133. #define VPD_PORT 0x8 /* valid vpd port data */
  1134. #define VPD_MASK 0xf /* mask for any vpd data */
  1135. struct timer_list fcp_poll_timer;
  1136. struct timer_list eratt_poll;
  1137. uint32_t eratt_poll_interval;
  1138. uint64_t bg_guard_err_cnt;
  1139. uint64_t bg_apptag_err_cnt;
  1140. uint64_t bg_reftag_err_cnt;
  1141. /* fastpath list. */
  1142. spinlock_t scsi_buf_list_get_lock; /* SCSI buf alloc list lock */
  1143. spinlock_t scsi_buf_list_put_lock; /* SCSI buf free list lock */
  1144. struct list_head lpfc_scsi_buf_list_get;
  1145. struct list_head lpfc_scsi_buf_list_put;
  1146. uint32_t total_scsi_bufs;
  1147. struct list_head lpfc_iocb_list;
  1148. uint32_t total_iocbq_bufs;
  1149. struct list_head active_rrq_list;
  1150. spinlock_t hbalock;
  1151. struct work_struct unblock_request_work; /* SCSI layer unblock IOs */
  1152. /* dma_mem_pools */
  1153. struct dma_pool *lpfc_sg_dma_buf_pool;
  1154. struct dma_pool *lpfc_mbuf_pool;
  1155. struct dma_pool *lpfc_hrb_pool; /* header receive buffer pool */
  1156. struct dma_pool *lpfc_drb_pool; /* data receive buffer pool */
  1157. struct dma_pool *lpfc_nvmet_drb_pool; /* data receive buffer pool */
  1158. struct dma_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
  1159. struct dma_pool *lpfc_cmd_rsp_buf_pool;
  1160. struct lpfc_dma_pool lpfc_mbuf_safety_pool;
  1161. mempool_t *mbox_mem_pool;
  1162. mempool_t *nlp_mem_pool;
  1163. mempool_t *rrq_pool;
  1164. mempool_t *active_rrq_pool;
  1165. struct fc_host_statistics link_stats;
  1166. enum lpfc_irq_chann_mode irq_chann_mode;
  1167. enum intr_type_t intr_type;
  1168. uint32_t intr_mode;
  1169. #define LPFC_INTR_ERROR 0xFFFFFFFF
  1170. struct list_head port_list;
  1171. spinlock_t port_list_lock; /* lock for port_list mutations */
  1172. struct lpfc_vport *pport; /* physical lpfc_vport pointer */
  1173. uint16_t max_vpi; /* Maximum virtual nports */
  1174. #define LPFC_MAX_VPI 0xFF /* Max number VPI supported 0 - 0xff */
  1175. #define LPFC_MAX_VPORTS 0x100 /* Max vports per port, with pport */
  1176. uint16_t max_vports; /*
  1177. * For IOV HBAs max_vpi can change
  1178. * after a reset. max_vports is max
  1179. * number of vports present. This can
  1180. * be greater than max_vpi.
  1181. */
  1182. uint16_t vpi_base;
  1183. uint16_t vfi_base;
  1184. unsigned long *vpi_bmask; /* vpi allocation table */
  1185. uint16_t *vpi_ids;
  1186. uint16_t vpi_count;
  1187. struct list_head lpfc_vpi_blk_list;
  1188. /* Data structure used by fabric iocb scheduler */
  1189. struct list_head fabric_iocb_list;
  1190. atomic_t fabric_iocb_count;
  1191. struct timer_list fabric_block_timer;
  1192. unsigned long bit_flags;
  1193. atomic_t num_rsrc_err;
  1194. atomic_t num_cmd_success;
  1195. unsigned long last_rsrc_error_time;
  1196. unsigned long last_ramp_down_time;
  1197. #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
  1198. struct dentry *hba_debugfs_root;
  1199. atomic_t debugfs_vport_count;
  1200. struct dentry *debug_multixri_pools;
  1201. struct dentry *debug_hbqinfo;
  1202. struct dentry *debug_dumpHostSlim;
  1203. struct dentry *debug_dumpHBASlim;
  1204. struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
  1205. struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
  1206. struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */
  1207. struct dentry *debug_writeGuard; /* inject write guard_tag errors */
  1208. struct dentry *debug_writeApp; /* inject write app_tag errors */
  1209. struct dentry *debug_writeRef; /* inject write ref_tag errors */
  1210. struct dentry *debug_readGuard; /* inject read guard_tag errors */
  1211. struct dentry *debug_readApp; /* inject read app_tag errors */
  1212. struct dentry *debug_readRef; /* inject read ref_tag errors */
  1213. struct dentry *debug_nvmeio_trc;
  1214. struct lpfc_debugfs_nvmeio_trc *nvmeio_trc;
  1215. struct dentry *debug_hdwqinfo;
  1216. #ifdef LPFC_HDWQ_LOCK_STAT
  1217. struct dentry *debug_lockstat;
  1218. #endif
  1219. struct dentry *debug_cgn_buffer;
  1220. struct dentry *debug_rx_monitor;
  1221. struct dentry *debug_ras_log;
  1222. atomic_t nvmeio_trc_cnt;
  1223. uint32_t nvmeio_trc_size;
  1224. uint32_t nvmeio_trc_output_idx;
  1225. /* T10 DIF error injection */
  1226. uint32_t lpfc_injerr_wgrd_cnt;
  1227. uint32_t lpfc_injerr_wapp_cnt;
  1228. uint32_t lpfc_injerr_wref_cnt;
  1229. uint32_t lpfc_injerr_rgrd_cnt;
  1230. uint32_t lpfc_injerr_rapp_cnt;
  1231. uint32_t lpfc_injerr_rref_cnt;
  1232. uint32_t lpfc_injerr_nportid;
  1233. struct lpfc_name lpfc_injerr_wwpn;
  1234. sector_t lpfc_injerr_lba;
  1235. #define LPFC_INJERR_LBA_OFF (sector_t)(-1)
  1236. struct dentry *debug_slow_ring_trc;
  1237. struct lpfc_debugfs_trc *slow_ring_trc;
  1238. atomic_t slow_ring_trc_cnt;
  1239. /* iDiag debugfs sub-directory */
  1240. struct dentry *idiag_root;
  1241. struct dentry *idiag_pci_cfg;
  1242. struct dentry *idiag_bar_acc;
  1243. struct dentry *idiag_que_info;
  1244. struct dentry *idiag_que_acc;
  1245. struct dentry *idiag_drb_acc;
  1246. struct dentry *idiag_ctl_acc;
  1247. struct dentry *idiag_mbx_acc;
  1248. struct dentry *idiag_ext_acc;
  1249. uint8_t lpfc_idiag_last_eq;
  1250. #endif
  1251. uint16_t nvmeio_trc_on;
  1252. /* Used for deferred freeing of ELS data buffers */
  1253. struct list_head elsbuf;
  1254. int elsbuf_cnt;
  1255. int elsbuf_prev_cnt;
  1256. uint8_t temp_sensor_support;
  1257. /* Fields used for heart beat. */
  1258. unsigned long last_completion_time;
  1259. unsigned long skipped_hb;
  1260. struct timer_list hb_tmofunc;
  1261. struct timer_list rrq_tmr;
  1262. enum hba_temp_state over_temp_state;
  1263. /*
  1264. * Following bit will be set for all buffer tags which are not
  1265. * associated with any HBQ.
  1266. */
  1267. #define QUE_BUFTAG_BIT (1<<31)
  1268. uint32_t buffer_tag_count;
  1269. /* Maximum number of events that can be outstanding at any time*/
  1270. #define LPFC_MAX_EVT_COUNT 512
  1271. atomic_t fast_event_count;
  1272. uint32_t fcoe_eventtag;
  1273. uint32_t fcoe_eventtag_at_fcf_scan;
  1274. uint32_t fcoe_cvl_eventtag;
  1275. uint32_t fcoe_cvl_eventtag_attn;
  1276. struct lpfc_fcf fcf;
  1277. uint8_t fc_map[3];
  1278. uint8_t valid_vlan;
  1279. uint16_t vlan_id;
  1280. struct list_head fcf_conn_rec_list;
  1281. bool defer_flogi_acc_flag;
  1282. uint16_t defer_flogi_acc_rx_id;
  1283. uint16_t defer_flogi_acc_ox_id;
  1284. spinlock_t ct_ev_lock; /* synchronize access to ct_ev_waiters */
  1285. struct list_head ct_ev_waiters;
  1286. struct unsol_rcv_ct_ctx ct_ctx[LPFC_CT_CTX_MAX];
  1287. uint32_t ctx_idx;
  1288. struct timer_list inactive_vmid_poll;
  1289. /* RAS Support */
  1290. struct lpfc_ras_fwlog ras_fwlog;
  1291. uint32_t iocb_cnt;
  1292. uint32_t iocb_max;
  1293. atomic_t sdev_cnt;
  1294. spinlock_t devicelock; /* lock for luns list */
  1295. mempool_t *device_data_mem_pool;
  1296. struct list_head luns;
  1297. #define LPFC_TRANSGRESSION_HIGH_TEMPERATURE 0x0080
  1298. #define LPFC_TRANSGRESSION_LOW_TEMPERATURE 0x0040
  1299. #define LPFC_TRANSGRESSION_HIGH_VOLTAGE 0x0020
  1300. #define LPFC_TRANSGRESSION_LOW_VOLTAGE 0x0010
  1301. #define LPFC_TRANSGRESSION_HIGH_TXBIAS 0x0008
  1302. #define LPFC_TRANSGRESSION_LOW_TXBIAS 0x0004
  1303. #define LPFC_TRANSGRESSION_HIGH_TXPOWER 0x0002
  1304. #define LPFC_TRANSGRESSION_LOW_TXPOWER 0x0001
  1305. #define LPFC_TRANSGRESSION_HIGH_RXPOWER 0x8000
  1306. #define LPFC_TRANSGRESSION_LOW_RXPOWER 0x4000
  1307. uint16_t sfp_alarm;
  1308. uint16_t sfp_warning;
  1309. #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
  1310. uint16_t hdwqstat_on;
  1311. #define LPFC_CHECK_OFF 0
  1312. #define LPFC_CHECK_NVME_IO 1
  1313. #define LPFC_CHECK_NVMET_IO 2
  1314. #define LPFC_CHECK_SCSI_IO 4
  1315. uint16_t ktime_on;
  1316. uint64_t ktime_data_samples;
  1317. uint64_t ktime_status_samples;
  1318. uint64_t ktime_last_cmd;
  1319. uint64_t ktime_seg1_total;
  1320. uint64_t ktime_seg1_min;
  1321. uint64_t ktime_seg1_max;
  1322. uint64_t ktime_seg2_total;
  1323. uint64_t ktime_seg2_min;
  1324. uint64_t ktime_seg2_max;
  1325. uint64_t ktime_seg3_total;
  1326. uint64_t ktime_seg3_min;
  1327. uint64_t ktime_seg3_max;
  1328. uint64_t ktime_seg4_total;
  1329. uint64_t ktime_seg4_min;
  1330. uint64_t ktime_seg4_max;
  1331. uint64_t ktime_seg5_total;
  1332. uint64_t ktime_seg5_min;
  1333. uint64_t ktime_seg5_max;
  1334. uint64_t ktime_seg6_total;
  1335. uint64_t ktime_seg6_min;
  1336. uint64_t ktime_seg6_max;
  1337. uint64_t ktime_seg7_total;
  1338. uint64_t ktime_seg7_min;
  1339. uint64_t ktime_seg7_max;
  1340. uint64_t ktime_seg8_total;
  1341. uint64_t ktime_seg8_min;
  1342. uint64_t ktime_seg8_max;
  1343. uint64_t ktime_seg9_total;
  1344. uint64_t ktime_seg9_min;
  1345. uint64_t ktime_seg9_max;
  1346. uint64_t ktime_seg10_total;
  1347. uint64_t ktime_seg10_min;
  1348. uint64_t ktime_seg10_max;
  1349. #endif
  1350. /* CMF objects */
  1351. struct lpfc_cgn_stat __percpu *cmf_stat;
  1352. uint32_t cmf_interval_rate; /* timer interval limit in ms */
  1353. uint32_t cmf_timer_cnt;
  1354. #define LPFC_CMF_INTERVAL 90
  1355. uint64_t cmf_link_byte_count;
  1356. uint64_t cmf_max_line_rate;
  1357. uint64_t cmf_max_bytes_per_interval;
  1358. uint64_t cmf_last_sync_bw;
  1359. #define LPFC_CMF_BLK_SIZE 512
  1360. struct hrtimer cmf_timer;
  1361. atomic_t cmf_bw_wait;
  1362. atomic_t cmf_busy;
  1363. atomic_t cmf_stop_io; /* To block request and stop IO's */
  1364. uint32_t cmf_active_mode;
  1365. uint32_t cmf_info_per_interval;
  1366. #define LPFC_MAX_CMF_INFO 32
  1367. struct timespec64 cmf_latency; /* Interval congestion timestamp */
  1368. uint32_t cmf_last_ts; /* Interval congestion time (ms) */
  1369. uint32_t cmf_active_info;
  1370. /* Signal / FPIN handling for Congestion Mgmt */
  1371. u8 cgn_reg_fpin; /* Negotiated value from RDF */
  1372. u8 cgn_init_reg_fpin; /* Initial value from READ_CONFIG */
  1373. #define LPFC_CGN_FPIN_NONE 0x0
  1374. #define LPFC_CGN_FPIN_WARN 0x1
  1375. #define LPFC_CGN_FPIN_ALARM 0x2
  1376. #define LPFC_CGN_FPIN_BOTH (LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM)
  1377. u8 cgn_reg_signal; /* Negotiated value from EDC */
  1378. u8 cgn_init_reg_signal; /* Initial value from READ_CONFIG */
  1379. /* cgn_reg_signal and cgn_init_reg_signal use
  1380. * enum fc_edc_cg_signal_cap_types
  1381. */
  1382. u16 cgn_fpin_frequency; /* In units of msecs */
  1383. #define LPFC_FPIN_INIT_FREQ 0xffff
  1384. u32 cgn_sig_freq;
  1385. u32 cgn_acqe_cnt;
  1386. /* RX monitor handling for CMF */
  1387. struct lpfc_rx_info_monitor *rx_monitor;
  1388. atomic_t rx_max_read_cnt; /* Maximum read bytes */
  1389. uint64_t rx_block_cnt;
  1390. /* Congestion parameters from flash */
  1391. struct lpfc_cgn_param cgn_p;
  1392. /* Statistics counter for ACQE cgn alarms and warnings */
  1393. struct lpfc_cgn_acqe_stat cgn_acqe_stat;
  1394. /* Congestion buffer information */
  1395. struct lpfc_dmabuf *cgn_i; /* Congestion Info buffer */
  1396. atomic_t cgn_fabric_warn_cnt; /* Total warning cgn events for info */
  1397. atomic_t cgn_fabric_alarm_cnt; /* Total alarm cgn events for info */
  1398. atomic_t cgn_sync_warn_cnt; /* Total warning events for SYNC wqe */
  1399. atomic_t cgn_sync_alarm_cnt; /* Total alarm events for SYNC wqe */
  1400. atomic_t cgn_driver_evt_cnt; /* Total driver cgn events for fmw */
  1401. atomic_t cgn_latency_evt_cnt;
  1402. struct timespec64 cgn_daily_ts;
  1403. atomic64_t cgn_latency_evt; /* Avg latency per minute */
  1404. unsigned long cgn_evt_timestamp;
  1405. #define LPFC_CGN_TIMER_TO_MIN 60000 /* ms in a minute */
  1406. uint32_t cgn_evt_minute;
  1407. #define LPFC_SEC_MIN 60
  1408. #define LPFC_MIN_HOUR 60
  1409. #define LPFC_HOUR_DAY 24
  1410. #define LPFC_MIN_DAY (LPFC_MIN_HOUR * LPFC_HOUR_DAY)
  1411. struct hlist_node cpuhp; /* used for cpuhp per hba callback */
  1412. struct timer_list cpuhp_poll_timer;
  1413. struct list_head poll_list; /* slowpath eq polling list */
  1414. #define LPFC_POLL_HB 1 /* slowpath heartbeat */
  1415. #define LPFC_POLL_FASTPATH 0 /* called from fastpath */
  1416. #define LPFC_POLL_SLOWPATH 1 /* called from slowpath */
  1417. char os_host_name[MAXHOSTNAMELEN];
  1418. /* LD Signaling */
  1419. u32 degrade_activate_threshold;
  1420. u32 degrade_deactivate_threshold;
  1421. u32 fec_degrade_interval;
  1422. atomic_t dbg_log_idx;
  1423. atomic_t dbg_log_cnt;
  1424. atomic_t dbg_log_dmping;
  1425. struct dbg_log_ent dbg_log[DBG_LOG_SZ];
  1426. };
  1427. #define LPFC_MAX_RXMONITOR_ENTRY 800
  1428. #define LPFC_MAX_RXMONITOR_DUMP 32
  1429. struct rx_info_entry {
  1430. uint64_t cmf_bytes; /* Total no of read bytes for CMF_SYNC_WQE */
  1431. uint64_t total_bytes; /* Total no of read bytes requested */
  1432. uint64_t rcv_bytes; /* Total no of read bytes completed */
  1433. uint64_t avg_io_size;
  1434. uint64_t avg_io_latency;/* Average io latency in microseconds */
  1435. uint64_t max_read_cnt; /* Maximum read bytes */
  1436. uint64_t max_bytes_per_interval;
  1437. uint32_t cmf_busy;
  1438. uint32_t cmf_info; /* CMF_SYNC_WQE info */
  1439. uint32_t io_cnt;
  1440. uint32_t timer_utilization;
  1441. uint32_t timer_interval;
  1442. };
  1443. struct lpfc_rx_info_monitor {
  1444. struct rx_info_entry *ring; /* info organized in a circular buffer */
  1445. u32 head_idx, tail_idx; /* index to head/tail of ring */
  1446. spinlock_t lock; /* spinlock for ring */
  1447. u32 entries; /* storing number entries/size of ring */
  1448. };
  1449. static inline struct Scsi_Host *
  1450. lpfc_shost_from_vport(struct lpfc_vport *vport)
  1451. {
  1452. return container_of((void *) vport, struct Scsi_Host, hostdata[0]);
  1453. }
  1454. static inline void
  1455. lpfc_set_loopback_flag(struct lpfc_hba *phba)
  1456. {
  1457. if (phba->cfg_topology == FLAGS_LOCAL_LB)
  1458. phba->link_flag |= LS_LOOPBACK_MODE;
  1459. else
  1460. phba->link_flag &= ~LS_LOOPBACK_MODE;
  1461. }
  1462. static inline int
  1463. lpfc_is_link_up(struct lpfc_hba *phba)
  1464. {
  1465. return phba->link_state == LPFC_LINK_UP ||
  1466. phba->link_state == LPFC_CLEAR_LA ||
  1467. phba->link_state == LPFC_HBA_READY;
  1468. }
  1469. static inline void
  1470. lpfc_worker_wake_up(struct lpfc_hba *phba)
  1471. {
  1472. /* Set the lpfc data pending flag */
  1473. set_bit(LPFC_DATA_READY, &phba->data_flags);
  1474. /* Wake up worker thread */
  1475. wake_up(&phba->work_waitq);
  1476. return;
  1477. }
  1478. static inline int
  1479. lpfc_readl(void __iomem *addr, uint32_t *data)
  1480. {
  1481. uint32_t temp;
  1482. temp = readl(addr);
  1483. if (temp == 0xffffffff)
  1484. return -EIO;
  1485. *data = temp;
  1486. return 0;
  1487. }
  1488. static inline int
  1489. lpfc_sli_read_hs(struct lpfc_hba *phba)
  1490. {
  1491. /*
  1492. * There was a link/board error. Read the status register to retrieve
  1493. * the error event and process it.
  1494. */
  1495. phba->sli.slistat.err_attn_event++;
  1496. /* Save status info and check for unplug error */
  1497. if (lpfc_readl(phba->HSregaddr, &phba->work_hs) ||
  1498. lpfc_readl(phba->MBslimaddr + 0xa8, &phba->work_status[0]) ||
  1499. lpfc_readl(phba->MBslimaddr + 0xac, &phba->work_status[1])) {
  1500. return -EIO;
  1501. }
  1502. /* Clear chip Host Attention error bit */
  1503. writel(HA_ERATT, phba->HAregaddr);
  1504. readl(phba->HAregaddr); /* flush */
  1505. phba->pport->stopped = 1;
  1506. return 0;
  1507. }
  1508. static inline struct lpfc_sli_ring *
  1509. lpfc_phba_elsring(struct lpfc_hba *phba)
  1510. {
  1511. /* Return NULL if sli_rev has become invalid due to bad fw */
  1512. if (phba->sli_rev != LPFC_SLI_REV4 &&
  1513. phba->sli_rev != LPFC_SLI_REV3 &&
  1514. phba->sli_rev != LPFC_SLI_REV2)
  1515. return NULL;
  1516. if (phba->sli_rev == LPFC_SLI_REV4) {
  1517. if (phba->sli4_hba.els_wq)
  1518. return phba->sli4_hba.els_wq->pring;
  1519. else
  1520. return NULL;
  1521. }
  1522. return &phba->sli.sli3_ring[LPFC_ELS_RING];
  1523. }
  1524. /**
  1525. * lpfc_next_online_cpu - Finds next online CPU on cpumask
  1526. * @mask: Pointer to phba's cpumask member.
  1527. * @start: starting cpu index
  1528. *
  1529. * Note: If no valid cpu found, then nr_cpu_ids is returned.
  1530. *
  1531. **/
  1532. static inline unsigned int
  1533. lpfc_next_online_cpu(const struct cpumask *mask, unsigned int start)
  1534. {
  1535. unsigned int cpu_it;
  1536. for_each_cpu_wrap(cpu_it, mask, start) {
  1537. if (cpu_online(cpu_it))
  1538. break;
  1539. }
  1540. return cpu_it;
  1541. }
  1542. /**
  1543. * lpfc_sli4_mod_hba_eq_delay - update EQ delay
  1544. * @phba: Pointer to HBA context object.
  1545. * @q: The Event Queue to update.
  1546. * @delay: The delay value (in us) to be written.
  1547. *
  1548. **/
  1549. static inline void
  1550. lpfc_sli4_mod_hba_eq_delay(struct lpfc_hba *phba, struct lpfc_queue *eq,
  1551. u32 delay)
  1552. {
  1553. struct lpfc_register reg_data;
  1554. reg_data.word0 = 0;
  1555. bf_set(lpfc_sliport_eqdelay_id, &reg_data, eq->queue_id);
  1556. bf_set(lpfc_sliport_eqdelay_delay, &reg_data, delay);
  1557. writel(reg_data.word0, phba->sli4_hba.u.if_type2.EQDregaddr);
  1558. eq->q_mode = delay;
  1559. }
  1560. /*
  1561. * Macro that declares tables and a routine to perform enum type to
  1562. * ascii string lookup.
  1563. *
  1564. * Defines a <key,value> table for an enum. Uses xxx_INIT defines for
  1565. * the enum to populate the table. Macro defines a routine (named
  1566. * by caller) that will search all elements of the table for the key
  1567. * and return the name string if found or "Unrecognized" if not found.
  1568. */
  1569. #define DECLARE_ENUM2STR_LOOKUP(routine, enum_name, enum_init) \
  1570. static struct { \
  1571. enum enum_name value; \
  1572. char *name; \
  1573. } fc_##enum_name##_e2str_names[] = enum_init; \
  1574. static const char *routine(enum enum_name table_key) \
  1575. { \
  1576. int i; \
  1577. char *name = "Unrecognized"; \
  1578. \
  1579. for (i = 0; i < ARRAY_SIZE(fc_##enum_name##_e2str_names); i++) {\
  1580. if (fc_##enum_name##_e2str_names[i].value == table_key) {\
  1581. name = fc_##enum_name##_e2str_names[i].name; \
  1582. break; \
  1583. } \
  1584. } \
  1585. return name; \
  1586. }
  1587. /**
  1588. * lpfc_is_vmid_enabled - returns if VMID is enabled for either switch types
  1589. * @phba: Pointer to HBA context object.
  1590. *
  1591. * Relationship between the enable, target support and if vmid tag is required
  1592. * for the particular combination
  1593. * ---------------------------------------------------
  1594. * Switch Enable Flag Target Support VMID Needed
  1595. * ---------------------------------------------------
  1596. * App Id 0 NA N
  1597. * App Id 1 0 N
  1598. * App Id 1 1 Y
  1599. * Pr Tag 0 NA N
  1600. * Pr Tag 1 0 N
  1601. * Pr Tag 1 1 Y
  1602. * Pr Tag 2 * Y
  1603. ---------------------------------------------------
  1604. *
  1605. **/
  1606. static inline int lpfc_is_vmid_enabled(struct lpfc_hba *phba)
  1607. {
  1608. return phba->cfg_vmid_app_header || phba->cfg_vmid_priority_tagging;
  1609. }
  1610. static inline
  1611. u8 get_job_ulpstatus(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1612. {
  1613. if (phba->sli_rev == LPFC_SLI_REV4)
  1614. return bf_get(lpfc_wcqe_c_status, &iocbq->wcqe_cmpl);
  1615. else
  1616. return iocbq->iocb.ulpStatus;
  1617. }
  1618. static inline
  1619. u32 get_job_word4(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1620. {
  1621. if (phba->sli_rev == LPFC_SLI_REV4)
  1622. return iocbq->wcqe_cmpl.parameter;
  1623. else
  1624. return iocbq->iocb.un.ulpWord[4];
  1625. }
  1626. static inline
  1627. u8 get_job_cmnd(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1628. {
  1629. if (phba->sli_rev == LPFC_SLI_REV4)
  1630. return bf_get(wqe_cmnd, &iocbq->wqe.generic.wqe_com);
  1631. else
  1632. return iocbq->iocb.ulpCommand;
  1633. }
  1634. static inline
  1635. u16 get_job_ulpcontext(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1636. {
  1637. if (phba->sli_rev == LPFC_SLI_REV4)
  1638. return bf_get(wqe_ctxt_tag, &iocbq->wqe.generic.wqe_com);
  1639. else
  1640. return iocbq->iocb.ulpContext;
  1641. }
  1642. static inline
  1643. u16 get_job_rcvoxid(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1644. {
  1645. if (phba->sli_rev == LPFC_SLI_REV4)
  1646. return bf_get(wqe_rcvoxid, &iocbq->wqe.generic.wqe_com);
  1647. else
  1648. return iocbq->iocb.unsli3.rcvsli3.ox_id;
  1649. }
  1650. static inline
  1651. u32 get_job_data_placed(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1652. {
  1653. if (phba->sli_rev == LPFC_SLI_REV4)
  1654. return iocbq->wcqe_cmpl.total_data_placed;
  1655. else
  1656. return iocbq->iocb.un.genreq64.bdl.bdeSize;
  1657. }
  1658. static inline
  1659. u32 get_job_abtsiotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1660. {
  1661. if (phba->sli_rev == LPFC_SLI_REV4)
  1662. return iocbq->wqe.abort_cmd.wqe_com.abort_tag;
  1663. else
  1664. return iocbq->iocb.un.acxri.abortIoTag;
  1665. }
  1666. static inline
  1667. u32 get_job_els_rsp64_did(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
  1668. {
  1669. if (phba->sli_rev == LPFC_SLI_REV4)
  1670. return bf_get(wqe_els_did, &iocbq->wqe.els_req.wqe_dest);
  1671. else
  1672. return iocbq->iocb.un.elsreq64.remoteID;
  1673. }