forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/scsi/qedf/qedf.h
....@@ -1,10 +1,7 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * QLogic FCoE Offload Driver
34 * Copyright (c) 2016-2018 Cavium Inc.
4
- *
5
- * This software is available under the terms of the GNU General Public License
6
- * (GPL) Version 2, available from the file COPYING in the main directory of
7
- * this source tree.
85 */
96 #ifndef _QEDFC_H_
107 #define _QEDFC_H_
....@@ -35,9 +32,6 @@
3532 #define QEDF_DESCR "QLogic FCoE Offload Driver"
3633 #define QEDF_MODULE_NAME "qedf"
3734
38
-#define QEDF_MIN_XID 0
39
-#define QEDF_MAX_SCSI_XID (NUM_TASKS_PER_CONNECTION - 1)
40
-#define QEDF_MAX_ELS_XID 4095
4135 #define QEDF_FLOGI_RETRY_CNT 3
4236 #define QEDF_RPORT_RETRY_CNT 255
4337 #define QEDF_MAX_SESSIONS 1024
....@@ -52,9 +46,10 @@
5246 sizeof(struct fc_frame_header))
5347 #define QEDF_MAX_NPIV 64
5448 #define QEDF_TM_TIMEOUT 10
55
-#define QEDF_ABORT_TIMEOUT 10
56
-#define QEDF_CLEANUP_TIMEOUT 10
49
+#define QEDF_ABORT_TIMEOUT (10 * 1000)
50
+#define QEDF_CLEANUP_TIMEOUT 1
5751 #define QEDF_MAX_CDB_LEN 16
52
+#define QEDF_LL2_BUF_SIZE 2500 /* Buffer size required for LL2 Rx */
5853
5954 #define UPSTREAM_REMOVE 1
6055 #define UPSTREAM_KEEP 1
....@@ -85,6 +80,7 @@
8580 };
8681
8782 enum qedf_ioreq_event {
83
+ QEDF_IOREQ_EV_NONE,
8884 QEDF_IOREQ_EV_ABORT_SUCCESS,
8985 QEDF_IOREQ_EV_ABORT_FAILED,
9086 QEDF_IOREQ_EV_SEND_RRQ,
....@@ -105,7 +101,6 @@
105101 struct list_head link;
106102 uint16_t xid;
107103 struct scsi_cmnd *sc_cmd;
108
- bool use_slowpath; /* Use slow SGL for this I/O */
109104 #define QEDF_SCSI_CMD 1
110105 #define QEDF_TASK_MGMT_CMD 2
111106 #define QEDF_ABTS 3
....@@ -117,22 +112,43 @@
117112 #define QEDF_CMD_IN_ABORT 0x1
118113 #define QEDF_CMD_IN_CLEANUP 0x2
119114 #define QEDF_CMD_SRR_SENT 0x3
115
+#define QEDF_CMD_DIRTY 0x4
116
+#define QEDF_CMD_ERR_SCSI_DONE 0x5
120117 u8 io_req_flags;
121118 uint8_t tm_flags;
122119 struct qedf_rport *fcport;
120
+#define QEDF_CMD_ST_INACTIVE 0
121
+#define QEDFC_CMD_ST_IO_ACTIVE 1
122
+#define QEDFC_CMD_ST_ABORT_ACTIVE 2
123
+#define QEDFC_CMD_ST_ABORT_ACTIVE_EH 3
124
+#define QEDFC_CMD_ST_CLEANUP_ACTIVE 4
125
+#define QEDFC_CMD_ST_CLEANUP_ACTIVE_EH 5
126
+#define QEDFC_CMD_ST_RRQ_ACTIVE 6
127
+#define QEDFC_CMD_ST_RRQ_WAIT 7
128
+#define QEDFC_CMD_ST_OXID_RETIRE_WAIT 8
129
+#define QEDFC_CMD_ST_TMF_ACTIVE 9
130
+#define QEDFC_CMD_ST_DRAIN_ACTIVE 10
131
+#define QEDFC_CMD_ST_CLEANED 11
132
+#define QEDFC_CMD_ST_ELS_ACTIVE 12
133
+ atomic_t state;
123134 unsigned long flags;
124135 enum qedf_ioreq_event event;
125136 size_t data_xfer_len;
137
+ /* ID: 001: Alloc cmd (qedf_alloc_cmd) */
138
+ /* ID: 002: Initiate ABTS (qedf_initiate_abts) */
139
+ /* ID: 003: For RRQ (qedf_process_abts_compl) */
126140 struct kref refcount;
127141 struct qedf_cmd_mgr *cmd_mgr;
128142 struct io_bdt *bd_tbl;
129143 struct delayed_work timeout_work;
130144 struct completion tm_done;
131145 struct completion abts_done;
146
+ struct completion cleanup_done;
132147 struct e4_fcoe_task_context *task;
133148 struct fcoe_task_params *task_params;
134149 struct scsi_sgl_task_params *sgl_task_params;
135150 int idx;
151
+ int lun;
136152 /*
137153 * Need to allocate enough room for both sense data and FCP response data
138154 * which has a max length of 8 bytes according to spec.
....@@ -155,9 +171,9 @@
155171 int fp_idx;
156172 unsigned int cpu;
157173 unsigned int int_cpu;
158
-#define QEDF_IOREQ_SLOW_SGE 0
159
-#define QEDF_IOREQ_SINGLE_SGE 1
160
-#define QEDF_IOREQ_FAST_SGE 2
174
+#define QEDF_IOREQ_UNKNOWN_SGE 1
175
+#define QEDF_IOREQ_SLOW_SGE 2
176
+#define QEDF_IOREQ_FAST_SGE 3
161177 u8 sge_type;
162178 struct delayed_work rrq_work;
163179
....@@ -172,6 +188,8 @@
172188 * during some form of error processing.
173189 */
174190 bool return_scsi_cmd_on_abts;
191
+
192
+ unsigned int alloc;
175193 };
176194
177195 extern struct workqueue_struct *qedf_io_wq;
....@@ -181,7 +199,10 @@
181199 #define QEDF_RPORT_SESSION_READY 1
182200 #define QEDF_RPORT_UPLOADING_CONNECTION 2
183201 #define QEDF_RPORT_IN_RESET 3
202
+#define QEDF_RPORT_IN_LUN_RESET 4
203
+#define QEDF_RPORT_IN_TARGET_RESET 5
184204 unsigned long flags;
205
+ int lun_reset_lun;
185206 unsigned long retry_delay_timestamp;
186207 struct fc_rport *rport;
187208 struct fc_rport_priv *rdata;
....@@ -191,6 +212,7 @@
191212 void __iomem *p_doorbell;
192213 /* Send queue management */
193214 atomic_t free_sqes;
215
+ atomic_t ios_to_queue;
194216 atomic_t num_active_ios;
195217 struct fcoe_wqe *sq;
196218 dma_addr_t sq_dma;
....@@ -295,8 +317,6 @@
295317 #define QEDF_DCBX_PENDING 0
296318 #define QEDF_DCBX_DONE 1
297319 atomic_t dcbx;
298
- uint16_t max_scsi_xid;
299
- uint16_t max_els_xid;
300320 #define QEDF_NULL_VLAN_ID -1
301321 #define QEDF_FALLBACK_VLAN 1002
302322 #define QEDF_DEFAULT_PRIO 3
....@@ -368,11 +388,13 @@
368388 #define QEDF_IO_WORK_MIN 64
369389 mempool_t *io_mempool;
370390 struct workqueue_struct *dpc_wq;
391
+ struct delayed_work recovery_work;
392
+ struct delayed_work board_disable_work;
371393 struct delayed_work grcdump_work;
394
+ struct delayed_work stag_work;
372395
373396 u32 slow_sge_ios;
374397 u32 fast_sge_ios;
375
- u32 single_sge_ios;
376398
377399 uint8_t *grcdump;
378400 uint32_t grcdump_size;
....@@ -385,6 +407,7 @@
385407
386408 u32 flogi_cnt;
387409 u32 flogi_failed;
410
+ u32 flogi_pending;
388411
389412 /* Used for fc statistics */
390413 struct mutex stats_mutex;
....@@ -397,6 +420,8 @@
397420 u8 target_resets;
398421 u8 task_set_fulls;
399422 u8 busy;
423
+ /* Used for flush routine */
424
+ struct mutex flush_mutex;
400425 };
401426
402427 struct io_bdt {
....@@ -436,13 +461,19 @@
436461 /*
437462 * Externs
438463 */
464
+
465
+/*
466
+ * (QEDF_LOG_NPIV | QEDF_LOG_SESS | QEDF_LOG_LPORT | QEDF_LOG_ELS | QEDF_LOG_MQ
467
+ * | QEDF_LOG_IO | QEDF_LOG_UNSOL | QEDF_LOG_SCSI_TM | QEDF_LOG_MP_REQ |
468
+ * QEDF_LOG_EVT | QEDF_LOG_CONN | QEDF_LOG_DISC | QEDF_LOG_INFO)
469
+ */
439470 #define QEDF_DEFAULT_LOG_MASK 0x3CFB6
440471 extern const struct qed_fcoe_ops *qed_ops;
441472 extern uint qedf_dump_frames;
442473 extern uint qedf_io_tracing;
443474 extern uint qedf_stop_io_on_error;
444475 extern uint qedf_link_down_tmo;
445
-#define QEDF_RETRY_DELAY_MAX 20 /* 2 seconds */
476
+#define QEDF_RETRY_DELAY_MAX 600 /* 60 seconds */
446477 extern bool qedf_retry_delay;
447478 extern uint qedf_debug;
448479
....@@ -495,7 +526,7 @@
495526 extern void qedf_create_sysfs_ctx_attr(struct qedf_ctx *qedf);
496527 extern void qedf_remove_sysfs_ctx_attr(struct qedf_ctx *qedf);
497528 extern void qedf_capture_grc_dump(struct qedf_ctx *qedf);
498
-extern void qedf_wait_for_upload(struct qedf_ctx *qedf);
529
+bool qedf_wait_for_upload(struct qedf_ctx *qedf);
499530 extern void qedf_process_unsol_compl(struct qedf_ctx *qedf, uint16_t que_idx,
500531 struct fcoe_cqe *cqe);
501532 extern void qedf_restart_rport(struct qedf_rport *fcport);
....@@ -509,9 +540,19 @@
509540 extern void qedf_fp_io_handler(struct work_struct *work);
510541 extern void qedf_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data);
511542 extern void qedf_wq_grcdump(struct work_struct *work);
543
+void qedf_stag_change_work(struct work_struct *work);
544
+void qedf_ctx_soft_reset(struct fc_lport *lport);
545
+extern void qedf_board_disable_work(struct work_struct *work);
546
+extern void qedf_schedule_hw_err_handler(void *dev,
547
+ enum qed_hw_err_type err_type);
512548
513549 #define FCOE_WORD_TO_BYTE 4
514550 #define QEDF_MAX_TASK_NUM 0xFFFF
551
+#define QL45xxx 0x165C
552
+#define QL41xxx 0x8080
553
+#define MAX_CT_PAYLOAD 2048
554
+#define DISCOVERED_PORTS 4
555
+#define NUMBER_OF_PORTS 1
515556
516557 struct fip_vlan {
517558 struct ethhdr eth;