FreeBSD kernel CAM code
scsi_ch.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/types.h>
#include <sys/malloc.h>
#include <sys/fcntl.h>
#include <sys/conf.h>
#include <sys/chio.h>
#include <sys/errno.h>
#include <sys/devicestat.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
#include <cam/scsi/scsi_ch.h>
Include dependency graph for scsi_ch.c:

Go to the source code of this file.

Data Structures

struct  scsi_mode_sense_data
 
struct  ch_softc
 

Macros

#define CH_Q_BIT_STRING
 
#define ccb_state   ppriv_field0
 
#define ccb_bp   ppriv_ptr1
 
#define PLURAL(c)   (c) == 1 ? "" : "s"
 

Enumerations

enum  ch_flags { CH_FLAG_INVALID = 0x001 }
 
enum  ch_state { CH_STATE_PROBE , CH_STATE_NORMAL }
 
enum  ch_ccb_types { CH_CCB_PROBE }
 
enum  ch_quirks { CH_Q_NONE = 0x00 , CH_Q_NO_DBD = 0x01 , CH_Q_NO_DVCID = 0x02 }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void chasync (void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
 
static void chdone (struct cam_periph *periph, union ccb *done_ccb)
 
static int cherror (union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 
static int chmove (struct cam_periph *periph, struct changer_move *cm)
 
static int chexchange (struct cam_periph *periph, struct changer_exchange *ce)
 
static int chposition (struct cam_periph *periph, struct changer_position *cp)
 
static int chgetelemstatus (struct cam_periph *periph, int scsi_version, u_long cmd, struct changer_element_status_request *csr)
 
static int chsetvoltag (struct cam_periph *periph, struct changer_set_voltag_request *csvr)
 
static int chielem (struct cam_periph *periph, unsigned int timeout)
 
static int chgetparams (struct cam_periph *periph)
 
static int chscsiversion (struct cam_periph *periph)
 
 PERIPHDRIVER_DECLARE (ch, chdriver)
 
static MALLOC_DEFINE (M_SCSICH, "scsi_ch", "scsi_ch buffers")
 
static void chdevgonecb (void *arg)
 
static void choninvalidate (struct cam_periph *periph)
 
static void chcleanup (struct cam_periph *periph)
 
static cam_status chregister (struct cam_periph *periph, void *arg)
 
static int chopen (struct cdev *dev, int flags, int fmt, struct thread *td)
 
static int chclose (struct cdev *dev, int flag, int fmt, struct thread *td)
 
static void chstart (struct cam_periph *periph, union ccb *start_ccb)
 
static int chioctl (struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 
static void copy_voltag (struct changer_voltag *uvoltag, struct volume_tag *voltag)
 
static void copy_element_status (struct ch_softc *softc, u_int16_t flags, struct read_element_status_descriptor *desc, struct changer_element_status *ces, int scsi_version)
 
void scsi_move_medium (struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int32_t tea, u_int32_t src, u_int32_t dst, int invert, u_int8_t sense_len, u_int32_t timeout)
 
void scsi_exchange_medium (struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int32_t tea, u_int32_t src, u_int32_t dst1, u_int32_t dst2, int invert1, int invert2, u_int8_t sense_len, u_int32_t timeout)
 
void scsi_position_to_element (struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int32_t tea, u_int32_t dst, int invert, u_int8_t sense_len, u_int32_t timeout)
 
void scsi_read_element_status (struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, int voltag, u_int32_t sea, int curdata, int dvcid, u_int32_t count, u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, u_int32_t timeout)
 
void scsi_initialize_element_status (struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int8_t sense_len, u_int32_t timeout)
 
void scsi_send_volume_tag (struct ccb_scsiio *csio, u_int32_t retries, void(*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int16_t element_address, u_int8_t send_action_code, struct scsi_send_volume_tag_parameters *parameters, u_int8_t sense_len, u_int32_t timeout)
 

Variables

static const u_int32_t CH_TIMEOUT_MODE_SENSE = 6000
 
static const u_int32_t CH_TIMEOUT_MOVE_MEDIUM = 15 * 60 * 1000
 
static const u_int32_t CH_TIMEOUT_EXCHANGE_MEDIUM = 15 * 60 * 1000
 
static const u_int32_t CH_TIMEOUT_POSITION_TO_ELEMENT = 15 * 60 * 1000
 
static const u_int32_t CH_TIMEOUT_READ_ELEMENT_STATUS = 5 * 60 * 1000
 
static const u_int32_t CH_TIMEOUT_SEND_VOLTAG = 10000
 
static const u_int32_t CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS = 500000
 
static d_open_t chopen
 
static d_close_t chclose
 
static d_ioctl_t chioctl
 
static periph_init_t chinit
 
static periph_ctor_t chregister
 
static periph_oninv_t choninvalidate
 
static periph_dtor_t chcleanup
 
static periph_start_t chstart
 
static struct periph_driver chdriver
 
static struct cdevsw ch_cdevsw
 

Macro Definition Documentation

◆ ccb_bp

#define ccb_bp   ppriv_ptr1

Definition at line 132 of file scsi_ch.c.

◆ ccb_state

#define ccb_state   ppriv_field0

Definition at line 131 of file scsi_ch.c.

◆ CH_Q_BIT_STRING

#define CH_Q_BIT_STRING
Value:
"\020" \
"\001NO_DBD" \
"\002NO_DVCID"

Definition at line 126 of file scsi_ch.c.

◆ PLURAL

#define PLURAL (   c)    (c) == 1 ? "" : "s"

Enumeration Type Documentation

◆ ch_ccb_types

Enumerator
CH_CCB_PROBE 

Definition at line 116 of file scsi_ch.c.

◆ ch_flags

enum ch_flags
Enumerator
CH_FLAG_INVALID 

Definition at line 107 of file scsi_ch.c.

◆ ch_quirks

enum ch_quirks
Enumerator
CH_Q_NONE 
CH_Q_NO_DBD 
CH_Q_NO_DVCID 

Definition at line 120 of file scsi_ch.c.

◆ ch_state

enum ch_state
Enumerator
CH_STATE_PROBE 
CH_STATE_NORMAL 

Definition at line 111 of file scsi_ch.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ chasync()

static void chasync ( void *  callback_arg,
u_int32_t  code,
struct cam_path path,
void *  arg 
)
static

Definition at line 319 of file scsi_ch.c.

References AC_FOUND_DEVICE, cam_periph_alloc(), cam_periph_async(), CAM_PERIPH_BIO, CAM_REQ_CMP, CAM_REQ_INPROG, chasync(), chcleanup, choninvalidate, chregister, chstart, ccb_getdev::inq_data, PROTO_SCSI, ccb_getdev::protocol, SID_QUAL, SID_QUAL_LU_CONNECTED, SID_TYPE, and T_CHANGER.

Referenced by chasync(), choninvalidate(), and chregister().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chcleanup()

static void chcleanup ( struct cam_periph periph)
static

Definition at line 307 of file scsi_ch.c.

References ch_softc::device_stats, and cam_periph::softc.

◆ chclose()

static int chclose ( struct cdev *  dev,
int  flag,
int  fmt,
struct thread *  td 
)
static

Definition at line 506 of file scsi_ch.c.

References cam_periph_mtx(), cam_periph_release_locked(), ch_softc::open_count, and cam_periph::softc.

Here is the call graph for this function:

◆ chdevgonecb()

static void chdevgonecb ( void *  arg)
static

Definition at line 245 of file scsi_ch.c.

References cam_periph_mtx(), cam_periph_release_locked(), ch_softc::open_count, and cam_periph::softc.

Referenced by choninvalidate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chdone()

◆ cherror()

static int cherror ( union ccb ccb,
u_int32_t  cam_flags,
u_int32_t  sense_flags 
)
static

Definition at line 735 of file scsi_ch.c.

References cam_periph_error().

Referenced by chdone(), chexchange(), chgetelemstatus(), chgetparams(), chielem(), chioctl(), chmove(), chposition(), and chsetvoltag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chexchange()

static int chexchange ( struct cam_periph periph,
struct changer_exchange *  ce 
)
static

◆ chgetelemstatus()

◆ chgetparams()

◆ chielem()

static int chielem ( struct cam_periph periph,
unsigned int  timeout 
)
static

◆ chioctl()

static int chioctl ( struct cdev *  dev,
u_long  cmd,
caddr_t  addr,
int  flag,
struct thread *  td 
)
static

◆ chmove()

static int chmove ( struct cam_periph periph,
struct changer_move *  cm 
)
static

◆ choninvalidate()

static void choninvalidate ( struct cam_periph periph)
static

Definition at line 286 of file scsi_ch.c.

References CH_FLAG_INVALID, chasync(), chdevgonecb(), ch_softc::dev, ch_softc::flags, cam_periph::path, cam_periph::softc, and xpt_register_async().

Here is the call graph for this function:

◆ chopen()

static int chopen ( struct cdev *  dev,
int  flags,
int  fmt,
struct thread *  td 
)
static

◆ chposition()

static int chposition ( struct cam_periph periph,
struct changer_position *  cp 
)
static

◆ chregister()

◆ chscsiversion()

static int chscsiversion ( struct cam_periph periph)
static

Definition at line 1699 of file scsi_ch.c.

References cam_periph_assert, CAM_PRIORITY_NORMAL, CAM_REQ_CMP, ccb_getdev::ccb_h, ccb_hdr::func_code, ccb_getdev::inq_data, cam_periph::path, ccb_hdr::status, scsi_inquiry_data::version, xpt_action(), xpt_alloc_ccb_nowait(), xpt_free_ccb(), XPT_GDEV_TYPE, and xpt_setup_ccb().

Referenced by chioctl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chsetvoltag()

◆ chstart()

static void chstart ( struct cam_periph periph,
union ccb start_ccb 
)
static

◆ copy_element_status()

static void copy_element_status ( struct ch_softc softc,
u_int16_t  flags,
struct read_element_status_descriptor desc,
struct changer_element_status *  ces,
int  scsi_version 
)
static

Definition at line 1049 of file scsi_ch.c.

References copy_voltag(), read_element_status_device_id::designator, read_element_status_device_id::designator_length, read_element_status_descriptor::devid, read_element_status_descriptor::dt_or_obsolete, read_element_status_descriptor::dt_scsi_addr, read_element_status_descriptor::dt_scsi_flags, read_element_status_descriptor::eaddr, read_element_status_descriptor::flags1, read_element_status_descriptor::flags2, read_element_status_device_id::piv_assoc_designator_type, read_element_status_device_id::prot_code_set, read_element_status_descriptor::pvol_and_devid, read_element_status_descriptor::pvoltag, READ_ELEMENT_STATUS_ASSOCIATION, READ_ELEMENT_STATUS_AVOLTAG, READ_ELEMENT_STATUS_CODE_SET, READ_ELEMENT_STATUS_DESIGNATOR_TYPE, READ_ELEMENT_STATUS_DT_IDVALID, READ_ELEMENT_STATUS_DT_LUNMASK, READ_ELEMENT_STATUS_DT_LUVALID, READ_ELEMENT_STATUS_INVERT, READ_ELEMENT_STATUS_PIV_SET, READ_ELEMENT_STATUS_PROTOCOL_ID, READ_ELEMENT_STATUS_PVOLTAG, READ_ELEMENT_STATUS_SVALID, ch_softc::sc_counts, ch_softc::sc_firsts, read_element_status_descriptor::scsi_2, scsi_2btoul(), SCSI_REV_2, SCSI_REV_SPC, read_element_status_descriptor::sense_code, read_element_status_descriptor::sense_qual, read_element_status_descriptor::ssea, read_element_status_descriptor::vol_tags_and_devid, read_element_status_descriptor::voltag, and read_element_status_descriptor::voltag_devid.

Referenced by chgetelemstatus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_voltag()

static void copy_voltag ( struct changer_voltag *  uvoltag,
struct volume_tag voltag 
)
static

Definition at line 1031 of file scsi_ch.c.

References scsi_2btoul(), volume_tag::vif, and volume_tag::vsn.

Referenced by copy_element_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_SCSICH  ,
"scsi_ch"  ,
"scsi_ch buffers"   
)
static

◆ PERIPHDRIVER_DECLARE()

PERIPHDRIVER_DECLARE ( ch  ,
chdriver   
)

◆ scsi_exchange_medium()

void scsi_exchange_medium ( struct ccb_scsiio csio,
u_int32_t  retries,
void(*)(struct cam_periph *, union ccb *)  cbfcnp,
u_int8_t  tag_action,
u_int32_t  tea,
u_int32_t  src,
u_int32_t  dst1,
u_int32_t  dst2,
int  invert1,
int  invert2,
u_int8_t  sense_len,
u_int32_t  timeout 
)

◆ scsi_initialize_element_status()

void scsi_initialize_element_status ( struct ccb_scsiio csio,
u_int32_t  retries,
void(*)(struct cam_periph *, union ccb *)  cbfcnp,
u_int8_t  tag_action,
u_int8_t  sense_len,
u_int32_t  timeout 
)

Definition at line 1870 of file scsi_ch.c.

References CAM_DIR_NONE, cam_fill_csio(), cdb_t::cdb_bytes, ccb_scsiio::cdb_io, INITIALIZE_ELEMENT_STATUS, and scsi_initialize_element_status::opcode.

Referenced by chielem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scsi_move_medium()

void scsi_move_medium ( struct ccb_scsiio csio,
u_int32_t  retries,
void(*)(struct cam_periph *, union ccb *)  cbfcnp,
u_int8_t  tag_action,
u_int32_t  tea,
u_int32_t  src,
u_int32_t  dst,
int  invert,
u_int8_t  sense_len,
u_int32_t  timeout 
)

Definition at line 1730 of file scsi_ch.c.

References CAM_DIR_NONE, cam_fill_csio(), cdb_t::cdb_bytes, ccb_scsiio::cdb_io, scsi_move_medium::dst, scsi_move_medium::invert, MOVE_MEDIUM, MOVE_MEDIUM_INVERT, scsi_move_medium::opcode, scsi_ulto2b(), scsi_move_medium::src, and scsi_move_medium::tea.

Referenced by chmove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scsi_position_to_element()

void scsi_position_to_element ( struct ccb_scsiio csio,
u_int32_t  retries,
void(*)(struct cam_periph *, union ccb *)  cbfcnp,
u_int8_t  tag_action,
u_int32_t  tea,
u_int32_t  dst,
int  invert,
u_int8_t  sense_len,
u_int32_t  timeout 
)

◆ scsi_read_element_status()

void scsi_read_element_status ( struct ccb_scsiio csio,
u_int32_t  retries,
void(*)(struct cam_periph *, union ccb *)  cbfcnp,
u_int8_t  tag_action,
int  voltag,
u_int32_t  sea,
int  curdata,
int  dvcid,
u_int32_t  count,
u_int8_t *  data_ptr,
u_int32_t  dxfer_len,
u_int8_t  sense_len,
u_int32_t  timeout 
)

◆ scsi_send_volume_tag()

void scsi_send_volume_tag ( struct ccb_scsiio csio,
u_int32_t  retries,
void(*)(struct cam_periph *, union ccb *)  cbfcnp,
u_int8_t  tag_action,
u_int16_t  element_address,
u_int8_t  send_action_code,
struct scsi_send_volume_tag_parameters parameters,
u_int8_t  sense_len,
u_int32_t  timeout 
)

Definition at line 1896 of file scsi_ch.c.

References CAM_DIR_OUT, cam_fill_csio(), cdb_t::cdb_bytes, ccb_scsiio::cdb_io, scsi_send_volume_tag::ea, scsi_send_volume_tag::opcode, scsi_send_volume_tag::pll, scsi_send_volume_tag::sac, scsi_ulto2b(), and SEND_VOLUME_TAG.

Referenced by chsetvoltag().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ ch_cdevsw

struct cdevsw ch_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_flags = D_TRACKCLOSE,
.d_open = chopen,
.d_close = chclose,
.d_ioctl = chioctl,
.d_name = "ch",
}
static d_ioctl_t chioctl
Definition: scsi_ch.c:180
static d_close_t chclose
Definition: scsi_ch.c:179
static d_open_t chopen
Definition: scsi_ch.c:178

Definition at line 216 of file scsi_ch.c.

Referenced by chregister().

◆ CH_TIMEOUT_EXCHANGE_MEDIUM

const u_int32_t CH_TIMEOUT_EXCHANGE_MEDIUM = 15 * 60 * 1000
static

Definition at line 101 of file scsi_ch.c.

Referenced by chexchange().

◆ CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS

const u_int32_t CH_TIMEOUT_INITIALIZE_ELEMENT_STATUS = 500000
static

Definition at line 105 of file scsi_ch.c.

Referenced by chielem().

◆ CH_TIMEOUT_MODE_SENSE

const u_int32_t CH_TIMEOUT_MODE_SENSE = 6000
static

Definition at line 99 of file scsi_ch.c.

Referenced by chgetparams(), and chstart().

◆ CH_TIMEOUT_MOVE_MEDIUM

const u_int32_t CH_TIMEOUT_MOVE_MEDIUM = 15 * 60 * 1000
static

Definition at line 100 of file scsi_ch.c.

Referenced by chmove().

◆ CH_TIMEOUT_POSITION_TO_ELEMENT

const u_int32_t CH_TIMEOUT_POSITION_TO_ELEMENT = 15 * 60 * 1000
static

Definition at line 102 of file scsi_ch.c.

Referenced by chposition().

◆ CH_TIMEOUT_READ_ELEMENT_STATUS

const u_int32_t CH_TIMEOUT_READ_ELEMENT_STATUS = 5 * 60 * 1000
static

Definition at line 103 of file scsi_ch.c.

Referenced by chgetelemstatus().

◆ CH_TIMEOUT_SEND_VOLTAG

const u_int32_t CH_TIMEOUT_SEND_VOLTAG = 10000
static

Definition at line 104 of file scsi_ch.c.

Referenced by chsetvoltag().

◆ chcleanup

periph_dtor_t chcleanup
static

Definition at line 184 of file scsi_ch.c.

Referenced by chasync().

◆ chclose

d_close_t chclose
static

Definition at line 179 of file scsi_ch.c.

◆ chdriver

struct periph_driver chdriver
static
Initial value:
=
{
chinit, "ch",
TAILQ_HEAD_INITIALIZER(chdriver.units), 0
}
static struct periph_driver chdriver
Definition: scsi_ch.c:208
static periph_init_t chinit
Definition: scsi_ch.c:181

Definition at line 208 of file scsi_ch.c.

◆ chinit

static void chinit ( void  )
static

Definition at line 181 of file scsi_ch.c.

◆ chioctl

d_ioctl_t chioctl
static

Definition at line 180 of file scsi_ch.c.

◆ choninvalidate

periph_oninv_t choninvalidate
static

Definition at line 183 of file scsi_ch.c.

Referenced by chasync().

◆ chopen

d_open_t chopen
static

Definition at line 178 of file scsi_ch.c.

◆ chregister

periph_ctor_t chregister
static

Definition at line 182 of file scsi_ch.c.

Referenced by chasync().

◆ chstart

periph_start_t chstart
static

Definition at line 185 of file scsi_ch.c.

Referenced by chasync().