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 */ 28 29 #ifndef __ECORE_VF_API_H__ 30 #define __ECORE_VF_API_H__ 31 32 #include "ecore_sp_api.h" 33 #include "ecore_mcp_api.h" 34 35 #ifdef CONFIG_ECORE_SRIOV 36 /** 37 * @brief Read the VF bulletin and act on it if needed 38 * 39 * @param p_hwfn 40 * @param p_change - ecore fills 1 iff bulletin board has changed, 0 otherwise. 41 * 42 * @return enum _ecore_status 43 */ 44 enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn, 45 u8 *p_change); 46 47 /** 48 * @brief Get link parameters for VF from ecore 49 * 50 * @param p_hwfn 51 * @param params - the link params structure to be filled for the VF 52 */ 53 void ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn, 54 struct ecore_mcp_link_params *params); 55 56 /** 57 * @brief Get link state for VF from ecore 58 * 59 * @param p_hwfn 60 * @param link - the link state structure to be filled for the VF 61 */ 62 void ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn, 63 struct ecore_mcp_link_state *link); 64 65 /** 66 * @brief Get link capabilities for VF from ecore 67 * 68 * @param p_hwfn 69 * @param p_link_caps - the link capabilities structure to be filled for the VF 70 */ 71 void ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn, 72 struct ecore_mcp_link_capabilities *p_link_caps); 73 74 /** 75 * @brief Get number of Rx queues allocated for VF by ecore 76 * 77 * @param p_hwfn 78 * @param num_rxqs - allocated RX queues 79 */ 80 void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn, 81 u8 *num_rxqs); 82 83 /** 84 * @brief Get number of Rx queues allocated for VF by ecore 85 * 86 * @param p_hwfn 87 * @param num_txqs - allocated RX queues 88 */ 89 void ecore_vf_get_num_txqs(struct ecore_hwfn *p_hwfn, 90 u8 *num_txqs); 91 92 /** 93 * @brief Get number of available connections [both Rx and Tx] for VF 94 * 95 * @param p_hwfn 96 * @param num_cids - allocated number of connections 97 */ 98 void ecore_vf_get_num_cids(struct ecore_hwfn *p_hwfn, u8 *num_cids); 99 100 /** 101 * @brief Get port mac address for VF 102 * 103 * @param p_hwfn 104 * @param port_mac - destination location for port mac 105 */ 106 void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn, 107 u8 *port_mac); 108 109 /** 110 * @brief Get number of VLAN filters allocated for VF by ecore 111 * 112 * @param p_hwfn 113 * @param num_rxqs - allocated VLAN filters 114 */ 115 void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn, 116 u8 *num_vlan_filters); 117 118 /** 119 * @brief Get number of MAC filters allocated for VF by ecore 120 * 121 * @param p_hwfn 122 * @param num_rxqs - allocated MAC filters 123 */ 124 void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn, 125 u8 *num_mac_filters); 126 127 /** 128 * @brief Check if VF can set a MAC address 129 * 130 * @param p_hwfn 131 * @param mac 132 * 133 * @return bool 134 */ 135 bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac); 136 137 #ifndef LINUX_REMOVE 138 /** 139 * @brief Copy forced MAC address from bulletin board 140 * 141 * @param hwfn 142 * @param dst_mac 143 * @param p_is_forced - out param which indicate in case mac 144 * exist if it forced or not. 145 * 146 * @return bool - return true if mac exist and false if 147 * not. 148 */ 149 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac, 150 u8 *p_is_forced); 151 152 /** 153 * @brief Check if force vlan is set and copy the forced vlan 154 * from bulletin board 155 * 156 * @param hwfn 157 * @param dst_pvid 158 * @return bool 159 */ 160 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid); 161 162 /** 163 * @brief Check if VF is based on PF whose driver is pre-fp-hsi version; 164 * This affects the fastpath implementation of the driver. 165 * 166 * @param p_hwfn 167 * 168 * @return bool - true iff PF is pre-fp-hsi version. 169 */ 170 bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn); 171 172 #endif 173 174 /** 175 * @brief Set firmware version information in dev_info from VFs acquire response tlv 176 * 177 * @param p_hwfn 178 * @param fw_major 179 * @param fw_minor 180 * @param fw_rev 181 * @param fw_eng 182 */ 183 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn, 184 u16 *fw_major, 185 u16 *fw_minor, 186 u16 *fw_rev, 187 u16 *fw_eng); 188 void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn *p_hwfn, 189 u16 *p_vxlan_port, u16 *p_geneve_port); 190 191 #ifdef CONFIG_ECORE_SW_CHANNEL 192 /** 193 * @brief set the VF to use a SW/HW channel when communicating with PF. 194 * NOTICE: today the likely first place to call this from VF 195 * would be OSAL_VF_FILL_ACQUIRE_RESC_REQ(); Might want to consider 196 * something a bit more appropriate. 197 * 198 * @param p_hwfn 199 * @param b_is_hw - true iff VF is to use a HW-channel 200 */ 201 void ecore_vf_set_hw_channel(struct ecore_hwfn *p_hwfn, bool b_is_hw); 202 #endif 203 #else 204 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;} 205 static OSAL_INLINE void ecore_vf_get_link_params(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_params OSAL_UNUSED *params) {} 206 static OSAL_INLINE void ecore_vf_get_link_state(struct ecore_hwfn OSAL_UNUSED *p_hwfn, struct ecore_mcp_link_state OSAL_UNUSED *link) {} 207 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) {} 208 static OSAL_INLINE void ecore_vf_get_num_rxqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_rxqs) {} 209 static OSAL_INLINE void ecore_vf_get_num_txqs(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_txqs) {} 210 211 static OSAL_INLINE void 212 ecore_vf_get_num_cids(struct ecore_hwfn OSAL_UNUSED *p_hwfn, 213 u8 OSAL_UNUSED *num_cids) 214 { 215 } 216 static OSAL_INLINE void ecore_vf_get_port_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *port_mac) {} 217 static OSAL_INLINE void ecore_vf_get_num_vlan_filters(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_vlan_filters) {} 218 static OSAL_INLINE void ecore_vf_get_num_mac_filters(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *num_mac_filters) {} 219 static OSAL_INLINE bool ecore_vf_check_mac(struct ecore_hwfn OSAL_UNUSED *p_hwfn, u8 OSAL_UNUSED *mac) {return false;} 220 #ifndef LINUX_REMOVE 221 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;} 222 static OSAL_INLINE bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn OSAL_UNUSED *p_hwfn) {return false; } 223 #endif 224 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) {} 225 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; } 226 227 #ifdef CONFIG_ECORE_SW_CHANNEL 228 static OSAL_INLINE void 229 ecore_vf_set_hw_channel(struct ecore_hwfn OSAL_UNUSED *p_hwfn, 230 bool OSAL_UNUSED b_is_hw) {} 231 #endif 232 #endif 233 #endif 234