Skip to content

Commit

Permalink
efa: Store extended CQ in EFA's CQ
Browse files Browse the repository at this point in the history
Change create CQ verb to call create extended ibvcq command using
extended init attributes, in order to support extended CQ later on.

Signed-off-by: Daniel Kranzdorf <dkkranzd@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
  • Loading branch information
dkkranz authored and gal-pressman committed Aug 10, 2020
1 parent dc6e991 commit c8323c3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
6 changes: 3 additions & 3 deletions providers/efa/efa-abi.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved.
* Copyright 2019-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
*/

#ifndef __EFA_ABI_H__
Expand All @@ -16,8 +16,8 @@ DECLARE_DRV_CMD(efa_alloc_ucontext, IB_USER_VERBS_CMD_GET_CONTEXT, empty,
efa_ibv_alloc_ucontext_resp);
DECLARE_DRV_CMD(efa_alloc_pd, IB_USER_VERBS_CMD_ALLOC_PD, empty,
efa_ibv_alloc_pd_resp);
DECLARE_DRV_CMD(efa_create_cq, IB_USER_VERBS_CMD_CREATE_CQ, efa_ibv_create_cq,
efa_ibv_create_cq_resp);
DECLARE_DRV_CMD(efa_create_cq, IB_USER_VERBS_EX_CMD_CREATE_CQ,
efa_ibv_create_cq, efa_ibv_create_cq_resp);
DECLARE_DRV_CMD(efa_create_qp, IB_USER_VERBS_CMD_CREATE_QP, efa_ibv_create_qp,
efa_ibv_create_qp_resp);
DECLARE_DRV_CMD(efa_create_ah, IB_USER_VERBS_CMD_CREATE_AH, empty,
Expand Down
9 changes: 7 additions & 2 deletions providers/efa/efa.h
Expand Up @@ -50,7 +50,7 @@ struct efa_sub_cq {
};

struct efa_cq {
struct ibv_cq ibvcq;
struct verbs_cq verbs_cq;
uint32_t cqn;
size_t cqe_size;
uint8_t *buf;
Expand Down Expand Up @@ -158,7 +158,12 @@ static inline struct efa_pd *to_efa_pd(struct ibv_pd *ibvpd)

static inline struct efa_cq *to_efa_cq(struct ibv_cq *ibvcq)
{
return container_of(ibvcq, struct efa_cq, ibvcq);
return container_of(ibvcq, struct efa_cq, verbs_cq.cq);
}

static inline struct efa_cq *to_efa_cq_ex(struct ibv_cq_ex *ibvcqx)
{
return container_of(ibvcqx, struct efa_cq, verbs_cq.cq_ex);
}

static inline struct efa_qp *to_efa_qp(struct ibv_qp *ibvqp)
Expand Down
35 changes: 25 additions & 10 deletions providers/efa/verbs.c
Expand Up @@ -360,7 +360,7 @@ static void efa_process_cqe(struct efa_cq *cq, struct ibv_wc *wc,
static int efa_poll_sub_cq(struct efa_cq *cq, struct efa_sub_cq *sub_cq,
struct efa_qp **cur_qp, struct ibv_wc *wc)
{
struct efa_context *ctx = to_efa_context(cq->ibvcq.context);
struct efa_context *ctx = to_efa_context(cq->verbs_cq.cq.context);
uint32_t qpn;

cq->cur_cqe = cq_next_sub_cqe_get(sub_cq);
Expand Down Expand Up @@ -438,8 +438,8 @@ static void efa_sub_cq_initialize(struct efa_sub_cq *sub_cq, uint8_t *buf,
sub_cq->ref_cnt = 0;
}

struct ibv_cq *efa_create_cq(struct ibv_context *ibvctx, int ncqe,
struct ibv_comp_channel *channel, int vec)
static struct ibv_cq_ex *create_cq(struct ibv_context *ibvctx,
struct ibv_cq_init_attr_ex *attr)
{
struct efa_context *ctx = to_efa_context(ibvctx);
struct efa_create_cq_resp resp = {};
Expand All @@ -461,16 +461,16 @@ struct ibv_cq *efa_create_cq(struct ibv_context *ibvctx, int ncqe,
cmd.num_sub_cqs = num_sub_cqs;
cmd.cq_entry_size = ctx->cqe_size;

ncqe = roundup_pow_of_two(ncqe);
err = ibv_cmd_create_cq(ibvctx, ncqe, channel, vec,
&cq->ibvcq, &cmd.ibv_cmd, sizeof(cmd),
&resp.ibv_resp, sizeof(resp));
attr->cqe = roundup_pow_of_two(attr->cqe);
err = ibv_cmd_create_cq_ex(ibvctx, attr, &cq->verbs_cq,
&cmd.ibv_cmd, sizeof(cmd),
&resp.ibv_resp, sizeof(resp));
if (err) {
errno = err;
goto err_free_cq;
}

sub_cq_size = cq->ibvcq.cqe;
sub_cq_size = cq->verbs_cq.cq.cqe;
cq->cqn = resp.cq_idx;
cq->buf_size = resp.q_mmap_size;
cq->num_sub_cqs = num_sub_cqs;
Expand All @@ -491,15 +491,30 @@ struct ibv_cq *efa_create_cq(struct ibv_context *ibvctx, int ncqe,

pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE);

return &cq->ibvcq;
return &cq->verbs_cq.cq_ex;

err_destroy_cq:
ibv_cmd_destroy_cq(&cq->ibvcq);
ibv_cmd_destroy_cq(&cq->verbs_cq.cq);
err_free_cq:
free(cq);
return NULL;
}

struct ibv_cq *efa_create_cq(struct ibv_context *ibvctx, int ncqe,
struct ibv_comp_channel *channel, int vec)
{
struct ibv_cq_init_attr_ex attr_ex = {
.cqe = ncqe,
.channel = channel,
.comp_vector = vec
};
struct ibv_cq_ex *ibvcqx;

ibvcqx = create_cq(ibvctx, &attr_ex);

return ibvcqx ? ibv_cq_ex_to_cq(ibvcqx) : NULL;
}

int efa_destroy_cq(struct ibv_cq *ibvcq)
{
struct efa_cq *cq = to_efa_cq(ibvcq);
Expand Down

0 comments on commit c8323c3

Please sign in to comment.