| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QLogic FCoE Offload Driver |
|---|
| 3 | 4 | * 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. |
|---|
| 8 | 5 | */ |
|---|
| 9 | 6 | #ifndef _QEDFC_H_ |
|---|
| 10 | 7 | #define _QEDFC_H_ |
|---|
| .. | .. |
|---|
| 35 | 32 | #define QEDF_DESCR "QLogic FCoE Offload Driver" |
|---|
| 36 | 33 | #define QEDF_MODULE_NAME "qedf" |
|---|
| 37 | 34 | |
|---|
| 38 | | -#define QEDF_MIN_XID 0 |
|---|
| 39 | | -#define QEDF_MAX_SCSI_XID (NUM_TASKS_PER_CONNECTION - 1) |
|---|
| 40 | | -#define QEDF_MAX_ELS_XID 4095 |
|---|
| 41 | 35 | #define QEDF_FLOGI_RETRY_CNT 3 |
|---|
| 42 | 36 | #define QEDF_RPORT_RETRY_CNT 255 |
|---|
| 43 | 37 | #define QEDF_MAX_SESSIONS 1024 |
|---|
| .. | .. |
|---|
| 52 | 46 | sizeof(struct fc_frame_header)) |
|---|
| 53 | 47 | #define QEDF_MAX_NPIV 64 |
|---|
| 54 | 48 | #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 |
|---|
| 57 | 51 | #define QEDF_MAX_CDB_LEN 16 |
|---|
| 52 | +#define QEDF_LL2_BUF_SIZE 2500 /* Buffer size required for LL2 Rx */ |
|---|
| 58 | 53 | |
|---|
| 59 | 54 | #define UPSTREAM_REMOVE 1 |
|---|
| 60 | 55 | #define UPSTREAM_KEEP 1 |
|---|
| .. | .. |
|---|
| 85 | 80 | }; |
|---|
| 86 | 81 | |
|---|
| 87 | 82 | enum qedf_ioreq_event { |
|---|
| 83 | + QEDF_IOREQ_EV_NONE, |
|---|
| 88 | 84 | QEDF_IOREQ_EV_ABORT_SUCCESS, |
|---|
| 89 | 85 | QEDF_IOREQ_EV_ABORT_FAILED, |
|---|
| 90 | 86 | QEDF_IOREQ_EV_SEND_RRQ, |
|---|
| .. | .. |
|---|
| 105 | 101 | struct list_head link; |
|---|
| 106 | 102 | uint16_t xid; |
|---|
| 107 | 103 | struct scsi_cmnd *sc_cmd; |
|---|
| 108 | | - bool use_slowpath; /* Use slow SGL for this I/O */ |
|---|
| 109 | 104 | #define QEDF_SCSI_CMD 1 |
|---|
| 110 | 105 | #define QEDF_TASK_MGMT_CMD 2 |
|---|
| 111 | 106 | #define QEDF_ABTS 3 |
|---|
| .. | .. |
|---|
| 117 | 112 | #define QEDF_CMD_IN_ABORT 0x1 |
|---|
| 118 | 113 | #define QEDF_CMD_IN_CLEANUP 0x2 |
|---|
| 119 | 114 | #define QEDF_CMD_SRR_SENT 0x3 |
|---|
| 115 | +#define QEDF_CMD_DIRTY 0x4 |
|---|
| 116 | +#define QEDF_CMD_ERR_SCSI_DONE 0x5 |
|---|
| 120 | 117 | u8 io_req_flags; |
|---|
| 121 | 118 | uint8_t tm_flags; |
|---|
| 122 | 119 | 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; |
|---|
| 123 | 134 | unsigned long flags; |
|---|
| 124 | 135 | enum qedf_ioreq_event event; |
|---|
| 125 | 136 | 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) */ |
|---|
| 126 | 140 | struct kref refcount; |
|---|
| 127 | 141 | struct qedf_cmd_mgr *cmd_mgr; |
|---|
| 128 | 142 | struct io_bdt *bd_tbl; |
|---|
| 129 | 143 | struct delayed_work timeout_work; |
|---|
| 130 | 144 | struct completion tm_done; |
|---|
| 131 | 145 | struct completion abts_done; |
|---|
| 146 | + struct completion cleanup_done; |
|---|
| 132 | 147 | struct e4_fcoe_task_context *task; |
|---|
| 133 | 148 | struct fcoe_task_params *task_params; |
|---|
| 134 | 149 | struct scsi_sgl_task_params *sgl_task_params; |
|---|
| 135 | 150 | int idx; |
|---|
| 151 | + int lun; |
|---|
| 136 | 152 | /* |
|---|
| 137 | 153 | * Need to allocate enough room for both sense data and FCP response data |
|---|
| 138 | 154 | * which has a max length of 8 bytes according to spec. |
|---|
| .. | .. |
|---|
| 155 | 171 | int fp_idx; |
|---|
| 156 | 172 | unsigned int cpu; |
|---|
| 157 | 173 | 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 |
|---|
| 161 | 177 | u8 sge_type; |
|---|
| 162 | 178 | struct delayed_work rrq_work; |
|---|
| 163 | 179 | |
|---|
| .. | .. |
|---|
| 172 | 188 | * during some form of error processing. |
|---|
| 173 | 189 | */ |
|---|
| 174 | 190 | bool return_scsi_cmd_on_abts; |
|---|
| 191 | + |
|---|
| 192 | + unsigned int alloc; |
|---|
| 175 | 193 | }; |
|---|
| 176 | 194 | |
|---|
| 177 | 195 | extern struct workqueue_struct *qedf_io_wq; |
|---|
| .. | .. |
|---|
| 181 | 199 | #define QEDF_RPORT_SESSION_READY 1 |
|---|
| 182 | 200 | #define QEDF_RPORT_UPLOADING_CONNECTION 2 |
|---|
| 183 | 201 | #define QEDF_RPORT_IN_RESET 3 |
|---|
| 202 | +#define QEDF_RPORT_IN_LUN_RESET 4 |
|---|
| 203 | +#define QEDF_RPORT_IN_TARGET_RESET 5 |
|---|
| 184 | 204 | unsigned long flags; |
|---|
| 205 | + int lun_reset_lun; |
|---|
| 185 | 206 | unsigned long retry_delay_timestamp; |
|---|
| 186 | 207 | struct fc_rport *rport; |
|---|
| 187 | 208 | struct fc_rport_priv *rdata; |
|---|
| .. | .. |
|---|
| 191 | 212 | void __iomem *p_doorbell; |
|---|
| 192 | 213 | /* Send queue management */ |
|---|
| 193 | 214 | atomic_t free_sqes; |
|---|
| 215 | + atomic_t ios_to_queue; |
|---|
| 194 | 216 | atomic_t num_active_ios; |
|---|
| 195 | 217 | struct fcoe_wqe *sq; |
|---|
| 196 | 218 | dma_addr_t sq_dma; |
|---|
| .. | .. |
|---|
| 295 | 317 | #define QEDF_DCBX_PENDING 0 |
|---|
| 296 | 318 | #define QEDF_DCBX_DONE 1 |
|---|
| 297 | 319 | atomic_t dcbx; |
|---|
| 298 | | - uint16_t max_scsi_xid; |
|---|
| 299 | | - uint16_t max_els_xid; |
|---|
| 300 | 320 | #define QEDF_NULL_VLAN_ID -1 |
|---|
| 301 | 321 | #define QEDF_FALLBACK_VLAN 1002 |
|---|
| 302 | 322 | #define QEDF_DEFAULT_PRIO 3 |
|---|
| .. | .. |
|---|
| 368 | 388 | #define QEDF_IO_WORK_MIN 64 |
|---|
| 369 | 389 | mempool_t *io_mempool; |
|---|
| 370 | 390 | struct workqueue_struct *dpc_wq; |
|---|
| 391 | + struct delayed_work recovery_work; |
|---|
| 392 | + struct delayed_work board_disable_work; |
|---|
| 371 | 393 | struct delayed_work grcdump_work; |
|---|
| 394 | + struct delayed_work stag_work; |
|---|
| 372 | 395 | |
|---|
| 373 | 396 | u32 slow_sge_ios; |
|---|
| 374 | 397 | u32 fast_sge_ios; |
|---|
| 375 | | - u32 single_sge_ios; |
|---|
| 376 | 398 | |
|---|
| 377 | 399 | uint8_t *grcdump; |
|---|
| 378 | 400 | uint32_t grcdump_size; |
|---|
| .. | .. |
|---|
| 385 | 407 | |
|---|
| 386 | 408 | u32 flogi_cnt; |
|---|
| 387 | 409 | u32 flogi_failed; |
|---|
| 410 | + u32 flogi_pending; |
|---|
| 388 | 411 | |
|---|
| 389 | 412 | /* Used for fc statistics */ |
|---|
| 390 | 413 | struct mutex stats_mutex; |
|---|
| .. | .. |
|---|
| 397 | 420 | u8 target_resets; |
|---|
| 398 | 421 | u8 task_set_fulls; |
|---|
| 399 | 422 | u8 busy; |
|---|
| 423 | + /* Used for flush routine */ |
|---|
| 424 | + struct mutex flush_mutex; |
|---|
| 400 | 425 | }; |
|---|
| 401 | 426 | |
|---|
| 402 | 427 | struct io_bdt { |
|---|
| .. | .. |
|---|
| 436 | 461 | /* |
|---|
| 437 | 462 | * Externs |
|---|
| 438 | 463 | */ |
|---|
| 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 | + */ |
|---|
| 439 | 470 | #define QEDF_DEFAULT_LOG_MASK 0x3CFB6 |
|---|
| 440 | 471 | extern const struct qed_fcoe_ops *qed_ops; |
|---|
| 441 | 472 | extern uint qedf_dump_frames; |
|---|
| 442 | 473 | extern uint qedf_io_tracing; |
|---|
| 443 | 474 | extern uint qedf_stop_io_on_error; |
|---|
| 444 | 475 | extern uint qedf_link_down_tmo; |
|---|
| 445 | | -#define QEDF_RETRY_DELAY_MAX 20 /* 2 seconds */ |
|---|
| 476 | +#define QEDF_RETRY_DELAY_MAX 600 /* 60 seconds */ |
|---|
| 446 | 477 | extern bool qedf_retry_delay; |
|---|
| 447 | 478 | extern uint qedf_debug; |
|---|
| 448 | 479 | |
|---|
| .. | .. |
|---|
| 495 | 526 | extern void qedf_create_sysfs_ctx_attr(struct qedf_ctx *qedf); |
|---|
| 496 | 527 | extern void qedf_remove_sysfs_ctx_attr(struct qedf_ctx *qedf); |
|---|
| 497 | 528 | 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); |
|---|
| 499 | 530 | extern void qedf_process_unsol_compl(struct qedf_ctx *qedf, uint16_t que_idx, |
|---|
| 500 | 531 | struct fcoe_cqe *cqe); |
|---|
| 501 | 532 | extern void qedf_restart_rport(struct qedf_rport *fcport); |
|---|
| .. | .. |
|---|
| 509 | 540 | extern void qedf_fp_io_handler(struct work_struct *work); |
|---|
| 510 | 541 | extern void qedf_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data); |
|---|
| 511 | 542 | 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); |
|---|
| 512 | 548 | |
|---|
| 513 | 549 | #define FCOE_WORD_TO_BYTE 4 |
|---|
| 514 | 550 | #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 |
|---|
| 515 | 556 | |
|---|
| 516 | 557 | struct fip_vlan { |
|---|
| 517 | 558 | struct ethhdr eth; |
|---|