Lines Matching refs:npages
221 int hns_roce_mtt_init(struct hns_roce_dev *hr_dev, int npages, int page_shift, in hns_roce_mtt_init() argument
228 if (!npages) { in hns_roce_mtt_init()
238 for (mtt->order = 0, i = HNS_ROCE_MTT_ENTRY_PER_SEG; i < npages; in hns_roce_mtt_init()
350 static int pbl_1hop_alloc(struct hns_roce_dev *hr_dev, int npages, in pbl_1hop_alloc() argument
355 if (npages > pbl_bt_sz / 8) { in pbl_1hop_alloc()
357 npages); in pbl_1hop_alloc()
360 mr->pbl_buf = dma_alloc_coherent(dev, npages * 8, in pbl_1hop_alloc()
366 mr->pbl_size = npages; in pbl_1hop_alloc()
376 static int pbl_2hop_alloc(struct hns_roce_dev *hr_dev, int npages, in pbl_2hop_alloc() argument
386 pbl_last_bt_num = (npages + pbl_bt_sz / 8 - 1) / (pbl_bt_sz / 8); in pbl_2hop_alloc()
394 size = (npages - npages_allocated) * 8; in pbl_2hop_alloc()
416 static int pbl_3hop_alloc(struct hns_roce_dev *hr_dev, int npages, in pbl_3hop_alloc() argument
429 pbl_last_bt_num = (npages + pbl_bt_sz / 8 - 1) / (pbl_bt_sz / 8); in pbl_3hop_alloc()
463 size = (npages - npages_allocated) * 8; in pbl_3hop_alloc()
507 static int hns_roce_mhop_alloc(struct hns_roce_dev *hr_dev, int npages, in hns_roce_mhop_alloc() argument
521 return pbl_1hop_alloc(hr_dev, npages, mr, pbl_bt_sz); in hns_roce_mhop_alloc()
542 if (pbl_2hop_alloc(hr_dev, npages, mr, pbl_bt_sz)) in hns_roce_mhop_alloc()
547 if (pbl_3hop_alloc(hr_dev, npages, mr, pbl_bt_sz)) in hns_roce_mhop_alloc()
552 mr->pbl_size = npages; in hns_roce_mhop_alloc()
572 u64 size, u32 access, int npages, in hns_roce_mr_alloc() argument
604 npages * BA_BYTE_LEN, in hns_roce_mr_alloc()
610 ret = hns_roce_mhop_alloc(hr_dev, npages, mr); in hns_roce_mr_alloc()
622 int npages; in hns_roce_mhop_free() local
628 npages = mr->pbl_size; in hns_roce_mhop_free()
636 dma_free_coherent(dev, (unsigned int)(npages * BA_BYTE_LEN), in hns_roce_mhop_free()
651 (npages - npages_allocated) * BA_BYTE_LEN, in hns_roce_mhop_free()
675 (npages - npages_allocated) * in hns_roce_mhop_free()
706 int npages = 0; in hns_roce_mr_free() local
718 npages = ib_umem_page_count(mr->umem); in hns_roce_mr_free()
722 (unsigned int)(npages * BA_BYTE_LEN), in hns_roce_mr_free()
788 u32 npages, u64 *page_list) in hns_roce_write_mtt_chunk() argument
819 (start_index + npages - 1) / (bt_page_size / sizeof(u64))) in hns_roce_write_mtt_chunk()
833 for (i = 0; i < npages; ++i) { in hns_roce_write_mtt_chunk()
845 u32 npages, u64 *page_list) in hns_roce_write_mtt() argument
874 while (npages > 0) { in hns_roce_write_mtt()
875 chunk = min_t(int, bt_page_size / sizeof(u64), npages); in hns_roce_write_mtt()
882 npages -= chunk; in hns_roce_write_mtt()
897 page_list = kmalloc_array(buf->npages, sizeof(*page_list), GFP_KERNEL); in hns_roce_buf_write_mtt()
901 for (i = 0; i < buf->npages; ++i) { in hns_roce_buf_write_mtt()
908 ret = hns_roce_write_mtt(hr_dev, mtt, 0, buf->npages, page_list); in hns_roce_buf_write_mtt()
1217 int npages; in rereg_mr_trans() local
1221 npages = ib_umem_page_count(mr->umem); in rereg_mr_trans()
1226 dma_free_coherent(dev, npages * 8, in rereg_mr_trans()
1237 npages = ib_umem_page_count(mr->umem); in rereg_mr_trans()
1240 ret = hns_roce_mhop_alloc(hr_dev, npages, mr); in rereg_mr_trans()
1244 mr->pbl_buf = dma_alloc_coherent(dev, npages * 8, in rereg_mr_trans()
1263 npages = ib_umem_page_count(mr->umem); in rereg_mr_trans()
1268 dma_free_coherent(dev, npages * 8, in rereg_mr_trans()
1429 mr->pbl_buf[mr->npages++] = addr; in hns_roce_set_page()
1439 mr->npages = 0; in hns_roce_map_mr_sg()