Skip to content

Commit ee9ccbf

Browse files
authored
Merge pull request #1203 from mrgolin/efa-dv-cq
efa: Add DV CQ with source GID capability
2 parents ae62d39 + 7fd5f60 commit ee9ccbf

19 files changed

+411
-55
lines changed

debian/ibverbs-providers.symbols

+3
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ libefa.so.1 ibverbs-providers #MINVER#
165165
* Build-Depends-Package: libibverbs-dev
166166
EFA_1.0@EFA_1.0 24
167167
EFA_1.1@EFA_1.1 26
168+
EFA_1.2@EFA_1.2 43
168169
efadv_create_driver_qp@EFA_1.0 24
169170
efadv_create_qp_ex@EFA_1.1 26
170171
efadv_query_device@EFA_1.1 26
171172
efadv_query_ah@EFA_1.1 26
173+
efadv_cq_from_ibv_cq_ex@EFA_1.2 43
174+
efadv_create_cq@EFA_1.2 43

kernel-headers/rdma/efa-abi.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
22
/*
3-
* Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#ifndef EFA_ABI_USER_H
@@ -54,6 +54,7 @@ struct efa_ibv_alloc_pd_resp {
5454

5555
enum {
5656
EFA_CREATE_CQ_WITH_COMPLETION_CHANNEL = 1 << 0,
57+
EFA_CREATE_CQ_WITH_SGID = 1 << 1,
5758
};
5859

5960
struct efa_ibv_create_cq {
@@ -118,6 +119,7 @@ enum {
118119
EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
119120
EFA_QUERY_DEVICE_CAPS_RNR_RETRY = 1 << 1,
120121
EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS = 1 << 2,
122+
EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID = 1 << 3,
121123
};
122124

123125
struct efa_ibv_ex_query_device_resp {

providers/efa/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
rdma_shared_provider(efa libefa.map
2-
1 1.1.${PACKAGE_VERSION}
2+
1 1.2.${PACKAGE_VERSION}
33
efa.c
44
verbs.c
55
)

providers/efa/efa.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
22
/*
3-
* Copyright 2019-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2019-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#include <stdio.h>
@@ -75,6 +75,7 @@ static struct verbs_context *efa_alloc_context(struct ibv_device *vdev,
7575
ctx->sub_cqs_per_cq = resp.sub_cqs_per_cq;
7676
ctx->cmds_supp_udata_mask = resp.cmds_supp_udata_mask;
7777
ctx->cqe_size = sizeof(struct efa_io_rx_cdesc);
78+
ctx->ex_cqe_size = sizeof(struct efa_io_rx_cdesc_ex);
7879
ctx->inline_buf_size = resp.inline_buf_size;
7980
ctx->max_llq_size = resp.max_llq_size;
8081
ctx->max_tx_batch = resp.max_tx_batch;

providers/efa/efa.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
22
/*
3-
* Copyright 2019-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2019-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#ifndef __EFA_H__
@@ -15,6 +15,7 @@
1515

1616
#include "efa-abi.h"
1717
#include "efa_io_defs.h"
18+
#include "efadv.h"
1819

1920
#define EFA_GET(ptr, mask) FIELD_GET(mask##_MASK, *(ptr))
2021

@@ -41,6 +42,7 @@ struct efa_context {
4142
uint16_t max_tx_batch;
4243
uint16_t min_sq_wr;
4344
size_t cqe_size;
45+
size_t ex_cqe_size;
4446
struct efa_qp **qp_table;
4547
unsigned int qp_table_sz_m1;
4648
pthread_spinlock_t qp_table_lock;
@@ -62,6 +64,7 @@ struct efa_sub_cq {
6264

6365
struct efa_cq {
6466
struct verbs_cq verbs_cq;
67+
struct efadv_cq dv_cq;
6568
uint32_t cqn;
6669
size_t cqe_size;
6770
uint8_t *buf;
@@ -174,6 +177,11 @@ static inline struct efa_cq *to_efa_cq_ex(struct ibv_cq_ex *ibvcqx)
174177
return container_of(ibvcqx, struct efa_cq, verbs_cq.cq_ex);
175178
}
176179

180+
static inline struct efa_cq *efadv_cq_to_efa_cq(struct efadv_cq *efadv_cq)
181+
{
182+
return container_of(efadv_cq, struct efa_cq, dv_cq);
183+
}
184+
177185
static inline struct efa_qp *to_efa_qp(struct ibv_qp *ibvqp)
178186
{
179187
return container_of(ibvqp, struct efa_qp, verbs_qp.qp);

providers/efa/efa_io_defs.h

+6-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
22
/*
3-
* Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#ifndef _EFA_IO_H_
@@ -219,9 +219,7 @@ struct efa_io_cdesc_common {
219219
* 2:1 : q_type - enum efa_io_queue_type: send/recv
220220
* 3 : has_imm - indicates that immediate data is
221221
* present - for RX completions only
222-
* 4 : wide_completion - indicates that wide
223-
* completion format is used
224-
* 7:5 : reserved29
222+
* 7:4 : reserved28 - MBZ
225223
*/
226224
uint8_t flags;
227225

