blob: 7a52f7c58c37ca1942ab29388ad9110282fd5480 [file] [log] [blame]
Yuval Mintz25c089d2015-10-26 11:02:26 +02001/* 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
9#ifndef _QED_ETH_IF_H
10#define _QED_ETH_IF_H
11
12#include <linux/list.h>
13#include <linux/if_link.h>
14#include <linux/qed/eth_common.h>
15#include <linux/qed/qed_if.h>
Yuval Mintz0b55e272016-05-11 16:36:15 +030016#include <linux/qed/qed_iov_if.h>
Yuval Mintz25c089d2015-10-26 11:02:26 +020017
Mintz, Yuval3da7a372016-11-29 16:47:06 +020018struct qed_queue_start_common_params {
19 /* Should always be relative to entity sending this. */
20 u8 vport_id;
21 u16 queue_id;
22
23 /* Relative, but relevant only for PFs */
24 u8 stats_id;
25
26 /* These are always absolute */
27 u16 sb;
28 u8 sb_idx;
29};
30
31struct qed_rxq_start_ret_params {
32 void __iomem *p_prod;
33 void *p_handle;
34};
35
36struct qed_txq_start_ret_params {
37 void __iomem *p_doorbell;
38 void *p_handle;
39};
40
Yuval Mintz25c089d2015-10-26 11:02:26 +020041struct qed_dev_eth_info {
42 struct qed_dev_info common;
43
44 u8 num_queues;
45 u8 num_tc;
46
47 u8 port_mac[ETH_ALEN];
Tomer Tayar2edbff82016-10-31 07:14:27 +020048 u16 num_vlan_filters;
Yuval Mintz7b7e70f2016-10-14 05:19:20 -040049 u16 num_mac_filters;
Yuval Mintzd8c2c7e2016-08-22 13:25:11 +030050
51 /* Legacy VF - this affects the datapath, so qede has to know */
52 bool is_legacy;
Yuval Mintz25c089d2015-10-26 11:02:26 +020053};
54
Manish Chopracee4d262015-10-26 11:02:28 +020055struct qed_update_vport_rss_params {
56 u16 rss_ind_table[128];
57 u32 rss_key[10];
Sudarsana Reddy Kalluru8c5ebd02016-04-10 12:43:00 +030058 u8 rss_caps;
Manish Chopracee4d262015-10-26 11:02:28 +020059};
60
61struct qed_update_vport_params {
62 u8 vport_id;
63 u8 update_vport_active_flg;
64 u8 vport_active_flg;
Yuval Mintz831bfb0e2016-05-11 16:36:25 +030065 u8 update_tx_switching_flg;
66 u8 tx_switching_flg;
Yuval Mintz3f9b4a62016-02-18 17:00:39 +020067 u8 update_accept_any_vlan_flg;
68 u8 accept_any_vlan;
Manish Chopracee4d262015-10-26 11:02:28 +020069 u8 update_rss_flg;
70 struct qed_update_vport_rss_params rss_params;
71};
72
Manish Chopra088c8612016-03-04 12:35:05 -050073struct qed_start_vport_params {
74 bool remove_inner_vlan;
75 bool gro_enable;
76 bool drop_ttl0;
77 u8 vport_id;
78 u16 mtu;
Yuval Mintza0d26d52016-06-19 15:18:13 +030079 bool clear_stats;
Manish Chopra088c8612016-03-04 12:35:05 -050080};
81
Manish Chopracee4d262015-10-26 11:02:28 +020082enum qed_filter_rx_mode_type {
83 QED_FILTER_RX_MODE_TYPE_REGULAR,
84 QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
85 QED_FILTER_RX_MODE_TYPE_PROMISC,
86};
87
88enum qed_filter_xcast_params_type {
89 QED_FILTER_XCAST_TYPE_ADD,
90 QED_FILTER_XCAST_TYPE_DEL,
91 QED_FILTER_XCAST_TYPE_REPLACE,
92};
93
94struct qed_filter_ucast_params {
95 enum qed_filter_xcast_params_type type;
96 u8 vlan_valid;
97 u16 vlan;
98 u8 mac_valid;
99 unsigned char mac[ETH_ALEN];
100};
101
102struct qed_filter_mcast_params {
103 enum qed_filter_xcast_params_type type;
104 u8 num;
105 unsigned char mac[64][ETH_ALEN];
106};
107
108union qed_filter_type_params {
109 enum qed_filter_rx_mode_type accept_flags;
110 struct qed_filter_ucast_params ucast;
111 struct qed_filter_mcast_params mcast;
112};
113
114enum qed_filter_type {
115 QED_FILTER_TYPE_UCAST,
116 QED_FILTER_TYPE_MCAST,
117 QED_FILTER_TYPE_RX_MODE,
118 QED_MAX_FILTER_TYPES,
119};
120
121struct qed_filter_params {
122 enum qed_filter_type type;
123 union qed_filter_type_params filter;
124};
125
Manish Chopra464f6642016-04-14 01:38:29 -0400126struct qed_tunn_params {
127 u16 vxlan_port;
128 u8 update_vxlan_port;
129 u16 geneve_port;
130 u8 update_geneve_port;
131};
132
Manish Chopracee4d262015-10-26 11:02:28 +0200133struct qed_eth_cb_ops {
134 struct qed_common_cb_ops common;
Yuval Mintzc3aaa402016-10-14 05:19:17 -0400135 void (*force_mac) (void *dev, u8 *mac, bool forced);
Manish Chopracee4d262015-10-26 11:02:28 +0200136};
137
Sudarsana Reddy Kallurua1d8d8a2016-06-08 06:22:11 -0400138#ifdef CONFIG_DCB
139/* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
140 * of dcbnl_rtnl_ops structure.
141 */
142struct qed_eth_dcbnl_ops {
143 /* IEEE 802.1Qaz std */
144 int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
145 int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
146 int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
147 int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
148 int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
149 int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
150 int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
151 int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
152
153 /* CEE std */
154 u8 (*getstate)(struct qed_dev *cdev);
155 u8 (*setstate)(struct qed_dev *cdev, u8 state);
156 void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
157 u8 *pgid, u8 *bw_pct, u8 *up_map);
158 void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
159 void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
160 u8 *pgid, u8 *bw_pct, u8 *up_map);
161 void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
162 void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
163 void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
164 u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
165 int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
166 u8 (*getpfcstate)(struct qed_dev *cdev);
167 int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
168 u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
169
170 /* DCBX configuration */
171 u8 (*getdcbx)(struct qed_dev *cdev);
172 void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
173 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
174 void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
175 u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
176 void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
177 void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
178 u8 (*setall)(struct qed_dev *cdev);
179 int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
180 void (*setpfcstate)(struct qed_dev *cdev, u8 state);
181 int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
182 u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
183 u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
184
185 /* Peer apps */
186 int (*peer_getappinfo)(struct qed_dev *cdev,
187 struct dcb_peer_app_info *info,
188 u16 *app_count);
189 int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
190
191 /* CEE peer */
192 int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
193 int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
194};
195#endif
196
Yuval Mintz25c089d2015-10-26 11:02:26 +0200197struct qed_eth_ops {
198 const struct qed_common_ops *common;
Yuval Mintz0b55e272016-05-11 16:36:15 +0300199#ifdef CONFIG_QED_SRIOV
200 const struct qed_iov_hv_ops *iov;
201#endif
Sudarsana Reddy Kallurua1d8d8a2016-06-08 06:22:11 -0400202#ifdef CONFIG_DCB
203 const struct qed_eth_dcbnl_ops *dcb;
204#endif
Yuval Mintz25c089d2015-10-26 11:02:26 +0200205
206 int (*fill_dev_info)(struct qed_dev *cdev,
207 struct qed_dev_eth_info *info);
208
Yuval Mintzcc875c22015-10-26 11:02:31 +0200209 void (*register_ops)(struct qed_dev *cdev,
210 struct qed_eth_cb_ops *ops,
211 void *cookie);
212
Yuval Mintzeff16962016-05-11 16:36:21 +0300213 bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
214
Manish Chopracee4d262015-10-26 11:02:28 +0200215 int (*vport_start)(struct qed_dev *cdev,
Manish Chopra088c8612016-03-04 12:35:05 -0500216 struct qed_start_vport_params *params);
Manish Chopracee4d262015-10-26 11:02:28 +0200217
218 int (*vport_stop)(struct qed_dev *cdev,
219 u8 vport_id);
220
221 int (*vport_update)(struct qed_dev *cdev,
222 struct qed_update_vport_params *params);
223
224 int (*q_rx_start)(struct qed_dev *cdev,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200225 u8 rss_num,
Manish Chopracee4d262015-10-26 11:02:28 +0200226 struct qed_queue_start_common_params *params,
227 u16 bd_max_bytes,
228 dma_addr_t bd_chain_phys_addr,
229 dma_addr_t cqe_pbl_addr,
230 u16 cqe_pbl_size,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200231 struct qed_rxq_start_ret_params *ret_params);
Manish Chopracee4d262015-10-26 11:02:28 +0200232
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200233 int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
Manish Chopracee4d262015-10-26 11:02:28 +0200234
235 int (*q_tx_start)(struct qed_dev *cdev,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200236 u8 rss_num,
Manish Chopracee4d262015-10-26 11:02:28 +0200237 struct qed_queue_start_common_params *params,
238 dma_addr_t pbl_addr,
239 u16 pbl_size,
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200240 struct qed_txq_start_ret_params *ret_params);
Manish Chopracee4d262015-10-26 11:02:28 +0200241
Mintz, Yuval3da7a372016-11-29 16:47:06 +0200242 int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
Manish Chopracee4d262015-10-26 11:02:28 +0200243
244 int (*filter_config)(struct qed_dev *cdev,
245 struct qed_filter_params *params);
246
247 int (*fastpath_stop)(struct qed_dev *cdev);
248
249 int (*eth_cqe_completion)(struct qed_dev *cdev,
250 u8 rss_id,
251 struct eth_slow_path_rx_cqe *cqe);
Manish Chopra9df2ed02015-10-26 11:02:33 +0200252
253 void (*get_vport_stats)(struct qed_dev *cdev,
254 struct qed_eth_stats *stats);
Manish Chopra464f6642016-04-14 01:38:29 -0400255
256 int (*tunn_config)(struct qed_dev *cdev,
257 struct qed_tunn_params *params);
Yuval Mintz25c089d2015-10-26 11:02:26 +0200258};
259
Rahul Verma95114342016-04-10 12:42:59 +0300260const struct qed_eth_ops *qed_get_eth_ops(void);
Yuval Mintz25c089d2015-10-26 11:02:26 +0200261void qed_put_eth_ops(void);
262
263#endif