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_LL2_API_H__
32 #define __ECORE_LL2_API_H__
34 /* ECORE LL2 API: called by ECORE's upper level client */
35 /* must be the asme as core_rx_conn_type */
36 #ifndef __EXTRACT__LINUX__
38 enum ecore_ll2_conn_type {
39 ECORE_LL2_TYPE_FCOE /* FCoE L2 connection */,
40 ECORE_LL2_TYPE_ISCSI /* Iscsi L2 connection */,
41 ECORE_LL2_TYPE_TEST /* Eth TB test connection */,
42 ECORE_LL2_TYPE_OOO /* Iscsi OOO L2 connection */,
43 ECORE_LL2_TYPE_TOE /* toe L2 connection */,
44 ECORE_LL2_TYPE_ROCE /* RoCE L2 connection */,
46 MAX_ECORE_LL2_RX_CONN_TYPE
49 enum ecore_ll2_roce_flavor_type {
50 ECORE_LL2_ROCE, /* use this as default or d/c */
52 MAX_ECORE_LL2_ROCE_FLAVOR_TYPE
55 enum ecore_ll2_tx_dest
57 ECORE_LL2_TX_DEST_NW /* Light L2 TX Destination to the Network */,
58 ECORE_LL2_TX_DEST_LB /* Light L2 TX Destination to the Loopback */,
59 ECORE_LL2_TX_DEST_DROP /* Light L2 Drop the TX packet */,
63 enum ecore_ll2_error_handle
65 ECORE_LL2_DROP_PACKET /* If error occurs drop packet */,
66 ECORE_LL2_DO_NOTHING /* If error occurs do nothing */,
67 ECORE_LL2_ASSERT /* If error occurs assert */,
70 struct ecore_ll2_stats {
72 u64 gsi_invalid_pkt_length;
73 u64 gsi_unsupported_pkt_typ;
74 u64 gsi_crcchksm_error;
76 u64 packet_too_big_discard;
94 struct ecore_ll2_comp_rx_data {
97 dma_addr_t rx_buf_addr;
105 u8 data_length_error;
112 u32 opaque_data_0; /* src_mac_addr_hi */
113 u32 opaque_data_1; /* src_mac_addr_lo */
121 void (*ecore_ll2_complete_rx_packet_cb)(void *cxt,
122 struct ecore_ll2_comp_rx_data *data);
125 void (*ecore_ll2_release_rx_packet_cb)(void *cxt,
126 u8 connection_handle,
128 dma_addr_t rx_buf_addr,
132 void (*ecore_ll2_complete_tx_packet_cb)(void *cxt,
133 u8 connection_handle,
135 dma_addr_t first_frag_addr,
136 bool b_last_fragment,
140 void (*ecore_ll2_release_tx_packet_cb)(void *cxt,
141 u8 connection_handle,
143 dma_addr_t first_frag_addr,
144 bool b_last_fragment,
148 void (*ecore_ll2_slowpath_cb)(void *cxt,
149 u8 connection_handle,
153 struct ecore_ll2_cbs {
154 ecore_ll2_complete_rx_packet_cb rx_comp_cb;
155 ecore_ll2_release_rx_packet_cb rx_release_cb;
156 ecore_ll2_complete_tx_packet_cb tx_comp_cb;
157 ecore_ll2_release_tx_packet_cb tx_release_cb;
158 ecore_ll2_slowpath_cb slowpath_cb;
162 struct ecore_ll2_acquire_data_inputs {
163 enum ecore_ll2_conn_type conn_type;
164 u16 mtu; /* Maximum bytes that can be placed on a BD*/
167 /* Relevant only for OOO connection if 0 OOO rx buffers=2*rx_num_desc */
168 u16 rx_num_ooo_buffers;
171 /* if set, 802.1q tags will be removed and copied to CQE */
172 u8 rx_vlan_removal_en;
174 u8 tx_max_bds_per_packet;
176 enum ecore_ll2_tx_dest tx_dest;
177 enum ecore_ll2_error_handle ai_err_packet_too_big;
178 enum ecore_ll2_error_handle ai_err_no_buf;
183 struct ecore_ll2_acquire_data {
184 struct ecore_ll2_acquire_data_inputs input;
185 const struct ecore_ll2_cbs *cbs;
187 /* Output container for LL2 connection's handle */
188 u8 *p_connection_handle;
193 * @brief ecore_ll2_acquire_connection - allocate resources,
194 * starts rx & tx (if relevant) queues pair. Provides
195 * connecion handler as output parameter.
199 * @param data - describes connection parameters
200 * @return enum _ecore_status_t
203 ecore_ll2_acquire_connection(void *cxt,
204 struct ecore_ll2_acquire_data *data);
207 * @brief ecore_ll2_establish_connection - start previously
208 * allocated LL2 queues pair
212 * @param connection_handle LL2 connection's handle
214 * ecore_ll2_require_connection
216 * @return enum _ecore_status_t
218 enum _ecore_status_t ecore_ll2_establish_connection(void *cxt,
219 u8 connection_handle);
222 * @brief ecore_ll2_post_rx_buffers - submit buffers to LL2 RxQ.
225 * @param connection_handle LL2 connection's handle
227 * ecore_ll2_require_connection
228 * @param addr rx (physical address) buffers to
231 * @param notify_fw produce corresponding Rx BD
234 * @return enum _ecore_status_t
236 enum _ecore_status_t ecore_ll2_post_rx_buffer(void *cxt,
237 u8 connection_handle,
243 #ifndef __EXTRACT__LINUX__
244 struct ecore_ll2_tx_pkt_info {
248 u16 l4_hdr_offset_w; /* from start of packet */
249 enum ecore_ll2_tx_dest tx_dest;
250 enum ecore_ll2_roce_flavor_type ecore_roce_flavor;
251 dma_addr_t first_frag;
253 bool enable_ip_cksum;
254 bool enable_l4_cksum;
262 * @brief ecore_ll2_prepare_tx_packet - request for start Tx BD
263 * to prepare Tx packet submission to FW.
267 * @param pkt - info regarding the tx packet
268 * @param notify_fw - issue doorbell to fw for this packet
270 * @return enum _ecore_status_t
272 enum _ecore_status_t ecore_ll2_prepare_tx_packet(
274 u8 connection_handle,
275 struct ecore_ll2_tx_pkt_info *pkt,
279 * @brief ecore_ll2_release_connection - releases resources
280 * allocated for LL2 connection
283 * @param connection_handle LL2 connection's handle
285 * ecore_ll2_require_connection
287 void ecore_ll2_release_connection(void *cxt,
288 u8 connection_handle);
291 * @brief ecore_ll2_set_fragment_of_tx_packet - provides
292 * fragments to fill Tx BD of BDs requested by
293 * ecore_ll2_prepare_tx_packet..
297 * @param connection_handle LL2 connection's handle
299 * ecore_ll2_require_connection
303 * @return enum _ecore_status_t
306 ecore_ll2_set_fragment_of_tx_packet(void *cxt,
307 u8 connection_handle,
312 * @brief ecore_ll2_terminate_connection - stops Tx/Rx queues
316 * @param connection_handle LL2 connection's handle
318 * ecore_ll2_require_connection
320 * @return enum _ecore_status_t
322 enum _ecore_status_t ecore_ll2_terminate_connection(void *cxt,
323 u8 connection_handle);
325 enum _ecore_status_t __ecore_ll2_get_stats(void *cxt,
326 u8 connection_handle,
327 struct ecore_ll2_stats *p_stats);
330 * @brief ecore_ll2_get_stats - get LL2 queue's statistics
334 * @param connection_handle LL2 connection's handle
336 * ecore_ll2_require_connection
339 * @return enum _ecore_status_t
341 enum _ecore_status_t ecore_ll2_get_stats(void *cxt,
342 u8 connection_handle,
343 struct ecore_ll2_stats *p_stats);