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_H__
32 #define __ECORE_LL2_H__
35 #include "ecore_hsi_eth.h"
36 #include "ecore_chain.h"
37 #include "ecore_hsi_common.h"
38 #include "ecore_ll2_api.h"
39 #include "ecore_sp_api.h"
41 /* ECORE LL2: internal structures and functions*/
42 #define ECORE_MAX_NUM_OF_LL2_CONNECTIONS (4)
44 static OSAL_INLINE u8 ecore_ll2_handle_to_queue_id(struct ecore_hwfn *p_hwfn,
47 return p_hwfn->hw_info.resc_start[ECORE_LL2_QUEUE] + handle;
50 struct ecore_ll2_rx_packet
52 osal_list_entry_t list_entry;
53 struct core_rx_bd_with_buff_len *rxq_bd;
54 dma_addr_t rx_buf_addr;
64 struct ecore_ll2_tx_packet
66 osal_list_entry_t list_entry;
71 struct core_tx_bd *txq_bd;
75 /* Flexible Array of bds_set determined by max_bds_per_packet */
78 struct ecore_ll2_rx_queue {
80 struct ecore_chain rxq_chain;
81 struct ecore_chain rcq_chain;
85 osal_list_t active_descq;
86 osal_list_t free_descq;
87 osal_list_t posting_descq;
88 struct ecore_ll2_rx_packet *descq_array;
89 void OSAL_IOMEM *set_prod_addr;
92 struct ecore_ll2_tx_queue {
94 struct ecore_chain txq_chain;
98 osal_list_t active_descq;
99 osal_list_t free_descq;
100 osal_list_t sending_descq;
101 struct ecore_ll2_tx_packet *descq_array;
102 struct ecore_ll2_tx_packet *cur_send_packet;
103 struct ecore_ll2_tx_packet cur_completing_packet;
104 u16 cur_completing_bd_idx;
105 void OSAL_IOMEM *doorbell_addr;
106 struct core_db_data db_msg;
108 u16 cur_send_frag_num;
109 u16 cur_completing_frag_num;
110 bool b_completing_packet;
113 struct ecore_ll2_info {
116 struct ecore_ll2_acquire_data_inputs input;
122 enum core_tx_dest tx_dest;
125 struct ecore_ll2_rx_queue rx_queue;
126 struct ecore_ll2_tx_queue tx_queue;
127 struct ecore_ll2_cbs cbs;
131 * @brief ecore_ll2_alloc - Allocates LL2 connections set
135 * @return enum _ecore_status_t
137 enum _ecore_status_t ecore_ll2_alloc(struct ecore_hwfn *p_hwfn);
140 * @brief ecore_ll2_setup - Inits LL2 connections set
145 void ecore_ll2_setup(struct ecore_hwfn *p_hwfn);
148 * @brief ecore_ll2_free - Releases LL2 connections set
153 void ecore_ll2_free(struct ecore_hwfn *p_hwfn);
157 * @brief ecore_ll2_get_fragment_of_tx_packet
160 * @param connection_handle LL2 connection's handle
162 * ecore_ll2_require_connection
164 * @param last_fragment)
166 * @return enum _ecore_status_t
169 ecore_ll2_get_fragment_of_tx_packet(struct ecore_hwfn *p_hwfn,
170 u8 connection_handle,
172 bool *last_fragment);
175 #endif /*__ECORE_LL2_H__*/