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 parameters 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 /** 132 * @brief Copy forced MAC address from bulletin board 133 * 134 * @param hwfn 135 * @param dst_mac 136 * @param p_is_forced - out param which indicate in case mac 137 * exist if it forced or not. 138 * 139 * @return bool - return true if mac exist and false if 140 * not. 141 */ 142 bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac, 143 u8 *p_is_forced); 144 145 /** 146 * @brief Check if force vlan is set and copy the forced vlan 147 * from bulletin board 148 * 149 * @param hwfn 150 * @param dst_pvid 151 * @return bool 152 */ 153 bool ecore_vf_bulletin_get_forced_vlan(struct ecore_hwfn *hwfn, u16 *dst_pvid); 154 155 /** 156 * @brief Check if VF is based on PF whose driver is pre-fp-hsi version; 157 * This affects the fastpath implementation of the driver. 158 * 159 * @param p_hwfn 160 * 161 * @return bool - true iff PF is pre-fp-hsi version. 162 */ 163 bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn); 164 165 166 /** 167 * @brief Set firmware version information in dev_info from VFs acquire response tlv 168 * 169 * @param p_hwfn 170 * @param fw_major 171 * @param fw_minor 172 * @param fw_rev 173 * @param fw_eng 174 */ 175 void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn, 176 u16 *fw_major, 177 u16 *fw_minor, 178 u16 *fw_rev, 179 u16 *fw_eng); 180 void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn *p_hwfn, 181 u16 *p_vxlan_port, u16 *p_geneve_port); 182 #else 183 static OSAL_INLINE enum _ecore_status_t ecore_vf_read_bulletin(struct ecore_hwfn *p_hwfn, u8 *p_change) {return ECORE_INVAL;} 184 static OSAL_INLINE void ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn, struct ecore_mcp_link_params *params) {} 185 static OSAL_INLINE void ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn, struct ecore_mcp_link_state *link) {} 186 static OSAL_INLINE void ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn, struct ecore_mcp_link_capabilities *p_link_caps) {} 187 static OSAL_INLINE void ecore_vf_get_num_rxqs(struct ecore_hwfn *p_hwfn, u8 *num_rxqs) {} 188 static OSAL_INLINE void ecore_vf_get_num_txqs(struct ecore_hwfn *p_hwfn, u8 *num_txqs) {} 189 static OSAL_INLINE void ecore_vf_get_port_mac(struct ecore_hwfn *p_hwfn, u8 *port_mac) {} 190 static OSAL_INLINE void ecore_vf_get_num_vlan_filters(struct ecore_hwfn *p_hwfn, u8 *num_vlan_filters) {} 191 static OSAL_INLINE void ecore_vf_get_num_mac_filters(struct ecore_hwfn *p_hwfn, u8 *num_mac_filters) {} 192 static OSAL_INLINE bool ecore_vf_check_mac(struct ecore_hwfn *p_hwfn, u8 *mac) {return false;} 193 static OSAL_INLINE bool ecore_vf_bulletin_get_forced_mac(struct ecore_hwfn *hwfn, u8 *dst_mac, u8 *p_is_forced) {return false;} 194 static OSAL_INLINE bool ecore_vf_get_pre_fp_hsi(struct ecore_hwfn *p_hwfn) {return false; } 195 static OSAL_INLINE void ecore_vf_get_fw_version(struct ecore_hwfn *p_hwfn, u16 *fw_major, u16 *fw_minor, u16 *fw_rev, u16 *fw_eng) {} 196 static OSAL_INLINE void ecore_vf_bulletin_get_udp_ports(struct ecore_hwfn *p_hwfn, u16 *p_vxlan_port, u16 *p_geneve_port) { return; } 197 #endif 198 #endif 199