Merge tag 'media/v4.8-7' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[cascardo/linux.git] / include / linux / qed / qed_eth_if.h
1 /* 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>
16 #include <linux/qed/qed_iov_if.h>
17
18 struct qed_dev_eth_info {
19         struct qed_dev_info common;
20
21         u8      num_queues;
22         u8      num_tc;
23
24         u8      port_mac[ETH_ALEN];
25         u8      num_vlan_filters;
26 };
27
28 struct qed_update_vport_rss_params {
29         u16     rss_ind_table[128];
30         u32     rss_key[10];
31         u8      rss_caps;
32 };
33
34 struct qed_update_vport_params {
35         u8 vport_id;
36         u8 update_vport_active_flg;
37         u8 vport_active_flg;
38         u8 update_tx_switching_flg;
39         u8 tx_switching_flg;
40         u8 update_accept_any_vlan_flg;
41         u8 accept_any_vlan;
42         u8 update_rss_flg;
43         struct qed_update_vport_rss_params rss_params;
44 };
45
46 struct qed_start_vport_params {
47         bool remove_inner_vlan;
48         bool gro_enable;
49         bool drop_ttl0;
50         u8 vport_id;
51         u16 mtu;
52         bool clear_stats;
53 };
54
55 struct qed_stop_rxq_params {
56         u8 rss_id;
57         u8 rx_queue_id;
58         u8 vport_id;
59         bool eq_completion_only;
60 };
61
62 struct qed_stop_txq_params {
63         u8 rss_id;
64         u8 tx_queue_id;
65 };
66
67 enum qed_filter_rx_mode_type {
68         QED_FILTER_RX_MODE_TYPE_REGULAR,
69         QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
70         QED_FILTER_RX_MODE_TYPE_PROMISC,
71 };
72
73 enum qed_filter_xcast_params_type {
74         QED_FILTER_XCAST_TYPE_ADD,
75         QED_FILTER_XCAST_TYPE_DEL,
76         QED_FILTER_XCAST_TYPE_REPLACE,
77 };
78
79 struct qed_filter_ucast_params {
80         enum qed_filter_xcast_params_type type;
81         u8 vlan_valid;
82         u16 vlan;
83         u8 mac_valid;
84         unsigned char mac[ETH_ALEN];
85 };
86
87 struct qed_filter_mcast_params {
88         enum qed_filter_xcast_params_type type;
89         u8 num;
90         unsigned char mac[64][ETH_ALEN];
91 };
92
93 union qed_filter_type_params {
94         enum qed_filter_rx_mode_type accept_flags;
95         struct qed_filter_ucast_params ucast;
96         struct qed_filter_mcast_params mcast;
97 };
98
99 enum qed_filter_type {
100         QED_FILTER_TYPE_UCAST,
101         QED_FILTER_TYPE_MCAST,
102         QED_FILTER_TYPE_RX_MODE,
103         QED_MAX_FILTER_TYPES,
104 };
105
106 struct qed_filter_params {
107         enum qed_filter_type type;
108         union qed_filter_type_params filter;
109 };
110
111 struct qed_queue_start_common_params {
112         u8 rss_id;
113         u8 queue_id;
114         u8 vport_id;
115         u16 sb;
116         u16 sb_idx;
117         u16 vf_qid;
118 };
119
120 struct qed_tunn_params {
121         u16 vxlan_port;
122         u8 update_vxlan_port;
123         u16 geneve_port;
124         u8 update_geneve_port;
125 };
126
127 struct qed_eth_cb_ops {
128         struct qed_common_cb_ops common;
129         void (*force_mac) (void *dev, u8 *mac);
130 };
131
132 #ifdef CONFIG_DCB
133 /* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
134  * of dcbnl_rtnl_ops structure.
135  */
136 struct qed_eth_dcbnl_ops {
137         /* IEEE 802.1Qaz std */
138         int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
139         int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
140         int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
141         int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
142         int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
143         int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
144         int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
145         int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
146
147         /* CEE std */
148         u8 (*getstate)(struct qed_dev *cdev);
149         u8 (*setstate)(struct qed_dev *cdev, u8 state);
150         void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
151                              u8 *pgid, u8 *bw_pct, u8 *up_map);
152         void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
153         void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
154                              u8 *pgid, u8 *bw_pct, u8 *up_map);
155         void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
156         void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
157         void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
158         u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
159         int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
160         u8 (*getpfcstate)(struct qed_dev *cdev);
161         int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
162         u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
163
164         /* DCBX configuration */
165         u8 (*getdcbx)(struct qed_dev *cdev);
166         void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
167                              u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
168         void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
169                              u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
170         void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
171         void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
172         u8 (*setall)(struct qed_dev *cdev);
173         int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
174         void (*setpfcstate)(struct qed_dev *cdev, u8 state);
175         int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
176         u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
177         u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
178
179         /* Peer apps */
180         int (*peer_getappinfo)(struct qed_dev *cdev,
181                                struct dcb_peer_app_info *info,
182                                u16 *app_count);
183         int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
184
185         /* CEE peer */
186         int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
187         int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
188 };
189 #endif
190
191 struct qed_eth_ops {
192         const struct qed_common_ops *common;
193 #ifdef CONFIG_QED_SRIOV
194         const struct qed_iov_hv_ops *iov;
195 #endif
196 #ifdef CONFIG_DCB
197         const struct qed_eth_dcbnl_ops *dcb;
198 #endif
199
200         int (*fill_dev_info)(struct qed_dev *cdev,
201                              struct qed_dev_eth_info *info);
202
203         void (*register_ops)(struct qed_dev *cdev,
204                              struct qed_eth_cb_ops *ops,
205                              void *cookie);
206
207          bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
208
209         int (*vport_start)(struct qed_dev *cdev,
210                            struct qed_start_vport_params *params);
211
212         int (*vport_stop)(struct qed_dev *cdev,
213                           u8 vport_id);
214
215         int (*vport_update)(struct qed_dev *cdev,
216                             struct qed_update_vport_params *params);
217
218         int (*q_rx_start)(struct qed_dev *cdev,
219                           struct qed_queue_start_common_params *params,
220                           u16 bd_max_bytes,
221                           dma_addr_t bd_chain_phys_addr,
222                           dma_addr_t cqe_pbl_addr,
223                           u16 cqe_pbl_size,
224                           void __iomem **pp_prod);
225
226         int (*q_rx_stop)(struct qed_dev *cdev,
227                          struct qed_stop_rxq_params *params);
228
229         int (*q_tx_start)(struct qed_dev *cdev,
230                           struct qed_queue_start_common_params *params,
231                           dma_addr_t pbl_addr,
232                           u16 pbl_size,
233                           void __iomem **pp_doorbell);
234
235         int (*q_tx_stop)(struct qed_dev *cdev,
236                          struct qed_stop_txq_params *params);
237
238         int (*filter_config)(struct qed_dev *cdev,
239                              struct qed_filter_params *params);
240
241         int (*fastpath_stop)(struct qed_dev *cdev);
242
243         int (*eth_cqe_completion)(struct qed_dev *cdev,
244                                   u8 rss_id,
245                                   struct eth_slow_path_rx_cqe *cqe);
246
247         void (*get_vport_stats)(struct qed_dev *cdev,
248                                 struct qed_eth_stats *stats);
249
250         int (*tunn_config)(struct qed_dev *cdev,
251                            struct qed_tunn_params *params);
252 };
253
254 const struct qed_eth_ops *qed_get_eth_ops(void);
255 void qed_put_eth_ops(void);
256
257 #endif