forked from ecdufcdrvr/bcmufctdrvr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathocs_io.h
197 lines (171 loc) · 7.67 KB
/
ocs_io.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* BSD LICENSE
*
* Copyright (c) 2011-2018 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* OCS linux driver IO declarations
*/
#if !defined(__OCS_IO_H__)
#define __OCS_IO_H__
#define io_error_log(io, fmt, ...) \
do { \
if (OCS_LOG_ENABLE_IO_ERRORS(io->ocs)) \
ocs_log_warn(io->ocs, fmt, ##__VA_ARGS__); \
} while (0)
/**
* @brief FCP IO context
*
* This structure is used for transport and backend IO requests and responses.
*/
#define SCSI_CMD_BUF_LENGTH 48
#define SCSI_RSP_BUF_LENGTH sizeof(fcp_rsp_iu_t)
/**
* @brief OCS IO types
*/
typedef enum {
OCS_IO_TYPE_IO = 0,
OCS_IO_TYPE_ELS,
OCS_IO_TYPE_CT,
OCS_IO_TYPE_CT_RESP,
OCS_IO_TYPE_BLS_RESP,
OCS_IO_TYPE_ABORT,
OCS_IO_TYPE_MAX, /**< must be last */
} ocs_io_type_e;
struct ocs_io_s {
ocs_t *ocs; /**< pointer back to ocs */
uint32_t instance_index; /**< unique instance index value */
const char *display_name; /**< display name */
ocs_node_t *node; /**< pointer to node */
ocs_list_link_t io_alloc_link; /**< (io_pool->io_free_list) free list link */
uint32_t init_task_tag; /**< initiator task tag (OX_ID) for back-end and SCSI logging */
uint32_t tgt_task_tag; /**< target task tag (RX_ID) - for back-end and SCSI logging */
uint32_t hw_tag; /**< HW layer unique IO id - for back-end and SCSI logging */
uint32_t tag; /**< unique IO identifier */
ocs_scsi_sgl_t *sgl; /**< SGL */
uint32_t sgl_allocated; /**< Number of allocated SGEs */
uint32_t sgl_count; /**< Number of SGEs in this SGL */
ocs_scsi_ini_io_t ini_io; /**< backend initiator private IO data */
ocs_scsi_tgt_io_t tgt_io; /**< backend target private IO data */
uint32_t exp_xfer_len; /**< expected data transfer length, based on FC or iSCSI header */
ocs_mgmt_functions_t *mgmt_functions;
/* Declarations private to HAL/SLI */
void *hal_priv; /**< HAL private context */
/* Declarations private to FC Transport */
ocs_io_type_e io_type; /**< indicates what this ocs_io_t structure is used for */
ocs_ref_t ref; /**< refcount object */
void *dslab_item; /**< pointer back to dslab allocation object */
ocs_hal_io_t *hio; /**< HAL IO context */
size_t transferred; /**< Number of bytes transfered so far */
uint32_t auto_resp:1, /**< set if auto_trsp was set */
low_latency:1, /**< set if low latency request */
wq_steering:4, /**< selected WQ steering request */
wq_class:4; /**< selected WQ class if steering is class */
uint32_t xfer_req; /**< transfer size for current request */
ocs_scsi_rsp_io_cb_t scsi_ini_cb; /**< initiator callback function */
void *scsi_ini_cb_arg; /**< initiator callback function argument */
ocs_scsi_io_cb_t scsi_tgt_cb; /**< target callback function */
void *scsi_tgt_cb_arg; /**< target callback function argument */
ocs_scsi_io_cb_t abort_cb; /**< abort callback function */
void *abort_cb_arg; /**< abort callback function argument */
ocs_scsi_io_cb_t bls_cb; /**< BLS callback function */
void *bls_cb_arg; /**< BLS callback function argument */
ocs_scsi_tmf_cmd_e tmf_cmd; /**< TMF command being processed */
uint16_t abort_rx_id; /**< rx_id from the ABTS that initiated the command abort */
uint32_t cmd_tgt:1, /**< True if this is a Target command */
send_abts:1, /**< when aborting, indicates ABTS is to be sent */
cmd_ini:1, /**< True if this is an Initiator command */
seq_init:1; /**< True if local node has sequence initiative */
ocs_hal_io_param_t iparam; /**< iparams for hal io send call */
ocs_hal_dif_info_t hal_dif; /**< HAL formatted DIF parameters */
ocs_scsi_dif_info_t scsi_dif_info; /**< DIF info saved for DIF error recovery */
ocs_hal_io_type_e hio_type; /**< HAL IO type */
uint32_t wire_len; /**< wire length */
void *hal_cb; /**< saved HAL callback */
ocs_list_link_t io_pending_link;/**< link list link pending */
ocs_dma_t ovfl_sgl; /**< Overflow SGL */
/* for ELS requests/responses */
uint32_t els_pend:1, /**< True if ELS is pending */
els_active:1; /**< True if ELS is active */
ocs_dma_t els_req; /**< ELS request payload buffer */
ocs_dma_t els_rsp; /**< ELS response payload buffer */
ocs_sm_ctx_t els_sm; /**< EIO IO state machine context */
uint32_t els_evtdepth; /**< current event posting nesting depth */
uint32_t els_req_free:1; /**< this els is to be free'd */
uint32_t els_retries_remaining; /*<< Retries remaining */
void (*els_callback)(ocs_node_t *node, ocs_node_cb_t *cbdata, void *cbarg);
void *els_callback_arg;
uint32_t els_timeout_sec; /**< timeout */
ocs_timer_t delay_timer; /**< delay timer */
/* for abort handling */
ocs_io_t *io_to_abort; /**< pointer to IO to abort */
ocs_list_link_t link; /**< linked list link */
ocs_dma_t cmdbuf; /**< SCSI Command buffer, used for CDB (initiator) */
ocs_dma_t rspbuf; /**< SCSI Response buffer (i+t) */
uint32_t timeout; /**< Timeout value in seconds for this IO */
uint8_t cs_ctl; /**< CS_CTL priority for this IO */
uint8_t io_free; /**< Is io object in freelist > */
};
/**
* @brief common IO callback argument
*
* Callback argument used as common I/O callback argument
*/
typedef struct {
int32_t status; /**< completion status */
int32_t ext_status; /**< extended completion status */
void *app; /**< application argument */
} ocs_io_cb_arg_t;
/**
* @brief Test if IO object is busy
*
* Return True if IO object is busy. Busy is defined as the IO object not being on
* the free list
*
* @param io Pointer to IO object
*
* @return returns True if IO is busy
*/
static inline int32_t
ocs_io_busy(ocs_io_t *io)
{
return !(io->io_free);
}
typedef struct ocs_io_pool_s ocs_io_pool_t;
extern ocs_io_pool_t *ocs_io_pool_create(ocs_t *ocs, uint32_t num_io, uint32_t num_sgl);
extern int32_t ocs_io_pool_free(ocs_io_pool_t *io_pool);
extern uint32_t ocs_io_pool_allocated(ocs_io_pool_t *io_pool);
extern ocs_io_t *ocs_io_pool_io_alloc(ocs_io_pool_t *io_pool);
extern void ocs_io_pool_io_free(ocs_io_pool_t *io_pool, ocs_io_t *io);
extern ocs_io_t *ocs_io_find_tgt_io(ocs_t *ocs, ocs_node_t *node, uint16_t ox_id, uint16_t rx_id);
extern void ocs_ddump_io(ocs_textbuf_t *textbuf, ocs_io_t *io);
#endif // __OCS_IO_H__
/* vim: set noexpandtab textwidth=120: */