Skip to content

Commit e952c49

Browse files
authored
Merge pull request #1739 from amzn/processing-hints
EFA work request processing hints
2 parents a68c2a6 + 2fa5086 commit e952c49

14 files changed

Lines changed: 191 additions & 13 deletions

debian/ibverbs-providers.symbols

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ libefa.so.1 ibverbs-providers #MINVER#
187187
EFA_1.3@EFA_1.3 50
188188
EFA_1.4@EFA_1.4 59
189189
EFA_1.5@EFA_1.5 63
190+
EFA_1.6@EFA_1.6 64
190191
efadv_create_driver_qp@EFA_1.0 24
191192
efadv_create_qp_ex@EFA_1.1 26
192193
efadv_query_device@EFA_1.1 26
@@ -198,6 +199,7 @@ libefa.so.1 ibverbs-providers #MINVER#
198199
efadv_query_cq@EFA_1.4 59
199200
efadv_get_max_sq_depth@EFA_1.5 63
200201
efadv_get_max_rq_depth@EFA_1.5 63
202+
efadv_qp_from_ibv_qp_ex@EFA_1.6 64
201203
libhns.so.1 ibverbs-providers #MINVER#
202204
* Build-Depends-Package: libibverbs-dev
203205
HNS_1.0@HNS_1.0 51

providers/efa/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (ENABLE_LTTNG AND LTTNGUST_FOUND)
33
endif()
44

