FreeBSD kernel CAM code
cam_periph.h File Reference
#include <sys/queue.h>
#include <cam/cam_sim.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
#include <vm/uma.h>
#include <cam/cam_xpt.h>
#include <sys/module.h>
Include dependency graph for cam_periph.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  periph_driver
 
struct  cam_periph
 
struct  cam_periph_map_info
 

Macros

#define PERIPHDRIVER_DECLARE(name, driver)
 
#define CAM_PERIPH_DRV_EARLY   0x01
 
#define ppriv_ptr0   periph_priv.entries[0].ptr
 
#define ppriv_ptr1   periph_priv.entries[1].ptr
 
#define ppriv_field0   periph_priv.entries[0].field
 
#define ppriv_field1   periph_priv.entries[1].field
 
#define CAM_PERIPH_RUNNING   0x01
 
#define CAM_PERIPH_LOCKED   0x02
 
#define CAM_PERIPH_LOCK_WANTED   0x04
 
#define CAM_PERIPH_INVALID   0x08
 
#define CAM_PERIPH_NEW_DEV_FOUND   0x10
 
#define CAM_PERIPH_RECOVERY_INPROG   0x20
 
#define CAM_PERIPH_RUN_TASK   0x40
 
#define CAM_PERIPH_FREE   0x80
 
#define CAM_PERIPH_ANNOUNCED   0x100
 
#define CAM_PERIPH_RECOVERY_WAIT   0x200
 
#define CAM_PERIPH_RECOVERY_WAIT_FAILED   0x400
 
#define CAM_PERIPH_MAXMAPS   2
 
#define cam_periph_owned(periph)    mtx_owned(xpt_path_mtx((periph)->path))
 
#define cam_periph_lock(periph)    mtx_lock(xpt_path_mtx((periph)->path))
 
#define cam_periph_unlock(periph)    mtx_unlock(xpt_path_mtx((periph)->path))
 
#define cam_periph_assert(periph, what)    mtx_assert(xpt_path_mtx((periph)->path), (what))
 
#define cam_periph_sleep(periph, chan, priority, wmesg, timo)    xpt_path_sleep((periph)->path, (chan), (priority), (wmesg), (timo))
 
#define CAM_PERIPH_FOREACH(periph, driver)
 
#define CAM_PERIPH_PRINT(p, msg, args...)    printf("%s%d:" msg, (periph)->periph_name, (periph)->unit_number, ##args)
 

Typedefs

typedef void() periph_init_t(void)
 
typedef int() periph_deinit_t(void)
 
typedef void periph_start_t(struct cam_periph *periph, union ccb *start_ccb)
 
typedef cam_status periph_ctor_t(struct cam_periph *periph, void *arg)
 
typedef void periph_oninv_t(struct cam_periph *periph)
 
typedef void periph_dtor_t(struct cam_periph *periph)
 

Enumerations

enum  cam_periph_type { CAM_PERIPH_BIO }
 

Functions

void periphdriver_register (void *)
 
int periphdriver_unregister (void *)
 
void periphdriver_init (int level)
 
cam_status cam_periph_alloc (periph_ctor_t *periph_ctor, periph_oninv_t *periph_oninvalidate, periph_dtor_t *periph_dtor, periph_start_t *periph_start, char *name, cam_periph_type type, struct cam_path *, ac_callback_t *, ac_code, void *arg)
 
struct cam_periphcam_periph_find (struct cam_path *path, char *name)
 
int cam_periph_list (struct cam_path *, struct sbuf *)
 
int cam_periph_acquire (struct cam_periph *periph)
 
void cam_periph_doacquire (struct cam_periph *periph)
 
void cam_periph_release (struct cam_periph *periph)
 
void cam_periph_release_locked (struct cam_periph *periph)
 
void cam_periph_release_locked_buses (struct cam_periph *periph)
 
int cam_periph_hold (struct cam_periph *periph, int priority)
 
void cam_periph_unhold (struct cam_periph *periph)
 
void cam_periph_invalidate (struct cam_periph *periph)
 
int cam_periph_mapmem (union ccb *ccb, struct cam_periph_map_info *mapinfo, u_int maxmap)
 
void cam_periph_unmapmem (union ccb *ccb, struct cam_periph_map_info *mapinfo)
 
union ccbcam_periph_getccb (struct cam_periph *periph, u_int32_t priority)
 
int cam_periph_runccb (union ccb *ccb, int(*error_routine)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags), cam_flags camflags, u_int32_t sense_flags, struct devstat *ds)
 
