2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
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.
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
19 #ifndef USNIC_IB_QP_GRP_H_
20 #define USNIC_IB_QP_GRP_H_
22 #include <linux/debugfs.h>
23 #include <rdma/ib_verbs.h>
26 #include "usnic_abi.h"
27 #include "usnic_fwd.h"
28 #include "usnic_vnic.h"
31 * The qp group struct represents all the hw resources needed to present a ib_qp
33 struct usnic_ib_qp_grp {
35 enum ib_qp_state state;
38 struct usnic_fwd_dev *ufdev;
39 struct usnic_ib_ucontext *ctx;
40 struct list_head flows_lst;
42 struct usnic_vnic_res_chunk **res_chunk_list;
45 struct usnic_ib_vf *vf;
46 struct list_head link;
53 struct usnic_ib_qp_grp_flow {
54 struct usnic_fwd_flow *flow;
55 enum usnic_transport_type trans_type;
64 struct usnic_ib_qp_grp *qp_grp;
65 struct list_head link;
68 struct dentry *dbgfs_dentry;
73 usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
74 { /*USNIC_TRANSPORT_UNKNOWN*/
76 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
79 { /*USNIC_TRANSPORT_ROCE_CUSTOM*/
81 {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
82 {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
83 {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
84 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
87 { /*USNIC_TRANSPORT_IPV4_UDP*/
89 {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
90 {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
91 {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
92 {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
97 const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
98 int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
99 int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
100 struct usnic_ib_qp_grp *
101 usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
102 struct usnic_ib_pd *pd,
103 struct usnic_vnic_res_spec *res_spec,
104 struct usnic_transport_spec *trans_spec);
105 void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
106 int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
107 enum ib_qp_state new_state,
109 struct usnic_vnic_res_chunk
110 *usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
111 enum usnic_vnic_res_type type);
113 struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
115 return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
117 #endif /* USNIC_IB_QP_GRP_H_ */