18a13362dSEric Joyner /* SPDX-License-Identifier: BSD-3-Clause */ 29dc2f6e2SEric Joyner /* Copyright (c) 2023, Intel Corporation 38a13362dSEric Joyner * All rights reserved. 48a13362dSEric Joyner * 58a13362dSEric Joyner * Redistribution and use in source and binary forms, with or without 68a13362dSEric Joyner * modification, are permitted provided that the following conditions are met: 78a13362dSEric Joyner * 88a13362dSEric Joyner * 1. Redistributions of source code must retain the above copyright notice, 98a13362dSEric Joyner * this list of conditions and the following disclaimer. 108a13362dSEric Joyner * 118a13362dSEric Joyner * 2. Redistributions in binary form must reproduce the above copyright 128a13362dSEric Joyner * notice, this list of conditions and the following disclaimer in the 138a13362dSEric Joyner * documentation and/or other materials provided with the distribution. 148a13362dSEric Joyner * 158a13362dSEric Joyner * 3. Neither the name of the Intel Corporation nor the names of its 168a13362dSEric Joyner * contributors may be used to endorse or promote products derived from 178a13362dSEric Joyner * this software without specific prior written permission. 188a13362dSEric Joyner * 198a13362dSEric Joyner * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 208a13362dSEric Joyner * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 218a13362dSEric Joyner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 228a13362dSEric Joyner * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 238a13362dSEric Joyner * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 248a13362dSEric Joyner * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 258a13362dSEric Joyner * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 268a13362dSEric Joyner * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 278a13362dSEric Joyner * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 288a13362dSEric Joyner * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 298a13362dSEric Joyner * POSSIBILITY OF SUCH DAMAGE. 308a13362dSEric Joyner */ 318a13362dSEric Joyner 328a13362dSEric Joyner /** 338a13362dSEric Joyner * @file ice_rdma.h 348a13362dSEric Joyner * @brief header file for RDMA client interface functions 358a13362dSEric Joyner * 368a13362dSEric Joyner * Contains definitions and function calls shared by the ice driver and the 378a13362dSEric Joyner * RDMA client interface driver. 388a13362dSEric Joyner * 398a13362dSEric Joyner * Since these definitions are shared between drivers it is important that any 408a13362dSEric Joyner * changes are considered carefully for backwards compatibility. 418a13362dSEric Joyner */ 428a13362dSEric Joyner #ifndef _ICE_RDMA_H_ 438a13362dSEric Joyner #define _ICE_RDMA_H_ 448a13362dSEric Joyner 458a13362dSEric Joyner /* 468a13362dSEric Joyner * The RDMA client interface version is used to help determine 478a13362dSEric Joyner * incompatibilities between the interface definition shared between the main 488a13362dSEric Joyner * driver and the client driver. 498a13362dSEric Joyner * 508a13362dSEric Joyner * It will follows the semantic version guidelines, that is: 518a13362dSEric Joyner * Given the version number MAJOR.MINOR.PATCH, increment the: 528a13362dSEric Joyner * 538a13362dSEric Joyner * MAJOR version when you make incompatible changes, 548a13362dSEric Joyner * MINOR version when you add functionality in a backwards-compatible manner, and 558a13362dSEric Joyner * PATCH version when you make backwards-compatible bug fixes. 568a13362dSEric Joyner * 578a13362dSEric Joyner * Any change to this file, or one of the kobject interface files must come 588a13362dSEric Joyner * with an associated change in one of the MAJOR, MINOR, or PATCH versions, 598a13362dSEric Joyner * and care must be taken that backwards incompatible changes MUST increment 608a13362dSEric Joyner * the MAJOR version. 618a13362dSEric Joyner * 628a13362dSEric Joyner * Note: Until the MAJOR version is set to at least 1, the above semantic 638a13362dSEric Joyner * version guarantees may not hold, and this interface should not be 648a13362dSEric Joyner * considered stable. 658a13362dSEric Joyner */ 668a13362dSEric Joyner #define ICE_RDMA_MAJOR_VERSION 1 67*01fbb869SBartosz Sobczak #define ICE_RDMA_MINOR_VERSION 1 688a13362dSEric Joyner #define ICE_RDMA_PATCH_VERSION 0 698a13362dSEric Joyner 708a13362dSEric Joyner /** 718a13362dSEric Joyner * @def ICE_RDMA_MAX_MSIX 728a13362dSEric Joyner * @brief Maximum number of MSI-X vectors that will be reserved 738a13362dSEric Joyner * 748a13362dSEric Joyner * Defines the maximum number of MSI-X vectors that an RDMA interface will 758a13362dSEric Joyner * have reserved in advance. Does not guarantee that many vectors have 768a13362dSEric Joyner * actually been enabled. 778a13362dSEric Joyner */ 788a13362dSEric Joyner #define ICE_RDMA_MAX_MSIX 64 798a13362dSEric Joyner 808a13362dSEric Joyner /** 818a13362dSEric Joyner * @struct ice_rdma_info 828a13362dSEric Joyner * @brief RDMA information from the client driver 838a13362dSEric Joyner * 848a13362dSEric Joyner * The RDMA client driver will fill in this structure and pass its contents 858a13362dSEric Joyner * back to the main driver using the ice_rdma_register function. 868a13362dSEric Joyner * 878a13362dSEric Joyner * It should fill the version in with the ICE_RDMA_* versions as defined in 888a13362dSEric Joyner * the ice_rdma.h header. 898a13362dSEric Joyner * 908a13362dSEric Joyner * Additionally it must provide a pointer to a kobject class which extends the 918a13362dSEric Joyner * ice_rdma_di_class with the operations defined in the rdma_if.m interface. 928a13362dSEric Joyner * 938a13362dSEric Joyner * If the version specified is not compatible, then the registration will 948a13362dSEric Joyner * of the RDMA driver will fail. 958a13362dSEric Joyner */ 968a13362dSEric Joyner struct ice_rdma_info { 978a13362dSEric Joyner uint16_t major_version; 988a13362dSEric Joyner uint16_t minor_version; 998a13362dSEric Joyner uint16_t patch_version; 1008a13362dSEric Joyner 1018a13362dSEric Joyner kobj_class_t rdma_class; 1028a13362dSEric Joyner }; 1038a13362dSEric Joyner 1048a13362dSEric Joyner #define ICE_RDMA_MAX_USER_PRIORITY 8 1058a13362dSEric Joyner #define ICE_RDMA_MAX_MSIX 64 1068a13362dSEric Joyner 1078a13362dSEric Joyner /* Declare the ice_rdma_di kobject class */ 1088a13362dSEric Joyner DECLARE_CLASS(ice_rdma_di_class); 1098a13362dSEric Joyner 1108a13362dSEric Joyner /** 1118a13362dSEric Joyner * @struct ice_rdma_msix_mapping 1128a13362dSEric Joyner * @brief MSI-X mapping requested by the peer RDMA driver 1138a13362dSEric Joyner * 1148a13362dSEric Joyner * Defines a mapping for MSI-X vectors being requested by the peer RDMA driver 1158a13362dSEric Joyner * for a given PF. 1168a13362dSEric Joyner */ 1178a13362dSEric Joyner struct ice_rdma_msix_mapping { 1188a13362dSEric Joyner uint8_t itr_indx; 1198a13362dSEric Joyner int aeq_vector; 1208a13362dSEric Joyner int ceq_cnt; 1218a13362dSEric Joyner int *ceq_vector; 1228a13362dSEric Joyner }; 1238a13362dSEric Joyner 1248a13362dSEric Joyner /** 1258a13362dSEric Joyner * @struct ice_rdma_msix 1268a13362dSEric Joyner * @brief RDMA MSI-X vectors reserved for the peer RDMA driver 1278a13362dSEric Joyner * 1288a13362dSEric Joyner * Defines the segment of the MSI-X vectors for use by the RDMA driver. These 1298a13362dSEric Joyner * are reserved by the PF when it initializes. 1308a13362dSEric Joyner */ 1318a13362dSEric Joyner struct ice_rdma_msix { 1328a13362dSEric Joyner int base; 1338a13362dSEric Joyner int count; 1348a13362dSEric Joyner }; 1358a13362dSEric Joyner 1368a13362dSEric Joyner /** 1378a13362dSEric Joyner * @struct ice_qos_info 1388a13362dSEric Joyner * @brief QoS information to be shared with RDMA driver 1398a13362dSEric Joyner */ 1408a13362dSEric Joyner struct ice_qos_info { 1418a13362dSEric Joyner uint64_t tc_ctx; 1428a13362dSEric Joyner uint8_t rel_bw; 1438a13362dSEric Joyner uint8_t prio_type; 1448a13362dSEric Joyner uint8_t egress_virt_up; 1458a13362dSEric Joyner uint8_t ingress_virt_up; 1468a13362dSEric Joyner }; 1478a13362dSEric Joyner 1488a13362dSEric Joyner /** 1498a13362dSEric Joyner * @struct ice_qos_app_priority_table 1508a13362dSEric Joyner * @brief Application priority data 1518a13362dSEric Joyner */ 1528a13362dSEric Joyner struct ice_qos_app_priority_table { 1538a13362dSEric Joyner uint16_t prot_id; 1548a13362dSEric Joyner uint8_t priority; 1558a13362dSEric Joyner uint8_t selector; 1568a13362dSEric Joyner }; 1578a13362dSEric Joyner 1588a13362dSEric Joyner #define IEEE_8021QAZ_MAX_TCS 8 1598a13362dSEric Joyner #define ICE_TC_MAX_USER_PRIORITY 8 1608a13362dSEric Joyner #define ICE_QOS_MAX_APPS 32 1618a13362dSEric Joyner #define ICE_QOS_DSCP_NUM_VAL 64 1628a13362dSEric Joyner 1638a13362dSEric Joyner /** 1648a13362dSEric Joyner * @struct ice_qos_params 1658a13362dSEric Joyner * @brief Holds all necessary data for RDMA to work with DCB 1668a13362dSEric Joyner * 1678a13362dSEric Joyner * Struct to hold QoS info 1688a13362dSEric Joyner */ 1698a13362dSEric Joyner struct ice_qos_params { 1708a13362dSEric Joyner struct ice_qos_info tc_info[IEEE_8021QAZ_MAX_TCS]; 1718a13362dSEric Joyner uint8_t up2tc[ICE_TC_MAX_USER_PRIORITY]; 1728a13362dSEric Joyner uint8_t vsi_relative_bw; 1738a13362dSEric Joyner uint8_t vsi_priority_type; 1748a13362dSEric Joyner uint32_t num_apps; 1758a13362dSEric Joyner uint8_t pfc_mode; 1768a13362dSEric Joyner uint8_t dscp_map[ICE_QOS_DSCP_NUM_VAL]; 1778a13362dSEric Joyner struct ice_qos_app_priority_table apps[ICE_QOS_MAX_APPS]; 1788a13362dSEric Joyner uint8_t num_tc; 1798a13362dSEric Joyner }; 1808a13362dSEric Joyner 1818a13362dSEric Joyner /** 1828a13362dSEric Joyner * @struct ice_rdma_peer 1838a13362dSEric Joyner * @brief RDMA driver information 1848a13362dSEric Joyner * 1858a13362dSEric Joyner * Shared structure used by the RDMA client driver when talking with the main 1868a13362dSEric Joyner * device driver. 1878a13362dSEric Joyner * 1888a13362dSEric Joyner * Because the definition of this structure is shared between the two drivers, 1898a13362dSEric Joyner * its ABI should be handled carefully. 1908a13362dSEric Joyner */ 1918a13362dSEric Joyner struct ice_rdma_peer { 1928a13362dSEric Joyner /** 1938a13362dSEric Joyner * The KOBJ_FIELDS macro must come first, in order for it to be used 1948a13362dSEric Joyner * as a kobject. 1958a13362dSEric Joyner */ 1968a13362dSEric Joyner KOBJ_FIELDS; 1978a13362dSEric Joyner 1988a13362dSEric Joyner struct ifnet *ifp; 1998a13362dSEric Joyner device_t dev; 2008a13362dSEric Joyner struct resource *pci_mem; 2018a13362dSEric Joyner struct ice_qos_params initial_qos_info; 2028a13362dSEric Joyner struct ice_rdma_msix msix; 2038a13362dSEric Joyner uint16_t mtu; 2048a13362dSEric Joyner uint16_t pf_vsi_num; 2058a13362dSEric Joyner uint8_t pf_id; 2068a13362dSEric Joyner }; 2078a13362dSEric Joyner 2088a13362dSEric Joyner /** 2098a13362dSEric Joyner * @enum ice_res_type 2108a13362dSEric Joyner * @brief enum for type of resource registration 2118a13362dSEric Joyner * 2128a13362dSEric Joyner * enum for type of resource registration. 2138a13362dSEric Joyner * created for plausible compatibility with IDC 2148a13362dSEric Joyner */ 2158a13362dSEric Joyner enum ice_res_type { 2168a13362dSEric Joyner ICE_INVAL_RES = 0x0, 2178a13362dSEric Joyner ICE_RDMA_QSET_ALLOC = 0x8, 2188a13362dSEric Joyner ICE_RDMA_QSET_FREE = 0x18, 2198a13362dSEric Joyner }; 2208a13362dSEric Joyner 2218a13362dSEric Joyner /** 2228a13362dSEric Joyner * @struct ice_rdma_qset_params 2238a13362dSEric Joyner * @brief struct to hold per RDMA Qset info 2248a13362dSEric Joyner */ 2258a13362dSEric Joyner struct ice_rdma_qset_params { 2268a13362dSEric Joyner uint32_t teid; /* qset TEID */ 2278a13362dSEric Joyner uint16_t qs_handle; /* RDMA driver provides this */ 2288a13362dSEric Joyner uint16_t vsi_id; /* VSI index */ 2298a13362dSEric Joyner uint8_t tc; /* TC branch the QSet should belong to */ 2308a13362dSEric Joyner uint8_t reserved[3]; 2318a13362dSEric Joyner }; 2328a13362dSEric Joyner 2338a13362dSEric Joyner #define ICE_MAX_TXQ_PER_TXQG 128 2348a13362dSEric Joyner /** 2358a13362dSEric Joyner * @struct ice_rdma_qset_update 2368a13362dSEric Joyner * @brief struct used to register and unregister qsets for RDMA driver 2378a13362dSEric Joyner */ 2388a13362dSEric Joyner struct ice_rdma_qset_update { 2398a13362dSEric Joyner enum ice_res_type res_type; 2408a13362dSEric Joyner uint16_t cnt_req; 2418a13362dSEric Joyner uint16_t res_allocated; 2428a13362dSEric Joyner uint32_t res_handle; 2438a13362dSEric Joyner struct ice_rdma_qset_params qsets; 2448a13362dSEric Joyner }; 2458a13362dSEric Joyner 2468a13362dSEric Joyner /** 2478a13362dSEric Joyner * @enum ice_rdma_event_type 2488a13362dSEric Joyner * @brief enum for type of event from base driver 2498a13362dSEric Joyner */ 2508a13362dSEric Joyner enum ice_rdma_event_type { 2518a13362dSEric Joyner ICE_RDMA_EVENT_NONE = 0, 2528a13362dSEric Joyner ICE_RDMA_EVENT_LINK_CHANGE, 2538a13362dSEric Joyner ICE_RDMA_EVENT_MTU_CHANGE, 2548a13362dSEric Joyner ICE_RDMA_EVENT_TC_CHANGE, 2558a13362dSEric Joyner ICE_RDMA_EVENT_API_CHANGE, 2568a13362dSEric Joyner ICE_RDMA_EVENT_CRIT_ERR, 2578a13362dSEric Joyner ICE_RDMA_EVENT_RESET, 2588a13362dSEric Joyner ICE_RDMA_EVENT_QSET_REGISTER, 2598a13362dSEric Joyner ICE_RDMA_EVENT_VSI_FILTER_UPDATE, 2608a13362dSEric Joyner ICE_RDMA_EVENT_LAST 2618a13362dSEric Joyner }; 2628a13362dSEric Joyner 2638a13362dSEric Joyner /** 2648a13362dSEric Joyner * @struct ice_rdma_event 2658a13362dSEric Joyner * @brief struct for event information to pass to RDMA driver 2668a13362dSEric Joyner */ 2678a13362dSEric Joyner struct ice_rdma_event { 2688a13362dSEric Joyner enum ice_rdma_event_type type; 2698a13362dSEric Joyner union { 2708a13362dSEric Joyner /* link change event */ 2718a13362dSEric Joyner struct { 2728a13362dSEric Joyner int linkstate; 2738a13362dSEric Joyner uint64_t baudrate; 2748a13362dSEric Joyner }; 2758a13362dSEric Joyner /* MTU change event */ 2768a13362dSEric Joyner int mtu; 2778a13362dSEric Joyner /* 2788a13362dSEric Joyner * TC/QoS/DCB change event 2798a13362dSEric Joyner * prep: if true, this is a pre-event, post-event otherwise 2808a13362dSEric Joyner */ 2818a13362dSEric Joyner struct { 2828a13362dSEric Joyner struct ice_qos_params port_qos; 2838a13362dSEric Joyner bool prep; 2848a13362dSEric Joyner }; 285*01fbb869SBartosz Sobczak /* 286*01fbb869SBartosz Sobczak * CRIT_ERR event 287*01fbb869SBartosz Sobczak */ 288*01fbb869SBartosz Sobczak uint32_t oicr_reg; 2898a13362dSEric Joyner }; 2908a13362dSEric Joyner }; 2918a13362dSEric Joyner 2928a13362dSEric Joyner /** 2938a13362dSEric Joyner * @struct ice_rdma_request 2948a13362dSEric Joyner * @brief struct with data for a request from the RDMA driver 2958a13362dSEric Joyner */ 2968a13362dSEric Joyner struct ice_rdma_request { 2978a13362dSEric Joyner enum ice_rdma_event_type type; 2988a13362dSEric Joyner union { 2998a13362dSEric Joyner struct { 3008a13362dSEric Joyner struct ice_rdma_qset_update res; 3018a13362dSEric Joyner }; 3028a13362dSEric Joyner struct { 3038a13362dSEric Joyner bool enable_filter; 3048a13362dSEric Joyner }; 3058a13362dSEric Joyner }; 3068a13362dSEric Joyner }; 3078a13362dSEric Joyner 3088a13362dSEric Joyner int ice_rdma_register(struct ice_rdma_info *info); 3098a13362dSEric Joyner int ice_rdma_unregister(void); 3108a13362dSEric Joyner 3118a13362dSEric Joyner #endif 312