FreeBSD kernel CAM code
cam_sim.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cam_sim
 

Macros

#define spriv_ptr0   sim_priv.entries[0].ptr
 
#define spriv_ptr1   sim_priv.entries[1].ptr
 
#define spriv_field0   sim_priv.entries[0].field
 
#define spriv_field1   sim_priv.entries[1].field
 

Typedefs

typedef void(* sim_action_func) (struct cam_sim *sim, union ccb *ccb)
 
typedef void(* sim_poll_func) (struct cam_sim *sim)
 

Functions

struct cam_devqcam_simq_alloc (u_int32_t max_sim_transactions)
 
void cam_simq_free (struct cam_devq *devq)
 
struct cam_simcam_sim_alloc (sim_action_func sim_action, sim_poll_func sim_poll, const char *sim_name, void *softc, u_int32_t unit, struct mtx *mtx, int max_dev_transactions, int max_tagged_dev_transactions, struct cam_devq *queue)
 allocate a new sim and fill in the details More...
 
struct cam_simcam_sim_alloc_dev (sim_action_func sim_action, sim_poll_func sim_poll, const char *sim_name, void *softc, device_t dev, struct mtx *mtx, int max_dev_transactions, int max_tagged_dev_transactions, struct cam_devq *queue)
 
void cam_sim_free (struct cam_sim *sim, int free_devq)
 frees up the sim More...
 
void cam_sim_hold (struct cam_sim *sim)
 
void cam_sim_release (struct cam_sim *sim)
 
void cam_sim_set_path (struct cam_sim *sim, u_int32_t path_id)
 
static __inline u_int32_t cam_sim_path (const struct cam_sim *sim)
 
static __inline const char * cam_sim_name (const struct cam_sim *sim)
 
static __inline void * cam_sim_softc (const struct cam_sim *sim)
 
static __inline u_int32_t cam_sim_unit (const struct cam_sim *sim)
 
static __inline u_int32_t cam_sim_bus (const struct cam_sim *sim)
 
static __inline bool cam_sim_pollable (const struct cam_sim *sim)
 

Macro Definition Documentation

◆ spriv_field0

#define spriv_field0   sim_priv.entries[0].field

Definition at line 84 of file cam_sim.h.

◆ spriv_field1

#define spriv_field1   sim_priv.entries[1].field

Definition at line 85 of file cam_sim.h.

◆ spriv_ptr0

#define spriv_ptr0   sim_priv.entries[0].ptr

Definition at line 82 of file cam_sim.h.

◆ spriv_ptr1

#define spriv_ptr1   sim_priv.entries[1].ptr

Definition at line 83 of file cam_sim.h.

Typedef Documentation

◆ sim_action_func

typedef void(* sim_action_func) (struct cam_sim *sim, union ccb *ccb)

Definition at line 50 of file cam_sim.h.

◆ sim_poll_func

typedef void(* sim_poll_func) (struct cam_sim *sim)

Definition at line 51 of file cam_sim.h.

Function Documentation

◆ cam_sim_alloc()

struct cam_sim * cam_sim_alloc ( sim_action_func  sim_action,
sim_poll_func  sim_poll,
const char *  sim_name,
void *  softc,
u_int32_t  unit,
struct mtx *  mtx,
int  max_dev_transactions,
int  max_tagged_dev_transactions,
struct cam_devq queue 
)

allocate a new sim and fill in the details

A Storage Interface Module (SIM) is the interface between CAM and hardware. SIM receives CCBs from CAM via sim_action callback and translates them into DMA or other hardware transactions. During system dumps, it can be polled with the sim_poll callback. CCB processing is terminated by calling xpt_done().

The mtx acts as a perimeter lock for the SIM. All calls into the SIM's sim_action are made with this lock held. It is also used to hold/release a SIM, managing its reference count. When the lock is NULL, the SIM is 100% responsible for locking (and the reference counting is done with a shared lock.

The cam_devq passed in (queue) is used to arbitrate the number of outstanding transactions to the SIM. For HBAs that have global limits shared between the different buses, the same devq should be specified for each bus attached to the SIM.

Parameters
sim_actionFunction to call to process CCBs
sim_pollFunction to poll the hardware for completions
sim_nameName of SIM class
softcSoftware context associated with the SIM
unitUnit number of SIM
mtxMutex to lock while interacting with the SIM, or NULL for a SIM that handle its own locking to enable multi queue support.
max_dev_transactionsMaximum number of concurrent untagged transactions possible
max_tagged_dev_transactionsMaximum number of concurrent tagged transactions possible.
queueThe cam_devq to use for this SIM.

Definition at line 103 of file cam_sim.c.

