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