isp_tpublic.h revision 1.13.4.1 1 1.13.4.1 yamt /* $NetBSD: isp_tpublic.h,v 1.13.4.1 2007/09/03 14:34:49 yamt Exp $ */
2 1.4 mjacob /*
3 1.13.4.1 yamt * Copyright (c) 1997-2006 by Matthew Jacob
4 1.1 mjacob * All rights reserved.
5 1.1 mjacob *
6 1.1 mjacob * Redistribution and use in source and binary forms, with or without
7 1.1 mjacob * modification, are permitted provided that the following conditions
8 1.1 mjacob * are met:
9 1.13.4.1 yamt *
10 1.1 mjacob * 1. Redistributions of source code must retain the above copyright
11 1.13.4.1 yamt * notice, this list of conditions and the following disclaimer.
12 1.13.4.1 yamt * 2. Redistributions in binary form must reproduce the above copyright
13 1.13.4.1 yamt * notice, this list of conditions and the following disclaimer in the
14 1.13.4.1 yamt * documentation and/or other materials provided with the distribution.
15 1.13.4.1 yamt *
16 1.13.4.1 yamt * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1 mjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 mjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.13.4.1 yamt * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.13.4.1 yamt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 mjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 mjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 mjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 mjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 mjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 mjacob * SUCH DAMAGE.
27 1.1 mjacob */
28 1.13.4.1 yamt /*
29 1.13.4.1 yamt * Host Adapter Public Target Interface Structures && Routines
30 1.13.4.1 yamt */
31 1.13.4.1 yamt
32 1.13.4.1 yamt #ifndef _ISP_TPUBLIC_H
33 1.13.4.1 yamt #define _ISP_TPUBLIC_H 1
34 1.1 mjacob
35 1.1 mjacob /*
36 1.13.4.1 yamt * Action codes set by the MD target driver for
37 1.13.4.1 yamt * the external layer to figure out what to do with.
38 1.1 mjacob */
39 1.13.4.1 yamt typedef enum {
40 1.13.4.1 yamt QOUT_HBA_REG=0, /* the argument is a pointer to a hba_register_t */
41 1.13.4.1 yamt QOUT_ENABLE, /* the argument is a pointer to a enadis_t */
42 1.13.4.1 yamt QOUT_DISABLE, /* the argument is a pointer to a enadis_t */
43 1.13.4.1 yamt QOUT_TMD_START, /* the argument is a pointer to a tmd_cmd_t */
44 1.13.4.1 yamt QOUT_TMD_DONE, /* the argument is a pointer to a tmd_cmd_t */
45 1.13.4.1 yamt QOUT_NOTIFY, /* the argument is a pointer to a tmd_notify_t */
46 1.13.4.1 yamt QOUT_HBA_UNREG /* the argument is a pointer to a hba_register_t */
47 1.13.4.1 yamt } tact_e;
48 1.1 mjacob
49 1.13.4.1 yamt /*
50 1.13.4.1 yamt * Action codes set by the external layer for the
51 1.13.4.1 yamt * MD driver to figure out what to do with.
52 1.13.4.1 yamt */
53 1.13.4.1 yamt typedef enum {
54 1.13.4.1 yamt QIN_HBA_REG=99, /* the argument is a pointer to a hba_register_t */
55 1.13.4.1 yamt QIN_GETINFO, /* the argument is a pointer to a info_t */
56 1.13.4.1 yamt QIN_SETINFO, /* the argument is a pointer to a info_t */
57 1.13.4.1 yamt QIN_GETDLIST, /* the argument is a pointer to a fc_dlist_t */
58 1.13.4.1 yamt QIN_ENABLE, /* the argument is a pointer to a enadis_t */
59 1.13.4.1 yamt QIN_DISABLE, /* the argument is a pointer to a enadis_t */
60 1.13.4.1 yamt QIN_TMD_CONT, /* the argument is a pointer to a tmd_cmd_t */
61 1.13.4.1 yamt QIN_TMD_FIN, /* the argument is a pointer to a tmd_cmd_t */
62 1.13.4.1 yamt QIN_NOTIFY_ACK, /* the argument is a pointer to a tmd_notify_t */
63 1.13.4.1 yamt QIN_HBA_UNREG, /* the argument is a pointer to a hba_register_t */
64 1.13.4.1 yamt } qact_e;
65 1.13.4.1 yamt
66 1.13.4.1 yamt /*
67 1.13.4.1 yamt * This structure is used to register to other software modules the
68 1.13.4.1 yamt * binding of an HBA identifier, driver name and instance and the
69 1.13.4.1 yamt * lun width capapbilities of this target driver. It's up to each
70 1.13.4.1 yamt * platform to figure out how it wants to do this, but a typical
71 1.13.4.1 yamt * sequence would be for the MD layer to find some external module's
72 1.13.4.1 yamt * entry point and start by sending a QOUT_HBA_REG with info filled
73 1.13.4.1 yamt * in, and the external module to call back with a QIN_HBA_REG that
74 1.13.4.1 yamt * passes back the corresponding information.
75 1.13.4.1 yamt */
76 1.13.4.1 yamt #define QR_VERSION 16
77 1.13.4.1 yamt typedef struct {
78 1.13.4.1 yamt /* NB: tags from here to r_version must never change */
79 1.13.4.1 yamt void * r_identity;
80 1.13.4.1 yamt void (*r_action)(qact_e, void *);
81 1.13.4.1 yamt char r_name[8];
82 1.13.4.1 yamt int r_inst;
83 1.13.4.1 yamt int r_version;
84 1.13.4.1 yamt uint32_t r_locator;
85 1.13.4.1 yamt uint32_t r_nchannels;
86 1.13.4.1 yamt enum { R_FC, R_SPI } r_type;
87 1.13.4.1 yamt void * r_private;
88 1.13.4.1 yamt } hba_register_t;
89 1.13.4.1 yamt
90 1.13.4.1 yamt /*
91 1.13.4.1 yamt * An information structure that is used to get or set per-channel transport layer parameters.
92 1.13.4.1 yamt */
93 1.13.4.1 yamt typedef struct {
94 1.13.4.1 yamt void * i_identity;
95 1.13.4.1 yamt enum { I_FC, I_SPI } i_type;
96 1.13.4.1 yamt int i_channel;
97 1.13.4.1 yamt int i_error;
98 1.13.4.1 yamt union {
99 1.13.4.1 yamt struct {
100 1.13.4.1 yamt uint64_t wwnn_nvram;
101 1.13.4.1 yamt uint64_t wwpn_nvram;
102 1.13.4.1 yamt uint64_t wwnn;
103 1.13.4.1 yamt uint64_t wwpn;
104 1.13.4.1 yamt } fc;
105 1.13.4.1 yamt struct {
106 1.13.4.1 yamt int iid;
107 1.13.4.1 yamt } spi;
108 1.13.4.1 yamt } i_id;
109 1.13.4.1 yamt } info_t;
110 1.13.4.1 yamt
111 1.13.4.1 yamt /*
112 1.13.4.1 yamt * An information structure to return a list of logged in WWPNs. FC specific.
113 1.13.4.1 yamt */
114 1.1 mjacob typedef struct {
115 1.13.4.1 yamt void * d_identity;
116 1.13.4.1 yamt int d_channel;
117 1.13.4.1 yamt int d_error;
118 1.13.4.1 yamt int d_count;
119 1.13.4.1 yamt uint64_t * d_wwpns;
120 1.13.4.1 yamt } fc_dlist_t;
121 1.13.4.1 yamt /*
122 1.13.4.1 yamt * Notify structure
123 1.13.4.1 yamt */
124 1.13.4.1 yamt typedef enum {
125 1.13.4.1 yamt NT_ABORT_TASK=0x1000,
126 1.13.4.1 yamt NT_ABORT_TASK_SET,
127 1.13.4.1 yamt NT_CLEAR_ACA,
128 1.13.4.1 yamt NT_CLEAR_TASK_SET,
129 1.13.4.1 yamt NT_LUN_RESET,
130 1.13.4.1 yamt NT_TARGET_RESET,
131 1.13.4.1 yamt NT_BUS_RESET,
132 1.13.4.1 yamt NT_LIP_RESET,
133 1.13.4.1 yamt NT_LINK_UP,
134 1.13.4.1 yamt NT_LINK_DOWN,
135 1.13.4.1 yamt NT_LOGOUT,
136 1.13.4.1 yamt NT_HBA_RESET
137 1.13.4.1 yamt } tmd_ncode_t;
138 1.13.4.1 yamt
139 1.13.4.1 yamt typedef struct tmd_notify {
140 1.13.4.1 yamt void * nt_hba; /* HBA tag */
141 1.13.4.1 yamt uint64_t nt_iid; /* inititator id */
142 1.13.4.1 yamt uint64_t nt_tgt; /* target id */
143 1.13.4.1 yamt uint16_t nt_lun; /* logical unit */
144 1.13.4.1 yamt uint16_t : 15,
145 1.13.4.1 yamt nt_need_ack : 1; /* this notify needs an ACK */
146 1.13.4.1 yamt uint64_t nt_tagval; /* tag value */
147 1.13.4.1 yamt uint32_t nt_channel; /* channel id */
148 1.13.4.1 yamt tmd_ncode_t nt_ncode; /* action */
149 1.13.4.1 yamt void * nt_lreserved;
150 1.13.4.1 yamt void * nt_hreserved;
151 1.13.4.1 yamt } tmd_notify_t;
152 1.13.4.1 yamt #define LUN_ANY 0xffff
153 1.13.4.1 yamt #define TGT_ANY ((uint64_t) -1)
154 1.13.4.1 yamt #define INI_ANY ((uint64_t) -1)
155 1.13.4.1 yamt #define TAG_ANY ((uint64_t) 0)
156 1.13.4.1 yamt #define MATCH_TMD(tmd, iid, lun, tag) \
157 1.13.4.1 yamt ( \
158 1.13.4.1 yamt (tmd) && \
159 1.13.4.1 yamt (iid == INI_ANY || iid == tmd->cd_iid) && \
160 1.13.4.1 yamt (lun == LUN_ANY || lun == tmd->cd_lun) && \
161 1.13.4.1 yamt (tag == TAG_ANY || tag == tmd->cd_tagval) \
162 1.13.4.1 yamt )
163 1.1 mjacob
164 1.13.4.1 yamt /*
165 1.13.4.1 yamt * A word about ENABLE/DISABLE: the argument is a pointer to a enadis_t
166 1.13.4.1 yamt * with en_hba, en_iid, en_chan, en_tgt and en_lun filled out.
167 1.13.4.1 yamt *
168 1.13.4.1 yamt * If an error occurs in either enabling or disabling the described lun
169 1.13.4.1 yamt * cd_error is set with an appropriate non-zero value.
170 1.13.4.1 yamt */
171 1.1 mjacob typedef struct {
172 1.13.4.1 yamt void * en_private; /* for outer layer usage */
173 1.13.4.1 yamt void * en_hba; /* HBA tag */
174 1.13.4.1 yamt uint64_t en_iid; /* initiator ID */
175 1.13.4.1 yamt uint64_t en_tgt; /* target id */
176 1.13.4.1 yamt uint16_t en_lun; /* logical unit */
177 1.13.4.1 yamt uint16_t en_chan; /* channel on card */
178 1.13.4.1 yamt int en_error;
179 1.13.4.1 yamt } enadis_t;
180 1.1 mjacob
181 1.1 mjacob /*
182 1.3 he * Suggested Software Target Mode Command Handling structure.
183 1.1 mjacob *
184 1.3 he * A note about terminology:
185 1.3 he *
186 1.3 he * MD stands for "Machine Dependent".
187 1.3 he *
188 1.3 he * This driver is structured in three layers: Outer MD, core, and inner MD.
189 1.3 he * The latter also is bus dependent (i.e., is cognizant of PCI bus issues
190 1.3 he * as well as platform issues).
191 1.3 he *
192 1.3 he *
193 1.3 he * "Outer Layer" means "Other Module"
194 1.3 he *
195 1.3 he * Some additional module that actually implements SCSI target command
196 1.3 he * policy is the recipient of incoming commands and the source of the
197 1.3 he * disposition for them.
198 1.3 he *
199 1.3 he * The command structure below is one suggested possible MD command structure,
200 1.3 he * but since the handling of thbis is entirely in the MD layer, there is
201 1.3 he * no explicit or implicit requirement that it be used.
202 1.1 mjacob *
203 1.1 mjacob * The cd_private tag should be used by the MD layer to keep a free list
204 1.1 mjacob * of these structures. Code outside of this driver can then use this
205 1.9 mjacob * to identify it's own unit structures. That is, when not on the MD
206 1.1 mjacob * layer's freelist, the MD layer should shove into it the identifier
207 1.1 mjacob * that the outer layer has for it- passed in on an initial QIN_HBA_REG
208 1.1 mjacob * call (see below).
209 1.1 mjacob *
210 1.1 mjacob * The cd_hba tag is a tag that uniquely identifies the HBA this target
211 1.1 mjacob * mode command is coming from. The outer layer has to pass this back
212 1.1 mjacob * unchanged to avoid chaos.
213 1.1 mjacob *
214 1.13.4.1 yamt * The cd_iid, cd_tgt, cd_lun and cd_port tags are used to identify the
215 1.1 mjacob * id of the initiator who sent us a command, the target claim to be, the
216 1.13.4.1 yamt * lun on the target we claim to be, and the port instance (for multiple
217 1.13.4.1 yamt * port host adapters) that this applies to (consider it an extra port
218 1.1 mjacob * parameter). The iid, tgt and lun values are deliberately chosen to be
219 1.1 mjacob * fat so that, for example, World Wide Names can be used instead of
220 1.13.4.1 yamt * the units that the firmware uses (in the case where the MD
221 1.1 mjacob * layer maintains a port database, for example).
222 1.1 mjacob *
223 1.13.4.1 yamt * The cd_tagtype field specifies what kind of command tag type, if
224 1.13.4.1 yamt * any, has been sent with the command. Note that the Outer Layer
225 1.13.4.1 yamt * still needs to pass the tag handle through unchanged even
226 1.13.4.1 yamt * if the tag type is CD_UNTAGGED.
227 1.1 mjacob *
228 1.1 mjacob * The cd_cdb contains storage for the passed in command descriptor block.
229 1.13.4.1 yamt * There is no need to define length as the callee should be able to
230 1.13.4.1 yamt * figure this out.
231 1.1 mjacob *
232 1.1 mjacob * The tag cd_lflags are the flags set by the MD driver when it gets
233 1.1 mjacob * command incoming or when it needs to inform any outside entities
234 1.1 mjacob * that the last requested action failed.
235 1.1 mjacob *
236 1.1 mjacob * The tag cd_hflags should be set by any outside software to indicate
237 1.1 mjacob * the validity of sense and status fields (defined below) and to indicate
238 1.1 mjacob * the direction data is expected to move. It is an error to have both
239 1.1 mjacob * CDFH_DATA_IN and CDFH_DATA_OUT set.
240 1.1 mjacob *
241 1.1 mjacob * If the CDFH_STSVALID flag is set, the command should be completed (after
242 1.1 mjacob * sending any data and/or status). If CDFH_SNSVALID is set and the MD layer
243 1.1 mjacob * can also handle sending the associated sense data (either back with an
244 1.1 mjacob * FCP RESPONSE IU for Fibre Channel or otherwise automatically handling a
245 1.1 mjacob * REQUEST SENSE from the initator for this target/lun), the MD layer will
246 1.1 mjacob * set the CDFL_SENTSENSE flag on successful transmission of the sense data.
247 1.1 mjacob * It is an error for the CDFH_SNSVALID bit to be set and CDFH_STSVALID not
248 1.1 mjacob * to be set. It is an error for the CDFH_SNSVALID be set and the associated
249 1.1 mjacob * SCSI status (cd_scsi_status) not be set to CHECK CONDITON.
250 1.13.4.1 yamt *
251 1.1 mjacob * The tag cd_data points to a data segment to either be filled or
252 1.1 mjacob * read from depending on the direction of data movement. The tag
253 1.1 mjacob * is undefined if no data direction is set. The MD layer and outer
254 1.13.4.1 yamt * layers must agree on the meaning of cd_data and it is specifically
255 1.13.4.1 yamt * not defined here.
256 1.1 mjacob *
257 1.1 mjacob * The tag cd_totlen is the total data amount expected to be moved
258 1.13.4.1 yamt * over the life of the command. It may be set by the MD layer, possibly
259 1.3 he * from the datalen field of an FCP CMND IU unit. If it shows up in the outer
260 1.3 he * layers set to zero and the CDB indicates data should be moved, the outer
261 1.3 he * layer should set it to the amount expected to be moved.
262 1.1 mjacob *
263 1.2 mjacob * The tag cd_resid should be the total residual of data not transferred.
264 1.13.4.1 yamt * The outer layers need to set this at the begining of command processing
265 1.2 mjacob * to equal cd_totlen. As data is successfully moved, this value is decreased.
266 1.2 mjacob * At the end of a command, any nonzero residual indicates the number of bytes
267 1.13.4.1 yamt * requested by the command but not moved.
268 1.1 mjacob *
269 1.1 mjacob * The tag cd_xfrlen is the length of the currently active data transfer.
270 1.1 mjacob * This allows several interations between any outside software and the
271 1.1 mjacob * MD layer to move data.
272 1.1 mjacob *
273 1.1 mjacob * The reason that total length and total residual have to be tracked
274 1.13.4.1 yamt * is to keep track of relative offset.
275 1.1 mjacob *
276 1.1 mjacob * The tags cd_sense and cd_scsi_status are pretty obvious.
277 1.1 mjacob *
278 1.1 mjacob * The tag cd_error is to communicate between the MD layer and outer software
279 1.1 mjacob * the current error conditions.
280 1.1 mjacob *
281 1.10 mjacob * The tag cd_lreserved, cd_hreserved are scratch areas for use for the MD
282 1.10 mjacob * and outer layers respectively.
283 1.13.4.1 yamt *
284 1.1 mjacob */
285 1.1 mjacob
286 1.13.4.1 yamt #ifndef TMD_CDBLEN
287 1.13.4.1 yamt #define TMD_CDBLEN 16
288 1.10 mjacob #endif
289 1.13.4.1 yamt #ifndef TMD_SENSELEN
290 1.13.4.1 yamt #define TMD_SENSELEN 18
291 1.1 mjacob #endif
292 1.13.4.1 yamt #ifndef QCDS
293 1.13.4.1 yamt #define QCDS (sizeof (void *))
294 1.1 mjacob #endif
295 1.1 mjacob
296 1.1 mjacob typedef struct tmd_cmd {
297 1.13.4.1 yamt void * cd_private; /* private data pointer */
298 1.13.4.1 yamt void * cd_hba; /* HBA tag */
299 1.13.4.1 yamt void * cd_data; /* 'pointer' to data */
300 1.13.4.1 yamt uint64_t cd_iid; /* initiator ID */
301 1.13.4.1 yamt uint64_t cd_tgt; /* target id */
302 1.13.4.1 yamt uint8_t cd_lun[8]; /* logical unit */
303 1.13.4.1 yamt uint64_t cd_tagval; /* tag value */
304 1.13.4.1 yamt uint32_t cd_channel; /* channel index */
305 1.13.4.1 yamt uint32_t cd_lflags; /* flags lower level sets */
306 1.13.4.1 yamt uint32_t cd_hflags; /* flags higher level sets */
307 1.13.4.1 yamt uint32_t cd_totlen; /* total data load */
308 1.13.4.1 yamt uint32_t cd_resid; /* total data residual */
309 1.13.4.1 yamt uint32_t cd_xfrlen; /* current data load */
310 1.13.4.1 yamt int32_t cd_error; /* current error */
311 1.13.4.1 yamt uint8_t cd_tagtype; /* tag type */
312 1.13.4.1 yamt uint8_t cd_scsi_status;
313 1.13.4.1 yamt uint8_t cd_sense[TMD_SENSELEN];
314 1.13.4.1 yamt uint8_t cd_cdb[TMD_CDBLEN];
315 1.13.4.1 yamt union {
316 1.13.4.1 yamt void * ptrs[QCDS / sizeof (void *)];
317 1.13.4.1 yamt uint64_t llongs[QCDS / sizeof (uint64_t)];
318 1.13.4.1 yamt uint32_t longs[QCDS / sizeof (uint32_t)];
319 1.13.4.1 yamt uint16_t shorts[QCDS / sizeof (uint16_t)];
320 1.13.4.1 yamt uint8_t bytes[QCDS];
321 1.13.4.1 yamt } cd_lreserved[4], cd_hreserved[4];
322 1.1 mjacob } tmd_cmd_t;
323 1.1 mjacob
324 1.13.4.1 yamt /* defined tags */
325 1.13.4.1 yamt #define CD_UNTAGGED 0
326 1.13.4.1 yamt #define CD_SIMPLE_TAG 1
327 1.13.4.1 yamt #define CD_ORDERED_TAG 2
328 1.13.4.1 yamt #define CD_HEAD_TAG 3
329 1.13.4.1 yamt #define CD_ACA_TAG 4
330 1.13.4.1 yamt
331 1.13.4.1 yamt #ifndef TMD_SIZE
332 1.13.4.1 yamt #define TMD_SIZE (sizeof (tmd_cmd_t))
333 1.10 mjacob #endif
334 1.10 mjacob
335 1.13.4.1 yamt #define L0LUN_TO_FLATLUN(lptr) ((((lptr)[0] & 0x3f) << 8) | ((lptr)[1]))
336 1.13.4.1 yamt #define FLATLUN_TO_L0LUN(lptr, lun) \
337 1.13.4.1 yamt (lptr)[1] = lun & 0xff; \
338 1.13.4.1 yamt if (sizeof (lun) == 1) { \
339 1.13.4.1 yamt (lptr)[0] = 0; \
340 1.13.4.1 yamt } else { \
341 1.13.4.1 yamt uint16_t nl = lun; \
342 1.13.4.1 yamt if (nl == LUN_ANY) { \
343 1.13.4.1 yamt (lptr)[0] = (nl >> 8) & 0xff; \
344 1.13.4.1 yamt } else if (nl < 256) { \
345 1.13.4.1 yamt (lptr)[0] = 0; \
346 1.13.4.1 yamt } else { \
347 1.13.4.1 yamt (lptr)[0] = 0x40 | ((nl >> 8) & 0x3f); \
348 1.13.4.1 yamt } \
349 1.13.4.1 yamt } \
350 1.13.4.1 yamt memset(&(lptr)[2], 0, 6)
351 1.13.4.1 yamt
352 1.10 mjacob /*
353 1.10 mjacob * Note that NODISC (obviously) doesn't apply to non-SPI transport.
354 1.10 mjacob *
355 1.10 mjacob * Note that knowing the data direction and lengh at the time of receipt of
356 1.10 mjacob * a command from the initiator is a feature only of Fibre Channel.
357 1.10 mjacob *
358 1.10 mjacob * The CDFL_BIDIR is in anticipation of the adoption of some newer
359 1.10 mjacob * features required by OSD.
360 1.10 mjacob *
361 1.10 mjacob * The principle selector for MD layer to know whether data is to
362 1.10 mjacob * be transferred in any QOUT_TMD_CONT call is cd_xfrlen- the
363 1.10 mjacob * flags CDFH_DATA_IN and CDFH_DATA_OUT define which direction.
364 1.10 mjacob */
365 1.13.4.1 yamt #define CDFL_SNSVALID 0x01 /* sense data (from f/w) good */
366 1.13.4.1 yamt #define CDFL_SENTSTATUS 0x02 /* last action sent status */
367 1.13.4.1 yamt #define CDFL_DATA_IN 0x04 /* target (us) -> initiator (them) */
368 1.13.4.1 yamt #define CDFL_DATA_OUT 0x08 /* initiator (them) -> target (us) */
369 1.13.4.1 yamt #define CDFL_BIDIR 0x0C /* bidirectional data */
370 1.13.4.1 yamt #define CDFL_ERROR 0x10 /* last action ended in error */
371 1.13.4.1 yamt #define CDFL_NODISC 0x20 /* disconnects disabled */
372 1.13.4.1 yamt #define CDFL_SENTSENSE 0x40 /* last action sent sense data */
373 1.13.4.1 yamt #define CDFL_BUSY 0x80 /* this command is not on a free list */
374 1.13.4.1 yamt #define CDFL_PRIVATE 0xFF000000 /* private layer flags */
375 1.13.4.1 yamt
376 1.13.4.1 yamt #define CDFH_SNSVALID 0x01 /* sense data (from outer layer) good */
377 1.13.4.1 yamt #define CDFH_STSVALID 0x02 /* status valid */
378 1.13.4.1 yamt #define CDFH_DATA_IN 0x04 /* target (us) -> initiator (them) */
379 1.13.4.1 yamt #define CDFH_DATA_OUT 0x08 /* initiator (them) -> target (us) */
380 1.13.4.1 yamt #define CDFH_DATA_MASK 0x0C /* mask to cover data direction */
381 1.13.4.1 yamt #define CDFH_PRIVATE 0xFF000000 /* private layer flags */
382 1.1 mjacob
383 1.10 mjacob
384 1.1 mjacob /*
385 1.1 mjacob * A word about the START/CONT/DONE/FIN dance:
386 1.1 mjacob *
387 1.13.4.1 yamt * When the HBA is enabled for receiving commands, one may show up
388 1.13.4.1 yamt * without notice. When that happens, the MD target mode driver
389 1.13.4.1 yamt * gets a tmd_cmd_t, fills it with the info that just arrived, and
390 1.13.4.1 yamt * calls the outer layer with a QOUT_TMD_START code and pointer to
391 1.13.4.1 yamt * the tmd_cmd_t.
392 1.13.4.1 yamt *
393 1.13.4.1 yamt * The outer layer decodes the command, fetches data, prepares stuff,
394 1.13.4.1 yamt * whatever, and starts by passing back the pointer with a QIN_TMD_CONT
395 1.13.4.1 yamt * code which causes the MD target mode driver to generate CTIOs to
396 1.13.4.1 yamt * satisfy whatever action needs to be taken. When those CTIOs complete,
397 1.13.4.1 yamt * the MD target driver sends the pointer to the cmd_tmd_t back with
398 1.13.4.1 yamt * a QOUT_TMD_DONE code. This repeats for as long as necessary. These
399 1.13.4.1 yamt * may not be done in parallel- they are sequential operations.
400 1.13.4.1 yamt *
401 1.13.4.1 yamt * The outer layer signals it wants to end the command by settings within
402 1.13.4.1 yamt * the tmd_cmd_t itself. When the final QIN_TMD_CONT is reported completed,
403 1.13.4.1 yamt * the outer layer frees the tmd_cmd_t by sending the pointer to it
404 1.13.4.1 yamt * back with a QIN_TMD_FIN code.
405 1.1 mjacob *
406 1.13.4.1 yamt * The graph looks like:
407 1.1 mjacob *
408 1.13.4.1 yamt * QOUT_TMD_START -> [ QIN_TMD_CONT -> QOUT_TMD_DONE ] * -> QIN_TMD_FIN.
409 1.3 he *
410 1.3 he */
411 1.3 he
412 1.3 he /*
413 1.10 mjacob * Target handler functions.
414 1.10 mjacob *
415 1.10 mjacob * The MD target handler function (the outer layer calls this)
416 1.10 mjacob * should be be prototyped like:
417 1.10 mjacob *
418 1.13.4.1 yamt * void target_action(qact_e, void *arg)
419 1.10 mjacob *
420 1.10 mjacob * The outer layer target handler function (the MD layer calls this)
421 1.10 mjacob * should be be prototyped like:
422 1.10 mjacob *
423 1.13.4.1 yamt * void scsi_target_handler(tact_e, void *arg)
424 1.13.4.1 yamt */
425 1.13.4.1 yamt #endif /* _ISP_TPUBLIC_H */
426 1.13.4.1 yamt /*
427 1.13.4.1 yamt * vim:ts=4:sw=4:expandtab
428 1.10 mjacob */
429