Lines Matching refs:page

57 	struct mlx4_db_page *page;  in __add_page()  local
64 page = malloc(sizeof *page + pp / 8); in __add_page()
65 if (!page) in __add_page()
68 if (mlx4_alloc_buf(&page->buf, ps, ps)) { in __add_page()
69 free(page); in __add_page()
73 page->num_db = pp; in __add_page()
74 page->use_cnt = 0; in __add_page()
76 page->free[i] = ~0; in __add_page()
78 page->prev = NULL; in __add_page()
79 page->next = context->db_list[type]; in __add_page()
80 context->db_list[type] = page; in __add_page()
81 if (page->next) in __add_page()
82 page->next->prev = page; in __add_page()
84 return page; in __add_page()
89 struct mlx4_db_page *page; in mlx4_alloc_db() local
95 for (page = context->db_list[type]; page; page = page->next) in mlx4_alloc_db()
96 if (page->use_cnt < page->num_db) in mlx4_alloc_db()
99 page = __add_page(context, type); in mlx4_alloc_db()
100 if (!page) in mlx4_alloc_db()
104 ++page->use_cnt; in mlx4_alloc_db()
106 for (i = 0; !page->free[i]; ++i) in mlx4_alloc_db()
109 j = ffsl(page->free[i]); in mlx4_alloc_db()
110 page->free[i] &= ~(1UL << (j - 1)); in mlx4_alloc_db()
111 db = page->buf.buf + (i * 8 * sizeof (long) + (j - 1)) * db_size[type]; in mlx4_alloc_db()
121 struct mlx4_db_page *page; in mlx4_free_db() local
127 for (page = context->db_list[type]; page; page = page->next) in mlx4_free_db()
128 if (((uintptr_t) db & ~(ps - 1)) == (uintptr_t) page->buf.buf) in mlx4_free_db()
131 if (!page) in mlx4_free_db()
134 i = ((void *) db - page->buf.buf) / db_size[type]; in mlx4_free_db()
135 page->free[i / (8 * sizeof (long))] |= 1UL << (i % (8 * sizeof (long))); in mlx4_free_db()
137 if (!--page->use_cnt) { in mlx4_free_db()
138 if (page->prev) in mlx4_free_db()
139 page->prev->next = page->next; in mlx4_free_db()
141 context->db_list[type] = page->next; in mlx4_free_db()
142 if (page->next) in mlx4_free_db()
143 page->next->prev = page->prev; in mlx4_free_db()
145 mlx4_free_buf(&page->buf); in mlx4_free_db()
146 free(page); in mlx4_free_db()