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