2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
1998-09-15 06:33:23 +00:00
|
|
|
* Data structures and definitions for SCSI Interface Modules (SIMs).
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 Justin T. Gibbs.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification, immediately at the beginning of the file.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1998-09-15 06:33:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CAM_CAM_SIM_H
|
|
|
|
#define _CAM_CAM_SIM_H 1
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
1998-09-15 06:33:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The sim driver creates a sim for each controller. The sim device
|
|
|
|
* queue is separately created in order to allow resource sharing between
|
|
|
|
* sims. For instance, a driver may create one sim for each channel of
|
|
|
|
* a multi-channel controller and use the same queue for each channel.
|
|
|
|
* In this way, the queue resources are shared across all the channels
|
|
|
|
* of the multi-channel controller.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct cam_sim;
|
|
|
|
struct cam_devq;
|
|
|
|
|
|
|
|
typedef void (*sim_action_func)(struct cam_sim *sim, union ccb *ccb);
|
|
|
|
typedef void (*sim_poll_func)(struct cam_sim *sim);
|
|
|
|
|
|
|
|
struct cam_devq * cam_simq_alloc(u_int32_t max_sim_transactions);
|
|
|
|
void cam_simq_free(struct cam_devq *devq);
|
|
|
|
|
|
|
|
struct cam_sim * cam_sim_alloc(sim_action_func sim_action,
|
|
|
|
sim_poll_func sim_poll,
|
2001-01-24 01:46:18 +00:00
|
|
|
const char *sim_name,
|
1998-09-15 06:33:23 +00:00
|
|
|
void *softc,
|
|
|
|
u_int32_t unit,
|
2007-04-15 08:49:19 +00:00
|
|
|
struct mtx *mtx,
|
Add a number of interrelated CAM feature enhancements and bug fixes.
NOTE: These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface. A make world is recommended.
camcontrol.[c8]:
- We now support two new commands, "tags" and "negotiate".
- The tags commands allows users to view the number of tagged
openings for a device as well as a number of other related
parameters, and it allows users to set tagged openings for
a device.
- The negotiate command allows users to enable and disable
disconnection and tagged queueing, set sync rates, offsets
and bus width. Note that not all of those features are
available for all controllers. Only the adv, ahc, and ncr
drivers fully support all of the features at this point.
Some cards do not allow the setting of sync rates, offsets and
the like, and some of the drivers don't have any facilities to
do so. Some drivers, like the adw driver, only support enabling
or disabling sync negotiation, but do not support setting sync
rates.
- new description in the camcontrol man page of how to format a disk
- cleanup of the camcontrol inquiry command
- add support in the 'devlist' command for skipping unconfigured devices if
-v was not specified on the command line.
- make use of the new base_transfer_speed in the path inquiry CCB.
- fix CCB bzero cases
cam_xpt.c, cam_sim.[ch], cam_ccb.h:
- new flags on many CCB function codes to designate whether they're
non-immediate, use a user-supplied CCB, and can only be passed from
userland programs via the xpt device. Use these flags in the transport
layer and pass driver to categorize CCBs.
- new flag in the transport layer device matching code for device nodes
that indicates whether a device is unconfigured
- bump the CAM version from 0x10 to 0x11
- Change the CAM ioctls to use the version as their group code, so we can
force users to recompile code even when the CCB size doesn't change.
- add + fill in a new value in the path inquiry CCB, base_transfer_speed.
Remove a corresponding field from the cam_sim structure, and add code to
every SIM to set this field to the proper value.
- Fix the set transfer settings code in the transport layer.
scsi_cd.c:
- make some variables volatile instead of just casting them in various
places
- fix a race condition in the changer code
- attach unless we get a "logical unit not supported" error. This should
fix all of the cases where people have devices that return weird errors
when they don't have media in the drive.
scsi_da.c:
- attach unless we get a "logical unit not supported" error
scsi_pass.c:
- for immediate CCBs, just malloc a CCB to send the user request in. This
gets rid of the 'held' count problem in camcontrol tags.
scsi_pass.h:
- change the CAM ioctls to use the CAM version as their group code.
adv driver:
- Allow changing the sync rate and offset separately.
adw driver
- Allow changing the sync rate and offset separately.
aha driver:
- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.
ahc driver:
- Allow setting offset and sync rate separately
bt driver:
- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.
NCR driver:
- Fix the ultra/ultra 2 negotiation bug
- allow setting both the sync rate and offset separately
Other HBA drivers:
- Put code in to set the base_transfer_speed field for
XPT_GET_TRAN_SETTINGS CCBs.
Reviewed by: gibbs, mjacob (isp), imp (aha)
1999-05-06 20:16:39 +00:00
|
|
|
int max_dev_transactions,
|
|
|
|
int max_tagged_dev_transactions,
|
1998-09-15 06:33:23 +00:00
|
|
|
struct cam_devq *queue);
|
|
|
|
void cam_sim_free(struct cam_sim *sim, int free_devq);
|
2008-12-16 16:57:33 +00:00
|
|
|
void cam_sim_hold(struct cam_sim *sim);
|
|
|
|
void cam_sim_release(struct cam_sim *sim);
|
1998-09-15 06:33:23 +00:00
|
|
|
|
|
|
|
/* Optional sim attributes may be set with these. */
|
|
|
|
void cam_sim_set_path(struct cam_sim *sim, u_int32_t path_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Convenience routines for accessing sim attributes. */
|
2001-01-24 01:46:18 +00:00
|
|
|
static __inline u_int32_t cam_sim_path(struct cam_sim *sim);
|
|
|
|
static __inline const char * cam_sim_name(struct cam_sim *sim);
|
|
|
|
static __inline void * cam_sim_softc(struct cam_sim *sim);
|
|
|
|
static __inline u_int32_t cam_sim_unit(struct cam_sim *sim);
|
|
|
|
static __inline u_int32_t cam_sim_bus(struct cam_sim *sim);
|
1998-09-15 06:33:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Generically useful offsets into the sim private area */
|
|
|
|
#define spriv_ptr0 sim_priv.entries[0].ptr
|
|
|
|
#define spriv_ptr1 sim_priv.entries[1].ptr
|
|
|
|
#define spriv_field0 sim_priv.entries[0].field
|
|
|
|
#define spriv_field1 sim_priv.entries[1].field
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The sim driver should not access anything directly from this
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
struct cam_sim {
|
|
|
|
sim_action_func sim_action;
|
|
|
|
sim_poll_func sim_poll;
|
2001-01-24 01:46:18 +00:00
|
|
|
const char *sim_name;
|
1998-09-15 06:33:23 +00:00
|
|
|
void *softc;
|
2007-04-15 08:49:19 +00:00
|
|
|
struct mtx *mtx;
|
2007-04-19 14:28:43 +00:00
|
|
|
TAILQ_HEAD(, ccb_hdr) sim_doneq;
|
|
|
|
TAILQ_ENTRY(cam_sim) links;
|
1998-09-15 06:33:23 +00:00
|
|
|
u_int32_t path_id;/* The Boot device may set this to 0? */
|
|
|
|
u_int32_t unit_number;
|
|
|
|
u_int32_t bus_id;
|
Add a number of interrelated CAM feature enhancements and bug fixes.
NOTE: These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface. A make world is recommended.
camcontrol.[c8]:
- We now support two new commands, "tags" and "negotiate".
- The tags commands allows users to view the number of tagged
openings for a device as well as a number of other related
parameters, and it allows users to set tagged openings for
a device.
- The negotiate command allows users to enable and disable
disconnection and tagged queueing, set sync rates, offsets
and bus width. Note that not all of those features are
available for all controllers. Only the adv, ahc, and ncr
drivers fully support all of the features at this point.
Some cards do not allow the setting of sync rates, offsets and
the like, and some of the drivers don't have any facilities to
do so. Some drivers, like the adw driver, only support enabling
or disabling sync negotiation, but do not support setting sync
rates.
- new description in the camcontrol man page of how to format a disk
- cleanup of the camcontrol inquiry command
- add support in the 'devlist' command for skipping unconfigured devices if
-v was not specified on the command line.
- make use of the new base_transfer_speed in the path inquiry CCB.
- fix CCB bzero cases
cam_xpt.c, cam_sim.[ch], cam_ccb.h:
- new flags on many CCB function codes to designate whether they're
non-immediate, use a user-supplied CCB, and can only be passed from
userland programs via the xpt device. Use these flags in the transport
layer and pass driver to categorize CCBs.
- new flag in the transport layer device matching code for device nodes
that indicates whether a device is unconfigured
- bump the CAM version from 0x10 to 0x11
- Change the CAM ioctls to use the version as their group code, so we can
force users to recompile code even when the CCB size doesn't change.
- add + fill in a new value in the path inquiry CCB, base_transfer_speed.
Remove a corresponding field from the cam_sim structure, and add code to
every SIM to set this field to the proper value.
- Fix the set transfer settings code in the transport layer.
scsi_cd.c:
- make some variables volatile instead of just casting them in various
places
- fix a race condition in the changer code
- attach unless we get a "logical unit not supported" error. This should
fix all of the cases where people have devices that return weird errors
when they don't have media in the drive.
scsi_da.c:
- attach unless we get a "logical unit not supported" error
scsi_pass.c:
- for immediate CCBs, just malloc a CCB to send the user request in. This
gets rid of the 'held' count problem in camcontrol tags.
scsi_pass.h:
- change the CAM ioctls to use the CAM version as their group code.
adv driver:
- Allow changing the sync rate and offset separately.
adw driver
- Allow changing the sync rate and offset separately.
aha driver:
- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.
ahc driver:
- Allow setting offset and sync rate separately
bt driver:
- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.
NCR driver:
- Fix the ultra/ultra 2 negotiation bug
- allow setting both the sync rate and offset separately
Other HBA drivers:
- Put code in to set the base_transfer_speed field for
XPT_GET_TRAN_SETTINGS CCBs.
Reviewed by: gibbs, mjacob (isp), imp (aha)
1999-05-06 20:16:39 +00:00
|
|
|
int max_tagged_dev_openings;
|
|
|
|
int max_dev_openings;
|
1998-09-15 06:33:23 +00:00
|
|
|
u_int32_t flags;
|
2007-04-15 08:49:19 +00:00
|
|
|
#define CAM_SIM_REL_TIMEOUT_PENDING 0x01
|
|
|
|
#define CAM_SIM_MPSAFE 0x02
|
2011-11-17 21:07:56 +00:00
|
|
|
#define CAM_SIM_ON_DONEQ 0x04
|
|
|
|
#define CAM_SIM_POLLED 0x08
|
2012-05-12 13:55:36 +00:00
|
|
|
#define CAM_SIM_BATCH 0x10
|
2007-04-15 08:49:19 +00:00
|
|
|
struct callout callout;
|
1998-09-15 06:33:23 +00:00
|
|
|
struct cam_devq *devq; /* Device Queue to use for this SIM */
|
2008-12-16 16:57:33 +00:00
|
|
|
int refcount; /* References to the SIM. */
|
2007-04-15 08:49:19 +00:00
|
|
|
|
2008-12-22 16:58:47 +00:00
|
|
|
/* "Pool" of inactive ccbs managed by xpt_get_ccb and xpt_release_ccb */
|
2007-04-15 08:49:19 +00:00
|
|
|
SLIST_HEAD(,ccb_hdr) ccb_freeq;
|
|
|
|
/*
|
|
|
|
* Maximum size of ccb pool. Modified as devices are added/removed
|
|
|
|
* or have their * opening counts changed.
|
|
|
|
*/
|
|
|
|
u_int max_ccbs;
|
|
|
|
/* Current count of allocated ccbs */
|
|
|
|
u_int ccb_count;
|
|
|
|
|
1998-09-15 06:33:23 +00:00
|
|
|
};
|
|
|
|
|
2007-04-15 08:49:19 +00:00
|
|
|
#define CAM_SIM_LOCK(sim) mtx_lock((sim)->mtx);
|
|
|
|
#define CAM_SIM_UNLOCK(sim) mtx_unlock((sim)->mtx);
|
|
|
|
|
1998-09-15 06:33:23 +00:00
|
|
|
static __inline u_int32_t
|
|
|
|
cam_sim_path(struct cam_sim *sim)
|
|
|
|
{
|
|
|
|
return (sim->path_id);
|
|
|
|
}
|
|
|
|
|
2001-01-24 01:46:18 +00:00
|
|
|
static __inline const char *
|
1998-09-15 06:33:23 +00:00
|
|
|
cam_sim_name(struct cam_sim *sim)
|
|
|
|
{
|
|
|
|
return (sim->sim_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline void *
|
|
|
|
cam_sim_softc(struct cam_sim *sim)
|
|
|
|
{
|
|
|
|
return (sim->softc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_int32_t
|
|
|
|
cam_sim_unit(struct cam_sim *sim)
|
|
|
|
{
|
|
|
|
return (sim->unit_number);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_int32_t
|
|
|
|
cam_sim_bus(struct cam_sim *sim)
|
|
|
|
{
|
|
|
|
return (sim->bus_id);
|
|
|
|
}
|
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#endif /* _KERNEL */
|
1998-09-15 06:33:23 +00:00
|
|
|
#endif /* _CAM_CAM_SIM_H */
|