9506 Want support for QLogic QL41000/45000 series devices
[unleashed.git] / usr / src / uts / common / io / qede / 579xx / drivers / ecore / ecore_ll2.h
blob7a4e92d3205375ceddc9b1ea5708f628479fda3d
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1, (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1, (the "License").
27 * You may not use this file except in compliance with the License.
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
36 #ifndef __ECORE_LL2_H__
37 #define __ECORE_LL2_H__
39 #include "ecore.h"
40 #include "ecore_hsi_eth.h"
41 #include "ecore_chain.h"
42 #include "ecore_hsi_common.h"
43 #include "ecore_ll2_api.h"
44 #include "ecore_sp_api.h"
46 /* ECORE LL2: internal structures and functions*/
47 #define ECORE_MAX_NUM_OF_LL2_CONNECTIONS (4)
49 static OSAL_INLINE u8 ecore_ll2_handle_to_queue_id(struct ecore_hwfn *p_hwfn,
50 u8 handle)
52 return p_hwfn->hw_info.resc_start[ECORE_LL2_QUEUE] + handle;
55 struct ecore_ll2_rx_packet
57 osal_list_entry_t list_entry;
58 struct core_rx_bd_with_buff_len *rxq_bd;
59 dma_addr_t rx_buf_addr;
60 u16 buf_length;
61 void *cookie;
62 u8 placement_offset;
63 u16 parse_flags;
64 u16 packet_length;
65 u16 vlan;
66 u32 opaque_data[2];
69 struct ecore_ll2_tx_packet
71 osal_list_entry_t list_entry;
72 u16 bd_used;
73 bool notify_fw;
74 void *cookie;
75 struct {
76 struct core_tx_bd *txq_bd;
77 dma_addr_t tx_frag;
78 u16 frag_len;
79 } bds_set[1];
80 /* Flexible Array of bds_set determined by max_bds_per_packet */
83 struct ecore_ll2_rx_queue {
84 osal_spinlock_t lock;
85 struct ecore_chain rxq_chain;
86 struct ecore_chain rcq_chain;
87 u8 rx_sb_index;
88 bool b_cb_registred;
89 __le16 *p_fw_cons;
90 osal_list_t active_descq;
91 osal_list_t free_descq;
92 osal_list_t posting_descq;
93 struct ecore_ll2_rx_packet *descq_array;
94 void OSAL_IOMEM *set_prod_addr;
97 struct ecore_ll2_tx_queue {
98 osal_spinlock_t lock;
99 struct ecore_chain txq_chain;
100 u8 tx_sb_index;
101 bool b_cb_registred;
102 __le16 *p_fw_cons;
103 osal_list_t active_descq;
104 osal_list_t free_descq;
105 osal_list_t sending_descq;
106 struct ecore_ll2_tx_packet *descq_array;
107 struct ecore_ll2_tx_packet *cur_send_packet;
108 struct ecore_ll2_tx_packet cur_completing_packet;
109 u16 cur_completing_bd_idx;
110 void OSAL_IOMEM *doorbell_addr;
111 u16 bds_idx;
112 u16 cur_send_frag_num;
113 u16 cur_completing_frag_num;
114 bool b_completing_packet;
117 struct ecore_ll2_info {
118 osal_mutex_t mutex;
119 enum ecore_ll2_conn_type conn_type;
120 u32 cid;
121 u8 my_id;
122 u8 queue_id;
123 u8 tx_stats_id;
124 bool b_active;
125 u16 mtu;
126 u8 rx_drop_ttl0_flg;
127 u8 rx_vlan_removal_en;
128 u8 tx_tc;
129 u8 tx_max_bds_per_packet;
130 enum core_tx_dest tx_dest;
131 enum core_error_handle ai_err_packet_too_big;
132 enum core_error_handle ai_err_no_buf;
133 u8 gsi_enable;
134 u8 tx_stats_en;
135 u8 main_func_queue;
136 struct ecore_ll2_rx_queue rx_queue;
137 struct ecore_ll2_tx_queue tx_queue;
138 struct ecore_ll2_cbs cbs;
142 * @brief ecore_ll2_alloc - Allocates LL2 connections set
144 * @param p_hwfn
146 * @return enum _ecore_status_t
148 enum _ecore_status_t ecore_ll2_alloc(struct ecore_hwfn *p_hwfn);
151 * @brief ecore_ll2_setup - Inits LL2 connections set
153 * @param p_hwfn
156 void ecore_ll2_setup(struct ecore_hwfn *p_hwfn);
159 * @brief ecore_ll2_free - Releases LL2 connections set
161 * @param p_hwfn
164 void ecore_ll2_free(struct ecore_hwfn *p_hwfn);
166 #ifndef LINUX_REMOVE
168 * @brief ecore_ll2_get_fragment_of_tx_packet
170 * @param p_hwfn
171 * @param connection_handle LL2 connection's handle
172 * obtained from
173 * ecore_ll2_require_connection
174 * @param addr
175 * @param last_fragment)
177 * @return enum _ecore_status_t
179 enum _ecore_status_t
180 ecore_ll2_get_fragment_of_tx_packet(struct ecore_hwfn *p_hwfn,
181 u8 connection_handle,
182 dma_addr_t *addr,
183 bool *last_fragment);
184 #endif
186 #endif /*__ECORE_LL2_H__*/