efct_hw.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
  4. * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
  5. */
  6. #ifndef _EFCT_HW_H
  7. #define _EFCT_HW_H
  8. #include "../libefc_sli/sli4.h"
  9. /*
  10. * EFCT PCI IDs
  11. */
  12. #define EFCT_VENDOR_ID 0x10df
  13. /* LightPulse 16Gb x 4 FC (lancer-g6) */
  14. #define EFCT_DEVICE_LANCER_G6 0xe307
  15. /* LightPulse 32Gb x 4 FC (lancer-g7) */
  16. #define EFCT_DEVICE_LANCER_G7 0xf407
  17. /*Default RQ entries len used by driver*/
  18. #define EFCT_HW_RQ_ENTRIES_MIN 512
  19. #define EFCT_HW_RQ_ENTRIES_DEF 1024
  20. #define EFCT_HW_RQ_ENTRIES_MAX 4096
  21. /*Defines the size of the RQ buffers used for each RQ*/
  22. #define EFCT_HW_RQ_SIZE_HDR 128
  23. #define EFCT_HW_RQ_SIZE_PAYLOAD 1024
  24. /*Define the maximum number of multi-receive queues*/
  25. #define EFCT_HW_MAX_MRQS 8
  26. /*
  27. * Define count of when to set the WQEC bit in a submitted
  28. * WQE, causing a consummed/released completion to be posted.
  29. */
  30. #define EFCT_HW_WQEC_SET_COUNT 32
  31. /*Send frame timeout in seconds*/
  32. #define EFCT_HW_SEND_FRAME_TIMEOUT 10
  33. /*
  34. * FDT Transfer Hint value, reads greater than this value
  35. * will be segmented to implement fairness. A value of zero disables
  36. * the feature.
  37. */
  38. #define EFCT_HW_FDT_XFER_HINT 8192
  39. #define EFCT_HW_TIMECHECK_ITERATIONS 100
  40. #define EFCT_HW_MAX_NUM_MQ 1
  41. #define EFCT_HW_MAX_NUM_RQ 32
  42. #define EFCT_HW_MAX_NUM_EQ 16
  43. #define EFCT_HW_MAX_NUM_WQ 32
  44. #define EFCT_HW_DEF_NUM_EQ 1
  45. #define OCE_HW_MAX_NUM_MRQ_PAIRS 16
  46. #define EFCT_HW_MQ_DEPTH 128
  47. #define EFCT_HW_EQ_DEPTH 1024
  48. /*
  49. * A CQ will be assinged to each WQ
  50. * (CQ must have 2X entries of the WQ for abort
  51. * processing), plus a separate one for each RQ PAIR and one for MQ
  52. */
  53. #define EFCT_HW_MAX_NUM_CQ \
  54. ((EFCT_HW_MAX_NUM_WQ * 2) + 1 + (OCE_HW_MAX_NUM_MRQ_PAIRS * 2))
  55. #define EFCT_HW_Q_HASH_SIZE 128
  56. #define EFCT_HW_RQ_HEADER_SIZE 128
  57. #define EFCT_HW_RQ_HEADER_INDEX 0
  58. #define EFCT_HW_REQUE_XRI_REGTAG 65534
  59. /* Options for efct_hw_command() */
  60. enum efct_cmd_opts {
  61. /* command executes synchronously and busy-waits for completion */
  62. EFCT_CMD_POLL,
  63. /* command executes asynchronously. Uses callback */
  64. EFCT_CMD_NOWAIT,
  65. };
  66. enum efct_hw_reset {
  67. EFCT_HW_RESET_FUNCTION,
  68. EFCT_HW_RESET_FIRMWARE,
  69. EFCT_HW_RESET_MAX
  70. };
  71. enum efct_hw_topo {
  72. EFCT_HW_TOPOLOGY_AUTO,
  73. EFCT_HW_TOPOLOGY_NPORT,
  74. EFCT_HW_TOPOLOGY_LOOP,
  75. EFCT_HW_TOPOLOGY_NONE,
  76. EFCT_HW_TOPOLOGY_MAX
  77. };
  78. /* pack fw revision values into a single uint64_t */
  79. #define HW_FWREV(a, b, c, d) (((uint64_t)(a) << 48) | ((uint64_t)(b) << 32) \
  80. | ((uint64_t)(c) << 16) | ((uint64_t)(d)))
  81. #define EFCT_FW_VER_STR(a, b, c, d) (#a "." #b "." #c "." #d)
  82. enum efct_hw_io_type {
  83. EFCT_HW_ELS_REQ,
  84. EFCT_HW_ELS_RSP,
  85. EFCT_HW_FC_CT,
  86. EFCT_HW_FC_CT_RSP,
  87. EFCT_HW_BLS_ACC,
  88. EFCT_HW_BLS_RJT,
  89. EFCT_HW_IO_TARGET_READ,
  90. EFCT_HW_IO_TARGET_WRITE,
  91. EFCT_HW_IO_TARGET_RSP,
  92. EFCT_HW_IO_DNRX_REQUEUE,
  93. EFCT_HW_IO_MAX,
  94. };
  95. enum efct_hw_io_state {
  96. EFCT_HW_IO_STATE_FREE,
  97. EFCT_HW_IO_STATE_INUSE,
  98. EFCT_HW_IO_STATE_WAIT_FREE,
  99. EFCT_HW_IO_STATE_WAIT_SEC_HIO,
  100. };
  101. #define EFCT_TARGET_WRITE_SKIPS 1
  102. #define EFCT_TARGET_READ_SKIPS 2
  103. struct efct_hw;
  104. struct efct_io;
  105. #define EFCT_CMD_CTX_POOL_SZ 32
  106. /**
  107. * HW command context.
  108. * Stores the state for the asynchronous commands sent to the hardware.
  109. */
  110. struct efct_command_ctx {
  111. struct list_head list_entry;
  112. int (*cb)(struct efct_hw *hw, int status, u8 *mqe, void *arg);
  113. void *arg; /* Argument for callback */
  114. /* buffer holding command / results */
  115. u8 buf[SLI4_BMBX_SIZE];
  116. void *ctx; /* upper layer context */
  117. };
  118. struct efct_hw_sgl {
  119. uintptr_t addr;
  120. size_t len;
  121. };
  122. union efct_hw_io_param_u {
  123. struct sli_bls_params bls;
  124. struct sli_els_params els;
  125. struct sli_ct_params fc_ct;
  126. struct sli_fcp_tgt_params fcp_tgt;
  127. };
  128. /* WQ steering mode */
  129. enum efct_hw_wq_steering {
  130. EFCT_HW_WQ_STEERING_CLASS,
  131. EFCT_HW_WQ_STEERING_REQUEST,
  132. EFCT_HW_WQ_STEERING_CPU,
  133. };
  134. /* HW wqe object */
  135. struct efct_hw_wqe {
  136. struct list_head list_entry;
  137. bool abort_wqe_submit_needed;
  138. bool send_abts;
  139. u32 id;
  140. u32 abort_reqtag;
  141. u8 *wqebuf;
  142. };
  143. struct efct_hw_io;
  144. /* Typedef for HW "done" callback */
  145. typedef int (*efct_hw_done_t)(struct efct_hw_io *, u32 len, int status,
  146. u32 ext, void *ul_arg);
  147. /**
  148. * HW IO object.
  149. *
  150. * Stores the per-IO information necessary
  151. * for both SLI and efct.
  152. * @ref: reference counter for hw io object
  153. * @state: state of IO: free, busy, wait_free
  154. * @list_entry used for busy, wait_free, free lists
  155. * @wqe Work queue object, with link for pending
  156. * @hw pointer back to hardware context
  157. * @xfer_rdy transfer ready data
  158. * @type IO type
  159. * @xbusy Exchange is active in FW
  160. * @abort_in_progress if TRUE, abort is in progress
  161. * @status_saved if TRUE, latched status should be returned
  162. * @wq_class WQ class if steering mode is Class
  163. * @reqtag request tag for this HW IO
  164. * @wq WQ assigned to the exchange
  165. * @done Function called on IO completion
  166. * @arg argument passed to IO done callback
  167. * @abort_done Function called on abort completion
  168. * @abort_arg argument passed to abort done callback
  169. * @wq_steering WQ steering mode request
  170. * @saved_status Saved status
  171. * @saved_len Status length
  172. * @saved_ext Saved extended status
  173. * @eq EQ on which this HIO came up
  174. * @sge_offset SGE data offset
  175. * @def_sgl_count Count of SGEs in default SGL
  176. * @abort_reqtag request tag for an abort of this HW IO
  177. * @indicator Exchange indicator
  178. * @def_sgl default SGL
  179. * @sgl pointer to current active SGL
  180. * @sgl_count count of SGEs in io->sgl
  181. * @first_data_sge index of first data SGE
  182. * @n_sge number of active SGEs
  183. */
  184. struct efct_hw_io {
  185. struct kref ref;
  186. enum efct_hw_io_state state;
  187. void (*release)(struct kref *arg);
  188. struct list_head list_entry;
  189. struct efct_hw_wqe wqe;
  190. struct efct_hw *hw;
  191. struct efc_dma xfer_rdy;
  192. u16 type;
  193. bool xbusy;
  194. int abort_in_progress;
  195. bool status_saved;
  196. u8 wq_class;
  197. u16 reqtag;
  198. struct hw_wq *wq;
  199. efct_hw_done_t done;
  200. void *arg;
  201. efct_hw_done_t abort_done;
  202. void *abort_arg;
  203. enum efct_hw_wq_steering wq_steering;
  204. u32 saved_status;
  205. u32 saved_len;
  206. u32 saved_ext;
  207. struct hw_eq *eq;
  208. u32 sge_offset;
  209. u32 def_sgl_count;
  210. u32 abort_reqtag;
  211. u32 indicator;
  212. struct efc_dma def_sgl;
  213. struct efc_dma *sgl;
  214. u32 sgl_count;
  215. u32 first_data_sge;
  216. u32 n_sge;
  217. };
  218. enum efct_hw_port {
  219. EFCT_HW_PORT_INIT,
  220. EFCT_HW_PORT_SHUTDOWN,
  221. };
  222. /* Node group rpi reference */
  223. struct efct_hw_rpi_ref {
  224. atomic_t rpi_count;
  225. atomic_t rpi_attached;
  226. };
  227. enum efct_hw_link_stat {
  228. EFCT_HW_LINK_STAT_LINK_FAILURE_COUNT,
  229. EFCT_HW_LINK_STAT_LOSS_OF_SYNC_COUNT,
  230. EFCT_HW_LINK_STAT_LOSS_OF_SIGNAL_COUNT,
  231. EFCT_HW_LINK_STAT_PRIMITIVE_SEQ_COUNT,
  232. EFCT_HW_LINK_STAT_INVALID_XMIT_WORD_COUNT,
  233. EFCT_HW_LINK_STAT_CRC_COUNT,
  234. EFCT_HW_LINK_STAT_PRIMITIVE_SEQ_TIMEOUT_COUNT,
  235. EFCT_HW_LINK_STAT_ELASTIC_BUFFER_OVERRUN_COUNT,
  236. EFCT_HW_LINK_STAT_ARB_TIMEOUT_COUNT,
  237. EFCT_HW_LINK_STAT_ADVERTISED_RCV_B2B_CREDIT,
  238. EFCT_HW_LINK_STAT_CURR_RCV_B2B_CREDIT,
  239. EFCT_HW_LINK_STAT_ADVERTISED_XMIT_B2B_CREDIT,
  240. EFCT_HW_LINK_STAT_CURR_XMIT_B2B_CREDIT,
  241. EFCT_HW_LINK_STAT_RCV_EOFA_COUNT,
  242. EFCT_HW_LINK_STAT_RCV_EOFDTI_COUNT,
  243. EFCT_HW_LINK_STAT_RCV_EOFNI_COUNT,
  244. EFCT_HW_LINK_STAT_RCV_SOFF_COUNT,
  245. EFCT_HW_LINK_STAT_RCV_DROPPED_NO_AER_COUNT,
  246. EFCT_HW_LINK_STAT_RCV_DROPPED_NO_RPI_COUNT,
  247. EFCT_HW_LINK_STAT_RCV_DROPPED_NO_XRI_COUNT,
  248. EFCT_HW_LINK_STAT_MAX,
  249. };
  250. enum efct_hw_host_stat {
  251. EFCT_HW_HOST_STAT_TX_KBYTE_COUNT,
  252. EFCT_HW_HOST_STAT_RX_KBYTE_COUNT,
  253. EFCT_HW_HOST_STAT_TX_FRAME_COUNT,
  254. EFCT_HW_HOST_STAT_RX_FRAME_COUNT,
  255. EFCT_HW_HOST_STAT_TX_SEQ_COUNT,
  256. EFCT_HW_HOST_STAT_RX_SEQ_COUNT,
  257. EFCT_HW_HOST_STAT_TOTAL_EXCH_ORIG,
  258. EFCT_HW_HOST_STAT_TOTAL_EXCH_RESP,
  259. EFCT_HW_HOSY_STAT_RX_P_BSY_COUNT,
  260. EFCT_HW_HOST_STAT_RX_F_BSY_COUNT,
  261. EFCT_HW_HOST_STAT_DROP_FRM_DUE_TO_NO_RQ_BUF_COUNT,
  262. EFCT_HW_HOST_STAT_EMPTY_RQ_TIMEOUT_COUNT,
  263. EFCT_HW_HOST_STAT_DROP_FRM_DUE_TO_NO_XRI_COUNT,
  264. EFCT_HW_HOST_STAT_EMPTY_XRI_POOL_COUNT,
  265. EFCT_HW_HOST_STAT_MAX,
  266. };
  267. enum efct_hw_state {
  268. EFCT_HW_STATE_UNINITIALIZED,
  269. EFCT_HW_STATE_QUEUES_ALLOCATED,
  270. EFCT_HW_STATE_ACTIVE,
  271. EFCT_HW_STATE_RESET_IN_PROGRESS,
  272. EFCT_HW_STATE_TEARDOWN_IN_PROGRESS,
  273. };
  274. struct efct_hw_link_stat_counts {
  275. u8 overflow;
  276. u32 counter;
  277. };
  278. struct efct_hw_host_stat_counts {
  279. u32 counter;
  280. };
  281. /* Structure used for the hash lookup of queue IDs */
  282. struct efct_queue_hash {
  283. bool in_use;
  284. u16 id;
  285. u16 index;
  286. };
  287. /* WQ callback object */
  288. struct hw_wq_callback {
  289. u16 instance_index; /* use for request tag */
  290. void (*callback)(void *arg, u8 *cqe, int status);
  291. void *arg;
  292. struct list_head list_entry;
  293. };
  294. struct reqtag_pool {
  295. spinlock_t lock; /* pool lock */
  296. struct hw_wq_callback *tags[U16_MAX];
  297. struct list_head freelist;
  298. };
  299. struct efct_hw_config {
  300. u32 n_eq;
  301. u32 n_cq;
  302. u32 n_mq;
  303. u32 n_rq;
  304. u32 n_wq;
  305. u32 n_io;
  306. u32 n_sgl;
  307. u32 speed;
  308. u32 topology;
  309. /* size of the buffers for first burst */
  310. u32 rq_default_buffer_size;
  311. u8 esoc;
  312. /* MRQ RQ selection policy */
  313. u8 rq_selection_policy;
  314. /* RQ quanta if rq_selection_policy == 2 */
  315. u8 rr_quanta;
  316. u32 filter_def[SLI4_CMD_REG_FCFI_NUM_RQ_CFG];
  317. };
  318. struct efct_hw {
  319. struct efct *os;
  320. struct sli4 sli;
  321. u16 ulp_start;
  322. u16 ulp_max;
  323. u32 dump_size;
  324. enum efct_hw_state state;
  325. bool hw_setup_called;
  326. u8 sliport_healthcheck;
  327. u16 fcf_indicator;
  328. /* HW configuration */
  329. struct efct_hw_config config;
  330. /* calculated queue sizes for each type */
  331. u32 num_qentries[SLI4_QTYPE_MAX];
  332. /* Storage for SLI queue objects */
  333. struct sli4_queue wq[EFCT_HW_MAX_NUM_WQ];
  334. struct sli4_queue rq[EFCT_HW_MAX_NUM_RQ];
  335. u16 hw_rq_lookup[EFCT_HW_MAX_NUM_RQ];
  336. struct sli4_queue mq[EFCT_HW_MAX_NUM_MQ];
  337. struct sli4_queue cq[EFCT_HW_MAX_NUM_CQ];
  338. struct sli4_queue eq[EFCT_HW_MAX_NUM_EQ];
  339. /* HW queue */
  340. u32 eq_count;
  341. u32 cq_count;
  342. u32 mq_count;
  343. u32 wq_count;
  344. u32 rq_count;
  345. u32 cmd_head_count;
  346. struct list_head eq_list;
  347. struct efct_queue_hash cq_hash[EFCT_HW_Q_HASH_SIZE];
  348. struct efct_queue_hash rq_hash[EFCT_HW_Q_HASH_SIZE];
  349. struct efct_queue_hash wq_hash[EFCT_HW_Q_HASH_SIZE];
  350. /* Storage for HW queue objects */
  351. struct hw_wq *hw_wq[EFCT_HW_MAX_NUM_WQ];
  352. struct hw_rq *hw_rq[EFCT_HW_MAX_NUM_RQ];
  353. struct hw_mq *hw_mq[EFCT_HW_MAX_NUM_MQ];
  354. struct hw_cq *hw_cq[EFCT_HW_MAX_NUM_CQ];
  355. struct hw_eq *hw_eq[EFCT_HW_MAX_NUM_EQ];
  356. /* count of hw_rq[] entries */
  357. u32 hw_rq_count;
  358. /* count of multirq RQs */
  359. u32 hw_mrq_count;
  360. struct hw_wq **wq_cpu_array;
  361. /* Sequence objects used in incoming frame processing */
  362. struct efc_hw_sequence *seq_pool;
  363. /* Maintain an ordered, linked list of outstanding HW commands. */
  364. struct mutex bmbx_lock;
  365. spinlock_t cmd_lock;
  366. struct list_head cmd_head;
  367. struct list_head cmd_pending;
  368. mempool_t *cmd_ctx_pool;
  369. mempool_t *mbox_rqst_pool;
  370. struct sli4_link_event link;
  371. /* pointer array of IO objects */
  372. struct efct_hw_io **io;
  373. /* array of WQE buffs mapped to IO objects */
  374. u8 *wqe_buffs;
  375. /* IO lock to synchronize list access */
  376. spinlock_t io_lock;
  377. /* List of IO objects in use */
  378. struct list_head io_inuse;
  379. /* List of IO objects waiting to be freed */
  380. struct list_head io_wait_free;
  381. /* List of IO objects available for allocation */
  382. struct list_head io_free;
  383. struct efc_dma loop_map;
  384. struct efc_dma xfer_rdy;
  385. struct efc_dma rnode_mem;
  386. atomic_t io_alloc_failed_count;
  387. /* stat: wq sumbit count */
  388. u32 tcmd_wq_submit[EFCT_HW_MAX_NUM_WQ];
  389. /* stat: wq complete count */
  390. u32 tcmd_wq_complete[EFCT_HW_MAX_NUM_WQ];
  391. atomic_t send_frame_seq_id;
  392. struct reqtag_pool *wq_reqtag_pool;
  393. };
  394. enum efct_hw_io_count_type {
  395. EFCT_HW_IO_INUSE_COUNT,
  396. EFCT_HW_IO_FREE_COUNT,
  397. EFCT_HW_IO_WAIT_FREE_COUNT,
  398. EFCT_HW_IO_N_TOTAL_IO_COUNT,
  399. };
  400. /* HW queue data structures */
  401. struct hw_eq {
  402. struct list_head list_entry;
  403. enum sli4_qtype type;
  404. u32 instance;
  405. u32 entry_count;
  406. u32 entry_size;
  407. struct efct_hw *hw;
  408. struct sli4_queue *queue;
  409. struct list_head cq_list;
  410. u32 use_count;
  411. };
  412. struct hw_cq {
  413. struct list_head list_entry;
  414. enum sli4_qtype type;
  415. u32 instance;
  416. u32 entry_count;
  417. u32 entry_size;
  418. struct hw_eq *eq;
  419. struct sli4_queue *queue;
  420. struct list_head q_list;
  421. u32 use_count;
  422. };
  423. struct hw_q {
  424. struct list_head list_entry;
  425. enum sli4_qtype type;
  426. };
  427. struct hw_mq {
  428. struct list_head list_entry;
  429. enum sli4_qtype type;
  430. u32 instance;
  431. u32 entry_count;
  432. u32 entry_size;
  433. struct hw_cq *cq;
  434. struct sli4_queue *queue;
  435. u32 use_count;
  436. };
  437. struct hw_wq {
  438. struct list_head list_entry;
  439. enum sli4_qtype type;
  440. u32 instance;
  441. struct efct_hw *hw;
  442. u32 entry_count;
  443. u32 entry_size;
  444. struct hw_cq *cq;
  445. struct sli4_queue *queue;
  446. u32 class;
  447. /* WQ consumed */
  448. u32 wqec_set_count;
  449. u32 wqec_count;
  450. u32 free_count;
  451. u32 total_submit_count;
  452. struct list_head pending_list;
  453. /* HW IO allocated for use with Send Frame */
  454. struct efct_hw_io *send_frame_io;
  455. /* Stats */
  456. u32 use_count;
  457. u32 wq_pending_count;
  458. };
  459. struct hw_rq {
  460. struct list_head list_entry;
  461. enum sli4_qtype type;
  462. u32 instance;
  463. u32 entry_count;
  464. u32 use_count;
  465. u32 hdr_entry_size;
  466. u32 first_burst_entry_size;
  467. u32 data_entry_size;
  468. bool is_mrq;
  469. u32 base_mrq_id;
  470. struct hw_cq *cq;
  471. u8 filter_mask;
  472. struct sli4_queue *hdr;
  473. struct sli4_queue *first_burst;
  474. struct sli4_queue *data;
  475. struct efc_hw_rq_buffer *hdr_buf;
  476. struct efc_hw_rq_buffer *fb_buf;
  477. struct efc_hw_rq_buffer *payload_buf;
  478. /* RQ tracker for this RQ */
  479. struct efc_hw_sequence **rq_tracker;
  480. };
  481. struct efct_hw_send_frame_context {
  482. struct efct_hw *hw;
  483. struct hw_wq_callback *wqcb;
  484. struct efct_hw_wqe wqe;
  485. void (*callback)(int status, void *arg);
  486. void *arg;
  487. /* General purpose elements */
  488. struct efc_hw_sequence *seq;
  489. struct efc_dma payload;
  490. };
  491. struct efct_hw_grp_hdr {
  492. u32 size;
  493. __be32 magic_number;
  494. u32 word2;
  495. u8 rev_name[128];
  496. u8 date[12];
  497. u8 revision[32];
  498. };
  499. static inline int
  500. efct_hw_get_link_speed(struct efct_hw *hw) {
  501. return hw->link.speed;
  502. }
  503. int
  504. efct_hw_setup(struct efct_hw *hw, void *os, struct pci_dev *pdev);
  505. int efct_hw_init(struct efct_hw *hw);
  506. int
  507. efct_hw_parse_filter(struct efct_hw *hw, void *value);
  508. int
  509. efct_hw_init_queues(struct efct_hw *hw);
  510. int
  511. efct_hw_map_wq_cpu(struct efct_hw *hw);
  512. uint64_t
  513. efct_get_wwnn(struct efct_hw *hw);
  514. uint64_t
  515. efct_get_wwpn(struct efct_hw *hw);
  516. int efct_hw_rx_allocate(struct efct_hw *hw);
  517. int efct_hw_rx_post(struct efct_hw *hw);
  518. void efct_hw_rx_free(struct efct_hw *hw);
  519. int
  520. efct_hw_command(struct efct_hw *hw, u8 *cmd, u32 opts, void *cb,
  521. void *arg);
  522. int
  523. efct_issue_mbox_rqst(void *base, void *cmd, void *cb, void *arg);
  524. struct efct_hw_io *efct_hw_io_alloc(struct efct_hw *hw);
  525. int efct_hw_io_free(struct efct_hw *hw, struct efct_hw_io *io);
  526. u8 efct_hw_io_inuse(struct efct_hw *hw, struct efct_hw_io *io);
  527. int
  528. efct_hw_io_send(struct efct_hw *hw, enum efct_hw_io_type type,
  529. struct efct_hw_io *io, union efct_hw_io_param_u *iparam,
  530. void *cb, void *arg);
  531. int
  532. efct_hw_io_register_sgl(struct efct_hw *hw, struct efct_hw_io *io,
  533. struct efc_dma *sgl,
  534. u32 sgl_count);
  535. int
  536. efct_hw_io_init_sges(struct efct_hw *hw,
  537. struct efct_hw_io *io, enum efct_hw_io_type type);
  538. int
  539. efct_hw_io_add_sge(struct efct_hw *hw, struct efct_hw_io *io,
  540. uintptr_t addr, u32 length);
  541. int
  542. efct_hw_io_abort(struct efct_hw *hw, struct efct_hw_io *io_to_abort,
  543. bool send_abts, void *cb, void *arg);
  544. u32
  545. efct_hw_io_get_count(struct efct_hw *hw,
  546. enum efct_hw_io_count_type io_count_type);
  547. struct efct_hw_io
  548. *efct_hw_io_lookup(struct efct_hw *hw, u32 indicator);
  549. void efct_hw_io_abort_all(struct efct_hw *hw);
  550. void efct_hw_io_free_internal(struct kref *arg);
  551. /* HW WQ request tag API */
  552. struct reqtag_pool *efct_hw_reqtag_pool_alloc(struct efct_hw *hw);
  553. void efct_hw_reqtag_pool_free(struct efct_hw *hw);
  554. struct hw_wq_callback
  555. *efct_hw_reqtag_alloc(struct efct_hw *hw,
  556. void (*callback)(void *arg, u8 *cqe,
  557. int status), void *arg);
  558. void
  559. efct_hw_reqtag_free(struct efct_hw *hw, struct hw_wq_callback *wqcb);
  560. struct hw_wq_callback
  561. *efct_hw_reqtag_get_instance(struct efct_hw *hw, u32 instance_index);
  562. /* RQ completion handlers for RQ pair mode */
  563. int
  564. efct_hw_rqpair_process_rq(struct efct_hw *hw,
  565. struct hw_cq *cq, u8 *cqe);
  566. int
  567. efct_hw_rqpair_sequence_free(struct efct_hw *hw, struct efc_hw_sequence *seq);
  568. static inline void
  569. efct_hw_sequence_copy(struct efc_hw_sequence *dst,
  570. struct efc_hw_sequence *src)
  571. {
  572. /* Copy src to dst, then zero out the linked list link */
  573. *dst = *src;
  574. }
  575. int
  576. efct_efc_hw_sequence_free(struct efc *efc, struct efc_hw_sequence *seq);
  577. static inline int
  578. efct_hw_sequence_free(struct efct_hw *hw, struct efc_hw_sequence *seq)
  579. {
  580. /* Only RQ pair mode is supported */
  581. return efct_hw_rqpair_sequence_free(hw, seq);
  582. }
  583. int
  584. efct_hw_eq_process(struct efct_hw *hw, struct hw_eq *eq,
  585. u32 max_isr_time_msec);
  586. void efct_hw_cq_process(struct efct_hw *hw, struct hw_cq *cq);
  587. void
  588. efct_hw_wq_process(struct efct_hw *hw, struct hw_cq *cq,
  589. u8 *cqe, int status, u16 rid);
  590. void
  591. efct_hw_xabt_process(struct efct_hw *hw, struct hw_cq *cq,
  592. u8 *cqe, u16 rid);
  593. int
  594. efct_hw_process(struct efct_hw *hw, u32 vector, u32 max_isr_time_msec);
  595. int
  596. efct_hw_queue_hash_find(struct efct_queue_hash *hash, u16 id);
  597. int efct_hw_wq_write(struct hw_wq *wq, struct efct_hw_wqe *wqe);
  598. int
  599. efct_hw_send_frame(struct efct_hw *hw, struct fc_frame_header *hdr,
  600. u8 sof, u8 eof, struct efc_dma *payload,
  601. struct efct_hw_send_frame_context *ctx,
  602. void (*callback)(void *arg, u8 *cqe, int status),
  603. void *arg);
  604. int
  605. efct_els_hw_srrs_send(struct efc *efc, struct efc_disc_io *io);
  606. int
  607. efct_efc_bls_send(struct efc *efc, u32 type, struct sli_bls_params *bls);
  608. int
  609. efct_hw_bls_send(struct efct *efct, u32 type, struct sli_bls_params *bls_params,
  610. void *cb, void *arg);
  611. /* Function for retrieving link statistics */
  612. int
  613. efct_hw_get_link_stats(struct efct_hw *hw,
  614. u8 req_ext_counters,
  615. u8 clear_overflow_flags,
  616. u8 clear_all_counters,
  617. void (*efct_hw_link_stat_cb_t)(int status,
  618. u32 num_counters,
  619. struct efct_hw_link_stat_counts *counters, void *arg),
  620. void *arg);
  621. /* Function for retrieving host statistics */
  622. int
  623. efct_hw_get_host_stats(struct efct_hw *hw,
  624. u8 cc,
  625. void (*efct_hw_host_stat_cb_t)(int status,
  626. u32 num_counters,
  627. struct efct_hw_host_stat_counts *counters, void *arg),
  628. void *arg);
  629. int
  630. efct_hw_firmware_write(struct efct_hw *hw, struct efc_dma *dma,
  631. u32 size, u32 offset, int last,
  632. void (*cb)(int status, u32 bytes_written,
  633. u32 change_status, void *arg),
  634. void *arg);
  635. typedef void (*efct_hw_async_cb_t)(struct efct_hw *hw, int status,
  636. u8 *mqe, void *arg);
  637. int
  638. efct_hw_async_call(struct efct_hw *hw, efct_hw_async_cb_t callback, void *arg);
  639. struct hw_eq *efct_hw_new_eq(struct efct_hw *hw, u32 entry_count);
  640. struct hw_cq *efct_hw_new_cq(struct hw_eq *eq, u32 entry_count);
  641. u32
  642. efct_hw_new_cq_set(struct hw_eq *eqs[], struct hw_cq *cqs[],
  643. u32 num_cqs, u32 entry_count);
  644. struct hw_mq *efct_hw_new_mq(struct hw_cq *cq, u32 entry_count);
  645. struct hw_wq
  646. *efct_hw_new_wq(struct hw_cq *cq, u32 entry_count);
  647. u32
  648. efct_hw_new_rq_set(struct hw_cq *cqs[], struct hw_rq *rqs[],
  649. u32 num_rq_pairs, u32 entry_count);
  650. void efct_hw_del_eq(struct hw_eq *eq);
  651. void efct_hw_del_cq(struct hw_cq *cq);
  652. void efct_hw_del_mq(struct hw_mq *mq);
  653. void efct_hw_del_wq(struct hw_wq *wq);
  654. void efct_hw_del_rq(struct hw_rq *rq);
  655. void efct_hw_queue_teardown(struct efct_hw *hw);
  656. void efct_hw_teardown(struct efct_hw *hw);
  657. int
  658. efct_hw_reset(struct efct_hw *hw, enum efct_hw_reset reset);
  659. int
  660. efct_hw_port_control(struct efct_hw *hw, enum efct_hw_port ctrl,
  661. uintptr_t value,
  662. void (*cb)(int status, uintptr_t value, void *arg),
  663. void *arg);
  664. #endif /* __EFCT_H__ */