blob: fad30ae12f633db3ff65a8cf40bd0e5942583e34 [file] [log] [blame]
Yuval Mintzdacd88d2016-05-11 16:36:16 +03001/* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
3 *
4 * This software is available under the terms of the GNU General Public License
5 * (GPL) Version 2, available from the file COPYING in the main directory of
6 * this source tree.
7 */
8#ifndef _QED_L2_H
9#define _QED_L2_H
10#include <linux/types.h>
11#include <linux/io.h>
12#include <linux/kernel.h>
13#include <linux/slab.h>
14#include <linux/qed/qed_eth_if.h>
15#include "qed.h"
16#include "qed_hw.h"
17#include "qed_sp.h"
18
Yuval Mintz17b235c2016-05-11 16:36:18 +030019struct qed_sge_tpa_params {
20 u8 max_buffers_per_cqe;
21
22 u8 update_tpa_en_flg;
23 u8 tpa_ipv4_en_flg;
24 u8 tpa_ipv6_en_flg;
25 u8 tpa_ipv4_tunn_en_flg;
26 u8 tpa_ipv6_tunn_en_flg;
27
28 u8 update_tpa_param_flg;
29 u8 tpa_pkt_split_flg;
30 u8 tpa_hdr_data_split_flg;
31 u8 tpa_gro_consistent_flg;
32 u8 tpa_max_aggs_num;
33 u16 tpa_max_size;
34 u16 tpa_min_size_to_start;
35 u16 tpa_min_size_to_cont;
36};
37
Yuval Mintzdacd88d2016-05-11 16:36:16 +030038enum qed_filter_opcode {
39 QED_FILTER_ADD,
40 QED_FILTER_REMOVE,
41 QED_FILTER_MOVE,
42 QED_FILTER_REPLACE, /* Delete all MACs and add new one instead */
43 QED_FILTER_FLUSH, /* Removes all filters */
44};
45
46enum qed_filter_ucast_type {
47 QED_FILTER_MAC,
48 QED_FILTER_VLAN,
49 QED_FILTER_MAC_VLAN,
50 QED_FILTER_INNER_MAC,
51 QED_FILTER_INNER_VLAN,
52 QED_FILTER_INNER_PAIR,
53 QED_FILTER_INNER_MAC_VNI_PAIR,
54 QED_FILTER_MAC_VNI_PAIR,
55 QED_FILTER_VNI,
56};
57
58struct qed_filter_ucast {
59 enum qed_filter_opcode opcode;
60 enum qed_filter_ucast_type type;
61 u8 is_rx_filter;
62 u8 is_tx_filter;
63 u8 vport_to_add_to;
64 u8 vport_to_remove_from;
65 unsigned char mac[ETH_ALEN];
66 u8 assert_on_error;
67 u16 vlan;
68 u32 vni;
69};
70
71struct qed_filter_mcast {
72 /* MOVE is not supported for multicast */
73 enum qed_filter_opcode opcode;
74 u8 vport_to_add_to;
75 u8 vport_to_remove_from;
76 u8 num_mc_addrs;
77#define QED_MAX_MC_ADDRS 64
78 unsigned char mac[QED_MAX_MC_ADDRS][ETH_ALEN];
79};
80
81int qed_sp_eth_rx_queue_stop(struct qed_hwfn *p_hwfn,
82 u16 rx_queue_id,
83 bool eq_completion_only, bool cqe_completion);
84
85int qed_sp_eth_tx_queue_stop(struct qed_hwfn *p_hwfn, u16 tx_queue_id);
86
87enum qed_tpa_mode {
88 QED_TPA_MODE_NONE,
89 QED_TPA_MODE_UNUSED,
90 QED_TPA_MODE_GRO,
91 QED_TPA_MODE_MAX
92};
93
94struct qed_sp_vport_start_params {
95 enum qed_tpa_mode tpa_mode;
96 bool remove_inner_vlan;
Yuval Mintz08feecd2016-05-11 16:36:20 +030097 bool only_untagged;
Yuval Mintzdacd88d2016-05-11 16:36:16 +030098 bool drop_ttl0;
99 u8 max_buffers_per_cqe;
100 u32 concrete_fid;
101 u16 opaque_fid;
102 u8 vport_id;
103 u16 mtu;
104};
105
106int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
107 struct qed_sp_vport_start_params *p_params);
108
109struct qed_rss_params {
110 u8 update_rss_config;
111 u8 rss_enable;
112 u8 rss_eng_id;
113 u8 update_rss_capabilities;
114 u8 update_rss_ind_table;
115 u8 update_rss_key;
116 u8 rss_caps;
117 u8 rss_table_size_log;
118 u16 rss_ind_table[QED_RSS_IND_TABLE_SIZE];
119 u32 rss_key[QED_RSS_KEY_SIZE];
120};
121
122struct qed_filter_accept_flags {
123 u8 update_rx_mode_config;
124 u8 update_tx_mode_config;
125 u8 rx_accept_filter;
126 u8 tx_accept_filter;
127#define QED_ACCEPT_NONE 0x01
128#define QED_ACCEPT_UCAST_MATCHED 0x02
129#define QED_ACCEPT_UCAST_UNMATCHED 0x04
130#define QED_ACCEPT_MCAST_MATCHED 0x08
131#define QED_ACCEPT_MCAST_UNMATCHED 0x10
132#define QED_ACCEPT_BCAST 0x20
133};
134
135struct qed_sp_vport_update_params {
136 u16 opaque_fid;
137 u8 vport_id;
138 u8 update_vport_active_rx_flg;
139 u8 vport_active_rx_flg;
140 u8 update_vport_active_tx_flg;
141 u8 vport_active_tx_flg;
Yuval Mintz17b235c2016-05-11 16:36:18 +0300142 u8 update_inner_vlan_removal_flg;
143 u8 inner_vlan_removal_flg;
Yuval Mintz08feecd2016-05-11 16:36:20 +0300144 u8 silent_vlan_removal_flg;
145 u8 update_default_vlan_enable_flg;
146 u8 default_vlan_enable_flg;
147 u8 update_default_vlan_flg;
148 u16 default_vlan;
Yuval Mintz17b235c2016-05-11 16:36:18 +0300149 u8 update_tx_switching_flg;
150 u8 tx_switching_flg;
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300151 u8 update_approx_mcast_flg;
152 u8 update_accept_any_vlan_flg;
153 u8 accept_any_vlan;
154 unsigned long bins[8];
155 struct qed_rss_params *rss_params;
156 struct qed_filter_accept_flags accept_flags;
Yuval Mintz17b235c2016-05-11 16:36:18 +0300157 struct qed_sge_tpa_params *sge_tpa_params;
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300158};
159
160int qed_sp_vport_update(struct qed_hwfn *p_hwfn,
161 struct qed_sp_vport_update_params *p_params,
162 enum spq_mode comp_mode,
163 struct qed_spq_comp_cb *p_comp_data);
164
165/**
166 * @brief qed_sp_vport_stop -
167 *
168 * This ramrod closes a VPort after all its RX and TX queues are terminated.
169 * An Assert is generated if any queues are left open.
170 *
171 * @param p_hwfn
172 * @param opaque_fid
173 * @param vport_id VPort ID
174 *
175 * @return int
176 */
177int qed_sp_vport_stop(struct qed_hwfn *p_hwfn, u16 opaque_fid, u8 vport_id);
178
179int qed_sp_eth_filter_ucast(struct qed_hwfn *p_hwfn,
180 u16 opaque_fid,
181 struct qed_filter_ucast *p_filter_cmd,
182 enum spq_mode comp_mode,
183 struct qed_spq_comp_cb *p_comp_data);
184
Yuval Mintz17b235c2016-05-11 16:36:18 +0300185/**
186 * @brief qed_sp_rx_eth_queues_update -
187 *
188 * This ramrod updates an RX queue. It is used for setting the active state
189 * of the queue and updating the TPA and SGE parameters.
190 *
191 * @note At the moment - only used by non-linux VFs.
192 *
193 * @param p_hwfn
194 * @param rx_queue_id RX Queue ID
195 * @param num_rxqs Allow to update multiple rx
196 * queues, from rx_queue_id to
197 * (rx_queue_id + num_rxqs)
198 * @param complete_cqe_flg Post completion to the CQE Ring if set
199 * @param complete_event_flg Post completion to the Event Ring if set
200 *
201 * @return int
202 */
203
204int
205qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
206 u16 rx_queue_id,
207 u8 num_rxqs,
208 u8 complete_cqe_flg,
209 u8 complete_event_flg,
210 enum spq_mode comp_mode,
211 struct qed_spq_comp_cb *p_comp_data);
212
Yuval Mintzdacd88d2016-05-11 16:36:16 +0300213int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
214 struct qed_sp_vport_start_params *p_params);
215
216int qed_sp_eth_rxq_start_ramrod(struct qed_hwfn *p_hwfn,
217 u16 opaque_fid,
218 u32 cid,
219 struct qed_queue_start_common_params *params,
220 u8 stats_id,
221 u16 bd_max_bytes,
222 dma_addr_t bd_chain_phys_addr,
223 dma_addr_t cqe_pbl_addr, u16 cqe_pbl_size);
224
225int qed_sp_eth_txq_start_ramrod(struct qed_hwfn *p_hwfn,
226 u16 opaque_fid,
227 u32 cid,
228 struct qed_queue_start_common_params *p_params,
229 u8 stats_id,
230 dma_addr_t pbl_addr,
231 u16 pbl_size,
232 union qed_qm_pq_params *p_pq_params);
233
234u8 qed_mcast_bin_from_mac(u8 *mac);
235
236#endif /* _QED_L2_H */