qedf.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * QLogic FCoE Offload Driver
  4. * Copyright (c) 2016-2018 Cavium Inc.
  5. */
  6. #ifndef _QEDFC_H_
  7. #define _QEDFC_H_
  8. #include <scsi/libfcoe.h>
  9. #include <scsi/libfc.h>
  10. #include <scsi/fc/fc_fip.h>
  11. #include <scsi/fc/fc_fc2.h>
  12. #include <scsi/scsi_tcq.h>
  13. /* qedf_hsi.h needs to before included any qed includes */
  14. #include "qedf_hsi.h"
  15. #include <linux/qed/qed_if.h>
  16. #include <linux/qed/qed_fcoe_if.h>
  17. #include <linux/qed/qed_ll2_if.h>
  18. #include "qedf_version.h"
  19. #include "qedf_dbg.h"
  20. #include "drv_fcoe_fw_funcs.h"
  21. /* Helpers to extract upper and lower 32-bits of pointer */
  22. #define U64_HI(val) ((u32)(((u64)(val)) >> 32))
  23. #define U64_LO(val) ((u32)(((u64)(val)) & 0xffffffff))
  24. #define QEDF_DESCR "QLogic FCoE Offload Driver"
  25. #define QEDF_MODULE_NAME "qedf"
  26. #define QEDF_FLOGI_RETRY_CNT 3
  27. #define QEDF_RPORT_RETRY_CNT 255
  28. #define QEDF_MAX_SESSIONS 1024
  29. #define QEDF_MAX_PAYLOAD 2048
  30. #define QEDF_MAX_BDS_PER_CMD 256
  31. #define QEDF_MAX_BD_LEN 0xffff
  32. #define QEDF_BD_SPLIT_SZ 0x1000
  33. #define QEDF_PAGE_SIZE 4096
  34. #define QED_HW_DMA_BOUNDARY 0xfff
  35. #define QEDF_MAX_SGLEN_FOR_CACHESGL ((1U << 16) - 1)
  36. #define QEDF_MFS (QEDF_MAX_PAYLOAD + \
  37. sizeof(struct fc_frame_header))
  38. #define QEDF_MAX_NPIV 64
  39. #define QEDF_TM_TIMEOUT 10
  40. #define QEDF_ABORT_TIMEOUT (10 * 1000)
  41. #define QEDF_CLEANUP_TIMEOUT 1
  42. #define QEDF_MAX_CDB_LEN 16
  43. #define QEDF_LL2_BUF_SIZE 2500 /* Buffer size required for LL2 Rx */
  44. #define UPSTREAM_REMOVE 1
  45. #define UPSTREAM_KEEP 1
  46. struct qedf_mp_req {
  47. uint32_t req_len;
  48. void *req_buf;
  49. dma_addr_t req_buf_dma;
  50. struct scsi_sge *mp_req_bd;
  51. dma_addr_t mp_req_bd_dma;
  52. struct fc_frame_header req_fc_hdr;
  53. uint32_t resp_len;
  54. void *resp_buf;
  55. dma_addr_t resp_buf_dma;
  56. struct scsi_sge *mp_resp_bd;
  57. dma_addr_t mp_resp_bd_dma;
  58. struct fc_frame_header resp_fc_hdr;
  59. };
  60. struct qedf_els_cb_arg {
  61. struct qedf_ioreq *aborted_io_req;
  62. struct qedf_ioreq *io_req;
  63. u8 op; /* Used to keep track of ELS op */
  64. uint16_t l2_oxid;
  65. u32 offset; /* Used for sequence cleanup */
  66. u8 r_ctl; /* Used for sequence cleanup */
  67. };
  68. enum qedf_ioreq_event {
  69. QEDF_IOREQ_EV_NONE,
  70. QEDF_IOREQ_EV_ABORT_SUCCESS,
  71. QEDF_IOREQ_EV_ABORT_FAILED,
  72. QEDF_IOREQ_EV_SEND_RRQ,
  73. QEDF_IOREQ_EV_ELS_TMO,
  74. QEDF_IOREQ_EV_ELS_ERR_DETECT,
  75. QEDF_IOREQ_EV_ELS_FLUSH,
  76. QEDF_IOREQ_EV_CLEANUP_SUCCESS,
  77. QEDF_IOREQ_EV_CLEANUP_FAILED,
  78. };
  79. #define FC_GOOD 0
  80. #define FCOE_FCP_RSP_FLAGS_FCP_RESID_OVER (0x1<<2)
  81. #define FCOE_FCP_RSP_FLAGS_FCP_RESID_UNDER (0x1<<3)
  82. #define FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID (0x1<<0)
  83. #define FCOE_FCP_RSP_FLAGS_FCP_SNS_LEN_VALID (0x1<<1)
  84. struct qedf_ioreq {
  85. struct list_head link;
  86. uint16_t xid;
  87. struct scsi_cmnd *sc_cmd;
  88. #define QEDF_SCSI_CMD 1
  89. #define QEDF_TASK_MGMT_CMD 2
  90. #define QEDF_ABTS 3
  91. #define QEDF_ELS 4
  92. #define QEDF_CLEANUP 5
  93. #define QEDF_SEQ_CLEANUP 6
  94. u8 cmd_type;
  95. #define QEDF_CMD_OUTSTANDING 0x0
  96. #define QEDF_CMD_IN_ABORT 0x1
  97. #define QEDF_CMD_IN_CLEANUP 0x2
  98. #define QEDF_CMD_SRR_SENT 0x3
  99. #define QEDF_CMD_DIRTY 0x4
  100. #define QEDF_CMD_ERR_SCSI_DONE 0x5
  101. u8 io_req_flags;
  102. uint8_t tm_flags;
  103. u64 tm_lun;
  104. struct qedf_rport *fcport;
  105. #define QEDF_CMD_ST_INACTIVE 0
  106. #define QEDFC_CMD_ST_IO_ACTIVE 1
  107. #define QEDFC_CMD_ST_ABORT_ACTIVE 2
  108. #define QEDFC_CMD_ST_ABORT_ACTIVE_EH 3
  109. #define QEDFC_CMD_ST_CLEANUP_ACTIVE 4
  110. #define QEDFC_CMD_ST_CLEANUP_ACTIVE_EH 5
  111. #define QEDFC_CMD_ST_RRQ_ACTIVE 6
  112. #define QEDFC_CMD_ST_RRQ_WAIT 7
  113. #define QEDFC_CMD_ST_OXID_RETIRE_WAIT 8
  114. #define QEDFC_CMD_ST_TMF_ACTIVE 9
  115. #define QEDFC_CMD_ST_DRAIN_ACTIVE 10
  116. #define QEDFC_CMD_ST_CLEANED 11
  117. #define QEDFC_CMD_ST_ELS_ACTIVE 12
  118. atomic_t state;
  119. unsigned long flags;
  120. enum qedf_ioreq_event event;
  121. size_t data_xfer_len;
  122. /* ID: 001: Alloc cmd (qedf_alloc_cmd) */
  123. /* ID: 002: Initiate ABTS (qedf_initiate_abts) */
  124. /* ID: 003: For RRQ (qedf_process_abts_compl) */
  125. struct kref refcount;
  126. struct qedf_cmd_mgr *cmd_mgr;
  127. struct io_bdt *bd_tbl;
  128. struct delayed_work timeout_work;
  129. struct completion tm_done;
  130. struct completion abts_done;
  131. struct completion cleanup_done;
  132. struct fcoe_task_context *task;
  133. struct fcoe_task_params *task_params;
  134. struct scsi_sgl_task_params *sgl_task_params;
  135. int idx;
  136. int lun;
  137. /*
  138. * Need to allocate enough room for both sense data and FCP response data
  139. * which has a max length of 8 bytes according to spec.
  140. */
  141. #define QEDF_SCSI_SENSE_BUFFERSIZE (SCSI_SENSE_BUFFERSIZE + 8)
  142. uint8_t *sense_buffer;
  143. dma_addr_t sense_buffer_dma;
  144. u32 fcp_resid;
  145. u32 fcp_rsp_len;
  146. u32 fcp_sns_len;
  147. u8 cdb_status;
  148. u8 fcp_status;
  149. u8 fcp_rsp_code;
  150. u8 scsi_comp_flags;
  151. #define QEDF_MAX_REUSE 0xfff
  152. u16 reuse_count;
  153. struct qedf_mp_req mp_req;
  154. void (*cb_func)(struct qedf_els_cb_arg *cb_arg);
  155. struct qedf_els_cb_arg *cb_arg;
  156. int fp_idx;
  157. unsigned int cpu;
  158. unsigned int int_cpu;
  159. #define QEDF_IOREQ_UNKNOWN_SGE 1
  160. #define QEDF_IOREQ_SLOW_SGE 2
  161. #define QEDF_IOREQ_FAST_SGE 3
  162. u8 sge_type;
  163. struct delayed_work rrq_work;
  164. /* Used for sequence level recovery; i.e. REC/SRR */
  165. uint32_t rx_buf_off;
  166. uint32_t tx_buf_off;
  167. uint32_t rx_id;
  168. uint32_t task_retry_identifier;
  169. /*
  170. * Used to tell if we need to return a SCSI command
  171. * during some form of error processing.
  172. */
  173. bool return_scsi_cmd_on_abts;
  174. unsigned int alloc;
  175. };
  176. struct qedf_cmd_priv {
  177. struct qedf_ioreq *io_req;
  178. };
  179. static inline struct qedf_cmd_priv *qedf_priv(struct scsi_cmnd *cmd)
  180. {
  181. return scsi_cmd_priv(cmd);
  182. }
  183. extern struct workqueue_struct *qedf_io_wq;
  184. struct qedf_rport {
  185. spinlock_t rport_lock;
  186. #define QEDF_RPORT_SESSION_READY 1
  187. #define QEDF_RPORT_UPLOADING_CONNECTION 2
  188. #define QEDF_RPORT_IN_RESET 3
  189. #define QEDF_RPORT_IN_LUN_RESET 4
  190. #define QEDF_RPORT_IN_TARGET_RESET 5
  191. unsigned long flags;
  192. int lun_reset_lun;
  193. unsigned long retry_delay_timestamp;
  194. struct fc_rport *rport;
  195. struct fc_rport_priv *rdata;
  196. struct qedf_ctx *qedf;
  197. u32 handle; /* Handle from qed */
  198. u32 fw_cid; /* fw_cid from qed */
  199. void __iomem *p_doorbell;
  200. /* Send queue management */
  201. atomic_t free_sqes;
  202. atomic_t ios_to_queue;
  203. atomic_t num_active_ios;
  204. struct fcoe_wqe *sq;
  205. dma_addr_t sq_dma;
  206. u16 sq_prod_idx;
  207. u16 fw_sq_prod_idx;
  208. u16 sq_con_idx;
  209. u32 sq_mem_size;
  210. void *sq_pbl;
  211. dma_addr_t sq_pbl_dma;
  212. u32 sq_pbl_size;
  213. u32 sid;
  214. #define QEDF_RPORT_TYPE_DISK 0
  215. #define QEDF_RPORT_TYPE_TAPE 1
  216. uint dev_type; /* Disk or tape */
  217. struct list_head peers;
  218. };
  219. /* Used to contain LL2 skb's in ll2_skb_list */
  220. struct qedf_skb_work {
  221. struct work_struct work;
  222. struct sk_buff *skb;
  223. struct qedf_ctx *qedf;
  224. };
  225. struct qedf_fastpath {
  226. #define QEDF_SB_ID_NULL 0xffff
  227. u16 sb_id;
  228. struct qed_sb_info *sb_info;
  229. struct qedf_ctx *qedf;
  230. /* Keep track of number of completions on this fastpath */
  231. unsigned long completions;
  232. uint32_t cq_num_entries;
  233. };
  234. /* Used to pass fastpath information needed to process CQEs */
  235. struct qedf_io_work {
  236. struct work_struct work;
  237. struct fcoe_cqe cqe;
  238. struct qedf_ctx *qedf;
  239. struct fc_frame *fp;
  240. };
  241. struct qedf_glbl_q_params {
  242. u64 hw_p_cq; /* Completion queue PBL */
  243. u64 hw_p_rq; /* Request queue PBL */
  244. u64 hw_p_cmdq; /* Command queue PBL */
  245. };
  246. struct global_queue {
  247. struct fcoe_cqe *cq;
  248. dma_addr_t cq_dma;
  249. u32 cq_mem_size;
  250. u32 cq_cons_idx; /* Completion queue consumer index */
  251. u32 cq_prod_idx;
  252. void *cq_pbl;
  253. dma_addr_t cq_pbl_dma;
  254. u32 cq_pbl_size;
  255. };
  256. /* I/O tracing entry */
  257. #define QEDF_IO_TRACE_SIZE 2048
  258. struct qedf_io_log {
  259. #define QEDF_IO_TRACE_REQ 0
  260. #define QEDF_IO_TRACE_RSP 1
  261. uint8_t direction;
  262. uint16_t task_id;
  263. uint32_t port_id; /* Remote port fabric ID */
  264. int lun;
  265. unsigned char op; /* SCSI CDB */
  266. uint8_t lba[4];
  267. unsigned int bufflen; /* SCSI buffer length */
  268. unsigned int sg_count; /* Number of SG elements */
  269. int result; /* Result passed back to mid-layer */
  270. unsigned long jiffies; /* Time stamp when I/O logged */
  271. int refcount; /* Reference count for task id */
  272. unsigned int req_cpu; /* CPU that the task is queued on */
  273. unsigned int int_cpu; /* Interrupt CPU that the task is received on */
  274. unsigned int rsp_cpu; /* CPU that task is returned on */
  275. u8 sge_type; /* Did we take the slow, single or fast SGE path */
  276. };
  277. /* Number of entries in BDQ */
  278. #define QEDF_BDQ_SIZE 256
  279. #define QEDF_BDQ_BUF_SIZE 2072
  280. /* DMA coherent buffers for BDQ */
  281. struct qedf_bdq_buf {
  282. void *buf_addr;
  283. dma_addr_t buf_dma;
  284. };
  285. /* Main adapter struct */
  286. struct qedf_ctx {
  287. struct qedf_dbg_ctx dbg_ctx;
  288. struct fcoe_ctlr ctlr;
  289. struct fc_lport *lport;
  290. u8 data_src_addr[ETH_ALEN];
  291. #define QEDF_LINK_DOWN 0
  292. #define QEDF_LINK_UP 1
  293. atomic_t link_state;
  294. #define QEDF_DCBX_PENDING 0
  295. #define QEDF_DCBX_DONE 1
  296. atomic_t dcbx;
  297. #define QEDF_NULL_VLAN_ID -1
  298. #define QEDF_FALLBACK_VLAN 1002
  299. #define QEDF_DEFAULT_PRIO 3
  300. int vlan_id;
  301. u8 prio;
  302. struct qed_dev *cdev;
  303. struct qed_dev_fcoe_info dev_info;
  304. struct qed_int_info int_info;
  305. uint16_t last_command;
  306. spinlock_t hba_lock;
  307. struct pci_dev *pdev;
  308. u64 wwnn;
  309. u64 wwpn;
  310. u8 __aligned(16) mac[ETH_ALEN];
  311. struct list_head fcports;
  312. atomic_t num_offloads;
  313. unsigned int curr_conn_id;
  314. struct workqueue_struct *ll2_recv_wq;
  315. struct workqueue_struct *link_update_wq;
  316. struct devlink *devlink;
  317. struct delayed_work link_update;
  318. struct delayed_work link_recovery;
  319. struct completion flogi_compl;
  320. struct completion fipvlan_compl;
  321. /*
  322. * Used to tell if we're in the window where we are waiting for
  323. * the link to come back up before informting fcoe that the link is
  324. * done.
  325. */
  326. atomic_t link_down_tmo_valid;
  327. #define QEDF_TIMER_INTERVAL (1 * HZ)
  328. struct timer_list timer; /* One second book keeping timer */
  329. #define QEDF_DRAIN_ACTIVE 1
  330. #define QEDF_LL2_STARTED 2
  331. #define QEDF_UNLOADING 3
  332. #define QEDF_GRCDUMP_CAPTURE 4
  333. #define QEDF_IN_RECOVERY 5
  334. #define QEDF_DBG_STOP_IO 6
  335. #define QEDF_PROBING 8
  336. #define QEDF_STAG_IN_PROGRESS 9
  337. unsigned long flags; /* Miscellaneous state flags */
  338. int fipvlan_retries;
  339. u8 num_queues;
  340. struct global_queue **global_queues;
  341. /* Pointer to array of queue structures */
  342. struct qedf_glbl_q_params *p_cpuq;
  343. /* Physical address of array of queue structures */
  344. dma_addr_t hw_p_cpuq;
  345. struct qedf_bdq_buf bdq[QEDF_BDQ_SIZE];
  346. void *bdq_pbl;
  347. dma_addr_t bdq_pbl_dma;
  348. size_t bdq_pbl_mem_size;
  349. void *bdq_pbl_list;
  350. dma_addr_t bdq_pbl_list_dma;
  351. u8 bdq_pbl_list_num_entries;
  352. void __iomem *bdq_primary_prod;
  353. void __iomem *bdq_secondary_prod;
  354. uint16_t bdq_prod_idx;
  355. /* Structure for holding all the fastpath for this qedf_ctx */
  356. struct qedf_fastpath *fp_array;
  357. struct qed_fcoe_tid tasks;
  358. struct qedf_cmd_mgr *cmd_mgr;
  359. /* Holds the PF parameters we pass to qed to start he FCoE function */
  360. struct qed_pf_params pf_params;
  361. /* Used to time middle path ELS and TM commands */
  362. struct workqueue_struct *timer_work_queue;
  363. #define QEDF_IO_WORK_MIN 64
  364. mempool_t *io_mempool;
  365. struct workqueue_struct *dpc_wq;
  366. struct delayed_work recovery_work;
  367. struct delayed_work board_disable_work;
  368. struct delayed_work grcdump_work;
  369. struct delayed_work stag_work;
  370. u32 slow_sge_ios;
  371. u32 fast_sge_ios;
  372. uint8_t *grcdump;
  373. uint32_t grcdump_size;
  374. struct qedf_io_log io_trace_buf[QEDF_IO_TRACE_SIZE];
  375. spinlock_t io_trace_lock;
  376. uint16_t io_trace_idx;
  377. bool stop_io_on_error;
  378. u32 flogi_cnt;
  379. u32 flogi_failed;
  380. u32 flogi_pending;
  381. /* Used for fc statistics */
  382. struct mutex stats_mutex;
  383. u64 input_requests;
  384. u64 output_requests;
  385. u64 control_requests;
  386. u64 packet_aborts;
  387. u64 alloc_failures;
  388. u8 lun_resets;
  389. u8 target_resets;
  390. u8 task_set_fulls;
  391. u8 busy;
  392. /* Used for flush routine */
  393. struct mutex flush_mutex;
  394. };
  395. struct io_bdt {
  396. struct qedf_ioreq *io_req;
  397. struct scsi_sge *bd_tbl;
  398. dma_addr_t bd_tbl_dma;
  399. u16 bd_valid;
  400. };
  401. struct qedf_cmd_mgr {
  402. struct qedf_ctx *qedf;
  403. u16 idx;
  404. struct io_bdt **io_bdt_pool;
  405. #define FCOE_PARAMS_NUM_TASKS 2048
  406. struct qedf_ioreq cmds[FCOE_PARAMS_NUM_TASKS];
  407. spinlock_t lock;
  408. atomic_t free_list_cnt;
  409. };
  410. /* Stolen from qed_cxt_api.h and adapted for qed_fcoe_info
  411. * Usage:
  412. *
  413. * void *ptr;
  414. * ptr = qedf_get_task_mem(&qedf->tasks, 128);
  415. */
  416. static inline void *qedf_get_task_mem(struct qed_fcoe_tid *info, u32 tid)
  417. {
  418. return (void *)(info->blocks[tid / info->num_tids_per_block] +
  419. (tid % info->num_tids_per_block) * info->size);
  420. }
  421. static inline void qedf_stop_all_io(struct qedf_ctx *qedf)
  422. {
  423. set_bit(QEDF_DBG_STOP_IO, &qedf->flags);
  424. }
  425. /*
  426. * Externs
  427. */
  428. /*
  429. * (QEDF_LOG_NPIV | QEDF_LOG_SESS | QEDF_LOG_LPORT | QEDF_LOG_ELS | QEDF_LOG_MQ
  430. * | QEDF_LOG_IO | QEDF_LOG_UNSOL | QEDF_LOG_SCSI_TM | QEDF_LOG_MP_REQ |
  431. * QEDF_LOG_EVT | QEDF_LOG_CONN | QEDF_LOG_DISC | QEDF_LOG_INFO)
  432. */
  433. #define QEDF_DEFAULT_LOG_MASK 0x3CFB6
  434. extern const struct qed_fcoe_ops *qed_ops;
  435. extern uint qedf_dump_frames;
  436. extern uint qedf_io_tracing;
  437. extern uint qedf_stop_io_on_error;
  438. extern uint qedf_link_down_tmo;
  439. #define QEDF_RETRY_DELAY_MAX 600 /* 60 seconds */
  440. extern bool qedf_retry_delay;
  441. extern uint qedf_debug;
  442. extern struct qedf_cmd_mgr *qedf_cmd_mgr_alloc(struct qedf_ctx *qedf);
  443. extern void qedf_cmd_mgr_free(struct qedf_cmd_mgr *cmgr);
  444. extern int qedf_queuecommand(struct Scsi_Host *host,
  445. struct scsi_cmnd *sc_cmd);
  446. extern void qedf_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb);
  447. extern u8 *qedf_get_src_mac(struct fc_lport *lport);
  448. extern void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb);
  449. extern void qedf_fcoe_send_vlan_req(struct qedf_ctx *qedf);
  450. extern void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
  451. struct qedf_ioreq *io_req);
  452. extern void qedf_process_warning_compl(struct qedf_ctx *qedf,
  453. struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
  454. extern void qedf_process_error_detect(struct qedf_ctx *qedf,
  455. struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
  456. extern void qedf_flush_active_ios(struct qedf_rport *fcport, u64 lun);
  457. extern void qedf_release_cmd(struct kref *ref);
  458. extern int qedf_initiate_abts(struct qedf_ioreq *io_req,
  459. bool return_scsi_cmd_on_abts);
  460. extern void qedf_process_abts_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
  461. struct qedf_ioreq *io_req);
  462. extern struct qedf_ioreq *qedf_alloc_cmd(struct qedf_rport *fcport,
  463. u8 cmd_type);
  464. extern const struct attribute_group *qedf_host_groups[];
  465. extern void qedf_cmd_timer_set(struct qedf_ctx *qedf, struct qedf_ioreq *io_req,
  466. unsigned int timer_msec);
  467. extern int qedf_init_mp_req(struct qedf_ioreq *io_req);
  468. extern void qedf_init_mp_task(struct qedf_ioreq *io_req,
  469. struct fcoe_task_context *task_ctx, struct fcoe_wqe *sqe);
  470. extern u16 qedf_get_sqe_idx(struct qedf_rport *fcport);
  471. extern void qedf_ring_doorbell(struct qedf_rport *fcport);
  472. extern void qedf_process_els_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
  473. struct qedf_ioreq *els_req);
  474. extern int qedf_send_rrq(struct qedf_ioreq *aborted_io_req);
  475. extern int qedf_send_adisc(struct qedf_rport *fcport, struct fc_frame *fp);
  476. extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req,
  477. bool return_scsi_cmd_on_abts);
  478. extern void qedf_process_cleanup_compl(struct qedf_ctx *qedf,
  479. struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
  480. extern int qedf_initiate_tmf(struct fc_rport *rport, u64 lun, u8 tm_flags);
  481. extern void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
  482. struct qedf_ioreq *io_req);
  483. extern void qedf_process_cqe(struct qedf_ctx *qedf, struct fcoe_cqe *cqe);
  484. extern void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req,
  485. int result);
  486. extern void qedf_set_vlan_id(struct qedf_ctx *qedf, int vlan_id);
  487. extern void qedf_create_sysfs_ctx_attr(struct qedf_ctx *qedf);
  488. extern void qedf_remove_sysfs_ctx_attr(struct qedf_ctx *qedf);
  489. extern void qedf_capture_grc_dump(struct qedf_ctx *qedf);
  490. bool qedf_wait_for_upload(struct qedf_ctx *qedf);
  491. extern void qedf_process_unsol_compl(struct qedf_ctx *qedf, uint16_t que_idx,
  492. struct fcoe_cqe *cqe);
  493. extern void qedf_restart_rport(struct qedf_rport *fcport);
  494. extern int qedf_send_rec(struct qedf_ioreq *orig_io_req);
  495. extern int qedf_post_io_req(struct qedf_rport *fcport,
  496. struct qedf_ioreq *io_req);
  497. extern void qedf_process_seq_cleanup_compl(struct qedf_ctx *qedf,
  498. struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
  499. extern int qedf_send_flogi(struct qedf_ctx *qedf);
  500. extern void qedf_get_protocol_tlv_data(void *dev, void *data);
  501. extern void qedf_fp_io_handler(struct work_struct *work);
  502. extern void qedf_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data);
  503. extern void qedf_wq_grcdump(struct work_struct *work);
  504. void qedf_stag_change_work(struct work_struct *work);
  505. void qedf_ctx_soft_reset(struct fc_lport *lport);
  506. extern void qedf_schedule_hw_err_handler(void *dev,
  507. enum qed_hw_err_type err_type);
  508. #define FCOE_WORD_TO_BYTE 4
  509. #define QEDF_MAX_TASK_NUM 0xFFFF
  510. #define QL45xxx 0x165C
  511. #define QL41xxx 0x8080
  512. #define MAX_CT_PAYLOAD 2048
  513. #define DISCOVERED_PORTS 4
  514. #define NUMBER_OF_PORTS 1
  515. struct fip_vlan {
  516. struct ethhdr eth;
  517. struct fip_header fip;
  518. struct {
  519. struct fip_mac_desc mac;
  520. struct fip_wwn_desc wwnn;
  521. } desc;
  522. };
  523. /* SQ/CQ Sizes */
  524. #define GBL_RSVD_TASKS 16
  525. #define NUM_TASKS_PER_CONNECTION 1024
  526. #define NUM_RW_TASKS_PER_CONNECTION 512
  527. #define FCOE_PARAMS_CQ_NUM_ENTRIES FCOE_PARAMS_NUM_TASKS
  528. #define FCOE_PARAMS_CMDQ_NUM_ENTRIES FCOE_PARAMS_NUM_TASKS
  529. #define SQ_NUM_ENTRIES NUM_TASKS_PER_CONNECTION
  530. #define QEDF_FCOE_PARAMS_GL_RQ_PI 0
  531. #define QEDF_FCOE_PARAMS_GL_CMD_PI 1
  532. #define QEDF_READ (1 << 1)
  533. #define QEDF_WRITE (1 << 0)
  534. #define MAX_FIBRE_LUNS 0xffffffff
  535. #define MIN_NUM_CPUS_MSIX(x) min_t(u32, x->dev_info.num_cqs, \
  536. num_online_cpus())
  537. /*
  538. * PCI function probe defines
  539. */
  540. /* Probe/remove called during normal PCI probe */
  541. #define QEDF_MODE_NORMAL 0
  542. /* Probe/remove called from qed error recovery */
  543. #define QEDF_MODE_RECOVERY 1
  544. #define SUPPORTED_25000baseKR_Full (1<<27)
  545. #define SUPPORTED_50000baseKR2_Full (1<<28)
  546. #define SUPPORTED_100000baseKR4_Full (1<<29)
  547. #define SUPPORTED_100000baseCR4_Full (1<<30)
  548. #endif