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_internal.h 348a13362dSEric Joyner * @brief internal header for the RMDA driver interface setup 358a13362dSEric Joyner * 368a13362dSEric Joyner * Contains the definitions and functions used by the ice driver to setup the 378a13362dSEric Joyner * RDMA driver interface. Functions and definitions in this file are not 388a13362dSEric Joyner * shared with the RDMA client driver. 398a13362dSEric Joyner */ 408a13362dSEric Joyner #ifndef _ICE_RDMA_INTERNAL_H_ 418a13362dSEric Joyner #define _ICE_RDMA_INTERNAL_H_ 428a13362dSEric Joyner 438a13362dSEric Joyner #include "ice_rdma.h" 448a13362dSEric Joyner 458a13362dSEric Joyner /* Forward declare the softc structure */ 468a13362dSEric Joyner struct ice_softc; 478a13362dSEric Joyner 488a13362dSEric Joyner /* Global sysctl variable indicating if the RDMA client interface is enabled */ 498a13362dSEric Joyner extern bool ice_enable_irdma; 508a13362dSEric Joyner 518a13362dSEric Joyner /** 528a13362dSEric Joyner * @struct ice_rdma_entry 538a13362dSEric Joyner * @brief RDMA peer list node 548a13362dSEric Joyner * 558a13362dSEric Joyner * Structure used to store peer entries for each PF in a linked list. 569c30461dSEric Joyner * @var ice_rdma_entry::attached 579c30461dSEric Joyner * check for irdma driver attached 589c30461dSEric Joyner * @var ice_rdma_entry::initiated 599c30461dSEric Joyner * check for irdma driver ready to use 609c30461dSEric Joyner * @var ice_rdma_entry::node 619c30461dSEric Joyner * list node of the RDMA entry 629c30461dSEric Joyner * @var ice_rdma_entry::peer 639c30461dSEric Joyner * pointer to peer 648a13362dSEric Joyner */ 658a13362dSEric Joyner struct ice_rdma_entry { 668a13362dSEric Joyner LIST_ENTRY(ice_rdma_entry) node; 678a13362dSEric Joyner struct ice_rdma_peer peer; 688a13362dSEric Joyner bool attached; 698a13362dSEric Joyner bool initiated; 708a13362dSEric Joyner }; 718a13362dSEric Joyner 728a13362dSEric Joyner #define ice_rdma_peer_to_entry(p) __containerof(p, struct ice_rdma_entry, peer) 738a13362dSEric Joyner #define ice_rdma_entry_to_sc(e) __containerof(e, struct ice_softc, rdma_entry) 748a13362dSEric Joyner #define ice_rdma_peer_to_sc(p) ice_rdma_entry_to_sc(ice_rdma_peer_to_entry(p)) 758a13362dSEric Joyner 768a13362dSEric Joyner /** 778a13362dSEric Joyner * @struct ice_rdma_peers 788a13362dSEric Joyner * @brief Head list structure for the RDMA entry list 798a13362dSEric Joyner * 808a13362dSEric Joyner * Type defining the head of the linked list of RDMA entries. 818a13362dSEric Joyner */ 828a13362dSEric Joyner LIST_HEAD(ice_rdma_peers, ice_rdma_entry); 838a13362dSEric Joyner 848a13362dSEric Joyner /** 858a13362dSEric Joyner * @struct ice_rdma_state 868a13362dSEric Joyner * @brief global driver state for RDMA 878a13362dSEric Joyner * 888a13362dSEric Joyner * Contains global state shared across all PFs by the device driver, such as 898a13362dSEric Joyner * the kobject class of the currently connected peer driver, and the linked 908a13362dSEric Joyner * list of peer entries for each PF. 919c30461dSEric Joyner * 929c30461dSEric Joyner * @var ice_rdma_state::registered 939c30461dSEric Joyner * check forr irdma driver registered 949c30461dSEric Joyner * @var ice_rdma_state::peer_class 959c30461dSEric Joyner * kobject class for irdma driver 969c30461dSEric Joyner * @var ice_rdma_state::mtx 979c30461dSEric Joyner * mutex for protecting irdma operations 989c30461dSEric Joyner * @var ice_rdma_state::peers 999c30461dSEric Joyner * list of RDMA entries 1008a13362dSEric Joyner */ 1018a13362dSEric Joyner struct ice_rdma_state { 1028a13362dSEric Joyner bool registered; 1038a13362dSEric Joyner kobj_class_t peer_class; 1048a13362dSEric Joyner struct sx mtx; 1058a13362dSEric Joyner struct ice_rdma_peers peers; 1068a13362dSEric Joyner }; 1078a13362dSEric Joyner 1088a13362dSEric Joyner void ice_rdma_init(void); 1098a13362dSEric Joyner void ice_rdma_exit(void); 1108a13362dSEric Joyner 1118a13362dSEric Joyner int ice_rdma_pf_attach(struct ice_softc *sc); 1128a13362dSEric Joyner void ice_rdma_pf_detach(struct ice_softc *sc); 1138a13362dSEric Joyner int ice_rdma_pf_init(struct ice_softc *sc); 1148a13362dSEric Joyner int ice_rdma_pf_stop(struct ice_softc *sc); 1158a13362dSEric Joyner void ice_rdma_link_change(struct ice_softc *sc, int linkstate, uint64_t baudrate); 1168a13362dSEric Joyner void ice_rdma_notify_dcb_qos_change(struct ice_softc *sc); 1178a13362dSEric Joyner void ice_rdma_dcb_qos_update(struct ice_softc *sc, struct ice_port_info *pi); 11801fbb869SBartosz Sobczak void ice_rdma_notify_pe_intr(struct ice_softc *sc, uint32_t oicr); 11901fbb869SBartosz Sobczak void ice_rdma_notify_reset(struct ice_softc *sc); 1208a13362dSEric Joyner #endif 121