FreeBSD kernel CAM code
cam_compat.h
Go to the documentation of this file.
1/*-
2 * CAM ioctl compatibility shims
3 *
4 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 *
6 * Copyright (c) 2013 Scott Long
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer,
14 * without modification, immediately at the beginning of the file.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD$
31 */
32
33#ifndef _CAM_CAM_COMPAT_H
34#define _CAM_CAM_COMPAT_H
35
36/* No user-serviceable parts in here. */
37#ifdef _KERNEL
38
39int cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
40 struct thread *td, int(*cbfnp)(struct cdev *, u_long, caddr_t, int,
41 struct thread *));
42
43/* Version 0x16 compatibility */
44#define CAM_VERSION_0x16 0x16
45
46/* The size of the union ccb didn't change when going to 0x17 */
47#define CAMIOCOMMAND_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 2, CAM_0X17_LEN)
48#define CAMGETPASSTHRU_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 3, CAM_0X17_LEN)
49
50#define CAM_SCATTER_VALID_0x16 0x00000010
51#define CAM_SG_LIST_PHYS_0x16 0x00040000
52#define CAM_DATA_PHYS_0x16 0x00200000
53
54/* Version 0x17 compatibility */
55#define CAM_VERSION_0x17 0x17
56
58 cam_pinfo pinfo; /* Info for priority scheduling */
59 camq_entry xpt_links; /* For chaining in the XPT layer */
60 camq_entry sim_links; /* For chaining in the SIM layer */
61 camq_entry periph_links; /* For chaining in the type driver */
62 u_int32_t retry_count;
63 void (*cbfcnp)(struct cam_periph *, union ccb *);
64 xpt_opcode func_code; /* XPT function code */
65 u_int32_t status; /* Status returned by CAM subsystem */
66 struct cam_path *path; /* Compiled path for this ccb */
67 path_id_t path_id; /* Path ID for the request */
68 target_id_t target_id; /* Target device ID */
69 u_int target_lun; /* Target LUN number */
70 u_int32_t flags; /* ccb_flags */
73 u_int32_t timeout; /* Hard timeout value in seconds */
74 struct callout *timeout_ch;
75};
76
79 u_int8_t version_num; /* Version number for the SIM/HBA */
80 u_int8_t hba_inquiry; /* Mimic of INQ byte 7 for the HBA */
81 u_int8_t target_sprt; /* Flags for target mode support */
82 u_int8_t hba_misc; /* Misc HBA features */
83 u_int16_t hba_eng_cnt; /* HBA engine count */
84 /* Vendor Unique capabilities */
86 u_int32_t max_target; /* Maximum supported Target */
87 u_int32_t max_lun; /* Maximum supported Lun */
88 u_int32_t async_flags; /* Installed Async handlers */
89 path_id_t hpath_id; /* Highest Path ID in the subsystem */
90 target_id_t initiator_id; /* ID of the HBA on the SCSI bus */
91 char sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */
92 char hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */
93 char dev_name[DEV_IDLEN];/* Device name for SIM */
94 u_int32_t unit_number; /* Unit number for SIM */
95 u_int32_t bus_id; /* Bus ID for SIM */
96 u_int32_t base_transfer_speed;/* Base bus speed in KB/sec */
101 union {
107 u_int maxio; /* Max supported I/O size, in bytes. */
108 u_int16_t hba_vendor; /* HBA vendor ID */
109 u_int16_t hba_device; /* HBA device ID */
110 u_int16_t hba_subvendor; /* HBA subvendor ID */
111 u_int16_t hba_subdevice; /* HBA subdevice ID */
112};
113
116 cts_type type; /* Current or User settings */
121 union {
122 u_int valid; /* Which fields to honor */
126 union {
127 u_int valid; /* Which fields to honor */
134};
135
136#define CAM_0X17_DATA_LEN CAM_0X18_DATA_LEN
137#define CAM_0X17_LEN (sizeof(struct ccb_hdr_0x17) + CAM_0X17_DATA_LEN)
138
139#define CAMIOCOMMAND_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 2, CAM_0X17_LEN)
140#define CAMGETPASSTHRU_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 3, CAM_0X17_LEN)
141
142/* Version 0x18 compatibility */
143#define CAM_VERSION_0x18 0x18
144
146 cam_pinfo pinfo; /* Info for priority scheduling */
147 camq_entry xpt_links; /* For chaining in the XPT layer */
148 camq_entry sim_links; /* For chaining in the SIM layer */
149 camq_entry periph_links; /* For chaining in the type driver */
150 u_int32_t retry_count;
151 void (*cbfcnp)(struct cam_periph *, union ccb *);
152 xpt_opcode func_code; /* XPT function code */
153 u_int32_t status; /* Status returned by CAM subsystem */
154 struct cam_path *path; /* Compiled path for this ccb */
155 path_id_t path_id; /* Path ID for the request */
156 target_id_t target_id; /* Target device ID */
157 u_int target_lun; /* Target LUN number */
158 u_int64_t ext_lun; /* 64-bit LUN, more or less */
159 u_int32_t flags; /* ccb_flags */
160 u_int32_t xflags; /* extended ccb_flags */
164 u_int32_t timeout; /* Hard timeout value in seconds */
165 struct timeval softtimeout; /* Soft timeout value in sec + usec */
166};
167
168typedef enum {
169 CAM_EXTLUN_VALID_0x18 = 0x00000001,/* 64bit lun field is valid */
171
174 cts_type type; /* Current or User settings */
179 union {
180 u_int valid; /* Which fields to honor */
184 union {
185 u_int valid; /* Which fields to honor */
192};
193
196 union {
197 struct {
199 u_int32_t unit_number;
204 struct {
207 u_int target_lun;
210 struct ata_params ident_data;
215};
216
217#define CAM_0X18_DATA_LEN (sizeof(union ccb) - 2*sizeof(void *) - sizeof(struct ccb_hdr))
218#define CAM_0X18_LEN (sizeof(struct ccb_hdr_0x18) + CAM_0X18_DATA_LEN)
219
220#define CAMIOCOMMAND_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 2, CAM_0X18_LEN)
221#define CAMGETPASSTHRU_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 3, CAM_0X18_LEN)
222
223/* Version 0x19 compatibility */
224#define CAM_VERSION_0x19 0x19
225#define CAMIOCOMMAND_0x19 _IOWR(CAM_VERSION_0x19, 2, union ccb)
226#define CAMGETPASSTHRU_0x19 _IOWR(CAM_VERSION_0x19, 3, union ccb)
227#define CAMIOQUEUE_0x19 _IO(CAM_VERSION_0x19, 4)
228#define CAMIOGET_0x19 _IO(CAM_VERSION_0x19, 5)
229
230#endif
231#endif
u_int path_id_t
Definition: cam.h:42
u_int target_id_t
Definition: cam.h:43
dev_result_flags
Definition: cam_ccb.h:508
cam_proto
Definition: cam_ccb.h:276
#define VUHBALEN
Definition: cam_ccb.h:51
cts_type
Definition: cam_ccb.h:944
dev_match_type
Definition: cam_ccb.h:489
cam_xport
Definition: cam_ccb.h:288
#define PATHINQ_SETTINGS_SIZE
Definition: cam_ccb.h:658
xpt_opcode
Definition: cam_ccb.h:129
#define HBA_IDLEN
Definition: cam_ccb.h:53
#define SIM_IDLEN
Definition: cam_ccb.h:52
#define DEV_IDLEN
Definition: cam_ccb.h:54
int cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td, int(*cbfnp)(struct cdev *, u_long, caddr_t, int, struct thread *))
ccb_xflags_0x18
Definition: cam_compat.h:168
@ CAM_EXTLUN_VALID_0x18
Definition: cam_compat.h:169
Definition: cam.h:85
camq_entry sim_links
Definition: cam_compat.h:60
struct callout * timeout_ch
Definition: cam_compat.h:74
target_id_t target_id
Definition: cam_compat.h:68
u_int32_t flags
Definition: cam_compat.h:70
u_int target_lun
Definition: cam_compat.h:69
struct cam_path * path
Definition: cam_compat.h:66
camq_entry xpt_links
Definition: cam_compat.h:59
xpt_opcode func_code
Definition: cam_compat.h:64
u_int32_t retry_count
Definition: cam_compat.h:62
void(* cbfcnp)(struct cam_periph *, union ccb *)
Definition: cam_compat.h:63
ccb_ppriv_area periph_priv
Definition: cam_compat.h:71
u_int32_t timeout
Definition: cam_compat.h:73
cam_pinfo pinfo
Definition: cam_compat.h:58
camq_entry periph_links
Definition: cam_compat.h:61
ccb_spriv_area sim_priv
Definition: cam_compat.h:72
path_id_t path_id
Definition: cam_compat.h:67
u_int32_t status
Definition: cam_compat.h:65
struct timeval softtimeout
Definition: cam_compat.h:165
cam_pinfo pinfo
Definition: cam_compat.h:146
xpt_opcode func_code
Definition: cam_compat.h:152
struct cam_path * path
Definition: cam_compat.h:154
u_int32_t xflags
Definition: cam_compat.h:160
u_int32_t flags
Definition: cam_compat.h:159
camq_entry sim_links
Definition: cam_compat.h:148
ccb_qos_area qos
Definition: cam_compat.h:163
path_id_t path_id
Definition: cam_compat.h:155
u_int64_t ext_lun
Definition: cam_compat.h:158
camq_entry periph_links
Definition: cam_compat.h:149
u_int target_lun
Definition: cam_compat.h:157
u_int32_t status
Definition: cam_compat.h:153
u_int32_t retry_count
Definition: cam_compat.h:150
target_id_t target_id
Definition: cam_compat.h:156
camq_entry xpt_links
Definition: cam_compat.h:147
ccb_ppriv_area periph_priv
Definition: cam_compat.h:161
ccb_spriv_area sim_priv
Definition: cam_compat.h:162
void(* cbfcnp)(struct cam_periph *, union ccb *)
Definition: cam_compat.h:151
u_int32_t timeout
Definition: cam_compat.h:164
cam_proto protocol
Definition: cam_compat.h:97
u_int32_t max_lun
Definition: cam_compat.h:87
u_int16_t hba_subvendor
Definition: cam_compat.h:110
u_int transport_version
Definition: cam_compat.h:100
struct ccb_pathinq_settings_spi spi
Definition: cam_compat.h:102
u_int8_t vuhba_flags[VUHBALEN]
Definition: cam_compat.h:85
path_id_t hpath_id
Definition: cam_compat.h:89
u_int32_t bus_id
Definition: cam_compat.h:95
struct ccb_pathinq_settings_fc fc
Definition: cam_compat.h:103
struct ccb_pathinq_settings_sas sas
Definition: cam_compat.h:104
u_int32_t base_transfer_speed
Definition: cam_compat.h:96
target_id_t initiator_id
Definition: cam_compat.h:90
u_int8_t target_sprt
Definition: cam_compat.h:81
char hba_vid[HBA_IDLEN]
Definition: cam_compat.h:92
cam_xport transport
Definition: cam_compat.h:99
u_int8_t hba_inquiry
Definition: cam_compat.h:80
u_int8_t version_num
Definition: cam_compat.h:79
union ccb_pathinq_0x17::@6 xport_specific
u_int protocol_version
Definition: cam_compat.h:98
u_int32_t unit_number
Definition: cam_compat.h:94
u_int16_t hba_device
Definition: cam_compat.h:109
u_int16_t hba_subdevice
Definition: cam_compat.h:111
u_int32_t max_target
Definition: cam_compat.h:86
char sim_vid[SIM_IDLEN]
Definition: cam_compat.h:91
char dev_name[DEV_IDLEN]
Definition: cam_compat.h:93
char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE]
Definition: cam_compat.h:105
u_int8_t hba_misc
Definition: cam_compat.h:82
struct ccb_hdr_0x17 ccb_h
Definition: cam_compat.h:78
u_int16_t hba_vendor
Definition: cam_compat.h:108
u_int32_t async_flags
Definition: cam_compat.h:88
u_int16_t hba_eng_cnt
Definition: cam_compat.h:83
struct ccb_trans_settings_sata sata
Definition: cam_compat.h:132
struct ccb_trans_settings_sas sas
Definition: cam_compat.h:130
struct ccb_trans_settings_scsi scsi
Definition: cam_compat.h:124
union ccb_trans_settings_0x17::@8 xport_specific
struct ccb_trans_settings_fc fc
Definition: cam_compat.h:129
struct ccb_hdr_0x17 ccb_h
Definition: cam_compat.h:115
struct ccb_trans_settings_spi spi
Definition: cam_compat.h:128
union ccb_trans_settings_0x17::@7 proto_specific
struct ccb_trans_settings_ata ata
Definition: cam_compat.h:123
struct ccb_trans_settings_sas sas
Definition: cam_compat.h:188
struct ccb_trans_settings_ata ata
Definition: cam_compat.h:181
union ccb_trans_settings_0x18::@9 proto_specific
struct ccb_trans_settings_fc fc
Definition: cam_compat.h:187
struct ccb_trans_settings_spi spi
Definition: cam_compat.h:186
union ccb_trans_settings_0x18::@10 xport_specific
struct ccb_trans_settings_scsi scsi
Definition: cam_compat.h:182
struct ccb_trans_settings_sata sata
Definition: cam_compat.h:190
struct ccb_hdr_0x18 ccb_h
Definition: cam_compat.h:173
struct ata_params ident_data
Definition: cam_compat.h:210
dev_result_flags flags
Definition: cam_compat.h:211
target_id_t target_id
Definition: cam_compat.h:201
char periph_name[DEV_IDLEN]
Definition: cam_compat.h:198
struct dev_match_result_0x18::@11::@12 periph_result
struct dev_match_result_0x18::@11::@13 device_result
struct bus_match_result bus_result
Definition: cam_compat.h:213
union dev_match_result_0x18::@11 result
struct scsi_inquiry_data inq_data
Definition: cam_compat.h:209
dev_match_type type
Definition: cam_compat.h:195
Definition: cam_ccb.h:319
Definition: cam_ccb.h:1345