blob: a8ba1b9224d8d4941eb19b23958d2ce5a8d7b4d7 [file] [log] [blame]
Upinder Malhie3cf00d2013-09-10 03:38:16 +00001/*
2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3 *
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
16 *
17 */
18
19#ifndef USNIC_IB_QP_GRP_H_
20#define USNIC_IB_QP_GRP_H_
21
22#include <rdma/ib_verbs.h>
23
24#include "usnic_ib.h"
25#include "usnic_abi.h"
26#include "usnic_fwd.h"
27#include "usnic_vnic.h"
28
Upinder Malhie3cf00d2013-09-10 03:38:16 +000029/*
30 * The qp group struct represents all the hw resources needed to present a ib_qp
31 */
32struct usnic_ib_qp_grp {
33 struct ib_qp ibqp;
34 enum ib_qp_state state;
35 int grp_id;
36
37 struct usnic_fwd_dev *ufdev;
Upinder Malhie3cf00d2013-09-10 03:38:16 +000038 struct usnic_ib_ucontext *ctx;
Upinder Malhi256d6a62014-01-09 14:48:09 -080039 struct list_head flows_lst;
Upinder Malhie3cf00d2013-09-10 03:38:16 +000040
41 struct usnic_vnic_res_chunk **res_chunk_list;
42
43 pid_t owner_pid;
44 struct usnic_ib_vf *vf;
45 struct list_head link;
46
47 spinlock_t lock;
48
49 struct kobject kobj;
50};
51
Upinder Malhi256d6a62014-01-09 14:48:09 -080052struct usnic_ib_qp_grp_flow {
53 struct usnic_fwd_flow *flow;
54 enum usnic_transport_type trans_type;
55 union {
56 struct {
57 uint16_t port_num;
58 } usnic_roce;
Upinder Malhie45e6142014-01-09 14:48:18 -080059 struct {
60 struct socket *sock;
61 } udp;
Upinder Malhi256d6a62014-01-09 14:48:09 -080062 };
63 struct usnic_ib_qp_grp *qp_grp;
64 struct list_head link;
65};
66
Upinder Malhie3cf00d2013-09-10 03:38:16 +000067static const struct
68usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
69 { /*USNIC_TRANSPORT_UNKNOWN*/
70 .resources = {
71 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
72 },
73 },
74 { /*USNIC_TRANSPORT_ROCE_CUSTOM*/
75 .resources = {
76 {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
77 {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
78 {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
79 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
80 },
81 },
Upinder Malhie45e6142014-01-09 14:48:18 -080082 { /*USNIC_TRANSPORT_IPV4_UDP*/
83 .resources = {
84 {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
85 {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
86 {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
87 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
88 },
89 },
Upinder Malhie3cf00d2013-09-10 03:38:16 +000090};
91
92const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
93int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
94int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
95struct usnic_ib_qp_grp *
96usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
97 struct usnic_ib_pd *pd,
98 struct usnic_vnic_res_spec *res_spec,
Upinder Malhi256d6a62014-01-09 14:48:09 -080099 struct usnic_transport_spec *trans_spec);
Upinder Malhie3cf00d2013-09-10 03:38:16 +0000100void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
101int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
102 enum ib_qp_state new_state,
Upinder Malhi256d6a62014-01-09 14:48:09 -0800103 void *data);
Upinder Malhie3cf00d2013-09-10 03:38:16 +0000104struct usnic_vnic_res_chunk
105*usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
106 enum usnic_vnic_res_type type);
107static inline
108struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
109{
110 return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
111}
112#endif /* USNIC_IB_QP_GRP_H_ */