FreeBSD kernel CAM code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/sx.h>
#include <sys/sysent.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#include <machine/stdarg.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_debug.h>
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
#include <cam/scsi/scsi_enc.h>
#include <cam/scsi/scsi_enc_internal.h>
#include "opt_ses.h"
Go to the source code of this file.
Macros | |
#define | SAFTE_START 44 |
#define | SAFTE_END 50 |
#define | SAFTE_LEN SAFTE_END-SAFTE_START |
Functions | |
__FBSDID ("$FreeBSD$") | |
MALLOC_DEFINE (M_SCSIENC, "SCSI ENC", "SCSI ENC buffers") | |
static void | enc_async (void *, uint32_t, struct cam_path *, void *) |
static enctyp | enc_type (struct ccb_getdev *) |
SYSCTL_NODE (_kern_cam, OID_AUTO, enc, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "CAM Enclosure Services driver") | |
SYSCTL_INT (_kern_cam_enc, OID_AUTO, verbose, CTLFLAG_RWTUN, &enc_verbose, 0, "Enable verbose logging") | |
CTASSERT (nitems(elm_type_names) - 1==ELMTYP_LAST) | |
PERIPHDRIVER_DECLARE (enc, encdriver) | |
static void | enc_devgonecb (void *arg) |
static void | enc_oninvalidate (struct cam_periph *periph) |
static void | enc_dtor (struct cam_periph *periph) |
static int | enc_open (struct cdev *dev, int flags, int fmt, struct thread *td) |
static int | enc_close (struct cdev *dev, int flag, int fmt, struct thread *td) |
int | enc_error (union ccb *ccb, uint32_t cflags, uint32_t sflags) |
static int | enc_ioctl (struct cdev *dev, u_long cmd, caddr_t arg_addr, int flag, struct thread *td) |
int | enc_runcmd (struct enc_softc *enc, char *cdb, int cdbl, char *dptr, int *dlenp) |
void | enc_log (struct enc_softc *enc, const char *fmt,...) |
void | enc_update_request (enc_softc_t *enc, uint32_t action) |
Queue an update request for a given action, if needed. More... | |
static void | enc_fsm_step (enc_softc_t *enc) |
Invoke the handler of the highest priority pending state in the SES state machine. More... | |
static void | enc_status_updater (void *arg) |
static void | enc_daemon (void *arg) |
static int | enc_kproc_init (enc_softc_t *enc) |
static cam_status | enc_ctor (struct cam_periph *periph, void *arg) |
Variables | |
static d_open_t | enc_open |
static d_close_t | enc_close |
static d_ioctl_t | enc_ioctl |
static periph_init_t | enc_init |
static periph_ctor_t | enc_ctor |
static periph_oninv_t | enc_oninvalidate |
static periph_dtor_t | enc_dtor |
int | enc_verbose = 0 |
const char * | elm_type_names [] = ELM_TYPE_NAMES |
static struct periph_driver | encdriver |
static struct cdevsw | enc_cdevsw |
#define SAFTE_END 50 |
Definition at line 676 of file scsi_enc.c.
#define SAFTE_LEN SAFTE_END-SAFTE_START |
Definition at line 677 of file scsi_enc.c.
#define SAFTE_START 44 |
Definition at line 675 of file scsi_enc.c.
__FBSDID | ( | "$FreeBSD$" | ) |
CTASSERT | ( | nitems(elm_type_names) - | 1 = =ELMTYP_LAST | ) |
|
static |
Definition at line 214 of file scsi_enc.c.
References AC_FOUND_DEVICE, cam_periph_alloc(), cam_periph_async(), CAM_PERIPH_BIO, CAM_REQ_CMP, CAM_REQ_INPROG, enc_vec::device_found, enc_async(), enc_ctor, enc_dtor, ENC_FLAG_INITIALIZED, enc_softc::enc_flags, ENC_NONE, enc_oninvalidate, ENC_SEMB_SES, enc_type(), enc_softc::enc_type, enc_softc::enc_vec, encdriver, cam_periph::path, enc_softc::periph, PROTO_ATA, ccb_getdev::protocol, cam_periph::softc, xpt_lock_buses(), xpt_path_path_id(), and xpt_unlock_buses().
Referenced by enc_async(), enc_ctor(), and enc_oninvalidate().
|
static |
Definition at line 313 of file scsi_enc.c.
References cam_periph_mtx(), cam_periph_release_locked(), enc_softc::open_count, and cam_periph::softc.
|
static |
Definition at line 886 of file scsi_enc.c.
References AC_LOST_DEVICE, enc_softc::announce_buf, cam_periph_acquire(), cam_periph_lock, cam_periph_release_locked(), cam_periph_unlock, CAM_REQ_CMP, CAM_REQ_CMP_ERR, enc_softc::current_action, ENC_ANNOUNCE_SZ, enc_async(), enc_softc::enc_cache_lock, enc_cdevsw, enc_softc::enc_dev, enc_dtor, ENC_FLAG_INITIALIZED, enc_softc::enc_flags, ENC_FREE, enc_kproc_init(), ENC_MALLOCZ, ENC_NONE, enc_softc::enc_rootmount, ENC_SAFT, ENC_SEMB_SAFT, ENC_SEMB_SES, ENC_SES, ENC_SES_PASSTHROUGH, enc_type(), enc_softc::enc_type, ENC_UPDATE_INVALID, enc_softc::enc_vec, cam_periph::path, enc_softc::periph, cam_periph::periph_name, enc_vec::poll_status, safte_softc_init, ses_softc_init, cam_periph::softc, cam_periph::unit_number, xpt_announce_periph_sbuf(), xpt_print(), and xpt_register_async().
|
static |
Definition at line 825 of file scsi_enc.c.
References cam_periph_lock, cam_periph_release(), cam_periph_sleep, cam_periph_unlock, enc_softc::current_action, enc_softc::enc_daemon, ENC_FLAG_SHUTDOWN, enc_softc::enc_flags, enc_fsm_step(), enc_softc::enc_rootmount, enc_status_updater(), ENC_UPDATE_NONE, enc_softc::pending_actions, enc_softc::periph, and enc_softc::status_updater.
Referenced by enc_kproc_init().
|
static |
Definition at line 129 of file scsi_enc.c.
References cam_periph_mtx(), cam_periph_release_locked(), enc_softc::open_count, enc_softc::periph, and cam_periph::softc.
Referenced by enc_oninvalidate().
|
static |
Definition at line 198 of file scsi_enc.c.
References ENC_FREE, enc_softc::enc_rootmount, enc_softc::enc_vec, enc_softc::periph, cam_periph::softc, and enc_vec::softc_cleanup.
int enc_error | ( | union ccb * | ccb, |
uint32_t | cflags, | ||
uint32_t | sflags | ||
) |
Definition at line 346 of file scsi_enc.c.
References cam_periph_error().
Referenced by enc_ioctl(), enc_runcmd(), and ses_set_timed_completion().
|
static |
Invoke the handler of the highest priority pending state in the SES state machine.
enc | The SES instance invoking the state machine. |
Definition at line 756 of file scsi_enc.c.
References ccb::ataio, enc_fsm_state::buf_size, cam_periph_getccb(), cam_periph_lock, cam_periph_runccb(), cam_periph_unlock, CAM_PRIORITY_NORMAL, ccb, ccb::ccb_h, ccb::csio, enc_softc::current_action, enc_fsm_state::done, ccb_scsiio::dxfer_len, ccb_ataio::dxfer_len, ENC_CFLAGS, ENC_DLOG, ENC_FLAGS, ENC_FREE_AND_NULL, enc_softc::enc_fsm_states, enc_fsm_state::error, enc_fsm_state::fill, ccb_hdr::func_code, enc_softc::pending_actions, enc_softc::periph, ccb_scsiio::resid, ccb_ataio::resid, SF_QUIET_IR, XPT_ATA_IO, and xpt_release_ccb().
Referenced by enc_daemon().
|
static |
Definition at line 353 of file scsi_enc.c.
References encioc_string::bufsiz, CAM_DEBUG, CAM_DEBUG_TRACE, cam_periph_ioctl(), cam_periph_lock, cam_periph_unlock, encioc_elm_desc::elm_desc_len, encioc_element::elm_idx, encioc_elm_status::elm_idx, encioc_elm_desc::elm_idx, encioc_elm_devnames::elm_idx, enc_cache::elm_map, encioc_element::elm_subenc_id, encioc_element::elm_type, enc_element::elm_type, enc_softc::enc_cache, enc_softc::enc_cache_lock, enc_error(), ENC_FLAG_INITIALIZED, enc_softc::enc_flags, enc_cache::enc_status, enc_softc::enc_vec, ENCIOC_GETELMDESC, ENCIOC_GETELMDEVNAMES, ENCIOC_GETELMMAP, ENCIOC_GETELMSTAT, ENCIOC_GETENCID, ENCIOC_GETENCNAME, ENCIOC_GETENCSTAT, ENCIOC_GETNELM, ENCIOC_GETSTRING, ENCIOC_INIT, ENCIOC_SETELMSTAT, ENCIOC_SETENCSTAT, ENCIOC_SETSTRING, enc_vec::get_elm_desc, enc_vec::get_elm_devnames, enc_vec::get_elm_status, enc_vec::handle_string, enc_vec::init_enc, enc_cache::nelms, cam_periph::path, enc_softc::periph, enc_vec::set_elm_status, enc_vec::set_enc_status, cam_periph::softc, and enc_element::subenclosure.
|
static |
Definition at line 863 of file scsi_enc.c.
References cam_periph_acquire(), cam_periph_lock, cam_periph_mtx(), cam_periph_release(), cam_periph_unlock, enc_daemon(), enc_softc::enc_daemon, enc_softc::enc_vec, enc_softc::periph, enc_vec::poll_status, enc_softc::status_updater, and cam_periph::unit_number.
Referenced by enc_ctor().
void enc_log | ( | struct enc_softc * | enc, |
const char * | fmt, | ||
... | |||
) |
Definition at line 652 of file scsi_enc.c.
References enc_softc::periph, cam_periph::periph_name, and cam_periph::unit_number.
|
static |
Definition at line 167 of file scsi_enc.c.
References enc_async(), enc_softc::enc_daemon, enc_softc::enc_dev, enc_devgonecb(), ENC_FLAG_INVALID, ENC_FLAG_SHUTDOWN, enc_softc::enc_flags, enc_softc::enc_vec, cam_periph::path, enc_softc::periph, cam_periph::softc, enc_vec::softc_invalidate, enc_softc::status_updater, and xpt_register_async().
|
static |
Definition at line 279 of file scsi_enc.c.
References cam_periph_acquire(), cam_periph_lock, cam_periph_release_locked(), cam_periph_unlock, ENC_FLAG_INITIALIZED, ENC_FLAG_INVALID, enc_softc::enc_flags, enc_softc::open_count, enc_softc::periph, and cam_periph::softc.
int enc_runcmd | ( | struct enc_softc * | enc, |
char * | cdb, | ||
int | cdbl, | ||
char * | dptr, | ||
int * | dlenp | ||
) |
Definition at line 579 of file scsi_enc.c.
References ata_28bit_cmd(), ccb::ataio, CAM_DEBUG, CAM_DEBUG_SUBTRACE, CAM_DEBUG_TRACE, CAM_DIR_IN, CAM_DIR_NONE, CAM_DIR_OUT, cam_fill_ataio(), cam_fill_csio(), cam_periph_getccb(), cam_periph_runccb(), CAM_PRIORITY_NORMAL, ccb, ccb::ccb_h, cdb_t::cdb_bytes, ccb_scsiio::cdb_io, ccb::csio, ENC_CFLAGS, enc_error(), ENC_FLAGS, ENC_SEMB_SAFT, ENC_SEMB_SES, enc_softc::enc_type, ccb_hdr::func_code, IOCDBLEN, MSG_SIMPLE_Q_TAG, cam_periph::path, enc_softc::periph, READ_BUFFER, RECEIVE_DIAGNOSTIC, ccb_scsiio::resid, ccb_ataio::resid, SEND_DIAGNOSTIC, XPT_ATA_IO, and xpt_release_ccb().
Referenced by safte_init_enc(), and ses_handle_string().
|
static |
Definition at line 815 of file scsi_enc.c.
References enc_softc::enc_vec, and enc_vec::poll_status.
Referenced by enc_daemon().
|
static |
Definition at line 680 of file scsi_enc.c.
References ccb::cgd, ENC_NONE, ENC_SAFT, ENC_SEMB_SAFT, ENC_SEMB_SES, ENC_SES, ENC_SES_PASSTHROUGH, ccb_getdev::ident_data, ccb_getdev::inq_data, PROTO_SCSI, PROTO_SEMB, ccb_getdev::protocol, SAFTE_END, SAFTE_LEN, SAFTE_START, SID_ADDITIONAL_LENGTH, STRNCMP, and T_ENCLOSURE.
Referenced by enc_async(), and enc_ctor().
void enc_update_request | ( | enc_softc_t * | enc, |
uint32_t | action | ||
) |
Queue an update request for a given action, if needed.
enc | SES softc to queue the request for. |
action | Action requested. |
Definition at line 735 of file scsi_enc.c.
References enc_softc::current_action, enc_softc::enc_daemon, ENC_DLOG, ENC_UPDATE_NONE, and enc_softc::pending_actions.
Referenced by safte_fill_control_request(), safte_fill_read_buf_io(), safte_poll_status(), safte_process_config(), safte_process_control_request(), safte_set_elm_status(), safte_set_enc_status(), ses_device_found(), ses_poll_status(), ses_process_config(), ses_process_elm_addlstatus(), ses_process_elm_descs(), ses_process_status(), ses_set_elm_status(), ses_set_enc_status(), and ses_softc_init().
MALLOC_DEFINE | ( | M_SCSIENC | , |
"SCSI ENC" | , | ||
"SCSI ENC buffers" | |||
) |
PERIPHDRIVER_DECLARE | ( | enc | , |
encdriver | |||
) |
SYSCTL_INT | ( | _kern_cam_enc | , |
OID_AUTO | , | ||
verbose | , | ||
CTLFLAG_RWTUN | , | ||
& | enc_verbose, | ||
0 | , | ||
"Enable verbose logging" | |||
) |
SYSCTL_NODE | ( | _kern_cam | , |
OID_AUTO | , | ||
enc | , | ||
CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"CAM Enclosure Services driver" | |||
) |
const char* elm_type_names[] = ELM_TYPE_NAMES |
Definition at line 92 of file scsi_enc.c.
Referenced by ses_print_addl_data().
|
static |
Definition at line 102 of file scsi_enc.c.
Referenced by enc_ctor().
|
static |
Definition at line 71 of file scsi_enc.c.
|
static |
Definition at line 74 of file scsi_enc.c.
Referenced by enc_async().
|
static |
Definition at line 76 of file scsi_enc.c.
Referenced by enc_async(), and enc_ctor().
|
static |
Definition at line 73 of file scsi_enc.c.
|
static |
Definition at line 72 of file scsi_enc.c.
|
static |
Definition at line 75 of file scsi_enc.c.
Referenced by enc_async().
|
static |
Definition at line 70 of file scsi_enc.c.
int enc_verbose = 0 |
Definition at line 87 of file scsi_enc.c.
|
static |
Definition at line 95 of file scsi_enc.c.
Referenced by enc_async().