2 * CAM ioctl compatibility shims
4 * Copyright (c) 2013 Scott Long
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_CAM_COMPAT_H
32 #define _CAM_CAM_COMPAT_H
34 /* No user-servicable parts in here. */
37 int cam_compat_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
38 struct thread *td, int(*cbfnp)(struct cdev *, u_long, caddr_t, int,
42 /* Version 0x16 compatibility */
43 #define CAM_VERSION_0x16 0x16
45 /* The size of the union ccb didn't change when going to 0x17 */
46 #define CAMIOCOMMAND_0x16 _IOWR(CAM_VERSION_0x16, 2, union ccb)
47 #define CAMGETPASSTHRU_0x16 _IOWR(CAM_VERSION_0x16, 3, union ccb)
49 #define CAM_SCATTER_VALID_0x16 0x00000010
50 #define CAM_SG_LIST_PHYS_0x16 0x00040000
51 #define CAM_DATA_PHYS_0x16 0x00200000
53 /* Version 0x17 compatibility */
54 #define CAM_VERSION_0x17 0x17
57 cam_pinfo pinfo; /* Info for priority scheduling */
58 camq_entry xpt_links; /* For chaining in the XPT layer */
59 camq_entry sim_links; /* For chaining in the SIM layer */
60 camq_entry periph_links; /* For chaining in the type driver */
61 u_int32_t retry_count;
62 void (*cbfcnp)(struct cam_periph *, union ccb *);
63 xpt_opcode func_code; /* XPT function code */
64 u_int32_t status; /* Status returned by CAM subsystem */
65 struct cam_path *path; /* Compiled path for this ccb */
66 path_id_t path_id; /* Path ID for the request */
67 target_id_t target_id; /* Target device ID */
68 lun_id_t target_lun; /* Target LUN number */
69 u_int32_t flags; /* ccb_flags */
70 ccb_ppriv_area periph_priv;
71 ccb_spriv_area sim_priv;
72 u_int32_t timeout; /* Hard timeout value in seconds */
73 struct callout_handle timeout_ch;
76 struct ccb_pathinq_0x17 {
77 struct ccb_hdr_0x17 ccb_h;
78 u_int8_t version_num; /* Version number for the SIM/HBA */
79 u_int8_t hba_inquiry; /* Mimic of INQ byte 7 for the HBA */
80 u_int8_t target_sprt; /* Flags for target mode support */
81 u_int8_t hba_misc; /* Misc HBA features */
82 u_int16_t hba_eng_cnt; /* HBA engine count */
83 /* Vendor Unique capabilities */
84 u_int8_t vuhba_flags[VUHBALEN];
85 u_int32_t max_target; /* Maximum supported Target */
86 u_int32_t max_lun; /* Maximum supported Lun */
87 u_int32_t async_flags; /* Installed Async handlers */
88 path_id_t hpath_id; /* Highest Path ID in the subsystem */
89 target_id_t initiator_id; /* ID of the HBA on the SCSI bus */
90 char sim_vid[SIM_IDLEN]; /* Vendor ID of the SIM */
91 char hba_vid[HBA_IDLEN]; /* Vendor ID of the HBA */
92 char dev_name[DEV_IDLEN];/* Device name for SIM */
93 u_int32_t unit_number; /* Unit number for SIM */
94 u_int32_t bus_id; /* Bus ID for SIM */
95 u_int32_t base_transfer_speed;/* Base bus speed in KB/sec */
97 u_int protocol_version;
99 u_int transport_version;
101 struct ccb_pathinq_settings_spi spi;
102 struct ccb_pathinq_settings_fc fc;
103 struct ccb_pathinq_settings_sas sas;
104 char ccb_pathinq_settings_opaque[PATHINQ_SETTINGS_SIZE];
106 u_int maxio; /* Max supported I/O size, in bytes. */
107 u_int16_t hba_vendor; /* HBA vendor ID */
108 u_int16_t hba_device; /* HBA device ID */
109 u_int16_t hba_subvendor; /* HBA subvendor ID */
110 u_int16_t hba_subdevice; /* HBA subdevice ID */
113 #define CAM_0X17_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr) + sizeof(struct ccb_hdr_0x17))
114 #define CAM_0X17_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr_0x17))
116 #define CAMIOCOMMAND_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 2, CAM_0X17_LEN)
117 #define CAMGETPASSTHRU_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 3, CAM_0X17_LEN)