qedf.h 17 KB

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