1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2023, 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 32 /** 33 * @file ice_rdma.h 34 * @brief header file for RDMA client interface functions 35 * 36 * Contains definitions and function calls shared by the ice driver and the 37 * RDMA client interface driver. 38 * 39 * Since these definitions are shared between drivers it is important that any 40 * changes are considered carefully for backwards compatibility. 41 */ 42 #ifndef _ICE_RDMA_H_ 43 #define _ICE_RDMA_H_ 44 45 /* 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. 49 * 50 * It will follows the semantic version guidelines, that is: 51 * Given the version number MAJOR.MINOR.PATCH, increment the: 52 * 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. 56 * 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 60 * the MAJOR version. 61 * 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 64 * considered stable. 65 */ 66 #define ICE_RDMA_MAJOR_VERSION 1 67 #define ICE_RDMA_MINOR_VERSION 0 68 #define ICE_RDMA_PATCH_VERSION 0 69 70 /** 71 * @def ICE_RDMA_MAX_MSIX 72 * @brief Maximum number of MSI-X vectors that will be reserved 73 * 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. 77 */ 78 #define ICE_RDMA_MAX_MSIX 64 79 80 /** 81 * @struct ice_rdma_info 82 * @brief RDMA information from the client driver 83 * 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. 86 * 87 * It should fill the version in with the ICE_RDMA_* versions as defined in 88 * the ice_rdma.h header. 89 * 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. 92 * 93 * If the version specified is not compatible, then the registration will 94 * of the RDMA driver will fail. 95 */ 96 struct ice_rdma_info { 97 uint16_t major_version; 98 uint16_t minor_version; 99 uint16_t patch_version; 100 101 kobj_class_t rdma_class; 102 }; 103 104 #define ICE_RDMA_MAX_USER_PRIORITY 8 105 #define ICE_RDMA_MAX_MSIX 64 106 107 /* Declare the ice_rdma_di kobject class */ 108 DECLARE_CLASS(ice_rdma_di_class); 109 110 /** 111 * @struct ice_rdma_msix_mapping 112 * @brief MSI-X mapping requested by the peer RDMA driver 113 * 114 * Defines a mapping for MSI-X vectors being requested by the peer RDMA driver 115 * for a given PF. 116 */ 117 struct ice_rdma_msix_mapping { 118 uint8_t itr_indx; 119 int aeq_vector; 120 int ceq_cnt; 121 int *ceq_vector; 122 }; 123 124 /** 125 * @struct ice_rdma_msix 126 * @brief RDMA MSI-X vectors reserved for the peer RDMA driver 127 * 128 * Defines the segment of the MSI-X vectors for use by the RDMA driver. These 129 * are reserved by the PF when it initializes. 130 */ 131 struct ice_rdma_msix { 132 int base; 133 int count; 134 }; 135 136 /** 137 * @struct ice_qos_info 138 * @brief QoS information to be shared with RDMA driver 139 */ 140 struct ice_qos_info { 141 uint64_t tc_ctx; 142 uint8_t rel_bw; 143 uint8_t prio_type; 144 uint8_t egress_virt_up; 145 uint8_t ingress_virt_up; 146 }; 147 148 /** 149 * @struct ice_qos_app_priority_table 150 * @brief Application priority data 151 */ 152 struct ice_qos_app_priority_table { 153 uint16_t prot_id; 154 uint8_t priority; 155 uint8_t selector; 156 }; 157 158 #define IEEE_8021QAZ_MAX_TCS 8 159 #define ICE_TC_MAX_USER_PRIORITY 8 160 #define ICE_QOS_MAX_APPS 32 161 #define ICE_QOS_DSCP_NUM_VAL 64 162 163 /** 164 * @struct ice_qos_params 165 * @brief Holds all necessary data for RDMA to work with DCB 166 * 167 * Struct to hold QoS info 168 */ 169 struct ice_qos_params { 170 struct ice_qos_info tc_info[IEEE_8021QAZ_MAX_TCS]; 171 uint8_t up2tc[ICE_TC_MAX_USER_PRIORITY]; 172 uint8_t vsi_relative_bw; 173 uint8_t vsi_priority_type; 174 uint32_t num_apps; 175 uint8_t pfc_mode; 176 uint8_t dscp_map[ICE_QOS_DSCP_NUM_VAL]; 177 struct ice_qos_app_priority_table apps[ICE_QOS_MAX_APPS]; 178 uint8_t num_tc; 179 }; 180 181 /** 182 * @struct ice_rdma_peer 183 * @brief RDMA driver information 184 * 185 * Shared structure used by the RDMA client driver when talking with the main 186 * device driver. 187 * 188 * Because the definition of this structure is shared between the two drivers, 189 * its ABI should be handled carefully. 190 */ 191 struct ice_rdma_peer { 192 /** 193 * The KOBJ_FIELDS macro must come first, in order for it to be used 194 * as a kobject. 195 */ 196 KOBJ_FIELDS; 197 198 struct ifnet *ifp; 199 device_t dev; 200 struct resource *pci_mem; 201 struct ice_qos_params initial_qos_info; 202 struct ice_rdma_msix msix; 203 uint16_t mtu; 204 uint16_t pf_vsi_num; 205 uint8_t pf_id; 206 }; 207 208 /** 209 * @enum ice_res_type 210 * @brief enum for type of resource registration 211 * 212 * enum for type of resource registration. 213 * created for plausible compatibility with IDC 214 */ 215 enum ice_res_type { 216 ICE_INVAL_RES = 0x0, 217 ICE_RDMA_QSET_ALLOC = 0x8, 218 ICE_RDMA_QSET_FREE = 0x18, 219 }; 220 221 /** 222 * @struct ice_rdma_qset_params 223 * @brief struct to hold per RDMA Qset info 224 */ 225 struct ice_rdma_qset_params { 226 uint32_t teid; /* qset TEID */ 227 uint16_t qs_handle; /* RDMA driver provides this */ 228 uint16_t vsi_id; /* VSI index */ 229 uint8_t tc; /* TC branch the QSet should belong to */ 230 uint8_t reserved[3]; 231 }; 232 233 #define ICE_MAX_TXQ_PER_TXQG 128 234 /** 235 * @struct ice_rdma_qset_update 236 * @brief struct used to register and unregister qsets for RDMA driver 237 */ 238 struct ice_rdma_qset_update { 239 enum ice_res_type res_type; 240 uint16_t cnt_req; 241 uint16_t res_allocated; 242 uint32_t res_handle; 243 struct ice_rdma_qset_params qsets; 244 }; 245 246 /** 247 * @enum ice_rdma_event_type 248 * @brief enum for type of event from base driver 249 */ 250 enum ice_rdma_event_type { 251 ICE_RDMA_EVENT_NONE = 0, 252 ICE_RDMA_EVENT_LINK_CHANGE, 253 ICE_RDMA_EVENT_MTU_CHANGE, 254 ICE_RDMA_EVENT_TC_CHANGE, 255 ICE_RDMA_EVENT_API_CHANGE, 256 ICE_RDMA_EVENT_CRIT_ERR, 257 ICE_RDMA_EVENT_RESET, 258 ICE_RDMA_EVENT_QSET_REGISTER, 259 ICE_RDMA_EVENT_VSI_FILTER_UPDATE, 260 ICE_RDMA_EVENT_LAST 261 }; 262 263 /** 264 * @struct ice_rdma_event 265 * @brief struct for event information to pass to RDMA driver 266 */ 267 struct ice_rdma_event { 268 enum ice_rdma_event_type type; 269 union { 270 /* link change event */ 271 struct { 272 int linkstate; 273 uint64_t baudrate; 274 }; 275 /* MTU change event */ 276 struct { 277 int mtu; 278 }; 279 /* 280 * TC/QoS/DCB change event 281 * RESET event use prep variable only 282 * prep: if true, this is a pre-event, post-event otherwise 283 */ 284 struct { 285 struct ice_qos_params port_qos; 286 bool prep; 287 }; 288 }; 289 }; 290 291 /** 292 * @struct ice_rdma_request 293 * @brief struct with data for a request from the RDMA driver 294 */ 295 struct ice_rdma_request { 296 enum ice_rdma_event_type type; 297 union { 298 struct { 299 struct ice_rdma_qset_update res; 300 }; 301 struct { 302 bool enable_filter; 303 }; 304 }; 305 }; 306 307 int ice_rdma_register(struct ice_rdma_info *info); 308 int ice_rdma_unregister(void); 309 310 #endif 311