Lines Matching refs:bfregi

615 static int max_bfregs(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi)  in max_bfregs()  argument
617 return get_num_static_uars(dev, bfregi) * MLX5_NON_FP_BFREGS_PER_UAR; in max_bfregs()
621 struct mlx5_bfreg_info *bfregi) in num_med_bfreg() argument
625 n = max_bfregs(dev, bfregi) - bfregi->num_low_latency_bfregs - in num_med_bfreg()
632 struct mlx5_bfreg_info *bfregi) in first_med_bfreg() argument
634 return num_med_bfreg(dev, bfregi) ? 1 : -ENOMEM; in first_med_bfreg()
638 struct mlx5_bfreg_info *bfregi) in first_hi_bfreg() argument
642 med = num_med_bfreg(dev, bfregi); in first_hi_bfreg()
647 struct mlx5_bfreg_info *bfregi) in alloc_high_class_bfreg() argument
651 for (i = first_hi_bfreg(dev, bfregi); i < max_bfregs(dev, bfregi); i++) { in alloc_high_class_bfreg()
652 if (!bfregi->count[i]) { in alloc_high_class_bfreg()
653 bfregi->count[i]++; in alloc_high_class_bfreg()
662 struct mlx5_bfreg_info *bfregi) in alloc_med_class_bfreg() argument
664 int minidx = first_med_bfreg(dev, bfregi); in alloc_med_class_bfreg()
670 for (i = minidx; i < first_hi_bfreg(dev, bfregi); i++) { in alloc_med_class_bfreg()
671 if (bfregi->count[i] < bfregi->count[minidx]) in alloc_med_class_bfreg()
673 if (!bfregi->count[minidx]) in alloc_med_class_bfreg()
677 bfregi->count[minidx]++; in alloc_med_class_bfreg()
682 struct mlx5_bfreg_info *bfregi) in alloc_bfreg() argument
686 if (bfregi->lib_uar_dyn) in alloc_bfreg()
689 mutex_lock(&bfregi->lock); in alloc_bfreg()
690 if (bfregi->ver >= 2) { in alloc_bfreg()
691 bfregn = alloc_high_class_bfreg(dev, bfregi); in alloc_bfreg()
693 bfregn = alloc_med_class_bfreg(dev, bfregi); in alloc_bfreg()
699 bfregi->count[bfregn]++; in alloc_bfreg()
701 mutex_unlock(&bfregi->lock); in alloc_bfreg()
706 void mlx5_ib_free_bfreg(struct mlx5_ib_dev *dev, struct mlx5_bfreg_info *bfregi, int bfregn) in mlx5_ib_free_bfreg() argument
708 mutex_lock(&bfregi->lock); in mlx5_ib_free_bfreg()
709 bfregi->count[bfregn]--; in mlx5_ib_free_bfreg()
710 mutex_unlock(&bfregi->lock); in mlx5_ib_free_bfreg()
750 struct mlx5_bfreg_info *bfregi, u32 bfregn, in bfregn_to_uar_index() argument
757 if (bfregi->lib_uar_dyn) in bfregn_to_uar_index()
760 bfregs_per_sys_page = get_uars_per_sys_page(dev, bfregi->lib_uar_4k) * in bfregn_to_uar_index()
765 index_of_sys_page += bfregi->num_static_sys_pages; in bfregn_to_uar_index()
767 if (index_of_sys_page >= bfregi->num_sys_pages) in bfregn_to_uar_index()
770 if (bfregn > bfregi->num_dyn_bfregs || in bfregn_to_uar_index()
771 bfregi->sys_pages[index_of_sys_page] == MLX5_IB_INVALID_UAR_INDEX) { in bfregn_to_uar_index()
778 return bfregi->sys_pages[index_of_sys_page] + offset; in bfregn_to_uar_index()
884 struct mlx5_bfreg_info *bfregi, int bfregn) in adjust_bfregn() argument
921 uar_index = bfregn_to_uar_index(dev, &context->bfregi, in _create_user_qp()
930 bfregn = alloc_bfreg(dev, &context->bfregi); in _create_user_qp()
940 uar_index = bfregn_to_uar_index(dev, &context->bfregi, bfregn, in _create_user_qp()
983 resp->bfreg_index = adjust_bfregn(dev, &context->bfregi, bfregn); in _create_user_qp()
1004 mlx5_ib_free_bfreg(dev, &context->bfregi, bfregn); in _create_user_qp()
1024 mlx5_ib_free_bfreg(dev, &context->bfregi, qp->bfregn); in destroy_qp()