Lines Matching refs:mhop
123 struct hns_roce_hem_mhop *mhop, in get_hem_table_config() argument
130 mhop->buf_chunk_size = 1 << (hr_dev->caps.qpc_buf_pg_sz in get_hem_table_config()
132 mhop->bt_chunk_size = 1 << (hr_dev->caps.qpc_ba_pg_sz in get_hem_table_config()
134 mhop->ba_l0_num = hr_dev->caps.qpc_bt_num; in get_hem_table_config()
135 mhop->hop_num = hr_dev->caps.qpc_hop_num; in get_hem_table_config()
138 mhop->buf_chunk_size = 1 << (hr_dev->caps.mpt_buf_pg_sz in get_hem_table_config()
140 mhop->bt_chunk_size = 1 << (hr_dev->caps.mpt_ba_pg_sz in get_hem_table_config()
142 mhop->ba_l0_num = hr_dev->caps.mpt_bt_num; in get_hem_table_config()
143 mhop->hop_num = hr_dev->caps.mpt_hop_num; in get_hem_table_config()
146 mhop->buf_chunk_size = 1 << (hr_dev->caps.cqc_buf_pg_sz in get_hem_table_config()
148 mhop->bt_chunk_size = 1 << (hr_dev->caps.cqc_ba_pg_sz in get_hem_table_config()
150 mhop->ba_l0_num = hr_dev->caps.cqc_bt_num; in get_hem_table_config()
151 mhop->hop_num = hr_dev->caps.cqc_hop_num; in get_hem_table_config()
154 mhop->buf_chunk_size = 1 << (hr_dev->caps.sccc_buf_pg_sz in get_hem_table_config()
156 mhop->bt_chunk_size = 1 << (hr_dev->caps.sccc_ba_pg_sz in get_hem_table_config()
158 mhop->ba_l0_num = hr_dev->caps.sccc_bt_num; in get_hem_table_config()
159 mhop->hop_num = hr_dev->caps.sccc_hop_num; in get_hem_table_config()
162 mhop->buf_chunk_size = 1 << (hr_dev->caps.qpc_timer_buf_pg_sz in get_hem_table_config()
164 mhop->bt_chunk_size = 1 << (hr_dev->caps.qpc_timer_ba_pg_sz in get_hem_table_config()
166 mhop->ba_l0_num = hr_dev->caps.qpc_timer_bt_num; in get_hem_table_config()
167 mhop->hop_num = hr_dev->caps.qpc_timer_hop_num; in get_hem_table_config()
170 mhop->buf_chunk_size = 1 << (hr_dev->caps.cqc_timer_buf_pg_sz in get_hem_table_config()
172 mhop->bt_chunk_size = 1 << (hr_dev->caps.cqc_timer_ba_pg_sz in get_hem_table_config()
174 mhop->ba_l0_num = hr_dev->caps.cqc_timer_bt_num; in get_hem_table_config()
175 mhop->hop_num = hr_dev->caps.cqc_timer_hop_num; in get_hem_table_config()
178 mhop->buf_chunk_size = 1 << (hr_dev->caps.srqc_buf_pg_sz in get_hem_table_config()
180 mhop->bt_chunk_size = 1 << (hr_dev->caps.srqc_ba_pg_sz in get_hem_table_config()
182 mhop->ba_l0_num = hr_dev->caps.srqc_bt_num; in get_hem_table_config()
183 mhop->hop_num = hr_dev->caps.srqc_hop_num; in get_hem_table_config()
186 mhop->buf_chunk_size = 1 << (hr_dev->caps.gmv_buf_pg_sz + in get_hem_table_config()
188 mhop->bt_chunk_size = 1 << (hr_dev->caps.gmv_ba_pg_sz + in get_hem_table_config()
190 mhop->ba_l0_num = hr_dev->caps.gmv_bt_num; in get_hem_table_config()
191 mhop->hop_num = hr_dev->caps.gmv_hop_num; in get_hem_table_config()
204 struct hns_roce_hem_mhop *mhop) in hns_roce_calc_hem_mhop() argument
212 if (get_hem_table_config(hr_dev, mhop, table->type)) in hns_roce_calc_hem_mhop()
222 bt_num = hns_roce_get_bt_num(table->type, mhop->hop_num); in hns_roce_calc_hem_mhop()
223 chunk_ba_num = mhop->bt_chunk_size / BA_BYTE_LEN; in hns_roce_calc_hem_mhop()
224 chunk_size = table->type < HEM_TYPE_MTT ? mhop->buf_chunk_size : in hns_roce_calc_hem_mhop()
225 mhop->bt_chunk_size; in hns_roce_calc_hem_mhop()
229 mhop->l2_idx = table_idx & (chunk_ba_num - 1); in hns_roce_calc_hem_mhop()
230 mhop->l1_idx = table_idx / chunk_ba_num & (chunk_ba_num - 1); in hns_roce_calc_hem_mhop()
231 mhop->l0_idx = (table_idx / chunk_ba_num) / chunk_ba_num; in hns_roce_calc_hem_mhop()
234 mhop->l1_idx = table_idx & (chunk_ba_num - 1); in hns_roce_calc_hem_mhop()
235 mhop->l0_idx = table_idx / chunk_ba_num; in hns_roce_calc_hem_mhop()
238 mhop->l0_idx = table_idx; in hns_roce_calc_hem_mhop()
242 table->type, mhop->hop_num); in hns_roce_calc_hem_mhop()
245 if (mhop->l0_idx >= mhop->ba_l0_num) in hns_roce_calc_hem_mhop()
246 mhop->l0_idx %= mhop->ba_l0_num; in hns_roce_calc_hem_mhop()
300 struct hns_roce_hem_mhop *mhop, in calc_hem_config() argument
310 ret = hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, mhop); in calc_hem_config()
314 l0_idx = mhop->l0_idx; in calc_hem_config()
315 l1_idx = mhop->l1_idx; in calc_hem_config()
316 l2_idx = mhop->l2_idx; in calc_hem_config()
317 chunk_ba_num = mhop->bt_chunk_size / BA_BYTE_LEN; in calc_hem_config()
318 bt_num = hns_roce_get_bt_num(table->type, mhop->hop_num); in calc_hem_config()
335 table->type, mhop->hop_num); in calc_hem_config()
350 struct hns_roce_hem_mhop *mhop, in free_mhop_hem() argument
353 u32 bt_size = mhop->bt_chunk_size; in free_mhop_hem()
376 struct hns_roce_hem_mhop *mhop, in alloc_mhop_hem() argument
379 u32 bt_size = mhop->bt_chunk_size; in alloc_mhop_hem()
387 if ((check_whether_bt_num_3(table->type, mhop->hop_num) || in alloc_mhop_hem()
388 check_whether_bt_num_2(table->type, mhop->hop_num)) && in alloc_mhop_hem()
401 if (check_whether_bt_num_3(table->type, mhop->hop_num) && in alloc_mhop_hem()
411 *(table->bt_l0[index->l0] + mhop->l1_idx) = in alloc_mhop_hem()
419 size = table->type < HEM_TYPE_MTT ? mhop->buf_chunk_size : bt_size; in alloc_mhop_hem()
431 if (mhop->hop_num == 2) in alloc_mhop_hem()
432 *(table->bt_l1[index->l1] + mhop->l2_idx) = bt_ba; in alloc_mhop_hem()
433 else if (mhop->hop_num == 1) in alloc_mhop_hem()
434 *(table->bt_l0[index->l0] + mhop->l1_idx) = bt_ba; in alloc_mhop_hem()
435 } else if (mhop->hop_num == 2) { in alloc_mhop_hem()
436 *(table->bt_l0[index->l0] + mhop->l1_idx) = bt_ba; in alloc_mhop_hem()
441 free_mhop_hem(hr_dev, table, mhop, index); in alloc_mhop_hem()
448 struct hns_roce_hem_mhop *mhop, in set_mhop_hem() argument
472 if (mhop->hop_num == HNS_ROCE_HOP_NUM_0) in set_mhop_hem()
475 step_idx = mhop->hop_num; in set_mhop_hem()
490 struct hns_roce_hem_mhop mhop = {}; in hns_roce_table_mhop_get() local
493 ret = calc_hem_config(hr_dev, table, obj, &mhop, &index); in hns_roce_table_mhop_get()
505 ret = alloc_mhop_hem(hr_dev, table, &mhop, &index); in hns_roce_table_mhop_get()
513 ret = set_mhop_hem(hr_dev, table, obj, &mhop, &index); in hns_roce_table_mhop_get()
524 free_mhop_hem(hr_dev, table, &mhop, &index); in hns_roce_table_mhop_get()
575 struct hns_roce_hem_mhop *mhop, in clear_mhop_hem() argument
579 u32 hop_num = mhop->hop_num; in clear_mhop_hem()
585 chunk_ba_num = mhop->bt_chunk_size / BA_BYTE_LEN; in clear_mhop_hem()
634 struct hns_roce_hem_mhop mhop = {}; in hns_roce_table_mhop_put() local
637 ret = calc_hem_config(hr_dev, table, obj, &mhop, &index); in hns_roce_table_mhop_put()
649 clear_mhop_hem(hr_dev, table, obj, &mhop, &index); in hns_roce_table_mhop_put()
650 free_mhop_hem(hr_dev, table, &mhop, &index); in hns_roce_table_mhop_put()
688 struct hns_roce_hem_mhop mhop; in hns_roce_table_find() local
708 if (hns_roce_calc_hem_mhop(hr_dev, table, &mhop_obj, &mhop)) in hns_roce_table_find()
711 i = mhop.l0_idx; in hns_roce_table_find()
712 j = mhop.l1_idx; in hns_roce_table_find()
713 if (mhop.hop_num == 2) in hns_roce_table_find()
714 hem_idx = i * (mhop.bt_chunk_size / BA_BYTE_LEN) + j; in hns_roce_table_find()
715 else if (mhop.hop_num == 1 || in hns_roce_table_find()
716 mhop.hop_num == HNS_ROCE_HOP_NUM_0) in hns_roce_table_find()
720 dma_offset = offset = obj * seg_size % mhop.bt_chunk_size; in hns_roce_table_find()
721 if (mhop.hop_num == 2) in hns_roce_table_find()
752 struct hns_roce_hem_mhop mhop = {}; in hns_roce_init_hem_table() local
759 if (get_hem_table_config(hr_dev, &mhop, type)) in hns_roce_init_hem_table()
762 buf_chunk_size = mhop.buf_chunk_size; in hns_roce_init_hem_table()
763 bt_chunk_size = mhop.bt_chunk_size; in hns_roce_init_hem_table()
764 num_bt_l0 = mhop.ba_l0_num; in hns_roce_init_hem_table()
765 hop_num = mhop.hop_num; in hns_roce_init_hem_table()
842 struct hns_roce_hem_mhop mhop; in hns_roce_cleanup_mhop_hem_table() local
847 if (hns_roce_calc_hem_mhop(hr_dev, table, NULL, &mhop)) in hns_roce_cleanup_mhop_hem_table()
849 buf_chunk_size = table->type < HEM_TYPE_MTT ? mhop.buf_chunk_size : in hns_roce_cleanup_mhop_hem_table()
850 mhop.bt_chunk_size; in hns_roce_cleanup_mhop_hem_table()