lpfc_sli4.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
  5. * “Broadcom” refers to Broadcom Inc. 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. struct list_head wqfull_list;
  128. enum lpfc_sli4_queue_type type;
  129. enum lpfc_sli4_queue_subtype subtype;
  130. struct lpfc_hba *phba;
  131. struct list_head child_list;
  132. struct list_head page_list;
  133. struct list_head sgl_list;
  134. uint32_t entry_count; /* Number of entries to support on the queue */
  135. uint32_t entry_size; /* Size of each queue entry. */
  136. uint32_t entry_repost; /* Count of entries before doorbell is rung */
  137. #define LPFC_EQ_REPOST 8
  138. #define LPFC_MQ_REPOST 8
  139. #define LPFC_CQ_REPOST 64
  140. #define LPFC_RQ_REPOST 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 host_index; /* The host's index for putting or getting */
  145. uint32_t hba_index; /* The last known hba index for get or put */
  146. struct lpfc_sli_ring *pring; /* ptr to io ring associated with q */
  147. struct lpfc_rqb *rqbp; /* ptr to RQ buffers */
  148. uint32_t q_mode;
  149. uint16_t page_count; /* Number of pages allocated for this queue */
  150. uint16_t page_size; /* size of page allocated for this queue */
  151. #define LPFC_EXPANDED_PAGE_SIZE 16384
  152. #define LPFC_DEFAULT_PAGE_SIZE 4096
  153. uint16_t chann; /* IO channel this queue is associated with */
  154. uint8_t db_format;
  155. #define LPFC_DB_RING_FORMAT 0x01
  156. #define LPFC_DB_LIST_FORMAT 0x02
  157. uint8_t q_flag;
  158. #define HBA_NVMET_WQFULL 0x1 /* We hit WQ Full condition for NVMET */
  159. void __iomem *db_regaddr;
  160. uint16_t dpp_enable;
  161. uint16_t dpp_id;
  162. void __iomem *dpp_regaddr;
  163. /* For q stats */
  164. uint32_t q_cnt_1;
  165. uint32_t q_cnt_2;
  166. uint32_t q_cnt_3;
  167. uint64_t q_cnt_4;
  168. /* defines for EQ stats */
  169. #define EQ_max_eqe q_cnt_1
  170. #define EQ_no_entry q_cnt_2
  171. #define EQ_cqe_cnt q_cnt_3
  172. #define EQ_processed q_cnt_4
  173. /* defines for CQ stats */
  174. #define CQ_mbox q_cnt_1
  175. #define CQ_max_cqe q_cnt_1
  176. #define CQ_release_wqe q_cnt_2
  177. #define CQ_xri_aborted q_cnt_3
  178. #define CQ_wq q_cnt_4
  179. /* defines for WQ stats */
  180. #define WQ_overflow q_cnt_1
  181. #define WQ_posted q_cnt_4
  182. /* defines for RQ stats */
  183. #define RQ_no_posted_buf q_cnt_1
  184. #define RQ_no_buf_found q_cnt_2
  185. #define RQ_buf_posted q_cnt_3
  186. #define RQ_rcv_buf q_cnt_4
  187. struct work_struct irqwork;
  188. struct work_struct spwork;
  189. uint64_t isr_timestamp;
  190. uint8_t qe_valid;
  191. struct lpfc_queue *assoc_qp;
  192. union sli4_qe qe[1]; /* array to index entries (must be last) */
  193. };
  194. struct lpfc_sli4_link {
  195. uint16_t speed;
  196. uint8_t duplex;
  197. uint8_t status;
  198. uint8_t type;
  199. uint8_t number;
  200. uint8_t fault;
  201. uint16_t logical_speed;
  202. uint16_t topology;
  203. };
  204. struct lpfc_fcf_rec {
  205. uint8_t fabric_name[8];
  206. uint8_t switch_name[8];
  207. uint8_t mac_addr[6];
  208. uint16_t fcf_indx;
  209. uint32_t priority;
  210. uint16_t vlan_id;
  211. uint32_t addr_mode;
  212. uint32_t flag;
  213. #define BOOT_ENABLE 0x01
  214. #define RECORD_VALID 0x02
  215. };
  216. struct lpfc_fcf_pri_rec {
  217. uint16_t fcf_index;
  218. #define LPFC_FCF_ON_PRI_LIST 0x0001
  219. #define LPFC_FCF_FLOGI_FAILED 0x0002
  220. uint16_t flag;
  221. uint32_t priority;
  222. };
  223. struct lpfc_fcf_pri {
  224. struct list_head list;
  225. struct lpfc_fcf_pri_rec fcf_rec;
  226. };
  227. /*
  228. * Maximum FCF table index, it is for driver internal book keeping, it
  229. * just needs to be no less than the supported HBA's FCF table size.
  230. */
  231. #define LPFC_SLI4_FCF_TBL_INDX_MAX 32
  232. struct lpfc_fcf {
  233. uint16_t fcfi;
  234. uint32_t fcf_flag;
  235. #define FCF_AVAILABLE 0x01 /* FCF available for discovery */
  236. #define FCF_REGISTERED 0x02 /* FCF registered with FW */
  237. #define FCF_SCAN_DONE 0x04 /* FCF table scan done */
  238. #define FCF_IN_USE 0x08 /* Atleast one discovery completed */
  239. #define FCF_INIT_DISC 0x10 /* Initial FCF discovery */
  240. #define FCF_DEAD_DISC 0x20 /* FCF DEAD fast FCF failover discovery */
  241. #define FCF_ACVL_DISC 0x40 /* All CVL fast FCF failover discovery */
  242. #define FCF_DISCOVERY (FCF_INIT_DISC | FCF_DEAD_DISC | FCF_ACVL_DISC)
  243. #define FCF_REDISC_PEND 0x80 /* FCF rediscovery pending */
  244. #define FCF_REDISC_EVT 0x100 /* FCF rediscovery event to worker thread */
  245. #define FCF_REDISC_FOV 0x200 /* Post FCF rediscovery fast failover */
  246. #define FCF_REDISC_PROG (FCF_REDISC_PEND | FCF_REDISC_EVT)
  247. uint16_t fcf_redisc_attempted;
  248. uint32_t addr_mode;
  249. uint32_t eligible_fcf_cnt;
  250. struct lpfc_fcf_rec current_rec;
  251. struct lpfc_fcf_rec failover_rec;
  252. struct list_head fcf_pri_list;
  253. struct lpfc_fcf_pri fcf_pri[LPFC_SLI4_FCF_TBL_INDX_MAX];
  254. uint32_t current_fcf_scan_pri;
  255. struct timer_list redisc_wait;
  256. unsigned long *fcf_rr_bmask; /* Eligible FCF indexes for RR failover */
  257. };
  258. #define LPFC_REGION23_SIGNATURE "RG23"
  259. #define LPFC_REGION23_VERSION 1
  260. #define LPFC_REGION23_LAST_REC 0xff
  261. #define DRIVER_SPECIFIC_TYPE 0xA2
  262. #define LINUX_DRIVER_ID 0x20
  263. #define PORT_STE_TYPE 0x1
  264. struct lpfc_fip_param_hdr {
  265. uint8_t type;
  266. #define FCOE_PARAM_TYPE 0xA0
  267. uint8_t length;
  268. #define FCOE_PARAM_LENGTH 2
  269. uint8_t parm_version;
  270. #define FIPP_VERSION 0x01
  271. uint8_t parm_flags;
  272. #define lpfc_fip_param_hdr_fipp_mode_SHIFT 6
  273. #define lpfc_fip_param_hdr_fipp_mode_MASK 0x3
  274. #define lpfc_fip_param_hdr_fipp_mode_WORD parm_flags
  275. #define FIPP_MODE_ON 0x1
  276. #define FIPP_MODE_OFF 0x0
  277. #define FIPP_VLAN_VALID 0x1
  278. };
  279. struct lpfc_fcoe_params {
  280. uint8_t fc_map[3];
  281. uint8_t reserved1;
  282. uint16_t vlan_tag;
  283. uint8_t reserved[2];
  284. };
  285. struct lpfc_fcf_conn_hdr {
  286. uint8_t type;
  287. #define FCOE_CONN_TBL_TYPE 0xA1
  288. uint8_t length; /* words */
  289. uint8_t reserved[2];
  290. };
  291. struct lpfc_fcf_conn_rec {
  292. uint16_t flags;
  293. #define FCFCNCT_VALID 0x0001
  294. #define FCFCNCT_BOOT 0x0002
  295. #define FCFCNCT_PRIMARY 0x0004 /* if not set, Secondary */
  296. #define FCFCNCT_FBNM_VALID 0x0008
  297. #define FCFCNCT_SWNM_VALID 0x0010
  298. #define FCFCNCT_VLAN_VALID 0x0020
  299. #define FCFCNCT_AM_VALID 0x0040
  300. #define FCFCNCT_AM_PREFERRED 0x0080 /* if not set, AM Required */
  301. #define FCFCNCT_AM_SPMA 0x0100 /* if not set, FPMA */
  302. uint16_t vlan_tag;
  303. uint8_t fabric_name[8];
  304. uint8_t switch_name[8];
  305. };
  306. struct lpfc_fcf_conn_entry {
  307. struct list_head list;
  308. struct lpfc_fcf_conn_rec conn_rec;
  309. };
  310. /*
  311. * Define the host's bootstrap mailbox. This structure contains
  312. * the member attributes needed to create, use, and destroy the
  313. * bootstrap mailbox region.
  314. *
  315. * The macro definitions for the bmbx data structure are defined
  316. * in lpfc_hw4.h with the register definition.
  317. */
  318. struct lpfc_bmbx {
  319. struct lpfc_dmabuf *dmabuf;
  320. struct dma_address dma_address;
  321. void *avirt;
  322. dma_addr_t aphys;
  323. uint32_t bmbx_size;
  324. };
  325. #define LPFC_EQE_SIZE LPFC_EQE_SIZE_4
  326. #define LPFC_EQE_SIZE_4B 4
  327. #define LPFC_EQE_SIZE_16B 16
  328. #define LPFC_CQE_SIZE 16
  329. #define LPFC_WQE_SIZE 64
  330. #define LPFC_WQE128_SIZE 128
  331. #define LPFC_MQE_SIZE 256
  332. #define LPFC_RQE_SIZE 8
  333. #define LPFC_EQE_DEF_COUNT 1024
  334. #define LPFC_CQE_DEF_COUNT 1024
  335. #define LPFC_CQE_EXP_COUNT 4096
  336. #define LPFC_WQE_DEF_COUNT 256
  337. #define LPFC_WQE_EXP_COUNT 1024
  338. #define LPFC_MQE_DEF_COUNT 16
  339. #define LPFC_RQE_DEF_COUNT 512
  340. #define LPFC_QUEUE_NOARM false
  341. #define LPFC_QUEUE_REARM true
  342. /*
  343. * SLI4 CT field defines
  344. */
  345. #define SLI4_CT_RPI 0
  346. #define SLI4_CT_VPI 1
  347. #define SLI4_CT_VFI 2
  348. #define SLI4_CT_FCFI 3
  349. /*
  350. * SLI4 specific data structures
  351. */
  352. struct lpfc_max_cfg_param {
  353. uint16_t max_xri;
  354. uint16_t xri_base;
  355. uint16_t xri_used;
  356. uint16_t max_rpi;
  357. uint16_t rpi_base;
  358. uint16_t rpi_used;
  359. uint16_t max_vpi;
  360. uint16_t vpi_base;
  361. uint16_t vpi_used;
  362. uint16_t max_vfi;
  363. uint16_t vfi_base;
  364. uint16_t vfi_used;
  365. uint16_t max_fcfi;
  366. uint16_t fcfi_used;
  367. uint16_t max_eq;
  368. uint16_t max_rq;
  369. uint16_t max_cq;
  370. uint16_t max_wq;
  371. };
  372. struct lpfc_hba;
  373. /* SLI4 HBA multi-fcp queue handler struct */
  374. #define LPFC_SLI4_HANDLER_NAME_SZ 16
  375. struct lpfc_hba_eq_hdl {
  376. uint32_t idx;
  377. char handler_name[LPFC_SLI4_HANDLER_NAME_SZ];
  378. struct lpfc_hba *phba;
  379. atomic_t hba_eq_in_use;
  380. struct cpumask *cpumask;
  381. /* CPU affinitsed to or 0xffffffff if multiple */
  382. uint32_t cpu;
  383. #define LPFC_MULTI_CPU_AFFINITY 0xffffffff
  384. };
  385. /*BB Credit recovery value*/
  386. struct lpfc_bbscn_params {
  387. uint32_t word0;
  388. #define lpfc_bbscn_min_SHIFT 0
  389. #define lpfc_bbscn_min_MASK 0x0000000F
  390. #define lpfc_bbscn_min_WORD word0
  391. #define lpfc_bbscn_max_SHIFT 4
  392. #define lpfc_bbscn_max_MASK 0x0000000F
  393. #define lpfc_bbscn_max_WORD word0
  394. #define lpfc_bbscn_def_SHIFT 8
  395. #define lpfc_bbscn_def_MASK 0x0000000F
  396. #define lpfc_bbscn_def_WORD word0
  397. };
  398. /* Port Capabilities for SLI4 Parameters */
  399. struct lpfc_pc_sli4_params {
  400. uint32_t supported;
  401. uint32_t if_type;
  402. uint32_t sli_rev;
  403. uint32_t sli_family;
  404. uint32_t featurelevel_1;
  405. uint32_t featurelevel_2;
  406. uint32_t proto_types;
  407. #define LPFC_SLI4_PROTO_FCOE 0x0000001
  408. #define LPFC_SLI4_PROTO_FC 0x0000002
  409. #define LPFC_SLI4_PROTO_NIC 0x0000004
  410. #define LPFC_SLI4_PROTO_ISCSI 0x0000008
  411. #define LPFC_SLI4_PROTO_RDMA 0x0000010
  412. uint32_t sge_supp_len;
  413. uint32_t if_page_sz;
  414. uint32_t rq_db_window;
  415. uint32_t loopbk_scope;
  416. uint32_t oas_supported;
  417. uint32_t eq_pages_max;
  418. uint32_t eqe_size;
  419. uint32_t cq_pages_max;
  420. uint32_t cqe_size;
  421. uint32_t mq_pages_max;
  422. uint32_t mqe_size;
  423. uint32_t mq_elem_cnt;
  424. uint32_t wq_pages_max;
  425. uint32_t wqe_size;
  426. uint32_t rq_pages_max;
  427. uint32_t rqe_size;
  428. uint32_t hdr_pages_max;
  429. uint32_t hdr_size;
  430. uint32_t hdr_pp_align;
  431. uint32_t sgl_pages_max;
  432. uint32_t sgl_pp_align;
  433. uint8_t cqv;
  434. uint8_t mqv;
  435. uint8_t wqv;
  436. uint8_t rqv;
  437. uint8_t eqav;
  438. uint8_t cqav;
  439. uint8_t wqsize;
  440. uint8_t bv1s;
  441. #define LPFC_WQ_SZ64_SUPPORT 1
  442. #define LPFC_WQ_SZ128_SUPPORT 2
  443. uint8_t wqpcnt;
  444. };
  445. #define LPFC_CQ_4K_PAGE_SZ 0x1
  446. #define LPFC_CQ_16K_PAGE_SZ 0x4
  447. #define LPFC_WQ_4K_PAGE_SZ 0x1
  448. #define LPFC_WQ_16K_PAGE_SZ 0x4
  449. struct lpfc_iov {
  450. uint32_t pf_number;
  451. uint32_t vf_number;
  452. };
  453. struct lpfc_sli4_lnk_info {
  454. uint8_t lnk_dv;
  455. #define LPFC_LNK_DAT_INVAL 0
  456. #define LPFC_LNK_DAT_VAL 1
  457. uint8_t lnk_tp;
  458. #define LPFC_LNK_GE 0x0 /* FCoE */
  459. #define LPFC_LNK_FC 0x1 /* FC */
  460. uint8_t lnk_no;
  461. uint8_t optic_state;
  462. };
  463. #define LPFC_SLI4_HANDLER_CNT (LPFC_HBA_IO_CHAN_MAX+ \
  464. LPFC_FOF_IO_CHAN_NUM)
  465. /* Used for IRQ vector to CPU mapping */
  466. struct lpfc_vector_map_info {
  467. uint16_t phys_id;
  468. uint16_t core_id;
  469. uint16_t irq;
  470. uint16_t channel_id;
  471. };
  472. #define LPFC_VECTOR_MAP_EMPTY 0xffff
  473. /* SLI4 HBA data structure entries */
  474. struct lpfc_sli4_hba {
  475. void __iomem *conf_regs_memmap_p; /* Kernel memory mapped address for
  476. * config space registers
  477. */
  478. void __iomem *ctrl_regs_memmap_p; /* Kernel memory mapped address for
  479. * control registers
  480. */
  481. void __iomem *drbl_regs_memmap_p; /* Kernel memory mapped address for
  482. * doorbell registers
  483. */
  484. void __iomem *dpp_regs_memmap_p; /* Kernel memory mapped address for
  485. * dpp registers
  486. */
  487. union {
  488. struct {
  489. /* IF Type 0, BAR 0 PCI cfg space reg mem map */
  490. void __iomem *UERRLOregaddr;
  491. void __iomem *UERRHIregaddr;
  492. void __iomem *UEMASKLOregaddr;
  493. void __iomem *UEMASKHIregaddr;
  494. } if_type0;
  495. struct {
  496. /* IF Type 2, BAR 0 PCI cfg space reg mem map. */
  497. void __iomem *STATUSregaddr;
  498. void __iomem *CTRLregaddr;
  499. void __iomem *ERR1regaddr;
  500. #define SLIPORT_ERR1_REG_ERR_CODE_1 0x1
  501. #define SLIPORT_ERR1_REG_ERR_CODE_2 0x2
  502. void __iomem *ERR2regaddr;
  503. #define SLIPORT_ERR2_REG_FW_RESTART 0x0
  504. #define SLIPORT_ERR2_REG_FUNC_PROVISON 0x1
  505. #define SLIPORT_ERR2_REG_FORCED_DUMP 0x2
  506. #define SLIPORT_ERR2_REG_FAILURE_EQ 0x3
  507. #define SLIPORT_ERR2_REG_FAILURE_CQ 0x4
  508. #define SLIPORT_ERR2_REG_FAILURE_BUS 0x5
  509. #define SLIPORT_ERR2_REG_FAILURE_RQ 0x6
  510. void __iomem *EQDregaddr;
  511. } if_type2;
  512. } u;
  513. /* IF type 0, BAR1 and if type 2, Bar 0 CSR register memory map */
  514. void __iomem *PSMPHRregaddr;
  515. /* Well-known SLI INTF register memory map. */
  516. void __iomem *SLIINTFregaddr;
  517. /* IF type 0, BAR 1 function CSR register memory map */
  518. void __iomem *ISRregaddr; /* HST_ISR register */
  519. void __iomem *IMRregaddr; /* HST_IMR register */
  520. void __iomem *ISCRregaddr; /* HST_ISCR register */
  521. /* IF type 0, BAR 0 and if type 2, BAR 0 doorbell register memory map */
  522. void __iomem *RQDBregaddr; /* RQ_DOORBELL register */
  523. void __iomem *WQDBregaddr; /* WQ_DOORBELL register */
  524. void __iomem *CQDBregaddr; /* CQ_DOORBELL register */
  525. void __iomem *EQDBregaddr; /* EQ_DOORBELL register */
  526. void __iomem *MQDBregaddr; /* MQ_DOORBELL register */
  527. void __iomem *BMBXregaddr; /* BootStrap MBX register */
  528. uint32_t ue_mask_lo;
  529. uint32_t ue_mask_hi;
  530. uint32_t ue_to_sr;
  531. uint32_t ue_to_rp;
  532. struct lpfc_register sli_intf;
  533. struct lpfc_pc_sli4_params pc_sli4_params;
  534. struct lpfc_bbscn_params bbscn_params;
  535. struct lpfc_hba_eq_hdl *hba_eq_hdl; /* HBA per-WQ handle */
  536. void (*sli4_eq_clr_intr)(struct lpfc_queue *q);
  537. uint32_t (*sli4_eq_release)(struct lpfc_queue *q, bool arm);
  538. uint32_t (*sli4_cq_release)(struct lpfc_queue *q, bool arm);
  539. /* Pointers to the constructed SLI4 queues */
  540. struct lpfc_queue **hba_eq; /* Event queues for HBA */
  541. struct lpfc_queue **fcp_cq; /* Fast-path FCP compl queue */
  542. struct lpfc_queue **nvme_cq; /* Fast-path NVME compl queue */
  543. struct lpfc_queue **nvmet_cqset; /* Fast-path NVMET CQ Set queues */
  544. struct lpfc_queue **nvmet_mrq_hdr; /* Fast-path NVMET hdr MRQs */
  545. struct lpfc_queue **nvmet_mrq_data; /* Fast-path NVMET data MRQs */
  546. struct lpfc_queue **fcp_wq; /* Fast-path FCP work queue */
  547. struct lpfc_queue **nvme_wq; /* Fast-path NVME work queue */
  548. uint16_t *fcp_cq_map;
  549. uint16_t *nvme_cq_map;
  550. struct list_head lpfc_wq_list;
  551. struct lpfc_queue *mbx_cq; /* Slow-path mailbox complete queue */
  552. struct lpfc_queue *els_cq; /* Slow-path ELS response complete queue */
  553. struct lpfc_queue *nvmels_cq; /* NVME LS complete queue */
  554. struct lpfc_queue *mbx_wq; /* Slow-path MBOX work queue */
  555. struct lpfc_queue *els_wq; /* Slow-path ELS work queue */
  556. struct lpfc_queue *nvmels_wq; /* NVME LS work queue */
  557. struct lpfc_queue *hdr_rq; /* Slow-path Header Receive queue */
  558. struct lpfc_queue *dat_rq; /* Slow-path Data Receive queue */
  559. struct lpfc_name wwnn;
  560. struct lpfc_name wwpn;
  561. uint32_t fw_func_mode; /* FW function protocol mode */
  562. uint32_t ulp0_mode; /* ULP0 protocol mode */
  563. uint32_t ulp1_mode; /* ULP1 protocol mode */
  564. struct lpfc_queue *fof_eq; /* Flash Optimized Fabric Event queue */
  565. /* Optimized Access Storage specific queues/structures */
  566. struct lpfc_queue *oas_cq; /* OAS completion queue */
  567. struct lpfc_queue *oas_wq; /* OAS Work queue */
  568. struct lpfc_sli_ring *oas_ring;
  569. uint64_t oas_next_lun;
  570. uint8_t oas_next_tgt_wwpn[8];
  571. uint8_t oas_next_vpt_wwpn[8];
  572. /* Setup information for various queue parameters */
  573. int eq_esize;
  574. int eq_ecount;
  575. int cq_esize;
  576. int cq_ecount;
  577. int wq_esize;
  578. int wq_ecount;
  579. int mq_esize;
  580. int mq_ecount;
  581. int rq_esize;
  582. int rq_ecount;
  583. #define LPFC_SP_EQ_MAX_INTR_SEC 10000
  584. #define LPFC_FP_EQ_MAX_INTR_SEC 10000
  585. uint32_t intr_enable;
  586. struct lpfc_bmbx bmbx;
  587. struct lpfc_max_cfg_param max_cfg_param;
  588. uint16_t extents_in_use; /* must allocate resource extents. */
  589. uint16_t rpi_hdrs_in_use; /* must post rpi hdrs if set. */
  590. uint16_t next_xri; /* last_xri - max_cfg_param.xri_base = used */
  591. uint16_t next_rpi;
  592. uint16_t nvme_xri_max;
  593. uint16_t nvme_xri_cnt;
  594. uint16_t nvme_xri_start;
  595. uint16_t scsi_xri_max;
  596. uint16_t scsi_xri_cnt;
  597. uint16_t scsi_xri_start;
  598. uint16_t els_xri_cnt;
  599. uint16_t nvmet_xri_cnt;
  600. uint16_t nvmet_io_wait_cnt;
  601. uint16_t nvmet_io_wait_total;
  602. struct list_head lpfc_els_sgl_list;
  603. struct list_head lpfc_abts_els_sgl_list;
  604. struct list_head lpfc_nvmet_sgl_list;
  605. struct list_head lpfc_abts_nvmet_ctx_list;
  606. struct list_head lpfc_abts_scsi_buf_list;
  607. struct list_head lpfc_abts_nvme_buf_list;
  608. struct list_head lpfc_nvmet_io_wait_list;
  609. struct lpfc_nvmet_ctx_info *nvmet_ctx_info;
  610. struct lpfc_sglq **lpfc_sglq_active_list;
  611. struct list_head lpfc_rpi_hdr_list;
  612. unsigned long *rpi_bmask;
  613. uint16_t *rpi_ids;
  614. uint16_t rpi_count;
  615. struct list_head lpfc_rpi_blk_list;
  616. unsigned long *xri_bmask;
  617. uint16_t *xri_ids;
  618. struct list_head lpfc_xri_blk_list;
  619. unsigned long *vfi_bmask;
  620. uint16_t *vfi_ids;
  621. uint16_t vfi_count;
  622. struct list_head lpfc_vfi_blk_list;
  623. struct lpfc_sli4_flags sli4_flags;
  624. struct list_head sp_queue_event;
  625. struct list_head sp_cqe_event_pool;
  626. struct list_head sp_asynce_work_queue;
  627. struct list_head sp_fcp_xri_aborted_work_queue;
  628. struct list_head sp_els_xri_aborted_work_queue;
  629. struct list_head sp_unsol_work_queue;
  630. struct lpfc_sli4_link link_state;
  631. struct lpfc_sli4_lnk_info lnk_info;
  632. uint32_t pport_name_sta;
  633. #define LPFC_SLI4_PPNAME_NON 0
  634. #define LPFC_SLI4_PPNAME_GET 1
  635. struct lpfc_iov iov;
  636. spinlock_t abts_nvme_buf_list_lock; /* list of aborted SCSI IOs */
  637. spinlock_t abts_scsi_buf_list_lock; /* list of aborted SCSI IOs */
  638. spinlock_t sgl_list_lock; /* list of aborted els IOs */
  639. spinlock_t nvmet_io_wait_lock; /* IOs waiting for ctx resources */
  640. uint32_t physical_port;
  641. /* CPU to vector mapping information */
  642. struct lpfc_vector_map_info *cpu_map;
  643. uint16_t num_online_cpu;
  644. uint16_t num_present_cpu;
  645. uint16_t curr_disp_cpu;
  646. };
  647. enum lpfc_sge_type {
  648. GEN_BUFF_TYPE,
  649. SCSI_BUFF_TYPE,
  650. NVMET_BUFF_TYPE
  651. };
  652. enum lpfc_sgl_state {
  653. SGL_FREED,
  654. SGL_ALLOCATED,
  655. SGL_XRI_ABORTED
  656. };
  657. struct lpfc_sglq {
  658. /* lpfc_sglqs are used in double linked lists */
  659. struct list_head list;
  660. struct list_head clist;
  661. enum lpfc_sge_type buff_type; /* is this a scsi sgl */
  662. enum lpfc_sgl_state state;
  663. struct lpfc_nodelist *ndlp; /* ndlp associated with IO */
  664. uint16_t iotag; /* pre-assigned IO tag */
  665. uint16_t sli4_lxritag; /* logical pre-assigned xri. */
  666. uint16_t sli4_xritag; /* pre-assigned XRI, (OXID) tag. */
  667. struct sli4_sge *sgl; /* pre-assigned SGL */
  668. void *virt; /* virtual address. */
  669. dma_addr_t phys; /* physical address */
  670. };
  671. struct lpfc_rpi_hdr {
  672. struct list_head list;
  673. uint32_t len;
  674. struct lpfc_dmabuf *dmabuf;
  675. uint32_t page_count;
  676. uint32_t start_rpi;
  677. uint16_t next_rpi;
  678. };
  679. struct lpfc_rsrc_blks {
  680. struct list_head list;
  681. uint16_t rsrc_start;
  682. uint16_t rsrc_size;
  683. uint16_t rsrc_used;
  684. };
  685. struct lpfc_rdp_context {
  686. struct lpfc_nodelist *ndlp;
  687. uint16_t ox_id;
  688. uint16_t rx_id;
  689. READ_LNK_VAR link_stat;
  690. uint8_t page_a0[DMP_SFF_PAGE_A0_SIZE];
  691. uint8_t page_a2[DMP_SFF_PAGE_A2_SIZE];
  692. void (*cmpl)(struct lpfc_hba *, struct lpfc_rdp_context*, int);
  693. };
  694. struct lpfc_lcb_context {
  695. uint8_t sub_command;
  696. uint8_t type;
  697. uint8_t capability;
  698. uint8_t frequency;
  699. uint16_t duration;
  700. uint16_t ox_id;
  701. uint16_t rx_id;
  702. struct lpfc_nodelist *ndlp;
  703. };
  704. /*
  705. * SLI4 specific function prototypes
  706. */
  707. int lpfc_pci_function_reset(struct lpfc_hba *);
  708. int lpfc_sli4_pdev_status_reg_wait(struct lpfc_hba *);
  709. int lpfc_sli4_hba_setup(struct lpfc_hba *);
  710. int lpfc_sli4_config(struct lpfc_hba *, struct lpfcMboxq *, uint8_t,
  711. uint8_t, uint32_t, bool);
  712. void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *);
  713. void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t);
  714. void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t,
  715. struct lpfc_mbx_sge *);
  716. int lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *, struct lpfcMboxq *,
  717. uint16_t);
  718. void lpfc_sli4_hba_reset(struct lpfc_hba *);
  719. struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t,
  720. uint32_t, uint32_t);
  721. void lpfc_sli4_queue_free(struct lpfc_queue *);
  722. int lpfc_eq_create(struct lpfc_hba *, struct lpfc_queue *, uint32_t);
  723. int lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, uint32_t startq,
  724. uint32_t numq, uint32_t imax);
  725. int lpfc_cq_create(struct lpfc_hba *, struct lpfc_queue *,
  726. struct lpfc_queue *, uint32_t, uint32_t);
  727. int lpfc_cq_create_set(struct lpfc_hba *phba, struct lpfc_queue **cqp,
  728. struct lpfc_queue **eqp, uint32_t type,
  729. uint32_t subtype);
  730. int32_t lpfc_mq_create(struct lpfc_hba *, struct lpfc_queue *,
  731. struct lpfc_queue *, uint32_t);
  732. int lpfc_wq_create(struct lpfc_hba *, struct lpfc_queue *,
  733. struct lpfc_queue *, uint32_t);
  734. int lpfc_rq_create(struct lpfc_hba *, struct lpfc_queue *,
  735. struct lpfc_queue *, struct lpfc_queue *, uint32_t);
  736. int lpfc_mrq_create(struct lpfc_hba *phba, struct lpfc_queue **hrqp,
  737. struct lpfc_queue **drqp, struct lpfc_queue **cqp,
  738. uint32_t subtype);
  739. int lpfc_eq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  740. int lpfc_cq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  741. int lpfc_mq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  742. int lpfc_wq_destroy(struct lpfc_hba *, struct lpfc_queue *);
  743. int lpfc_rq_destroy(struct lpfc_hba *, struct lpfc_queue *,
  744. struct lpfc_queue *);
  745. int lpfc_sli4_queue_setup(struct lpfc_hba *);
  746. void lpfc_sli4_queue_unset(struct lpfc_hba *);
  747. int lpfc_sli4_post_sgl(struct lpfc_hba *, dma_addr_t, dma_addr_t, uint16_t);
  748. int lpfc_sli4_repost_scsi_sgl_list(struct lpfc_hba *);
  749. int lpfc_repost_nvme_sgl_list(struct lpfc_hba *phba);
  750. uint16_t lpfc_sli4_next_xritag(struct lpfc_hba *);
  751. void lpfc_sli4_free_xri(struct lpfc_hba *, int);
  752. int lpfc_sli4_post_async_mbox(struct lpfc_hba *);
  753. int lpfc_sli4_post_scsi_sgl_block(struct lpfc_hba *, struct list_head *, int);
  754. struct lpfc_cq_event *__lpfc_sli4_cq_event_alloc(struct lpfc_hba *);
  755. struct lpfc_cq_event *lpfc_sli4_cq_event_alloc(struct lpfc_hba *);
  756. void __lpfc_sli4_cq_event_release(struct lpfc_hba *, struct lpfc_cq_event *);
  757. void lpfc_sli4_cq_event_release(struct lpfc_hba *, struct lpfc_cq_event *);
  758. int lpfc_sli4_init_rpi_hdrs(struct lpfc_hba *);
  759. int lpfc_sli4_post_rpi_hdr(struct lpfc_hba *, struct lpfc_rpi_hdr *);
  760. int lpfc_sli4_post_all_rpi_hdrs(struct lpfc_hba *);
  761. struct lpfc_rpi_hdr *lpfc_sli4_create_rpi_hdr(struct lpfc_hba *);
  762. void lpfc_sli4_remove_rpi_hdrs(struct lpfc_hba *);
  763. int lpfc_sli4_alloc_rpi(struct lpfc_hba *);
  764. void lpfc_sli4_free_rpi(struct lpfc_hba *, int);
  765. void lpfc_sli4_remove_rpis(struct lpfc_hba *);
  766. void lpfc_sli4_async_event_proc(struct lpfc_hba *);
  767. void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *);
  768. int lpfc_sli4_resume_rpi(struct lpfc_nodelist *,
  769. void (*)(struct lpfc_hba *, LPFC_MBOXQ_t *), void *);
  770. void lpfc_sli4_fcp_xri_abort_event_proc(struct lpfc_hba *);
  771. void lpfc_sli4_els_xri_abort_event_proc(struct lpfc_hba *);
  772. void lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *,
  773. struct sli4_wcqe_xri_aborted *);
  774. void lpfc_sli4_nvme_xri_aborted(struct lpfc_hba *phba,
  775. struct sli4_wcqe_xri_aborted *axri);
  776. void lpfc_sli4_nvmet_xri_aborted(struct lpfc_hba *phba,
  777. struct sli4_wcqe_xri_aborted *axri);
  778. void lpfc_sli4_els_xri_aborted(struct lpfc_hba *,
  779. struct sli4_wcqe_xri_aborted *);
  780. void lpfc_sli4_vport_delete_els_xri_aborted(struct lpfc_vport *);
  781. void lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *);
  782. int lpfc_sli4_brdreset(struct lpfc_hba *);
  783. int lpfc_sli4_add_fcf_record(struct lpfc_hba *, struct fcf_record *);
  784. void lpfc_sli_remove_dflt_fcf(struct lpfc_hba *);
  785. int lpfc_sli4_get_els_iocb_cnt(struct lpfc_hba *);
  786. int lpfc_sli4_get_iocb_cnt(struct lpfc_hba *phba);
  787. int lpfc_sli4_init_vpi(struct lpfc_vport *);
  788. inline void lpfc_sli4_eq_clr_intr(struct lpfc_queue *);
  789. uint32_t lpfc_sli4_cq_release(struct lpfc_queue *, bool);
  790. uint32_t lpfc_sli4_eq_release(struct lpfc_queue *, bool);
  791. inline void lpfc_sli4_if6_eq_clr_intr(struct lpfc_queue *q);
  792. uint32_t lpfc_sli4_if6_cq_release(struct lpfc_queue *q, bool arm);
  793. uint32_t lpfc_sli4_if6_eq_release(struct lpfc_queue *q, bool arm);
  794. void lpfc_sli4_fcfi_unreg(struct lpfc_hba *, uint16_t);
  795. int lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *, uint16_t);
  796. int lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *, uint16_t);
  797. int lpfc_sli4_read_fcf_rec(struct lpfc_hba *, uint16_t);
  798. void lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
  799. void lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
  800. void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *);
  801. int lpfc_sli4_unregister_fcf(struct lpfc_hba *);
  802. int lpfc_sli4_post_status_check(struct lpfc_hba *);
  803. uint8_t lpfc_sli_config_mbox_subsys_get(struct lpfc_hba *, LPFC_MBOXQ_t *);
  804. uint8_t lpfc_sli_config_mbox_opcode_get(struct lpfc_hba *, LPFC_MBOXQ_t *);