Lines Matching refs:vmplp
54 vio_mblk_pool_t *vmplp;
65 vmplp = kmem_zalloc(sizeof (*vmplp), KM_SLEEP);
66 vmplp->quelen = num_mblks;
67 vmplp->quemask = num_mblks - 1; /* expects quelen is power-of-2 */
68 vmplp->mblk_size = mblk_size;
70 mutex_init(&vmplp->hlock, NULL, MUTEX_DRIVER,
72 mutex_init(&vmplp->tlock, NULL, MUTEX_DRIVER,
75 vmplp->basep = kmem_zalloc(num_mblks * sizeof (vio_mblk_t), KM_SLEEP);
77 vmplp->datap = kmem_zalloc(num_mblks * mblk_size, KM_SLEEP);
79 vmplp->datap = mblk_datap;
80 vmplp->flag |= VMPL_FLAG_CLIENT_DATA;
82 vmplp->nextp = NULL;
85 vmplp->quep = kmem_zalloc(vmplp->quelen *
87 vmplp->head = 0;
88 vmplp->tail = 0;
90 for (i = 0, datap = vmplp->datap; i < num_mblks; i++) {
92 vmp = &(vmplp->basep[i]);
93 vmp->vmplp = vmplp;
102 vmplp->tail = vmplp->head;
108 rv = vio_destroy_mblks(vmplp);
119 vmplp->quep[vmplp->tail] = vmp;
120 vmplp->tail = (vmplp->tail + 1) & vmplp->quemask;
125 *poolp = vmplp;
140 vio_destroy_mblks(vio_mblk_pool_t *vmplp)
148 if (vmplp == NULL)
156 if (vmplp->head == vmplp->tail) {
164 if (vmplp->head != vmplp->tail) {
168 num_mblks = vmplp->quelen;
175 * chunk through kmem_free(vmplp->datap).
177 vmplp->flag |= VMPL_FLAG_DESTROYING;
179 vmp = &(vmplp->basep[i]);
190 vmplp->flag &= ~(VMPL_FLAG_DESTROYING);
192 kmem_free(vmplp->basep, num_mblks * sizeof (vio_mblk_t));
193 if ((vmplp->flag & VMPL_FLAG_CLIENT_DATA) == 0) {
194 kmem_free(vmplp->datap, num_mblks * vmplp->mblk_size);
196 kmem_free(vmplp->quep, num_mblks * sizeof (vio_mblk_t *));
198 mutex_destroy(&vmplp->hlock);
199 mutex_destroy(&vmplp->tlock);
201 kmem_free(vmplp, sizeof (*vmplp));
211 vio_allocb(vio_mblk_pool_t *vmplp)
216 mutex_enter(&vmplp->hlock);
217 head = (vmplp->head + 1) & vmplp->quemask;
218 if (head != vmplp->tail) {
220 vmp = vmplp->quep[vmplp->head];
221 vmplp->head = head;
225 mutex_exit(&vmplp->hlock);
238 vio_mblk_pool_t *vmplp = vmp->vmplp;
240 if (vmplp->flag & VMPL_FLAG_DESTROYING) {
251 vmp->mp = desballoc(vmp->datap, vmplp->mblk_size,
255 mutex_enter(&vmplp->tlock);
256 vmplp->quep[vmplp->tail] = vmp;
257 vmplp->tail = (vmplp->tail + 1) & vmplp->quemask;
258 mutex_exit(&vmplp->tlock);
271 vio_clobber_pool(vio_mblk_pool_t *vmplp)
273 uint64_t num_mblks = vmplp->quelen;
277 mutex_enter(&vmplp->hlock);
278 mutex_enter(&vmplp->tlock);
280 vmp = &(vmplp->basep[i]);
284 ASSERT(vmplp->tail != vmplp->head);
285 vmplp->quep[vmplp->tail] = vmp;
286 vmplp->tail = (vmplp->tail + 1) & vmplp->quemask;
289 mutex_exit(&vmplp->tlock);
290 mutex_exit(&vmplp->hlock);