Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providers/erdma: Add non-4K page size support #1313

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion kernel-headers/rdma/erdma-abi.h
Expand Up @@ -40,10 +40,13 @@ struct erdma_uresp_alloc_ctx {
__u32 dev_id;
__u32 pad;
__u32 sdb_type;
__u32 sdb_offset;
__u32 sdb_entid;
__aligned_u64 sdb;
__aligned_u64 rdb;
__aligned_u64 cdb;
__u32 sdb_off;
__u32 rdb_off;
__u32 cdb_off;
};

#endif
4 changes: 4 additions & 0 deletions kernel-headers/rdma/hns-abi.h
Expand Up @@ -87,10 +87,14 @@ struct hns_roce_ib_create_qp_resp {

enum {
HNS_ROCE_EXSGE_FLAGS = 1 << 0,
HNS_ROCE_RQ_INLINE_FLAGS = 1 << 1,
HNS_ROCE_CQE_INLINE_FLAGS = 1 << 2,
};

enum {
HNS_ROCE_RSP_EXSGE_FLAGS = 1 << 0,
HNS_ROCE_RSP_RQ_INLINE_FLAGS = 1 << 1,
HNS_ROCE_RSP_CQE_INLINE_FLAGS = 1 << 2,
};

struct hns_roce_ib_alloc_ucontext_resp {
Expand Down
22 changes: 15 additions & 7 deletions providers/erdma/erdma.c
Expand Up @@ -60,36 +60,42 @@ static struct verbs_context *erdma_alloc_context(struct ibv_device *device,
goto err_out;

verbs_set_ops(&ctx->ibv_ctx, &erdma_context_ops);
ctx->page_size = to_edev(device)->page_size;
ctx->dev_id = resp.dev_id;

ctx->sdb_type = resp.sdb_type;
ctx->sdb_offset = resp.sdb_offset;
ctx->sdb_entid = resp.sdb_entid;

ctx->sdb = mmap(NULL, ERDMA_PAGE_SIZE, PROT_WRITE, MAP_SHARED, cmd_fd,
ctx->sdb = mmap(NULL, ctx->page_size, PROT_WRITE, MAP_SHARED, cmd_fd,
resp.sdb);
if (ctx->sdb == MAP_FAILED)
goto err_out;

ctx->rdb = mmap(NULL, ERDMA_PAGE_SIZE, PROT_WRITE, MAP_SHARED, cmd_fd,
ctx->rdb = mmap(NULL, ctx->page_size, PROT_WRITE, MAP_SHARED, cmd_fd,
resp.rdb);
if (ctx->rdb == MAP_FAILED)
goto err_rdb_map;

ctx->cdb = mmap(NULL, ERDMA_PAGE_SIZE, PROT_WRITE, MAP_SHARED, cmd_fd,
ctx->cdb = mmap(NULL, ctx->page_size, PROT_WRITE, MAP_SHARED, cmd_fd,
resp.cdb);
if (ctx->cdb == MAP_FAILED)
goto err_cdb_map;

ctx->page_size = ERDMA_PAGE_SIZE;
ctx->sdb += resp.sdb_off;
ctx->rdb += resp.rdb_off;
ctx->cdb += resp.cdb_off;

list_head_init(&ctx->dbrecord_pages_list);
pthread_mutex_init(&ctx->dbrecord_pages_mutex, NULL);

return &ctx->ibv_ctx;

err_cdb_map:
munmap(ctx->rdb, ERDMA_PAGE_SIZE);
munmap((void *)align_down((uintptr_t)ctx->rdb, ctx->page_size),
ctx->page_size);
err_rdb_map:
munmap(ctx->sdb, ERDMA_PAGE_SIZE);
munmap((void *)align_down((uintptr_t)ctx->sdb, ctx->page_size),
ctx->page_size);
err_out:
verbs_uninit_context(&ctx->ibv_ctx);
free(ctx);
Expand All @@ -106,6 +112,8 @@ erdma_device_alloc(struct verbs_sysfs_dev *sysfs_dev)
if (!dev)
return NULL;

dev->page_size = sysconf(_SC_PAGESIZE);

return &dev->ibv_dev;
}

Expand Down
8 changes: 7 additions & 1 deletion providers/erdma/erdma.h
Expand Up @@ -23,6 +23,7 @@

struct erdma_device {
struct verbs_device ibv_dev;
uint32_t page_size;
};

#define ERDMA_QP_TABLE_SIZE 4096
Expand All @@ -40,7 +41,7 @@ struct erdma_context {
pthread_mutex_t qp_table_mutex;

uint8_t sdb_type;
uint32_t sdb_offset;
uint32_t sdb_entid;

void *sdb;
void *rdb;
Expand All @@ -56,4 +57,9 @@ static inline struct erdma_context *to_ectx(struct ibv_context *base)
return container_of(base, struct erdma_context, ibv_ctx.context);
}

static inline struct erdma_device *to_edev(struct ibv_device *ibv_dev)
{
return container_of(ibv_dev, struct erdma_device, ibv_dev.device);
}

#endif
11 changes: 7 additions & 4 deletions providers/erdma/erdma_verbs.c
Expand Up @@ -277,7 +277,7 @@ static void __erdma_alloc_dbs(struct erdma_qp *qp, struct erdma_context *ctx)
uint32_t db_offset;

if (ctx->sdb_type == ERDMA_SDB_ENTRY)
db_offset = ctx->sdb_offset * ERDMA_NSDB_PER_ENTRY *
db_offset = ctx->sdb_entid * ERDMA_NSDB_PER_ENTRY *
ERDMA_SQDB_SIZE;
else
db_offset = (qpn & ERDMA_SDB_ALLOC_QPN_MASK) * ERDMA_SQDB_SIZE;
Expand Down Expand Up @@ -1018,9 +1018,12 @@ void erdma_free_context(struct ibv_context *ibv_ctx)
struct erdma_context *ctx = to_ectx(ibv_ctx);
int i;

munmap(ctx->sdb, ERDMA_PAGE_SIZE);
munmap(ctx->rdb, ERDMA_PAGE_SIZE);
munmap(ctx->cdb, ERDMA_PAGE_SIZE);
munmap((void *)align_down((uintptr_t)ctx->sdb, ctx->page_size),
ctx->page_size);
munmap((void *)align_down((uintptr_t)ctx->rdb, ctx->page_size),
ctx->page_size);
munmap((void *)align_down((uintptr_t)ctx->cdb, ctx->page_size),
ctx->page_size);

pthread_mutex_lock(&ctx->qp_table_mutex);
for (i = 0; i < ERDMA_QP_TABLE_SIZE; ++i) {
Expand Down