References cam_sim::bus_id, CAM_PATH_ANY, cam_sim::devq, cam_sim::flags, cam_sim::max_dev_openings, cam_sim::max_tagged_dev_openings, cam_sim::mtx, cam_sim::path_id, cam_sim::refcount, cam_sim::sim_action, cam_sim::sim_name, cam_sim::sim_poll, cam_sim::softc, and cam_sim::unit_number.

Referenced by cfcs_init(), mmc_cam_sim_alloc(), and xpt_init().

Here is the caller graph for this function:

◆ cam_sim_alloc_dev()

struct cam_sim * cam_sim_alloc_dev ( sim_action_func  sim_action,
sim_poll_func  sim_poll,
const char *  sim_name,
void *  softc,
device_t  dev,
struct mtx *  mtx,
int  max_dev_transactions,
int  max_tagged_dev_transactions,
struct cam_devq queue 
)

◆ cam_sim_bus()

static __inline u_int32_t cam_sim_bus ( const struct cam_sim sim)
static

Definition at line 133 of file cam_sim.h.

References cam_sim::bus_id.

Referenced by mmc_path_inq().

Here is the caller graph for this function:

◆ cam_sim_free()

void cam_sim_free ( struct cam_sim sim,
int  free_devq 
)

frees up the sim

Frees up the CAM sim and optionally the devq. If a mutex is associated with the sim, it must be locked on entry. It will remain locked on return.

This function will wait for all outstanding reference to the sim to clear before returning.

Parameters
simThe sim to free
free_devqFree the devq associated with the sim at creation.

Definition at line 144 of file cam_sim.c.

References cam_sim_free_mtx, cam_simq_free(), cam_sim::devq, cam_sim::mtx, and cam_sim::refcount.

Referenced by cfcs_init(), cfcs_shutdown(), mmc_cam_sim_alloc(), and mmc_cam_sim_free().

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

◆ cam_sim_hold()

void cam_sim_hold ( struct cam_sim sim)

Definition at line 193 of file cam_sim.c.

References cam_sim_free_mtx, cam_sim::mtx, and cam_sim::refcount.

Referenced by xpt_bus_register().

Here is the caller graph for this function:

◆ cam_sim_name()

static __inline const char * cam_sim_name ( const struct cam_sim sim)
static

Definition at line 115 of file cam_sim.h.

References cam_sim::sim_name.

Referenced by cfcs_action(), mmc_path_inq(), and mmccam_start_discovery().

Here is the caller graph for this function:

◆ cam_sim_path()

static __inline u_int32_t cam_sim_path ( const struct cam_sim sim)
static

Definition at line 109 of file cam_sim.h.

References cam_sim::path_id.

Referenced by cfcs_init(), cfcs_onoffline(), cfcs_shutdown(), mmc_cam_sim_free(), mmccam_start_discovery(), and sgioctl().

Here is the caller graph for this function:

◆ cam_sim_pollable()

static __inline bool cam_sim_pollable ( const struct cam_sim sim)
static

Definition at line 139 of file cam_sim.h.

References cam_sim::sim_poll.

Referenced by adaregister(), cam_periph_runccb(), daregister(), ndaregister(), sdda_add_part(), xpt_poll_setup(), xpt_pollwait(), and xpt_sim_poll().

Here is the caller graph for this function:

◆ cam_sim_release()

void cam_sim_release ( struct cam_sim sim)

Definition at line 172 of file cam_sim.c.

References cam_sim_free_mtx, cam_sim::mtx, and cam_sim::refcount.

Referenced by xpt_release_bus().

Here is the caller graph for this function:

◆ cam_sim_set_path()

void cam_sim_set_path ( struct cam_sim sim,
u_int32_t  path_id 
)

Definition at line 212 of file cam_sim.c.

References cam_sim::path_id.

◆ cam_sim_softc()

static __inline void * cam_sim_softc ( const struct cam_sim sim)
static

Definition at line 121 of file cam_sim.h.

References cam_sim::softc.

Referenced by cfcs_action(), mmc_cam_default_poll(), and mmc_cam_sim_default_action().

Here is the caller graph for this function:

◆ cam_sim_unit()

static __inline u_int32_t cam_sim_unit ( const struct cam_sim sim)
static

Definition at line 127 of file cam_sim.h.

References cam_sim::unit_number.

Referenced by mmc_path_inq().

Here is the caller graph for this function:

◆ cam_simq_alloc()

struct cam_devq * cam_simq_alloc ( u_int32_t  max_sim_transactions)

Definition at line 55 of file cam_sim.c.

References cam_devq_alloc().

Referenced by cfcs_init(), mmc_cam_sim_alloc(), and xpt_init().

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

◆ cam_simq_free()

void cam_simq_free ( struct cam_devq devq)

Definition at line 61 of file cam_sim.c.

References cam_devq_free().

Referenced by cam_sim_free(), cfcs_init(), mmc_cam_sim_alloc(), and mmc_cam_sim_free().

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