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"
14 #include "ecore_dev_api.h"
16 /* Default number of CIDs [total of both Rx and Tx] to be requested
19 #define ECORE_ETH_VF_DEFAULT_NUM_CIDS (32)
21 /* This data is held in the ecore_hwfn structure for VFs only. */
23 union vfpf_tlvs
*vf2pf_request
;
24 dma_addr_t vf2pf_request_phys
;
25 union pfvf_tlvs
*pf2vf_reply
;
26 dma_addr_t pf2vf_reply_phys
;
28 /* Should be taken whenever the mailbox buffers are accessed */
33 struct ecore_bulletin bulletin
;
34 struct ecore_bulletin_content bulletin_shadow
;
36 /* we set aside a copy of the acquire response */
37 struct pfvf_acquire_resp_tlv acquire_resp
;
39 /* In case PF originates prior to the fp-hsi version comparison,
40 * this has to be propagated as it affects the fastpath.
44 /* Current day VFs are passing the SBs physical address on vport
45 * start, and as they lack an IGU mapping they need to store the
46 * addresses of previously registered SBs.
47 * Even if we were to change configuration flow, due to backward
48 * compatibility [with older PFs] we'd still need to store these.
50 struct ecore_sb_info
*sbs_info
[PFVF_MAX_SBS_PER_VF
];
52 #ifdef CONFIG_ECORE_SW_CHANNEL
53 /* Would be set if the VF is to try communicating with it PF
59 /* Determines whether VF utilizes doorbells via limited register
60 * bar or via the doorbell bar.
64 /* retry count for VF acquire on channel timeout */
69 * @brief VF - Get coalesce per VF's relative queue.
72 * @param p_coal - coalesce value in micro second for VF queues.
73 * @param p_cid - queue cid
76 enum _ecore_status_t
ecore_vf_pf_get_coalesce(struct ecore_hwfn
*p_hwfn
,
78 struct ecore_queue_cid
*p_cid
);
80 enum _ecore_status_t
ecore_vf_pf_acquire(struct ecore_hwfn
*p_hwfn
);
82 * @brief VF - Set Rx/Tx coalesce per VF's relative queue.
83 * Coalesce value '0' will omit the configuration.
86 * @param rx_coal - coalesce value in micro second for rx queue
87 * @param tx_coal - coalesce value in micro second for tx queue
88 * @param p_cid - queue cid
91 enum _ecore_status_t
ecore_vf_pf_set_coalesce(struct ecore_hwfn
*p_hwfn
,
92 u16 rx_coal
, u16 tx_coal
,
93 struct ecore_queue_cid
*p_cid
);
95 #ifdef CONFIG_ECORE_SRIOV
97 * @brief hw preparation for VF
98 * sends ACQUIRE message
103 * @return enum _ecore_status_t
106 ecore_vf_hw_prepare(struct ecore_hwfn
*p_hwfn
,
107 struct ecore_hw_prepare_params
*p_params
);
110 * @brief VF - start the RX Queue by sending a message to the PF
113 * @param p_cid - Only relative fields are relevant
114 * @param bd_max_bytes - maximum number of bytes per bd
115 * @param bd_chain_phys_addr - physical address of bd chain
116 * @param cqe_pbl_addr - physical address of pbl
117 * @param cqe_pbl_size - pbl size
118 * @param pp_prod - pointer to the producer to be
121 * @return enum _ecore_status_t
123 enum _ecore_status_t
ecore_vf_pf_rxq_start(struct ecore_hwfn
*p_hwfn
,
124 struct ecore_queue_cid
*p_cid
,
126 dma_addr_t bd_chain_phys_addr
,
127 dma_addr_t cqe_pbl_addr
,
129 void OSAL_IOMEM
**pp_prod
);
132 * @brief VF - start the TX queue by sending a message to the
137 * @param bd_chain_phys_addr - physical address of tx chain
138 * @param pp_doorbell - pointer to address to which to
139 * write the doorbell too..
141 * @return enum _ecore_status_t
144 ecore_vf_pf_txq_start(struct ecore_hwfn
*p_hwfn
,
145 struct ecore_queue_cid
*p_cid
,
146 dma_addr_t pbl_addr
, u16 pbl_size
,
147 void OSAL_IOMEM
**pp_doorbell
);
150 * @brief VF - stop the RX queue by sending a message to the PF
154 * @param cqe_completion
156 * @return enum _ecore_status_t
158 enum _ecore_status_t
ecore_vf_pf_rxq_stop(struct ecore_hwfn
*p_hwfn
,
159 struct ecore_queue_cid
*p_cid
,
160 bool cqe_completion
);
163 * @brief VF - stop the TX queue by sending a message to the PF
168 * @return enum _ecore_status_t
170 enum _ecore_status_t
ecore_vf_pf_txq_stop(struct ecore_hwfn
*p_hwfn
,
171 struct ecore_queue_cid
*p_cid
);
173 /* TODO - fix all the !SRIOV prototypes */
177 * @brief VF - update the RX queue by sending a message to the
181 * @param pp_cid - list of queue-cids which we want to update
183 * @param comp_cqe_flg
184 * @param comp_event_flg
186 * @return enum _ecore_status_t
188 enum _ecore_status_t
ecore_vf_pf_rxqs_update(struct ecore_hwfn
*p_hwfn
,
189 struct ecore_queue_cid
**pp_cid
,
196 * @brief VF - send a vport update command
201 * @return enum _ecore_status_t
204 ecore_vf_pf_vport_update(struct ecore_hwfn
*p_hwfn
,
205 struct ecore_sp_vport_update_params
*p_params
);
208 * @brief VF - send a close message to PF
212 * @return enum _ecore_status
214 enum _ecore_status_t
ecore_vf_pf_reset(struct ecore_hwfn
*p_hwfn
);
217 * @brief VF - free vf`s memories
221 * @return enum _ecore_status
223 enum _ecore_status_t
ecore_vf_pf_release(struct ecore_hwfn
*p_hwfn
);
226 * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
227 * sb_id. For VFs igu sbs don't have to be contiguous
234 u16
ecore_vf_get_igu_sb_id(struct ecore_hwfn
*p_hwfn
,
238 * @brief Stores [or removes] a configured sb_info.
241 * @param sb_id - zero-based SB index [for fastpath]
242 * @param sb_info - may be OSAL_NULL [during removal].
244 void ecore_vf_set_sb_info(struct ecore_hwfn
*p_hwfn
,
245 u16 sb_id
, struct ecore_sb_info
*p_sb
);
248 * @brief ecore_vf_pf_vport_start - perform vport start for VF.
253 * @param inner_vlan_removal
255 * @param max_buffers_per_cqe,
256 * @param only_untagged - default behavior regarding vlan acceptance
258 * @return enum _ecore_status
260 enum _ecore_status_t
ecore_vf_pf_vport_start(
261 struct ecore_hwfn
*p_hwfn
,
264 u8 inner_vlan_removal
,
265 enum ecore_tpa_mode tpa_mode
,
266 u8 max_buffers_per_cqe
,
270 * @brief ecore_vf_pf_vport_stop - stop the VF's vport
274 * @return enum _ecore_status
276 enum _ecore_status_t
ecore_vf_pf_vport_stop(struct ecore_hwfn
*p_hwfn
);
278 enum _ecore_status_t
ecore_vf_pf_filter_ucast(
279 struct ecore_hwfn
*p_hwfn
,
280 struct ecore_filter_ucast
*p_param
);
282 void ecore_vf_pf_filter_mcast(struct ecore_hwfn
*p_hwfn
,
283 struct ecore_filter_mcast
*p_filter_cmd
);
286 * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
290 * @return enum _ecore_status
292 enum _ecore_status_t
ecore_vf_pf_int_cleanup(struct ecore_hwfn
*p_hwfn
);
295 * @brief - return the link params in a given bulletin board
297 * @param p_params - pointer to a struct to fill with link params
300 void __ecore_vf_get_link_params(struct ecore_mcp_link_params
*p_params
,
301 struct ecore_bulletin_content
*p_bulletin
);
304 * @brief - return the link state in a given bulletin board
306 * @param p_link - pointer to a struct to fill with link state
309 void __ecore_vf_get_link_state(struct ecore_mcp_link_state
*p_link
,
310 struct ecore_bulletin_content
*p_bulletin
);
313 * @brief - return the link capabilities in a given bulletin board
315 * @param p_link - pointer to a struct to fill with link capabilities
318 void __ecore_vf_get_link_caps(struct ecore_mcp_link_capabilities
*p_link_caps
,
319 struct ecore_bulletin_content
*p_bulletin
);
322 ecore_vf_pf_tunnel_param_update(struct ecore_hwfn
*p_hwfn
,
323 struct ecore_tunnel_info
*p_tunn
);
325 void ecore_vf_set_vf_start_tunn_update_param(struct ecore_tunnel_info
*p_tun
);
327 u32
ecore_vf_hw_bar_size(struct ecore_hwfn
*p_hwfn
,
331 * @brief - ecore_vf_pf_update_mtu Update MTU for VF.
337 ecore_vf_pf_update_mtu(struct ecore_hwfn
*p_hwfn
, u16 mtu
);
339 #endif /* __ECORE_VF_H__ */