xref: /freebsd/sys/dev/irdma/irdma_uda.h (revision 5b5f7d0e77a9eee73eb5d596f43aef4e1a3674d8)
1 /*-
2  * SPDX-License-Identifier: GPL-2.0 or Linux-OpenIB
3  *
4  * Copyright (c) 2016 - 2023 Intel Corporation
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenFabrics.org BSD license below:
11  *
12  *   Redistribution and use in source and binary forms, with or
13  *   without modification, are permitted provided that the following
14  *   conditions are met:
15  *
16  *    - Redistributions of source code must retain the above
17  *	copyright notice, this list of conditions and the following
18  *	disclaimer.
19  *
20  *    - Redistributions in binary form must reproduce the above
21  *	copyright notice, this list of conditions and the following
22  *	disclaimer in the documentation and/or other materials
23  *	provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34 
35 #ifndef IRDMA_UDA_H
36 #define IRDMA_UDA_H
37 
38 #define IRDMA_UDA_MAX_FSI_MGS	4096
39 #define IRDMA_UDA_MAX_PFS	16
40 #define IRDMA_UDA_MAX_VFS	128
41 
42 struct irdma_sc_cqp;
43 
44 struct irdma_ah_info {
45 	struct irdma_sc_vsi *vsi;
46 	struct irdma_cqp_request *cqp_request;
47 	u32 pd_idx;
48 	u32 dst_arpindex;
49 	u32 dest_ip_addr[4];
50 	u32 src_ip_addr[4];
51 	u32 flow_label;
52 	u32 ah_idx;
53 	u16 vlan_tag;
54 	u8 insert_vlan_tag;
55 	u8 tc_tos;
56 	u8 hop_ttl;
57 	u8 mac_addr[ETHER_ADDR_LEN];
58 	bool ah_valid:1;
59 	bool ipv4_valid:1;
60 	bool do_lpbk:1;
61 };
62 
63 struct irdma_sc_ah {
64 	struct irdma_sc_dev *dev;
65 	struct irdma_ah_info ah_info;
66 };
67 
68 int irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx,
69 			   struct irdma_mcast_grp_ctx_entry_info *mg);
70 int irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx,
71 			   struct irdma_mcast_grp_ctx_entry_info *mg);
72 int irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info,
73 		       u32 op, u64 scratch);
74 int irdma_access_mcast_grp(struct irdma_sc_cqp *cqp,
75 			   struct irdma_mcast_grp_info *info, u32 op,
76 			   u64 scratch);
77 
irdma_sc_init_ah(struct irdma_sc_dev * dev,struct irdma_sc_ah * ah)78 static inline void irdma_sc_init_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah)
79 {
80 	ah->dev = dev;
81 }
82 
irdma_sc_create_ah(struct irdma_sc_cqp * cqp,struct irdma_ah_info * info,u64 scratch)83 static inline int irdma_sc_create_ah(struct irdma_sc_cqp *cqp,
84 				     struct irdma_ah_info *info, u64 scratch)
85 {
86 	return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_CREATE_ADDR_HANDLE,
87 				  scratch);
88 }
89 
irdma_sc_destroy_ah(struct irdma_sc_cqp * cqp,struct irdma_ah_info * info,u64 scratch)90 static inline int irdma_sc_destroy_ah(struct irdma_sc_cqp *cqp,
91 				      struct irdma_ah_info *info, u64 scratch)
92 {
93 	return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_DESTROY_ADDR_HANDLE,
94 				  scratch);
95 }
96 
irdma_sc_create_mcast_grp(struct irdma_sc_cqp * cqp,struct irdma_mcast_grp_info * info,u64 scratch)97 static inline int irdma_sc_create_mcast_grp(struct irdma_sc_cqp *cqp,
98 					    struct irdma_mcast_grp_info *info,
99 					    u64 scratch)
100 {
101 	return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_CREATE_MCAST_GRP,
102 				      scratch);
103 }
104 
irdma_sc_modify_mcast_grp(struct irdma_sc_cqp * cqp,struct irdma_mcast_grp_info * info,u64 scratch)105 static inline int irdma_sc_modify_mcast_grp(struct irdma_sc_cqp *cqp,
106 					    struct irdma_mcast_grp_info *info,
107 					    u64 scratch)
108 {
109 	return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_MODIFY_MCAST_GRP,
110 				      scratch);
111 }
112 
irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp * cqp,struct irdma_mcast_grp_info * info,u64 scratch)113 static inline int irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp *cqp,
114 					     struct irdma_mcast_grp_info *info,
115 					     u64 scratch)
116 {
117 	return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_DESTROY_MCAST_GRP,
118 				      scratch);
119 }
120 #endif /* IRDMA_UDA_H */
121