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 atomic_t ah_refcnt;
48 u32 pd_idx;
49 u32 dst_arpindex;
50 u32 dest_ip_addr[4];
51 u32 src_ip_addr[4];
52 u32 flow_label;
53 u32 ah_idx;
54 u16 vlan_tag;
55 u8 insert_vlan_tag;
56 u8 tc_tos;
57 u8 hop_ttl;
58 u8 mac_addr[ETHER_ADDR_LEN];
59 bool ah_valid:1;
60 bool ipv4_valid:1;
61 bool do_lpbk:1;
62 };
63
64 struct irdma_sc_ah {
65 struct irdma_sc_dev *dev;
66 struct irdma_ah_info ah_info;
67 struct work_struct ah_free_work;
68 };
69
70 int irdma_sc_add_mcast_grp(struct irdma_mcast_grp_info *ctx,
71 struct irdma_mcast_grp_ctx_entry_info *mg);
72 int irdma_sc_del_mcast_grp(struct irdma_mcast_grp_info *ctx,
73 struct irdma_mcast_grp_ctx_entry_info *mg);
74 int irdma_sc_access_ah(struct irdma_sc_cqp *cqp, struct irdma_ah_info *info,
75 u32 op, u64 scratch);
76 int irdma_access_mcast_grp(struct irdma_sc_cqp *cqp,
77 struct irdma_mcast_grp_info *info, u32 op,
78 u64 scratch);
79
irdma_sc_init_ah(struct irdma_sc_dev * dev,struct irdma_sc_ah * ah)80 static inline void irdma_sc_init_ah(struct irdma_sc_dev *dev, struct irdma_sc_ah *ah)
81 {
82 ah->dev = dev;
83 }
84
irdma_sc_create_ah(struct irdma_sc_cqp * cqp,struct irdma_ah_info * info,u64 scratch)85 static inline int irdma_sc_create_ah(struct irdma_sc_cqp *cqp,
86 struct irdma_ah_info *info, u64 scratch)
87 {
88 return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_CREATE_ADDR_HANDLE,
89 scratch);
90 }
91
irdma_sc_destroy_ah(struct irdma_sc_cqp * cqp,struct irdma_ah_info * info,u64 scratch)92 static inline int irdma_sc_destroy_ah(struct irdma_sc_cqp *cqp,
93 struct irdma_ah_info *info, u64 scratch)
94 {
95 return irdma_sc_access_ah(cqp, info, IRDMA_CQP_OP_DESTROY_ADDR_HANDLE,
96 scratch);
97 }
98
irdma_sc_create_mcast_grp(struct irdma_sc_cqp * cqp,struct irdma_mcast_grp_info * info,u64 scratch)99 static inline int irdma_sc_create_mcast_grp(struct irdma_sc_cqp *cqp,
100 struct irdma_mcast_grp_info *info,
101 u64 scratch)
102 {
103 return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_CREATE_MCAST_GRP,
104 scratch);
105 }
106
irdma_sc_modify_mcast_grp(struct irdma_sc_cqp * cqp,struct irdma_mcast_grp_info * info,u64 scratch)107 static inline int irdma_sc_modify_mcast_grp(struct irdma_sc_cqp *cqp,
108 struct irdma_mcast_grp_info *info,
109 u64 scratch)
110 {
111 return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_MODIFY_MCAST_GRP,
112 scratch);
113 }
114
irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp * cqp,struct irdma_mcast_grp_info * info,u64 scratch)115 static inline int irdma_sc_destroy_mcast_grp(struct irdma_sc_cqp *cqp,
116 struct irdma_mcast_grp_info *info,
117 u64 scratch)
118 {
119 return irdma_access_mcast_grp(cqp, info, IRDMA_CQP_OP_DESTROY_MCAST_GRP,
120 scratch);
121 }
122 #endif /* IRDMA_UDA_H */
123