13126df22SRasesh Mody /* SPDX-License-Identifier: BSD-3-Clause 29adde217SRasesh Mody * Copyright (c) 2016 - 2018 Cavium Inc. 386a2265eSRasesh Mody * All rights reserved. 49adde217SRasesh Mody * www.cavium.com 586a2265eSRasesh Mody */ 686a2265eSRasesh Mody 786a2265eSRasesh Mody #ifndef __ECORE_VF_H__ 886a2265eSRasesh Mody #define __ECORE_VF_H__ 986a2265eSRasesh Mody 1086a2265eSRasesh Mody #include "ecore_status.h" 1186a2265eSRasesh Mody #include "ecore_vf_api.h" 1286a2265eSRasesh Mody #include "ecore_l2_api.h" 1386a2265eSRasesh Mody #include "ecore_vfpf_if.h" 14*f44ca48cSManish Chopra #include "ecore_dev_api.h" 1586a2265eSRasesh Mody 16a90c566fSRasesh Mody /* Default number of CIDs [total of both Rx and Tx] to be requested 17a90c566fSRasesh Mody * by default. 18a90c566fSRasesh Mody */ 19a90c566fSRasesh Mody #define ECORE_ETH_VF_DEFAULT_NUM_CIDS (32) 20a90c566fSRasesh Mody 2122d07d93SRasesh Mody /* This data is held in the ecore_hwfn structure for VFs only. */ 2222d07d93SRasesh Mody struct ecore_vf_iov { 2322d07d93SRasesh Mody union vfpf_tlvs *vf2pf_request; 2422d07d93SRasesh Mody dma_addr_t vf2pf_request_phys; 2522d07d93SRasesh Mody union pfvf_tlvs *pf2vf_reply; 2622d07d93SRasesh Mody dma_addr_t pf2vf_reply_phys; 2722d07d93SRasesh Mody 2822d07d93SRasesh Mody /* Should be taken whenever the mailbox buffers are accessed */ 2922d07d93SRasesh Mody osal_mutex_t mutex; 3022d07d93SRasesh Mody u8 *offset; 3122d07d93SRasesh Mody 3222d07d93SRasesh Mody /* Bulletin Board */ 3322d07d93SRasesh Mody struct ecore_bulletin bulletin; 3422d07d93SRasesh Mody struct ecore_bulletin_content bulletin_shadow; 3522d07d93SRasesh Mody 3622d07d93SRasesh Mody /* we set aside a copy of the acquire response */ 3722d07d93SRasesh Mody struct pfvf_acquire_resp_tlv acquire_resp; 3822d07d93SRasesh Mody 3922d07d93SRasesh Mody /* In case PF originates prior to the fp-hsi version comparison, 4022d07d93SRasesh Mody * this has to be propagated as it affects the fastpath. 4122d07d93SRasesh Mody */ 4222d07d93SRasesh Mody bool b_pre_fp_hsi; 436e4fcea9SRasesh Mody 446e4fcea9SRasesh Mody /* Current day VFs are passing the SBs physical address on vport 456e4fcea9SRasesh Mody * start, and as they lack an IGU mapping they need to store the 466e4fcea9SRasesh Mody * addresses of previously registered SBs. 476e4fcea9SRasesh Mody * Even if we were to change configuration flow, due to backward 486e4fcea9SRasesh Mody * compatibility [with older PFs] we'd still need to store these. 496e4fcea9SRasesh Mody */ 506e4fcea9SRasesh Mody struct ecore_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF]; 51c73d7da7SRasesh Mody 5201491d29SRasesh Mody #ifdef CONFIG_ECORE_SW_CHANNEL 5301491d29SRasesh Mody /* Would be set if the VF is to try communicating with it PF 5401491d29SRasesh Mody * using a hw channel. 5501491d29SRasesh Mody */ 5601491d29SRasesh Mody bool b_hw_channel; 5701491d29SRasesh Mody #endif 5801491d29SRasesh Mody 59c73d7da7SRasesh Mody /* Determines whether VF utilizes doorbells via limited register 60c73d7da7SRasesh Mody * bar or via the doorbell bar. 61c73d7da7SRasesh Mody */ 62c73d7da7SRasesh Mody bool b_doorbell_bar; 63*f44ca48cSManish Chopra 64*f44ca48cSManish Chopra /* retry count for VF acquire on channel timeout */ 65*f44ca48cSManish Chopra u8 acquire_retry_cnt; 6622d07d93SRasesh Mody }; 6722d07d93SRasesh Mody 68823a84aaSRasesh Mody /** 69823a84aaSRasesh Mody * @brief VF - Get coalesce per VF's relative queue. 70823a84aaSRasesh Mody * 71823a84aaSRasesh Mody * @param p_hwfn 72823a84aaSRasesh Mody * @param p_coal - coalesce value in micro second for VF queues. 73823a84aaSRasesh Mody * @param p_cid - queue cid 74823a84aaSRasesh Mody * 75823a84aaSRasesh Mody **/ 76823a84aaSRasesh Mody enum _ecore_status_t ecore_vf_pf_get_coalesce(struct ecore_hwfn *p_hwfn, 77823a84aaSRasesh Mody u16 *p_coal, 780863dbe3SRasesh Mody struct ecore_queue_cid *p_cid); 79*f44ca48cSManish Chopra 80*f44ca48cSManish Chopra enum _ecore_status_t ecore_vf_pf_acquire(struct ecore_hwfn *p_hwfn); 810863dbe3SRasesh Mody /** 820863dbe3SRasesh Mody * @brief VF - Set Rx/Tx coalesce per VF's relative queue. 830863dbe3SRasesh Mody * Coalesce value '0' will omit the configuration. 840863dbe3SRasesh Mody * 850863dbe3SRasesh Mody * @param p_hwfn 860863dbe3SRasesh Mody * @param rx_coal - coalesce value in micro second for rx queue 870863dbe3SRasesh Mody * @param tx_coal - coalesce value in micro second for tx queue 88823a84aaSRasesh Mody * @param p_cid - queue cid 890863dbe3SRasesh Mody * 900863dbe3SRasesh Mody **/ 910863dbe3SRasesh Mody enum _ecore_status_t ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn, 920863dbe3SRasesh Mody u16 rx_coal, u16 tx_coal, 930863dbe3SRasesh Mody struct ecore_queue_cid *p_cid); 940863dbe3SRasesh Mody 9586a2265eSRasesh Mody #ifdef CONFIG_ECORE_SRIOV 9686a2265eSRasesh Mody /** 9786a2265eSRasesh Mody * @brief hw preparation for VF 9886a2265eSRasesh Mody * sends ACQUIRE message 9986a2265eSRasesh Mody * 10086a2265eSRasesh Mody * @param p_hwfn 101*f44ca48cSManish Chopra * @param p_params 10286a2265eSRasesh Mody * 10386a2265eSRasesh Mody * @return enum _ecore_status_t 10486a2265eSRasesh Mody */ 105*f44ca48cSManish Chopra enum _ecore_status_t 106*f44ca48cSManish Chopra ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn, 107*f44ca48cSManish Chopra struct ecore_hw_prepare_params *p_params); 10886a2265eSRasesh Mody 10986a2265eSRasesh Mody /** 11086a2265eSRasesh Mody * @brief VF - start the RX Queue by sending a message to the PF 11186a2265eSRasesh Mody * 11286a2265eSRasesh Mody * @param p_hwfn 113a55e422eSRasesh Mody * @param p_cid - Only relative fields are relevant 11486a2265eSRasesh Mody * @param bd_max_bytes - maximum number of bytes per bd 11586a2265eSRasesh Mody * @param bd_chain_phys_addr - physical address of bd chain 11686a2265eSRasesh Mody * @param cqe_pbl_addr - physical address of pbl 11786a2265eSRasesh Mody * @param cqe_pbl_size - pbl size 11886a2265eSRasesh Mody * @param pp_prod - pointer to the producer to be 11922d07d93SRasesh Mody * used in fasthpath 12086a2265eSRasesh Mody * 12186a2265eSRasesh Mody * @return enum _ecore_status_t 12286a2265eSRasesh Mody */ 12386a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn, 124a55e422eSRasesh Mody struct ecore_queue_cid *p_cid, 12586a2265eSRasesh Mody u16 bd_max_bytes, 12686a2265eSRasesh Mody dma_addr_t bd_chain_phys_addr, 12786a2265eSRasesh Mody dma_addr_t cqe_pbl_addr, 12886a2265eSRasesh Mody u16 cqe_pbl_size, 12986a2265eSRasesh Mody void OSAL_IOMEM **pp_prod); 13086a2265eSRasesh Mody 13186a2265eSRasesh Mody /** 13286a2265eSRasesh Mody * @brief VF - start the TX queue by sending a message to the 13386a2265eSRasesh Mody * PF. 13486a2265eSRasesh Mody * 13586a2265eSRasesh Mody * @param p_hwfn 136a55e422eSRasesh Mody * @param p_cid 13786a2265eSRasesh Mody * @param bd_chain_phys_addr - physical address of tx chain 13886a2265eSRasesh Mody * @param pp_doorbell - pointer to address to which to 13986a2265eSRasesh Mody * write the doorbell too.. 14086a2265eSRasesh Mody * 14186a2265eSRasesh Mody * @return enum _ecore_status_t 14286a2265eSRasesh Mody */ 143a55e422eSRasesh Mody enum _ecore_status_t 144a55e422eSRasesh Mody ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn, 145a55e422eSRasesh Mody struct ecore_queue_cid *p_cid, 146a55e422eSRasesh Mody dma_addr_t pbl_addr, u16 pbl_size, 14786a2265eSRasesh Mody void OSAL_IOMEM **pp_doorbell); 14886a2265eSRasesh Mody 14986a2265eSRasesh Mody /** 15086a2265eSRasesh Mody * @brief VF - stop the RX queue by sending a message to the PF 15186a2265eSRasesh Mody * 15286a2265eSRasesh Mody * @param p_hwfn 153a55e422eSRasesh Mody * @param p_cid 15486a2265eSRasesh Mody * @param cqe_completion 15586a2265eSRasesh Mody * 15686a2265eSRasesh Mody * @return enum _ecore_status_t 15786a2265eSRasesh Mody */ 15886a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn, 159a55e422eSRasesh Mody struct ecore_queue_cid *p_cid, 16022d07d93SRasesh Mody bool cqe_completion); 16186a2265eSRasesh Mody 16286a2265eSRasesh Mody /** 16386a2265eSRasesh Mody * @brief VF - stop the TX queue by sending a message to the PF 16486a2265eSRasesh Mody * 16586a2265eSRasesh Mody * @param p_hwfn 166a55e422eSRasesh Mody * @param p_cid 16786a2265eSRasesh Mody * 16886a2265eSRasesh Mody * @return enum _ecore_status_t 16986a2265eSRasesh Mody */ 17086a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn, 171a55e422eSRasesh Mody struct ecore_queue_cid *p_cid); 172a55e422eSRasesh Mody 173a55e422eSRasesh Mody /* TODO - fix all the !SRIOV prototypes */ 17486a2265eSRasesh Mody 17522d07d93SRasesh Mody #ifndef LINUX_REMOVE 17686a2265eSRasesh Mody /** 17786a2265eSRasesh Mody * @brief VF - update the RX queue by sending a message to the 17886a2265eSRasesh Mody * PF 17986a2265eSRasesh Mody * 18086a2265eSRasesh Mody * @param p_hwfn 181a55e422eSRasesh Mody * @param pp_cid - list of queue-cids which we want to update 18286a2265eSRasesh Mody * @param num_rxqs 18386a2265eSRasesh Mody * @param comp_cqe_flg 18486a2265eSRasesh Mody * @param comp_event_flg 18586a2265eSRasesh Mody * 18686a2265eSRasesh Mody * @return enum _ecore_status_t 18786a2265eSRasesh Mody */ 188a55e422eSRasesh Mody enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn, 189a55e422eSRasesh Mody struct ecore_queue_cid **pp_cid, 19086a2265eSRasesh Mody u8 num_rxqs, 19186a2265eSRasesh Mody u8 comp_cqe_flg, 19286a2265eSRasesh Mody u8 comp_event_flg); 19322d07d93SRasesh Mody #endif 19486a2265eSRasesh Mody 19586a2265eSRasesh Mody /** 19686a2265eSRasesh Mody * @brief VF - send a vport update command 19786a2265eSRasesh Mody * 19886a2265eSRasesh Mody * @param p_hwfn 19986a2265eSRasesh Mody * @param params 20086a2265eSRasesh Mody * 20186a2265eSRasesh Mody * @return enum _ecore_status_t 20286a2265eSRasesh Mody */ 20386a2265eSRasesh Mody enum _ecore_status_t 20486a2265eSRasesh Mody ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn, 20586a2265eSRasesh Mody struct ecore_sp_vport_update_params *p_params); 20686a2265eSRasesh Mody 20786a2265eSRasesh Mody /** 20886a2265eSRasesh Mody * @brief VF - send a close message to PF 20986a2265eSRasesh Mody * 21086a2265eSRasesh Mody * @param p_hwfn 21186a2265eSRasesh Mody * 21286a2265eSRasesh Mody * @return enum _ecore_status 21386a2265eSRasesh Mody */ 21486a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn); 21586a2265eSRasesh Mody 21686a2265eSRasesh Mody /** 21786a2265eSRasesh Mody * @brief VF - free vf`s memories 21886a2265eSRasesh Mody * 21986a2265eSRasesh Mody * @param p_hwfn 22086a2265eSRasesh Mody * 22186a2265eSRasesh Mody * @return enum _ecore_status 22286a2265eSRasesh Mody */ 22386a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn); 22486a2265eSRasesh Mody 22586a2265eSRasesh Mody /** 22686a2265eSRasesh Mody * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given 22786a2265eSRasesh Mody * sb_id. For VFs igu sbs don't have to be contiguous 22886a2265eSRasesh Mody * 22986a2265eSRasesh Mody * @param p_hwfn 23086a2265eSRasesh Mody * @param sb_id 23186a2265eSRasesh Mody * 23286a2265eSRasesh Mody * @return INLINE u16 23386a2265eSRasesh Mody */ 23422d07d93SRasesh Mody u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn, 23522d07d93SRasesh Mody u16 sb_id); 23622d07d93SRasesh Mody 2376e4fcea9SRasesh Mody /** 2386e4fcea9SRasesh Mody * @brief Stores [or removes] a configured sb_info. 2396e4fcea9SRasesh Mody * 2406e4fcea9SRasesh Mody * @param p_hwfn 2416e4fcea9SRasesh Mody * @param sb_id - zero-based SB index [for fastpath] 2426e4fcea9SRasesh Mody * @param sb_info - may be OSAL_NULL [during removal]. 2436e4fcea9SRasesh Mody */ 2446e4fcea9SRasesh Mody void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn, 2456e4fcea9SRasesh Mody u16 sb_id, struct ecore_sb_info *p_sb); 24686a2265eSRasesh Mody 24786a2265eSRasesh Mody /** 24886a2265eSRasesh Mody * @brief ecore_vf_pf_vport_start - perform vport start for VF. 24986a2265eSRasesh Mody * 25086a2265eSRasesh Mody * @param p_hwfn 25186a2265eSRasesh Mody * @param vport_id 25286a2265eSRasesh Mody * @param mtu 25386a2265eSRasesh Mody * @param inner_vlan_removal 25486a2265eSRasesh Mody * @param tpa_mode 25586a2265eSRasesh Mody * @param max_buffers_per_cqe, 25686a2265eSRasesh Mody * @param only_untagged - default behavior regarding vlan acceptance 25786a2265eSRasesh Mody * 25886a2265eSRasesh Mody * @return enum _ecore_status 25986a2265eSRasesh Mody */ 26022d07d93SRasesh Mody enum _ecore_status_t ecore_vf_pf_vport_start( 26122d07d93SRasesh Mody struct ecore_hwfn *p_hwfn, 26286a2265eSRasesh Mody u8 vport_id, 26386a2265eSRasesh Mody u16 mtu, 26486a2265eSRasesh Mody u8 inner_vlan_removal, 26586a2265eSRasesh Mody enum ecore_tpa_mode tpa_mode, 26686a2265eSRasesh Mody u8 max_buffers_per_cqe, 26786a2265eSRasesh Mody u8 only_untagged); 26886a2265eSRasesh Mody 26986a2265eSRasesh Mody /** 27086a2265eSRasesh Mody * @brief ecore_vf_pf_vport_stop - stop the VF's vport 27186a2265eSRasesh Mody * 27286a2265eSRasesh Mody * @param p_hwfn 27386a2265eSRasesh Mody * 27486a2265eSRasesh Mody * @return enum _ecore_status 27586a2265eSRasesh Mody */ 27686a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn); 27786a2265eSRasesh Mody 27822d07d93SRasesh Mody enum _ecore_status_t ecore_vf_pf_filter_ucast( 27922d07d93SRasesh Mody struct ecore_hwfn *p_hwfn, 28022d07d93SRasesh Mody struct ecore_filter_ucast *p_param); 28186a2265eSRasesh Mody 28286a2265eSRasesh Mody void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn, 28386a2265eSRasesh Mody struct ecore_filter_mcast *p_filter_cmd); 28486a2265eSRasesh Mody 28586a2265eSRasesh Mody /** 28686a2265eSRasesh Mody * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF 28786a2265eSRasesh Mody * 28886a2265eSRasesh Mody * @param p_hwfn 28986a2265eSRasesh Mody * 29086a2265eSRasesh Mody * @return enum _ecore_status 29186a2265eSRasesh Mody */ 29286a2265eSRasesh Mody enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn); 29386a2265eSRasesh Mody 29486a2265eSRasesh Mody /** 29586a2265eSRasesh Mody * @brief - return the link params in a given bulletin board 29686a2265eSRasesh Mody * 29786a2265eSRasesh Mody * @param p_params - pointer to a struct to fill with link params 29886a2265eSRasesh Mody * @param p_bulletin 29986a2265eSRasesh Mody */ 30030ecf673SRasesh Mody void __ecore_vf_get_link_params(struct ecore_mcp_link_params *p_params, 30186a2265eSRasesh Mody struct ecore_bulletin_content *p_bulletin); 30286a2265eSRasesh Mody 30386a2265eSRasesh Mody /** 30486a2265eSRasesh Mody * @brief - return the link state in a given bulletin board 30586a2265eSRasesh Mody * 30686a2265eSRasesh Mody * @param p_link - pointer to a struct to fill with link state 30786a2265eSRasesh Mody * @param p_bulletin 30886a2265eSRasesh Mody */ 30930ecf673SRasesh Mody void __ecore_vf_get_link_state(struct ecore_mcp_link_state *p_link, 31086a2265eSRasesh Mody struct ecore_bulletin_content *p_bulletin); 31186a2265eSRasesh Mody 31286a2265eSRasesh Mody /** 31386a2265eSRasesh Mody * @brief - return the link capabilities in a given bulletin board 31486a2265eSRasesh Mody * 31586a2265eSRasesh Mody * @param p_link - pointer to a struct to fill with link capabilities 31686a2265eSRasesh Mody * @param p_bulletin 31786a2265eSRasesh Mody */ 31830ecf673SRasesh Mody void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities *p_link_caps, 31986a2265eSRasesh Mody struct ecore_bulletin_content *p_bulletin); 32086a2265eSRasesh Mody 3210b090fd3SRasesh Mody enum _ecore_status_t 3220b090fd3SRasesh Mody ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn, 3230b090fd3SRasesh Mody struct ecore_tunnel_info *p_tunn); 3240b090fd3SRasesh Mody 3250b090fd3SRasesh Mody void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun); 326c73d7da7SRasesh Mody 327c73d7da7SRasesh Mody u32 ecore_vf_hw_bar_size(struct ecore_hwfn *p_hwfn, 328c73d7da7SRasesh Mody enum BAR_ID bar_id); 329d121a6b5SRasesh Mody 330d121a6b5SRasesh Mody /** 331d121a6b5SRasesh Mody * @brief - ecore_vf_pf_update_mtu Update MTU for VF. 332d121a6b5SRasesh Mody * 333d121a6b5SRasesh Mody * @param p_hwfn 334d121a6b5SRasesh Mody * @param - mtu 335d121a6b5SRasesh Mody */ 336d121a6b5SRasesh Mody enum _ecore_status_t 337d121a6b5SRasesh Mody ecore_vf_pf_update_mtu(struct ecore_hwfn *p_hwfn, u16 mtu); 33886a2265eSRasesh Mody #endif 33986a2265eSRasesh Mody #endif /* __ECORE_VF_H__ */ 340