1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright (c) 2023, Intel Corporation
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
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.
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.
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.
34 * @brief header file for RDMA client interface functions
36 * Contains definitions and function calls shared by the ice driver and the
37 * RDMA client interface driver.
39 * Since these definitions are shared between drivers it is important that any
40 * changes are considered carefully for backwards compatibility.
46 * The RDMA client interface version is used to help determine
47 * incompatibilities between the interface definition shared between the main
48 * driver and the client driver.
50 * It will follows the semantic version guidelines, that is:
51 * Given the version number MAJOR.MINOR.PATCH, increment the:
53 * MAJOR version when you make incompatible changes,
54 * MINOR version when you add functionality in a backwards-compatible manner, and
55 * PATCH version when you make backwards-compatible bug fixes.
57 * Any change to this file, or one of the kobject interface files must come
58 * with an associated change in one of the MAJOR, MINOR, or PATCH versions,
59 * and care must be taken that backwards incompatible changes MUST increment
62 * Note: Until the MAJOR version is set to at least 1, the above semantic
63 * version guarantees may not hold, and this interface should not be
66 #define ICE_RDMA_MAJOR_VERSION 1
67 #define ICE_RDMA_MINOR_VERSION 1
68 #define ICE_RDMA_PATCH_VERSION 0
71 * @def ICE_RDMA_MAX_MSIX
72 * @brief Maximum number of MSI-X vectors that will be reserved
74 * Defines the maximum number of MSI-X vectors that an RDMA interface will
75 * have reserved in advance. Does not guarantee that many vectors have
76 * actually been enabled.
78 #define ICE_RDMA_MAX_MSIX 64
81 * @struct ice_rdma_info
82 * @brief RDMA information from the client driver
84 * The RDMA client driver will fill in this structure and pass its contents
85 * back to the main driver using the ice_rdma_register function.
87 * It should fill the version in with the ICE_RDMA_* versions as defined in
88 * the ice_rdma.h header.
90 * Additionally it must provide a pointer to a kobject class which extends the
91 * ice_rdma_di_class with the operations defined in the rdma_if.m interface.
93 * If the version specified is not compatible, then the registration will
94 * of the RDMA driver will fail.
96 * @var ice_rdma_info::major_version
97 * describe major changes in the interface
98 * @var ice_rdma_info::minor_version
99 * describe changes and fixes with backward compatibility
100 * @var ice_rdma_info::patch_version
101 * changes without impact on compatibility or features
102 * @var ice_rdma_info::rdma_class
105 struct ice_rdma_info {
106 uint16_t major_version;
107 uint16_t minor_version;
108 uint16_t patch_version;
110 kobj_class_t rdma_class;
113 #define ICE_RDMA_MAX_USER_PRIORITY 8
114 #define ICE_RDMA_MAX_MSIX 64
116 /* Declare the ice_rdma_di kobject class */
117 DECLARE_CLASS(ice_rdma_di_class);
120 * @struct ice_rdma_msix_mapping
121 * @brief MSI-X mapping requested by the peer RDMA driver
123 * Defines a mapping for MSI-X vectors being requested by the peer RDMA driver
127 struct ice_rdma_msix_mapping {
135 * @struct ice_rdma_msix
136 * @brief RDMA MSI-X vectors reserved for the peer RDMA driver
138 * Defines the segment of the MSI-X vectors for use by the RDMA driver. These
139 * are reserved by the PF when it initializes.
141 struct ice_rdma_msix {
147 * @struct ice_qos_info
148 * @brief QoS information to be shared with RDMA driver
150 struct ice_qos_info {
154 uint8_t egress_virt_up;
155 uint8_t ingress_virt_up;
159 * @struct ice_qos_app_priority_table
160 * @brief Application priority data
162 struct ice_qos_app_priority_table {
168 #define IEEE_8021QAZ_MAX_TCS 8
169 #define ICE_TC_MAX_USER_PRIORITY 8
170 #define ICE_QOS_MAX_APPS 32
171 #define ICE_QOS_DSCP_NUM_VAL 64
174 * @struct ice_qos_params
175 * @brief Holds all necessary data for RDMA to work with DCB
177 * Struct to hold QoS info
178 * @var ice_qos_params::tc_info
179 * traffic class information
180 * @var ice_qos_params::up2tc
181 * mapping from user priority to traffic class
182 * @var ice_qos_params::vsi_relative_bw
184 * @var ice_qos_params::vsi_priority_type
186 * @var ice_qos_params::num_apps
188 * @var ice_qos_params::pfc_mode
190 * @var ice_qos_params::dscp_map
192 * @var ice_qos_params::apps
194 * @var ice_qos_params::num_tc
195 * number of traffic classes
198 struct ice_qos_params {
199 struct ice_qos_info tc_info[IEEE_8021QAZ_MAX_TCS];
200 uint8_t up2tc[ICE_TC_MAX_USER_PRIORITY];
201 uint8_t vsi_relative_bw;
202 uint8_t vsi_priority_type;
205 uint8_t dscp_map[ICE_QOS_DSCP_NUM_VAL];
206 struct ice_qos_app_priority_table apps[ICE_QOS_MAX_APPS];
211 * @struct ice_rdma_peer
212 * @brief RDMA driver information
214 * Shared structure used by the RDMA client driver when talking with the main
217 * Because the definition of this structure is shared between the two drivers,
218 * its ABI should be handled carefully.
220 * @var ice_rdma_peer::ifp
221 * pointer to ifnet structure
222 * @var ice_rdma_peer::dev
224 * @var ice_rdma_peer::pci_mem
225 * information about PCI
226 * @var ice_rdma_peer::initial_qos_info
227 * initial information on QoS
228 * @var ice_rdma_peer::msix
229 * info about msix vectors
230 * @var ice_rdma_peer::mtu
232 * @var ice_rdma_peer::pf_vsi_num
234 * @var ice_rdma_peer::pf_id
237 struct ice_rdma_peer {
239 * The KOBJ_FIELDS macro must come first, in order for it to be used
246 struct resource *pci_mem;
247 struct ice_qos_params initial_qos_info;
248 struct ice_rdma_msix msix;
256 * @brief enum for type of resource registration
258 * enum for type of resource registration.
259 * created for plausible compatibility with IDC
263 ICE_RDMA_QSET_ALLOC = 0x8,
264 ICE_RDMA_QSET_FREE = 0x18,
268 * @struct ice_rdma_qset_params
269 * @brief struct to hold per RDMA Qset info
271 * @var ice_rdma_qset_params::teid
273 * @var ice_rdma_qset_params::qs_handle
274 * qset from rdma driver
275 * @var ice_rdma_qset_params::vsi_id
277 * @var ice_rdma_qset_params::tc
278 * traffic class to which qset should belong to
279 * @var ice_rdma_qset_params::reserved
282 struct ice_rdma_qset_params {
290 #define ICE_MAX_TXQ_PER_TXQG 128
292 * @struct ice_rdma_qset_update
293 * @brief struct used to register and unregister qsets for RDMA driver
295 * @var ice_rdma_qset_update::res_type
297 * @var ice_rdma_qset_update::cnt_req
298 * how many qsets are requested
299 * @var ice_rdma_qset_update::res_allocated
300 * how many qsets are allocated
301 * @var ice_rdma_qset_update::qsets
304 struct ice_rdma_qset_update {
305 enum ice_res_type res_type;
307 uint16_t res_allocated;
309 struct ice_rdma_qset_params qsets;
313 * @enum ice_rdma_event_type
314 * @brief enum for type of event from base driver
316 enum ice_rdma_event_type {
317 ICE_RDMA_EVENT_NONE = 0,
318 ICE_RDMA_EVENT_LINK_CHANGE,
319 ICE_RDMA_EVENT_MTU_CHANGE,
320 ICE_RDMA_EVENT_TC_CHANGE,
321 ICE_RDMA_EVENT_API_CHANGE,
322 ICE_RDMA_EVENT_CRIT_ERR,
323 ICE_RDMA_EVENT_RESET,
324 ICE_RDMA_EVENT_QSET_REGISTER,
325 ICE_RDMA_EVENT_VSI_FILTER_UPDATE,
330 * @struct ice_rdma_event
331 * @brief struct for event information to pass to RDMA driver
333 * @var ice_rdma_event::type
336 struct ice_rdma_event {
337 enum ice_rdma_event_type type;
339 /* link change event */
344 /* MTU change event */
347 * TC/QoS/DCB change event
348 * prep: if true, this is a pre-event, post-event otherwise
351 struct ice_qos_params port_qos;
362 * @struct ice_rdma_request
363 * @brief struct with data for a request from the RDMA driver
365 * @var ice_rdma_request::type
368 struct ice_rdma_request {
369 enum ice_rdma_event_type type;
372 struct ice_rdma_qset_update res;
380 int ice_rdma_register(struct ice_rdma_info *info);
381 int ice_rdma_unregister(void);