Lines Matching refs:bfregi

582 static int max_bfregs(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi)  in max_bfregs()  argument
584 return get_num_static_uars(dev, bfregi) * MLX5_NON_FP_BFREGS_PER_UAR; in max_bfregs()
588 struct mlx5_bfreg_info *bfregi) in num_med_bfreg() argument
592 n = max_bfregs(dev, bfregi) - bfregi->num_low_latency_bfregs - in num_med_bfreg()
599 struct mlx5_bfreg_info *bfregi) in first_med_bfreg() argument
601 return num_med_bfreg(dev, bfregi) ? 1 : -ENOMEM; in first_med_bfreg()
605 struct mlx5_bfreg_info *bfregi) in first_hi_bfreg() argument
609 med = num_med_bfreg(dev, bfregi); in first_hi_bfreg()
614 struct mlx5_bfreg_info *bfregi) in alloc_high_class_bfreg() argument
618 for (i = first_hi_bfreg(dev, bfregi); i < max_bfregs(dev, bfregi); i++) { in alloc_high_class_bfreg()
619 if (!bfregi->count[i]) { in alloc_high_class_bfreg()
620 bfregi->count[i]++; in alloc_high_class_bfreg()
629 struct mlx5_bfreg_info *bfregi) in alloc_med_class_bfreg() argument
631 int minidx = first_med_bfreg(dev, bfregi); in alloc_med_class_bfreg()
637 for (i = minidx; i < first_hi_bfreg(dev, bfregi); i++) { in alloc_med_class_bfreg()
638 if (bfregi->count[i] < bfregi->count[minidx]) in alloc_med_class_bfreg()
640 if (!bfregi->count[minidx]) in alloc_med_class_bfreg()
644 bfregi->count[minidx]++; in alloc_med_class_bfreg()
649 struct mlx5_bfreg_info *bfregi) in alloc_bfreg() argument
653 mutex_lock(&bfregi->lock); in alloc_bfreg()
654 if (bfregi->ver >= 2) { in alloc_bfreg()
655 bfregn = alloc_high_class_bfreg(dev, bfregi); in alloc_bfreg()
657 bfregn = alloc_med_class_bfreg(dev, bfregi); in alloc_bfreg()
663 bfregi->count[bfregn]++; in alloc_bfreg()
665 mutex_unlock(&bfregi->lock); in alloc_bfreg()
670 void mlx5_ib_free_bfreg(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi, int bfregn) in mlx5_ib_free_bfreg() argument
672 mutex_lock(&bfregi->lock); in mlx5_ib_free_bfreg()
673 bfregi->count[bfregn]--; in mlx5_ib_free_bfreg()
674 mutex_unlock(&bfregi->lock); in mlx5_ib_free_bfreg()
717 struct mlx5_bfreg_info *bfregi, u32 bfregn, in bfregn_to_uar_index() argument
724 bfregs_per_sys_page = get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * in bfregn_to_uar_index()
729 index_of_sys_page += bfregi->num_static_sys_pages; in bfregn_to_uar_index()
731 if (index_of_sys_page >= bfregi->num_sys_pages) in bfregn_to_uar_index()
734 if (bfregn > bfregi->num_dyn_bfregs || in bfregn_to_uar_index()
735 bfregi->sys_pages[index_of_sys_page] == MLX5_IB_INVALID_UAR_INDEX) { in bfregn_to_uar_index()
742 return bfregi->sys_pages[index_of_sys_page] + offset; in bfregn_to_uar_index()
849 struct mlx5_bfreg_info *bfregi, int bfregn) in adjust_bfregn() argument
885 uar_index = bfregn_to_uar_index(dev, &context->bfregi, in create_user_qp()
899 bfregn = alloc_bfreg(dev, &context->bfregi); in create_user_qp()
906 uar_index = bfregn_to_uar_index(dev, &context->bfregi, bfregn, in create_user_qp()
950 resp->bfreg_index = adjust_bfregn(dev, &context->bfregi, bfregn); in create_user_qp()
981 mlx5_ib_free_bfreg(dev, &context->bfregi, bfregn); in create_user_qp()
1003 mlx5_ib_free_bfreg(dev, &context->bfregi, qp->bfregn); in destroy_qp_user()