Lines Matching refs:bfregi
1594 struct mlx5_bfreg_info *bfregi) in calc_total_bfregs() argument
1616 bfregi->num_static_sys_pages = req->total_num_bfregs / bfregs_per_sys_page; in calc_total_bfregs()
1617 bfregi->num_dyn_bfregs = ALIGN(calc_dynamic_bfregs(uars_per_sys_page), bfregs_per_sys_page); in calc_total_bfregs()
1618 bfregi->total_num_bfregs = req->total_num_bfregs + bfregi->num_dyn_bfregs; in calc_total_bfregs()
1619 bfregi->num_sys_pages = bfregi->total_num_bfregs / bfregs_per_sys_page; in calc_total_bfregs()
1624 req->total_num_bfregs, bfregi->total_num_bfregs, in calc_total_bfregs()
1625 bfregi->num_sys_pages); in calc_total_bfregs()
1632 struct mlx5_bfreg_info *bfregi; in allocate_uars() local
1636 bfregi = &context->bfregi; in allocate_uars()
1637 for (i = 0; i < bfregi->num_static_sys_pages; i++) { in allocate_uars()
1638 err = mlx5_cmd_uar_alloc(dev->mdev, &bfregi->sys_pages[i], in allocate_uars()
1643 mlx5_ib_dbg(dev, "allocated uar %d\n", bfregi->sys_pages[i]); in allocate_uars()
1646 for (i = bfregi->num_static_sys_pages; i < bfregi->num_sys_pages; i++) in allocate_uars()
1647 bfregi->sys_pages[i] = MLX5_IB_INVALID_UAR_INDEX; in allocate_uars()
1653 if (mlx5_cmd_uar_dealloc(dev->mdev, bfregi->sys_pages[i], in allocate_uars()
1663 struct mlx5_bfreg_info *bfregi; in deallocate_uars() local
1666 bfregi = &context->bfregi; in deallocate_uars()
1667 for (i = 0; i < bfregi->num_sys_pages; i++) in deallocate_uars()
1668 if (i < bfregi->num_static_sys_pages || in deallocate_uars()
1669 bfregi->sys_pages[i] != MLX5_IB_INVALID_UAR_INDEX) in deallocate_uars()
1670 mlx5_cmd_uar_dealloc(dev->mdev, bfregi->sys_pages[i], in deallocate_uars()
1758 struct mlx5_bfreg_info *bfregi = &context->bfregi; in set_ucontext_resp() local
1786 resp->tot_bfregs = bfregi->lib_uar_dyn ? 0 : in set_ucontext_resp()
1787 bfregi->total_num_bfregs - bfregi->num_dyn_bfregs; in set_ucontext_resp()
1823 resp->num_dyn_bfregs = bfregi->num_dyn_bfregs; in set_ucontext_resp()
1842 struct mlx5_bfreg_info *bfregi; in mlx5_ib_alloc_ucontext() local
1884 bfregi = &context->bfregi; in mlx5_ib_alloc_ucontext()
1887 bfregi->lib_uar_dyn = lib_uar_dyn; in mlx5_ib_alloc_ucontext()
1892 err = calc_total_bfregs(dev, lib_uar_4k, &req, bfregi); in mlx5_ib_alloc_ucontext()
1896 mutex_init(&bfregi->lock); in mlx5_ib_alloc_ucontext()
1897 bfregi->lib_uar_4k = lib_uar_4k; in mlx5_ib_alloc_ucontext()
1898 bfregi->count = kcalloc(bfregi->total_num_bfregs, sizeof(*bfregi->count), in mlx5_ib_alloc_ucontext()
1900 if (!bfregi->count) { in mlx5_ib_alloc_ucontext()
1905 bfregi->sys_pages = kcalloc(bfregi->num_sys_pages, in mlx5_ib_alloc_ucontext()
1906 sizeof(*bfregi->sys_pages), in mlx5_ib_alloc_ucontext()
1908 if (!bfregi->sys_pages) { in mlx5_ib_alloc_ucontext()
1939 bfregi->ver = ver; in mlx5_ib_alloc_ucontext()
1940 bfregi->num_low_latency_bfregs = req.num_low_latency_bfregs; in mlx5_ib_alloc_ucontext()
1961 kfree(bfregi->sys_pages); in mlx5_ib_alloc_ucontext()
1964 kfree(bfregi->count); in mlx5_ib_alloc_ucontext()
2001 struct mlx5_bfreg_info *bfregi; in mlx5_ib_dealloc_ucontext() local
2003 bfregi = &context->bfregi; in mlx5_ib_dealloc_ucontext()
2007 kfree(bfregi->sys_pages); in mlx5_ib_dealloc_ucontext()
2008 kfree(bfregi->count); in mlx5_ib_dealloc_ucontext()
2132 struct mlx5_bfreg_info *bfregi = &context->bfregi; in uar_mmap() local
2140 int max_valid_idx = dyn_uar ? bfregi->num_sys_pages : in uar_mmap()
2141 bfregi->num_static_sys_pages; in uar_mmap()
2143 if (bfregi->lib_uar_dyn) in uar_mmap()
2150 idx = get_extended_index(vma->vm_pgoff) + bfregi->num_static_sys_pages; in uar_mmap()
2177 uars_per_page = get_uars_per_sys_page(dev, bfregi->lib_uar_4k); in uar_mmap()
2179 if (bfreg_dyn_idx >= bfregi->total_num_bfregs) { in uar_mmap()
2181 bfreg_dyn_idx, bfregi->total_num_bfregs); in uar_mmap()
2185 mutex_lock(&bfregi->lock); in uar_mmap()
2189 if (bfregi->count[bfreg_dyn_idx]) { in uar_mmap()
2191 mutex_unlock(&bfregi->lock); in uar_mmap()
2195 bfregi->count[bfreg_dyn_idx]++; in uar_mmap()
2196 mutex_unlock(&bfregi->lock); in uar_mmap()
2205 uar_index = bfregi->sys_pages[idx]; in uar_mmap()
2221 bfregi->sys_pages[idx] = uar_index; in uar_mmap()
2231 mlx5_ib_free_bfreg(dev, bfregi, bfreg_dyn_idx); in uar_mmap()