This source file includes following definitions.
- csio_get_scsi_ioreq
- csio_put_scsi_ioreq
- csio_put_scsi_ioreq_list
- csio_get_scsi_ddp
- csio_put_scsi_ddp
- csio_put_scsi_ddp_list
- csio_scsi_completed
- csio_scsi_aborted
- csio_scsi_closed
- csio_scsi_drvcleanup
- csio_scsi_start_io
- csio_scsi_start_tm
- csio_scsi_abort
- csio_scsi_close
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 #ifndef __CSIO_SCSI_H__
36 #define __CSIO_SCSI_H__
37
38 #include <linux/spinlock_types.h>
39 #include <linux/completion.h>
40 #include <scsi/scsi.h>
41 #include <scsi/scsi_cmnd.h>
42 #include <scsi/scsi_device.h>
43 #include <scsi/scsi_host.h>
44 #include <scsi/scsi_eh.h>
45 #include <scsi/scsi_tcq.h>
46 #include <scsi/fc/fc_fcp.h>
47
48 #include "csio_defs.h"
49 #include "csio_wr.h"
50
51 extern struct scsi_host_template csio_fcoe_shost_template;
52 extern struct scsi_host_template csio_fcoe_shost_vport_template;
53
54 extern int csio_scsi_eqsize;
55 extern int csio_scsi_iqlen;
56 extern int csio_scsi_ioreqs;
57 extern uint32_t csio_max_scan_tmo;
58 extern uint32_t csio_delta_scan_tmo;
59 extern int csio_lun_qdepth;
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 #define CSIO_SCSI_MAX_SGE 35
80 #define CSIO_SCSI_ABRT_TMO_MS 60000
81 #define CSIO_SCSI_LUNRST_TMO_MS 60000
82 #define CSIO_SCSI_TM_POLL_MS 2000
83
84
85 #define CSIO_SCSI_IQ_WRSZ 128
86 #define CSIO_SCSI_IQSIZE (csio_scsi_iqlen * CSIO_SCSI_IQ_WRSZ)
87
88 #define CSIO_MAX_SNS_LEN 128
89 #define CSIO_SCSI_RSP_LEN (FCP_RESP_WITH_EXT + 4 + CSIO_MAX_SNS_LEN)
90
91
92 #define csio_scsi_cmnd(req) ((req)->scratch1)
93
94 struct csio_scsi_stats {
95 uint64_t n_tot_success;
96 uint32_t n_rn_nr_error;
97
98
99 uint32_t n_hw_nr_error;
100
101
102 uint32_t n_dmamap_error;
103 uint32_t n_unsupp_sge_error;
104
105
106 uint32_t n_no_req_error;
107 uint32_t n_busy_error;
108 uint32_t n_hosterror;
109 uint32_t n_rsperror;
110 uint32_t n_autosense;
111 uint32_t n_ovflerror;
112 uint32_t n_unflerror;
113 uint32_t n_rdev_nr_error;
114
115
116 uint32_t n_rdev_lost_error;
117 uint32_t n_rdev_logo_error;
118 uint32_t n_link_down_error;
119 uint32_t n_no_xchg_error;
120 uint32_t n_unknown_error;
121 uint32_t n_aborted;
122 uint32_t n_abrt_timedout;
123 uint32_t n_abrt_fail;
124 uint32_t n_abrt_dups;
125 uint32_t n_abrt_race_comp;
126
127
128 uint32_t n_abrt_busy_error;
129
130
131 uint32_t n_closed;
132 uint32_t n_cls_busy_error;
133
134
135 uint32_t n_active;
136 uint32_t n_tm_active;
137 uint32_t n_wcbfn;
138
139
140 uint32_t n_free_ioreq;
141 uint32_t n_free_ddp;
142 uint32_t n_unaligned;
143 uint32_t n_inval_cplop;
144 uint32_t n_inval_scsiop;
145 };
146
147 struct csio_scsim {
148 struct csio_hw *hw;
149 uint8_t max_sge;
150 uint8_t proto_cmd_len;
151
152
153 uint16_t proto_rsp_len;
154
155
156 spinlock_t freelist_lock;
157 struct list_head active_q;
158 struct list_head ioreq_freelist;
159 struct list_head ddp_freelist;
160 struct csio_scsi_stats stats;
161 };
162
163
164 enum csio_scsi_ev {
165 CSIO_SCSIE_START_IO = 1,
166 CSIO_SCSIE_START_TM,
167 CSIO_SCSIE_COMPLETED,
168 CSIO_SCSIE_ABORT,
169 CSIO_SCSIE_ABORTED,
170 CSIO_SCSIE_CLOSE,
171 CSIO_SCSIE_CLOSED,
172 CSIO_SCSIE_DRVCLEANUP,
173
174
175 };
176
177 enum csio_scsi_lev {
178 CSIO_LEV_ALL = 1,
179 CSIO_LEV_LNODE,
180 CSIO_LEV_RNODE,
181 CSIO_LEV_LUN,
182 };
183
184 struct csio_scsi_level_data {
185 enum csio_scsi_lev level;
186 struct csio_rnode *rnode;
187 struct csio_lnode *lnode;
188 uint64_t oslun;
189 };
190
191 static inline struct csio_ioreq *
192 csio_get_scsi_ioreq(struct csio_scsim *scm)
193 {
194 struct csio_sm *req;
195
196 if (likely(!list_empty(&scm->ioreq_freelist))) {
197 req = list_first_entry(&scm->ioreq_freelist,
198 struct csio_sm, sm_list);
199 list_del_init(&req->sm_list);
200 CSIO_DEC_STATS(scm, n_free_ioreq);
201 return (struct csio_ioreq *)req;
202 } else
203 return NULL;
204 }
205
206 static inline void
207 csio_put_scsi_ioreq(struct csio_scsim *scm, struct csio_ioreq *ioreq)
208 {
209 list_add_tail(&ioreq->sm.sm_list, &scm->ioreq_freelist);
210 CSIO_INC_STATS(scm, n_free_ioreq);
211 }
212
213 static inline void
214 csio_put_scsi_ioreq_list(struct csio_scsim *scm, struct list_head *reqlist,
215 int n)
216 {
217 list_splice_init(reqlist, &scm->ioreq_freelist);
218 scm->stats.n_free_ioreq += n;
219 }
220
221 static inline struct csio_dma_buf *
222 csio_get_scsi_ddp(struct csio_scsim *scm)
223 {
224 struct csio_dma_buf *ddp;
225
226 if (likely(!list_empty(&scm->ddp_freelist))) {
227 ddp = list_first_entry(&scm->ddp_freelist,
228 struct csio_dma_buf, list);
229 list_del_init(&ddp->list);
230 CSIO_DEC_STATS(scm, n_free_ddp);
231 return ddp;
232 } else
233 return NULL;
234 }
235
236 static inline void
237 csio_put_scsi_ddp(struct csio_scsim *scm, struct csio_dma_buf *ddp)
238 {
239 list_add_tail(&ddp->list, &scm->ddp_freelist);
240 CSIO_INC_STATS(scm, n_free_ddp);
241 }
242
243 static inline void
244 csio_put_scsi_ddp_list(struct csio_scsim *scm, struct list_head *reqlist,
245 int n)
246 {
247 list_splice_tail_init(reqlist, &scm->ddp_freelist);
248 scm->stats.n_free_ddp += n;
249 }
250
251 static inline void
252 csio_scsi_completed(struct csio_ioreq *ioreq, struct list_head *cbfn_q)
253 {
254 csio_post_event(&ioreq->sm, CSIO_SCSIE_COMPLETED);
255 if (csio_list_deleted(&ioreq->sm.sm_list))
256 list_add_tail(&ioreq->sm.sm_list, cbfn_q);
257 }
258
259 static inline void
260 csio_scsi_aborted(struct csio_ioreq *ioreq, struct list_head *cbfn_q)
261 {
262 csio_post_event(&ioreq->sm, CSIO_SCSIE_ABORTED);
263 list_add_tail(&ioreq->sm.sm_list, cbfn_q);
264 }
265
266 static inline void
267 csio_scsi_closed(struct csio_ioreq *ioreq, struct list_head *cbfn_q)
268 {
269 csio_post_event(&ioreq->sm, CSIO_SCSIE_CLOSED);
270 list_add_tail(&ioreq->sm.sm_list, cbfn_q);
271 }
272
273 static inline void
274 csio_scsi_drvcleanup(struct csio_ioreq *ioreq)
275 {
276 csio_post_event(&ioreq->sm, CSIO_SCSIE_DRVCLEANUP);
277 }
278
279
280
281
282
283
284
285 static inline int
286 csio_scsi_start_io(struct csio_ioreq *ioreq)
287 {
288 csio_post_event(&ioreq->sm, CSIO_SCSIE_START_IO);
289 return ioreq->drv_status;
290 }
291
292
293
294
295
296
297
298 static inline int
299 csio_scsi_start_tm(struct csio_ioreq *ioreq)
300 {
301 csio_post_event(&ioreq->sm, CSIO_SCSIE_START_TM);
302 return ioreq->drv_status;
303 }
304
305
306
307
308
309
310
311 static inline int
312 csio_scsi_abort(struct csio_ioreq *ioreq)
313 {
314 csio_post_event(&ioreq->sm, CSIO_SCSIE_ABORT);
315 return ioreq->drv_status;
316 }
317
318
319
320
321
322
323
324 static inline int
325 csio_scsi_close(struct csio_ioreq *ioreq)
326 {
327 csio_post_event(&ioreq->sm, CSIO_SCSIE_CLOSE);
328 return ioreq->drv_status;
329 }
330
331 void csio_scsi_cleanup_io_q(struct csio_scsim *, struct list_head *);
332 int csio_scsim_cleanup_io(struct csio_scsim *, bool abort);
333 int csio_scsim_cleanup_io_lnode(struct csio_scsim *,
334 struct csio_lnode *);
335 struct csio_ioreq *csio_scsi_cmpl_handler(struct csio_hw *, void *, uint32_t,
336 struct csio_fl_dma_buf *,
337 void *, uint8_t **);
338 int csio_scsi_qconfig(struct csio_hw *);
339 int csio_scsim_init(struct csio_scsim *, struct csio_hw *);
340 void csio_scsim_exit(struct csio_scsim *);
341
342 #endif