int cam_periph_ioctl (struct cam_periph *periph, u_long cmd, caddr_t addr, int(*error_routine)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags))
 
void cam_freeze_devq (struct cam_path *path)
 
u_int32_t cam_release_devq (struct cam_path *path, u_int32_t relsim_flags, u_int32_t opening_reduction, u_int32_t arg, int getcount_only)
 
void cam_periph_async (struct cam_periph *periph, u_int32_t code, struct cam_path *path, void *arg)
 
void cam_periph_bus_settle (struct cam_periph *periph, u_int bus_settle_ms)
 
void cam_periph_freeze_after_event (struct cam_periph *periph, struct timeval *event_time, u_int duration_ms)
 
int cam_periph_error (union ccb *ccb, cam_flags camflags, u_int32_t sense_flags)
 
int cam_periph_invalidate_sysctl (SYSCTL_HANDLER_ARGS)
 
static __inline struct mtx * cam_periph_mtx (struct cam_periph *periph)
 
static struct cam_periphcam_periph_acquire_first (struct periph_driver *driver)
 
static struct cam_periphcam_periph_acquire_next (struct cam_periph *pperiph)
 

Variables

struct cam_periphxpt_periph
 
struct periph_driver ** periph_drivers
 

Macro Definition Documentation

◆ CAM_PERIPH_ANNOUNCED

#define CAM_PERIPH_ANNOUNCED   0x100

Definition at line 138 of file cam_periph.h.

◆ cam_periph_assert

#define cam_periph_assert (   periph,
  what 
)     mtx_assert(xpt_path_mtx((periph)->path), (what))

Definition at line 230 of file cam_periph.h.

◆ CAM_PERIPH_DRV_EARLY

#define CAM_PERIPH_DRV_EARLY   0x01

Definition at line 99 of file cam_periph.h.

◆ CAM_PERIPH_FOREACH

#define CAM_PERIPH_FOREACH (   periph,
  driver 
)
Value:
for ((periph) = cam_periph_acquire_first(driver); \
(periph) != NULL; \
(periph) = cam_periph_acquire_next(periph))
static struct cam_periph * cam_periph_acquire_next(struct cam_periph *pperiph)
Definition: cam_periph.h:252
static struct cam_periph * cam_periph_acquire_first(struct periph_driver *driver)
Definition: cam_periph.h:237

Definition at line 268 of file cam_periph.h.

◆ CAM_PERIPH_FREE

#define CAM_PERIPH_FREE   0x80

Definition at line 137 of file cam_periph.h.

◆ CAM_PERIPH_INVALID

#define CAM_PERIPH_INVALID   0x08

Definition at line 133 of file cam_periph.h.

◆ cam_periph_lock

#define cam_periph_lock (   periph)     mtx_lock(xpt_path_mtx((periph)->path))

Definition at line 224 of file cam_periph.h.

◆ CAM_PERIPH_LOCK_WANTED

#define CAM_PERIPH_LOCK_WANTED   0x04

Definition at line 132 of file cam_periph.h.

◆ CAM_PERIPH_LOCKED

#define CAM_PERIPH_LOCKED   0x02

Definition at line 131 of file cam_periph.h.

◆ CAM_PERIPH_MAXMAPS

#define CAM_PERIPH_MAXMAPS   2

Definition at line 155 of file cam_periph.h.

◆ CAM_PERIPH_NEW_DEV_FOUND

#define CAM_PERIPH_NEW_DEV_FOUND   0x10

Definition at line 134 of file cam_periph.h.

◆ cam_periph_owned

#define cam_periph_owned (   periph)     mtx_owned(xpt_path_mtx((periph)->path))

Definition at line 221 of file cam_periph.h.

◆ CAM_PERIPH_PRINT

#define CAM_PERIPH_PRINT (   p,
  msg,
  args... 
)     printf("%s%d:" msg, (periph)->periph_name, (periph)->unit_number, ##args)

Definition at line 273 of file cam_periph.h.

◆ CAM_PERIPH_RECOVERY_INPROG

#define CAM_PERIPH_RECOVERY_INPROG   0x20

Definition at line 135 of file cam_periph.h.

◆ CAM_PERIPH_RECOVERY_WAIT

#define CAM_PERIPH_RECOVERY_WAIT   0x200

Definition at line 139 of file cam_periph.h.

◆ CAM_PERIPH_RECOVERY_WAIT_FAILED

#define CAM_PERIPH_RECOVERY_WAIT_FAILED   0x400

Definition at line 140 of file cam_periph.h.

◆ CAM_PERIPH_RUN_TASK

#define CAM_PERIPH_RUN_TASK   0x40

Definition at line 136 of file cam_periph.h.

◆ CAM_PERIPH_RUNNING

#define CAM_PERIPH_RUNNING   0x01

Definition at line 130 of file cam_periph.h.

◆ cam_periph_sleep

#define cam_periph_sleep (   periph,
  chan,
  priority,
  wmesg,
  timo 
)     xpt_path_sleep((periph)->path, (chan), (priority), (wmesg), (timo))

