Skip to content

Commit ac1b36e

Browse files
Ram Amranidledford
authored andcommitted
qedr: Add support for user context verbs
Add support for ucontext, query port, add and del gid verbs. Signed-off-by: Rajesh Borundia <[email protected]> Signed-off-by: Ram Amrani <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent ec72fce commit ac1b36e

File tree

6 files changed

+622
-1
lines changed

6 files changed

+622
-1
lines changed

drivers/infiniband/hw/qedr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
obj-$(CONFIG_INFINIBAND_QEDR) := qedr.o
22

3-
qedr-y := main.o
3+
qedr-y := main.o verbs.o

drivers/infiniband/hw/qedr/main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@
3232
#include <linux/module.h>
3333
#include <rdma/ib_verbs.h>
3434
#include <rdma/ib_addr.h>
35+
#include <rdma/ib_user_verbs.h>
3536
#include <linux/netdevice.h>
3637
#include <linux/iommu.h>
3738
#include <net/addrconf.h>
3839
#include <linux/qed/qede_roce.h>
3940
#include <linux/qed/qed_chain.h>
4041
#include <linux/qed/qed_if.h>
4142
#include "qedr.h"
43+
#include "verbs.h"
44+
#include <rdma/qedr-abi.h>
4245

4346
MODULE_DESCRIPTION("QLogic 40G/100G ROCE Driver");
4447
MODULE_AUTHOR("QLogic Corporation");
@@ -80,6 +83,29 @@ static int qedr_register_device(struct qedr_dev *dev)
8083

8184
memcpy(dev->ibdev.node_desc, QEDR_NODE_DESC, sizeof(QEDR_NODE_DESC));
8285
dev->ibdev.owner = THIS_MODULE;
86+
dev->ibdev.uverbs_abi_ver = QEDR_ABI_VERSION;
87+
88+
dev->ibdev.uverbs_cmd_mask = QEDR_UVERBS(GET_CONTEXT) |
89+
QEDR_UVERBS(QUERY_DEVICE) |
90+
QEDR_UVERBS(QUERY_PORT);
91+
92+
dev->ibdev.phys_port_cnt = 1;
93+
dev->ibdev.num_comp_vectors = dev->num_cnq;
94+
dev->ibdev.node_type = RDMA_NODE_IB_CA;
95+
96+
dev->ibdev.query_device = qedr_query_device;
97+
dev->ibdev.query_port = qedr_query_port;
98+
dev->ibdev.modify_port = qedr_modify_port;
99+
100+
dev->ibdev.query_gid = qedr_query_gid;
101+
dev->ibdev.add_gid = qedr_add_gid;
102+
dev->ibdev.del_gid = qedr_del_gid;
103+
104+
dev->ibdev.alloc_ucontext = qedr_alloc_ucontext;
105+
dev->ibdev.dealloc_ucontext = qedr_dealloc_ucontext;
106+
dev->ibdev.mmap = qedr_mmap;
107+
108+
dev->ibdev.dma_device = &dev->pdev->dev;
83109

84110
dev->ibdev.get_link_layer = qedr_link_layer;
85111
dev->ibdev.get_dev_fw_str = qedr_get_dev_fw_str;

drivers/infiniband/hw/qedr/qedr.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
DP_NAME(dev) ? DP_NAME(dev) : "", ## __VA_ARGS__)
5050

5151
#define QEDR_MSG_INIT "INIT"
52+
#define QEDR_MSG_MISC "MISC"
5253

5354
struct qedr_dev;
5455

@@ -176,6 +177,39 @@ struct qedr_dev {
176177

177178
#define QEDR_UVERBS(CMD_NAME) (1ull << IB_USER_VERBS_CMD_##CMD_NAME)
178179

180+
#define QEDR_ROCE_PKEY_MAX 1
181+
#define QEDR_ROCE_PKEY_TABLE_LEN 1
182+
#define QEDR_ROCE_PKEY_DEFAULT 0xffff
183+
184+
struct qedr_ucontext {
185+
struct ib_ucontext ibucontext;
186+
struct qedr_dev *dev;
187+
struct qedr_pd *pd;
188+
u64 dpi_addr;
189+
u64 dpi_phys_addr;
190+
u32 dpi_size;
191+
u16 dpi;
192+
193+
struct list_head mm_head;
194+
195+
/* Lock to protect mm list */
196+
struct mutex mm_list_lock;
197+
};
198+
199+
struct qedr_mm {
200+
struct {
201+
u64 phy_addr;
202+
unsigned long len;
203+
} key;
204+
struct list_head entry;
205+
};
206+
207+
static inline
208+
struct qedr_ucontext *get_qedr_ucontext(struct ib_ucontext *ibucontext)
209+
{
210+
return container_of(ibucontext, struct qedr_ucontext, ibucontext);
211+
}
212+
179213
static inline struct qedr_dev *get_qedr_dev(struct ib_device *ibdev)
180214
{
181215
return container_of(ibdev, struct qedr_dev, ibdev);

0 commit comments

Comments
 (0)