xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_vf_api.h (revision c697fb7f)
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 number of available connections [both Rx and Tx] for VF
96  *
97  * @param p_hwfn
98  * @param num_cids - allocated number of connections
99  */
100 void ecore_vf_get_num_cids(struct ecore_hwfn *p_hwfn, u8 *num_cids);
101 
102 /**
103  * @brief Get port mac address for VF
104  *
105  * @param p_hwfn
106  * @param port_mac - destination location for port mac
107  */
108 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn,
109 			   u8 *port_mac);
110 
111 /**
112  * @brief Get number of VLAN filters allocated for VF by ecore
113  *
114  *  @param p_hwfn
115  *  @param num_rxqs - allocated VLAN filters
116  */
117 void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn,
118 				   u8 *num_vlan_filters);
119 
120 /**
121  * @brief Get number of MAC filters allocated for VF by ecore
122  *
123  *  @param p_hwfn
124  *  @param num_rxqs - allocated MAC filters
125  */
126 void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn,
127 				  u8 *num_mac_filters);
128 
129 /**
130  * @brief Check if VF can set a MAC address
131  *
132  * @param p_hwfn
133  * @param mac
134  *
135  * @return bool
136  */
137 bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac);
138 
139 #ifndef LINUX_REMOVE
140 /**
141  * @brief Copy forced MAC address from bulletin board
142  *
143  * @param hwfn
144  * @param dst_mac
145  * @param p_is_forced - out param which indicate in case mac
146  *      	        exist if it forced or not.
147  *
148  * @return bool       - return true if mac exist and false if
149  *                      not.
150  */
151 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac,
152 				      u8 *p_is_forced);
153 
154 /**
155  * @brief Check if force vlan is set and copy the forced vlan
156  *        from bulletin board
157  *
158  * @param hwfn
159  * @param dst_pvid
160  * @return bool
161  */
162 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid);
163 
164 /**
165  * @brief Check if VF is based on PF whose driver is pre-fp-hsi version;
166  *        This affects the fastpath implementation of the driver.
167  *
168  * @param p_hwfn
169  *
170  * @return bool - true iff PF is pre-fp-hsi version.
171  */
172 bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn);
173 
174 #endif
175 
176 /**
177  * @brief Set firmware version information in dev_info from VFs acquire response tlv
178  *
179  * @param p_hwfn
180  * @param fw_major
181  * @param fw_minor
182  * @param fw_rev
183  * @param fw_eng
184  */
185 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn,
186 			     u16 *fw_major,
187 			     u16 *fw_minor,
188 			     u16 *fw_rev,
189 			     u16 *fw_eng);
190 void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn *p_hwfn,
191 				     u16 *p_vxlan_port, u16 *p_geneve_port);
192 
193 #ifdef CONFIG_ECORE_SW_CHANNEL
194 /**
195  * @brief set the VF to use a SW/HW channel when communicating with PF.
196  *        NOTICE: today the likely first place to call this from VF
197  *        would be OSAL_VF_FILL_ACQUIRE_RESC_REQ(); Might want to consider
198  *        something a bit more appropriate.
199  *
200  * @param p_hwfn
201  * @param b_is_hw - true iff VF is to use a HW-channel
202  */
203 void ecore_vf_set_hw_channel(struct ecore_hwfn *p_hwfn, bool b_is_hw);
204 #endif
205 #else
206 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;}
207 static OSAL_INLINE void ecore_vf_get_link_params(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_params OSAL_UNUSED *params) {}
208 static OSAL_INLINE void ecore_vf_get_link_state(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_state OSAL_UNUSED *link) {}
209 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) {}
210 static OSAL_INLINE void ecore_vf_get_num_rxqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_rxqs) {}
211 static OSAL_INLINE void ecore_vf_get_num_txqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_txqs) {}
212 
213 static OSAL_INLINE void
214 ecore_vf_get_num_cids(struct ecore_hwfn OSAL_UNUSED *p_hwfn,
215 		      u8 OSAL_UNUSED *num_cids)
216 {
217 }
218 
219 static OSAL_INLINE void ecore_vf_get_port_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *port_mac) {}
220 static OSAL_INLINE void ecore_vf_get_num_vlan_filters(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_vlan_filters) {}
221 static OSAL_INLINE void ecore_vf_get_num_mac_filters(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_mac_filters) {}
222 static OSAL_INLINE bool ecore_vf_check_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *mac) {return false;}
223 #ifndef LINUX_REMOVE
224 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;}
225 static OSAL_INLINE bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return false; }
226 #endif
227 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) {}
228 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; }
229 
230 #ifdef CONFIG_ECORE_SW_CHANNEL
231 static OSAL_INLINE void
232 ecore_vf_set_hw_channel(struct ecore_hwfn OSAL_UNUSED *p_hwfn,
233 			bool OSAL_UNUSED b_is_hw) {}
234 #endif
235 #endif
236 #endif
237