18a13362dSEric Joyner /* SPDX-License-Identifier: BSD-3-Clause */ 2*015f8cc5SEric Joyner /* Copyright (c) 2024, 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 6701fbb869SBartosz 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. 959c30461dSEric Joyner * 969c30461dSEric Joyner * @var ice_rdma_info::major_version 979c30461dSEric Joyner * describe major changes in the interface 989c30461dSEric Joyner * @var ice_rdma_info::minor_version 999c30461dSEric Joyner * describe changes and fixes with backward compatibility 1009c30461dSEric Joyner * @var ice_rdma_info::patch_version 1019c30461dSEric Joyner * changes without impact on compatibility or features 1029c30461dSEric Joyner * @var ice_rdma_info::rdma_class 1039c30461dSEric Joyner * kobject class 1048a13362dSEric Joyner */ 1058a13362dSEric Joyner struct ice_rdma_info { 1068a13362dSEric Joyner uint16_t major_version; 1078a13362dSEric Joyner uint16_t minor_version; 1088a13362dSEric Joyner uint16_t patch_version; 1098a13362dSEric Joyner 1108a13362dSEric Joyner kobj_class_t rdma_class; 1118a13362dSEric Joyner }; 1128a13362dSEric Joyner 1138a13362dSEric Joyner #define ICE_RDMA_MAX_USER_PRIORITY 8 1148a13362dSEric Joyner #define ICE_RDMA_MAX_MSIX 64 1158a13362dSEric Joyner 1168a13362dSEric Joyner /* Declare the ice_rdma_di kobject class */ 1178a13362dSEric Joyner DECLARE_CLASS(ice_rdma_di_class); 1188a13362dSEric Joyner 1198a13362dSEric Joyner /** 1208a13362dSEric Joyner * @struct ice_rdma_msix_mapping 1218a13362dSEric Joyner * @brief MSI-X mapping requested by the peer RDMA driver 1228a13362dSEric Joyner * 1238a13362dSEric Joyner * Defines a mapping for MSI-X vectors being requested by the peer RDMA driver 1248a13362dSEric Joyner * for a given PF. 1259c30461dSEric Joyner * 1268a13362dSEric Joyner */ 1278a13362dSEric Joyner struct ice_rdma_msix_mapping { 1288a13362dSEric Joyner uint8_t itr_indx; 1298a13362dSEric Joyner int aeq_vector; 1308a13362dSEric Joyner int ceq_cnt; 1318a13362dSEric Joyner int *ceq_vector; 1328a13362dSEric Joyner }; 1338a13362dSEric Joyner 1348a13362dSEric Joyner /** 1358a13362dSEric Joyner * @struct ice_rdma_msix 1368a13362dSEric Joyner * @brief RDMA MSI-X vectors reserved for the peer RDMA driver 1378a13362dSEric Joyner * 1388a13362dSEric Joyner * Defines the segment of the MSI-X vectors for use by the RDMA driver. These 1398a13362dSEric Joyner * are reserved by the PF when it initializes. 1408a13362dSEric Joyner */ 1418a13362dSEric Joyner struct ice_rdma_msix { 1428a13362dSEric Joyner int base; 1438a13362dSEric Joyner int count; 1448a13362dSEric Joyner }; 1458a13362dSEric Joyner 1468a13362dSEric Joyner /** 1478a13362dSEric Joyner * @struct ice_qos_info 1488a13362dSEric Joyner * @brief QoS information to be shared with RDMA driver 1498a13362dSEric Joyner */ 1508a13362dSEric Joyner struct ice_qos_info { 1518a13362dSEric Joyner uint64_t tc_ctx; 1528a13362dSEric Joyner uint8_t rel_bw; 1538a13362dSEric Joyner uint8_t prio_type; 1548a13362dSEric Joyner uint8_t egress_virt_up; 1558a13362dSEric Joyner uint8_t ingress_virt_up; 1568a13362dSEric Joyner }; 1578a13362dSEric Joyner 1588a13362dSEric Joyner /** 1598a13362dSEric Joyner * @struct ice_qos_app_priority_table 1608a13362dSEric Joyner * @brief Application priority data 1618a13362dSEric Joyner */ 1628a13362dSEric Joyner struct ice_qos_app_priority_table { 1638a13362dSEric Joyner uint16_t prot_id; 1648a13362dSEric Joyner uint8_t priority; 1658a13362dSEric Joyner uint8_t selector; 1668a13362dSEric Joyner }; 1678a13362dSEric Joyner 1688a13362dSEric Joyner #define IEEE_8021QAZ_MAX_TCS 8 1698a13362dSEric Joyner #define ICE_TC_MAX_USER_PRIORITY 8 1708a13362dSEric Joyner #define ICE_QOS_MAX_APPS 32 1718a13362dSEric Joyner #define ICE_QOS_DSCP_NUM_VAL 64 1728a13362dSEric Joyner 1738a13362dSEric Joyner /** 1748a13362dSEric Joyner * @struct ice_qos_params 1758a13362dSEric Joyner * @brief Holds all necessary data for RDMA to work with DCB 1768a13362dSEric Joyner * 1778a13362dSEric Joyner * Struct to hold QoS info 1789c30461dSEric Joyner * @var ice_qos_params::tc_info 1799c30461dSEric Joyner * traffic class information 1809c30461dSEric Joyner * @var ice_qos_params::up2tc 1819c30461dSEric Joyner * mapping from user priority to traffic class 1829c30461dSEric Joyner * @var ice_qos_params::vsi_relative_bw 1839c30461dSEric Joyner * bandwidth settings 1849c30461dSEric Joyner * @var ice_qos_params::vsi_priority_type 1859c30461dSEric Joyner * priority type 1869c30461dSEric Joyner * @var ice_qos_params::num_apps 1879c30461dSEric Joyner * app count 1889c30461dSEric Joyner * @var ice_qos_params::pfc_mode 1899c30461dSEric Joyner * PFC mode 1909c30461dSEric Joyner * @var ice_qos_params::dscp_map 1919c30461dSEric Joyner * dscp mapping 1929c30461dSEric Joyner * @var ice_qos_params::apps 1939c30461dSEric Joyner * apps 1949c30461dSEric Joyner * @var ice_qos_params::num_tc 1959c30461dSEric Joyner * number of traffic classes 1969c30461dSEric Joyner }; 1978a13362dSEric Joyner */ 1988a13362dSEric Joyner struct ice_qos_params { 1998a13362dSEric Joyner struct ice_qos_info tc_info[IEEE_8021QAZ_MAX_TCS]; 2008a13362dSEric Joyner uint8_t up2tc[ICE_TC_MAX_USER_PRIORITY]; 2018a13362dSEric Joyner uint8_t vsi_relative_bw; 2028a13362dSEric Joyner uint8_t vsi_priority_type; 2038a13362dSEric Joyner uint32_t num_apps; 2048a13362dSEric Joyner uint8_t pfc_mode; 2058a13362dSEric Joyner uint8_t dscp_map[ICE_QOS_DSCP_NUM_VAL]; 2068a13362dSEric Joyner struct ice_qos_app_priority_table apps[ICE_QOS_MAX_APPS]; 2078a13362dSEric Joyner uint8_t num_tc; 2088a13362dSEric Joyner }; 2098a13362dSEric Joyner 2108a13362dSEric Joyner /** 2118a13362dSEric Joyner * @struct ice_rdma_peer 2128a13362dSEric Joyner * @brief RDMA driver information 2138a13362dSEric Joyner * 2148a13362dSEric Joyner * Shared structure used by the RDMA client driver when talking with the main 2158a13362dSEric Joyner * device driver. 2168a13362dSEric Joyner * 2178a13362dSEric Joyner * Because the definition of this structure is shared between the two drivers, 2188a13362dSEric Joyner * its ABI should be handled carefully. 2199c30461dSEric Joyner * 2209c30461dSEric Joyner * @var ice_rdma_peer::ifp 2219c30461dSEric Joyner * pointer to ifnet structure 2229c30461dSEric Joyner * @var ice_rdma_peer::dev 2239c30461dSEric Joyner * device pointer 2249c30461dSEric Joyner * @var ice_rdma_peer::pci_mem 2259c30461dSEric Joyner * information about PCI 2269c30461dSEric Joyner * @var ice_rdma_peer::initial_qos_info 2279c30461dSEric Joyner * initial information on QoS 2289c30461dSEric Joyner * @var ice_rdma_peer::msix 2299c30461dSEric Joyner * info about msix vectors 2309c30461dSEric Joyner * @var ice_rdma_peer::mtu 2319c30461dSEric Joyner * initial mtu size 2329c30461dSEric Joyner * @var ice_rdma_peer::pf_vsi_num 2339c30461dSEric Joyner * id of vsi 2349c30461dSEric Joyner * @var ice_rdma_peer::pf_id 2359c30461dSEric Joyner * id of PF 2368a13362dSEric Joyner */ 2378a13362dSEric Joyner struct ice_rdma_peer { 2388a13362dSEric Joyner /** 2398a13362dSEric Joyner * The KOBJ_FIELDS macro must come first, in order for it to be used 2408a13362dSEric Joyner * as a kobject. 2418a13362dSEric Joyner */ 2428a13362dSEric Joyner KOBJ_FIELDS; 2438a13362dSEric Joyner 2448a13362dSEric Joyner struct ifnet *ifp; 2458a13362dSEric Joyner device_t dev; 2468a13362dSEric Joyner struct resource *pci_mem; 2478a13362dSEric Joyner struct ice_qos_params initial_qos_info; 2488a13362dSEric Joyner struct ice_rdma_msix msix; 2498a13362dSEric Joyner uint16_t mtu; 2508a13362dSEric Joyner uint16_t pf_vsi_num; 2518a13362dSEric Joyner uint8_t pf_id; 2528a13362dSEric Joyner }; 2538a13362dSEric Joyner 2548a13362dSEric Joyner /** 2558a13362dSEric Joyner * @enum ice_res_type 2568a13362dSEric Joyner * @brief enum for type of resource registration 2578a13362dSEric Joyner * 2588a13362dSEric Joyner * enum for type of resource registration. 2598a13362dSEric Joyner * created for plausible compatibility with IDC 2608a13362dSEric Joyner */ 2618a13362dSEric Joyner enum ice_res_type { 2628a13362dSEric Joyner ICE_INVAL_RES = 0x0, 2638a13362dSEric Joyner ICE_RDMA_QSET_ALLOC = 0x8, 2648a13362dSEric Joyner ICE_RDMA_QSET_FREE = 0x18, 2658a13362dSEric Joyner }; 2668a13362dSEric Joyner 2678a13362dSEric Joyner /** 2688a13362dSEric Joyner * @struct ice_rdma_qset_params 2698a13362dSEric Joyner * @brief struct to hold per RDMA Qset info 2709c30461dSEric Joyner * 2719c30461dSEric Joyner * @var ice_rdma_qset_params::teid 2729c30461dSEric Joyner * qset teid 2739c30461dSEric Joyner * @var ice_rdma_qset_params::qs_handle 2749c30461dSEric Joyner * qset from rdma driver 2759c30461dSEric Joyner * @var ice_rdma_qset_params::vsi_id 2769c30461dSEric Joyner * vsi index 2779c30461dSEric Joyner * @var ice_rdma_qset_params::tc 2789c30461dSEric Joyner * traffic class to which qset should belong to 2799c30461dSEric Joyner * @var ice_rdma_qset_params::reserved 2809c30461dSEric Joyner * for future use 2818a13362dSEric Joyner */ 2828a13362dSEric Joyner struct ice_rdma_qset_params { 2839c30461dSEric Joyner uint32_t teid; 2849c30461dSEric Joyner uint16_t qs_handle; 2859c30461dSEric Joyner uint16_t vsi_id; 2869c30461dSEric Joyner uint8_t tc; 2878a13362dSEric Joyner uint8_t reserved[3]; 2888a13362dSEric Joyner }; 2898a13362dSEric Joyner 2908a13362dSEric Joyner #define ICE_MAX_TXQ_PER_TXQG 128 2918a13362dSEric Joyner /** 2928a13362dSEric Joyner * @struct ice_rdma_qset_update 2938a13362dSEric Joyner * @brief struct used to register and unregister qsets for RDMA driver 2949c30461dSEric Joyner * 2959c30461dSEric Joyner * @var ice_rdma_qset_update::res_type 2969c30461dSEric Joyner * ALLOC or FREE 2979c30461dSEric Joyner * @var ice_rdma_qset_update::cnt_req 2989c30461dSEric Joyner * how many qsets are requested 2999c30461dSEric Joyner * @var ice_rdma_qset_update::res_allocated 3009c30461dSEric Joyner * how many qsets are allocated 3019c30461dSEric Joyner * @var ice_rdma_qset_update::qsets 3029c30461dSEric Joyner * rdma qset info 3038a13362dSEric Joyner */ 3048a13362dSEric Joyner struct ice_rdma_qset_update { 3058a13362dSEric Joyner enum ice_res_type res_type; 3068a13362dSEric Joyner uint16_t cnt_req; 3078a13362dSEric Joyner uint16_t res_allocated; 3088a13362dSEric Joyner uint32_t res_handle; 3098a13362dSEric Joyner struct ice_rdma_qset_params qsets; 3108a13362dSEric Joyner }; 3118a13362dSEric Joyner 3128a13362dSEric Joyner /** 3138a13362dSEric Joyner * @enum ice_rdma_event_type 3148a13362dSEric Joyner * @brief enum for type of event from base driver 3158a13362dSEric Joyner */ 3168a13362dSEric Joyner enum ice_rdma_event_type { 3178a13362dSEric Joyner ICE_RDMA_EVENT_NONE = 0, 3188a13362dSEric Joyner ICE_RDMA_EVENT_LINK_CHANGE, 3198a13362dSEric Joyner ICE_RDMA_EVENT_MTU_CHANGE, 3208a13362dSEric Joyner ICE_RDMA_EVENT_TC_CHANGE, 3218a13362dSEric Joyner ICE_RDMA_EVENT_API_CHANGE, 3228a13362dSEric Joyner ICE_RDMA_EVENT_CRIT_ERR, 3238a13362dSEric Joyner ICE_RDMA_EVENT_RESET, 3248a13362dSEric Joyner ICE_RDMA_EVENT_QSET_REGISTER, 3258a13362dSEric Joyner ICE_RDMA_EVENT_VSI_FILTER_UPDATE, 3268a13362dSEric Joyner ICE_RDMA_EVENT_LAST 3278a13362dSEric Joyner }; 3288a13362dSEric Joyner 3298a13362dSEric Joyner /** 3308a13362dSEric Joyner * @struct ice_rdma_event 3318a13362dSEric Joyner * @brief struct for event information to pass to RDMA driver 3329c30461dSEric Joyner * 3339c30461dSEric Joyner * @var ice_rdma_event::type 3349c30461dSEric Joyner * event type 3358a13362dSEric Joyner */ 3368a13362dSEric Joyner struct ice_rdma_event { 3378a13362dSEric Joyner enum ice_rdma_event_type type; 3388a13362dSEric Joyner union { 3398a13362dSEric Joyner /* link change event */ 3408a13362dSEric Joyner struct { 3418a13362dSEric Joyner int linkstate; 3428a13362dSEric Joyner uint64_t baudrate; 3438a13362dSEric Joyner }; 3448a13362dSEric Joyner /* MTU change event */ 3458a13362dSEric Joyner int mtu; 3468a13362dSEric Joyner /* 3478a13362dSEric Joyner * TC/QoS/DCB change event 3488a13362dSEric Joyner * prep: if true, this is a pre-event, post-event otherwise 3498a13362dSEric Joyner */ 3508a13362dSEric Joyner struct { 3518a13362dSEric Joyner struct ice_qos_params port_qos; 3528a13362dSEric Joyner bool prep; 3538a13362dSEric Joyner }; 35401fbb869SBartosz Sobczak /* 35501fbb869SBartosz Sobczak * CRIT_ERR event 35601fbb869SBartosz Sobczak */ 35701fbb869SBartosz Sobczak uint32_t oicr_reg; 3588a13362dSEric Joyner }; 3598a13362dSEric Joyner }; 3608a13362dSEric Joyner 3618a13362dSEric Joyner /** 3628a13362dSEric Joyner * @struct ice_rdma_request 3638a13362dSEric Joyner * @brief struct with data for a request from the RDMA driver 3649c30461dSEric Joyner * 3659c30461dSEric Joyner * @var ice_rdma_request::type 3669c30461dSEric Joyner * event type 3678a13362dSEric Joyner */ 3688a13362dSEric Joyner struct ice_rdma_request { 3698a13362dSEric Joyner enum ice_rdma_event_type type; 3708a13362dSEric Joyner union { 3718a13362dSEric Joyner struct { 3728a13362dSEric Joyner struct ice_rdma_qset_update res; 3738a13362dSEric Joyner }; 3748a13362dSEric Joyner struct { 3758a13362dSEric Joyner bool enable_filter; 3768a13362dSEric Joyner }; 3778a13362dSEric Joyner }; 3788a13362dSEric Joyner }; 3798a13362dSEric Joyner 3808a13362dSEric Joyner int ice_rdma_register(struct ice_rdma_info *info); 3818a13362dSEric Joyner int ice_rdma_unregister(void); 3828a13362dSEric Joyner 3838a13362dSEric Joyner #endif 384