blob: b1458be1d402d60b417904ec450e3d7a0b5b5020 [file] [log] [blame]
Upinder Malhie3cf00d2013-09-10 03:38:16 +00001/*
2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3 *
Jeff Squyres3805ead2015-09-30 13:34:00 -07004 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
Upinder Malhie3cf00d2013-09-10 03:38:16 +000022 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 *
32 */
33
34#ifndef USNIC_IB_QP_GRP_H_
35#define USNIC_IB_QP_GRP_H_
36
Upinder Malhi9f637f72014-01-09 15:40:58 -080037#include <linux/debugfs.h>
Upinder Malhie3cf00d2013-09-10 03:38:16 +000038#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
Upinder Malhie3cf00d2013-09-10 03:38:16 +000045/*
46 * The qp group struct represents all the hw resources needed to present a ib_qp
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;
Upinder Malhie3cf00d2013-09-10 03:38:16 +000054 struct usnic_ib_ucontext *ctx;
Upinder Malhi256d6a62014-01-09 14:48:09 -080055 struct list_head flows_lst;
Upinder Malhie3cf00d2013-09-10 03:38:16 +000056
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
Upinder Malhi256d6a62014-01-09 14:48:09 -080068struct 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;
Upinder Malhie45e6142014-01-09 14:48:18 -080075 struct {
76 struct socket *sock;
77 } udp;
Upinder Malhi256d6a62014-01-09 14:48:09 -080078 };
79 struct usnic_ib_qp_grp *qp_grp;
80 struct list_head link;
Upinder Malhi9f637f72014-01-09 15:40:58 -080081
82 /* Debug FS */
83 struct dentry *dbgfs_dentry;
84 char dentry_name[32];
Upinder Malhi256d6a62014-01-09 14:48:09 -080085};
86
Upinder Malhie3cf00d2013-09-10 03:38:16 +000087static const struct
88usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
89 { /*USNIC_TRANSPORT_UNKNOWN*/
90 .resources = {
91 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
92 },
93 },
94 { /*USNIC_TRANSPORT_ROCE_CUSTOM*/
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 },
Upinder Malhie45e6142014-01-09 14:48:18 -0800102 { /*USNIC_TRANSPORT_IPV4_UDP*/
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 },
Upinder Malhie3cf00d2013-09-10 03:38:16 +0000110};
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,
Upinder Malhi256d6a62014-01-09 14:48:09 -0800119 struct usnic_transport_spec *trans_spec);
Upinder Malhie3cf00d2013-09-10 03:38:16 +0000120void 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,
Upinder Malhi256d6a62014-01-09 14:48:09 -0800123 void *data);
Upinder Malhie3cf00d2013-09-10 03:38:16 +0000124struct 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 /* USNIC_IB_QP_GRP_H_ */