lpfc_sli4.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2017 Broadcom. All Rights Reserved. The term *
  5. * “Broadcom” refers to Broadcom Limited and/or its subsidiaries. *
  6. * Copyright (C) 2009-2016 Emulex. All rights reserved. *
  7. * EMULEX and SLI are trademarks of Emulex. *
  8. * www.broadcom.com *
  9. * *
  10. * This program is free software; you can redistribute it and/or *
  11. * modify it under the terms of version 2 of the GNU General *
  12. * Public License as published by the Free Software Foundation. *
  13. * This program is distributed in the hope that it will be useful. *
  14. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  15. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  16. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  17. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  18. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  19. * more details, a copy of which can be found in the file COPYING *
  20. * included with this package. *
  21. *******************************************************************/
  22. #define LPFC_ACTIVE_MBOX_WAIT_CNT 100
  23. #define LPFC_XRI_EXCH_BUSY_WAIT_TMO 10000
  24. #define LPFC_XRI_EXCH_BUSY_WAIT_T1 10
  25. #define LPFC_XRI_EXCH_BUSY_WAIT_T2 30000
  26. #define LPFC_RPI_LOW_WATER_MARK 10
  27. #define LPFC_UNREG_FCF 1
  28. #define LPFC_SKIP_UNREG_FCF 0
  29. /* Amount of time in seconds for waiting FCF rediscovery to complete */
  30. #define LPFC_FCF_REDISCOVER_WAIT_TMO 2000 /* msec */
  31. /* Number of SGL entries can be posted in a 4KB nonembedded mbox command */
  32. #define LPFC_NEMBED_MBOX_SGL_CNT 254
  33. /* Multi-queue arrangement for FCP EQ/CQ/WQ tuples */
  34. #define LPFC_HBA_IO_CHAN_MIN 0
  35. #define LPFC_HBA_IO_CHAN_MAX 32
  36. #define LPFC_FCP_IO_CHAN_DEF 4
  37. #define LPFC_NVME_IO_CHAN_DEF 0
  38. /* Number of channels used for Flash Optimized Fabric (FOF) operations */
  39. #define LPFC_FOF_IO_CHAN_NUM 1
  40. /*
  41. * Provide the default FCF Record attributes used by the driver
  42. * when nonFIP mode is configured and there is no other default
  43. * FCF Record attributes.
  44. */
  45. #define LPFC_FCOE_FCF_DEF_INDEX 0
  46. #define LPFC_FCOE_FCF_GET_FIRST 0xFFFF
  47. #define LPFC_FCOE_FCF_NEXT_NONE 0xFFFF
  48. #define LPFC_FCOE_NULL_VID 0xFFF
  49. #define LPFC_FCOE_IGNORE_VID 0xFFFF
  50. /* First 3 bytes of default FCF MAC is specified by FC_MAP */
  51. #define LPFC_FCOE_FCF_MAC3 0xFF
  52. #define LPFC_FCOE_FCF_MAC4 0xFF
  53. #define LPFC_FCOE_FCF_MAC5 0xFE
  54. #define LPFC_FCOE_FCF_MAP0 0x0E
  55. #define LPFC_FCOE_FCF_MAP1 0xFC
  56. #define LPFC_FCOE_FCF_MAP2 0x00
  57. #define LPFC_FCOE_MAX_RCV_SIZE 0x800
  58. #define LPFC_FCOE_FKA_ADV_PER 0
  59. #define LPFC_FCOE_FIP_PRIORITY 0x80
  60. #define sli4_sid_from_fc_hdr(fc_hdr) \
  61. ((fc_hdr)->fh_s_id[0] << 16 | \
  62. (fc_hdr)->fh_s_id[1] << 8 | \
  63. (fc_hdr)->fh_s_id[2])
  64. #define sli4_did_from_fc_hdr(fc_hdr) \
  65. ((fc_hdr)->fh_d_id[0] << 16 | \
  66. (fc_hdr)->fh_d_id[1] << 8 | \
  67. (fc_hdr)->fh_d_id[2])
  68. #define sli4_fctl_from_fc_hdr(fc_hdr) \
  69. ((fc_hdr)->fh_f_ctl[0] << 16 | \
  70. (fc_hdr)->fh_f_ctl[1] << 8 | \
  71. (fc_hdr)->fh_f_ctl[2])
  72. #define sli4_type_from_fc_hdr(fc_hdr) \
  73. ((fc_hdr)->fh_type)
  74. #define LPFC_FW_RESET_MAXIMUM_WAIT_10MS_CNT 12000
  75. #define INT_FW_UPGRADE 0
  76. #define RUN_FW_UPGRADE 1
  77. enum lpfc_sli4_queue_type {
  78. LPFC_EQ,
  79. LPFC_GCQ,
  80. LPFC_MCQ,
  81. LPFC_WCQ,
  82. LPFC_RCQ,
  83. LPFC_MQ,
  84. LPFC_WQ,
  85. LPFC_HRQ,
  86. LPFC_DRQ
  87. };
  88. /* The queue sub-type defines the functional purpose of the queue */
  89. enum lpfc_sli4_queue_subtype {
  90. LPFC_NONE,
  91. LPFC_MBOX,
  92. LPFC_FCP,
  93. LPFC_ELS,
  94. LPFC_NVME,
  95. LPFC_NVMET,
  96. LPFC_NVME_LS,
  97. LPFC_USOL
  98. };
  99. union sli4_qe {
  100. void *address;
  101. struct lpfc_eqe *eqe;
  102. struct lpfc_cqe *cqe;
  103. struct lpfc_mcqe *mcqe;
  104. struct lpfc_wcqe_complete *wcqe_complete;
  105. struct lpfc_wcqe_release *wcqe_release;
  106. struct sli4_wcqe_xri_aborted *wcqe_xri_aborted;
  107. struct lpfc_rcqe_complete *rcqe_complete;
  108. struct lpfc_mqe *mqe;
  109. union lpfc_wqe *wqe;
  110. union lpfc_wqe128 *wqe128;
  111. struct lpfc_rqe *rqe;
  112. };
  113. /* RQ buffer list */
  114. struct lpfc_rqb {
  115. uint16_t entry_count; /* Current number of RQ slots */
  116. uint16_t buffer_count; /* Current number of buffers posted */
  117. struct list_head rqb_buffer_list; /* buffers assigned to this HBQ */
  118. /* Callback for HBQ buffer allocation */
  119. struct rqb_dmabuf *(*rqb_alloc_buffer)(struct lpfc_hba *);
  120. /* Callback for HBQ buffer free */
  121. void (*rqb_free_buffer)(struct lpfc_hba *,
  122. struct rqb_dmabuf *);
  123. };
  124. struct lpfc_queue {
  125. struct list_head list;
  126. struct list_head wq_list;
  127. enum lpfc_sli4_queue_type type;
  128. enum lpfc_sli4_queue_subtype subtype;
  129. struct lpfc_hba *phba;
  130. struct list_head child_list;
  131. struct list_head page_list;
  132. struct list_head sgl_list;
  133. uint32_t entry_count; /* Number of entries to support on the queue */
  134. uint32_t entry_size; /* Size of each queue entry. */
  135. uint32_t entry_repost; /* Count of entries before doorbell is rung */
  136. #define LPFC_EQ_REPOST 8
  137. #define LPFC_MQ_REPOST 8
  138. #define LPFC_CQ_REPOST 64
  139. #define LPFC_RQ_REPOST 64
  140. #define LPFC_MAX_ISR_CQE 64
  141. #define LPFC_RELEASE_NOTIFICATION_INTERVAL 32 /* For WQs */
  142. uint32_t queue_id; /* Queue ID assigned by the hardware */
  143. uint32_t assoc_qid; /* Queue ID associated with, for CQ/WQ/MQ */
  144. uint32_t page_count; /* Number of pages allocated for this queue */
  145. uint32_t host_index; /* The host's index for putting or getting */
  146. uint32_t hba_index; /* The last known hba index for get or put */
  147. struct lpfc_sli_ring *pring; /* ptr to io ring associated with q */
  148. struct lpfc_rqb *rqbp; /* ptr to RQ buffers */
  149. uint32_t q_mode;
  150. uint16_t db_format;
  151. #define LPFC_DB_RING_FORMAT 0x01
  152. #define LPFC_DB_LIST_FORMAT 0x02
  153. void __iomem *db_regaddr;
  154. /* For q stats */
  155. uint32_t q_cnt_1;
  156. uint32_t q_cnt_2;
  157. uint32_t q_cnt_3;
  158. uint64_t q_cnt_4;
  159. /* defines for EQ stats */
  160. #define EQ_max_eqe q_cnt_1
  161. #define EQ_no_entry q_cnt_2
  162. #define EQ_cqe_cnt q_cnt_3
  163. #define EQ_processed q_cnt_4
  164. /* defines for CQ stats */
  165. #define CQ_mbox q_cnt_1
  166. #define CQ_max_cqe q_cnt_1
  167. #define CQ_release_wqe q_cnt_2
  168. #define CQ_xri_aborted q_cnt_3
  169. #define CQ_wq q_cnt_4
  170. /* defines for WQ stats */
  171. #define WQ_overflow q_cnt_1
  172. #define WQ_posted q_cnt_4
  173. /* defines for RQ stats */
  174. #define RQ_no_posted_buf q_cnt_1
  175. #define RQ_no_buf_found q_cnt_2
  176. #define RQ_buf_posted q_cnt_3
  177. #define RQ_rcv_buf q_cnt_4
  178. uint64_t isr_timestamp;
  179. struct lpfc_queue *assoc_qp;
  180. union sli4_qe qe[1]; /* array to index entries (must be last) */
  181. };
  182. struct lpfc_sli4_link {
  183. uint16_t speed;
  184. uint8_t duplex;
  185. uint8_t status;
  186. uint8_t type;
  187. uint8_t number;
  188. uint8_t fault;
  189. uint16_t logical_speed;
  190. uint16_t topology;
  191. };
  192. struct lpfc_fcf_rec {
  193. uint8_t fabric_name[8];
  194. uint8_t switch_name[8];
  195. uint8_t mac_addr[6];
  196. uint16_t fcf_indx;
  197. uint32_t priority;
  198. uint16_t vlan_id;
  199. uint32_t addr_mode;
  200. uint32_t flag;
  201. #define BOOT_ENABLE 0x01
  202. #define RECORD_VALID 0x02
  203. };
  204. struct lpfc_fcf_pri_rec {
  205. uint16_t fcf_index;
  206. #define LPFC_FCF_ON_PRI_LIST 0x0001
  207. #define LPFC_FCF_FLOGI_FAILED 0x0002
  208. uint16_t flag;
  209. uint32_t priority;
  210. };
  211. struct lpfc_fcf_pri {
  212. struct list_head list;
  213. struct lpfc_fcf_pri_rec fcf_rec;
  214. };
  215. /*
  216. * Maximum FCF table index, it is for driver internal book keeping, it
  217. * just needs to be no less than the supported HBA's FCF table size.
  218. */
  219. #define LPFC_SLI4_FCF_TBL_INDX_MAX 32
  220. struct lpfc_fcf {
  221. uint16_t fcfi;
  222. uint32_t fcf_flag;
  223. #define FCF_AVAILABLE 0x01 /* FCF available for discovery */
  224. #define FCF_REGISTERED 0x02 /* FCF registered with FW */
  225. #define FCF_SCAN_DONE 0x04 /* FCF table scan done */
  226. #define FCF_IN_USE 0x08 /* Atleast one discovery completed */
  227. #define FCF_INIT_DISC 0x10 /* Initial FCF discovery */
  228. #define FCF_DEAD_DISC 0x20 /* FCF DEAD fast FCF failover discovery */
  229. #define FCF_ACVL_DISC 0x40 /* All CVL fast FCF failover discovery */
  230. #define FCF_DISCOVERY (FCF_INIT_DISC | FCF_DEAD_DISC | FCF_ACVL_DISC)
  231. #define FCF_REDISC_PEND 0x80 /* FCF rediscovery pending */
  232. #define FCF_REDISC_EVT 0x100 /* FCF rediscovery event to worker thread */
  233. #define FCF_REDISC_FOV 0x200 /* Post FCF rediscovery fast failover */
  234. #define FCF_REDISC_PROG (FCF_REDISC_PEND | FCF_REDISC_EVT)
  235. uint16_t fcf_redisc_attempted;
  236. uint32_t addr_mode;
  237. uint32_t eligible_fcf_cnt;
  238. struct lpfc_fcf_rec current_rec;
  239. struct lpfc_fcf_rec failover_rec;
  240. struct list_head fcf_pri_list;
  241. struct lpfc_fcf_pri fcf_pri[LPFC_SLI4_FCF_TBL_INDX_MAX];
  242. uint32_t current_fcf_scan_pri;
  243. struct timer_list redisc_wait;
  244. unsigned long *fcf_rr_bmask; /* Eligible FCF indexes for RR failover */
  245. };
  246. #define LPFC_REGION23_SIGNATURE "RG23"
  247. #define LPFC_REGION23_VERSION 1
  248. #define LPFC_REGION23_LAST_REC 0xff
  249. #define DRIVER_SPECIFIC_TYPE 0xA2
  250. #define LINUX_DRIVER_ID 0x20
  251. #define PORT_STE_TYPE 0x1
  252. struct lpfc_fip_param_hdr {
  253. uint8_t type;
  254. #define FCOE_PARAM_TYPE 0xA0
  255. uint8_t length;
  256. #define FCOE_PARAM_LENGTH 2
  257. uint8_t parm_version;
  258. #define FIPP_VERSION 0x01
  259. uint8_t parm_flags;
  260. #define lpfc_fip_param_hdr_fipp_mode_SHIFT 6
  261. #define lpfc_fip_param_hdr_fipp_mode_MASK 0x3
  262. #define lpfc_fip_param_hdr_fipp_mode_WORD parm_flags
  263. #define FIPP_MODE_ON 0x1
  264. #define FIPP_MODE_OFF 0x0
  265. #define FIPP_VLAN_VALID 0x1
  266. };
  267. struct lpfc_fcoe_params {
  268. uint8_t fc_map[3];
  269. uint8_t reserved1;
  270. uint16_t vlan_tag;
  271. uint8_t reserved[2];
  272. };
  273. struct lpfc_fcf_conn_hdr {
  274. uint8_t type;
  275. #define FCOE_CONN_TBL_TYPE 0xA1
  276. uint8_t length; /* words */
  277. uint8_t reserved[2];
  278. };
  279. struct lpfc_fcf_conn_rec {
  280. uint16_t flags;
  281. #define FCFCNCT_VALID 0x0001
  282. #define FCFCNCT_BOOT 0x0002
  283. #define FCFCNCT_PRIMARY 0x0004 /* if not set, Secondary */
  284. #define FCFCNCT_FBNM_VALID 0x0008
  285. #define FCFCNCT_SWNM_VALID 0x0010
  286. #define FCFCNCT_VLAN_VALID 0x0020
  287. #define FCFCNCT_AM_VALID 0x0040
  288. #define FCFCNCT_AM_PREFERRED 0x0080 /* if not set, AM Required */
  289. #define FCFCNCT_AM_SPMA 0x0100 /* if not set, FPMA */
  290. uint16_t vlan_tag;
  291. uint8_t fabric_name[8];
  292. uint8_t switch_name[8];
  293. };
  294. struct lpfc_fcf_conn_entry {
  295. struct list_head list;
  296. struct lpfc_fcf_conn_rec conn_rec;
  297. };
  298. /*
  299. * Define the host's bootstrap mailbox. This structure contains
  300. * the member attributes needed to create, use, and destroy the
  301. * bootstrap mailbox region.
  302. *
  303. * The macro definitions for the bmbx data structure are defined
  304. * in lpfc_hw4.h with the register definition.
  305. */
  306. struct lpfc_bmbx {
  307. struct lpfc_dmabuf *dmabuf;
  308. struct dma_address dma_address;
  309. void *avirt;
  310. dma_addr_t aphys;
  311. uint32_t bmbx_size;
  312. };
  313. #define LPFC_EQE_SIZE LPFC_EQE_SIZE_4
  314. #define LPFC_EQE_SIZE_4B 4
  315. #define LPFC_EQE_SIZE_16B 16
  316. #define LPFC_CQE_SIZE 16
  317. #define LPFC_WQE_SIZE 64
  318. #define LPFC_WQE128_SIZE 128
  319. #define LPFC_MQE_SIZE 256
  320. #define LPFC_RQE_SIZE 8
  321. #define LPFC_EQE_DEF_COUNT 1024
  322. #define LPFC_CQE_DEF_COUNT 1024
  323. #define LPFC_WQE_DEF_COUNT 256
  324. #define LPFC_WQE128_DEF_COUNT 128
  325. #define LPFC_WQE128_MAX_COUNT 256
  326. #define LPFC_MQE_DEF_COUNT 16
  327. #define LPFC_RQE_DEF_COUNT 512
  328. #define LPFC_QUEUE_NOARM false
  329. #define LPFC_QUEUE_REARM true
  330. /*
  331. * SLI4 CT field defines
  332. */
  333. #define SLI4_CT_RPI 0
  334. #define SLI4_CT_VPI 1
  335. #define SLI4_CT_VFI 2
  336. #define SLI4_CT_FCFI 3
  337. /*
  338. * SLI4 specific data structures
  339. */
  340. struct lpfc_max_cfg_param {
  341. uint16_t max_xri;
  342. uint16_t xri_base;
  343. uint16_t xri_used;
  344. uint16_t max_rpi;
  345. uint16_t rpi_base;
  346. uint16_t rpi_used;
  347. uint16_t max_vpi;
  348. uint16_t vpi_base;
  349. uint16_t vpi_used;
  350. uint16_t max_vfi;
  351. uint16_t vfi_base;
  352. uint16_t vfi_used;
  353. uint16_t max_fcfi;
  354. uint16_t fcfi_used;
  355. uint16_t max_eq;
  356. uint16_t max_rq;
  357. uint16_t max_cq;
  358. uint16_t max_wq;
  359. };
  360. struct lpfc_hba;
  361. /* SLI4 HBA multi-fcp queue handler struct */
  362. #define LPFC_SLI4_HANDLER_NAME_SZ 16
  363. struct lpfc_hba_eq_hdl {
  364. uint32_t idx;
  365. char handler_name[LPFC_SLI4_HANDLER_NAME_SZ];
  366. struct lpfc_hba *phba;
  367. atomic_t hba_eq_in_use;
  368. struct cpumask *cpumask;
  369. /* CPU affinitsed to or 0xffffffff if multiple */
  370. uint32_t cpu;
  371. #define LPFC_MULTI_CPU_AFFINITY 0xffffffff
  372. };
  373. /*BB Credit recovery value*/
  374. struct lpfc_bbscn_params {
  375. uint32_t word0;
  376. #define lpfc_bbscn_min_SHIFT 0
  377. #define lpfc_bbscn_min_MASK 0x0000000F
  378. #define lpfc_bbscn_min_WORD word0
  379. #define lpfc_bbscn_max_SHIFT 4
  380. #define lpfc_bbscn_max_MASK 0x0000000F
  381. #define lpfc_bbscn_max_WORD word0
  382. #define lpfc_bbscn_def_SHIFT 8
  383. #define lpfc_bbscn_def_MASK 0x0000000F
  384. #define lpfc_bbscn_def_WORD word0
  385. };
  386. /* Port Capabilities for SLI4 Parameters */
  387. struct lpfc_pc_sli4_params {
  388. uint32_t supported;
  389. uint32_t if_type;
  390. uint32_t sli_rev;
  391. uint32_t sli_family;
  392. uint32_t featurelevel_1;
  393. uint32_t featurelevel_2;
  394. uint32_t proto_types;
  395. #define LPFC_SLI4_PROTO_FCOE 0x0000001
  396. #define LPFC_SLI4_PROTO_FC 0x0000002
  397. #define LPFC_SLI4_PROTO_NIC 0x0000004
  398. #define LPFC_SLI4_PROTO_ISCSI 0x0000008
  399. #define LPFC_SLI4_PROTO_RDMA 0x0000010
  400. uint32_t sge_supp_len;
  401. uint32_t if_page_sz;
  402. uint32_t rq_db_window;
  403. uint32_t loopbk_scope;
  404. uint32_t oas_supported;
  405. uint32_t eq_pages_max;
  406. uint32_t eqe_size;
  407. uint32_t cq_pages_max;
  408. uint32_t cqe_size;
  409. uint32_t mq_pages_max;
  410. uint32_t mqe_size;
  411. uint32_t mq_elem_cnt;
  412. uint32_t wq_pages_max;
  413. uint32_t wqe_size;
  414. uint32_t rq_pages_max;
  415. uint32_t rqe_size;
  416. uint32_t hdr_pages_max;
  417. uint32_t hdr_size;
  418. uint32_t hdr_pp_align;
  419. uint32_t sgl_pages_max;
  420. uint32_t sgl_pp_align;
  421. uint8_t cqv;
  422. uint8_t mqv;
  423. uint8_t wqv;
  424. uint8_t rqv;
  425. uint8_t wqsize;
  426. #define LPFC_WQ_SZ64_SUPPORT 1
  427. #define LPFC_WQ_SZ128_SUPPORT 2
  428. uint8_t wqpcnt;
  429. };
  430. struct lpfc_iov {
  431. uint32_t pf_number;
  432. uint32_t vf_number;
  433. };
  434. struct lpfc_sli4_lnk_info {
  435. uint8_t lnk_dv;
  436. #define LPFC_LNK_DAT_INVAL 0
  437. #define LPFC_LNK_DAT_VAL 1
  438. uint8_t lnk_tp;
  439. #define LPFC_LNK_GE 0x0 /* FCoE */
  440. #define LPFC_LNK_FC 0x1 /* FC */
  441. uint8_t lnk_no;
  442. uint8_t optic_state;
  443. };
  444. #define LPFC_SLI4_HANDLER_CNT (LPFC_HBA_IO_CHAN_MAX+ \
  445. LPFC_FOF_IO_CHAN_NUM)
  446. /* Used for IRQ vector to CPU mapping */
  447. struct lpfc_vector_map_info {
  448. uint16_t phys_id;
  449. uint16_t core_id;
  450. uint16_t irq;
  451. uint16_t channel_id;
  452. };
  453. #define LPFC_VECTOR_MAP_EMPTY 0xffff
  454. /* SLI4 HBA data structure entries */
  455. struct lpfc_sli4_hba {
  456. void __iomem *conf_regs_memmap_p; /* Kernel memory mapped address for
  457. PCI BAR0, config space registers */
  458. void __iomem *ctrl_regs_memmap_p; /* Kernel memory mapped address for
  459. PCI BAR1, control registers */
  460. void __iomem *drbl_regs_memmap_p; /* Kernel memory mapped address for
  461. PCI BAR2, doorbell registers */
  462. union {
  463. struct {
  464. /* IF Type 0, BAR 0 PCI cfg space reg mem map */
  465. void __iomem *UERRLOregaddr;
  466. void __iomem *UERRHIregaddr;
  467. void __iomem *UEMASKLOregaddr;
  468. void __iomem *UEMASKHIregaddr;
  469. } if_type0;
  470. struct {
  471. /* IF Type 2, BAR 0 PCI cfg space reg mem map. */
  472. void __iomem *STATUSregaddr;
  473. void __iomem *CTRLregaddr;
  474. void __iomem *ERR1regaddr;
  475. #define SLIPORT_ERR1_REG_ERR_CODE_1 0x1
  476. #define SLIPORT_ERR1_REG_ERR_CODE_2 0x2
  477. void __iomem *ERR2regaddr;
  478. #define SLIPORT_ERR2_REG_FW_RESTART 0x0
  479. #define SLIPORT_ERR2_REG_FUNC_PROVISON 0x1
  480. #define SLIPORT_ERR2_REG_FORCED_DUMP 0x2
  481. #define SLIPORT_ERR2_REG_FAILURE_EQ 0x3
  482. #define SLIPORT_ERR2_REG_FAILURE_CQ 0x4
  483. #define SLIPORT_ERR2_REG_FAILURE_BUS 0x5
  484. #define SLIPORT_ERR2_REG_FAILURE_RQ 0x6
  485. void __iomem *EQDregaddr;
  486. } if_type2;
  487. } u;
  488. /* IF type 0, BAR1 and if type 2, Bar 0 CSR register memory map */
  489. void __iomem *PSMPHRregaddr;
  490. /* Well-known SLI INTF register memory map. */
  491. void __iomem *SLIINTFregaddr;
  492. /* IF type 0, BAR 1 function CSR register memory map */
  493. void __iomem *ISRregaddr; /* HST_ISR register */
  494. void __iomem *IMRregaddr; /* HST_IMR register */
  495. void __iomem *ISCRregaddr; /* HST_ISCR register */
  496. /* IF type 0, BAR 0 and if type 2, BAR 0 doorbell register memory map */
  497. void __iomem *RQDBregaddr; /* RQ_DOORBELL register */
  498. void __iomem *WQDBregaddr; /* WQ_DOORBELL register */
  499. void __iomem *EQCQDBregaddr; /* EQCQ_DOORBELL register */
  500. void __iomem *MQDBregaddr; /* MQ_DOORBELL register */
  501. void __iomem *BMBXregaddr; /* BootStrap MBX register */
  502. uint32_t ue_mask_lo;
  503. uint32_t ue_mask_hi;
  504. uint32_t ue_to_sr;
  505. uint32_t ue_to_rp;
  506. struct lpfc_register sli_intf;
  507. struct lpfc_pc_sli4_params pc_sli4_params;
  508. struct lpfc_bbscn_params bbscn_params;
  509. struct lpfc_hba_eq_hdl *hba_eq_hdl; /* HBA per-WQ handle */
  510. /* Pointers to the constructed SLI4 queues */
  511. struct lpfc_queue **hba_eq; /* Event queues for HBA */
  512. struct lpfc_queue **fcp_cq; /* Fast-path FCP compl queue */
  513. struct lpfc_queue **nvme_cq; /* Fast-path NVME compl queue */
  514. struct lpfc_queue **nvmet_cqset; /* Fast-path NVMET CQ Set queues */
  515. struct lpfc_queue **nvmet_mrq_hdr; /* Fast-path NVMET hdr MRQs */
  516. struct lpfc_queue **nvmet_mrq_data; /* Fast-path NVMET data MRQs */
  517. struct lpfc_queue **fcp_wq; /* Fast-path FCP work queue */
  518. struct lpfc_queue **nvme_wq; /* Fast-path NVME work queue */
  519. uint16_t *fcp_cq_map;
  520. uint16_t *nvme_cq_map;
  521. struct list_head lpfc_wq_list;
  522. struct lpfc_queue *mbx_cq; /* Slow-path mailbox complete queue */
  523. struct lpfc_queue *els_cq; /* Slow-path ELS response complete queue */
  524. struct lpfc_queue *nvmels_cq; /* NVME LS complete queue */
  525. struct lpfc_queue *mbx_wq; /* Slow-path MBOX work queue */
  526. struct lpfc_queue *els_wq; /* Slow-path ELS work queue */
  527. struct lpfc_queue *nvmels_wq; /* NVME LS work queue */
  528. struct lpfc_queue *hdr_rq; /* Slow-path Header Receive queue */
  529. struct lpfc_queue *dat_rq; /* Slow-path Data Receive queue */
  530. struct lpfc_name wwnn;
  531. struct lpfc_name wwpn;
  532. uint32_t fw_func_mode; /* FW function protocol mode */
  533. uint32_t ulp0_mode; /* ULP0 protocol mode */
  534. uint32_t ulp1_mode; /* ULP1 protocol mode */
  535. struct lpfc_queue *fof_eq; /* Flash Optimized Fabric Event queue */
  536. /* Optimized Access Storage specific queues/structures */
  537. struct lpfc_queue *oas_cq; /* OAS completion queue */
  538. struct lpfc_queue *oas_wq; /* OAS Work queue */
  539. struct lpfc_sli_ring *oas_ring;
  540. uint64_t oas_next_lun;
  541. uint8_t oas_next_tgt_wwpn[8];
  542. uint8_t oas_next_vpt_wwpn[8];
  543. /* Setup information for various queue parameters */
  544. int eq_esize;
  545. int eq_ecount;
  546. int cq_esize;
  547. int cq_ecount;
  548. int wq_esize;
  549. int wq_ecount;
  550. int mq_esize;
  551. int mq_ecount;
  552. int rq_esize;
  553. int rq_ecount;
  554. #define LPFC_SP_EQ_MAX_INTR_SEC 10000
  555. #define LPFC_FP_EQ_MAX_INTR_SEC 10000
  556. uint32_t intr_enable;
  557. struct lpfc_bmbx bmbx;
  558. struct lpfc_max_cfg_param max_cfg_param;
  559. uint16_t extents_in_use; /* must allocate resource extents. */
  560. uint16_t rpi_hdrs_in_use; /* must post rpi hdrs if set. */
  561. uint16_t next_xri; /* last_xri - max_cfg_param.xri_base = used */
  562. uint16_t next_rpi;
  563. uint16_t nvme_xri_max;
  564. uint16_t nvme_xri_cnt;
  565. uint16_t nvme_xri_start;
  566. uint16_t scsi_xri_max;
  567. uint16_t scsi_xri_cnt;
  568. uint16_t scsi_xri_start;
  569. uint16_t els_xri_cnt;
  570. uint16_t nvmet_xri_cnt;
  571. uint16_t nvmet_io_wait_cnt;
  572. uint16_t nvmet_io_wait_total;
  573. struct list_head lpfc_els_sgl_list;
  574. struct list_head lpfc_abts_els_sgl_list;
  575. struct list_head lpfc_nvmet_sgl_list;
  576. struct list_head lpfc_abts_nvmet_ctx_list;
  577. struct list_head lpfc_abts_scsi_buf_list;
  578. struct list_head lpfc_abts_nvme_buf_list;
  579. struct list_head lpfc_nvmet_io_wait_list;
  580. struct lpfc_nvmet_ctx_info *nvmet_ctx_info;
  581. struct lpfc_sglq **lpfc_sglq_active_list;
  582. struct list_head lpfc_rpi_hdr_list;
  583. unsigned long *rpi_bmask;
  584. uint16_t *rpi_ids;
  585. uint16_t rpi_count;
  586. struct list_head lpfc_rpi_blk_list;
  587. unsigned long *xri_bmask;
  588. uint16_t *xri_ids;
  589. struct list_head lpfc_xri_blk_list;
  590. unsigned long *vfi_bmask;
  591. uint16_t *vfi_ids;
  592. uint16_t vfi_count;
  593. struct list_head lpfc_vfi_blk_list;
  594. struct lpfc_sli4_flags sli4_flags;
  595. struct list_head sp_queue_event;
  596. struct list_head sp_cqe_event_pool;
  597. struct list_head sp_asynce_work_queue;
  598. struct list_head sp_fcp_xri_aborted_work_queue;
  599. struct list_head sp_els_xri_aborted_work_queue;
  600. struct list_head sp_nvme_xri_aborted_work_queue;
  601. struct list_head sp_unsol_work_queue;
  602. struct lpfc_sli4_link link_state;
  603. struct lpfc_sli4_lnk_info lnk_info;
  604. uint32_t pport_name_sta;
  605. #define LPFC_SLI4_PPNAME_NON 0
  606. #define LPFC_SLI4_PPNAME_GET 1
  607. struct lpfc_iov iov;
  608. spinlock_t abts_nvme_buf_list_lock; /* list of aborted SCSI IOs */
  609. spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */
  610. spinlock_t sgl_list_lock; /* list of aborted els IOs */
  611. spinlock_t nvmet_io_wait_lock; /* IOs waiting for ctx resources */
  612. uint32_t physical_port;
  613. /* CPU to vector mapping information */
  614. struct lpfc_vector_map_info *cpu_map;
  615. uint16_t num_online_cpu;
  616. uint16_t num_present_cpu;
  617. uint16_t curr_disp_cpu;
  618. };
  619. enum lpfc_sge_type {
  620. GEN_BUFF_TYPE,
  621. SCSI_BUFF_TYPE,
  622. NVMET_BUFF_TYPE
  623. };
  624. enum lpfc_sgl_state {
  625. SGL_FREED,
  626. SGL_ALLOCATED,
  627. SGL_XRI_ABORTED
  628. };
  629. struct lpfc_sglq {
  630. /* lpfc_sglqs are used in double linked lists */
  631. struct list_head list;
  632. struct list_head clist;
  633. enum lpfc_sge_type buff_type; /* is this a scsi sgl */
  634. enum lpfc_sgl_state state;
  635. struct lpfc_nodelist *ndlp; /* ndlp associated with IO */
  636. uint16_t iotag; /* pre-assigned IO tag */
  637. uint16_t sli4_lxritag; /* logical pre-assigned xri. */
  638. uint16_t sli4_xritag; /* pre-assigned XRI, (OXID) tag. */
  639. struct sli4_sge *sgl; /* pre-assigned SGL */
  640. void *virt; /* virtual address. */
  641. dma_addr_t phys; /* physical address */
  642. };
  643. struct lpfc_rpi_hdr {
  644. struct list_head list;
  645. uint32_t len;
  646. struct lpfc_dmabuf *dmabuf;
  647. uint32_t page_count;
  648. uint32_t start_rpi;
  649. uint16_t next_rpi;
  650. };
  651. struct lpfc_rsrc_blks {
  652. struct list_head list;
  653. uint16_t rsrc_start;
  654. uint16_t rsrc_size;
  655. uint16_t rsrc_used;
  656. };
  657. struct lpfc_rdp_context {
  658. struct lpfc_nodelist *ndlp;
  659. uint16_t ox_id;
  660. uint16_t rx_id;
  661. READ_LNK_VAR link_stat;
  662. uint8_t page_a0[DMP_SFF_PAGE_A0_SIZE];
  663. uint8_t page_a2[DMP_SFF_PAGE_A2_SIZE];
  664. void (*cmpl)(struct lpfc_hba *, struct lpfc_rdp_context*, int);
  665. };
  666. struct lpfc_lcb_context {
  667. uint8_t sub_command;
  668. uint8_t type;
  669. uint8_t frequency;
  670. uint16_t ox_id;
  671. uint16_t rx_id;
  672. struct lpfc_nodelist *ndlp;
  673. };
  674. /*
  675. * SLI4 specific function prototypes
  676. */
  677. int lpfc_pci_function_reset(struct lpfc_hba *);
  678. int lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *);
  679. int lpfc_sli4_hba_setup(struct lpfc_hba *);
  680. int lpfc_sli4_config(struct lpfc_hba *, struct lpfcMboxq *, uint8_t,
  681. uint8_t, uint32_t, bool);
  682. void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *);
  683. void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t);
  684. void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t,
  685. struct lpfc_mbx_sge *);
  686. int lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *, struct lpfcMboxq *,
  687. uint16_t);
  688. void lpfc_sli4_hba_reset(struct lpfc_hba *);
  689. struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t,
  690. uint32_t);
  691. void lpfc_sli4_queue_free(struct lpfc_queue *);
  692. int lpfc_eq_create(struct lpfc_hba *, struct lpfc_queue *, uint32_t);
  693. int lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, uint32_t startq,
  694. uint32_t numq, uint32_t imax);
  695. int lpfc_cq_create(struct lpfc_hba *, struct lpfc_queue *,
  696. struct lpfc_queue *, uint32_t, uint32_t);
  697. int lpfc_cq_create_set(struct lpfc_hba *phba, struct lpfc_queue **cqp,
  698. struct lpfc_queue **eqp, uint32_t type,
  699. uint32_t subtype);
  700. int32_t lpfc_mq_create(struct lpfc_hba *, struct lpfc_queue *,
  701. struct lpfc_queue *, uint32_t);
  702. int lpfc_wq_create(struct lpfc_hba *, struct lpfc_queue *,
  703. struct lpfc_queue *, uint32_t);
  704. int lpfc_rq_create(struct lpfc_hba *, struct lpfc_queue *,
  705. struct lpfc_queue *, struct lpfc_queue *, uint32_t);
  706. int lpfc_mrq_create(struct lpfc_hba *phba, struct lpfc_queue **hrqp,
  707. struct lpfc_queue **drqp, struct lpfc_queue **cqp,
  708. uint32_t subtype);
  709. int lpfc_eq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  710. int lpfc_cq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  711. int lpfc_mq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  712. int lpfc_wq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  713. int lpfc_rq_destroy(struct lpfc_hba *, struct lpfc_queue *,
  714. struct lpfc_queue *);
  715. int lpfc_sli4_queue_setup(struct lpfc_hba *);
  716. void lpfc_sli4_queue_unset(struct lpfc_hba *);
  717. int lpfc_sli4_post_sgl(struct lpfc_hba *, dma_addr_t, dma_addr_t, uint16_t);
  718. int lpfc_sli4_repost_scsi_sgl_list(struct lpfc_hba *);
  719. int lpfc_repost_nvme_sgl_list(struct lpfc_hba *phba);
  720. uint16_t lpfc_sli4_next_xritag(struct lpfc_hba *);
  721. void lpfc_sli4_free_xri(struct lpfc_hba *, int);
  722. int lpfc_sli4_post_async_mbox(struct lpfc_hba *);
  723. int lpfc_sli4_post_scsi_sgl_block(struct lpfc_hba *, struct list_head *, int);
  724. struct lpfc_cq_event *__lpfc_sli4_cq_event_alloc(struct lpfc_hba *);
  725. struct lpfc_cq_event *lpfc_sli4_cq_event_alloc(struct lpfc_hba *);
  726. void __lpfc_sli4_cq_event_release(struct lpfc_hba *, struct lpfc_cq_event *);
  727. void lpfc_sli4_cq_event_release(struct lpfc_hba *, struct lpfc_cq_event *);
  728. int lpfc_sli4_init_rpi_hdrs(struct lpfc_hba *);
  729. int lpfc_sli4_post_rpi_hdr(struct lpfc_hba *, struct lpfc_rpi_hdr *);
  730. int lpfc_sli4_post_all_rpi_hdrs(struct lpfc_hba *);
  731. struct lpfc_rpi_hdr *lpfc_sli4_create_rpi_hdr(struct lpfc_hba *);
  732. void lpfc_sli4_remove_rpi_hdrs(struct lpfc_hba *);
  733. int lpfc_sli4_alloc_rpi(struct lpfc_hba *);
  734. void lpfc_sli4_free_rpi(struct lpfc_hba *, int);
  735. void lpfc_sli4_remove_rpis(struct lpfc_hba *);
  736. void lpfc_sli4_async_event_proc(struct lpfc_hba *);
  737. void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *);
  738. int lpfc_sli4_resume_rpi(struct lpfc_nodelist *,
  739. void (*)(struct lpfc_hba *, LPFC_MBOXQ_t *), void *);
  740. void lpfc_sli4_fcp_xri_abort_event_proc(struct lpfc_hba *);
  741. void lpfc_sli4_nvme_xri_abort_event_proc(struct lpfc_hba *phba);
  742. void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *);
  743. void lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *,
  744. struct sli4_wcqe_xri_aborted *);
  745. void lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba,
  746. struct sli4_wcqe_xri_aborted *axri);
  747. void lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba,
  748. struct sli4_wcqe_xri_aborted *axri);
  749. void lpfc_sli4_els_xri_aborted(struct lpfc_hba *,
  750. struct sli4_wcqe_xri_aborted *);
  751. void lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *);
  752. void lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *);
  753. int lpfc_sli4_brdreset(struct lpfc_hba *);
  754. int lpfc_sli4_add_fcf_record(struct lpfc_hba *, struct fcf_record *);
  755. void lpfc_sli_remove_dflt_fcf(struct lpfc_hba *);
  756. int lpfc_sli4_get_els_iocb_cnt(struct lpfc_hba *);
  757. int lpfc_sli4_get_iocb_cnt(struct lpfc_hba *phba);
  758. int lpfc_sli4_init_vpi(struct lpfc_vport *);
  759. uint32_t lpfc_sli4_cq_release(struct lpfc_queue *, bool);
  760. uint32_t lpfc_sli4_eq_release(struct lpfc_queue *, bool);
  761. void lpfc_sli4_fcfi_unreg(struct lpfc_hba *, uint16_t);
  762. int lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *, uint16_t);
  763. int lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *, uint16_t);
  764. int lpfc_sli4_read_fcf_rec(struct lpfc_hba *, uint16_t);
  765. void lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
  766. void lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
  767. void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
  768. int lpfc_sli4_unregister_fcf(struct lpfc_hba *);
  769. int lpfc_sli4_post_status_check(struct lpfc_hba *);
  770. uint8_t lpfc_sli_config_mbox_subsys_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
  771. uint8_t lpfc_sli_config_mbox_opcode_get(struct lpfc_hba *, LPFC_MBOXQ_t *);