175 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright (C) 2021 Broadcom. All Rights Reserved. The term4 * “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 4822#define SCSI_RSP_BUF_LENGTH (FCP_RESP_WITH_EXT + SCSI_SENSE_BUFFERSIZE)23#define EFCT_NUM_SCSI_IOS 819224 25enum 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 36enum 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 object47 * @efct: pointer back to efct48 * @instance_index: unique instance index value49 * @io: IO display name50 * @node: pointer to node51 * @list_entry: io list entry52 * @io_pending_link: io pending list entry53 * @ref: reference counter54 * @release: release callback function55 * @init_task_tag: initiator task tag (OX_ID) for back-end and SCSI logging56 * @tgt_task_tag: target task tag (RX_ID) for back-end and SCSI logging57 * @hw_tag: HW layer unique IO id58 * @tag: unique IO identifier59 * @sgl: SGL60 * @sgl_allocated: Number of allocated SGEs61 * @sgl_count: Number of SGEs in this SGL62 * @tgt_io: backend target private IO data63 * @exp_xfer_len: expected data transfer length, based on FC header64 * @hw_priv: Declarations private to HW/SLI65 * @io_type: indicates what this struct efct_io structure is used for66 * @hio: hw io object67 * @transferred: Number of bytes transferred68 * @auto_resp: set if auto_trsp was set69 * @low_latency: set if low latency request70 * @wq_steering: selected WQ steering request71 * @wq_class: selected WQ class if steering is class72 * @xfer_req: transfer size for current request73 * @scsi_tgt_cb: target callback function74 * @scsi_tgt_cb_arg: target callback function argument75 * @abort_cb: abort callback function76 * @abort_cb_arg: abort callback function argument77 * @bls_cb: BLS callback function78 * @bls_cb_arg: BLS callback function argument79 * @tmf_cmd: TMF command being processed80 * @abort_rx_id: rx_id from the ABTS that initiated the command abort81 * @cmd_tgt: True if this is a Target command82 * @send_abts: when aborting, indicates ABTS is to be sent83 * @cmd_ini: True if this is an Initiator command84 * @seq_init: True if local node has sequence initiative85 * @iparam: iparams for hw io send call86 * @hio_type: HW IO type87 * @wire_len: wire length88 * @hw_cb: saved HW callback89 * @io_to_abort: for abort handling, pointer to IO to abort90 * @rspbuf: SCSI Response buffer91 * @timeout: Timeout value in seconds for this IO92 * @cs_ctl: CS_CTL priority for this IO93 * @io_free: Is io object in freelist94 * @app_id: application id95 */96struct 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 154struct efct_io_cb_arg {155 int status;156 int ext_status;157 void *app;158};159 160struct efct_io_pool *161efct_io_pool_create(struct efct *efct, u32 num_sgl);162int163efct_io_pool_free(struct efct_io_pool *io_pool);164u32165efct_io_pool_allocated(struct efct_io_pool *io_pool);166 167struct efct_io *168efct_io_pool_io_alloc(struct efct_io_pool *io_pool);169void170efct_io_pool_io_free(struct efct_io_pool *io_pool, struct efct_io *io);171struct efct_io *172efct_io_find_tgt_io(struct efct *efct, struct efct_node *node,173 u16 ox_id, u16 rx_id);174#endif /* __EFCT_IO_H__ */175