]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/cam/cam_compat.h
Add UPDATING entries and bump version.
[FreeBSD/FreeBSD.git] / sys / cam / cam_compat.h
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
39 int 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
44 /* Version 0x16 compatibility */
45 #define CAM_VERSION_0x16        0x16
46
47 /* The size of the union ccb didn't change when going to 0x17 */
48 #define CAMIOCOMMAND_0x16       _IOC(IOC_INOUT, CAM_VERSION_0x16, 2, CAM_0X17_LEN)
49 #define CAMGETPASSTHRU_0x16     _IOC(IOC_INOUT, CAM_VERSION_0x16, 3, CAM_0X17_LEN)
50
51 #define CAM_SCATTER_VALID_0x16  0x00000010
52 #define CAM_SG_LIST_PHYS_0x16   0x00040000
53 #define CAM_DATA_PHYS_0x16      0x00200000
54
55 /* Version 0x17 compatibility */
56 #define CAM_VERSION_0x17        0x17
57
58 struct ccb_hdr_0x17 {
59         cam_pinfo       pinfo;          /* Info for priority scheduling */
60         camq_entry      xpt_links;      /* For chaining in the XPT layer */     
61         camq_entry      sim_links;      /* For chaining in the SIM layer */     
62         camq_entry      periph_links;   /* For chaining in the type driver */
63         u_int32_t       retry_count;
64         void            (*cbfcnp)(struct cam_periph *, union ccb *);
65         xpt_opcode      func_code;      /* XPT function code */
66         u_int32_t       status;         /* Status returned by CAM subsystem */
67         struct          cam_path *path; /* Compiled path for this ccb */
68         path_id_t       path_id;        /* Path ID for the request */
69         target_id_t     target_id;      /* Target device ID */
70         u_int           target_lun;     /* Target LUN number */
71         u_int32_t       flags;          /* ccb_flags */
72         ccb_ppriv_area  periph_priv;
73         ccb_spriv_area  sim_priv;
74         u_int32_t       timeout;        /* Hard timeout value in seconds */
75         struct callout_handle timeout_ch;
76 };
77
78 struct ccb_pathinq_0x17 {
79         struct ccb_hdr_0x17 ccb_h;
80         u_int8_t    version_num;        /* Version number for the SIM/HBA */
81         u_int8_t    hba_inquiry;        /* Mimic of INQ byte 7 for the HBA */
82         u_int8_t    target_sprt;        /* Flags for target mode support */
83         u_int8_t    hba_misc;           /* Misc HBA features */
84         u_int16_t   hba_eng_cnt;        /* HBA engine count */
85                                         /* Vendor Unique capabilities */
86         u_int8_t    vuhba_flags[VUHBALEN];
87         u_int32_t   max_target;         /* Maximum supported Target */
88         u_int32_t   max_lun;            /* Maximum supported Lun */
89         u_int32_t   async_flags;        /* Installed Async handlers */
90         path_id_t   hpath_id;           /* Highest Path ID in the subsystem */
91         target_id_t initiator_id;       /* ID of the HBA on the SCSI bus */
92         char        sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */
93         char        hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */
94         char        dev_name[DEV_IDLEN];/* Device name for SIM */
95         u_int32_t   unit_number;        /* Unit number for SIM */
96         u_int32_t   bus_id;             /* Bus ID for SIM */
97         u_int32_t   base_transfer_speed;/* Base bus speed in KB/sec */
98         cam_proto   protocol;
99         u_int       protocol_version;
100         cam_xport   transport;
101         u_int       transport_version;
102         union {
103                 struct ccb_pathinq_settings_spi spi;
104                 struct ccb_pathinq_settings_fc fc;
105                 struct ccb_pathinq_settings_sas sas;
106                 char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];
107         } xport_specific;
108         u_int           maxio;          /* Max supported I/O size, in bytes. */
109         u_int16_t       hba_vendor;     /* HBA vendor ID */
110         u_int16_t       hba_device;     /* HBA device ID */
111         u_int16_t       hba_subvendor;  /* HBA subvendor ID */
112         u_int16_t       hba_subdevice;  /* HBA subdevice ID */
113 };
114
115 struct ccb_trans_settings_0x17 {
116         struct    ccb_hdr_0x17 ccb_h;
117         cts_type  type;         /* Current or User settings */
118         cam_proto protocol;
119         u_int     protocol_version;
120         cam_xport transport;
121         u_int     transport_version;
122         union {
123                 u_int  valid;   /* Which fields to honor */
124                 struct ccb_trans_settings_ata ata;
125                 struct ccb_trans_settings_scsi scsi;
126         } proto_specific;
127         union {
128                 u_int  valid;   /* Which fields to honor */
129                 struct ccb_trans_settings_spi spi;
130                 struct ccb_trans_settings_fc fc;
131                 struct ccb_trans_settings_sas sas;
132                 struct ccb_trans_settings_pata ata;
133                 struct ccb_trans_settings_sata sata;
134         } xport_specific;
135 };
136
137 #define CAM_0X17_DATA_LEN       CAM_0X18_DATA_LEN
138 #define CAM_0X17_LEN            (sizeof(struct ccb_hdr_0x17) + CAM_0X17_DATA_LEN)
139
140 #define CAMIOCOMMAND_0x17       _IOC(IOC_INOUT, CAM_VERSION_0x17, 2, CAM_0X17_LEN)
141 #define CAMGETPASSTHRU_0x17     _IOC(IOC_INOUT, CAM_VERSION_0x17, 3, CAM_0X17_LEN)
142
143 /* Version 0x18 compatibility */
144 #define CAM_VERSION_0x18        0x18
145
146 struct ccb_hdr_0x18 {
147         cam_pinfo       pinfo;          /* Info for priority scheduling */
148         camq_entry      xpt_links;      /* For chaining in the XPT layer */     
149         camq_entry      sim_links;      /* For chaining in the SIM layer */     
150         camq_entry      periph_links;   /* For chaining in the type driver */
151         u_int32_t       retry_count;
152         void            (*cbfcnp)(struct cam_periph *, union ccb *);
153         xpt_opcode      func_code;      /* XPT function code */
154         u_int32_t       status;         /* Status returned by CAM subsystem */
155         struct          cam_path *path; /* Compiled path for this ccb */
156         path_id_t       path_id;        /* Path ID for the request */
157         target_id_t     target_id;      /* Target device ID */
158         u_int           target_lun;     /* Target LUN number */
159         u_int64_t       ext_lun;        /* 64-bit LUN, more or less */
160         u_int32_t       flags;          /* ccb_flags */
161         u_int32_t       xflags;         /* extended ccb_flags */
162         ccb_ppriv_area  periph_priv;
163         ccb_spriv_area  sim_priv;
164         ccb_qos_area    qos;
165         u_int32_t       timeout;        /* Hard timeout value in seconds */
166         struct timeval  softtimeout;    /* Soft timeout value in sec + usec */
167 };
168
169 typedef enum {
170         CAM_EXTLUN_VALID_0x18   = 0x00000001,/* 64bit lun field is valid      */
171 } ccb_xflags_0x18;
172
173 struct ccb_trans_settings_0x18 {
174         struct    ccb_hdr_0x18 ccb_h;
175         cts_type  type;         /* Current or User settings */
176         cam_proto protocol;
177         u_int     protocol_version;
178         cam_xport transport;
179         u_int     transport_version;
180         union {
181                 u_int  valid;   /* Which fields to honor */
182                 struct ccb_trans_settings_ata ata;
183                 struct ccb_trans_settings_scsi scsi;
184         } proto_specific;
185         union {
186                 u_int  valid;   /* Which fields to honor */
187                 struct ccb_trans_settings_spi spi;
188                 struct ccb_trans_settings_fc fc;
189                 struct ccb_trans_settings_sas sas;
190                 struct ccb_trans_settings_pata ata;
191                 struct ccb_trans_settings_sata sata;
192         } xport_specific;
193 };
194
195 struct dev_match_result_0x18 {
196         dev_match_type          type;
197         union {
198                 struct {
199                         char periph_name[DEV_IDLEN];
200                         u_int32_t unit_number;
201                         path_id_t path_id;
202                         target_id_t target_id;
203                         u_int target_lun;
204                 } periph_result;
205                 struct {
206                         path_id_t       path_id;
207                         target_id_t     target_id;
208                         u_int           target_lun;
209                         cam_proto       protocol;
210                         struct scsi_inquiry_data inq_data;
211                         struct ata_params ident_data;
212                         dev_result_flags flags;
213                 } device_result;
214                 struct bus_match_result bus_result;
215         } result;
216 };
217
218 #define CAM_0X18_DATA_LEN       (sizeof(union ccb) - 2*sizeof(void *) - sizeof(struct ccb_hdr))
219 #define CAM_0X18_LEN            (sizeof(struct ccb_hdr_0x18) + CAM_0X18_DATA_LEN)
220
221 #define CAMIOCOMMAND_0x18       _IOC(IOC_INOUT, CAM_VERSION_0x18, 2, CAM_0X18_LEN)
222 #define CAMGETPASSTHRU_0x18     _IOC(IOC_INOUT, CAM_VERSION_0x18, 3, CAM_0X18_LEN)
223
224 #endif
225 #endif