Skip to content

Commit 666e8ff

Browse files
dkkranzjgunthorpe
authored andcommitted
RDMA/efa: Expose RDMA read related attributes
Query the device attributes for RDMA operations, including maximum transfer size and maximum number of SGEs per RDMA WR, and report them back to the userspace library. Link: https://lore.kernel.org/r/20191121141509.59297-4-galpress@amazon.com Signed-off-by: Daniel Kranzdorf <dkkranzd@amazon.com> Reviewed-by: Yossi Leybovich <sleybo@amazon.com> Signed-off-by: Gal Pressman <galpress@amazon.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent e6c4f3f commit 666e8ff

5 files changed

Lines changed: 46 additions & 5 deletions

File tree

‎drivers/infiniband/hw/efa/efa_admin_cmds_defs.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,16 @@ struct efa_admin_feature_device_attr_desc {
562562

563563
/* Indicates how many bits are used virtual address access */
564564
u8 virt_addr_width;
565+
566+
/*
567+
* 0 : rdma_read - If set, RDMA Read is supported on
568+
* TX queues
569+
* 31:1 : reserved - MBZ
570+
*/
571+
u32 device_caps;
572+
573+
/* Max RDMA transfer size in bytes */
574+
u32 max_rdma_size;
565575
};
566576

