xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_vf_api.h (revision b00ab754)
1 /*
2  * Copyright (c) 2017-2018 Cavium, Inc.
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
7  *  are met:
8  *
9  *  1. Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
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  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  *  POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  *
29  */
30 
31 #ifndef __ECORE_VF_API_H__
32 #define __ECORE_VF_API_H__
33 
34 #include "ecore_sp_api.h"
35 #include "ecore_mcp_api.h"
36 
37 #ifdef CONFIG_ECORE_SRIOV
38 /**
39  * @brief Read the VF bulletin and act on it if needed
40  *
41  * @param p_hwfn
42  * @param p_change - ecore fills 1 iff bulletin board has changed, 0 otherwise.
43  *
44  * @return enum _ecore_status
45  */
46 enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn,
47 					    u8 *p_change);
48 
49 /**
50  * @brief Get link paramters for VF from ecore
51  *
52  * @param p_hwfn
53  * @param params - the link params structure to be filled for the VF
54  */
55 void ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
56 			      struct ecore_mcp_link_params *params);
57 
58 /**
59  * @brief Get link state for VF from ecore
60  *
61  * @param p_hwfn
62  * @param link - the link state structure to be filled for the VF
63  */
64 void ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
65 			     struct ecore_mcp_link_state *link);
66 
67 /**
68  * @brief Get link capabilities for VF from ecore
69  *
70  * @param p_hwfn
71  * @param p_link_caps - the link capabilities structure to be filled for the VF
72  */
73 void ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
74 			    struct ecore_mcp_link_capabilities *p_link_caps);
75 
76 /**
77  * @brief Get number of Rx queues allocated for VF by ecore
78  *
79  *  @param p_hwfn
80  *  @param num_rxqs - allocated RX queues
81  */
82 void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn,
83 			   u8 *num_rxqs);
84 
85 /**
86  * @brief Get number of Rx queues allocated for VF by ecore
87  *
88  *  @param p_hwfn
89  *  @param num_txqs - allocated RX queues
90  */
91 void ecore_vf_get_num_txqs(struct ecore_hwfn *p_hwfn,
92 			   u8 *num_txqs);
93 
94 /**
95  * @brief Get port mac address for VF
96  *
97  * @param p_hwfn
98  * @param port_mac - destination location for port mac
99  */
100 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn,
101 			   u8 *port_mac);
102 
103 /**
104  * @brief Get number of VLAN filters allocated for VF by ecore
105  *
106  *  @param p_hwfn
107  *  @param num_rxqs - allocated VLAN filters
108  */
109 void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn,
110 				   u8 *num_vlan_filters);
111 
112 /**
113  * @brief Get number of MAC filters allocated for VF by ecore
114  *
115  *  @param p_hwfn
116  *  @param num_rxqs - allocated MAC filters
117  */
118 void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn,
119 				  u8 *num_mac_filters);
120 
121 /**
122  * @brief Check if VF can set a MAC address
123  *
124  * @param p_hwfn
125  * @param mac
126  *
127  * @return bool
128  */
129 bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac);
130 
131 #ifndef LINUX_REMOVE
132 /**
133  * @brief Copy forced MAC address from bulletin board
134  *
135  * @param hwfn
136  * @param dst_mac
137  * @param p_is_forced - out param which indicate in case mac
138  *      	        exist if it forced or not.
139  *
140  * @return bool       - return true if mac exist and false if
141  *                      not.
142  */
143 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac,
144 				      u8 *p_is_forced);
145 
146 /**
147  * @brief Check if force vlan is set and copy the forced vlan
148  *        from bulletin board
149  *
150  * @param hwfn
151  * @param dst_pvid
152  * @return bool
153  */
154 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid);
155 
156 /**
157  * @brief Check if VF is based on PF whose driver is pre-fp-hsi version;
158  *        This affects the fastpath implementation of the driver.
159  *
160  * @param p_hwfn
161  *
162  * @return bool - true iff PF is pre-fp-hsi version.
163  */
164 bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn);
165 
166 #endif
167 
168 /**
169  * @brief Set firmware version information in dev_info from VFs acquire response tlv
170  *
171  * @param p_hwfn
172  * @param fw_major
173  * @param fw_minor
174  * @param fw_rev
175  * @param fw_eng
176  */
177 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn,
178 			     u16 *fw_major,
179 			     u16 *fw_minor,
180 			     u16 *fw_rev,
181 			     u16 *fw_eng);
182 void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn *p_hwfn,
183 				     u16 *p_vxlan_port, u16 *p_geneve_port);
184 #else
185 static OSAL_INLINE enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *p_change) {return ECORE_INVAL;}
186 static OSAL_INLINE void ecore_vf_get_link_params(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_params OSAL_UNUSED *params) {}
187 static OSAL_INLINE void ecore_vf_get_link_state(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_state OSAL_UNUSED *link) {}
188 static OSAL_INLINE void ecore_vf_get_link_caps(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_capabilities OSAL_UNUSED *p_link_caps) {}
189 static OSAL_INLINE void ecore_vf_get_num_rxqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_rxqs) {}
190 static OSAL_INLINE void ecore_vf_get_num_txqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_txqs) {}
191 static OSAL_INLINE void ecore_vf_get_port_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *port_mac) {}
192 static OSAL_INLINE void ecore_vf_get_num_vlan_filters(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_vlan_filters) {}
193 static OSAL_INLINE void ecore_vf_get_num_mac_filters(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_mac_filters) {}
194 static OSAL_INLINE bool ecore_vf_check_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *mac) {return false;}
195 #ifndef LINUX_REMOVE
196 static OSAL_INLINE bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn OSAL_UNUSED *hwfn, u8 OSAL_UNUSED *dst_mac, u8 OSAL_UNUSED *p_is_forced) {return false;}
197 static OSAL_INLINE bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return false; }
198 #endif
199 static OSAL_INLINE void ecore_vf_get_fw_version(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED *fw_major, u16 OSAL_UNUSED *fw_minor, u16 OSAL_UNUSED *fw_rev, u16 OSAL_UNUSED *fw_eng) {}
200 static OSAL_INLINE void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u16 OSAL_UNUSED *p_vxlan_port, u16 OSAL_UNUSED *p_geneve_port) { return; }
201 #endif
202 #endif
203