xref: /freebsd/sys/dev/ice/ice_rdma_internal.h (revision 8a13362d49bf07dfc654e25976d057adbe0ac9c1)
1*8a13362dSEric Joyner /* SPDX-License-Identifier: BSD-3-Clause */
2*8a13362dSEric Joyner /*  Copyright (c) 2022, Intel Corporation
3*8a13362dSEric Joyner  *  All rights reserved.
4*8a13362dSEric Joyner  *
5*8a13362dSEric Joyner  *  Redistribution and use in source and binary forms, with or without
6*8a13362dSEric Joyner  *  modification, are permitted provided that the following conditions are met:
7*8a13362dSEric Joyner  *
8*8a13362dSEric Joyner  *   1. Redistributions of source code must retain the above copyright notice,
9*8a13362dSEric Joyner  *      this list of conditions and the following disclaimer.
10*8a13362dSEric Joyner  *
11*8a13362dSEric Joyner  *   2. Redistributions in binary form must reproduce the above copyright
12*8a13362dSEric Joyner  *      notice, this list of conditions and the following disclaimer in the
13*8a13362dSEric Joyner  *      documentation and/or other materials provided with the distribution.
14*8a13362dSEric Joyner  *
15*8a13362dSEric Joyner  *   3. Neither the name of the Intel Corporation nor the names of its
16*8a13362dSEric Joyner  *      contributors may be used to endorse or promote products derived from
17*8a13362dSEric Joyner  *      this software without specific prior written permission.
18*8a13362dSEric Joyner  *
19*8a13362dSEric Joyner  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20*8a13362dSEric Joyner  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*8a13362dSEric Joyner  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*8a13362dSEric Joyner  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23*8a13362dSEric Joyner  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*8a13362dSEric Joyner  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*8a13362dSEric Joyner  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*8a13362dSEric Joyner  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*8a13362dSEric Joyner  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*8a13362dSEric Joyner  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*8a13362dSEric Joyner  *  POSSIBILITY OF SUCH DAMAGE.
30*8a13362dSEric Joyner  */
31*8a13362dSEric Joyner /*$FreeBSD$*/
32*8a13362dSEric Joyner 
33*8a13362dSEric Joyner /**
34*8a13362dSEric Joyner  * @file ice_rdma_internal.h
35*8a13362dSEric Joyner  * @brief internal header for the RMDA driver interface setup
36*8a13362dSEric Joyner  *
37*8a13362dSEric Joyner  * Contains the definitions and functions used by the ice driver to setup the
38*8a13362dSEric Joyner  * RDMA driver interface. Functions and definitions in this file are not
39*8a13362dSEric Joyner  * shared with the RDMA client driver.
40*8a13362dSEric Joyner  */
41*8a13362dSEric Joyner #ifndef _ICE_RDMA_INTERNAL_H_
42*8a13362dSEric Joyner #define _ICE_RDMA_INTERNAL_H_
43*8a13362dSEric Joyner 
44*8a13362dSEric Joyner #include "ice_rdma.h"
45*8a13362dSEric Joyner 
46*8a13362dSEric Joyner /* Forward declare the softc structure */
47*8a13362dSEric Joyner struct ice_softc;
48*8a13362dSEric Joyner 
49*8a13362dSEric Joyner /* Global sysctl variable indicating if the RDMA client interface is enabled */
50*8a13362dSEric Joyner extern bool ice_enable_irdma;
51*8a13362dSEric Joyner 
52*8a13362dSEric Joyner /**
53*8a13362dSEric Joyner  * @struct ice_rdma_entry
54*8a13362dSEric Joyner  * @brief RDMA peer list node
55*8a13362dSEric Joyner  *
56*8a13362dSEric Joyner  * Structure used to store peer entries for each PF in a linked list.
57*8a13362dSEric Joyner  */
58*8a13362dSEric Joyner struct ice_rdma_entry {
59*8a13362dSEric Joyner 	LIST_ENTRY(ice_rdma_entry) node;
60*8a13362dSEric Joyner 	struct ice_rdma_peer peer;
61*8a13362dSEric Joyner 	bool attached;
62*8a13362dSEric Joyner 	bool initiated;
63*8a13362dSEric Joyner };
64*8a13362dSEric Joyner 
65*8a13362dSEric Joyner #define ice_rdma_peer_to_entry(p) __containerof(p, struct ice_rdma_entry, peer)
66*8a13362dSEric Joyner #define ice_rdma_entry_to_sc(e) __containerof(e, struct ice_softc, rdma_entry)
67*8a13362dSEric Joyner #define ice_rdma_peer_to_sc(p) ice_rdma_entry_to_sc(ice_rdma_peer_to_entry(p))
68*8a13362dSEric Joyner 
69*8a13362dSEric Joyner /**
70*8a13362dSEric Joyner  * @struct ice_rdma_peers
71*8a13362dSEric Joyner  * @brief Head list structure for the RDMA entry list
72*8a13362dSEric Joyner  *
73*8a13362dSEric Joyner  * Type defining the head of the linked list of RDMA entries.
74*8a13362dSEric Joyner  */
75*8a13362dSEric Joyner LIST_HEAD(ice_rdma_peers, ice_rdma_entry);
76*8a13362dSEric Joyner 
77*8a13362dSEric Joyner /**
78*8a13362dSEric Joyner  * @struct ice_rdma_state
79*8a13362dSEric Joyner  * @brief global driver state for RDMA
80*8a13362dSEric Joyner  *
81*8a13362dSEric Joyner  * Contains global state shared across all PFs by the device driver, such as
82*8a13362dSEric Joyner  * the kobject class of the currently connected peer driver, and the linked
83*8a13362dSEric Joyner  * list of peer entries for each PF.
84*8a13362dSEric Joyner  */
85*8a13362dSEric Joyner struct ice_rdma_state {
86*8a13362dSEric Joyner 	bool registered;
87*8a13362dSEric Joyner 	kobj_class_t peer_class;
88*8a13362dSEric Joyner 	struct sx mtx;
89*8a13362dSEric Joyner 	struct ice_rdma_peers peers;
90*8a13362dSEric Joyner };
91*8a13362dSEric Joyner 
92*8a13362dSEric Joyner void ice_rdma_init(void);
93*8a13362dSEric Joyner void ice_rdma_exit(void);
94*8a13362dSEric Joyner 
95*8a13362dSEric Joyner int  ice_rdma_pf_attach(struct ice_softc *sc);
96*8a13362dSEric Joyner void ice_rdma_pf_detach(struct ice_softc *sc);
97*8a13362dSEric Joyner int  ice_rdma_pf_init(struct ice_softc *sc);
98*8a13362dSEric Joyner int  ice_rdma_pf_stop(struct ice_softc *sc);
99*8a13362dSEric Joyner void ice_rdma_link_change(struct ice_softc *sc, int linkstate, uint64_t baudrate);
100*8a13362dSEric Joyner void ice_rdma_notify_dcb_qos_change(struct ice_softc *sc);
101*8a13362dSEric Joyner void ice_rdma_dcb_qos_update(struct ice_softc *sc, struct ice_port_info *pi);
102*8a13362dSEric Joyner #endif
103