1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#ifndef USNIC_IB_QP_GRP_H_
35#define USNIC_IB_QP_GRP_H_
36
37#include <linux/debugfs.h>
38#include <rdma/ib_verbs.h>
39
40#include "usnic_ib.h"
41#include "usnic_abi.h"
42#include "usnic_fwd.h"
43#include "usnic_vnic.h"
44
45
46
47
48struct usnic_ib_qp_grp {
49 struct ib_qp ibqp;
50 enum ib_qp_state state;
51 int grp_id;
52
53 struct usnic_fwd_dev *ufdev;
54 struct usnic_ib_ucontext *ctx;
55 struct list_head flows_lst;
56
57 struct usnic_vnic_res_chunk **res_chunk_list;
58
59 pid_t owner_pid;
60 struct usnic_ib_vf *vf;
61 struct list_head link;
62
63 spinlock_t lock;
64
65 struct kobject kobj;
66};
67
68struct usnic_ib_qp_grp_flow {
69 struct usnic_fwd_flow *flow;
70 enum usnic_transport_type trans_type;
71 union {
72 struct {
73 uint16_t port_num;
74 } usnic_roce;
75 struct {
76 struct socket *sock;
77 } udp;
78 };
79 struct usnic_ib_qp_grp *qp_grp;
80 struct list_head link;
81
82
83 struct dentry *dbgfs_dentry;
84 char dentry_name[32];
85};
86
87static const struct
88usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
89 {
90 .resources = {
91 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
92 },
93 },
94 {
95 .resources = {
96 {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
97 {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
98 {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
99 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
100 },
101 },
102 {
103 .resources = {
104 {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
105 {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
106 {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
107 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
108 },
109 },
110};
111
112const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
113int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
114int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
115struct usnic_ib_qp_grp *
116usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
117 struct usnic_ib_pd *pd,
118 struct usnic_vnic_res_spec *res_spec,
119 struct usnic_transport_spec *trans_spec);
120void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
121int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
122 enum ib_qp_state new_state,
123 void *data);
124struct usnic_vnic_res_chunk
125*usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
126 enum usnic_vnic_res_type type);
127static inline
128struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
129{
130 return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
131}
132#endif
133