2 * Ioctl definitions for the Target Mode SCSI Proccessor Target driver for CAM.
4 * Copyright (c) 1998 Justin T. Gibbs.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer,
12 * without modification, immediately at the beginning of the file.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #ifndef _CAM_SCSI_SCSI_TARGETIO_H_
32 #define _CAM_SCSI_SCSI_TARGETIO_H_
34 #include <sys/types.h>
36 #include <sys/ioccom.h>
39 #include <cam/cam_ccb.h>
41 TAILQ_HEAD(ccb_queue, ccb_hdr);
43 /* Determine and clear exception state in the driver */
45 TARG_EXCEPT_NONE = 0x00,
46 TARG_EXCEPT_DEVICE_INVALID = 0x01,
47 TARG_EXCEPT_BDR_RECEIVED = 0x02,
48 TARG_EXCEPT_BUS_RESET_SEEN = 0x04,
49 TARG_EXCEPT_ABORT_SEEN = 0x08,
50 TARG_EXCEPT_ABORT_TAG_SEEN = 0x10,
51 TARG_EXCEPT_UNKNOWN_ATIO = 0x80
54 #define TARGIOCFETCHEXCEPTION _IOR('C', 1, targ_exception)
55 #define TARGIOCCLEAREXCEPTION _IOW('C', 2, targ_exception)
58 * Retreive an Accept Target I/O CCB for a command that is not handled
59 * directly by the kernel target driver.
61 #define TARGIOCFETCHATIO _IOR('C', 3, struct ccb_accept_tio)
64 * Used for responding to incoming ATIO requests. XPT_CONTINUE_TARG_IO
65 * operations are the norm, but ccb types for manipulating the device
66 * queue, etc. can also be used if error handling is to be performed by the
69 #define TARGIOCCOMMAND _IOWR('C', 4, union ccb)
85 struct initiator_state {
88 struct scsi_sense_data sense_data;
89 struct ccb_queue held_queue;
92 struct ioc_initiator_state {
94 struct initiator_state istate;
98 * Get and Set Contingent Allegiance and Unit Attention state
99 * presented by the target driver. This is usually used to
100 * properly report and error condition in response to an incoming
101 * ATIO request handled by the userland process.
103 * The initiator_id must be properly initialized in the ioc_initiator_state
104 * structure before calling TARGIOCGETISTATE.
106 #define TARGIOCGETISTATE _IOWR('C', 6, struct ioc_initiator_state)
107 #define TARGIOCSETISTATE _IOW('C', 5, struct ioc_initiator_state)
109 struct ioc_alloc_unit {
111 target_id_t target_id;
117 * Allocate and Free a target mode instance. For allocation, the path_id,
118 * target_id, and lun_id fields must be set. On successful completion
119 * of the ioctl, the unit field will indicate the unit number of the
120 * newly created instance. For de-allocation, all fields must match
121 * an instance in the inactive (i.e. closed) state.
123 #define TARGCTLIOALLOCUNIT _IOWR('C', 7, struct ioc_alloc_unit)
124 #define TARGCTLIOFREEUNIT _IOW('C', 8, struct ioc_alloc_unit)
125 #endif /* _CAM_SCSI_SCSI_TARGETIO_H_ */