Definition at line 233 of file cam_periph.h.

◆ cam_periph_unlock

#define cam_periph_unlock (   periph)     mtx_unlock(xpt_path_mtx((periph)->path))

Definition at line 227 of file cam_periph.h.

◆ PERIPHDRIVER_DECLARE

#define PERIPHDRIVER_DECLARE (   name,
  driver 
)
Value:
static int name ## _modevent(module_t mod, int type, void *data) \
{ \
switch (type) { \
case MOD_LOAD: \
periphdriver_register(data); \
break; \
case MOD_UNLOAD: \
return (periphdriver_unregister(data)); \
default: \
return EOPNOTSUPP; \
} \
return 0; \
} \
static moduledata_t name ## _mod = { \
#name, \
name ## _modevent, \
(void *)&driver \
}; \
DECLARE_MODULE(name, name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY); \
MODULE_DEPEND(name, cam, 1, 1, 1)
int periphdriver_unregister(void *)
Definition: cam_periph.c:152

Definition at line 59 of file cam_periph.h.

◆ ppriv_field0

#define ppriv_field0   periph_priv.entries[0].field

Definition at line 110 of file cam_periph.h.

◆ ppriv_field1

#define ppriv_field1   periph_priv.entries[1].field

Definition at line 111 of file cam_periph.h.

◆ ppriv_ptr0

#define ppriv_ptr0   periph_priv.entries[0].ptr

Definition at line 108 of file cam_periph.h.

◆ ppriv_ptr1

#define ppriv_ptr1   periph_priv.entries[1].ptr

Definition at line 109 of file cam_periph.h.

Typedef Documentation

◆ periph_ctor_t

typedef cam_status periph_ctor_t(struct cam_periph *periph, void *arg)

Definition at line 115 of file cam_periph.h.

◆ periph_deinit_t

typedef int() periph_deinit_t(void)

Definition at line 91 of file cam_periph.h.

◆ periph_dtor_t

typedef void periph_dtor_t(struct cam_periph *periph)

Definition at line 118 of file cam_periph.h.

◆ periph_init_t

typedef void() periph_init_t(void)

Definition at line 85 of file cam_periph.h.

◆ periph_oninv_t

typedef void periph_oninv_t(struct cam_periph *periph)

Definition at line 117 of file cam_periph.h.

◆ periph_start_t

typedef void periph_start_t(struct cam_periph *periph, union ccb *start_ccb)

Definition at line 113 of file cam_periph.h.

Enumeration Type Documentation

◆ cam_periph_type

Enumerator
CAM_PERIPH_BIO 

Definition at line 103 of file cam_periph.h.

Function Documentation

◆ cam_freeze_devq()

void cam_freeze_devq ( struct cam_path path)

Definition at line 1329 of file cam_periph.c.

References CAM_DEBUG, CAM_DEBUG_TRACE, CAM_DEV_QFREEZE, ccb_hdr::flags, ccb_hdr::func_code, ccb_hdr::path, xpt_action(), XPT_NOOP, and xpt_setup_ccb().

Referenced by cam_periph_freeze_after_event(), pmpdone(), pmpfreeze(), probestart(), and scsi_dev_async().

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

◆ cam_periph_acquire()

◆ cam_periph_acquire_first()

static struct cam_periph * cam_periph_acquire_first ( struct periph_driver driver)
inlinestatic

Definition at line 237 of file cam_periph.h.

References CAM_PERIPH_INVALID, cam_periph::flags, cam_periph::refcount, xpt_lock_buses(), and xpt_unlock_buses().

Here is the call graph for this function:

◆ cam_periph_acquire_next()

static struct cam_periph * cam_periph_acquire_next ( struct cam_periph pperiph)
inlinestatic

Definition at line 252 of file cam_periph.h.

References cam_periph_assert, CAM_PERIPH_INVALID, cam_periph_release(), cam_periph::flags, cam_periph::refcount, xpt_lock_buses(), and xpt_unlock_buses().

