2 * Copyright 2009 Scott Long
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. The name of the author may not be used to endorse or promote products
12 * derived from this software without specific prior written permission.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _CAM_CAM_XPT_INTERNAL_H
30 #define _CAM_CAM_XPT_INTERNAL_H 1
32 /* Forward Declarations */
37 typedef struct cam_ed * (*xpt_alloc_device_func)(struct cam_eb *bus,
38 struct cam_et *target,
40 typedef void (*xpt_release_device_func)(struct cam_ed *device);
41 typedef void (*xpt_action_func)(union ccb *start_ccb);
42 typedef void (*xpt_dev_async_func)(u_int32_t async_code,
44 struct cam_et *target,
45 struct cam_ed *device,
47 typedef void (*xpt_announce_periph_func)(struct cam_periph *periph);
50 xpt_alloc_device_func alloc_device;
51 xpt_release_device_func reldev;
52 xpt_action_func action;
53 xpt_dev_async_func async;
54 xpt_announce_periph_func announce;
58 * Structure for queueing a device in a run queue.
59 * There is one run queue for allocating new ccbs,
60 * and another for sending ccbs to the controller.
64 struct cam_ed *device;
68 * The CAM EDT (Existing Device Table) contains the device information for
69 * all devices for all busses in the system. The table contains a
70 * cam_ed structure for each device on the bus.
73 TAILQ_ENTRY(cam_ed) links;
74 struct cam_ed_qinfo alloc_ccb_entry;
75 struct cam_ed_qinfo send_ccb_entry;
76 struct cam_et *target;
80 * Queue of type drivers wanting to do
81 * work on this device.
83 struct cam_ccbq ccbq; /* Queue of pending ccbs */
84 struct async_list asyncs; /* Async callback info for this B/T/L */
85 struct periph_list periphs; /* All attached devices */
86 u_int generation; /* Generation number */
87 struct cam_periph *owner; /* Peripheral driver's ownership tag */
88 void *quirk; /* Oddities about this device */
92 u_int protocol_version;
94 u_int transport_version;
95 struct scsi_inquiry_data inq_data;
96 uint8_t *supported_vpds;
97 uint8_t supported_vpds_len;
98 struct ata_params ident_data;
99 u_int8_t inq_flags; /*
100 * Current settings for inquiry flags.
101 * This allows us to override settings
102 * like disconnection and tagged
103 * queuing for a device.
105 u_int8_t queue_flags; /* Queue flags from the control page */
106 u_int8_t serial_num_len;
107 u_int8_t *serial_num;
109 #define CAM_DEV_UNCONFIGURED 0x01
110 #define CAM_DEV_REL_TIMEOUT_PENDING 0x02
111 #define CAM_DEV_REL_ON_COMPLETE 0x04
112 #define CAM_DEV_REL_ON_QUEUE_EMPTY 0x08
113 #define CAM_DEV_RESIZE_QUEUE_NEEDED 0x10
114 #define CAM_DEV_TAG_AFTER_COUNT 0x20
115 #define CAM_DEV_INQUIRY_DATA_VALID 0x40
116 #define CAM_DEV_IN_DV 0x80
117 #define CAM_DEV_DV_HIT_BOTTOM 0x100
118 #define CAM_DEV_IDENTIFY_DATA_VALID 0x200
119 u_int32_t tag_delay_count;
120 #define CAM_TAG_DELAY_COUNT 5
121 u_int32_t tag_saved_openings;
123 struct callout callout;
127 * Each target is represented by an ET (Existing Target). These
128 * entries are created when a target is successfully probed with an
129 * identify, and removed when a device fails to respond after a number
130 * of retries, or a bus rescan finds the device missing.
133 TAILQ_HEAD(, cam_ed) ed_entries;
134 TAILQ_ENTRY(cam_et) links;
136 target_id_t target_id;
139 struct timeval last_reset;
141 struct scsi_report_luns_data *luns;
145 * Each bus is represented by an EB (Existing Bus). These entries
146 * are created by calls to xpt_bus_register and deleted by calls to
147 * xpt_bus_deregister.
150 TAILQ_HEAD(, cam_et) et_entries;
151 TAILQ_ENTRY(cam_eb) links;
154 struct timeval last_reset;
156 #define CAM_EB_RUNQ_SCHEDULED 0x01
160 struct xpt_xport *xport;
164 struct cam_periph *periph;
166 struct cam_et *target;
167 struct cam_ed *device;
170 struct xpt_xport * scsi_get_xport(void);
171 struct xpt_xport * ata_get_xport(void);
173 struct cam_ed * xpt_alloc_device(struct cam_eb *bus,
174 struct cam_et *target,
176 void xpt_acquire_device(struct cam_ed *device);
177 void xpt_release_device(struct cam_ed *device);
178 int xpt_schedule_dev(struct camq *queue, cam_pinfo *dev_pinfo,
179 u_int32_t new_priority);
180 u_int32_t xpt_dev_ccbq_resize(struct cam_path *path, int newopenings);
181 void xpt_start_tags(struct cam_path *path);
182 void xpt_stop_tags(struct cam_path *path);
184 MALLOC_DECLARE(M_CAMXPT);