FreeBSD kernel CAM code
cam_xpt_internal.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright 2009 Scott Long
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_CAM_XPT_INTERNAL_H
32#define _CAM_CAM_XPT_INTERNAL_H 1
33
34#include <sys/taskqueue.h>
35
36/* Forward Declarations */
37struct cam_eb;
38struct cam_et;
39struct cam_ed;
40
41typedef struct cam_ed * (*xpt_alloc_device_func)(struct cam_eb *bus,
42 struct cam_et *target,
43 lun_id_t lun_id);
44typedef void (*xpt_release_device_func)(struct cam_ed *device);
45typedef void (*xpt_action_func)(union ccb *start_ccb);
46typedef void (*xpt_dev_async_func)(u_int32_t async_code,
47 struct cam_eb *bus,
48 struct cam_et *target,
49 struct cam_ed *device,
50 void *async_arg);
51typedef void (*xpt_announce_periph_func)(struct cam_periph *periph);
52typedef void (*xpt_announce_periph_sbuf_func)(struct cam_periph *periph, struct sbuf *sbuf);
53
61};
62
63struct xpt_xport {
65 const char *name;
67};
68
69SET_DECLARE(cam_xpt_xport_set, struct xpt_xport);
70#define CAM_XPT_XPORT(data) \
71 DATA_SET(cam_xpt_xport_set, data)
72
73typedef void (*xpt_proto_announce_func)(struct cam_ed *);
74typedef void (*xpt_proto_announce_sbuf_func)(struct cam_ed *, struct sbuf *);
75typedef void (*xpt_proto_debug_out_func)(union ccb *);
76
83};
84
85struct xpt_proto {
87 const char *name;
89};
90
91SET_DECLARE(cam_xpt_proto_set, struct xpt_proto);
92#define CAM_XPT_PROTO(data) \
93 DATA_SET(cam_xpt_proto_set, data)
94
95/*
96 * The CAM EDT (Existing Device Table) contains the device information for
97 * all devices for all buses in the system. The table contains a
98 * cam_ed structure for each device on the bus.
99 */
100struct cam_ed {
103 struct cam_et *target;
104 struct cam_sim *sim;
106 struct cam_ccbq ccbq; /* Queue of pending ccbs */
107 struct async_list asyncs; /* Async callback info for this B/T/L */
108 struct periph_list periphs; /* All attached devices */
109 u_int generation; /* Generation number */
110 void *quirk; /* Oddities about this device */
111 u_int maxtags;
112 u_int mintags;
121 uint8_t *device_id;
122 uint32_t ext_inq_len;
123 uint8_t *ext_inq;
125 uint8_t *physpath; /* physical path string form */
126 uint32_t rcap_len;
127 uint8_t *rcap_buf;
128 struct ata_params ident_data;
130 u_int8_t inq_flags; /*
131 * Current settings for inquiry flags.
132 * This allows us to override settings
133 * like disconnection and tagged
134 * queuing for a device.
135 */
136 u_int8_t queue_flags; /* Queue flags from the control page */
138 u_int8_t *serial_num;
139 u_int32_t flags;
140#define CAM_DEV_UNCONFIGURED 0x01
141#define CAM_DEV_REL_TIMEOUT_PENDING 0x02
142#define CAM_DEV_REL_ON_COMPLETE 0x04
143#define CAM_DEV_REL_ON_QUEUE_EMPTY 0x08
144#define CAM_DEV_TAG_AFTER_COUNT 0x20
145#define CAM_DEV_INQUIRY_DATA_VALID 0x40
146#define CAM_DEV_IN_DV 0x80
147#define CAM_DEV_DV_HIT_BOTTOM 0x100
148#define CAM_DEV_IDENTIFY_DATA_VALID 0x200
150#define CAM_TAG_DELAY_COUNT 5
152 u_int32_t refcount;
154 STAILQ_ENTRY(cam_ed) highpowerq_entry;
155 struct mtx device_mtx;
157 struct nvme_controller_data *nvme_cdata;
158 struct nvme_namespace_data *nvme_data;
159};
160
161/*
162 * Each target is represented by an ET (Existing Target). These
163 * entries are created when a target is successfully probed with an
164 * identify, and removed when a device fails to respond after a number
165 * of retries, or a bus rescan finds the device missing.
166 */
167struct cam_et {
168 TAILQ_HEAD(, cam_ed) ed_entries;
170 struct cam_eb *bus;
172 u_int32_t refcount;
174 struct timeval last_reset;
175 u_int rpl_size;
177 struct mtx luns_mtx; /* Protection for luns field. */
178};
179
180/*
181 * Each bus is represented by an EB (Existing Bus). These entries
182 * are created by calls to xpt_bus_register and deleted by calls to
183 * xpt_bus_deregister.
184 */
185struct cam_eb {
186 TAILQ_HEAD(, cam_et) et_entries;
189 struct cam_sim *sim;
190 struct timeval last_reset;
191 u_int32_t flags;
192#define CAM_EB_RUNQ_SCHEDULED 0x01
193 u_int32_t refcount;
195 device_t parent_dev;
197 struct mtx eb_mtx; /* Bus topology mutex. */
198};
199
200struct cam_path {
202 struct cam_eb *bus;
203 struct cam_et *target;
204 struct cam_ed *device;
205};
206
207struct cam_ed * xpt_alloc_device(struct cam_eb *bus,
208 struct cam_et *target,
210void xpt_acquire_device(struct cam_ed *device);
211void xpt_release_device(struct cam_ed *device);
212u_int32_t xpt_dev_ccbq_resize(struct cam_path *path, int newopenings);
213void xpt_start_tags(struct cam_path *path);
214void xpt_stop_tags(struct cam_path *path);
215
217
218#endif
u_int path_id_t
Definition: cam.h:42
u_int target_id_t
Definition: cam.h:43
u_int64_t lun_id_t
Definition: cam.h:44
cam_proto
Definition: cam_ccb.h:276
cam_xport
Definition: cam_ccb.h:288
void xpt_acquire_device(struct cam_ed *device)
Definition: cam_xpt.c:4897
MALLOC_DECLARE(M_CAMXPT)
void xpt_start_tags(struct cam_path *path)
Definition: cam_xpt.c:5026
void xpt_release_device(struct cam_ed *device)
Definition: cam_xpt.c:4907
struct cam_ed *(* xpt_alloc_device_func)(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
void(* xpt_release_device_func)(struct cam_ed *device)
void(* xpt_announce_periph_sbuf_func)(struct cam_periph *periph, struct sbuf *sbuf)
SET_DECLARE(cam_xpt_xport_set, struct xpt_xport)
void(* xpt_proto_announce_func)(struct cam_ed *)
void xpt_stop_tags(struct cam_path *path)
Definition: cam_xpt.c:5057
void(* xpt_dev_async_func)(u_int32_t async_code, struct cam_eb *bus, struct cam_et *target, struct cam_ed *device, void *async_arg)
struct cam_ed * xpt_alloc_device(struct cam_eb *bus, struct cam_et *target, lun_id_t lun_id)
Definition: cam_xpt.c:4840
void(* xpt_proto_announce_sbuf_func)(struct cam_ed *, struct sbuf *)
void(* xpt_announce_periph_func)(struct cam_periph *periph)
void(* xpt_proto_debug_out_func)(union ccb *)
u_int32_t xpt_dev_ccbq_resize(struct cam_path *path, int newopenings)
Definition: cam_xpt.c:4958
void(* xpt_action_func)(union ccb *start_ccb)
struct timeval last_reset
u_int32_t refcount
path_id_t path_id
u_int generation
TAILQ_ENTRY(cam_eb) links
struct xpt_xport * xport
device_t parent_dev
struct cam_sim * sim
u_int32_t flags
struct mtx eb_mtx
TAILQ_HEAD(, cam_et) et_entries
uint8_t * supported_vpds
u_int protocol_version
struct cam_sim * sim
STAILQ_ENTRY(cam_ed) highpowerq_entry
uint8_t * ext_inq
uint8_t * rcap_buf
struct task device_destroy_task
u_int maxtags
uint8_t physpath_len
u_int32_t tag_delay_count
struct periph_list periphs
u_int8_t queue_flags
u_int generation
struct cam_ccbq ccbq
u_int8_t * serial_num
struct mtx device_mtx
cam_pinfo devq_entry
u_int mintags
uint8_t supported_vpds_len
struct cam_et * target
u_int8_t serial_num_len
lun_id_t lun_id
u_int8_t inq_flags
struct nvme_namespace_data * nvme_data
struct mmc_params mmc_ident_data
TAILQ_ENTRY(cam_ed) links
struct ata_params ident_data
uint8_t * device_id
struct async_list asyncs
uint32_t rcap_len
u_int transport_version
uint8_t * physpath
void * quirk
cam_proto protocol
struct nvme_controller_data * nvme_cdata
uint32_t ext_inq_len
struct callout callout
u_int32_t tag_saved_openings
uint32_t device_id_len
cam_xport transport
u_int32_t flags
struct scsi_inquiry_data inq_data
u_int32_t refcount
TAILQ_ENTRY(cam_et) links
u_int generation
struct timeval last_reset
struct mtx luns_mtx
u_int rpl_size
u_int32_t refcount
target_id_t target_id
struct scsi_report_luns_data * luns
TAILQ_HEAD(, cam_ed) ed_entries
struct cam_eb * bus
struct cam_ed * device
struct cam_et * target
struct cam_eb * bus
struct cam_periph * periph
Definition: cam.h:85
Definition: mmc.h:66
xpt_proto_announce_sbuf_func announce_sbuf
xpt_proto_announce_func denounce
xpt_proto_announce_func announce
xpt_proto_debug_out_func debug_out
xpt_proto_announce_sbuf_func denounce_sbuf
const char * name
struct xpt_proto_ops * ops
cam_proto proto
xpt_action_func action
xpt_release_device_func reldev
xpt_announce_periph_sbuf_func announce_sbuf
xpt_dev_async_func async
xpt_announce_periph_func announce
xpt_alloc_device_func alloc_device
cam_xport xport
struct xpt_xport_ops * ops
const char * name
Definition: cam_ccb.h:1345