New upstream version 17.11-rc3
[deb_dpdk.git] / drivers / net / qede / qede_if.h
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #ifndef _QEDE_IF_H
10 #define _QEDE_IF_H
11
12 #include "qede_ethdev.h"
13
14 /* forward */
15 struct ecore_dev;
16 struct qed_sb_info;
17 struct qed_pf_params;
18 enum ecore_int_mode;
19
20 struct qed_dev_info {
21         uint8_t num_hwfns;
22         uint8_t hw_mac[ETHER_ADDR_LEN];
23         bool is_mf_default;
24
25         /* FW version */
26         uint16_t fw_major;
27         uint16_t fw_minor;
28         uint16_t fw_rev;
29         uint16_t fw_eng;
30
31         /* MFW version */
32         uint32_t mfw_rev;
33 #define QED_MFW_VERSION_0_MASK          0x000000FF
34 #define QED_MFW_VERSION_0_OFFSET        0
35 #define QED_MFW_VERSION_1_MASK          0x0000FF00
36 #define QED_MFW_VERSION_1_OFFSET        8
37 #define QED_MFW_VERSION_2_MASK          0x00FF0000
38 #define QED_MFW_VERSION_2_OFFSET        16
39 #define QED_MFW_VERSION_3_MASK          0xFF000000
40 #define QED_MFW_VERSION_3_OFFSET        24
41
42         uint32_t flash_size;
43         bool b_arfs_capable;
44         bool b_inter_pf_switch;
45         bool tx_switching;
46         u16 mtu;
47
48         bool smart_an;
49
50         /* Out param for qede */
51         bool vxlan_enable;
52         bool gre_enable;
53         bool geneve_enable;
54
55         enum ecore_dev_type dev_type;
56 };
57
58 struct qed_dev_eth_info {
59         struct qed_dev_info common;
60
61         uint8_t num_queues;
62         uint8_t num_tc;
63
64         struct ether_addr port_mac;
65         uint16_t num_vlan_filters;
66         uint32_t num_mac_filters;
67
68         /* Legacy VF - this affects the datapath */
69         bool is_legacy;
70 };
71
72 #define INIT_STRUCT_FIELD(field, value) .field = value
73
74 struct qed_eth_ops {
75         const struct qed_common_ops *common;
76         int (*fill_dev_info)(struct ecore_dev *edev,
77                              struct qed_dev_eth_info *info);
78 };
79
80 struct qed_link_params {
81         bool link_up;
82
83 #define QED_LINK_OVERRIDE_SPEED_AUTONEG         (1 << 0)
84 #define QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS      (1 << 1)
85 #define QED_LINK_OVERRIDE_SPEED_FORCED_SPEED    (1 << 2)
86 #define QED_LINK_OVERRIDE_PAUSE_CONFIG          (1 << 3)
87 #define QED_LINK_OVERRIDE_EEE_CONFIG            (1 << 5)
88         uint32_t override_flags;
89         bool autoneg;
90         uint32_t adv_speeds;
91         uint32_t forced_speed;
92 #define QED_LINK_PAUSE_AUTONEG_ENABLE           (1 << 0)
93 #define QED_LINK_PAUSE_RX_ENABLE                (1 << 1)
94 #define QED_LINK_PAUSE_TX_ENABLE                (1 << 2)
95         uint32_t pause_config;
96         struct ecore_link_eee_params eee;
97 };
98
99 struct qed_link_output {
100         bool link_up;
101         uint32_t supported_caps;        /* In SUPPORTED defs */
102         uint32_t advertised_caps;       /* In ADVERTISED defs */
103         uint32_t lp_caps;       /* In ADVERTISED defs */
104         uint32_t speed;         /* In Mb/s */
105         uint32_t adv_speed;     /* Speed mask */
106         uint8_t duplex;         /* In DUPLEX defs */
107         uint16_t port;          /* In PORT defs */
108         bool autoneg;
109         uint32_t pause_config;
110
111         /* EEE - capability & param */
112         bool eee_supported;
113         bool eee_active;
114         u8 sup_caps;
115         struct ecore_link_eee_params eee;
116 };
117
118 struct qed_slowpath_params {
119         uint32_t int_mode;
120         uint8_t drv_major;
121         uint8_t drv_minor;
122         uint8_t drv_rev;
123         uint8_t drv_eng;
124         uint8_t name[NAME_SIZE];
125 };
126
127 struct qed_common_cb_ops {
128         void (*link_update)(void *dev, struct qed_link_output *link);
129 };
130
131 struct qed_common_ops {
132         int (*probe)(struct ecore_dev *edev,
133                      struct rte_pci_device *pci_dev,
134                      uint32_t dp_module, uint8_t dp_level, bool is_vf);
135         void (*set_name)(struct ecore_dev *edev, char name[]);
136         enum _ecore_status_t
137                 (*chain_alloc)(struct ecore_dev *edev,
138                                enum ecore_chain_use_mode
139                                intended_use,
140                                enum ecore_chain_mode mode,
141                                enum ecore_chain_cnt_type cnt_type,
142                                uint32_t num_elems,
143                                osal_size_t elem_size,
144                                struct ecore_chain *p_chain,
145                                struct ecore_chain_ext_pbl *ext_pbl);
146
147         void (*chain_free)(struct ecore_dev *edev,
148                            struct ecore_chain *p_chain);
149
150         void (*get_link)(struct ecore_dev *edev,
151                          struct qed_link_output *if_link);
152         int (*set_link)(struct ecore_dev *edev,
153                         struct qed_link_params *params);
154
155         int (*drain)(struct ecore_dev *edev);
156
157         void (*remove)(struct ecore_dev *edev);
158
159         int (*slowpath_stop)(struct ecore_dev *edev);
160
161         void (*update_pf_params)(struct ecore_dev *edev,
162                                  struct ecore_pf_params *params);
163
164         int (*slowpath_start)(struct ecore_dev *edev,
165                               struct qed_slowpath_params *params);
166
167         int (*set_fp_int)(struct ecore_dev *edev, uint16_t cnt);
168
169         uint32_t (*sb_init)(struct ecore_dev *edev,
170                             struct ecore_sb_info *sb_info,
171                             void *sb_virt_addr,
172                             dma_addr_t sb_phy_addr,
173                             uint16_t sb_id);
174
175         int (*get_sb_info)(struct ecore_dev *edev,
176                            struct ecore_sb_info *sb, u16 qid,
177                            struct ecore_sb_info_dbg *sb_dbg);
178
179         bool (*can_link_change)(struct ecore_dev *edev);
180
181         void (*update_msglvl)(struct ecore_dev *edev,
182                               uint32_t dp_module, uint8_t dp_level);
183
184         int (*send_drv_state)(struct ecore_dev *edev, bool active);
185 };
186
187 /* Externs */
188
189 const struct qed_eth_ops *qed_get_eth_ops(void);
190
191 #endif /* _QEDE_IF_H */