#include <linux/vmalloc.h>
#include <linux/count_zeros.h>
#include <rdma/ib_umem.h>
#include <linux/math.h>
#include "hns_roce_device.h"
#include "hns_roce_cmd.h"
#include "hns_roce_hem.h"
static u32 hw_index_to_key(int ind)
{ … }
unsigned long key_to_hw_index(u32 key)
{ … }
static int alloc_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr)
{ … }
static void free_mr_key(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr)
{ … }
static int alloc_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr,
struct ib_udata *udata, u64 start)
{ … }
static void free_mr_pbl(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr)
{ … }
static void hns_roce_mr_free(struct hns_roce_dev *hr_dev, struct hns_roce_mr *mr)
{ … }
static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
struct hns_roce_mr *mr)
{ … }
void hns_roce_init_mr_table(struct hns_roce_dev *hr_dev)
{ … }
struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc)
{ … }
struct ib_mr *hns_roce_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags,
struct ib_udata *udata)
{ … }
struct ib_mr *hns_roce_rereg_user_mr(struct ib_mr *ibmr, int flags, u64 start,
u64 length, u64 virt_addr,
int mr_access_flags, struct ib_pd *pd,
struct ib_udata *udata)
{ … }
int hns_roce_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
{ … }
struct ib_mr *hns_roce_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
u32 max_num_sg)
{ … }
static int hns_roce_set_page(struct ib_mr *ibmr, u64 addr)
{ … }
int hns_roce_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
unsigned int *sg_offset)
{ … }
static void hns_roce_mw_free(struct hns_roce_dev *hr_dev,
struct hns_roce_mw *mw)
{ … }
static int hns_roce_mw_enable(struct hns_roce_dev *hr_dev,
struct hns_roce_mw *mw)
{ … }
int hns_roce_alloc_mw(struct ib_mw *ibmw, struct ib_udata *udata)
{ … }
int hns_roce_dealloc_mw(struct ib_mw *ibmw)
{ … }
static int mtr_map_region(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
struct hns_roce_buf_region *region, dma_addr_t *pages,
int max_count)
{ … }
static inline bool mtr_has_mtt(struct hns_roce_buf_attr *attr)
{ … }
static inline size_t mtr_bufs_size(struct hns_roce_buf_attr *attr)
{ … }
static inline int mtr_check_direct_pages(dma_addr_t *pages, int page_count,
unsigned int page_shift)
{ … }
static void mtr_free_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr)
{ … }
static int mtr_alloc_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
struct hns_roce_buf_attr *buf_attr,
struct ib_udata *udata, unsigned long user_addr)
{ … }
static int cal_mtr_pg_cnt(struct hns_roce_mtr *mtr)
{ … }
static bool need_split_huge_page(struct hns_roce_mtr *mtr)
{ … }
static int mtr_map_bufs(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr)
{ … }
int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
dma_addr_t *pages, unsigned int page_cnt)
{ … }
static int hns_roce_get_direct_addr_mtt(struct hns_roce_hem_cfg *cfg,
u32 start_index, u64 *mtt_buf,
int mtt_cnt)
{ … }
static int hns_roce_get_mhop_mtt(struct hns_roce_dev *hr_dev,
struct hns_roce_mtr *mtr, u32 start_index,
u64 *mtt_buf, int mtt_cnt)
{ … }
int hns_roce_mtr_find(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
u32 offset, u64 *mtt_buf, int mtt_max)
{ … }
static int get_best_page_shift(struct hns_roce_dev *hr_dev,
struct hns_roce_mtr *mtr,
struct hns_roce_buf_attr *buf_attr)
{ … }
static int get_best_hop_num(struct hns_roce_dev *hr_dev,
struct hns_roce_mtr *mtr,
struct hns_roce_buf_attr *buf_attr,
unsigned int ba_pg_shift)
{ … }
static bool is_buf_attr_valid(struct hns_roce_dev *hr_dev,
struct hns_roce_buf_attr *attr)
{ … }
static int mtr_init_buf_cfg(struct hns_roce_dev *hr_dev,
struct hns_roce_mtr *mtr,
struct hns_roce_buf_attr *attr)
{ … }
static u64 cal_pages_per_l1ba(unsigned int ba_per_bt, unsigned int hopnum)
{ … }
static unsigned int cal_best_bt_pg_sz(struct hns_roce_dev *hr_dev,
struct hns_roce_mtr *mtr,
unsigned int pg_shift)
{ … }
static int mtr_alloc_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
unsigned int ba_page_shift)
{ … }
static void mtr_free_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr)
{ … }
int hns_roce_mtr_create(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
struct hns_roce_buf_attr *buf_attr,
unsigned int ba_page_shift, struct ib_udata *udata,
unsigned long user_addr)
{ … }
void hns_roce_mtr_destroy(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr)
{ … }