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 */
37 enum ecore_ll2_conn_type {
38 ECORE_LL2_TYPE_FCOE /* FCoE L2 connection */,
39 ECORE_LL2_TYPE_ISCSI /* Iscsi L2 connection */,
40 ECORE_LL2_TYPE_TEST /* Eth TB test connection */,
41 ECORE_LL2_TYPE_OOO /* Iscsi OOO L2 connection */,
42 ECORE_LL2_TYPE_TOE /* toe L2 connection */,
43 ECORE_LL2_TYPE_ROCE /* RoCE L2 connection */,
45 MAX_ECORE_LL2_RX_CONN_TYPE
48 enum ecore_ll2_roce_flavor_type {
49 ECORE_LL2_ROCE, /* use this as default or d/c */
51 MAX_ECORE_LL2_ROCE_FLAVOR_TYPE
54 enum ecore_ll2_tx_dest
56 ECORE_LL2_TX_DEST_NW /* Light L2 TX Destination to the Network */,
57 ECORE_LL2_TX_DEST_LB /* Light L2 TX Destination to the Loopback */,
58 ECORE_LL2_TX_DEST_DROP /* Light L2 Drop the TX packet */,
62 enum ecore_ll2_error_handle
64 ECORE_LL2_DROP_PACKET /* If error occurs drop packet */,
65 ECORE_LL2_DO_NOTHING /* If error occurs do nothing */,
66 ECORE_LL2_ASSERT /* If error occurs assert */,
69 struct ecore_ll2_stats {
71 u64 gsi_invalid_pkt_length;
72 u64 gsi_unsupported_pkt_typ;
73 u64 gsi_crcchksm_error;
75 u64 packet_too_big_discard;
93 struct ecore_ll2_comp_rx_data {
96 dma_addr_t rx_buf_addr;
104 u8 data_length_error;
111 u32 opaque_data_0; /* src_mac_addr_hi */
112 u32 opaque_data_1; /* src_mac_addr_lo */
120 void (*ecore_ll2_complete_rx_packet_cb)(void *cxt,
121 struct ecore_ll2_comp_rx_data *data);
124 void (*ecore_ll2_release_rx_packet_cb)(void *cxt,
125 u8 connection_handle,
127 dma_addr_t rx_buf_addr,
131 void (*ecore_ll2_complete_tx_packet_cb)(void *cxt,
132 u8 connection_handle,
134 dma_addr_t first_frag_addr,
135 bool b_last_fragment,
139 void (*ecore_ll2_release_tx_packet_cb)(void *cxt,
140 u8 connection_handle,
142 dma_addr_t first_frag_addr,
143 bool b_last_fragment,
146 struct ecore_ll2_cbs {
147 ecore_ll2_complete_rx_packet_cb rx_comp_cb;
148 ecore_ll2_release_rx_packet_cb rx_release_cb;
149 ecore_ll2_complete_tx_packet_cb tx_comp_cb;
150 ecore_ll2_release_tx_packet_cb tx_release_cb;
154 struct ecore_ll2_acquire_data {
155 enum ecore_ll2_conn_type conn_type;
156 u16 mtu; /* Maximum bytes that can be placed on a BD*/
159 /* Relevant only for OOO connection if 0 OOO rx buffers=2*rx_num_desc */
160 u16 rx_num_ooo_buffers;
163 /* if set, 802.1q tags will be removed and copied to CQE */
164 u8 rx_vlan_removal_en;
166 u8 tx_max_bds_per_packet;
168 enum ecore_ll2_tx_dest tx_dest;
169 enum ecore_ll2_error_handle ai_err_packet_too_big;
170 enum ecore_ll2_error_handle ai_err_no_buf;
174 /* Output container for LL2 connection's handle */
175 u8 *p_connection_handle;
176 const struct ecore_ll2_cbs *cbs;
180 * @brief ecore_ll2_acquire_connection - allocate resources,
181 * starts rx & tx (if relevant) queues pair. Provides
182 * connecion handler as output parameter.
186 * @param data - describes connection parameters
187 * @return enum _ecore_status_t
190 ecore_ll2_acquire_connection(void *cxt,
191 struct ecore_ll2_acquire_data *data);
194 * @brief ecore_ll2_establish_connection - start previously
195 * allocated LL2 queues pair
199 * @param connection_handle LL2 connection's handle
201 * ecore_ll2_require_connection
203 * @return enum _ecore_status_t
205 enum _ecore_status_t ecore_ll2_establish_connection(void *cxt,
206 u8 connection_handle);
209 * @brief ecore_ll2_post_rx_buffers - submit buffers to LL2 RxQ.
212 * @param connection_handle LL2 connection's handle
214 * ecore_ll2_require_connection
215 * @param addr rx (physical address) buffers to
218 * @param notify_fw produce corresponding Rx BD
221 * @return enum _ecore_status_t
223 enum _ecore_status_t ecore_ll2_post_rx_buffer(void *cxt,
224 u8 connection_handle,
230 struct ecore_ll2_tx_pkt_info {
234 u16 l4_hdr_offset_w; /* from start of packet */
235 enum ecore_ll2_tx_dest tx_dest;
236 enum ecore_ll2_roce_flavor_type ecore_roce_flavor;
237 dma_addr_t first_frag;
239 bool enable_ip_cksum;
240 bool enable_l4_cksum;
246 * @brief ecore_ll2_prepare_tx_packet - request for start Tx BD
247 * to prepare Tx packet submission to FW.
251 * @param pkt - info regarding the tx packet
252 * @param notify_fw - issue doorbell to fw for this packet
254 * @return enum _ecore_status_t
256 enum _ecore_status_t ecore_ll2_prepare_tx_packet(
258 u8 connection_handle,
259 struct ecore_ll2_tx_pkt_info *pkt,
263 * @brief ecore_ll2_release_connection - releases resources
264 * allocated for LL2 connection
267 * @param connection_handle LL2 connection's handle
269 * ecore_ll2_require_connection
271 void ecore_ll2_release_connection(void *cxt,
272 u8 connection_handle);
275 * @brief ecore_ll2_set_fragment_of_tx_packet - provides
276 * fragments to fill Tx BD of BDs requested by
277 * ecore_ll2_prepare_tx_packet..
281 * @param connection_handle LL2 connection's handle
283 * ecore_ll2_require_connection
287 * @return enum _ecore_status_t
290 ecore_ll2_set_fragment_of_tx_packet(void *cxt,
291 u8 connection_handle,
296 * @brief ecore_ll2_terminate_connection - stops Tx/Rx queues
300 * @param connection_handle LL2 connection's handle
302 * ecore_ll2_require_connection
304 * @return enum _ecore_status_t
306 enum _ecore_status_t ecore_ll2_terminate_connection(void *cxt,
307 u8 connection_handle);
310 * @brief ecore_ll2_get_stats - get LL2 queue's statistics
314 * @param connection_handle LL2 connection's handle
316 * ecore_ll2_require_connection
319 * @return enum _ecore_status_t
321 enum _ecore_status_t ecore_ll2_get_stats(void *cxt,
322 u8 connection_handle,
323 struct ecore_ll2_stats *p_stats);