x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_ll2.h
blob31a409033c4177f826c2c65b4d5fc2cbb8b74bef
1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
33 #ifndef _QED_LL2_H
34 #define _QED_LL2_H
36 #include <linux/types.h>
37 #include <linux/kernel.h>
38 #include <linux/list.h>
39 #include <linux/mutex.h>
40 #include <linux/slab.h>
41 #include <linux/spinlock.h>
42 #include <linux/qed/qed_chain.h>
43 #include <linux/qed/qed_ll2_if.h>
44 #include "qed.h"
45 #include "qed_hsi.h"
46 #include "qed_sp.h"
48 #define QED_MAX_NUM_OF_LL2_CONNECTIONS (4)
50 enum qed_ll2_roce_flavor_type {
51 QED_LL2_ROCE,
52 QED_LL2_RROCE,
53 MAX_QED_LL2_ROCE_FLAVOR_TYPE
56 enum qed_ll2_conn_type {
57 QED_LL2_TYPE_FCOE,
58 QED_LL2_TYPE_ISCSI,
59 QED_LL2_TYPE_TEST,
60 QED_LL2_TYPE_ISCSI_OOO,
61 QED_LL2_TYPE_RESERVED2,
62 QED_LL2_TYPE_ROCE,
63 QED_LL2_TYPE_RESERVED3,
64 MAX_QED_LL2_RX_CONN_TYPE
67 enum qed_ll2_tx_dest {
68 QED_LL2_TX_DEST_NW, /* Light L2 TX Destination to the Network */
69 QED_LL2_TX_DEST_LB, /* Light L2 TX Destination to the Loopback */
70 QED_LL2_TX_DEST_MAX
73 struct qed_ll2_rx_packet {
74 struct list_head list_entry;
75 struct core_rx_bd_with_buff_len *rxq_bd;
76 dma_addr_t rx_buf_addr;
77 u16 buf_length;
78 void *cookie;
79 u8 placement_offset;
80 u16 parse_flags;
81 u16 packet_length;
82 u16 vlan;
83 u32 opaque_data[2];
86 struct qed_ll2_tx_packet {
87 struct list_head list_entry;
88 u16 bd_used;
89 u16 vlan;
90 u16 l4_hdr_offset_w;
91 u8 bd_flags;
92 bool notify_fw;
93 void *cookie;
95 struct {
96 struct core_tx_bd *txq_bd;
97 dma_addr_t tx_frag;
98 u16 frag_len;
99 } bds_set[ETH_TX_MAX_BDS_PER_NON_LSO_PACKET];
102 struct qed_ll2_rx_queue {
103 /* Lock protecting the Rx queue manipulation */
104 spinlock_t lock;
105 struct qed_chain rxq_chain;
106 struct qed_chain rcq_chain;
107 u8 rx_sb_index;
108 bool b_cb_registred;
109 __le16 *p_fw_cons;
110 struct list_head active_descq;
111 struct list_head free_descq;
112 struct list_head posting_descq;
113 struct qed_ll2_rx_packet *descq_array;
114 void __iomem *set_prod_addr;
117 struct qed_ll2_tx_queue {
118 /* Lock protecting the Tx queue manipulation */
119 spinlock_t lock;
120 struct qed_chain txq_chain;
121 u8 tx_sb_index;
122 bool b_cb_registred;
123 __le16 *p_fw_cons;
124 struct list_head active_descq;
125 struct list_head free_descq;
126 struct list_head sending_descq;
127 struct qed_ll2_tx_packet *descq_array;
128 struct qed_ll2_tx_packet *cur_send_packet;
129 struct qed_ll2_tx_packet cur_completing_packet;
130 u16 cur_completing_bd_idx;
131 void __iomem *doorbell_addr;
132 u16 bds_idx;
133 u16 cur_send_frag_num;
134 u16 cur_completing_frag_num;
135 bool b_completing_packet;
138 struct qed_ll2_conn {
139 enum qed_ll2_conn_type conn_type;
140 u16 mtu;
141 u8 rx_drop_ttl0_flg;
142 u8 rx_vlan_removal_en;
143 u8 tx_tc;
144 enum core_tx_dest tx_dest;
145 enum core_error_handle ai_err_packet_too_big;
146 enum core_error_handle ai_err_no_buf;
147 u8 gsi_enable;
150 struct qed_ll2_info {
151 /* Lock protecting the state of LL2 */
152 struct mutex mutex;
153 struct qed_ll2_conn conn;
154 u32 cid;
155 u8 my_id;
156 u8 queue_id;
157 u8 tx_stats_id;
158 bool b_active;
159 u8 tx_stats_en;
160 struct qed_ll2_rx_queue rx_queue;
161 struct qed_ll2_tx_queue tx_queue;
165 * @brief qed_ll2_acquire_connection - allocate resources,
166 * starts rx & tx (if relevant) queues pair. Provides
167 * connecion handler as output parameter.
169 * @param p_hwfn
170 * @param p_params Contain various configuration properties
171 * @param rx_num_desc
172 * @param tx_num_desc
174 * @param p_connection_handle Output container for LL2 connection's handle
176 * @return 0 on success, failure otherwise
178 int qed_ll2_acquire_connection(struct qed_hwfn *p_hwfn,
179 struct qed_ll2_conn *p_params,
180 u16 rx_num_desc,
181 u16 tx_num_desc,
182 u8 *p_connection_handle);
185 * @brief qed_ll2_establish_connection - start previously
186 * allocated LL2 queues pair
188 * @param p_hwfn
189 * @param p_ptt
190 * @param connection_handle LL2 connection's handle obtained from
191 * qed_ll2_require_connection
193 * @return 0 on success, failure otherwise
195 int qed_ll2_establish_connection(struct qed_hwfn *p_hwfn, u8 connection_handle);
198 * @brief qed_ll2_post_rx_buffers - submit buffers to LL2 Rx queue.
200 * @param p_hwfn
201 * @param connection_handle LL2 connection's handle obtained from
202 * qed_ll2_require_connection
203 * @param addr rx (physical address) buffers to submit
204 * @param cookie
205 * @param notify_fw produce corresponding Rx BD immediately
207 * @return 0 on success, failure otherwise
209 int qed_ll2_post_rx_buffer(struct qed_hwfn *p_hwfn,
210 u8 connection_handle,
211 dma_addr_t addr,
212 u16 buf_len, void *cookie, u8 notify_fw);
215 * @brief qed_ll2_prepare_tx_packet - request for start Tx BD
216 * to prepare Tx packet submission to FW.
218 * @param p_hwfn
219 * @param connection_handle LL2 connection's handle obtained from
220 * qed_ll2_require_connection
221 * @param num_of_bds a number of requested BD equals a number of
222 * fragments in Tx packet
223 * @param vlan VLAN to insert to packet (if insertion set)
224 * @param bd_flags
225 * @param l4_hdr_offset_w L4 Header Offset from start of packet
226 * (in words). This is needed if both l4_csum
227 * and ipv6_ext are set
228 * @param e_tx_dest indicates if the packet is to be transmitted via
229 * loopback or to the network
230 * @param first_frag
231 * @param first_frag_len
232 * @param cookie
234 * @param notify_fw
236 * @return 0 on success, failure otherwise
238 int qed_ll2_prepare_tx_packet(struct qed_hwfn *p_hwfn,
239 u8 connection_handle,
240 u8 num_of_bds,
241 u16 vlan,
242 u8 bd_flags,
243 u16 l4_hdr_offset_w,
244 enum qed_ll2_tx_dest e_tx_dest,
245 enum qed_ll2_roce_flavor_type qed_roce_flavor,
246 dma_addr_t first_frag,
247 u16 first_frag_len, void *cookie, u8 notify_fw);
250 * @brief qed_ll2_release_connection - releases resources
251 * allocated for LL2 connection
253 * @param p_hwfn
254 * @param connection_handle LL2 connection's handle obtained from
255 * qed_ll2_require_connection
257 void qed_ll2_release_connection(struct qed_hwfn *p_hwfn, u8 connection_handle);
260 * @brief qed_ll2_set_fragment_of_tx_packet - provides fragments to fill
261 * Tx BD of BDs requested by
262 * qed_ll2_prepare_tx_packet
264 * @param p_hwfn
265 * @param connection_handle LL2 connection's handle
266 * obtained from
267 * qed_ll2_require_connection
268 * @param addr
269 * @param nbytes
271 * @return 0 on success, failure otherwise
273 int qed_ll2_set_fragment_of_tx_packet(struct qed_hwfn *p_hwfn,
274 u8 connection_handle,
275 dma_addr_t addr, u16 nbytes);
278 * @brief qed_ll2_terminate_connection - stops Tx/Rx queues
281 * @param p_hwfn
282 * @param connection_handle LL2 connection's handle
283 * obtained from
284 * qed_ll2_require_connection
286 * @return 0 on success, failure otherwise
288 int qed_ll2_terminate_connection(struct qed_hwfn *p_hwfn, u8 connection_handle);
291 * @brief qed_ll2_get_stats - get LL2 queue's statistics
294 * @param p_hwfn
295 * @param connection_handle LL2 connection's handle obtained from
296 * qed_ll2_require_connection
297 * @param p_stats
299 * @return 0 on success, failure otherwise
301 int qed_ll2_get_stats(struct qed_hwfn *p_hwfn,
302 u8 connection_handle, struct qed_ll2_stats *p_stats);
305 * @brief qed_ll2_alloc - Allocates LL2 connections set
307 * @param p_hwfn
309 * @return pointer to alocated qed_ll2_info or NULL
311 struct qed_ll2_info *qed_ll2_alloc(struct qed_hwfn *p_hwfn);
314 * @brief qed_ll2_setup - Inits LL2 connections set
316 * @param p_hwfn
317 * @param p_ll2_connections
320 void qed_ll2_setup(struct qed_hwfn *p_hwfn,
321 struct qed_ll2_info *p_ll2_connections);
324 * @brief qed_ll2_free - Releases LL2 connections set
326 * @param p_hwfn
327 * @param p_ll2_connections
330 void qed_ll2_free(struct qed_hwfn *p_hwfn,
331 struct qed_ll2_info *p_ll2_connections);
332 #endif