55
rdma_shared_provider(efa libefa.map
6-
1 1.5.${PACKAGE_VERSION}
6+
1 1.6.${PACKAGE_VERSION}
77
${TRACE_FILE}
88
efa.c
99
verbs.c

providers/efa/efa.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ struct efa_sq {
175175

176176
struct efa_qp {
177177
struct verbs_qp verbs_qp;
178+
struct efadv_qp dv_qp;
178179
struct efa_sq sq;
179180
struct efa_rq rq;
180181
int page_size;
@@ -239,6 +240,11 @@ static inline struct efa_qp *to_efa_qp_ex(struct ibv_qp_ex *ibvqpx)
239240
return container_of(ibvqpx, struct efa_qp, verbs_qp.qp_ex);
240241
}
241242

243+
static inline struct efa_qp *efadv_qp_to_efa_qp(struct efadv_qp *efadv_qp)
244+
{
245+
return container_of(efadv_qp, struct efa_qp, dv_qp);
246+
}
247+
242248
static inline struct efa_ah *to_efa_ah(struct ibv_ah *ibvah)
243249
{
244250
return container_of(ibvah, struct efa_ah, ibvah);

providers/efa/efa_io_defs.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ enum efa_io_comp_status {
6565
EFA_IO_COMP_STATUS_REMOTE_ERROR_FEATURE_MISMATCH = 18,
6666
};
6767

68+
enum efa_io_processing_hint {
69+
/* Optimize for throughput */
70+
EFA_IO_PROCESSING_HINT_BURST_PPS_SENSITIVE = 1 << 0,
71+
};
72+
6873
struct efa_io_tx_meta_desc {
6974
/* Verbs-generated Request ID */
7075
uint16_t req_id;
@@ -114,7 +119,15 @@ struct efa_io_tx_meta_desc {
114119

115120
uint16_t ah;
116121

117-
uint16_t reserved;
122+
/*
123+
* control flags
124+
* 1:0 : processing_hints - Bitmask of enum
125+
* efa_io_processing_hint
126+
* 7:2 : reserved - MBZ
127+
*/
128+
uint8_t ctrl3;
129+
130+
uint8_t reserved;
118131

119132
/* Queue key */
120133
uint32_t qkey;
@@ -327,6 +340,7 @@ struct efa_io_rx_cdesc_ex {
327340
#define EFA_IO_TX_META_DESC_FIRST_MASK BIT(2)
328341
#define EFA_IO_TX_META_DESC_LAST_MASK BIT(3)
329342
#define EFA_IO_TX_META_DESC_COMP_REQ_MASK BIT(4)
343+
#define EFA_IO_TX_META_DESC_PROCESSING_HINTS_MASK GENMASK(1, 0)
330344

331345
/* tx_buf_desc */
332346
#define EFA_IO_TX_BUF_DESC_LKEY_MASK GENMASK(23, 0)

providers/efa/efadv.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ enum {
8787
EFADV_QP_FLAGS_INLINE_WRITE = 1 << 1,
8888
};
8989

90+
enum {
91+
EFADV_WR_EX_WITH_PROCESSING_HINTS = 1 << 0,
92+
};
93+
9094
struct efadv_qp_init_attr {
9195
uint64_t comp_mask;
9296
uint32_t driver_qp_type;
9397
uint16_t flags;
9498
uint8_t sl;
9599
uint8_t reserved;
100+
uint64_t wr_flags;
96101
};
97102

98103
struct ibv_qp *efadv_create_qp_ex(struct ibv_context *ibvctx,
@@ -113,12 +118,22 @@ struct efadv_wq_attr {
113118
int efadv_query_qp_wqs(struct ibv_qp *ibvqp, struct efadv_wq_attr *sq_attr,
114119
struct efadv_wq_attr *rq_attr, uint32_t inlen);
115120

116-
struct efadv_cq {
121+
enum efadv_wr_processing_hint {
122+
EFADV_WR_PROCESSING_HINT_BURST_PPS_SENSITIVE = 1 << 0,
123+
};
124+
125+
struct efadv_qp {
117126
uint64_t comp_mask;
118-
int (*wc_read_sgid)(struct efadv_cq *efadv_cq, union ibv_gid *sgid);
119-
bool (*wc_is_unsolicited)(struct efadv_cq *efadv_cq);
127+
void (*wr_set_processing_hints)(struct efadv_qp *efadv_qp, uint32_t hints);
120128
};
121129

130+
struct efadv_qp *efadv_qp_from_ibv_qp_ex(struct ibv_qp_ex *ibvqpx);
131+
132+
static inline void efadv_wr_set_processing_hints(struct efadv_qp *efadv_qp, uint32_t hints)
133+
{
134+
efadv_qp->wr_set_processing_hints(efadv_qp, hints);
135+
}
136+
122137
enum {
123138
EFADV_WC_EX_WITH_SGID = 1 << 0,
124139
EFADV_WC_EX_WITH_IS_UNSOLICITED = 1 << 1,
@@ -156,6 +171,12 @@ struct efadv_cq_attr {
156171

157172
int efadv_query_cq(struct ibv_cq *ibvcq, struct efadv_cq_attr *attr, uint32_t inlen);
158173

174+
struct efadv_cq {
175+
uint64_t comp_mask;
176+
int (*wc_read_sgid)(struct efadv_cq *efadv_cq, union ibv_gid *sgid);
177+
bool (*wc_is_unsolicited)(struct efadv_cq *efadv_cq);
178+
};
179+
159180
struct efadv_cq *efadv_cq_from_ibv_cq_ex(struct ibv_cq_ex *ibvcqx);
160181

161182
static inline int efadv_wc_read_sgid(struct efadv_cq *efadv_cq,

providers/efa/libefa.map

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ EFA_1.5 {
3535
efadv_get_max_sq_depth;
3636
efadv_get_max_rq_depth;
3737
} EFA_1.4;
38+
39+
EFA_1.6 {
40+
global:
41+
efadv_qp_from_ibv_qp_ex;
42+
} EFA_1.5;

providers/efa/man/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ rdma_man_pages(
77
efadv_query_device.3.md
88
efadv_query_mr.3.md
99
efadv_query_qp_wqs.3.md
10+
efadv_wr_set_processing_hints.3.md
1011
)

providers/efa/man/efadv_create_qp_ex.3.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ struct efadv_qp_init_attr {
4646
uint32_t driver_qp_type;
4747
uint16_t flags;
4848
uint8_t sl;
49-
uint8_t reserved[1];
49+
uint8_t reserved;
50+
uint64_t wr_flags;
5051
};
5152
```
5253

@@ -74,6 +75,15 @@ struct efadv_qp_init_attr {
7475
*sl*
7576
: Service Level - 0 value implies default level.
7677

78+
*wr_flags*
79+
: A bitwise OR of the values described below. Controls which
80+
EFA-specific work request setter functions are available on
81+
the QP. Use **efadv_qp_from_ibv_qp_ex()** to get the
82+
efadv_qp for accessing the work request setter interface.
83+
84+
EFADV_WR_EX_WITH_PROCESSING_HINTS:
85+
Enable **efadv_wr_set_processing_hints()** on this QP.
86+
7787
# RETURN VALUE
7888

7989
efadv_create_qp_ex() returns a pointer to the created QP, or NULL if the request fails.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
layout: page
3+
title: EFADV_WR_SET_PROCESSING_HINTS
4+
section: 3
5+
tagline: Verbs
6+
date: 2026-05-05
7+
header: "EFA Direct Verbs Manual"
8+
footer: efa
9+
---
10+
11+
# NAME
12+
13+
efadv_wr_set_processing_hints - Set processing hints on the current
14+
work request
15+
16+
# SYNOPSIS
17+
18+
```c
19+
#include <infiniband/efadv.h>
20+
21+
static inline void efadv_wr_set_processing_hints(
22+
struct efadv_qp *efadv_qp,
23+
uint32_t hints);
24+
```
25+
26+
# DESCRIPTION
27+
28+
**efadv_wr_set_processing_hints()** sets processing hints on the
29+
current work request being built. Hints allow the application to
30+
communicate intended usage patterns to the device, which may use them
31+
to optimize processing.
32+
33+
This function is a work request setter and must be called after the
34+
work request opcode function (e.g. **ibv_wr_send()**) and before
35+
**ibv_wr_complete()** or the next work request opcode call.
36+
37+
Use **efadv_qp_from_ibv_qp_ex()** to get the efadv_qp for accessing
38+
this interface.
39+
40+
The QP must be created with **EFADV_WR_EX_WITH_PROCESSING_HINTS** set
41+
in *efadv_qp_init_attr.wr_flags* to use this function.
42+
43+
The *hints* argument is a bitmask of **efadv_wr_processing_hint**
44+
values:
45+
46+
```c
47+
enum efadv_wr_processing_hint {
48+
EFADV_WR_PROCESSING_HINT_BURST_PPS_SENSITIVE = 1 << 0,
49+
};
50+
```
51+
52+
*EFADV_WR_PROCESSING_HINT_BURST_PPS_SENSITIVE*
53+
: Optimize for throughput in bursty, packet-rate sensitive
54+
workloads.
55+
56+
# SEE ALSO
57+
58+
**efadv**(7), **efadv_create_qp_ex**(3), **ibv_wr_start**(3)
59+
60+
# AUTHORS
61+
62+
Michael Margolin <mrgolin@amazon.com>

providers/efa/verbs.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,8 +1777,9 @@ static void efa_unlock_cqs(struct ibv_qp *ibvqp)
17771777
}
17781778
}
17791779

1780-
static void efa_qp_fill_wr_pfns(struct ibv_qp_ex *ibvqpx,
1780+
static void efa_qp_fill_wr_pfns(struct efa_qp *qp,
17811781
struct ibv_qp_init_attr_ex *attr_ex,
1782+
struct efadv_qp_init_attr *efa_attr,
17821783
uint16_t wqe_size);
17831784

17841785
static int efa_check_qp_attr(struct efa_context *ctx,
@@ -1853,6 +1854,12 @@ static int efa_check_qp_attr(struct efa_context *ctx,
18531854
}
18541855
}
18551856

1857+
if (!check_comp_mask(efa_attr->wr_flags, EFADV_WR_EX_WITH_PROCESSING_HINTS)) {
1858+
verbs_err(&ctx->ibvctx, "Unsupported wr_flags[%" PRIx64 "]\n",
1859+
efa_attr->wr_flags);
1860+
return EOPNOTSUPP;
1861+
}
1862+
18561863
if (!attr->recv_cq || !attr->send_cq) {
18571864
verbs_err(&ctx->ibvctx, "Send/Receive CQ not provided\n");
18581865
return EINVAL;
@@ -1983,7 +1990,7 @@ static struct ibv_qp *create_qp(struct ibv_context *ibvctx,
19831990
pthread_spin_unlock(&ctx->qp_table_lock);
19841991

19851992
if (attr->comp_mask & IBV_QP_INIT_ATTR_SEND_OPS_FLAGS) {
1986-
efa_qp_fill_wr_pfns(&qp->verbs_qp.qp_ex, attr, qp->sq.wqe_size);
1993+
efa_qp_fill_wr_pfns(qp, attr, efa_attr, qp->sq.wqe_size);
19871994
qp->verbs_qp.comp_mask |= VERBS_QP_EX;
19881995
}
19891996

@@ -2185,6 +2192,13 @@ int efa_query_qp_data_in_order(struct ibv_qp *ibvqp, enum ibv_wr_opcode op,
21852192
return caps;
21862193
}
21872194

2195+
struct efadv_qp *efadv_qp_from_ibv_qp_ex(struct ibv_qp_ex *ibvqpx)
2196+
{
2197+
struct efa_qp *qp = to_efa_qp_ex(ibvqpx);
2198+
2199+
return &qp->dv_qp;
2200+
}
2201+
21882202
int efa_destroy_qp(struct ibv_qp *ibvqp)
21892203
{
21902204
struct efa_context *ctx = to_efa_context(ibvqp->context);
@@ -2912,6 +2926,20 @@ static void efa_send_wr_set_addr(struct ibv_qp_ex *ibvqpx,
29122926
efa_wqe_get_data_length(qp->sq));
29132927
}
29142928

2929+
static void efa_send_wr_set_processing_hints(struct efadv_qp *efadv_qp, uint32_t hints)
2930+
{
2931+
struct efa_qp *qp = efadv_qp_to_efa_qp(efadv_qp);
2932+
uint8_t wqe_hints = 0;
2933+
2934+
if (unlikely(qp->wr_session_err))
2935+
return;
2936+
2937+
if (hints & EFADV_WR_PROCESSING_HINT_BURST_PPS_SENSITIVE)
2938+
wqe_hints |= EFA_IO_PROCESSING_HINT_BURST_PPS_SENSITIVE;
2939+
2940+
EFA_SET(&qp->sq.curr_tx_wqe.md->ctrl3, EFA_IO_TX_META_DESC_PROCESSING_HINTS, wqe_hints);
2941+
}
2942+
29152943
static void efa_send_wr_start(struct ibv_qp_ex *ibvqpx)
29162944
{
29172945
struct efa_qp *qp = to_efa_qp_ex(ibvqpx);
@@ -3012,11 +3040,13 @@ static void efa_send_wr_abort(struct ibv_qp_ex *ibvqpx)
30123040
pthread_spin_unlock(&sq->wq.wqlock);
30133041
}
30143042

3015-
static void efa_qp_fill_wr_pfns(struct ibv_qp_ex *ibvqpx,
3043+
static void efa_qp_fill_wr_pfns(struct efa_qp *qp,
30163044
struct ibv_qp_init_attr_ex *attr_ex,
3045+
struct efadv_qp_init_attr *efa_attr,
30173046
uint16_t wqe_size)
30183047
{
30193048
bool use_64 = wqe_size == EFA_IO_TX_DESC_SIZE_64;
3049+
struct ibv_qp_ex *ibvqpx = &qp->verbs_qp.qp_ex;
30203050

30213051
ibvqpx->wr_start = efa_send_wr_start;
30223052
ibvqpx->wr_complete = efa_send_wr_complete;
@@ -3045,6 +3075,9 @@ static void efa_qp_fill_wr_pfns(struct ibv_qp_ex *ibvqpx,
30453075
ibvqpx->wr_set_sge = efa_send_wr_set_sge;
30463076
ibvqpx->wr_set_sge_list = efa_send_wr_set_sge_list;
30473077
ibvqpx->wr_set_ud_addr = efa_send_wr_set_addr;
3078+
3079+
if (efa_attr->wr_flags & EFADV_WR_EX_WITH_PROCESSING_HINTS)
3080+
qp->dv_qp.wr_set_processing_hints = efa_send_wr_set_processing_hints;
30483081
}
30493082

30503083
static int efa_post_recv_validate(struct efa_qp *qp, struct ibv_recv_wr *wr)

0 commit comments

Comments
 (0)