FreeBSD kernel CAM code
scsi_pass.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/types.h>
#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/devicestat.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/poll.h>
#include <sys/selinfo.h>
#include <sys/sdt.h>
#include <sys/sysent.h>
#include <sys/taskqueue.h>
#include <vm/uma.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <machine/bus.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
#include <cam/cam_periph.h>
#include <cam/cam_queue.h>
#include <cam/cam_xpt.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
#include <cam/cam_compat.h>
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_pass.h>
Include dependency graph for scsi_pass.c:

Go to the source code of this file.

Data Structures

struct  pass_io_req
 
struct  pass_softc
 

Macros

#define ccb_type   ppriv_field0
 
#define ccb_ioreq   ppriv_ptr1
 
#define PASS_MAX_SEGS   16
 

Enumerations

enum  pass_flags {
  PASS_FLAG_OPEN = 0x01 , PASS_FLAG_LOCKED = 0x02 , PASS_FLAG_INVALID = 0x04 , PASS_FLAG_INITIAL_PHYSPATH = 0x08 ,
  PASS_FLAG_ZONE_INPROG = 0x10 , PASS_FLAG_ZONE_VALID = 0x20 , PASS_FLAG_UNMAPPED_CAPABLE = 0x40 , PASS_FLAG_ABANDONED_REF_SET = 0x80
}
 
enum  pass_state { PASS_STATE_NORMAL }
 
enum  pass_ccb_types { PASS_CCB_BUFFER_IO , PASS_CCB_QUEUED_IO }
 
enum  pass_io_flags { PASS_IO_NONE = 0x00 , PASS_IO_USER_SEG_MALLOC = 0x01 , PASS_IO_KERN_SEG_MALLOC = 0x02 , PASS_IO_ABANDONED = 0x04 }
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void passreadfiltdetach (struct knote *kn)
 
static int passreadfilt (struct knote *kn, long hint)
 
static void pass_shutdown_kqueue (void *context, int pending)
 
static void pass_add_physpath (void *context, int pending)
 
static void passasync (void *callback_arg, u_int32_t code, struct cam_path *path, void *arg)
 
static void passdone (struct cam_periph *periph, union ccb *done_ccb)
 
static int passcreatezone (struct cam_periph *periph)
 
static void passiocleanup (struct pass_softc *softc, struct pass_io_req *io_req)
 
static int passcopysglist (struct cam_periph *periph, struct pass_io_req *io_req, ccb_flags direction)
 
static int passmemsetup (struct cam_periph *periph, struct pass_io_req *io_req)
 
static int passmemdone (struct cam_periph *periph, struct pass_io_req *io_req)
 
