net/i40e: fix Rx packet statistics
[dpdk.git] / drivers / net / qede / qede_if.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6
7 #ifndef _QEDE_IF_H
8 #define _QEDE_IF_H
9
10 #include "qede_ethdev.h"
11
12 /* forward */
13 struct ecore_dev;
14 struct qed_sb_info;
15 struct qed_pf_params;
16 enum ecore_int_mode;
17
18 struct qed_dev_info {
19         uint8_t num_hwfns;
20         uint8_t hw_mac[RTE_ETHER_ADDR_LEN];
21         bool is_mf_default;
22
23         /* FW version */
24         uint16_t fw_major;
25         uint16_t fw_minor;
26         uint16_t fw_rev;
27         uint16_t fw_eng;
28
29         /* MFW version */
30         uint32_t mfw_rev;
31 #define QED_MFW_VERSION_0_MASK          0x000000FF
32 #define QED_MFW_VERSION_0_OFFSET        0
33 #define QED_MFW_VERSION_1_MASK          0x0000FF00
34 #define QED_MFW_VERSION_1_OFFSET        8
35 #define QED_MFW_VERSION_2_MASK          0x00FF0000
36 #define QED_MFW_VERSION_2_OFFSET        16
37 #define QED_MFW_VERSION_3_MASK          0xFF000000
38 #define QED_MFW_VERSION_3_OFFSET        24
39
40         uint32_t flash_size;
41         bool b_arfs_capable;
42         bool b_inter_pf_switch;
43         bool tx_switching;
44         u16 mtu;
45
46         bool smart_an;
47
48         /* MBI version */
49         uint32_t mbi_version;
50 #define QED_MBI_VERSION_0_MASK          0x000000FF
51 #define QED_MBI_VERSION_0_OFFSET        0
52 #define QED_MBI_VERSION_1_MASK          0x0000FF00
53 #define QED_MBI_VERSION_1_OFFSET        8
54 #define QED_MBI_VERSION_2_MASK          0x00FF0000
55 #define QED_MBI_VERSION_2_OFFSET        16
56
57         /* Out param for qede */
58         bool vxlan_enable;
59         bool gre_enable;
60         bool geneve_enable;
61
62         enum ecore_dev_type dev_type;
63 };
64
65 struct qed_dev_eth_info {
66         struct qed_dev_info common;
67
68         uint8_t num_queues;
69         uint8_t num_tc;
70
71         struct rte_ether_addr port_mac;
72         uint16_t num_vlan_filters;
73         uint32_t num_mac_filters;
74
75         /* Legacy VF - this affects the datapath */
76         bool is_legacy;
77 };
78
79 #define INIT_STRUCT_FIELD(field, value) .field = value
80
81 struct qed_eth_ops {
82         const struct qed_common_ops *common;
83         int (*fill_dev_info)(struct ecore_dev *edev,
84                              struct qed_dev_eth_info *info);
85         void (*sriov_configure)(struct ecore_dev *edev, int num_vfs);
86 };
87
88 struct qed_link_params {
89         bool link_up;
90
91 #define QED_LINK_OVERRIDE_SPEED_AUTONEG         (1 << 0)
92 #define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS      (1 << 1)
93 #define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED    (1 << 2)
94 #define QED_LINK_OVERRIDE_PAUSE_CONFIG          (1 << 3)
95 #define QED_LINK_OVERRIDE_EEE_CONFIG            (1 << 5)
96         uint32_t override_flags;
97         bool autoneg;
98         uint32_t adv_speeds;
99         uint32_t forced_speed;
100 #define QED_LINK_PAUSE_AUTONEG_ENABLE           (1 << 0)
101 #define QED_LINK_PAUSE_RX_ENABLE                (1 << 1)
102 #define QED_LINK_PAUSE_TX_ENABLE                (1 << 2)
103         uint32_t pause_config;
104         struct ecore_link_eee_params eee;
105 };
106
107 struct qed_link_output {
108         bool link_up;
109         uint32_t supported_caps;        /* In SUPPORTED defs */
110         uint32_t advertised_caps;       /* In ADVERTISED defs */
111         uint32_t lp_caps;       /* In ADVERTISED defs */
112         uint32_t speed;         /* In Mb/s */
113         uint32_t adv_speed;     /* Speed mask */
114         uint8_t duplex;         /* In DUPLEX defs */
115         uint16_t port;          /* In PORT defs */
116         bool autoneg;
117         uint32_t pause_config;
118
119         /* EEE - capability & param */
120         bool eee_supported;
121         bool eee_active;
122         u8 sup_caps;
123         struct ecore_link_eee_params eee;
124 };
125
126 struct qed_slowpath_params {
127         uint32_t int_mode;
128         uint8_t drv_major;
129         uint8_t drv_minor;
130         uint8_t drv_rev;
131         uint8_t drv_eng;
132         uint8_t name[NAME_SIZE];
133 };
134
135 struct qed_common_cb_ops {
136         void (*link_update)(void *dev, struct qed_link_output *link);
137 };
138
139 struct qed_common_ops {
140         int (*probe)(struct ecore_dev *edev,
141                      struct rte_pci_device *pci_dev,
142                      uint32_t dp_module, uint8_t dp_level, bool is_vf);
143         void (*set_name)(struct ecore_dev *edev, char name[]);
144         enum _ecore_status_t
145                 (*chain_alloc)(struct ecore_dev *edev,
146                                enum ecore_chain_use_mode
147                                intended_use,
148                                enum ecore_chain_mode mode,
149                                enum ecore_chain_cnt_type cnt_type,
150                                uint32_t num_elems,
151                                osal_size_t elem_size,
152                                struct ecore_chain *p_chain,
153                                struct ecore_chain_ext_pbl *ext_pbl);
154
155         void (*chain_free)(struct ecore_dev *edev,
156                            struct ecore_chain *p_chain);
157
158         void (*get_link)(struct ecore_dev *edev,
159                          struct qed_link_output *if_link);
160         int (*set_link)(struct ecore_dev *edev,
161                         struct qed_link_params *params);
162
163         int (*drain)(struct ecore_dev *edev);
164
165         void (*remove)(struct ecore_dev *edev);
166
167         int (*slowpath_stop)(struct ecore_dev *edev);
168
169         void (*update_pf_params)(struct ecore_dev *edev,
170                                  struct ecore_pf_params *params);
171
172         int (*slowpath_start)(struct ecore_dev *edev,
173                               struct qed_slowpath_params *params);
174
175         int (*set_fp_int)(struct ecore_dev *edev, uint16_t cnt);
176
177         uint32_t (*sb_init)(struct ecore_dev *edev,
178                             struct ecore_sb_info *sb_info,
179                             void *sb_virt_addr,
180                             dma_addr_t sb_phy_addr,
181                             uint16_t sb_id);
182
183         int (*get_sb_info)(struct ecore_dev *edev,
184                            struct ecore_sb_info *sb, u16 qid,
185                            struct ecore_sb_info_dbg *sb_dbg);
186
187         bool (*can_link_change)(struct ecore_dev *edev);
188
189         void (*update_msglvl)(struct ecore_dev *edev,
190                               uint32_t dp_module, uint8_t dp_level);
191
192         int (*send_drv_state)(struct ecore_dev *edev, bool active);
193
194         /* ###############  DEBUG *************************/
195
196         int     (*dbg_grc)(struct ecore_dev       *edev,
197                            void          *buffer,
198                            u32            *num_dumped_bytes);
199         int     (*dbg_grc_size)(struct ecore_dev *edev);
200
201         int     (*dbg_idle_chk)(struct ecore_dev  *edev,
202                                 void        *buffer,
203                                 u32          *num_dumped_bytes);
204         int     (*dbg_idle_chk_size)(struct ecore_dev *edev);
205
206         int     (*dbg_reg_fifo)(struct ecore_dev  *edev,
207                                 void        *buffer,
208                                 u32          *num_dumped_bytes);
209         int     (*dbg_reg_fifo_size)(struct ecore_dev *edev);
210
211         int     (*dbg_mcp_trace)(struct ecore_dev *edev,
212                                  void      *buffer,
213                                  u32        *num_dumped_bytes);
214         int     (*dbg_mcp_trace_size)(struct ecore_dev *edev);
215
216         int     (*dbg_protection_override)(struct ecore_dev *edev, void *buffer,
217                                            u32 *num_dumped_bytes);
218         int     (*dbg_protection_override_size)(struct ecore_dev *edev);
219
220         int     (*dbg_igu_fifo_size)(struct ecore_dev *edev);
221         int     (*dbg_igu_fifo)(struct ecore_dev *edev, void *buffer,
222                                 u32 *num_dumped_bytes);
223
224         int     (*dbg_fw_asserts)(struct ecore_dev *edev, void *buffer,
225                                   u32 *num_dumped_bytes);
226
227         int     (*dbg_fw_asserts_size)(struct ecore_dev *edev);
228
229         int     (*dbg_ilt)(struct ecore_dev *edev, void *buffer,
230                            u32 *num_dumped_bytes);
231
232         int     (*dbg_ilt_size)(struct ecore_dev *edev);
233
234         u8      (*dbg_get_debug_engine)(struct ecore_dev *edev);
235         void    (*dbg_set_debug_engine)(struct ecore_dev  *edev,
236                                         int          engine_number);
237
238 };
239
240 /* Externs */
241
242 const struct qed_eth_ops *qed_get_eth_ops(void);
243
244 #endif /* _QEDE_IF_H */