blob: d91651ecfd26a2e2bee0b64d1d4827c775c35284 [file] [log] [blame]
Yuval Mintz25c089d2015-10-26 11:02:26 +02001/* QLogic qed NIC Driver
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +02002 * Copyright (c) 2015-2017 QLogic Corporation
Yuval Mintz25c089d2015-10-26 11:02:26 +02003 *
Mintz, Yuvale8f1cb52017-01-01 13:57:00 +02004 * 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.
Yuval Mintz25c089d2015-10-26 11:02:26 +020031 */
32
33#ifndef _QED_ETH_IF_H
34#define _QED_ETH_IF_H
35
36#include <linux/list.h>
37#include <linux/if_link.h>
38#include <linux/qed/eth_common.h>
39#include <linux/qed/qed_if.h>
Yuval Mintz0b55e272016-05-11 16:36:15 +030040#include <linux/qed/qed_iov_if.h>
Yuval Mintz25c089d2015-10-26 11:02:26 +020041
Mintz, Yuval3da7a372016-11-29 16:47:06 +020042struct qed_queue_start_common_params {
43 /* Should always be relative to entity sending this. */
44 u8 vport_id;
45 u16 queue_id;
46
47 /* Relative, but relevant only for PFs */
48 u8 stats_id;
49
50 /* These are always absolute */
51 u16 sb;
52 u8 sb_idx;
53};
54
55struct qed_rxq_start_ret_params {
56 void __iomem *p_prod;
57 void *p_handle;
58};
59
60struct qed_txq_start_ret_params {
61 void __iomem *p_doorbell;
62 void *p_handle;
63};
64
Yuval Mintz25c089d2015-10-26 11:02:26 +020065struct qed_dev_eth_info {
66 struct qed_dev_info common;
67
68 u8 num_queues;
69 u8 num_tc;
70
71 u8 port_mac[ETH_ALEN];
Tomer Tayar2edbff82016-10-31 07:14:27 +020072 u16 num_vlan_filters;
Yuval Mintz7b7e70f2016-10-14 05:19:20 -040073 u16 num_mac_filters;
Yuval Mintzd8c2c7e2016-08-22 13:25:11 +030074
75 /* Legacy VF - this affects the datapath, so qede has to know */
76 bool is_legacy;
Yuval Mintz25c089d2015-10-26 11:02:26 +020077};
78
Manish Chopracee4d262015-10-26 11:02:28 +020079struct qed_update_vport_rss_params {
80 u16 rss_ind_table[128];
81 u32 rss_key[10];
Sudarsana Reddy Kalluru8c5ebd02016-04-10 12:43:00 +030082 u8 rss_caps;
Manish Chopracee4d262015-10-26 11:02:28 +020083};
84
85struct qed_update_vport_params {
86 u8 vport_id;
87 u8 update_vport_active_flg;
88 u8 vport_active_flg;
Yuval Mintz831bfb0e2016-05-11 16:36:25 +030089 u8 update_tx_switching_flg;
90 u8 tx_switching_flg;
Yuval Mintz3f9b4a62016-02-18 17:00:39 +020091 u8 update_accept_any_vlan_flg;
92 u8 accept_any_vlan;
Manish Chopracee4d262015-10-26 11:02:28 +020093 u8 update_rss_flg;
94 struct qed_update_vport_rss_params rss_params;
95};
96
Manish Chopra088c8612016-03-04 12:35:05 -050097struct qed_start_vport_params {
98 bool remove_inner_vlan;
99 bool gro_enable;
100 bool drop_ttl0;
101 u8 vport_id;
102 u16 mtu;
Yuval Mintza0d26d52016-06-19 15:18:13 +0300103 bool clear_stats;
Manish Chopra088c8612016-03-04 12:35:05 -0500104};
105
Manish Chopracee4d262015-10-26 11:02:28 +0200106enum qed_filter_rx_mode_type {
107 QED_FILTER_RX_MODE_TYPE_REGULAR,
108 QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
109 QED_FILTER_RX_MODE_TYPE_PROMISC,
110};
111
112enum qed_filter_xcast_params_type {
113 QED_FILTER_XCAST_TYPE_ADD,
114 QED_FILTER_XCAST_TYPE_DEL,
115 QED_FILTER_XCAST_TYPE_REPLACE,
116};
117
118struct qed_filter_ucast_params {
119 enum qed_filter_xcast_params_type type;
120 u8 vlan_valid;
121 u16 vlan;
122 u8 mac_valid;
123 unsigned char mac[ETH_ALEN];
124};
125
126struct qed_filter_mcast_params {
127 enum qed_filter_xcast_params_type type;
128 u8 num;
129 unsigned char mac[64][ETH_ALEN];
130};
131
132union qed_filter_type_params {
133 enum qed_filter_rx_mode_type accept_flags;
134 struct qed_filter_ucast_params ucast;
135 struct qed_filter_mcast_params mcast;
136};
137
138enum qed_filter_type {
139 QED_FILTER_TYPE_UCAST,
140 QED_FILTER_TYPE_MCAST,
141 QED_FILTER_TYPE_RX_MODE,
142 QED_MAX_FILTER_TYPES,
143};
144
145struct qed_filter_params {
146 enum qed_filter_type type;
147 union qed_filter_type_params filter;
148};
149
Manish Chopra464f6642016-04-14 01:38:29 -0400150struct qed_tunn_params {
151 u16 vxlan_port;
152 u8 update_vxlan_port;
153 u16 geneve_port;
154 u8 update_geneve_port;
155};
156
Manish Chopracee4d262015-10-26 11:02:28 +0200157struct qed_eth_cb_ops {
158 struct qed_common_cb_ops common;
Yuval Mintzc3aaa402016-10-14 05:19:17 -0400159 void (*force_mac) (void *dev, u8 *mac, bool forced);
Manish Chopracee4d262015-10-26 11:02:28 +0200160};
161
Sudarsana Reddy Kallurua1d8d8a2016-06-08 06:22:11 -0400162#ifdef CONFIG_DCB
163/* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
164 * of dcbnl_rtnl_ops structure.
165 */
166struct qed_eth_dcbnl_ops {
167 /* IEEE 802.1Qaz std */
168 int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
169 int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
170 int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
171 int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
172 int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
173 int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
174 int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
175 int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
176
177 /* CEE std */
178 u8 (*getstate)(struct qed_dev *cdev);
179 u8 (*setstate)(struct qed_dev *cdev, u8 state);
180 void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
181 u8 *pgid, u8 *bw_pct, u8 *up_map);
182 void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
183 void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
184 u8 *pgid, u8 *bw_pct, u8 *up_map);
185 void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
186 void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
187 void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
188 u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
189 int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
190 u8 (*getpfcstate)(struct qed_dev *cdev);
191 int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
192 u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
193
194 /* DCBX configuration */
195 u8 (*getdcbx)(struct qed_dev *cdev);
196 void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
197 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
198 void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
199 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
200 void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
201 void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
202 u8 (*setall)(struct qed_dev *cdev);
203 int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
204 void (*setpfcstate)(struct qed_dev *cdev, u8 state);
205 int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
206 u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
207 u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
208
209 /* Peer apps */
210 int (*peer_getappinfo)(struct qed_dev *cdev,
211 struct dcb_peer_app_info *info,
212 u16 *app_count);
213 int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
214
215 /* CEE peer */
216 int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
217 int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
218};
219#endif
220
Yuval Mintz25c089d2015-10-26 11:02:26 +0200221struct qed_eth_ops {
222 const struct qed_common_ops *common;
Yuval Mintz0b55e272016-05-11 16:36:15 +0300223#ifdef CONFIG_QED_SRIOV
224 const struct qed_iov_hv_ops *iov;
225#endif
Sudarsana Reddy Kallurua1d8d8a2016-06-08 06:22:11 -0400226#ifdef CONFIG_DCB
227 const struct qed_eth_dcbnl_ops *dcb;
228#endif
Yuval Mintz25c089d2015-10-26 11:02:26 +0200229
230 int (*fill_dev_info)(struct qed_dev *cdev,
231 struct qed_dev_eth_info *info);
232
Yuval Mintzcc875c22015-10-26 11:02:31 +0200233 void (*register_ops)(struct qed_dev *cdev,
234 struct qed_eth_cb_ops *ops,
235 void *cookie);
236
Yuval Mintzeff16962016-05-11 16:36:21 +0300237 bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
238
Manish Chopracee4d262015-10-26 11:02:28 +0200239 int (*vport_start)(struct qed_dev *cdev,
Manish Chopra088c8612016-03-04 12:35:05 -0500240 struct qed_start_vport_params *params);
Manish Chopracee4d262015-10-26 11:02:28 +0200241
242 int (*vport_stop)(struct qed_dev *cdev,
243 u8 vport_id);
244
245 int (*vport_update)(struct qed_dev *cdev,
246 struct qed_update_vport_params *params);
247
248 int (*q_rx_start)(struct qed_dev *cdev,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200249 u8 rss_num,
Manish Chopracee4d262015-10-26 11:02:28 +0200250 struct qed_queue_start_common_params *params,
251 u16 bd_max_bytes,
252 dma_addr_t bd_chain_phys_addr,
253 dma_addr_t cqe_pbl_addr,
254 u16 cqe_pbl_size,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200255 struct qed_rxq_start_ret_params *ret_params);
Manish Chopracee4d262015-10-26 11:02:28 +0200256
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200257 int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
Manish Chopracee4d262015-10-26 11:02:28 +0200258
259 int (*q_tx_start)(struct qed_dev *cdev,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200260 u8 rss_num,
Manish Chopracee4d262015-10-26 11:02:28 +0200261 struct qed_queue_start_common_params *params,
262 dma_addr_t pbl_addr,
263 u16 pbl_size,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200264 struct qed_txq_start_ret_params *ret_params);
Manish Chopracee4d262015-10-26 11:02:28 +0200265
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200266 int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
Manish Chopracee4d262015-10-26 11:02:28 +0200267
268 int (*filter_config)(struct qed_dev *cdev,
269 struct qed_filter_params *params);
270
271 int (*fastpath_stop)(struct qed_dev *cdev);
272
273 int (*eth_cqe_completion)(struct qed_dev *cdev,
274 u8 rss_id,
275 struct eth_slow_path_rx_cqe *cqe);
Manish Chopra9df2ed02015-10-26 11:02:33 +0200276
277 void (*get_vport_stats)(struct qed_dev *cdev,
278 struct qed_eth_stats *stats);
Manish Chopra464f6642016-04-14 01:38:29 -0400279
280 int (*tunn_config)(struct qed_dev *cdev,
281 struct qed_tunn_params *params);
Yuval Mintz25c089d2015-10-26 11:02:26 +0200282};
283
Rahul Verma95114342016-04-10 12:42:59 +0300284const struct qed_eth_ops *qed_get_eth_ops(void);
Yuval Mintz25c089d2015-10-26 11:02:26 +0200285void qed_put_eth_ops(void);
286
287#endif