567577
struct efa_admin_feature_queue_attr_desc {
@@ -608,6 +618,9 @@ struct efa_admin_feature_queue_attr_desc {
608618

609619
/* The maximum size of LLQ in bytes */
610620
u32 max_llq_size;
621+
622+
/* Maximum number of SGEs for a single RDMA read WQE */
623+
u16 max_wr_rdma_sges;
611624
};
612625

613626
struct efa_admin_feature_aenq_desc {
@@ -622,6 +635,7 @@ struct efa_admin_feature_network_attr_desc {
622635
/* Raw address data in network byte order */
623636
u8 addr[16];
624637

638+
/* max packet payload size in bytes */
625639
u32 mtu;
626640
};
627641

@@ -797,4 +811,7 @@ struct efa_admin_mmio_req_read_less_resp {
797811
/* get_set_feature_common_desc */
798812
#define EFA_ADMIN_GET_SET_FEATURE_COMMON_DESC_SELECT_MASK GENMASK(1, 0)
799813

814+
/* feature_device_attr_desc */
815+
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_READ_MASK BIT(0)
816+
800817
#endif /* _EFA_ADMIN_CMDS_H_ */

‎drivers/infiniband/hw/efa/efa_com_cmd.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ int efa_com_get_device_attr(struct efa_com_dev *edev,
444444
result->phys_addr_width = resp.u.device_attr.phys_addr_width;
445445
result->virt_addr_width = resp.u.device_attr.virt_addr_width;
446446
result->db_bar = resp.u.device_attr.db_bar;
447+
result->max_rdma_size = resp.u.device_attr.max_rdma_size;
448+
result->device_caps = resp.u.device_attr.device_caps;
447449

448450
if (result->admin_api_version < 1) {
449451
ibdev_err_ratelimited(
@@ -477,6 +479,7 @@ int efa_com_get_device_attr(struct efa_com_dev *edev,
477479
result->max_ah = resp.u.queue_attr.max_ah;
478480
result->max_llq_size = resp.u.queue_attr.max_llq_size;
479481
result->sub_cqs_per_cq = resp.u.queue_attr.sub_cqs_per_cq;
482+
result->max_wr_rdma_sge = resp.u.queue_attr.max_wr_rdma_sges;
480483

481484
err = efa_com_get_feature(edev, &resp, EFA_ADMIN_NETWORK_ATTR);
482485
if (err) {

‎drivers/infiniband/hw/efa/efa_com_cmd.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,12 @@ struct efa_com_get_device_attr_result {
121121
u32 max_pd;
122122
u32 max_ah;
123123
u32 max_llq_size;
124+
u32 max_rdma_size;
125+
u32 device_caps;
124126
u16 sub_cqs_per_cq;
125127
u16 max_sq_sge;
126128
u16 max_rq_sge;
129+
u16 max_wr_rdma_sge;
127130
u8 db_bar;
128131
};
129132

‎drivers/infiniband/hw/efa/efa_verbs.c‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ static const char *const efa_stats_names[] = {
7070
#define EFA_CHUNK_USED_SIZE \
7171
((EFA_PTRS_PER_CHUNK * EFA_CHUNK_PAYLOAD_PTR_SIZE) + EFA_CHUNK_PTR_SIZE)
7272

73-
#define EFA_SUPPORTED_ACCESS_FLAGS \
74-
(IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ)
75-
7673
struct pbl_chunk {
7774
dma_addr_t dma_addr;
7875
u64 *buf;
@@ -142,6 +139,11 @@ to_emmap(struct rdma_user_mmap_entry *rdma_entry)
142139
return container_of(rdma_entry, struct efa_user_mmap_entry, rdma_entry);
143140
}
144141

142+
static inline bool is_rdma_read_cap(struct efa_dev *dev)
143+
{
144+
return dev->dev_attr.device_caps & EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_READ_MASK;
145+
}
146+
145147
#define field_avail(x, fld, sz) (offsetof(typeof(x), fld) + \
146148
FIELD_SIZEOF(typeof(x), fld) <= (sz))
147149

@@ -201,12 +203,17 @@ int efa_query_device(struct ib_device *ibdev,
201203
dev_attr->max_rq_depth);
202204
props->max_send_sge = dev_attr->max_sq_sge;
203205
props->max_recv_sge = dev_attr->max_rq_sge;
206+
props->max_sge_rd = dev_attr->max_wr_rdma_sge;
204207

205208
if (udata && udata->outlen) {
206209
resp.max_sq_sge = dev_attr->max_sq_sge;
207210
resp.max_rq_sge = dev_attr->max_rq_sge;
208211
resp.max_sq_wr = dev_attr->max_sq_depth;
209212
resp.max_rq_wr = dev_attr->max_rq_depth;
213+
resp.max_rdma_size = dev_attr->max_rdma_size;
214+
215+
if (is_rdma_read_cap(dev))
216+
resp.device_caps |= EFA_QUERY_DEVICE_CAPS_RDMA_READ;
210217

211218
err = ib_copy_to_udata(udata, &resp,
212219
min(sizeof(resp), udata->outlen));
@@ -1345,6 +1352,7 @@ struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
13451352
struct efa_com_reg_mr_params params = {};
13461353
struct efa_com_reg_mr_result result = {};
13471354
struct pbl_context pbl;
1355+
int supp_access_flags;
13481356
unsigned int pg_sz;
13491357
struct efa_mr *mr;
13501358
int inline_size;
@@ -1358,10 +1366,14 @@ struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
13581366
goto err_out;
13591367
}
13601368

1361-
if (access_flags & ~EFA_SUPPORTED_ACCESS_FLAGS) {
1369+
supp_access_flags =
1370+
IB_ACCESS_LOCAL_WRITE |
1371+
(is_rdma_read_cap(dev) ? IB_ACCESS_REMOTE_READ : 0);
1372+
1373+
if (access_flags & ~supp_access_flags) {
13621374
ibdev_dbg(&dev->ibdev,
13631375
"Unsupported access flags[%#x], supported[%#x]\n",
1364-
access_flags, EFA_SUPPORTED_ACCESS_FLAGS);
1376+
access_flags, supp_access_flags);
13651377
err = -EOPNOTSUPP;
13661378
goto err_out;
13671379
}

‎include/uapi/rdma/efa-abi.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ struct efa_ibv_create_ah_resp {
9090
__u8 reserved_30[2];
9191
};
9292

93+
enum {
94+
EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
95+
};
96+
9397
struct efa_ibv_ex_query_device_resp {
9498
__u32 comp_mask;
9599
__u32 max_sq_wr;
96100
__u32 max_rq_wr;
97101
__u16 max_sq_sge;
98102
__u16 max_rq_sge;
103+
__u32 max_rdma_size;
104+
__u32 device_caps;
99105
};
100106

101107
#endif /* EFA_ABI_USER_H */

0 commit comments

Comments
 (0)