@@ -253,33 +251,15 @@ struct efa_io_rx_cdesc {
253251
};
254252

255253
/* Extended Rx Completion Descriptor */
256-
struct efa_io_rx_cdesc_wide {
254+
struct efa_io_rx_cdesc_ex {
257255
/* Base RX completion info */
258256
struct efa_io_rx_cdesc rx_cdesc_base;
259257

260258
/*
261-
* Word 0 of remote (source) address, needed only for in-band
262-
* ad-hoc AH support
259+
* Valid only in case of unknown AH (0xFFFF) and CQ set_src_addr is
260+
* enabled.
263261
*/
264-
uint32_t src_addr_0;
265-
266-
/*
267-
* Word 1 of remote (source) address, needed only for in-band
268-
* ad-hoc AH support
269-
*/
270-
uint32_t src_addr_1;
271-
272-
/*
273-
* Word 2 of remote (source) address, needed only for in-band
274-
* ad-hoc AH support
275-
*/
276-
uint32_t src_addr_2;
277-
278-
/*
279-
* Word 3 of remote (source) address, needed only for in-band
280-
* ad-hoc AH support
281-
*/
282-
uint32_t src_addr_3;
262+
uint8_t src_addr[16];
283263
};
284264

285265
/* tx_meta_desc */
@@ -305,6 +285,5 @@ struct efa_io_rx_cdesc_wide {
305285
#define EFA_IO_CDESC_COMMON_PHASE_MASK BIT(0)
306286
#define EFA_IO_CDESC_COMMON_Q_TYPE_MASK GENMASK(2, 1)
307287
#define EFA_IO_CDESC_COMMON_HAS_IMM_MASK BIT(3)
308-
#define EFA_IO_CDESC_COMMON_WIDE_COMPLETION_MASK BIT(4)
309288

310289
#endif /* _EFA_IO_H_ */

providers/efa/efadv.h

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
22
/*
3-
* Copyright 2019-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
3+
* Copyright 2019-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#ifndef __EFADV_H__
@@ -38,6 +38,7 @@ struct ibv_qp *efadv_create_qp_ex(struct ibv_context *ibvctx,
3838
enum {
3939
EFADV_DEVICE_ATTR_CAPS_RDMA_READ = 1 << 0,
4040
EFADV_DEVICE_ATTR_CAPS_RNR_RETRY = 1 << 1,
41+
EFADV_DEVICE_ATTR_CAPS_CQ_WITH_SGID = 1 << 2,
4142
};
4243

4344
struct efadv_device_attr {
@@ -65,6 +66,33 @@ struct efadv_ah_attr {
6566
int efadv_query_ah(struct ibv_ah *ibvah, struct efadv_ah_attr *attr,
6667
uint32_t inlen);
6768

69+
struct efadv_cq {
70+
uint64_t comp_mask;
71+
int (*wc_read_sgid)(struct efadv_cq *efadv_cq, union ibv_gid *sgid);
72+
};
73+
74+
enum {
75+
EFADV_WC_EX_WITH_SGID = 1 << 0,
76+
};
77+
78+
struct efadv_cq_init_attr {
79+
uint64_t comp_mask;
80+
uint64_t wc_flags;
81+
};
82+
83+
struct ibv_cq_ex *efadv_create_cq(struct ibv_context *ibvctx,
84+
struct ibv_cq_init_attr_ex *attr_ex,
85+
struct efadv_cq_init_attr *efa_attr,
86+
uint32_t inlen);
87+
88+
struct efadv_cq *efadv_cq_from_ibv_cq_ex(struct ibv_cq_ex *ibvcqx);
89+
90+
static inline int efadv_wc_read_sgid(struct efadv_cq *efadv_cq,
91+
union ibv_gid *sgid)
92+
{
93+
return efadv_cq->wc_read_sgid(efadv_cq, sgid);
94+
}
95+
6896
#ifdef __cplusplus
6997
}
7098
#endif

providers/efa/libefa.map

+7
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ EFA_1.1 {
1212
efadv_query_ah;
1313
efadv_query_device;
1414
} EFA_1.0;
15+
16+
EFA_1.2 {
17+
global:
18+
efadv_cq_from_ibv_cq_ex;
19+
efadv_create_cq;
20+
efadv_wc_read_sgid;
21+
} EFA_1.1;
+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
layout: page
3+
title: EFADV_CREATE_CQ
4+
section: 3
5+
tagline: Verbs
6+
date: 2021-01-04
7+
header: "EFA Direct Verbs Manual"
8+
footer: efa
9+
---
10+
11+
# NAME
12+
13+
efadv_create_cq - Create EFA specific Completion Queue (CQ)
14+
15+
# SYNOPSIS
16+
17+
```c
18+
#include <infiniband/efadv.h>
19+
20+
struct ibv_cq_ex *efadv_create_cq(struct ibv_context *context,
21+
struct ibv_cq_init_attr_ex *attr_ex,
22+
struct efadv_cq_init_attr *efa_attr,
23+
uint32_t inlen);
24+
25+
static inline int efadv_wc_read_sgid(struct efadv_cq *efadv_cq,
26+
union ibv_gid *sgid);
27+
```
28+
29+
# DESCRIPTION
30+
31+
**efadv_create_cq()** creates a Completion Queue (CQ) with specific driver
32+
properties.
33+
34+
The argument attr_ex is an ibv_cq_init_attr_ex struct,
35+
as defined in <infiniband/verbs.h>.
36+
37+
The EFADV work completions APIs (efadv_wc_\*) is an extension for IBV work
38+
completions API (ibv_wc_\*) with efa specific features for polling fields in
39+
the completion. This may be used together with or without ibv_wc_* calls.
40+
41+
Use efadv_cq_from_ibv_cq_ex() to get the efadv_cq for accessing the work
42+
completion interface.
43+
44+
Compatibility is handled using the comp_mask and inlen fields.
45+
46+
```c
47+
struct efadv_cq_init_attr {
48+
uint64_t comp_mask;
49+
uint64_t wc_flags;
50+
};
51+
```
52+
53+
*inlen*
54+
: In: Size of struct efadv_cq_init_attr.
55+
56+
*comp_mask*
57+
: Compatibility mask.
58+
59+
*wc_flags*
60+
: A bitwise OR of the various values described below.
61+
62+
EFADV_WC_EX_WITH_SGID:
63+
if source AH is unknown, require sgid in WC.
64+
65+
66+
# Completion iterator functions
67+
68+
*efadv_wc_read_sgid*
69+
: Get the source GID field from the current completion.
70+
If the AH is known, a negative error value is returned.
71+
72+
73+
# RETURN VALUE
74+
75+
efadv_create_cq() returns a pointer to the created extended CQ, or NULL if the
76+
request fails.
77+
78+
# SEE ALSO
79+
80+
**efadv**(7), **ibv_create_cq_ex**(3)
81+
82+
# AUTHORS
83+
84+
Daniel Kranzdorf <[email protected]>

providers/efa/man/efadv_query_device.3.md

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ struct efadv_device_attr {
7272
EFADV_DEVICE_ATTR_CAPS_RNR_RETRY:
7373
RNR retry is supported for SRD QPs.
7474

75+
EFADV_DEVICE_ATTR_CAPS_CQ_WITH_SGID:
76+
Reading source address (SGID) from receive completion descriptors is supported.
77+
Valid only for unknown AH.
78+
7579
*max_rdma_size*
7680
: Maximum RDMA transfer size in bytes.
7781

0 commit comments

Comments
 (0)