2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
31 #ifndef __ECORE_SPQ_H__
32 #define __ECORE_SPQ_H__
34 #include "ecore_hsi_common.h"
35 #include "ecore_status.h"
36 #include "ecore_hsi_eth.h"
37 #include "ecore_hsi_fcoe.h"
38 #include "tcp_common.h"
39 #include "ecore_hsi_iscsi.h"
40 #include "ecore_hsi_roce.h"
41 #include "ecore_hsi_iwarp.h"
42 #include "ecore_chain.h"
43 #include "ecore_sp_api.h"
47 struct pf_start_ramrod_data pf_start;
48 struct pf_update_ramrod_data pf_update;
49 struct rl_update_ramrod_data rl_update;
50 struct rx_queue_start_ramrod_data rx_queue_start;
51 struct rx_queue_update_ramrod_data rx_queue_update;
52 struct rx_queue_stop_ramrod_data rx_queue_stop;
53 struct tx_queue_start_ramrod_data tx_queue_start;
54 struct tx_queue_stop_ramrod_data tx_queue_stop;
55 struct vport_start_ramrod_data vport_start;
56 struct vport_stop_ramrod_data vport_stop;
57 struct rx_update_gft_filter_data rx_update_gft;
58 struct vport_update_ramrod_data vport_update;
59 struct core_rx_start_ramrod_data core_rx_queue_start;
60 struct core_rx_stop_ramrod_data core_rx_queue_stop;
61 struct core_tx_start_ramrod_data core_tx_queue_start;
62 struct core_tx_stop_ramrod_data core_tx_queue_stop;
63 struct vport_filter_update_ramrod_data vport_filter_update;
65 struct rdma_init_func_ramrod_data rdma_init_func;
66 struct rdma_close_func_ramrod_data rdma_close_func;
67 struct rdma_register_tid_ramrod_data rdma_register_tid;
68 struct rdma_deregister_tid_ramrod_data rdma_deregister_tid;
69 struct roce_create_qp_resp_ramrod_data roce_create_qp_resp;
70 struct roce_create_qp_req_ramrod_data roce_create_qp_req;
71 struct roce_modify_qp_resp_ramrod_data roce_modify_qp_resp;
72 struct roce_modify_qp_req_ramrod_data roce_modify_qp_req;
73 struct roce_query_qp_resp_ramrod_data roce_query_qp_resp;
74 struct roce_query_qp_req_ramrod_data roce_query_qp_req;
75 struct roce_destroy_qp_resp_ramrod_data roce_destroy_qp_resp;
76 struct roce_destroy_qp_req_ramrod_data roce_destroy_qp_req;
77 struct roce_init_func_ramrod_data roce_init_func;
79 struct rdma_create_cq_ramrod_data rdma_create_cq;
80 struct rdma_resize_cq_ramrod_data rdma_resize_cq;
81 struct rdma_destroy_cq_ramrod_data rdma_destroy_cq;
82 struct rdma_srq_create_ramrod_data rdma_create_srq;
83 struct rdma_srq_destroy_ramrod_data rdma_destroy_srq;
84 struct rdma_srq_modify_ramrod_data rdma_modify_srq;
86 struct iwarp_create_qp_ramrod_data iwarp_create_qp;
87 struct iwarp_tcp_offload_ramrod_data iwarp_tcp_offload;
88 struct iwarp_mpa_offload_ramrod_data iwarp_mpa_offload;
89 struct iwarp_modify_qp_ramrod_data iwarp_modify_qp;
90 struct iwarp_query_qp_ramrod_data iwarp_query_qp;
91 struct iwarp_init_func_ramrod_data iwarp_init_func;
93 struct fcoe_init_ramrod_params fcoe_init;
94 struct fcoe_conn_offload_ramrod_params fcoe_conn_ofld;
95 struct fcoe_conn_terminate_ramrod_params fcoe_conn_terminate;
96 struct fcoe_stat_ramrod_params fcoe_stat;
98 struct iscsi_slow_path_hdr iscsi_empty;
99 struct iscsi_init_ramrod_params iscsi_init;
100 struct iscsi_spe_func_dstry iscsi_destroy;
101 struct iscsi_spe_conn_offload iscsi_conn_offload;
102 struct iscsi_conn_update_ramrod_params iscsi_conn_update;
103 struct iscsi_spe_conn_mac_update iscsi_conn_mac_update;
104 struct iscsi_spe_conn_termination iscsi_conn_terminate;
106 struct vf_start_ramrod_data vf_start;
107 struct vf_stop_ramrod_data vf_stop;
110 #define EQ_MAX_CREDIT 0xffffffff
113 ECORE_SPQ_PRIORITY_NORMAL,
114 ECORE_SPQ_PRIORITY_HIGH,
117 union ecore_spq_req_comp {
118 struct ecore_spq_comp_cb cb;
122 /* SPQ_MODE_EBLOCK */
123 struct ecore_spq_comp_done {
128 struct ecore_spq_entry {
129 osal_list_entry_t list;
133 /* HSI slow path element */
134 struct slow_path_element elem;
136 union ramrod_data ramrod;
138 enum spq_priority priority;
140 /* pending queue for this entry */
143 enum spq_mode comp_mode;
144 struct ecore_spq_comp_cb comp_cb;
145 struct ecore_spq_comp_done comp_done; /* SPQ_MODE_EBLOCK */
149 struct ecore_chain chain;
150 u8 eq_sb_index; /* index within the SB */
151 __le16 *p_fw_cons; /* ptr to index value */
155 struct ecore_chain chain;
159 osal_spinlock_t lock;
161 osal_list_t unlimited_pending;
163 osal_list_t completion_pending;
164 osal_list_t free_pool;
166 struct ecore_chain chain;
168 /* allocated dma-able memory for spq entries (+ramrod data) */
170 struct ecore_spq_entry *p_virt;
172 /* Bitmap for handling out-of-order completions */
173 #define SPQ_RING_SIZE \
174 (CORE_SPQE_PAGE_SIZE_BYTES / sizeof(struct slow_path_element))
175 #define SPQ_COMP_BMAP_SIZE (SPQ_RING_SIZE / (sizeof(unsigned long) * 8 /* BITS_PER_LONG */))
176 unsigned long p_comp_bitmap[SPQ_COMP_BMAP_SIZE];
178 #define SPQ_COMP_BMAP_SET_BIT(p_spq, idx) \
180 OSAL_SET_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
182 #define SPQ_COMP_BMAP_CLEAR_BIT(p_spq, idx) \
184 OSAL_CLEAR_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap); \
186 #define SPQ_COMP_BMAP_TEST_BIT(p_spq, idx) \
187 (OSAL_TEST_BIT(((idx) % SPQ_RING_SIZE), (p_spq)->p_comp_bitmap))
190 u32 unlimited_pending_count;
203 * @brief ecore_spq_post - Posts a Slow hwfn request to FW, or lacking that
204 * Pends it to the future list.
209 * @return enum _ecore_status_t
211 enum _ecore_status_t ecore_spq_post(struct ecore_hwfn *p_hwfn,
212 struct ecore_spq_entry *p_ent,
216 * @brief ecore_spq_allocate - Alloocates & initializes the SPQ and EQ.
220 * @return enum _ecore_status_t
222 enum _ecore_status_t ecore_spq_alloc(struct ecore_hwfn *p_hwfn);
225 * @brief ecore_spq_setup - Reset the SPQ to its start state.
229 void ecore_spq_setup(struct ecore_hwfn *p_hwfn);
232 * @brief ecore_spq_deallocate - Deallocates the given SPQ struct.
236 void ecore_spq_free(struct ecore_hwfn *p_hwfn);
239 * @brief ecore_spq_get_entry - Obtain an entrry from the spq
247 * @return enum _ecore_status_t
250 ecore_spq_get_entry(struct ecore_hwfn *p_hwfn,
251 struct ecore_spq_entry **pp_ent);
254 * @brief ecore_spq_return_entry - Return an entry to spq free
260 void ecore_spq_return_entry(struct ecore_hwfn *p_hwfn,
261 struct ecore_spq_entry *p_ent);
263 * @brief ecore_eq_allocate - Allocates & initializes an EQ struct
266 * @param num_elem number of elements in the eq
268 * @return enum _ecore_status_t
270 enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem);
273 * @brief ecore_eq_setup - Reset the EQ to its start state.
277 void ecore_eq_setup(struct ecore_hwfn *p_hwfn);
280 * @brief ecore_eq_free - deallocates the given EQ struct.
284 void ecore_eq_free(struct ecore_hwfn *p_hwfn);
287 * @brief ecore_eq_prod_update - update the FW with default EQ producer
292 void ecore_eq_prod_update(struct ecore_hwfn *p_hwfn,
296 * @brief ecore_eq_completion - Completes currently pending EQ elements
301 * @return enum _ecore_status_t
303 enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn,
307 * @brief ecore_spq_completion - Completes a single event
310 * @param echo - echo value from cookie (used for determining completion)
311 * @param p_data - data from cookie (used in callback function if applicable)
313 * @return enum _ecore_status_t
315 enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn,
318 union event_ring_data *p_data);
321 * @brief ecore_spq_get_cid - Given p_hwfn, return cid for the hwfn's SPQ
325 * @return u32 - SPQ CID
327 u32 ecore_spq_get_cid(struct ecore_hwfn *p_hwfn);
330 * @brief ecore_consq_alloc - Allocates & initializes an ConsQ struct
334 * @return enum _ecore_status_t
336 enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn);
339 * @brief ecore_consq_setup - Reset the ConsQ to its start state.
343 void ecore_consq_setup(struct ecore_hwfn *p_hwfn);
346 * @brief ecore_consq_free - deallocates the given ConsQ struct.
350 void ecore_consq_free(struct ecore_hwfn *p_hwfn);
352 #endif /* __ECORE_SPQ_H__ */