xref: /freebsd/sys/dev/ice/ice_rdma_internal.h (revision 22cf89c938886d14f5796fc49f9f020c23ea8eaf)
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_internal.h
34  * @brief internal header for the RMDA driver interface setup
35  *
36  * Contains the definitions and functions used by the ice driver to setup the
37  * RDMA driver interface. Functions and definitions in this file are not
38  * shared with the RDMA client driver.
39  */
40 #ifndef _ICE_RDMA_INTERNAL_H_
41 #define _ICE_RDMA_INTERNAL_H_
42 
43 #include "ice_rdma.h"
44 
45 /* Forward declare the softc structure */
46 struct ice_softc;
47 
48 /* Global sysctl variable indicating if the RDMA client interface is enabled */
49 extern bool ice_enable_irdma;
50 
51 /**
52  * @struct ice_rdma_entry
53  * @brief RDMA peer list node
54  *
55  * Structure used to store peer entries for each PF in a linked list.
56  */
57 struct ice_rdma_entry {
58 	LIST_ENTRY(ice_rdma_entry) node;
59 	struct ice_rdma_peer peer;
60 	bool attached;
61 	bool initiated;
62 };
63 
64 #define ice_rdma_peer_to_entry(p) __containerof(p, struct ice_rdma_entry, peer)
65 #define ice_rdma_entry_to_sc(e) __containerof(e, struct ice_softc, rdma_entry)
66 #define ice_rdma_peer_to_sc(p) ice_rdma_entry_to_sc(ice_rdma_peer_to_entry(p))
67 
68 /**
69  * @struct ice_rdma_peers
70  * @brief Head list structure for the RDMA entry list
71  *
72  * Type defining the head of the linked list of RDMA entries.
73  */
74 LIST_HEAD(ice_rdma_peers, ice_rdma_entry);
75 
76 /**
77  * @struct ice_rdma_state
78  * @brief global driver state for RDMA
79  *
80  * Contains global state shared across all PFs by the device driver, such as
81  * the kobject class of the currently connected peer driver, and the linked
82  * list of peer entries for each PF.
83  */
84 struct ice_rdma_state {
85 	bool registered;
86 	kobj_class_t peer_class;
87 	struct sx mtx;
88 	struct ice_rdma_peers peers;
89 };
90 
91 void ice_rdma_init(void);
92 void ice_rdma_exit(void);
93 
94 int  ice_rdma_pf_attach(struct ice_softc *sc);
95 void ice_rdma_pf_detach(struct ice_softc *sc);
96 int  ice_rdma_pf_init(struct ice_softc *sc);
97 int  ice_rdma_pf_stop(struct ice_softc *sc);
98 void ice_rdma_link_change(struct ice_softc *sc, int linkstate, uint64_t baudrate);
99 void ice_rdma_notify_dcb_qos_change(struct ice_softc *sc);
100 void ice_rdma_dcb_qos_update(struct ice_softc *sc, struct ice_port_info *pi);
101 void ice_rdma_notify_pe_intr(struct ice_softc *sc, uint32_t oicr);
102 void ice_rdma_notify_reset(struct ice_softc *sc);
103 #endif
104