2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_SPQ_H__
10 #define __ECORE_SPQ_H__
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"
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 rx_update_gft_filter_data rx_update_gft;
30 struct vport_update_ramrod_data vport_update;
31 struct core_rx_start_ramrod_data core_rx_queue_start;
32 struct core_rx_stop_ramrod_data core_rx_queue_stop;
33 struct core_tx_start_ramrod_data core_tx_queue_start;
34 struct core_tx_stop_ramrod_data core_tx_queue_stop;
35 struct vport_filter_update_ramrod_data vport_filter_update;
37 struct vf_start_ramrod_data vf_start;
38 struct vf_stop_ramrod_data vf_stop;
41 #define EQ_MAX_CREDIT 0xffffffff
44 ECORE_SPQ_PRIORITY_NORMAL,
45 ECORE_SPQ_PRIORITY_HIGH,
48 union ecore_spq_req_comp {
49 struct ecore_spq_comp_cb cb;
54 struct ecore_spq_comp_done {
59 struct ecore_spq_entry {
60 osal_list_entry_t list;
64 /* HSI slow path element */
65 struct slow_path_element elem;
67 union ramrod_data ramrod;
69 enum spq_priority priority;
71 /* pending queue for this entry */
74 enum spq_mode comp_mode;
75 struct ecore_spq_comp_cb comp_cb;
76 struct ecore_spq_comp_done comp_done; /* SPQ_MODE_EBLOCK */
80 struct ecore_chain chain;
81 u8 eq_sb_index; /* index within the SB */
82 __le16 *p_fw_cons; /* ptr to index value */
86 struct ecore_chain chain;
92 osal_list_t unlimited_pending;
94 osal_list_t completion_pending;
95 osal_list_t free_pool;
97 struct ecore_chain chain;
99 /* allocated dma-able memory for spq entries (+ramrod data) */
101 struct ecore_spq_entry *p_virt;
103 /* Bitmap for handling out-of-order completions */
104 #define SPQ_RING_SIZE \
105 (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
107 #define SPQ_COMP_BMAP_SIZE (SPQ_RING_SIZE / (sizeof(unsigned long) * 8))
108 unsigned long p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
110 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx) \
111 (OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
113 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx) \
114 (OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
116 #define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx) \
117 (OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
120 u32 unlimited_pending_count;
129 struct core_db_data db_data;
136 * @brief ecore_spq_post - Posts a Slow hwfn request to FW, or lacking that
137 * Pends it to the future list.
142 * @return enum _ecore_status_t
144 enum _ecore_status_t ecore_spq_post(struct ecore_hwfn *p_hwfn,
145 struct ecore_spq_entry *p_ent,
149 * @brief ecore_spq_allocate - Alloocates & initializes the SPQ and EQ.
153 * @return enum _ecore_status_t
155 enum _ecore_status_t ecore_spq_alloc(struct ecore_hwfn *p_hwfn);
158 * @brief ecore_spq_setup - Reset the SPQ to its start state.
162 void ecore_spq_setup(struct ecore_hwfn *p_hwfn);
165 * @brief ecore_spq_deallocate - Deallocates the given SPQ struct.
169 void ecore_spq_free(struct ecore_hwfn *p_hwfn);
172 * @brief ecore_spq_get_entry - Obtain an entrry from the spq
180 * @return enum _ecore_status_t
183 ecore_spq_get_entry(struct ecore_hwfn *p_hwfn,
184 struct ecore_spq_entry **pp_ent);
187 * @brief ecore_spq_return_entry - Return an entry to spq free
193 void ecore_spq_return_entry(struct ecore_hwfn *p_hwfn,
194 struct ecore_spq_entry *p_ent);
196 * @brief ecore_eq_allocate - Allocates & initializes an EQ struct
199 * @param num_elem number of elements in the eq
201 * @return enum _ecore_status_t
203 enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem);
206 * @brief ecore_eq_setup - Reset the EQ to its start state.
210 void ecore_eq_setup(struct ecore_hwfn *p_hwfn);
213 * @brief ecore_eq_free - deallocates the given EQ struct.
217 void ecore_eq_free(struct ecore_hwfn *p_hwfn);
220 * @brief ecore_eq_prod_update - update the FW with default EQ producer
225 void ecore_eq_prod_update(struct ecore_hwfn *p_hwfn,
229 * @brief ecore_eq_completion - Completes currently pending EQ elements
234 * @return enum _ecore_status_t
236 enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn,
240 * @brief ecore_spq_completion - Completes a single event
243 * @param echo - echo value from cookie (used for determining completion)
244 * @param p_data - data from cookie (used in callback function if applicable)
246 * @return enum _ecore_status_t
248 enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
251 union event_ring_data *p_data);
254 * @brief ecore_spq_get_cid - Given p_hwfn, return cid for the hwfn's SPQ
258 * @return u32 - SPQ CID
260 u32 ecore_spq_get_cid(struct ecore_hwfn *p_hwfn);
263 * @brief ecore_consq_alloc - Allocates & initializes an ConsQ struct
267 * @return enum _ecore_status_t
269 enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn);
272 * @brief ecore_consq_setup - Reset the ConsQ to its start state.
276 void ecore_consq_setup(struct ecore_hwfn *p_hwfn);
279 * @brief ecore_consq_free - deallocates the given ConsQ struct.
283 void ecore_consq_free(struct ecore_hwfn *p_hwfn);
285 #endif /* __ECORE_SPQ_H__ */