static int passerror (union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 
static int passsendccb (struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
 
 PERIPHDRIVER_DECLARE (pass, passdriver)
 
static MALLOC_DEFINE (M_SCSIPASS, "scsi_pass", "scsi passthrough buffers")
 
static void passrejectios (struct cam_periph *periph)
 
static void passdevgonecb (void *arg)
 
static void passoninvalidate (struct cam_periph *periph)
 
static void passcleanup (struct cam_periph *periph)
 
static cam_status passregister (struct cam_periph *periph, void *arg)
 
static int passopen (struct cdev *dev, int flags, int fmt, struct thread *td)
 
static int passclose (struct cdev *dev, int flag, int fmt, struct thread *td)
 
static void passstart (struct cam_periph *periph, union ccb *start_ccb)
 
static int passioctl (struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 
static int passdoioctl (struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 
static int passpoll (struct cdev *dev, int poll_events, struct thread *td)
 
static int passkqfilter (struct cdev *dev, struct knote *kn)
 

Variables

static d_open_t passopen
 
static d_close_t passclose
 
static d_ioctl_t passioctl
 
static d_ioctl_t passdoioctl
 
static d_poll_t passpoll
 
static d_kqfilter_t passkqfilter
 
static periph_init_t passinit
 
static periph_ctor_t passregister
 
static periph_oninv_t passoninvalidate
 
static periph_dtor_t passcleanup
 
static periph_start_t passstart
 
static struct periph_driver passdriver
 
static struct cdevsw pass_cdevsw
 
static struct filterops passread_filtops
 

Macro Definition Documentation

◆ ccb_ioreq

#define ccb_ioreq   ppriv_ptr1

Definition at line 90 of file scsi_pass.c.

◆ ccb_type

#define ccb_type   ppriv_field0

Definition at line 89 of file scsi_pass.c.

◆ PASS_MAX_SEGS

#define PASS_MAX_SEGS   16

Definition at line 95 of file scsi_pass.c.

Enumeration Type Documentation

◆ pass_ccb_types

Enumerator
PASS_CCB_BUFFER_IO 
PASS_CCB_QUEUED_IO 

Definition at line 84 of file scsi_pass.c.

◆ pass_flags

enum pass_flags
Enumerator
PASS_FLAG_OPEN 
PASS_FLAG_LOCKED 
PASS_FLAG_INVALID 
PASS_FLAG_INITIAL_PHYSPATH 
PASS_FLAG_ZONE_INPROG 
PASS_FLAG_ZONE_VALID 
PASS_FLAG_UNMAPPED_CAPABLE 
PASS_FLAG_ABANDONED_REF_SET 

Definition at line 69 of file scsi_pass.c.

◆ pass_io_flags

Enumerator
PASS_IO_NONE 
PASS_IO_USER_SEG_MALLOC 
PASS_IO_KERN_SEG_MALLOC 
PASS_IO_ABANDONED 

Definition at line 97 of file scsi_pass.c.

◆ pass_state

enum pass_state
Enumerator
PASS_STATE_NORMAL 

Definition at line 80 of file scsi_pass.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_SCSIPASS  ,
"scsi_pass"  ,
"scsi passthrough buffers"   
)
static

◆ pass_add_physpath()

static void pass_add_physpath ( void *  context,
int  pending 
)
static

Definition at line 436 of file scsi_pass.c.

References pass_softc::alias_dev, CAM_PERIPH_INVALID, cam_periph_mtx(), cam_periph_release_locked(), pass_softc::dev, cam_periph::flags, pass_softc::flags, PASS_FLAG_INITIAL_PHYSPATH, cam_periph::path, cam_periph::softc, and xpt_getattr().

Referenced by passregister().

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

◆ pass_shutdown_kqueue()

static void pass_shutdown_kqueue ( void *  context,
int  pending 
)
static

Definition at line 418 of file scsi_pass.c.

References cam_periph_release(), pass_softc::read_select, and cam_periph::softc.

Referenced by passregister().

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

◆ passasync()

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

◆ passcleanup()

static void passcleanup ( struct cam_periph periph)
static

◆ passclose()

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

◆ passcopysglist()

static int passcopysglist ( struct cam_periph periph,
struct pass_io_req io_req,
ccb_flags  direction 
)
static

Definition at line 1214 of file scsi_pass.c.

References CAM_DIR_IN, pass_io_req::kern_segptr, pass_io_req::num_kern_segs, pass_io_req::num_user_segs, cam_periph::path, pass_io_req::user_segptr, and xpt_print().

Referenced by passmemdone(), and passmemsetup().

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

◆ passcreatezone()

static int passcreatezone ( struct cam_periph periph)
static

Definition at line 1036 of file scsi_pass.c.

References cam_periph_assert, cam_periph_lock, cam_periph_mtx(), cam_periph_unlock, pass_softc::flags, PASS_FLAG_ZONE_INPROG, PASS_FLAG_ZONE_VALID, cam_periph::path, cam_periph::softc, and xpt_print().

Referenced by passdoioctl().

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

◆ passdevgonecb()

static void passdevgonecb ( void *  arg)
static

Definition at line 287 of file scsi_pass.c.

References cam_periph_mtx(), cam_periph_release_locked(), pass_softc::open_count, passrejectios(), pass_softc::shutdown_kqueue_task, and cam_periph::softc.

Referenced by passoninvalidate().

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

◆ passdoioctl()

◆ passdone()

◆ passerror()

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

Definition at line 2249 of file scsi_pass.c.

References cam_periph_error().

Referenced by passdoioctl(), passdone(), and passsendccb().

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

◆ passiocleanup()

◆ passioctl()

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

Definition at line 1738 of file scsi_pass.c.

References cam_compat_ioctl(), pass_softc::dev, and passdoioctl.

Here is the call graph for this function:

◆ passkqfilter()

static int passkqfilter ( struct cdev *  dev,
struct knote *  kn 
)
static

Definition at line 2121 of file scsi_pass.c.

References passread_filtops, and cam_periph::softc.

◆ passmemdone()

static int passmemdone ( struct cam_periph periph,
struct pass_io_req io_req 
)
static

◆ passmemsetup()

static int passmemsetup ( struct cam_periph periph,
struct pass_io_req io_req 
)
static

Definition at line 1280 of file scsi_pass.c.

References ccb::ataio, ccb_dev_advinfo::buf, ccb_dev_advinfo::bufsiz, CAM_DATA_BIO, CAM_DATA_MASK, CAM_DATA_PADDR, CAM_DATA_SG, CAM_DATA_SG_PADDR, CAM_DATA_VADDR, CAM_DIR_IN, CAM_DIR_MASK, CAM_DIR_NONE, CAM_DIR_OUT, cam_periph_assert, CAM_PERIPH_MAXMAPS, ccb, pass_io_req::ccb, ccb::ccb_h, ccb::cdai, ccb::cdm, ccb::csio, pass_io_req::data_flags, ccb_scsiio::data_ptr, ccb_ataio::data_ptr, ccb_nvmeio::data_ptr, pass_io_req::dirs, ccb_scsiio::dxfer_len, ccb_ataio::dxfer_len, ccb_nvmeio::dxfer_len, ccb_hdr::flags, pass_io_req::flags, ccb_hdr::func_code, pass_io_req::kern_bufs, pass_io_req::kern_segptr, pass_io_req::kern_segs, pass_io_req::lengths, ccb_dev_match::match_buf_len, ccb_dev_match::matches, pass_softc::maxio, pass_io_req::num_bufs, pass_io_req::num_kern_segs, pass_io_req::num_user_segs, ccb::nvmeio, PASS_IO_KERN_SEG_MALLOC, PASS_IO_USER_SEG_MALLOC, PASS_MAX_SEGS, passcopysglist(), passiocleanup(), cam_periph::path, ccb_dev_match::pattern_buf_len, ccb_dev_match::patterns, ccb_scsiio::sglist_cnt, ccb_nvmeio::sglist_cnt, ccb_smpio::smp_request, ccb_smpio::smp_request_len, ccb_smpio::smp_response, ccb_smpio::smp_response_len, ccb::smpio, cam_periph::softc, pass_io_req::user_bufs, pass_io_req::user_segptr, pass_io_req::user_segs, XPT_ATA_IO, XPT_CONT_TARGET_IO, XPT_DEV_ADVINFO, XPT_DEV_MATCH, XPT_NVME_ADMIN, XPT_NVME_IO, xpt_print(), XPT_SCSI_IO, and XPT_SMP_IO.

Referenced by passdoioctl().

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

◆ passoninvalidate()

static void passoninvalidate ( struct cam_periph periph)
static

Definition at line 337 of file scsi_pass.c.

References pass_softc::dev, pass_softc::flags, PASS_FLAG_INVALID, passasync(), passdevgonecb(), cam_periph::path, cam_periph::softc, and xpt_register_async().

Here is the call graph for this function:

◆ passopen()

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

◆ passpoll()

static int passpoll ( struct cdev *  dev,
int  poll_events,
struct thread *  td 
)
static

Definition at line 2096 of file scsi_pass.c.

References cam_periph_lock, cam_periph_unlock, and cam_periph::softc.

◆ passreadfilt()

static int passreadfilt ( struct knote *  kn,
long  hint 
)
static

Definition at line 2149 of file scsi_pass.c.

References cam_periph_assert, and cam_periph::softc.

◆ passreadfiltdetach()

static void passreadfiltdetach ( struct knote *  kn)
static

Definition at line 2137 of file scsi_pass.c.

References cam_periph::softc.

◆ passregister()

◆ passrejectios()

static void passrejectios ( struct cam_periph periph)
static

Definition at line 233 of file scsi_pass.c.

References cam_periph_doacquire(), pass_io_req::flags, pass_softc::flags, PASS_FLAG_ABANDONED_REF_SET, PASS_IO_ABANDONED, passiocleanup(), and cam_periph::softc.

Referenced by passdevgonecb().

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

◆ passsendccb()

◆ passstart()

◆ PERIPHDRIVER_DECLARE()

PERIPHDRIVER_DECLARE ( pass  ,
passdriver   
)

Variable Documentation

◆ pass_cdevsw

struct cdevsw pass_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_flags = D_TRACKCLOSE,
.d_open = passopen,
.d_close = passclose,
.d_ioctl = passioctl,
.d_poll = passpoll,
.d_kqfilter = passkqfilter,
.d_name = "pass",
}
static d_open_t passopen
Definition: scsi_pass.c:152
static d_close_t passclose
Definition: scsi_pass.c:153
static d_poll_t passpoll
Definition: scsi_pass.c:156
static d_ioctl_t passioctl
Definition: scsi_pass.c:154
static d_kqfilter_t passkqfilter
Definition: scsi_pass.c:157

Definition at line 195 of file scsi_pass.c.

Referenced by passregister().

◆ passcleanup

periph_dtor_t passcleanup
static

Definition at line 164 of file scsi_pass.c.

Referenced by passasync().

◆ passclose

d_close_t passclose
static

Definition at line 153 of file scsi_pass.c.

◆ passdoioctl

d_ioctl_t passdoioctl
static

Definition at line 155 of file scsi_pass.c.

Referenced by passioctl().

◆ passdriver

struct periph_driver passdriver
static
Initial value:
=
{
passinit, "pass",
TAILQ_HEAD_INITIALIZER(passdriver.units), 0
}
static periph_init_t passinit
Definition: scsi_pass.c:161
static struct periph_driver passdriver
Definition: scsi_pass.c:187

Definition at line 187 of file scsi_pass.c.

◆ passinit

static void passinit ( void  )
static

Definition at line 161 of file scsi_pass.c.

◆ passioctl

d_ioctl_t passioctl
static

Definition at line 154 of file scsi_pass.c.

◆ passkqfilter

d_kqfilter_t passkqfilter
static

Definition at line 157 of file scsi_pass.c.

◆ passoninvalidate

periph_oninv_t passoninvalidate
static

Definition at line 163 of file scsi_pass.c.

Referenced by passasync().

◆ passopen

d_open_t passopen
static

Definition at line 152 of file scsi_pass.c.

◆ passpoll

d_poll_t passpoll
static

Definition at line 156 of file scsi_pass.c.

◆ passread_filtops

struct filterops passread_filtops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = passreadfiltdetach,
.f_event = passreadfilt
}
static int passreadfilt(struct knote *kn, long hint)
Definition: scsi_pass.c:2149
static void passreadfiltdetach(struct knote *kn)
Definition: scsi_pass.c:2137

Definition at line 206 of file scsi_pass.c.

Referenced by passkqfilter().

◆ passregister

periph_ctor_t passregister
static

Definition at line 162 of file scsi_pass.c.

Referenced by passasync().

◆ passstart

periph_start_t passstart
static

Definition at line 165 of file scsi_pass.c.

Referenced by passasync().