1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2016 - 2018 Cavium Inc.
10 #include "ecore_status.h"
11 #include "ecore_vf_api.h"
12 #include "ecore_l2_api.h"
13 #include "ecore_vfpf_if.h"
15 /* Default number of CIDs [total of both Rx and Tx] to be requested
18 #define ECORE_ETH_VF_DEFAULT_NUM_CIDS (32)
20 /* This data is held in the ecore_hwfn structure for VFs only. */
22 union vfpf_tlvs *vf2pf_request;
23 dma_addr_t vf2pf_request_phys;
24 union pfvf_tlvs *pf2vf_reply;
25 dma_addr_t pf2vf_reply_phys;
27 /* Should be taken whenever the mailbox buffers are accessed */
32 struct ecore_bulletin bulletin;
33 struct ecore_bulletin_content bulletin_shadow;
35 /* we set aside a copy of the acquire response */
36 struct pfvf_acquire_resp_tlv acquire_resp;
38 /* In case PF originates prior to the fp-hsi version comparison,
39 * this has to be propagated as it affects the fastpath.
43 /* Current day VFs are passing the SBs physical address on vport
44 * start, and as they lack an IGU mapping they need to store the
45 * addresses of previously registered SBs.
46 * Even if we were to change configuration flow, due to backward
47 * compatibility [with older PFs] we'd still need to store these.
49 struct ecore_sb_info *sbs_info[PFVF_MAX_SBS_PER_VF];
51 #ifdef CONFIG_ECORE_SW_CHANNEL
52 /* Would be set if the VF is to try communicating with it PF
58 /* Determines whether VF utilizes doorbells via limited register
59 * bar or via the doorbell bar.
65 * @brief VF - Get coalesce per VF's relative queue.
68 * @param p_coal - coalesce value in micro second for VF queues.
69 * @param p_cid - queue cid
72 enum _ecore_status_t ecore_vf_pf_get_coalesce(struct ecore_hwfn *p_hwfn,
74 struct ecore_queue_cid *p_cid);
76 * @brief VF - Set Rx/Tx coalesce per VF's relative queue.
77 * Coalesce value '0' will omit the configuration.
80 * @param rx_coal - coalesce value in micro second for rx queue
81 * @param tx_coal - coalesce value in micro second for tx queue
82 * @param p_cid - queue cid
85 enum _ecore_status_t ecore_vf_pf_set_coalesce(struct ecore_hwfn *p_hwfn,
86 u16 rx_coal, u16 tx_coal,
87 struct ecore_queue_cid *p_cid);
89 #ifdef CONFIG_ECORE_SRIOV
91 * @brief hw preparation for VF
92 * sends ACQUIRE message
96 * @return enum _ecore_status_t
98 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn);
101 * @brief VF - start the RX Queue by sending a message to the PF
104 * @param p_cid - Only relative fields are relevant
105 * @param bd_max_bytes - maximum number of bytes per bd
106 * @param bd_chain_phys_addr - physical address of bd chain
107 * @param cqe_pbl_addr - physical address of pbl
108 * @param cqe_pbl_size - pbl size
109 * @param pp_prod - pointer to the producer to be
112 * @return enum _ecore_status_t
114 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
115 struct ecore_queue_cid *p_cid,
117 dma_addr_t bd_chain_phys_addr,
118 dma_addr_t cqe_pbl_addr,
120 void OSAL_IOMEM **pp_prod);
123 * @brief VF - start the TX queue by sending a message to the
128 * @param bd_chain_phys_addr - physical address of tx chain
129 * @param pp_doorbell - pointer to address to which to
130 * write the doorbell too..
132 * @return enum _ecore_status_t
135 ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
136 struct ecore_queue_cid *p_cid,
137 dma_addr_t pbl_addr, u16 pbl_size,
138 void OSAL_IOMEM **pp_doorbell);
141 * @brief VF - stop the RX queue by sending a message to the PF
145 * @param cqe_completion
147 * @return enum _ecore_status_t
149 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn *p_hwfn,
150 struct ecore_queue_cid *p_cid,
151 bool cqe_completion);
154 * @brief VF - stop the TX queue by sending a message to the PF
159 * @return enum _ecore_status_t
161 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn *p_hwfn,
162 struct ecore_queue_cid *p_cid);
164 /* TODO - fix all the !SRIOV prototypes */
168 * @brief VF - update the RX queue by sending a message to the
172 * @param pp_cid - list of queue-cids which we want to update
174 * @param comp_cqe_flg
175 * @param comp_event_flg
177 * @return enum _ecore_status_t
179 enum _ecore_status_t ecore_vf_pf_rxqs_update(struct ecore_hwfn *p_hwfn,
180 struct ecore_queue_cid **pp_cid,
187 * @brief VF - send a vport update command
192 * @return enum _ecore_status_t
195 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
196 struct ecore_sp_vport_update_params *p_params);
199 * @brief VF - send a close message to PF
203 * @return enum _ecore_status
205 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn);
208 * @brief VF - free vf`s memories
212 * @return enum _ecore_status
214 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn);
217 * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
218 * sb_id. For VFs igu sbs don't have to be contiguous
225 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
229 * @brief Stores [or removes] a configured sb_info.
232 * @param sb_id - zero-based SB index [for fastpath]
233 * @param sb_info - may be OSAL_NULL [during removal].
235 void ecore_vf_set_sb_info(struct ecore_hwfn *p_hwfn,
236 u16 sb_id, struct ecore_sb_info *p_sb);
239 * @brief ecore_vf_pf_vport_start - perform vport start for VF.
244 * @param inner_vlan_removal
246 * @param max_buffers_per_cqe,
247 * @param only_untagged - default behavior regarding vlan acceptance
249 * @return enum _ecore_status
251 enum _ecore_status_t ecore_vf_pf_vport_start(
252 struct ecore_hwfn *p_hwfn,
255 u8 inner_vlan_removal,
256 enum ecore_tpa_mode tpa_mode,
257 u8 max_buffers_per_cqe,
261 * @brief ecore_vf_pf_vport_stop - stop the VF's vport
265 * @return enum _ecore_status
267 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn);
269 enum _ecore_status_t ecore_vf_pf_filter_ucast(
270 struct ecore_hwfn *p_hwfn,
271 struct ecore_filter_ucast *p_param);
273 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
274 struct ecore_filter_mcast *p_filter_cmd);
277 * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
281 * @return enum _ecore_status
283 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn);
286 * @brief - return the link params in a given bulletin board
288 * @param p_params - pointer to a struct to fill with link params
291 void __ecore_vf_get_link_params(struct ecore_mcp_link_params *p_params,
292 struct ecore_bulletin_content *p_bulletin);
295 * @brief - return the link state in a given bulletin board
297 * @param p_link - pointer to a struct to fill with link state
300 void __ecore_vf_get_link_state(struct ecore_mcp_link_state *p_link,
301 struct ecore_bulletin_content *p_bulletin);
304 * @brief - return the link capabilities in a given bulletin board
306 * @param p_link - pointer to a struct to fill with link capabilities
309 void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities *p_link_caps,
310 struct ecore_bulletin_content *p_bulletin);
313 ecore_vf_pf_tunnel_param_update(struct ecore_hwfn *p_hwfn,
314 struct ecore_tunnel_info *p_tunn);
316 void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info *p_tun);
318 u32 ecore_vf_hw_bar_size(struct ecore_hwfn *p_hwfn,
322 * @brief - ecore_vf_pf_update_mtu Update MTU for VF.
328 ecore_vf_pf_update_mtu(struct ecore_hwfn *p_hwfn, u16 mtu);
330 #endif /* __ECORE_VF_H__ */