Lines Matching refs:rstruct

75 	ioat_rs_t *rstruct;  in ioat_rs_init()  local
84 rstruct = kmem_alloc(sizeof (ioat_rs_t), KM_SLEEP); in ioat_rs_init()
92 rstruct->rs_free_size = (max_val >> 6) * 8; in ioat_rs_init()
94 rstruct->rs_free_size = ((max_val >> 6) + 1) * 8; in ioat_rs_init()
96 rstruct->rs_free = kmem_alloc(rstruct->rs_free_size, KM_SLEEP); in ioat_rs_init()
99 rstruct->rs_min = min_val; in ioat_rs_init()
100 rstruct->rs_last = min_val; in ioat_rs_init()
101 rstruct->rs_max = max_val; in ioat_rs_init()
102 mutex_init(&rstruct->rs_mutex, NULL, MUTEX_DRIVER, in ioat_rs_init()
106 array_size = rstruct->rs_free_size >> 3; in ioat_rs_init()
108 rstruct->rs_free[index] = (uint64_t)0xFFFFFFFFFFFFFFFF; in ioat_rs_init()
112 *handle = rstruct; in ioat_rs_init()
125 ioat_rs_t *rstruct; in ioat_rs_fini() local
130 rstruct = (ioat_rs_t *)*handle; in ioat_rs_fini()
132 mutex_destroy(&rstruct->rs_mutex); in ioat_rs_fini()
133 kmem_free(rstruct->rs_free, rstruct->rs_free_size); in ioat_rs_fini()
134 kmem_free(rstruct, sizeof (ioat_rs_t)); in ioat_rs_fini()
148 ioat_rs_t *rstruct; in ioat_rs_alloc() local
160 rstruct = (ioat_rs_t *)handle; in ioat_rs_alloc()
162 mutex_enter(&rstruct->rs_mutex); in ioat_rs_alloc()
163 min = rstruct->rs_min; in ioat_rs_alloc()
164 max = rstruct->rs_max; in ioat_rs_alloc()
173 array_idx = rstruct->rs_last >> 6; in ioat_rs_alloc()
174 free = rstruct->rs_free[array_idx]; in ioat_rs_alloc()
175 last = rstruct->rs_last & 0x3F; in ioat_rs_alloc()
180 *resource = rstruct->rs_last; in ioat_rs_alloc()
183 rstruct->rs_free[array_idx] &= ~((uint64_t)1 << last); in ioat_rs_alloc()
190 rstruct->rs_last++; in ioat_rs_alloc()
191 if (rstruct->rs_last > max) { in ioat_rs_alloc()
192 rstruct->rs_last = rstruct->rs_min; in ioat_rs_alloc()
196 mutex_exit(&rstruct->rs_mutex); in ioat_rs_alloc()
205 rstruct->rs_last++; in ioat_rs_alloc()
206 if (rstruct->rs_last > max) { in ioat_rs_alloc()
207 rstruct->rs_last = rstruct->rs_min; in ioat_rs_alloc()
211 mutex_exit(&rstruct->rs_mutex); in ioat_rs_alloc()
225 ioat_rs_t *rstruct; in ioat_rs_free() local
232 rstruct = (ioat_rs_t *)handle; in ioat_rs_free()
233 ASSERT(resource >= rstruct->rs_min); in ioat_rs_free()
234 ASSERT(resource <= rstruct->rs_max); in ioat_rs_free()
236 mutex_enter(&rstruct->rs_mutex); in ioat_rs_free()
241 rstruct->rs_free[array_idx] |= ((uint64_t)1 << offset); in ioat_rs_free()
243 mutex_exit(&rstruct->rs_mutex); in ioat_rs_free()