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 7 #if !defined(__EFCT_IO_H__) 8 #define __EFCT_IO_H__ 9 10 #include "efct_lio.h" 11 12 #define EFCT_LOG_ENABLE_IO_ERRORS(efct) \ 13 (((efct) != NULL) ? (((efct)->logmask & (1U << 6)) != 0) : 0) 14 15 #define io_error_log(io, fmt, ...) \ 16 do { \ 17 if (EFCT_LOG_ENABLE_IO_ERRORS(io->efct)) \ 18 efc_log_warn(io->efct, fmt, ##__VA_ARGS__); \ 19 } while (0) 20 21 #define SCSI_CMD_BUF_LENGTH 48 22 #define SCSI_RSP_BUF_LENGTH (FCP_RESP_WITH_EXT + SCSI_SENSE_BUFFERSIZE) 23 #define EFCT_NUM_SCSI_IOS 8192 24 25 enum efct_io_type { 26 EFCT_IO_TYPE_IO = 0, 27 EFCT_IO_TYPE_ELS, 28 EFCT_IO_TYPE_CT, 29 EFCT_IO_TYPE_CT_RESP, 30 EFCT_IO_TYPE_BLS_RESP, 31 EFCT_IO_TYPE_ABORT, 32 33 EFCT_IO_TYPE_MAX, 34 }; 35 36 enum efct_els_state { 37 EFCT_ELS_REQUEST = 0, 38 EFCT_ELS_REQUEST_DELAYED, 39 EFCT_ELS_REQUEST_DELAY_ABORT, 40 EFCT_ELS_REQ_ABORT, 41 EFCT_ELS_REQ_ABORTED, 42 EFCT_ELS_ABORT_IO_COMPL, 43 }; 44 45 /** 46 * Scsi target IO object 47 * @efct: pointer back to efct 48 * @instance_index: unique instance index value 49 * @io: IO display name 50 * @node: pointer to node 51 * @list_entry: io list entry 52 * @io_pending_link: io pending list entry 53 * @ref: reference counter 54 * @release: release callback function 55 * @init_task_tag: initiator task tag (OX_ID) for back-end and SCSI logging 56 * @tgt_task_tag: target task tag (RX_ID) for back-end and SCSI logging 57 * @hw_tag: HW layer unique IO id 58 * @tag: unique IO identifier 59 * @sgl: SGL 60 * @sgl_allocated: Number of allocated SGEs 61 * @sgl_count: Number of SGEs in this SGL 62 * @tgt_io: backend target private IO data 63 * @exp_xfer_len: expected data transfer length, based on FC header 64 * @hw_priv: Declarations private to HW/SLI 65 * @io_type: indicates what this struct efct_io structure is used for 66 * @hio: hw io object 67 * @transferred: Number of bytes transferred 68 * @auto_resp: set if auto_trsp was set 69 * @low_latency: set if low latency request 70 * @wq_steering: selected WQ steering request 71 * @wq_class: selected WQ class if steering is class 72 * @xfer_req: transfer size for current request 73 * @scsi_tgt_cb: target callback function 74 * @scsi_tgt_cb_arg: target callback function argument 75 * @abort_cb: abort callback function 76 * @abort_cb_arg: abort callback function argument 77 * @bls_cb: BLS callback function 78 * @bls_cb_arg: BLS callback function argument 79 * @tmf_cmd: TMF command being processed 80 * @abort_rx_id: rx_id from the ABTS that initiated the command abort 81 * @cmd_tgt: True if this is a Target command 82 * @send_abts: when aborting, indicates ABTS is to be sent 83 * @cmd_ini: True if this is an Initiator command 84 * @seq_init: True if local node has sequence initiative 85 * @iparam: iparams for hw io send call 86 * @hio_type: HW IO type 87 * @wire_len: wire length 88 * @hw_cb: saved HW callback 89 * @io_to_abort: for abort handling, pointer to IO to abort 90 * @rspbuf: SCSI Response buffer 91 * @timeout: Timeout value in seconds for this IO 92 * @cs_ctl: CS_CTL priority for this IO 93 * @io_free: Is io object in freelist 94 * @app_id: application id 95 */ 96 struct efct_io { 97 struct efct *efct; 98 u32 instance_index; 99 const char *display_name; 100 struct efct_node *node; 101 102 struct list_head list_entry; 103 struct list_head io_pending_link; 104 struct kref ref; 105 void (*release)(struct kref *arg); 106 u32 init_task_tag; 107 u32 tgt_task_tag; 108 u32 hw_tag; 109 u32 tag; 110 struct efct_scsi_sgl *sgl; 111 u32 sgl_allocated; 112 u32 sgl_count; 113 struct efct_scsi_tgt_io tgt_io; 114 u32 exp_xfer_len; 115 116 void *hw_priv; 117 118 enum efct_io_type io_type; 119 struct efct_hw_io *hio; 120 size_t transferred; 121 122 bool auto_resp; 123 bool low_latency; 124 u8 wq_steering; 125 u8 wq_class; 126 u64 xfer_req; 127 efct_scsi_io_cb_t scsi_tgt_cb; 128 void *scsi_tgt_cb_arg; 129 efct_scsi_io_cb_t abort_cb; 130 void *abort_cb_arg; 131 efct_scsi_io_cb_t bls_cb; 132 void *bls_cb_arg; 133 enum efct_scsi_tmf_cmd tmf_cmd; 134 u16 abort_rx_id; 135 136 bool cmd_tgt; 137 bool send_abts; 138 bool cmd_ini; 139 bool seq_init; 140 union efct_hw_io_param_u iparam; 141 enum efct_hw_io_type hio_type; 142 u64 wire_len; 143 void *hw_cb; 144 145 struct efct_io *io_to_abort; 146 147 struct efc_dma rspbuf; 148 u32 timeout; 149 u8 cs_ctl; 150 u8 io_free; 151 u32 app_id; 152 }; 153 154 struct efct_io_cb_arg { 155 int status; 156 int ext_status; 157 void *app; 158 }; 159 160 struct efct_io_pool * 161 efct_io_pool_create(struct efct *efct, u32 num_sgl); 162 int 163 efct_io_pool_free(struct efct_io_pool *io_pool); 164 u32 165 efct_io_pool_allocated(struct efct_io_pool *io_pool); 166 167 struct efct_io * 168 efct_io_pool_io_alloc(struct efct_io_pool *io_pool); 169 void 170 efct_io_pool_io_free(struct efct_io_pool *io_pool, struct efct_io *io); 171 struct efct_io * 172 efct_io_find_tgt_io(struct efct *efct, struct efct_node *node, 173 u16 ox_id, u16 rx_id); 174 #endif /* __EFCT_IO_H__ */ 175