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