Skip to content

Commit 943e30e

Browse files
mrgolinpaniakin-aws
authored andcommitted
AL2 5.15 Update EFA driver to 2.13.0
Signed-off-by: Michael Margolin <mrgolin@amazon.com> Signed-off-by: Mahmoud Adam <mngyadam@amazon.com>
1 parent c700349 commit 943e30e

File tree

15 files changed

+1934
-118
lines changed

15 files changed

+1934
-118
lines changed

drivers/amazon/net/efa/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
obj-$(CONFIG_AMAZON_EFA_INFINIBAND) += efa.o
88

99
efa-y := efa_com.o efa_com_cmd.o efa_gdr.o efa_main.o efa_neuron.o efa_p2p.o
10-
efa-y += efa_verbs.o
10+
efa-y += efa_verbs.o efa_data_verbs.o
1111

1212
efa-$(CONFIG_SYSFS) += efa_sysfs.o

drivers/amazon/net/efa/efa.h

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct efa_stats {
4444
atomic64_t create_ah_err;
4545
atomic64_t mmap_err;
4646
atomic64_t keep_alive_rcvd;
47+
atomic64_t alloc_mr_err;
48+
atomic64_t get_dma_mr_err;
4749
};
4850

4951
struct efa_dev {
@@ -58,7 +60,10 @@ struct efa_dev {
5860
u64 mem_bar_len;
5961
u64 db_bar_addr;
6062
u64 db_bar_len;
63+
u8 __iomem *mem_bar;
64+
u8 __iomem *db_bar;
6165

66+
unsigned int num_irq_vectors;
6267
int admin_msix_vector_idx;
6368
struct efa_irq admin_irq;
6469

@@ -70,6 +75,11 @@ struct efa_dev {
7075

7176
/* Only stores CQs with interrupts enabled */
7277
struct xarray cqs_xa;
78+
u16 uarn;
79+
struct efa_qp **qp_table;
80+
/* Protects against simultaneous QPs insertion or removal */
81+
spinlock_t qp_table_lock;
82+
u32 qp_table_mask;
7383
};
7484

7585
struct efa_ucontext {
@@ -93,10 +103,32 @@ struct efa_mr_interconnect_info {
93103

94104
struct efa_mr {
95105
struct ib_mr ibmr;
96-
struct ib_umem *umem;
97-
struct efa_mr_interconnect_info ic_info;
98-
struct efa_p2pmem *p2pmem;
99-
u64 p2p_ticket;
106+
union {
107+
/* Used only by kernel MRs */
108+
struct {
109+
u64 *pages_list;
110+
u32 pages_list_length;
111+
dma_addr_t pages_list_dma_addr;
112+
u32 num_pages;
113+
};
114+
115+
/* Used only by User MRs */
116+
struct {
117+
struct ib_umem *umem;
118+
struct efa_mr_interconnect_info ic_info;
119+
struct efa_p2pmem *p2pmem;
120+
u64 p2p_ticket;
121+
};
122+
};
123+
};
124+
125+
struct efa_sub_cq {
126+
u8 *buf;
127+
u32 cqe_size;
128+
u32 queue_mask;
129+
u32 ref_cnt;
130+
u32 consumed_cnt;
131+
int phase;
100132
};
101133

102134
struct efa_cq {
@@ -110,6 +142,57 @@ struct efa_cq {
110142
u16 cq_idx;
111143
/* NULL when no interrupts requested */
112144
struct efa_eq *eq;
145+
u8 *buf;
146+
size_t buf_size;
147+
struct efa_sub_cq *sub_cq_arr;
148+
u16 num_sub_cqs;
149+
u32 *db;
150+
/* Index of next sub cq idx to poll. This is used to guarantee fairness for sub cqs */
151+
u16 next_poll_idx;
152+
/* Protects the access to the CQ and CQ to QP association */
153+
u16 cc; /* Consumer Counter */
154+
u8 cmd_sn;
155+
spinlock_t lock;
156+
};
157+
158+
struct efa_wq {
159+
u64 *wrid;
160+
/* wrid_idx_pool: Pool of free indexes in the wrid array, used to select the
161+
* wrid entry to be used to hold the next tx packet's context.
162+
* At init time, entry N will hold value N, as OOO tx-completions arrive,
163+
* the value stored in a given entry might not equal the entry's index.
164+
*/
165+
u32 *wrid_idx_pool;
166+
/* wrid_idx_pool_next: Index of the next entry to use in wrid_idx_pool. */
167+
u32 wrid_idx_pool_next;
168+
u32 max_sge;
169+
u32 max_wqes;
170+
u32 queue_mask;
171+
u32 *db;
172+
u32 wqes_posted;
173+
u32 wqes_completed;
174+
/* Producer counter */
175+
u32 pc;
176+
int phase;
177+
u16 sub_cq_idx;
178+
/* Synchronizes access to the WQ on datapath */
179+
spinlock_t lock;
180+
};
181+
182+
struct efa_rq {
183+
struct efa_wq wq;
184+
u8 *buf;
185+
size_t buf_size;
186+
};
187+
188+
struct efa_sq {
189+
struct efa_wq wq;
190+
u8 *desc;
191+
u32 desc_offset;
192+
u32 max_inline_data;
193+
u32 max_rdma_sges;
194+
u32 max_batch_wr;
195+
enum ib_sig_type sig_type;
113196
};
114197

115198
struct efa_qp {
@@ -131,6 +214,8 @@ struct efa_qp {
131214
u32 max_send_sge;
132215
u32 max_recv_sge;
133216
u32 max_inline_data;
217+
struct efa_sq sq;
218+
struct efa_rq rq;
134219
};
135220

136221
struct efa_ah {
@@ -172,6 +257,9 @@ struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,
172257
u64 length, u64 virt_addr,
173258
int fd, int access_flags,
174259
struct ib_udata *udata);
260+
struct ib_mr *efa_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
261+
struct ib_mr *efa_alloc_fast_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
262+
u32 max_num_sg);
175263
int efa_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
176264
int efa_get_port_immutable(struct ib_device *ibdev, port_t port_num,
177265
struct ib_port_immutable *immutable);
@@ -184,6 +272,16 @@ int efa_create_ah(struct ib_ah *ibah,
184272
struct rdma_ah_init_attr *init_attr,
185273
struct ib_udata *udata);
186274
int efa_destroy_ah(struct ib_ah *ibah, u32 flags);
275+
int efa_post_send(struct ib_qp *ibqp,
276+
const struct ib_send_wr *wr,
277+
const struct ib_send_wr **bad_wr);
278+
int efa_post_recv(struct ib_qp *ibqp,
279+
const struct ib_recv_wr *wr,
280+
const struct ib_recv_wr **bad_wr);
281+
int efa_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
282+
int efa_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
283+
int efa_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
284+
unsigned int *sg_offset);
187285
int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
188286
int qp_attr_mask, struct ib_udata *udata);
189287
enum rdma_link_layer efa_port_link_layer(struct ib_device *ibdev,

drivers/amazon/net/efa/efa_admin_cmds_defs.h

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ enum efa_admin_aq_opcode {
3030
EFA_ADMIN_DEALLOC_UAR = 17,
3131
EFA_ADMIN_CREATE_EQ = 18,
3232
EFA_ADMIN_DESTROY_EQ = 19,
33-
EFA_ADMIN_MAX_OPCODE = 19,
33+
EFA_ADMIN_ALLOC_MR = 20,
34+
EFA_ADMIN_MAX_OPCODE = 20,
3435
};
3536

3637
enum efa_admin_aq_feature_id {
@@ -110,7 +111,10 @@ struct efa_admin_create_qp_cmd {
110111
* virtual (IOVA returned by MR registration)
111112
* 1 : rq_virt - If set, RQ ring base address is
112113
* virtual (IOVA returned by MR registration)
113-
* 7:2 : reserved - MBZ
114+
* 2 : unsolicited_write_recv - If set, work requests
115+
* will not be consumed for incoming RDMA write with
116+
* immediate
117+
* 7:3 : reserved - MBZ
114118
*/
115119
u8 flags;
116120

@@ -147,8 +151,11 @@ struct efa_admin_create_qp_cmd {
147151
/* UAR number */
148152
u16 uar;
149153

154+
/* Requested service level for the QP, 0 is the default SL */
155+
u8 sl;
156+
150157
/* MBZ */
151-
u16 reserved;
158+
u8 reserved;
152159

153160
/* MBZ */
154161
u32 reserved2;
@@ -456,6 +463,41 @@ struct efa_admin_dereg_mr_resp {
456463
struct efa_admin_acq_common_desc acq_common_desc;
457464
};
458465

466+
/*
467+
* Allocation of MemoryRegion, required for QP working with Virtual
468+
* Addresses in kernel verbs semantics, ready for fast registration use.
469+
*/
470+
struct efa_admin_alloc_mr_cmd {
471+
/* Common Admin Queue descriptor */
472+
struct efa_admin_aq_common_desc aq_common_desc;
473+
474+
/* Protection Domain */
475+
u16 pd;
476+
477+
/* MBZ */
478+
u16 reserved1;
479+
480+
/* Maximum number of pages this MR supports. */
481+
u32 max_pages;
482+
};
483+
484+
struct efa_admin_alloc_mr_resp {
485+
/* Common Admin Queue completion descriptor */
486+
struct efa_admin_acq_common_desc acq_common_desc;
487+
488+
/*
489+
* L_Key, to be used in conjunction with local buffer references in
490+
* SQ and RQ WQE, or with virtual RQ/CQ rings
491+
*/
492+
u32 l_key;
493+
494+
/*
495+
* R_Key, to be used in RDMA messages to refer to remotely accessed
496+
* memory region
497+
*/
498+
u32 r_key;
499+
};
500+
459501
struct efa_admin_create_cq_cmd {
460502
struct efa_admin_aq_common_desc aq_common_desc;
461503

@@ -480,8 +522,8 @@ struct efa_admin_create_cq_cmd {
480522
*/
481523
u8 cq_caps_2;
482524

483-
/* completion queue depth in # of entries. must be power of 2 */
484-
u16 cq_depth;
525+
/* Sub completion queue depth in # of entries. must be power of 2 */
526+
u16 sub_cq_depth;
485527

486528
/* EQ number assigned to this cq */
487529
u16 eqn;
@@ -516,8 +558,8 @@ struct efa_admin_create_cq_resp {
516558

517559
u16 cq_idx;
518560

519-
/* actual cq depth in number of entries */
520-
u16 cq_actual_depth;
561+
/* actual sub cq depth in number of entries */
562+
u16 sub_cq_actual_depth;
521563

522564
/* CQ doorbell address, as offset to PCIe DB BAR */
523565
u32 db_offset;
@@ -575,6 +617,8 @@ struct efa_admin_basic_stats {
575617
u64 rx_pkts;
576618

577619
u64 rx_drops;
620+
621+
u64 qkey_viol;
578622
};
579623

580624
struct efa_admin_messages_stats {
@@ -663,12 +707,26 @@ struct efa_admin_feature_device_attr_desc {
663707
* polling is supported
664708
* 3 : rdma_write - If set, RDMA Write is supported
665709
* on TX queues
666-
* 31:4 : reserved - MBZ
710+
* 4 : unsolicited_write_recv - If set, unsolicited
711+
* write with imm. receive is supported
712+
* 31:5 : reserved - MBZ
667713
*/
668714
u32 device_caps;
669715

670716
/* Max RDMA transfer size in bytes */
671717
u32 max_rdma_size;
718+
719+
/* Unique global ID for an EFA device */
720+
u64 guid;
721+
722+
/* The device maximum link speed in Gbit/sec */
723+
u16 max_link_speed_gbps;
724+
725+
/* MBZ */
726+
u16 reserved0;
727+
728+
/* MBZ */
729+
u32 reserved1;
672730
};
673731

674732
struct efa_admin_feature_queue_attr_desc {
@@ -1009,6 +1067,7 @@ struct efa_admin_host_info {
10091067
/* create_qp_cmd */
10101068
#define EFA_ADMIN_CREATE_QP_CMD_SQ_VIRT_MASK BIT(0)
10111069
#define EFA_ADMIN_CREATE_QP_CMD_RQ_VIRT_MASK BIT(1)
1070+
#define EFA_ADMIN_CREATE_QP_CMD_UNSOLICITED_WRITE_RECV_MASK BIT(2)
10121071

10131072
/* modify_qp_cmd */
10141073
#define EFA_ADMIN_MODIFY_QP_CMD_QP_STATE_MASK BIT(0)
@@ -1044,10 +1103,10 @@ struct efa_admin_host_info {
10441103
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RNR_RETRY_MASK BIT(1)
10451104
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_DATA_POLLING_128_MASK BIT(2)
10461105
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_WRITE_MASK BIT(3)
1106+
#define EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_UNSOLICITED_WRITE_RECV_MASK BIT(4)
10471107

10481108
/* create_eq_cmd */
10491109
#define EFA_ADMIN_CREATE_EQ_CMD_ENTRY_SIZE_WORDS_MASK GENMASK(4, 0)
1050-
#define EFA_ADMIN_CREATE_EQ_CMD_VIRT_MASK BIT(6)
10511110
#define EFA_ADMIN_CREATE_EQ_CMD_COMPLETION_EVENTS_MASK BIT(0)
10521111

10531112
/* host_info */

drivers/amazon/net/efa/efa_admin_defs.h

Lines changed: 2 additions & 2 deletions
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-2024 Amazon.com, Inc. or its affiliates. All rights reserved.
44
*/
55

66
#ifndef _EFA_ADMIN_H_
@@ -96,7 +96,7 @@ struct efa_admin_acq_entry {
9696
struct efa_admin_aenq_common_desc {
9797
u16 group;
9898

99-
u16 syndrom;
99+
u16 syndrome;
100100

101101
/*
102102
* 0 : phase

0 commit comments

Comments
 (0)