1 /*
2 * Ioctl definitions for the Target Mode SCSI Proccessor Target driver for CAM.
3 *
4 * Copyright (c) 1998 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
15 *
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
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30
31 #ifndef _CAM_SCSI_SCSI_TARGETIO_H_
32 #define _CAM_SCSI_SCSI_TARGETIO_H_
33 #ifndef KERNEL
34 #include <sys/types.h>
35 #endif
36 #include <sys/ioccom.h>
37
38 #include <cam/cam.h>
39 #include <cam/cam_ccb.h>
40
41 /* Determine and clear exception state in the driver */
42 typedef enum {
43 TARG_EXCEPT_NONE = 0x00,
44 TARG_EXCEPT_DEVICE_INVALID = 0x01,
45 TARG_EXCEPT_BDR_RECEIVED = 0x02,
46 TARG_EXCEPT_BUS_RESET_SEEN = 0x04,
47 TARG_EXCEPT_UNKNOWN_ATIO = 0x08,
48 } targ_exception;
49
50 #define TARGIOCFETCHEXCEPTION _IOR('C', 1, targ_exception)
51 #define TARGIOCCLEAREXCEPTION _IOW('C', 2, targ_exception)
52
53 /*
54 * Retreive an Accept Target I/O CCB for a command that is not handled
55 * directly by the kernel target driver.
56 */
57 #define TARGIOCFETCHATIO _IOR('C', 3, struct ccb_accept_tio)
58
59 /*
60 * Used for responding to incoming ATIO requests. XPT_CONTINUE_TARG_IO
61 * operations are the norm, but ccb types for manipulating the device
62 * queue, etc. can also be used if error handling is to be performed by the
63 * user land process.
64 */
65 #define TARGIOCCOMMAND _IOWR('C', 4, union ccb)
66
67
68 typedef enum {
69 UA_NONE = 0x00,
70 UA_POWER_ON = 0x01,
71 UA_BUS_RESET = 0x02
72 } ua_types;
73
74 typedef enum {
75 CA_NONE = 0x00,
76 CA_UNIT_ATTN = 0x01,
77 CA_CMD_SENSE = 0x02
78 } ca_types;
79
80 struct initiator_state {
81 ua_types pending_ua;
82 ca_types pending_ca;
83 struct scsi_sense_data sense_data;
84 };
85
86 struct ioc_initiator_state {
87 u_int initiator_id;
88 struct initiator_state istate;
89 };
90
91 /*
92 * Get and Set Contingent Allegiance and Unit Attention state
93 * presented by the target driver. This is usually used to
94 * properly report and error condition in response to an incoming
95 * ATIO request handled by the userland process.
96 *
97 * The initiator_id must be properly initialized in the ioc_initiator_state
98 * structure before calling TARGIOCGETISTATE.
99 */
100 #define TARGIOCGETISTATE _IOWR('C', 6, struct ioc_initiator_state)
101 #define TARGIOCSETISTATE _IOW('C', 5, struct ioc_initiator_state)
102
103 struct ioc_alloc_unit {
104 path_id_t path_id;
105 target_id_t target_id;
106 lun_id_t lun_id;
107 u_int unit;
108 };
109
110 /*
111 * Allocate and Free a target mode instance. For allocation, the path_id,
112 * target_id, and lun_id fields must be set. On successful completion
113 * of the ioctl, the unit field will indicate the unit number of the
114 * newly created instance. For de-allocation, all fields must match
115 * an instance in the inactive (i.e. closed) state.
116 */
117 #define TARGCTLIOALLOCUNIT _IOWR('C', 7, struct ioc_alloc_unit)
118 #define TARGCTLIOFREEUNIT _IOW('C', 8, struct ioc_alloc_unit)
119 #endif /* _CAM_SCSI_SCSI_TARGETIO_H_ */
Cache object: 184480e3236f5f6a23b2953f759752b0
|