Skip to content

Commit

Permalink
efa: Query device attributes for RDMA operations
Browse files Browse the repository at this point in the history
Query the device attributes of maximum RDMA transfer size and RDMA read
capability and report it through the query device direct verb.

Signed-off-by: Daniel Kranzdorf <[email protected]>
Signed-off-by: Gal Pressman <[email protected]>
  • Loading branch information
dkkranz authored and gal-pressman committed Dec 4, 2019
1 parent 36d052c commit 0d14a4b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions providers/efa/efa.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ struct efa_dev {
uint32_t max_rq_wr;
uint16_t max_sq_sge;
uint16_t max_rq_sge;
uint32_t max_rdma_size;
uint16_t max_wr_rdma_sge;
};

static inline struct efa_dev *to_efa_dev(struct ibv_device *ibvdev)
Expand Down
6 changes: 6 additions & 0 deletions providers/efa/efadv.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ struct ibv_qp *efadv_create_qp_ex(struct ibv_context *ibvctx,
struct efadv_qp_init_attr *efa_attr,
uint32_t inlen);

enum {
EFADV_DEVICE_ATTR_CAPS_RDMA_READ = 1 << 0,
};

struct efadv_device_attr {
uint64_t comp_mask;
uint32_t max_sq_wr;
Expand All @@ -43,6 +47,8 @@ struct efadv_device_attr {
uint16_t max_rq_sge;
uint16_t inline_buf_size;
uint8_t reserved[2];
uint32_t device_caps;
uint32_t max_rdma_size;
};

int efadv_query_device(struct ibv_context *ibvctx,
Expand Down
11 changes: 11 additions & 0 deletions providers/efa/man/efadv_query_device.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ struct efadv_device_attr {
uint16_t max_rq_sge;
uint16_t inline_buf_size;
uint8_t reserved[2];
uint32_t device_caps;
uint32_t max_rdma_size;
};
```

Expand All @@ -61,6 +63,15 @@ struct efadv_device_attr {
*inline_buf_size*
: Maximum inline buffer size.

*device_caps*
: Bitmask of device capabilities:

EFADV_DEVICE_ATTR_CAPS_RDMA_READ:
RDMA read is supported.

*max_rdma_size*
: Maximum RDMA transfer size in bytes.

# RETURN VALUE

**efadv_query_device()** returns 0 on success, or the value of errno on failure
Expand Down
12 changes: 10 additions & 2 deletions providers/efa/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ int efa_query_device_ex(struct ibv_context *context,
struct efa_dev *dev = to_efa_dev(context->device);
int cmd_supp_uhw = ctx->cmds_supp_udata_mask &
EFA_USER_CMDS_SUPP_UDATA_QUERY_DEVICE;
struct ibv_device_attr *a = &attr->orig_attr;
struct efa_query_device_ex_resp resp = {};
struct ibv_query_device_ex cmd = {};
struct ibv_device_attr *a;
uint8_t fw_ver[8];
int err;

Expand All @@ -77,8 +77,9 @@ int efa_query_device_ex(struct ibv_context *context,
dev->max_rq_wr = resp.max_rq_wr;
dev->max_sq_sge = resp.max_sq_sge;
dev->max_rq_sge = resp.max_rq_sge;
dev->max_rdma_size = resp.max_rdma_size;
dev->max_wr_rdma_sge = a->max_sge_rd;

a = &attr->orig_attr;
a->max_qp_wr = min_t(int, a->max_qp_wr,
ctx->max_llq_size / sizeof(struct efa_io_tx_wqe));
snprintf(a->fw_ver, sizeof(a->fw_ver), "%u.%u.%u.%u",
Expand Down Expand Up @@ -108,6 +109,13 @@ int efadv_query_device(struct ibv_context *ibvctx,
attr->max_rq_sge = dev->max_rq_sge;
attr->inline_buf_size = ctx->inline_buf_size;

if (vext_field_avail(typeof(*attr), max_rdma_size, inlen)) {
attr->max_rdma_size = dev->max_rdma_size;

if (is_rdma_read_cap(dev))
attr->device_caps |= EFADV_DEVICE_ATTR_CAPS_RDMA_READ;
}

attr->comp_mask = comp_mask_out;

return 0;
Expand Down

0 comments on commit 0d14a4b

Please sign in to comment.