Lines Matching +full:cam +full:- +full:0

1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
38 #include <cam/cam.h>
39 #include <cam/cam_ccb.h>
40 #include <cam/cam_queue.h>
41 #include <cam/cam_sim.h>
42 #include <cam/cam_xpt.h>
44 #define CAM_PATH_ANY (uint32_t)-1
46 static MALLOC_DEFINE(M_CAMSIM, "CAM SIM", "CAM SIM buffers");
49 MTX_SYSINIT(cam_sim_free_init, &cam_sim_free_mtx, "CAM SIM free lock", MTX_DEF);
54 return (cam_devq_alloc(/*size*/0, max_sim_transactions)); in cam_simq_alloc()
68 * A Storage Interface Module (SIM) is the interface between CAM and
69 * hardware. SIM receives CCBs from CAM via @p sim_action callback and
111 sim->sim_action = sim_action; in cam_sim_alloc()
112 sim->sim_poll = sim_poll; in cam_sim_alloc()
113 sim->sim_name = sim_name; in cam_sim_alloc()
114 sim->softc = softc; in cam_sim_alloc()
115 sim->path_id = CAM_PATH_ANY; in cam_sim_alloc()
116 sim->unit_number = unit; in cam_sim_alloc()
117 sim->bus_id = 0; /* set in xpt_bus_register */ in cam_sim_alloc()
118 sim->max_tagged_dev_openings = max_tagged_dev_transactions; in cam_sim_alloc()
119 sim->max_dev_openings = max_dev_transactions; in cam_sim_alloc()
120 sim->flags = 0; in cam_sim_alloc()
121 sim->refcount = 1; in cam_sim_alloc()
122 sim->devq = queue; in cam_sim_alloc()
123 sim->mtx = mtx; in cam_sim_alloc()
130 * Frees up the CAM @c sim and optionally the devq. If a mutex is associated
146 if (sim->mtx == NULL) { in cam_sim_free()
150 mtx = sim->mtx; in cam_sim_free()
153 KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); in cam_sim_free()
154 sim->refcount--; in cam_sim_free()
155 if (sim->refcount > 0) { in cam_sim_free()
156 error = msleep(sim, mtx, PRIBIO, "simfree", 0); in cam_sim_free()
157 KASSERT(error == 0, ("invalid error value for msleep(9)")); in cam_sim_free()
159 KASSERT(sim->refcount == 0, ("sim->refcount == 0")); in cam_sim_free()
160 if (mtx == &cam_sim_free_mtx) /* sim->mtx == NULL */ in cam_sim_free()
164 cam_simq_free(sim->devq); in cam_sim_free()
173 if (sim->mtx == NULL) in cam_sim_release()
175 else if (!mtx_owned(sim->mtx)) in cam_sim_release()
176 mtx = sim->mtx; in cam_sim_release()
181 KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); in cam_sim_release()
182 sim->refcount--; in cam_sim_release()
183 if (sim->refcount == 0) in cam_sim_release()
194 if (sim->mtx == NULL) in cam_sim_hold()
196 else if (!mtx_owned(sim->mtx)) in cam_sim_hold()
197 mtx = sim->mtx; in cam_sim_hold()
202 KASSERT(sim->refcount >= 1, ("sim->refcount >= 1")); in cam_sim_hold()
203 sim->refcount++; in cam_sim_hold()
211 sim->path_id = path_id; in cam_sim_set_path()