Imported Upstream version 16.11
[deb_dpdk.git] / drivers / net / qede / base / ecore_vf.h
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 /* This data is held in the ecore_hwfn structure for VFs only. */
18 struct ecore_vf_iov {
19         union vfpf_tlvs                 *vf2pf_request;
20         dma_addr_t                      vf2pf_request_phys;
21         union pfvf_tlvs                 *pf2vf_reply;
22         dma_addr_t                      pf2vf_reply_phys;
23
24         /* Should be taken whenever the mailbox buffers are accessed */
25         osal_mutex_t                    mutex;
26         u8                              *offset;
27
28         /* Bulletin Board */
29         struct ecore_bulletin           bulletin;
30         struct ecore_bulletin_content   bulletin_shadow;
31
32         /* we set aside a copy of the acquire response */
33         struct pfvf_acquire_resp_tlv    acquire_resp;
34
35         /* In case PF originates prior to the fp-hsi version comparison,
36          * this has to be propagated as it affects the fastpath.
37          */
38         bool b_pre_fp_hsi;
39 };
40
41 #ifdef CONFIG_ECORE_SRIOV
42 /**
43  * @brief hw preparation for VF
44  * sends ACQUIRE message
45  *
46  * @param p_hwfn
47  *
48  * @return enum _ecore_status_t
49  */
50 enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_hwfn *p_hwfn);
51
52 /**
53  * @brief VF - start the RX Queue by sending a message to the PF
54  *
55  * @param p_hwfn
56  * @param cid                   - zero based within the VF
57  * @param rx_queue_id           - zero based within the VF
58  * @param sb                    - VF status block for this queue
59  * @param sb_index              - Index within the status block
60  * @param bd_max_bytes          - maximum number of bytes per bd
61  * @param bd_chain_phys_addr    - physical address of bd chain
62  * @param cqe_pbl_addr          - physical address of pbl
63  * @param cqe_pbl_size          - pbl size
64  * @param pp_prod               - pointer to the producer to be
65  *                                used in fasthpath
66  *
67  * @return enum _ecore_status_t
68  */
69 enum _ecore_status_t ecore_vf_pf_rxq_start(struct ecore_hwfn *p_hwfn,
70                                            u8 rx_queue_id,
71                                            u16 sb,
72                                            u8 sb_index,
73                                            u16 bd_max_bytes,
74                                            dma_addr_t bd_chain_phys_addr,
75                                            dma_addr_t cqe_pbl_addr,
76                                            u16 cqe_pbl_size,
77                                            void OSAL_IOMEM **pp_prod);
78
79 /**
80  * @brief VF - start the TX queue by sending a message to the
81  *        PF.
82  *
83  * @param p_hwfn
84  * @param tx_queue_id           - zero based within the VF
85  * @param sb                    - status block for this queue
86  * @param sb_index              - index within the status block
87  * @param bd_chain_phys_addr    - physical address of tx chain
88  * @param pp_doorbell           - pointer to address to which to
89  *                              write the doorbell too..
90  *
91  * @return enum _ecore_status_t
92  */
93 enum _ecore_status_t ecore_vf_pf_txq_start(struct ecore_hwfn *p_hwfn,
94                                            u16 tx_queue_id,
95                                            u16 sb,
96                                            u8 sb_index,
97                                            dma_addr_t pbl_addr,
98                                            u16 pbl_size,
99                                            void OSAL_IOMEM **pp_doorbell);
100
101 /**
102  * @brief VF - stop the RX queue by sending a message to the PF
103  *
104  * @param p_hwfn
105  * @param rx_qid
106  * @param cqe_completion
107  *
108  * @return enum _ecore_status_t
109  */
110 enum _ecore_status_t ecore_vf_pf_rxq_stop(struct ecore_hwfn     *p_hwfn,
111                                           u16                   rx_qid,
112                                           bool                  cqe_completion);
113
114 /**
115  * @brief VF - stop the TX queue by sending a message to the PF
116  *
117  * @param p_hwfn
118  * @param tx_qid
119  *
120  * @return enum _ecore_status_t
121  */
122 enum _ecore_status_t ecore_vf_pf_txq_stop(struct ecore_hwfn     *p_hwfn,
123                                           u16                   tx_qid);
124
125 #ifndef LINUX_REMOVE
126 /**
127  * @brief VF - update the RX queue by sending a message to the
128  *        PF
129  *
130  * @param p_hwfn
131  * @param rx_queue_id
132  * @param num_rxqs
133  * @param init_sge_ring
134  * @param comp_cqe_flg
135  * @param comp_event_flg
136  *
137  * @return enum _ecore_status_t
138  */
139 enum _ecore_status_t ecore_vf_pf_rxqs_update(
140                         struct ecore_hwfn       *p_hwfn,
141                         u16                     rx_queue_id,
142                         u8                      num_rxqs,
143                         u8                      comp_cqe_flg,
144                         u8                      comp_event_flg);
145 #endif
146
147 /**
148  * @brief VF - send a vport update command
149  *
150  * @param p_hwfn
151  * @param params
152  *
153  * @return enum _ecore_status_t
154  */
155 enum _ecore_status_t
156 ecore_vf_pf_vport_update(struct ecore_hwfn *p_hwfn,
157                          struct ecore_sp_vport_update_params *p_params);
158
159 /**
160  * @brief VF - send a close message to PF
161  *
162  * @param p_hwfn
163  *
164  * @return enum _ecore_status
165  */
166 enum _ecore_status_t ecore_vf_pf_reset(struct ecore_hwfn *p_hwfn);
167
168 /**
169  * @brief VF - free vf`s memories
170  *
171  * @param p_hwfn
172  *
173  * @return enum _ecore_status
174  */
175 enum _ecore_status_t ecore_vf_pf_release(struct ecore_hwfn *p_hwfn);
176
177 /**
178  * @brief ecore_vf_get_igu_sb_id - Get the IGU SB ID for a given
179  *        sb_id. For VFs igu sbs don't have to be contiguous
180  *
181  * @param p_hwfn
182  * @param sb_id
183  *
184  * @return INLINE u16
185  */
186 u16 ecore_vf_get_igu_sb_id(struct ecore_hwfn *p_hwfn,
187                            u16               sb_id);
188
189
190 /**
191  * @brief ecore_vf_pf_vport_start - perform vport start for VF.
192  *
193  * @param p_hwfn
194  * @param vport_id
195  * @param mtu
196  * @param inner_vlan_removal
197  * @param tpa_mode
198  * @param max_buffers_per_cqe,
199  * @param only_untagged - default behavior regarding vlan acceptance
200  *
201  * @return enum _ecore_status
202  */
203 enum _ecore_status_t ecore_vf_pf_vport_start(
204                         struct ecore_hwfn *p_hwfn,
205                         u8 vport_id,
206                         u16 mtu,
207                         u8 inner_vlan_removal,
208                         enum ecore_tpa_mode tpa_mode,
209                         u8 max_buffers_per_cqe,
210                         u8 only_untagged);
211
212 /**
213  * @brief ecore_vf_pf_vport_stop - stop the VF's vport
214  *
215  * @param p_hwfn
216  *
217  * @return enum _ecore_status
218  */
219 enum _ecore_status_t ecore_vf_pf_vport_stop(struct ecore_hwfn *p_hwfn);
220
221 enum _ecore_status_t ecore_vf_pf_filter_ucast(
222                         struct ecore_hwfn *p_hwfn,
223                         struct ecore_filter_ucast *p_param);
224
225 void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn,
226                               struct ecore_filter_mcast *p_filter_cmd);
227
228 /**
229  * @brief ecore_vf_pf_int_cleanup - clean the SB of the VF
230  *
231  * @param p_hwfn
232  *
233  * @return enum _ecore_status
234  */
235 enum _ecore_status_t ecore_vf_pf_int_cleanup(struct ecore_hwfn *p_hwfn);
236
237 /**
238  * @brief - return the link params in a given bulletin board
239  *
240  * @param p_hwfn
241  * @param p_params - pointer to a struct to fill with link params
242  * @param p_bulletin
243  */
244 void __ecore_vf_get_link_params(struct ecore_hwfn *p_hwfn,
245                                 struct ecore_mcp_link_params *p_params,
246                                 struct ecore_bulletin_content *p_bulletin);
247
248 /**
249  * @brief - return the link state in a given bulletin board
250  *
251  * @param p_hwfn
252  * @param p_link - pointer to a struct to fill with link state
253  * @param p_bulletin
254  */
255 void __ecore_vf_get_link_state(struct ecore_hwfn *p_hwfn,
256                                struct ecore_mcp_link_state *p_link,
257                                struct ecore_bulletin_content *p_bulletin);
258
259 /**
260  * @brief - return the link capabilities in a given bulletin board
261  *
262  * @param p_hwfn
263  * @param p_link - pointer to a struct to fill with link capabilities
264  * @param p_bulletin
265  */
266 void __ecore_vf_get_link_caps(struct ecore_hwfn *p_hwfn,
267                               struct ecore_mcp_link_capabilities *p_link_caps,
268                               struct ecore_bulletin_content *p_bulletin);
269
270 #endif
271 #endif /* __ECORE_VF_H__ */