qed: aRFS infrastructure support
[linux-2.6-block.git] / drivers / net / ethernet / qlogic / qed / qed_l2.h
CommitLineData
dacd88d6 1/* QLogic qed NIC Driver
e8f1cb50 2 * Copyright (c) 2015-2017 QLogic Corporation
dacd88d6 3 *
e8f1cb50
MY
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:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
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.
22 *
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.
dacd88d6
YM
31 */
32#ifndef _QED_L2_H
33#define _QED_L2_H
34#include <linux/types.h>
35#include <linux/io.h>
36#include <linux/kernel.h>
37#include <linux/slab.h>
38#include <linux/qed/qed_eth_if.h>
39#include "qed.h"
40#include "qed_hw.h"
41#include "qed_sp.h"
f29ffdb6
MY
42struct qed_rss_params {
43 u8 update_rss_config;
44 u8 rss_enable;
45 u8 rss_eng_id;
46 u8 update_rss_capabilities;
47 u8 update_rss_ind_table;
48 u8 update_rss_key;
49 u8 rss_caps;
50 u8 rss_table_size_log;
51
52 /* Indirection table consist of rx queue handles */
53 void *rss_ind_table[QED_RSS_IND_TABLE_SIZE];
54 u32 rss_key[QED_RSS_KEY_SIZE];
55};
dacd88d6 56
17b235c1
YM
57struct qed_sge_tpa_params {
58 u8 max_buffers_per_cqe;
59
60 u8 update_tpa_en_flg;
61 u8 tpa_ipv4_en_flg;
62 u8 tpa_ipv6_en_flg;
63 u8 tpa_ipv4_tunn_en_flg;
64 u8 tpa_ipv6_tunn_en_flg;
65
66 u8 update_tpa_param_flg;
67 u8 tpa_pkt_split_flg;
68 u8 tpa_hdr_data_split_flg;
69 u8 tpa_gro_consistent_flg;
70 u8 tpa_max_aggs_num;
71 u16 tpa_max_size;
72 u16 tpa_min_size_to_start;
73 u16 tpa_min_size_to_cont;
74};
75
dacd88d6
YM
76enum qed_filter_opcode {
77 QED_FILTER_ADD,
78 QED_FILTER_REMOVE,
79 QED_FILTER_MOVE,
80 QED_FILTER_REPLACE, /* Delete all MACs and add new one instead */
81 QED_FILTER_FLUSH, /* Removes all filters */
82};
83
84enum qed_filter_ucast_type {
85 QED_FILTER_MAC,
86 QED_FILTER_VLAN,
87 QED_FILTER_MAC_VLAN,
88 QED_FILTER_INNER_MAC,
89 QED_FILTER_INNER_VLAN,
90 QED_FILTER_INNER_PAIR,
91 QED_FILTER_INNER_MAC_VNI_PAIR,
92 QED_FILTER_MAC_VNI_PAIR,
93 QED_FILTER_VNI,
94};
95
96struct qed_filter_ucast {
97 enum qed_filter_opcode opcode;
98 enum qed_filter_ucast_type type;
99 u8 is_rx_filter;
100 u8 is_tx_filter;
101 u8 vport_to_add_to;
102 u8 vport_to_remove_from;
103 unsigned char mac[ETH_ALEN];
104 u8 assert_on_error;
105 u16 vlan;
106 u32 vni;
107};
108
109struct qed_filter_mcast {
110 /* MOVE is not supported for multicast */
111 enum qed_filter_opcode opcode;
112 u8 vport_to_add_to;
113 u8 vport_to_remove_from;
114 u8 num_mc_addrs;
115#define QED_MAX_MC_ADDRS 64
116 unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
117};
118
3da7a37a
MY
119/**
120 * @brief qed_eth_rx_queue_stop - This ramrod closes an Rx queue
121 *
122 * @param p_hwfn
123 * @param p_rxq Handler of queue to close
124 * @param eq_completion_only If True completion will be on
125 * EQe, if False completion will be
126 * on EQe if p_hwfn opaque
127 * different from the RXQ opaque
128 * otherwise on CQe.
129 * @param cqe_completion If True completion will be
130 * receive on CQe.
131 * @return int
132 */
133int
134qed_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
135 void *p_rxq,
136 bool eq_completion_only, bool cqe_completion);
dacd88d6 137
3da7a37a
MY
138/**
139 * @brief qed_eth_tx_queue_stop - closes a Tx queue
140 *
141 * @param p_hwfn
142 * @param p_txq - handle to Tx queue needed to be closed
143 *
144 * @return int
145 */
146int qed_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, void *p_txq);
dacd88d6
YM
147
148enum qed_tpa_mode {
149 QED_TPA_MODE_NONE,
150 QED_TPA_MODE_UNUSED,
151 QED_TPA_MODE_GRO,
152 QED_TPA_MODE_MAX
153};
154
155struct qed_sp_vport_start_params {
156 enum qed_tpa_mode tpa_mode;
157 bool remove_inner_vlan;
831bfb0e 158 bool tx_switching;
c78c70fa 159 bool handle_ptp_pkts;
08feecd7 160 bool only_untagged;
dacd88d6
YM
161 bool drop_ttl0;
162 u8 max_buffers_per_cqe;
163 u32 concrete_fid;
164 u16 opaque_fid;
165 u8 vport_id;
166 u16 mtu;
11a85d75
YM
167 bool check_mac;
168 bool check_ethtype;
dacd88d6
YM
169};
170
171int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
172 struct qed_sp_vport_start_params *p_params);
173
dacd88d6
YM
174
175struct qed_filter_accept_flags {
176 u8 update_rx_mode_config;
177 u8 update_tx_mode_config;
178 u8 rx_accept_filter;
179 u8 tx_accept_filter;
180#define QED_ACCEPT_NONE 0x01
181#define QED_ACCEPT_UCAST_MATCHED 0x02
182#define QED_ACCEPT_UCAST_UNMATCHED 0x04
183#define QED_ACCEPT_MCAST_MATCHED 0x08
184#define QED_ACCEPT_MCAST_UNMATCHED 0x10
185#define QED_ACCEPT_BCAST 0x20
186};
187
d51e4af5
CM
188struct qed_arfs_config_params {
189 bool tcp;
190 bool udp;
191 bool ipv4;
192 bool ipv6;
193 bool arfs_enable;
194};
195
dacd88d6
YM
196struct qed_sp_vport_update_params {
197 u16 opaque_fid;
198 u8 vport_id;
199 u8 update_vport_active_rx_flg;
200 u8 vport_active_rx_flg;
201 u8 update_vport_active_tx_flg;
202 u8 vport_active_tx_flg;
17b235c1
YM
203 u8 update_inner_vlan_removal_flg;
204 u8 inner_vlan_removal_flg;
08feecd7
YM
205 u8 silent_vlan_removal_flg;
206 u8 update_default_vlan_enable_flg;
207 u8 default_vlan_enable_flg;
208 u8 update_default_vlan_flg;
209 u16 default_vlan;
17b235c1
YM
210 u8 update_tx_switching_flg;
211 u8 tx_switching_flg;
dacd88d6 212 u8 update_approx_mcast_flg;
6ddc7608
YM
213 u8 update_anti_spoofing_en_flg;
214 u8 anti_spoofing_en;
dacd88d6
YM
215 u8 update_accept_any_vlan_flg;
216 u8 accept_any_vlan;
217 unsigned long bins[8];
218 struct qed_rss_params *rss_params;
219 struct qed_filter_accept_flags accept_flags;
17b235c1 220 struct qed_sge_tpa_params *sge_tpa_params;
dacd88d6
YM
221};
222
223int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
224 struct qed_sp_vport_update_params *p_params,
225 enum spq_mode comp_mode,
226 struct qed_spq_comp_cb *p_comp_data);
227
228/**
229 * @brief qed_sp_vport_stop -
230 *
231 * This ramrod closes a VPort after all its RX and TX queues are terminated.
232 * An Assert is generated if any queues are left open.
233 *
234 * @param p_hwfn
235 * @param opaque_fid
236 * @param vport_id VPort ID
237 *
238 * @return int
239 */
240int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
241
242int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
243 u16 opaque_fid,
244 struct qed_filter_ucast *p_filter_cmd,
245 enum spq_mode comp_mode,
246 struct qed_spq_comp_cb *p_comp_data);
247
17b235c1
YM
248/**
249 * @brief qed_sp_rx_eth_queues_update -
250 *
251 * This ramrod updates an RX queue. It is used for setting the active state
252 * of the queue and updating the TPA and SGE parameters.
253 *
254 * @note At the moment - only used by non-linux VFs.
255 *
256 * @param p_hwfn
3da7a37a
MY
257 * @param pp_rxq_handlers An array of queue handlers to be updated.
258 * @param num_rxqs number of queues to update.
17b235c1
YM
259 * @param complete_cqe_flg Post completion to the CQE Ring if set
260 * @param complete_event_flg Post completion to the Event Ring if set
3da7a37a
MY
261 * @param comp_mode
262 * @param p_comp_data
17b235c1
YM
263 *
264 * @return int
265 */
266
267int
268qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
3da7a37a 269 void **pp_rxq_handlers,
17b235c1
YM
270 u8 num_rxqs,
271 u8 complete_cqe_flg,
272 u8 complete_event_flg,
273 enum spq_mode comp_mode,
274 struct qed_spq_comp_cb *p_comp_data);
275
6c754246
SRK
276void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);
277
3da7a37a
MY
278void qed_reset_vport_stats(struct qed_dev *cdev);
279
280struct qed_queue_cid {
281 /* 'Relative' is a relative term ;-). Usually the indices [not counting
282 * SBs] would be PF-relative, but there are some cases where that isn't
283 * the case - specifically for a PF configuring its VF indices it's
284 * possible some fields [E.g., stats-id] in 'rel' would already be abs.
285 */
286 struct qed_queue_start_common_params rel;
287 struct qed_queue_start_common_params abs;
288 u32 cid;
289 u16 opaque_fid;
290
291 /* VFs queues are mapped differently, so we need to know the
292 * relative queue associated with them [0-based].
293 * Notice this is relevant on the *PF* queue-cid of its VF's queues,
294 * and not on the VF itself.
295 */
296 bool is_vf;
297 u8 vf_qid;
298
299 /* Legacy VFs might have Rx producer located elsewhere */
300 bool b_legacy_vf;
f29ffdb6
MY
301
302 struct qed_hwfn *p_owner;
3da7a37a 303};
dacd88d6 304
3da7a37a
MY
305void qed_eth_queue_cid_release(struct qed_hwfn *p_hwfn,
306 struct qed_queue_cid *p_cid);
307
308struct qed_queue_cid *_qed_eth_queue_to_cid(struct qed_hwfn *p_hwfn,
309 u16 opaque_fid,
310 u32 cid,
311 u8 vf_qid,
312 struct qed_queue_start_common_params
313 *p_params);
314
315int
316qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
317 struct qed_sp_vport_start_params *p_params);
318
319/**
320 * @brief - Starts an Rx queue, when queue_cid is already prepared
321 *
322 * @param p_hwfn
323 * @param p_cid
324 * @param bd_max_bytes
325 * @param bd_chain_phys_addr
326 * @param cqe_pbl_addr
327 * @param cqe_pbl_size
328 *
329 * @return int
330 */
331int
332qed_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
333 struct qed_queue_cid *p_cid,
334 u16 bd_max_bytes,
335 dma_addr_t bd_chain_phys_addr,
336 dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
337
338/**
339 * @brief - Starts a Tx queue, where queue_cid is already prepared
340 *
341 * @param p_hwfn
342 * @param p_cid
343 * @param pbl_addr
344 * @param pbl_size
345 * @param p_pq_params - parameters for choosing the PQ for this Tx queue
346 *
347 * @return int
348 */
349int
350qed_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
351 struct qed_queue_cid *p_cid,
352 dma_addr_t pbl_addr, u16 pbl_size, u16 pq_id);
dacd88d6
YM
353
354u8 qed_mcast_bin_from_mac(u8 *mac);
355
356#endif /* _QED_L2_H */