Here is the call graph for this function:

◆ cam_periph_alloc()

cam_status cam_periph_alloc ( periph_ctor_t periph_ctor,
periph_oninv_t periph_oninvalidate,
periph_dtor_t periph_dtor,
periph_start_t periph_start,
char *  name,
cam_periph_type  type,
struct cam_path path,
ac_callback_t ac_callback,
ac_code  code,
void *  arg 
)

◆ cam_periph_async()

void cam_periph_async ( struct cam_periph periph,
u_int32_t  code,
struct cam_path path,
void *  arg 
)

Definition at line 1471 of file cam_periph.c.

References AC_LOST_DEVICE, and cam_periph_invalidate().

Referenced by adaasync(), cdasync(), chasync(), daasync(), enc_async(), ndaasync(), passasync(), pmpasync(), ptasync(), saasync(), sddaasync(), and sgasync().

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

◆ cam_periph_bus_settle()

void cam_periph_bus_settle ( struct cam_periph periph,
u_int  bus_settle_ms 
)

◆ cam_periph_doacquire()

void cam_periph_doacquire ( struct cam_periph periph)

Definition at line 432 of file cam_periph.c.

References cam_periph::refcount, xpt_lock_buses(), and xpt_unlock_buses().

Referenced by passclose(), passrejectios(), probestart(), and xpt_run_allocq().

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

◆ cam_periph_error()

int cam_periph_error ( union ccb ccb,
cam_flags  camflags,
u_int32_t  sense_flags 
)

Definition at line 1864 of file cam_periph.c.

References AC_LOST_DEVICE, AC_UNIT_ATTENTION, CAM_ATA_STATUS_ERROR, CAM_AUTOSENSE_FAIL, CAM_BDR_SENT, CAM_BUSY, CAM_CMD_TIMEOUT, CAM_DATA_RUN_ERR, CAM_DEBUG_INFO, CAM_DEBUGGED, CAM_DEV_NOT_THERE, CAM_DEV_QFRZN, CAM_EPF_ALL, cam_error_print(), CAM_ESF_ALL, CAM_FUNC_NOTAVAIL, CAM_LUN_INVALID, CAM_LUN_WILDCARD, CAM_MSG_REJECT_REC, CAM_NO_HBA, CAM_PATH_INVALID, cam_periph_devctl_notify(), CAM_PERIPH_INVALID, CAM_PROVIDE_FAIL, cam_release_devq(), CAM_REQ_ABORTED, CAM_REQ_CMP, CAM_REQ_CMP_ERR, CAM_REQ_INVALID, CAM_REQ_TERMIO, CAM_REQ_TOO_BIG, CAM_REQUEUE_REQ, CAM_RESRC_UNAVAIL, CAM_RETRY_SELTO, CAM_SCSI_BUS_RESET, CAM_SCSI_STATUS_ERROR, CAM_SEL_TIMEOUT, CAM_SMP_STATUS_ERROR, CAM_STATUS_MASK, CAM_TID_INVALID, CAM_UA_ABORT, CAM_UA_TERMIO, CAM_UNCOR_PARITY, CAM_UNEXP_BUSFREE, CAM_UNREC_HBA_ERROR, camperiphscsistatuserror(), ccb, ccb::ccb_h, ccb::crcn, ccb_rescan::flags, cam_periph::flags, ccb_hdr::func_code, ccb_hdr::path, periph_busy_delay, periph_noresrc_delay, periph_selto_delay, RELSIM_RELEASE_AFTER_TIMEOUT, ccb_hdr::retry_count, SF_NO_PRINT, SF_NO_RETRY, SF_PRINT_ALWAYS, SSQ_LOST, SSQ_PRINT_SENSE, SSQ_RESCAN, SSQ_UA, ccb_hdr::status, xpt_action(), xpt_alloc_ccb_nowait(), xpt_async(), xpt_create_path(), xpt_free_path(), xpt_path_lun_id(), xpt_path_path_id(), xpt_path_periph(), xpt_path_target_id(), xpt_print(), xpt_rescan(), and XPT_SCAN_TGT.

Referenced by adaerror(), aprobedone(), camperiphdone(), cderror(), cherror(), dadump(), daerror(), enc_error(), ndadump(), ndaerror(), nvme_probe_done(), passerror(), pmpdone(), probedone(), pterror(), sadone(), saerror(), sddadump(), sddaerror(), and sgerror().

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

