FreeBSD/Linux Kernel Cross Reference
sys/dev/ice/ice_rdma.h
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2021, Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the Intel Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*$FreeBSD$*/
32
33 /**
34 * @file ice_rdma.h
35 * @brief header file for RDMA client interface functions
36 *
37 * Contains definitions and function calls shared by the ice driver and the
38 * RDMA client interface driver.
39 *
40 * Since these definitions are shared between drivers it is important that any
41 * changes are considered carefully for backwards compatibility.
42 */
43 #ifndef _ICE_RDMA_H_
44 #define _ICE_RDMA_H_
45
46 /*
47 * The RDMA client interface version is used to help determine
48 * incompatibilities between the interface definition shared between the main
49 * driver and the client driver.
50 *
51 * It will follows the semantic version guidelines, that is:
52 * Given the version number MAJOR.MINOR.PATCH, increment the:
53 *
54 * MAJOR version when you make incompatible changes,
55 * MINOR version when you add functionality in a backwards-compatible manner, and
56 * PATCH version when you make backwards-compatible bug fixes.
57 *
58 * Any change to this file, or one of the kobject interface files must come
59 * with an associated change in one of the MAJOR, MINOR, or PATCH versions,
60 * and care must be taken that backwards incompatible changes MUST increment
61 * the MAJOR version.
62 *
63 * Note: Until the MAJOR version is set to at least 1, the above semantic
64 * version guarantees may not hold, and this interface should not be
65 * considered stable.
66 */
67 #define ICE_RDMA_MAJOR_VERSION 1
68 #define ICE_RDMA_MINOR_VERSION 0
69 #define ICE_RDMA_PATCH_VERSION 0
70
71 /**
72 * @def ICE_RDMA_MAX_MSIX
73 * @brief Maximum number of MSI-X vectors that will be reserved
74 *
75 * Defines the maximum number of MSI-X vectors that an RDMA interface will
76 * have reserved in advance. Does not guarantee that many vectors have
77 * actually been enabled.
78 */
79 #define ICE_RDMA_MAX_MSIX 64
80
81 /**
82 * @struct ice_rdma_info
83 * @brief RDMA information from the client driver
84 *
85 * The RDMA client driver will fill in this structure and pass its contents
86 * back to the main driver using the ice_rdma_register function.
87 *
88 * It should fill the version in with the ICE_RDMA_* versions as defined in
89 * the ice_rdma.h header.
90 *
91 * Additionally it must provide a pointer to a kobject class which extends the
92 * ice_rdma_di_class with the operations defined in the rdma_if.m interface.
93 *
94 * If the version specified is not compatible, then the registration will
95 * of the RDMA driver will fail.
96 */
97 struct ice_rdma_info {
98 uint16_t major_version;
99 uint16_t minor_version;
100 uint16_t patch_version;
101
102 kobj_class_t rdma_class;
103 };
104
105 #define ICE_RDMA_MAX_USER_PRIORITY 8
106 #define ICE_RDMA_MAX_MSIX 64
107
108 /* Declare the ice_rdma_di kobject class */
109 DECLARE_CLASS(ice_rdma_di_class);
110
111 /**
112 * @struct ice_rdma_msix_mapping
113 * @brief MSI-X mapping requested by the peer RDMA driver
114 *
115 * Defines a mapping for MSI-X vectors being requested by the peer RDMA driver
116 * for a given PF.
117 */
118 struct ice_rdma_msix_mapping {
119 uint8_t itr_indx;
120 int aeq_vector;
121 int ceq_cnt;
122 int *ceq_vector;
123 };
124
125 /**
126 * @struct ice_rdma_msix
127 * @brief RDMA MSI-X vectors reserved for the peer RDMA driver
128 *
129 * Defines the segment of the MSI-X vectors for use by the RDMA driver. These
130 * are reserved by the PF when it initializes.
131 */
132 struct ice_rdma_msix {
133 int base;
134 int count;
135 };
136
137 /**
138 * @struct ice_qos_info
139 * @brief QoS information to be shared with RDMA driver
140 */
141 struct ice_qos_info {
142 uint64_t tc_ctx;
143 uint8_t rel_bw;
144 uint8_t prio_type;
145 uint8_t egress_virt_up;
146 uint8_t ingress_virt_up;
147 };
148
149 /**
150 * @struct ice_qos_app_priority_table
151 * @brief Application priority data
152 */
153 struct ice_qos_app_priority_table {
154 uint16_t prot_id;
155 uint8_t priority;
156 uint8_t selector;
157 };
158
159 #define IEEE_8021QAZ_MAX_TCS 8
160 #define ICE_TC_MAX_USER_PRIORITY 8
161 #define ICE_QOS_MAX_APPS 32
162 #define ICE_QOS_DSCP_NUM_VAL 64
163
164 /**
165 * @struct ice_qos_params
166 * @brief Holds all necessary data for RDMA to work with DCB
167 *
168 * Struct to hold QoS info
169 */
170 struct ice_qos_params {
171 struct ice_qos_info tc_info[IEEE_8021QAZ_MAX_TCS];
172 uint8_t up2tc[ICE_TC_MAX_USER_PRIORITY];
173 uint8_t vsi_relative_bw;
174 uint8_t vsi_priority_type;
175 uint32_t num_apps;
176 uint8_t pfc_mode;
177 uint8_t dscp_map[ICE_QOS_DSCP_NUM_VAL];
178 struct ice_qos_app_priority_table apps[ICE_QOS_MAX_APPS];
179 uint8_t num_tc;
180 };
181
182 /**
183 * @struct ice_rdma_peer
184 * @brief RDMA driver information
185 *
186 * Shared structure used by the RDMA client driver when talking with the main
187 * device driver.
188 *
189 * Because the definition of this structure is shared between the two drivers,
190 * its ABI should be handled carefully.
191 */
192 struct ice_rdma_peer {
193 /**
194 * The KOBJ_FIELDS macro must come first, in order for it to be used
195 * as a kobject.
196 */
197 KOBJ_FIELDS;
198
199 struct ifnet *ifp;
200 device_t dev;
201 struct resource *pci_mem;
202 struct ice_qos_params initial_qos_info;
203 struct ice_rdma_msix msix;
204 uint16_t mtu;
205 uint16_t pf_vsi_num;
206 uint8_t pf_id;
207 };
208
209 /**
210 * @enum ice_res_type
211 * @brief enum for type of resource registration
212 *
213 * enum for type of resource registration.
214 * created for plausible compatibility with IDC
215 */
216 enum ice_res_type {
217 ICE_INVAL_RES = 0x0,
218 ICE_RDMA_QSET_ALLOC = 0x8,
219 ICE_RDMA_QSET_FREE = 0x18,
220 };
221
222 /**
223 * @struct ice_rdma_qset_params
224 * @brief struct to hold per RDMA Qset info
225 */
226 struct ice_rdma_qset_params {
227 uint32_t teid; /* qset TEID */
228 uint16_t qs_handle; /* RDMA driver provides this */
229 uint16_t vsi_id; /* VSI index */
230 uint8_t tc; /* TC branch the QSet should belong to */
231 uint8_t reserved[3];
232 };
233
234 #define ICE_MAX_TXQ_PER_TXQG 128
235 /**
236 * @struct ice_rdma_qset_update
237 * @brief struct used to register and unregister qsets for RDMA driver
238 */
239 struct ice_rdma_qset_update {
240 enum ice_res_type res_type;
241 uint16_t cnt_req;
242 uint16_t res_allocated;
243 uint32_t res_handle;
244 struct ice_rdma_qset_params qsets;
245 };
246
247 /**
248 * @enum ice_rdma_event_type
249 * @brief enum for type of event from base driver
250 */
251 enum ice_rdma_event_type {
252 ICE_RDMA_EVENT_NONE = 0,
253 ICE_RDMA_EVENT_LINK_CHANGE,
254 ICE_RDMA_EVENT_MTU_CHANGE,
255 ICE_RDMA_EVENT_TC_CHANGE,
256 ICE_RDMA_EVENT_API_CHANGE,
257 ICE_RDMA_EVENT_CRIT_ERR,
258 ICE_RDMA_EVENT_RESET,
259 ICE_RDMA_EVENT_QSET_REGISTER,
260 ICE_RDMA_EVENT_VSI_FILTER_UPDATE,
261 ICE_RDMA_EVENT_LAST
262 };
263
264 /**
265 * @struct ice_rdma_event
266 * @brief struct for event information to pass to RDMA driver
267 */
268 struct ice_rdma_event {
269 enum ice_rdma_event_type type;
270 union {
271 /* link change event */
272 struct {
273 int linkstate;
274 uint64_t baudrate;
275 };
276 /* MTU change event */
277 struct {
278 int mtu;
279 };
280 /*
281 * TC/QoS/DCB change event
282 * RESET event use prep variable only
283 * prep: if true, this is a pre-event, post-event otherwise
284 */
285 struct {
286 struct ice_qos_params port_qos;
287 bool prep;
288 };
289 };
290 };
291
292 /**
293 * @struct ice_rdma_request
294 * @brief struct with data for a request from the RDMA driver
295 */
296 struct ice_rdma_request {
297 enum ice_rdma_event_type type;
298 union {
299 struct {
300 struct ice_rdma_qset_update res;
301 };
302 struct {
303 bool enable_filter;
304 };
305 };
306 };
307
308 int ice_rdma_register(struct ice_rdma_info *info);
309 int ice_rdma_unregister(void);
310
311 #endif
Cache object: 7b59b874ad6fd2e13e2f139e9590dddd
|