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 32 #ifndef __ECORE_VF_H__ 33 #define __ECORE_VF_H__ 34 35 #include "ecore_status.h" 36 #include "ecore_vf_api.h" 37 #include "ecore_l2_api.h" 38 #include "ecore_vfpf_if.h" 39 40 /* Default number of CIDs [total of both Rx and Tx] to be requested 41 * by default. 42 */ 43 #define ECORE_ETH_VF_DEFAULT_NUM_CIDS (32) 44 45 /* This data is held in the ecore_hwfn structure for VFs only. */ 46 struct ecore_vf_iov { 47 union vfpf_tlvs *vf2pf_request; 48 dma_addr_t vf2pf_request_phys; 49 union pfvf_tlvs *pf2vf_reply; 50 dma_addr_t pf2vf_reply_phys; 51 52 /* Should be taken whenever the mailbox buffers are accessed */ 53 osal_mutex_t mutex; 54 u8 *offset; 55 56 /* Bulletin Board */ 57 struct ecore_bulletin bulletin; 58 struct ecore_bulletin_content bulletin_shadow; 59 60 /* we set aside a copy of the acquire response */ 61 struct pfvf_acquire_resp_tlv acquire_resp; 62 63 /* In case PF originates prior to the fp-hsi version comparison, 64 * this has to be propagated as it affects the fastpath. 65 */ 66 bool b_pre_fp_hsi; 67 68 /* Current day VFs are passing the SBs physical address on vport 69 * start, and as they lack an IGU mapping they need to store the 70 * addresses of previously registered SBs. 71 * Even if we were to change configuration flow, due to backward 72 * compatibility [with older PFs] we'd still need to store these. 73 */ 74 struct ecore_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF]; 75 }; 76 77 78 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn, 79 struct ecore_ptt *p_ptt, 80 u16 coalesce, 81 struct ecore_queue_cid *p_cid); 82 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn, 83 struct ecore_ptt *p_ptt, 84 u16 coalesce, 85 struct ecore_queue_cid *p_cid); 86 /** 87 * @brief VF - Set Rx/Tx coalesce per VF's relative queue. 88 * Coalesce value '0' will omit the configuration. 89 * 90 * @param p_hwfn 91 * @param rx_coal - coalesce value in micro second for rx queue 92 * @param tx_coal - coalesce value in micro second for tx queue 93 * @param queue_cid 94 * 95 **/ 96 enum _ecore_status_t ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn, 97 u16 rx_coal, u16 tx_coal, 98 struct ecore_queue_cid *p_cid); 99 100 #ifdef CONFIG_ECORE_SRIOV 101 /** 102 * @brief hw preparation for VF 103 * sends ACQUIRE message 104 * 105 * @param p_hwfn 106 * 107 * @return enum _ecore_status_t 108 */ 109 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn); 110 111 /** 112 * @brief VF - start the RX Queue by sending a message to the PF 113 * 114 * @param p_hwfn 115 * @param p_cid - Only relative fields are relevant 116 * @param bd_max_bytes - maximum number of bytes per bd 117 * @param bd_chain_phys_addr - physical address of bd chain 118 * @param cqe_pbl_addr - physical address of pbl 119 * @param cqe_pbl_size - pbl size 120 * @param pp_prod - pointer to the producer to be 121 * used in fasthpath 122 * 123 * @return enum _ecore_status_t 124 */ 125 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn, 126 struct ecore_queue_cid *p_cid, 127 u16 bd_max_bytes, 128 dma_addr_t bd_chain_phys_addr, 129 dma_addr_t cqe_pbl_addr, 130 u16 cqe_pbl_size, 131 void OSAL_IOMEM **pp_prod); 132 133 /** 134 * @brief VF - start the TX queue by sending a message to the 135 * PF. 136 * 137 * @param p_hwfn 138 * @param p_cid 139 * @param bd_chain_phys_addr - physical address of tx chain 140 * @param pp_doorbell - pointer to address to which to 141 * write the doorbell too.. 142 * 143 * @return enum _ecore_status_t 144 */ 145 enum _ecore_status_t 146 ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn, 147 struct ecore_queue_cid *p_cid, 148 dma_addr_t pbl_addr, u16 pbl_size, 149 void OSAL_IOMEM **pp_doorbell); 150 151 /** 152 * @brief VF - stop the RX queue by sending a message to the PF 153 * 154 * @param p_hwfn 155 * @param p_cid 156 * @param cqe_completion 157 * 158 * @return enum _ecore_status_t 159 */ 160 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn, 161 struct ecore_queue_cid *p_cid, 162 bool cqe_completion); 163 164 /** 165 * @brief VF - stop the TX queue by sending a message to the PF 166 * 167 * @param p_hwfn 168 * @param p_cid 169 * 170 * @return enum _ecore_status_t 171 */ 172 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn, 173 struct ecore_queue_cid *p_cid); 174 175 /* TODO - fix all the !SRIOV prototypes */ 176 177 /** 178 * @brief VF - update the RX queue by sending a message to the 179 * PF 180 * 181 * @param p_hwfn 182 * @param pp_cid - list of queue-cids which we want to update 183 * @param num_rxqs 184 * @param comp_cqe_flg 185 * @param comp_event_flg 186 * 187 * @return enum _ecore_status_t 188 */ 189 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn, 190 struct ecore_queue_cid **pp_cid, 191 u8 num_rxqs, 192 u8 comp_cqe_flg, 193 u8 comp_event_flg); 194 195 /** 196 * @brief VF - send a vport update command 197 * 198 * @param p_hwfn 199 * @param params 200 * 201 * @return enum _ecore_status_t 202 */ 203 enum _ecore_status_t ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn, 204 struct ecore_sp_vport_update_params *p_params); 205 206 /** 207 * @brief VF - send a close message to PF 208 * 209 * @param p_hwfn 210 * 211 * @return enum _ecore_status 212 */ 213 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn); 214 215 /** 216 * @brief VF - free vf`s memories 217 * 218 * @param p_hwfn 219 * 220 * @return enum _ecore_status 221 */ 222 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn); 223 224 /** 225 * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given 226 * sb_id. For VFs igu sbs don't have to be contiguous 227 * 228 * @param p_hwfn 229 * @param sb_id 230 * 231 * @return INLINE u16 232 */ 233 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn, 234 u16 sb_id); 235 236 /** 237 * @brief Stores [or removes] a configured sb_info. 238 * 239 * @param p_hwfn 240 * @param sb_id - zero-based SB index [for fastpath] 241 * @param sb_info - may be OSAL_NULL [during removal]. 242 */ 243 void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn, 244 u16 sb_id, struct ecore_sb_info *p_sb); 245 246 /** 247 * @brief ecore_vf_pf_vport_start - perform vport start for VF. 248 * 249 * @param p_hwfn 250 * @param vport_id 251 * @param mtu 252 * @param inner_vlan_removal 253 * @param tpa_mode 254 * @param max_buffers_per_cqe, 255 * @param only_untagged - default behavior regarding vlan acceptance 256 * 257 * @return enum _ecore_status 258 */ 259 enum _ecore_status_t ecore_vf_pf_vport_start( 260 struct ecore_hwfn *p_hwfn, 261 u8 vport_id, 262 u16 mtu, 263 u8 inner_vlan_removal, 264 enum ecore_tpa_mode tpa_mode, 265 u8 max_buffers_per_cqe, 266 u8 only_untagged); 267 268 /** 269 * @brief ecore_vf_pf_vport_stop - stop the VF's vport 270 * 271 * @param p_hwfn 272 * 273 * @return enum _ecore_status 274 */ 275 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn); 276 277 enum _ecore_status_t ecore_vf_pf_filter_ucast( 278 struct ecore_hwfn *p_hwfn, 279 struct ecore_filter_ucast *p_param); 280 281 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn, 282 struct ecore_filter_mcast *p_filter_cmd); 283 284 /** 285 * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF 286 * 287 * @param p_hwfn 288 * 289 * @return enum _ecore_status 290 */ 291 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn); 292 293 /** 294 * @brief - return the link params in a given bulletin board 295 * 296 * @param p_hwfn 297 * @param p_params - pointer to a struct to fill with link params 298 * @param p_bulletin 299 */ 300 void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn, 301 struct ecore_mcp_link_params *p_params, 302 struct ecore_bulletin_content *p_bulletin); 303 304 /** 305 * @brief - return the link state in a given bulletin board 306 * 307 * @param p_hwfn 308 * @param p_link - pointer to a struct to fill with link state 309 * @param p_bulletin 310 */ 311 void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn, 312 struct ecore_mcp_link_state *p_link, 313 struct ecore_bulletin_content *p_bulletin); 314 315 /** 316 * @brief - return the link capabilities in a given bulletin board 317 * 318 * @param p_hwfn 319 * @param p_link - pointer to a struct to fill with link capabilities 320 * @param p_bulletin 321 */ 322 void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn, 323 struct ecore_mcp_link_capabilities *p_link_caps, 324 struct ecore_bulletin_content *p_bulletin); 325 enum _ecore_status_t 326 ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn, 327 struct ecore_tunnel_info *p_tunn); 328 void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun); 329 #else 330 static OSAL_INLINE enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn) {return ECORE_INVAL;} 331 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn, struct ecore_queue_cid *p_cid, u16 bd_max_bytes, dma_addr_t bd_chain_phys_addr, dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size, void OSAL_IOMEM **pp_prod) {return ECORE_INVAL;} 332 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn, struct ecore_queue_cid *p_cid, dma_addr_t pbl_addr, u16 pbl_size, void OSAL_IOMEM **pp_doorbell) {return ECORE_INVAL;} 333 334 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn, struct ecore_queue_cid *p_cid, bool cqe_completion) {return ECORE_INVAL;} 335 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn, struct ecore_queue_cid *p_cid) {return ECORE_INVAL;} 336 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn, struct ecore_queue_cid **pp_cid, u8 num_rxqs, u8 comp_cqe_flg, u8 comp_event_flg) {return ECORE_INVAL;} 337 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn, struct ecore_sp_vport_update_params *p_params) {return ECORE_INVAL;} 338 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn) {return ECORE_INVAL;} 339 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn) {return ECORE_INVAL;} 340 static OSAL_INLINE u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id) {return 0;} 341 static OSAL_INLINE void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn, u16 sb_id, struct ecore_sb_info *p_sb) {} 342 343 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_start(struct ecore_hwfn *p_hwfn, u8 vport_id, u16 mtu, u8 inner_vlan_removal, enum ecore_tpa_mode tpa_mode, u8 max_buffers_per_cqe, u8 only_untagged) {return ECORE_INVAL;} 344 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn) {return ECORE_INVAL;} 345 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_filter_ucast(struct ecore_hwfn *p_hwfn, struct ecore_filter_ucast *p_param) {return ECORE_INVAL;} 346 static OSAL_INLINE void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn, struct ecore_filter_mcast *p_filter_cmd) {} 347 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn) {return ECORE_INVAL;} 348 static OSAL_INLINE void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn, struct ecore_mcp_link_params *p_params, struct ecore_bulletin_content *p_bulletin) {} 349 static OSAL_INLINE void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn, struct ecore_mcp_link_state *p_link, struct ecore_bulletin_content *p_bulletin) {} 350 static OSAL_INLINE void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn, struct ecore_mcp_link_capabilities *p_link_caps, struct ecore_bulletin_content *p_bulletin) {} 351 static OSAL_INLINE enum _ecore_status_t ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn, struct ecore_tunnel_info *p_tunn) { return ECORE_INVAL; } 352 static OSAL_INLINE void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun) { return; } 353 #endif 354 355 #endif /* __ECORE_VF_H__ */ 356