◆ cam_periph_find()

struct cam_periph * cam_periph_find ( struct cam_path path,
char *  name 
)

Definition at line 340 of file cam_periph.c.

References cam_periph_assert, cam_periph::path, periph_drivers, xpt_lock_buses(), xpt_path_comp(), and xpt_unlock_buses().

Referenced by ata_scan_lun(), cam_periph_alloc(), ctlfe_lun_enable(), ctlfe_offline(), ctlfe_online(), mmc_scan_lun(), nvme_scan_lun(), scsi_scan_lun(), targbhasync(), and targenable().

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

◆ cam_periph_freeze_after_event()

void cam_periph_freeze_after_event ( struct cam_periph periph,
struct timeval *  event_time,
u_int  duration_ms 
)

Definition at line 1496 of file cam_periph.c.

References cam_freeze_devq(), cam_release_devq(), cam_periph::path, and RELSIM_RELEASE_AFTER_TIMEOUT.

Referenced by cam_periph_bus_settle(), and proberegister().

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

◆ cam_periph_getccb()

◆ cam_periph_hold()

int cam_periph_hold ( struct cam_periph periph,
int  priority 
)

◆ cam_periph_invalidate()

◆ cam_periph_invalidate_sysctl()

int cam_periph_invalidate_sysctl ( SYSCTL_HANDLER_ARGS  )

Definition at line 2182 of file cam_periph.c.

References cam_periph_invalidate(), cam_periph_lock, and cam_periph_unlock.

Referenced by adasysctlinit(), dasysctlinit(), and ndasysctlinit().

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

◆ cam_periph_ioctl()

int cam_periph_ioctl ( struct cam_periph periph,
u_long  cmd,
caddr_t  addr,
int(*)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags)  error_routine 
)

◆ cam_periph_list()

int cam_periph_list ( struct cam_path path,
struct sbuf *  sb 
)

Definition at line 370 of file cam_periph.c.

References cam_periph::path, periph_drivers, cam_periph::periph_name, cam_periph::unit_number, xpt_lock_buses(), xpt_path_comp(), and xpt_unlock_buses().

Referenced by ses_elmdevname_callback().

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

◆ cam_periph_mapmem()

◆ cam_periph_mtx()

static __inline struct mtx * cam_periph_mtx ( struct cam_periph periph)
static

◆ cam_periph_release()

◆ cam_periph_release_locked()

◆ cam_periph_release_locked_buses()

void cam_periph_release_locked_buses ( struct cam_periph periph)

Definition at line 443 of file cam_periph.c.

References cam_periph_assert, camperiphfree(), and cam_periph::refcount.

Referenced by cam_periph_release_locked().

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

◆ cam_periph_runccb()

int cam_periph_runccb ( union ccb ccb,
int(*)(union ccb *ccb, cam_flags camflags, u_int32_t sense_flags)  error_routine,
cam_flags  camflags,
u_int32_t  sense_flags,
struct devstat *  ds 
)

◆ cam_periph_unhold()

void cam_periph_unhold ( struct cam_periph periph)

◆ cam_periph_unmapmem()

◆ cam_release_devq()

◆ periphdriver_init()

void periphdriver_init ( int  level)

Definition at line 184 of file cam_periph.c.

References CAM_PERIPH_DRV_EARLY, periph_driver::flags, periph_driver::init, initialized, and periph_drivers.

Referenced by xpt_config(), and xpt_finishconfig_task().

Here is the caller graph for this function:

◆ periphdriver_register()

void periphdriver_register ( void *  data)

Definition at line 115 of file cam_periph.c.

References CAM_PERIPH_DRV_EARLY, periph_driver::flags, periph_driver::init, initialized, nperiph_drivers, periph_drivers, xpt_lock_buses(), and xpt_unlock_buses().

Referenced by ctlfeinitialize().

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

◆ periphdriver_unregister()

int periphdriver_unregister ( void *  data)

Definition at line 152 of file cam_periph.c.

References CAM_PERIPH_DRV_EARLY, periph_driver::deinit, periph_driver::driver_name, periph_driver::flags, initialized, nperiph_drivers, periph_drivers, xpt_lock_buses(), and xpt_unlock_buses().

Referenced by ctlfeshutdown().

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

Variable Documentation

◆ periph_drivers

◆ xpt_periph

struct cam_periph* xpt_periph
extern

Definition at line 188 of file cam_xpt.c.

Referenced by xpt_async_process(), xptdoioctl(), and xptregister().