]> git.proxmox.com Git - ceph.git/blame - ceph/src/dpdk/drivers/net/qede/base/ecore_spq.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / net / qede / base / ecore_spq.h
CommitLineData
7c673cae
FG
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_SPQ_H__
10#define __ECORE_SPQ_H__
11
12#include "ecore_hsi_common.h"
13#include "ecore_status.h"
14#include "ecore_hsi_eth.h"
15#include "ecore_chain.h"
16#include "ecore_sp_api.h"
17
18union ramrod_data {
19 struct pf_start_ramrod_data pf_start;
20 struct pf_update_ramrod_data pf_update;
21 struct rl_update_ramrod_data rl_update;
22 struct rx_queue_start_ramrod_data rx_queue_start;
23 struct rx_queue_update_ramrod_data rx_queue_update;
24 struct rx_queue_stop_ramrod_data rx_queue_stop;
25 struct tx_queue_start_ramrod_data tx_queue_start;
26 struct tx_queue_stop_ramrod_data tx_queue_stop;
27 struct vport_start_ramrod_data vport_start;
28 struct vport_stop_ramrod_data vport_stop;
29 struct vport_update_ramrod_data vport_update;
30 struct core_rx_start_ramrod_data core_rx_queue_start;
31 struct core_rx_stop_ramrod_data core_rx_queue_stop;
32 struct core_tx_start_ramrod_data core_tx_queue_start;
33 struct core_tx_stop_ramrod_data core_tx_queue_stop;
34 struct vport_filter_update_ramrod_data vport_filter_update;
35
36 struct vf_start_ramrod_data vf_start;
37 struct vf_stop_ramrod_data vf_stop;
38};
39
40#define EQ_MAX_CREDIT 0xffffffff
41
42enum spq_priority {
43 ECORE_SPQ_PRIORITY_NORMAL,
44 ECORE_SPQ_PRIORITY_HIGH,
45};
46
47union ecore_spq_req_comp {
48 struct ecore_spq_comp_cb cb;
49 u64 *done_addr;
50};
51
52/* SPQ_MODE_EBLOCK */
53struct ecore_spq_comp_done {
54 u64 done;
55 u8 fw_return_code;
56};
57
58struct ecore_spq_entry {
59 osal_list_entry_t list;
60
61 u8 flags;
62
63 /* HSI slow path element */
64 struct slow_path_element elem;
65
66 union ramrod_data ramrod;
67
68 enum spq_priority priority;
69
70 /* pending queue for this entry */
71 osal_list_t *queue;
72
73 enum spq_mode comp_mode;
74 struct ecore_spq_comp_cb comp_cb;
75 struct ecore_spq_comp_done comp_done; /* SPQ_MODE_EBLOCK */
76};
77
78struct ecore_eq {
79 struct ecore_chain chain;
80 u8 eq_sb_index; /* index within the SB */
81 __le16 *p_fw_cons; /* ptr to index value */
82};
83
84struct ecore_consq {
85 struct ecore_chain chain;
86};
87
88struct ecore_spq {
89 osal_spinlock_t lock;
90
91 osal_list_t unlimited_pending;
92 osal_list_t pending;
93 osal_list_t completion_pending;
94 osal_list_t free_pool;
95
96 struct ecore_chain chain;
97
98 /* allocated dma-able memory for spq entries (+ramrod data) */
99 dma_addr_t p_phys;
100 struct ecore_spq_entry *p_virt;
101
102 /* Bitmap for handling out-of-order completions */
103#define SPQ_RING_SIZE \
104 (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
105/* BITS_PER_LONG */
106#define SPQ_COMP_BMAP_SIZE (SPQ_RING_SIZE / (sizeof(unsigned long) * 8))
107 unsigned long p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
108 u8 comp_bitmap_idx;
109#define SPQ_COMP_BMAP_SET_BIT(p_spq, idx) \
110 (OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
111
112#define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx) \
113 (OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
114
115#define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx) \
116 (OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
117
118 /* Statistics */
119 u32 unlimited_pending_count;
120 u32 normal_count;
121 u32 high_count;
122 u32 comp_sent_count;
123 u32 comp_count;
124
125 u32 cid;
126};
127
128struct ecore_port;
129struct ecore_hwfn;
130
131/**
132 * @brief ecore_spq_post - Posts a Slow hwfn request to FW, or lacking that
133 * Pends it to the future list.
134 *
135 * @param p_hwfn
136 * @param p_req
137 *
138 * @return enum _ecore_status_t
139 */
140enum _ecore_status_t ecore_spq_post(struct ecore_hwfn *p_hwfn,
141 struct ecore_spq_entry *p_ent,
142 u8 *fw_return_code);
143
144/**
145 * @brief ecore_spq_allocate - Alloocates & initializes the SPQ and EQ.
146 *
147 * @param p_hwfn
148 *
149 * @return enum _ecore_status_t
150 */
151enum _ecore_status_t ecore_spq_alloc(struct ecore_hwfn *p_hwfn);
152
153/**
154 * @brief ecore_spq_setup - Reset the SPQ to its start state.
155 *
156 * @param p_hwfn
157 */
158void ecore_spq_setup(struct ecore_hwfn *p_hwfn);
159
160/**
161 * @brief ecore_spq_deallocate - Deallocates the given SPQ struct.
162 *
163 * @param p_hwfn
164 */
165void ecore_spq_free(struct ecore_hwfn *p_hwfn);
166
167/**
168 * @brief ecore_spq_get_entry - Obtain an entrry from the spq
169 * free pool list.
170 *
171 *
172 *
173 * @param p_hwfn
174 * @param pp_ent
175 *
176 * @return enum _ecore_status_t
177 */
178enum _ecore_status_t
179ecore_spq_get_entry(struct ecore_hwfn *p_hwfn,
180 struct ecore_spq_entry **pp_ent);
181
182/**
183 * @brief ecore_spq_return_entry - Return an entry to spq free
184 * pool list
185 *
186 * @param p_hwfn
187 * @param p_ent
188 */
189void ecore_spq_return_entry(struct ecore_hwfn *p_hwfn,
190 struct ecore_spq_entry *p_ent);
191/**
192 * @brief ecore_eq_allocate - Allocates & initializes an EQ struct
193 *
194 * @param p_hwfn
195 * @param num_elem number of elements in the eq
196 *
197 * @return struct ecore_eq* - a newly allocated structure; NULL upon error.
198 */
199struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn,
200 u16 num_elem);
201
202/**
203 * @brief ecore_eq_setup - Reset the SPQ to its start state.
204 *
205 * @param p_hwfn
206 * @param p_eq
207 */
208void ecore_eq_setup(struct ecore_hwfn *p_hwfn,
209 struct ecore_eq *p_eq);
210
211/**
212 * @brief ecore_eq_deallocate - deallocates the given EQ struct.
213 *
214 * @param p_hwfn
215 * @param p_eq
216 */
217void ecore_eq_free(struct ecore_hwfn *p_hwfn,
218 struct ecore_eq *p_eq);
219
220/**
221 * @brief ecore_eq_prod_update - update the FW with default EQ producer
222 *
223 * @param p_hwfn
224 * @param prod
225 */
226void ecore_eq_prod_update(struct ecore_hwfn *p_hwfn,
227 u16 prod);
228
229/**
230 * @brief ecore_eq_completion - Completes currently pending EQ elements
231 *
232 * @param p_hwfn
233 * @param cookie
234 *
235 * @return enum _ecore_status_t
236 */
237enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn,
238 void *cookie);
239
240/**
241 * @brief ecore_spq_completion - Completes a single event
242 *
243 * @param p_hwfn
244 * @param echo - echo value from cookie (used for determining completion)
245 * @param p_data - data from cookie (used in callback function if applicable)
246 *
247 * @return enum _ecore_status_t
248 */
249enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
250 __le16 echo,
251 u8 fw_return_code,
252 union event_ring_data *p_data);
253
254/**
255 * @brief ecore_spq_get_cid - Given p_hwfn, return cid for the hwfn's SPQ
256 *
257 * @param p_hwfn
258 *
259 * @return u32 - SPQ CID
260 */
261u32 ecore_spq_get_cid(struct ecore_hwfn *p_hwfn);
262
263/**
264 * @brief ecore_consq_alloc - Allocates & initializes an ConsQ
265 * struct
266 *
267 * @param p_hwfn
268 *
269 * @return struct ecore_eq* - a newly allocated structure; NULL upon error.
270 */
271struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn);
272
273/**
274 * @brief ecore_consq_setup - Reset the ConsQ to its start
275 * state.
276 *
277 * @param p_hwfn
278 * @param p_eq
279 */
280void ecore_consq_setup(struct ecore_hwfn *p_hwfn,
281 struct ecore_consq *p_consq);
282
283/**
284 * @brief ecore_consq_free - deallocates the given ConsQ struct.
285 *
286 * @param p_hwfn
287 * @param p_eq
288 */
289void ecore_consq_free(struct ecore_hwfn *p_hwfn,
290 struct ecore_consq *p_consq);
291
292#endif /* __ECORE_SPQ_H__ */