1e3cf00d0SUpinder Malhi /*
2e3cf00d0SUpinder Malhi  * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3e3cf00d0SUpinder Malhi  *
43805eadeSJeff Squyres  * This software is available to you under a choice of one of two
53805eadeSJeff Squyres  * licenses.  You may choose to be licensed under the terms of the GNU
63805eadeSJeff Squyres  * General Public License (GPL) Version 2, available from the file
73805eadeSJeff Squyres  * COPYING in the main directory of this source tree, or the
83805eadeSJeff Squyres  * BSD license below:
93805eadeSJeff Squyres  *
103805eadeSJeff Squyres  *     Redistribution and use in source and binary forms, with or
113805eadeSJeff Squyres  *     without modification, are permitted provided that the following
123805eadeSJeff Squyres  *     conditions are met:
133805eadeSJeff Squyres  *
143805eadeSJeff Squyres  *      - Redistributions of source code must retain the above
153805eadeSJeff Squyres  *        copyright notice, this list of conditions and the following
163805eadeSJeff Squyres  *        disclaimer.
173805eadeSJeff Squyres  *
183805eadeSJeff Squyres  *      - Redistributions in binary form must reproduce the above
193805eadeSJeff Squyres  *        copyright notice, this list of conditions and the following
203805eadeSJeff Squyres  *        disclaimer in the documentation and/or other materials
213805eadeSJeff Squyres  *        provided with the distribution.
22e3cf00d0SUpinder Malhi  *
23e3cf00d0SUpinder Malhi  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24e3cf00d0SUpinder Malhi  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25e3cf00d0SUpinder Malhi  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26e3cf00d0SUpinder Malhi  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27e3cf00d0SUpinder Malhi  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28e3cf00d0SUpinder Malhi  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29e3cf00d0SUpinder Malhi  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30e3cf00d0SUpinder Malhi  * SOFTWARE.
31e3cf00d0SUpinder Malhi  *
32e3cf00d0SUpinder Malhi  */
33e3cf00d0SUpinder Malhi 
34e3cf00d0SUpinder Malhi #ifndef USNIC_IB_QP_GRP_H_
35e3cf00d0SUpinder Malhi #define USNIC_IB_QP_GRP_H_
36e3cf00d0SUpinder Malhi 
379f637f79SUpinder Malhi #include <linux/debugfs.h>
38e3cf00d0SUpinder Malhi #include <rdma/ib_verbs.h>
39e3cf00d0SUpinder Malhi 
40e3cf00d0SUpinder Malhi #include "usnic_ib.h"
41e3cf00d0SUpinder Malhi #include "usnic_abi.h"
42e3cf00d0SUpinder Malhi #include "usnic_fwd.h"
43e3cf00d0SUpinder Malhi #include "usnic_vnic.h"
44e3cf00d0SUpinder Malhi 
45e3cf00d0SUpinder Malhi /*
46e3cf00d0SUpinder Malhi  * The qp group struct represents all the hw resources needed to present a ib_qp
47e3cf00d0SUpinder Malhi  */
48e3cf00d0SUpinder Malhi struct usnic_ib_qp_grp {
49e3cf00d0SUpinder Malhi 	struct ib_qp				ibqp;
50e3cf00d0SUpinder Malhi 	enum ib_qp_state			state;
51e3cf00d0SUpinder Malhi 	int					grp_id;
52e3cf00d0SUpinder Malhi 
53e3cf00d0SUpinder Malhi 	struct usnic_fwd_dev			*ufdev;
54e3cf00d0SUpinder Malhi 	struct usnic_ib_ucontext		*ctx;
55256d6a6aSUpinder Malhi 	struct list_head			flows_lst;
56e3cf00d0SUpinder Malhi 
57e3cf00d0SUpinder Malhi 	struct usnic_vnic_res_chunk		**res_chunk_list;
58e3cf00d0SUpinder Malhi 
59e3cf00d0SUpinder Malhi 	pid_t					owner_pid;
60e3cf00d0SUpinder Malhi 	struct usnic_ib_vf			*vf;
61e3cf00d0SUpinder Malhi 	struct list_head			link;
62e3cf00d0SUpinder Malhi 
63e3cf00d0SUpinder Malhi 	spinlock_t				lock;
64e3cf00d0SUpinder Malhi 
65e3cf00d0SUpinder Malhi 	struct kobject				kobj;
66e3cf00d0SUpinder Malhi };
67e3cf00d0SUpinder Malhi 
68256d6a6aSUpinder Malhi struct usnic_ib_qp_grp_flow {
69256d6a6aSUpinder Malhi 	struct usnic_fwd_flow		*flow;
70256d6a6aSUpinder Malhi 	enum usnic_transport_type	trans_type;
71256d6a6aSUpinder Malhi 	union {
72256d6a6aSUpinder Malhi 		struct {
73256d6a6aSUpinder Malhi 			uint16_t	port_num;
74256d6a6aSUpinder Malhi 		} usnic_roce;
75e45e614eSUpinder Malhi 		struct {
76e45e614eSUpinder Malhi 			struct socket	*sock;
77e45e614eSUpinder Malhi 		} udp;
78256d6a6aSUpinder Malhi 	};
79256d6a6aSUpinder Malhi 	struct usnic_ib_qp_grp		*qp_grp;
80256d6a6aSUpinder Malhi 	struct list_head		link;
819f637f79SUpinder Malhi 
829f637f79SUpinder Malhi 	/* Debug FS */
839f637f79SUpinder Malhi 	struct dentry			*dbgfs_dentry;
849f637f79SUpinder Malhi 	char				dentry_name[32];
85256d6a6aSUpinder Malhi };
86256d6a6aSUpinder Malhi 
87bd8c2021SBart Van Assche extern const struct usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX];
88e3cf00d0SUpinder Malhi 
89e3cf00d0SUpinder Malhi const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
90e3cf00d0SUpinder Malhi int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
91e3cf00d0SUpinder Malhi int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
92*514aee66SLeon Romanovsky int usnic_ib_qp_grp_create(struct usnic_ib_qp_grp *qp,
93*514aee66SLeon Romanovsky 			   struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
94e3cf00d0SUpinder Malhi 			   struct usnic_ib_pd *pd,
95e3cf00d0SUpinder Malhi 			   struct usnic_vnic_res_spec *res_spec,
96256d6a6aSUpinder Malhi 			   struct usnic_transport_spec *trans_spec);
97e3cf00d0SUpinder Malhi void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
98e3cf00d0SUpinder Malhi int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
99e3cf00d0SUpinder Malhi 				enum ib_qp_state new_state,
100256d6a6aSUpinder Malhi 				void *data);
101e3cf00d0SUpinder Malhi struct usnic_vnic_res_chunk
102e3cf00d0SUpinder Malhi *usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
103e3cf00d0SUpinder Malhi 				enum usnic_vnic_res_type type);
104e3cf00d0SUpinder Malhi static inline
to_uqp_grp(struct ib_qp * ibqp)105e3cf00d0SUpinder Malhi struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
106e3cf00d0SUpinder Malhi {
107e3cf00d0SUpinder Malhi 	return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
108e3cf00d0SUpinder Malhi }
109e3cf00d0SUpinder Malhi #endif /* USNIC_IB_QP_GRP_H_ */
110