FreeBSD kernel CAM code
scsi_enc.c File Reference
#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"
Include dependency graph for scsi_enc.c:

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
 

Macro Definition Documentation

◆ SAFTE_END

#define SAFTE_END   50

Definition at line 676 of file scsi_enc.c.

◆ SAFTE_LEN

#define SAFTE_LEN   SAFTE_END-SAFTE_START

Definition at line 677 of file scsi_enc.c.

◆ SAFTE_START

#define SAFTE_START   44

Definition at line 675 of file scsi_enc.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ CTASSERT()

CTASSERT ( nitems(elm_type_names) -  1 = =ELMTYP_LAST)

◆ enc_async()

static void enc_async ( void *  callback_arg,
uint32_t  code,
struct cam_path path,
void *  arg 
)
static

◆ enc_close()

static int enc_close ( struct cdev *  dev,
int  flag,
int  fmt,
struct thread *  td 
)
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.

Here is the call graph for this function:

◆ enc_ctor()

◆ enc_daemon()

static void enc_daemon ( void *  arg)
static

◆ enc_devgonecb()

static void enc_devgonecb ( void *  arg)
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().

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

◆ enc_dtor()

static void enc_dtor ( struct cam_periph periph)
static

◆ enc_error()

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().

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

◆ enc_fsm_step()

static void enc_fsm_step ( enc_softc_t enc)
static

Invoke the handler of the highest priority pending state in the SES state machine.

Parameters
encThe 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().

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

◆ enc_ioctl()

◆ enc_kproc_init()

static int enc_kproc_init ( enc_softc_t enc)
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().

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

◆ enc_log()

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.

◆ enc_oninvalidate()

◆ enc_open()

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

◆ enc_runcmd()

◆ enc_status_updater()

static void enc_status_updater ( void *  arg)
static
Invariant
Called with cam_periph mutex held.

Definition at line 815 of file scsi_enc.c.

References enc_softc::enc_vec, and enc_vec::poll_status.

Referenced by enc_daemon().

Here is the caller graph for this function:

◆ enc_type()

static enctyp enc_type ( struct ccb_getdev cgd)
static

◆ enc_update_request()

void enc_update_request ( enc_softc_t enc,
uint32_t  action 
)

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_SCSIENC  ,
"SCSI ENC"  ,
"SCSI ENC buffers"   
)

◆ PERIPHDRIVER_DECLARE()

PERIPHDRIVER_DECLARE ( enc  ,
encdriver   
)

◆ SYSCTL_INT()

SYSCTL_INT ( _kern_cam_enc  ,
OID_AUTO  ,
verbose  ,
CTLFLAG_RWTUN  ,
enc_verbose,
,
"Enable verbose logging"   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( _kern_cam  ,
OID_AUTO  ,
enc  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
"CAM Enclosure Services driver"   
)

Variable Documentation

◆ elm_type_names

const char* elm_type_names[] = ELM_TYPE_NAMES

Definition at line 92 of file scsi_enc.c.

Referenced by ses_print_addl_data().

◆ enc_cdevsw

struct cdevsw enc_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_open = enc_open,
.d_close = enc_close,
.d_ioctl = enc_ioctl,
.d_name = "ses",
.d_flags = D_TRACKCLOSE,
}
static d_ioctl_t enc_ioctl
Definition: scsi_enc.c:72
static d_open_t enc_open
Definition: scsi_enc.c:70
static d_close_t enc_close
Definition: scsi_enc.c:71

Definition at line 102 of file scsi_enc.c.

Referenced by enc_ctor().

◆ enc_close

d_close_t enc_close
static

Definition at line 71 of file scsi_enc.c.

◆ enc_ctor

periph_ctor_t enc_ctor
static

Definition at line 74 of file scsi_enc.c.

Referenced by enc_async().

◆ enc_dtor

periph_dtor_t enc_dtor
static

Definition at line 76 of file scsi_enc.c.

Referenced by enc_async(), and enc_ctor().

◆ enc_init

static void enc_init ( void  )
static

Definition at line 73 of file scsi_enc.c.

◆ enc_ioctl

d_ioctl_t enc_ioctl
static

Definition at line 72 of file scsi_enc.c.

◆ enc_oninvalidate

periph_oninv_t enc_oninvalidate
static

Definition at line 75 of file scsi_enc.c.

Referenced by enc_async().

◆ enc_open

d_open_t enc_open
static

Definition at line 70 of file scsi_enc.c.

◆ enc_verbose

int enc_verbose = 0

Definition at line 87 of file scsi_enc.c.

◆ encdriver

struct periph_driver encdriver
static
Initial value:
= {
enc_init, "ses",
TAILQ_HEAD_INITIALIZER(encdriver.units), 0
}
static struct periph_driver encdriver
Definition: scsi_enc.c:95
static periph_init_t enc_init
Definition: scsi_enc.c:73

Definition at line 95 of file scsi_enc.c.

Referenced by enc_async().