PERFORCE change 160398 for review
Scott Long
scottl at FreeBSD.org
Wed Apr 8 21:56:09 PDT 2009
http://perforce.freebsd.org/chv.cgi?CH=160398
Change 160398 by scottl at scottl-deimos on 2009/04/09 04:55:48
Move a bunch of stuff from cam_xpt.h to cam_xpt_internal.h to keep
from complicating the headers. Add enough glue to get the scsi
transport fully compiling, bootstraped, and working.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#84 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#16 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_xpt.c#11 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#84 (text+ko) ====
@@ -61,6 +61,7 @@
#include <cam/cam_xpt.h>
#include <cam/cam_xpt_sim.h>
#include <cam/cam_xpt_periph.h>
+#include <cam/cam_xpt_internal.h>
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
@@ -207,10 +208,7 @@
static path_id_t xptnextfreepathid(void);
static path_id_t xptpathid(const char *sim_name, int sim_unit, int sim_bus);
static union ccb *xpt_get_ccb(struct cam_ed *device);
-static int xpt_schedule_dev(struct camq *queue, cam_pinfo *dev_pinfo,
- u_int32_t new_priority);
static void xpt_run_dev_allocq(struct cam_eb *bus);
-static void xpt_run_dev_sendq(struct cam_eb *bus);
static timeout_t xpt_release_devq_timeout;
static void xpt_release_simq_timeout(void *arg) __unused;
static void xpt_release_bus(struct cam_eb *bus);
@@ -221,7 +219,6 @@
static void xpt_release_target(struct cam_eb *bus, struct cam_et *target);
static void xpt_release_device(struct cam_eb *bus, struct cam_et *target,
struct cam_ed *device);
-static u_int32_t xpt_dev_ccbq_resize(struct cam_path *path, int newopenings);
static struct cam_eb*
xpt_find_bus(path_id_t path_id);
static struct cam_et*
@@ -284,8 +281,6 @@
static void xpt_start_tags(struct cam_path *path);
static __inline int xpt_schedule_dev_allocq(struct cam_eb *bus,
struct cam_ed *dev);
-static __inline int xpt_schedule_dev_sendq(struct cam_eb *bus,
- struct cam_ed *dev);
static __inline int periph_is_queued(struct cam_periph *periph);
static __inline int device_is_alloc_queued(struct cam_ed *device);
static __inline int device_is_send_queued(struct cam_ed *device);
@@ -319,27 +314,6 @@
}
static __inline int
-xpt_schedule_dev_sendq(struct cam_eb *bus, struct cam_ed *dev)
-{
- int retval;
-
- if (dev->ccbq.dev_openings > 0) {
- /*
- * The priority of a device waiting for controller
- * resources is that of the the highest priority CCB
- * enqueued.
- */
- retval =
- xpt_schedule_dev(&bus->sim->devq->send_queue,
- &dev->send_ccb_entry.pinfo,
- CAMQ_GET_HEAD(&dev->ccbq.queue)->priority);
- } else {
- retval = 0;
- }
- return (retval);
-}
-
-static __inline int
periph_is_queued(struct cam_periph *periph)
{
return (periph->pinfo.index != CAM_UNQUEUED_INDEX);
@@ -2406,7 +2380,7 @@
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("xpt_action\n"));
start_ccb->ccb_h.status = CAM_REQ_INPROG;
- (*(start_ccb->ccb_h.path->bus->xport->xpt_action_func))(start_ccb);
+ (*(start_ccb->ccb_h.path->bus->xport->action))(start_ccb);
}
void
@@ -3043,7 +3017,7 @@
* started the queue, return 0 so the caller doesn't attempt
* to run the queue.
*/
-static int
+int
xpt_schedule_dev(struct camq *queue, cam_pinfo *pinfo,
u_int32_t new_priority)
{
@@ -3152,7 +3126,7 @@
devq->alloc_queue.qfrozen_cnt--;
}
-static void
+void
xpt_run_dev_sendq(struct cam_eb *bus)
{
struct cam_devq *devq;
@@ -3401,7 +3375,7 @@
struct cam_ed *new_device;
new_device =
- (*(bus->xport->xpt_alloc_device))(bus,
+ (*(bus->xport->alloc_device))(bus,
target,
lun_id);
if (new_device == NULL) {
@@ -3701,6 +3675,8 @@
return (CAM_RESRC_UNAVAIL);
}
+ new_bus->xport = scsi_get_xport();
+
if (strcmp(sim->sim_name, "xpt") != 0) {
sim->path_id =
@@ -3890,9 +3866,9 @@
&& device->lun_id != CAM_LUN_WILDCARD)
continue;
- (*(bus->xport->xpt_dev_async_func))(async_code, bus,
- target, device,
- async_arg);
+ (*(bus->xport->async))(async_code, bus,
+ target, device,
+ async_arg);
xpt_async_bcast(&device->asyncs, async_code,
path, async_arg);
@@ -4333,7 +4309,7 @@
}
}
-static u_int32_t
+u_int32_t
xpt_dev_ccbq_resize(struct cam_path *path, int newopenings)
{
int diff;
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#16 (text+ko) ====
@@ -63,118 +63,6 @@
SLIST_HEAD(async_list, async_node);
SLIST_HEAD(periph_list, cam_periph);
-/*
- * Structure for queueing a device in a run queue.
- * There is one run queue for allocating new ccbs,
- * and another for sending ccbs to the controller.
- */
-struct cam_ed_qinfo {
- cam_pinfo pinfo;
- struct cam_ed *device;
-};
-
-/*
- * The CAM EDT (Existing Device Table) contains the device information for
- * all devices for all busses in the system. The table contains a
- * cam_ed structure for each device on the bus.
- */
-struct cam_ed {
- TAILQ_ENTRY(cam_ed) links;
- struct cam_ed_qinfo alloc_ccb_entry;
- struct cam_ed_qinfo send_ccb_entry;
- struct cam_et *target;
- struct cam_sim *sim;
- lun_id_t lun_id;
- struct camq drvq; /*
- * Queue of type drivers wanting to do
- * work on this device.
- */
- struct cam_ccbq ccbq; /* Queue of pending ccbs */
- struct async_list asyncs; /* Async callback info for this B/T/L */
- struct periph_list periphs; /* All attached devices */
- u_int generation; /* Generation number */
- struct cam_periph *owner; /* Peripheral driver's ownership tag */
- void *quirk; /* Oddities about this device */
- u_int maxtags;
- u_int mintags;
- cam_proto protocol;
- u_int protocol_version;
- cam_xport transport;
- u_int transport_version;
- struct scsi_inquiry_data inq_data;
- u_int8_t inq_flags; /*
- * Current settings for inquiry flags.
- * This allows us to override settings
- * like disconnection and tagged
- * queuing for a device.
- */
- u_int8_t queue_flags; /* Queue flags from the control page */
- u_int8_t serial_num_len;
- u_int8_t *serial_num;
- u_int32_t qfrozen_cnt;
- u_int32_t flags;
-#define CAM_DEV_UNCONFIGURED 0x01
-#define CAM_DEV_REL_TIMEOUT_PENDING 0x02
-#define CAM_DEV_REL_ON_COMPLETE 0x04
-#define CAM_DEV_REL_ON_QUEUE_EMPTY 0x08
-#define CAM_DEV_RESIZE_QUEUE_NEEDED 0x10
-#define CAM_DEV_TAG_AFTER_COUNT 0x20
-#define CAM_DEV_INQUIRY_DATA_VALID 0x40
-#define CAM_DEV_IN_DV 0x80
-#define CAM_DEV_DV_HIT_BOTTOM 0x100
- u_int32_t tag_delay_count;
-#define CAM_TAG_DELAY_COUNT 5
- u_int32_t tag_saved_openings;
- u_int32_t refcount;
- struct callout callout;
-};
-
-/*
- * Each target is represented by an ET (Existing Target). These
- * entries are created when a target is successfully probed with an
- * identify, and removed when a device fails to respond after a number
- * of retries, or a bus rescan finds the device missing.
- */
-struct cam_et {
- TAILQ_HEAD(, cam_ed) ed_entries;
- TAILQ_ENTRY(cam_et) links;
- struct cam_eb *bus;
- target_id_t target_id;
- u_int32_t refcount;
- u_int generation;
- struct timeval last_reset;
-};
-
-/*
- * Each bus is represented by an EB (Existing Bus). These entries
- * are created by calls to xpt_bus_register and deleted by calls to
- * xpt_bus_deregister.
- */
-struct cam_eb {
- TAILQ_HEAD(, cam_et) et_entries;
- TAILQ_ENTRY(cam_eb) links;
- path_id_t path_id;
- struct cam_sim *sim;
- struct timeval last_reset;
- u_int32_t flags;
-#define CAM_EB_RUNQ_SCHEDULED 0x01
- u_int32_t refcount;
- u_int generation;
- device_t parent_dev;
-};
-
-struct cam_path {
- struct cam_periph *periph;
- struct cam_eb *bus;
- struct cam_et *target;
- struct cam_ed *device;
-};
-
-typedef struct cam_ed * (*xpt_alloc_device_func)(struct cam_eb *bus,
- struct cam_et *target,
- lun_id_t lun_id);
-typedef void (*xpt_action_func)(union ccb *start_ccb);
-
#if defined(CAM_DEBUG_FLAGS) && !defined(CAMDEBUG)
#error "You must have options CAMDEBUG to use options CAM_DEBUG_FLAGS"
#endif
@@ -197,13 +85,8 @@
#endif /* CAMDEBUG */
#endif /* CAM_DEBUG_BUS || CAM_DEBUG_TARGET || CAM_DEBUG_LUN */
-MALLOC_DECLARE(M_CAMXPT);
-
void xpt_action(union ccb *new_ccb);
void xpt_action_default(union ccb *new_ccb);
-static struct cam_ed* xpt_alloc_device(struct cam_eb *bus,
- struct cam_et *target,
- lun_id_t lun_id);
void xpt_setup_ccb(struct ccb_hdr *ccb_h,
struct cam_path *path,
u_int32_t priority);
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_xpt.c#11 (text+ko) ====
@@ -59,6 +59,7 @@
#include <cam/cam_xpt.h>
#include <cam/cam_xpt_sim.h>
#include <cam/cam_xpt_periph.h>
+#include <cam/cam_xpt_internal.h>
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
@@ -550,6 +551,19 @@
struct cam_et *target,
struct cam_ed *device,
void *async_arg);
+static void scsi_action(union ccb *start_ccb);
+
+static struct xpt_xport scsi_xport = {
+ .alloc_device = scsi_alloc_device,
+ .action = scsi_action,
+ .async = scsi_dev_async,
+};
+
+struct xpt_xport *
+scsi_get_xport(void)
+{
+ return (&scsi_xport);
+}
static void
probe_periph_init()
More information about the p4-projects
mailing list