6d0616e57bfcdfd5637e8e68545996da0214da72
[dpdk.git] / drivers / net / qede / qede_ethdev.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
10 #ifndef _QEDE_ETHDEV_H_
11 #define _QEDE_ETHDEV_H_
12
13 #include <sys/queue.h>
14
15 #include <rte_ether.h>
16 #include <rte_ethdev.h>
17 #include <rte_dev.h>
18
19 /* ecore includes */
20 #include "base/bcm_osal.h"
21 #include "base/ecore.h"
22 #include "base/ecore_dev_api.h"
23 #include "base/ecore_l2_api.h"
24 #include "base/ecore_vf_api.h"
25 #include "base/ecore_hsi_common.h"
26 #include "base/ecore_int_api.h"
27 #include "base/ecore_chain.h"
28 #include "base/ecore_status.h"
29 #include "base/ecore_hsi_eth.h"
30 #include "base/ecore_dev_api.h"
31 #include "base/ecore_iov_api.h"
32 #include "base/ecore_cxt.h"
33 #include "base/nvm_cfg.h"
34 #include "base/ecore_iov_api.h"
35 #include "base/ecore_sp_commands.h"
36
37 #include "qede_logs.h"
38 #include "qede_if.h"
39 #include "qede_eth_if.h"
40
41 #include "qede_rxtx.h"
42
43 #define qede_stringify1(x...)           #x
44 #define qede_stringify(x...)            qede_stringify1(x)
45
46 /* Driver versions */
47 #define QEDE_PMD_VER_PREFIX             "QEDE PMD"
48 #define QEDE_PMD_VERSION_MAJOR          1
49 #define QEDE_PMD_VERSION_MINOR          2
50 #define QEDE_PMD_VERSION_REVISION       0
51 #define QEDE_PMD_VERSION_PATCH          1
52
53 #define QEDE_PMD_VERSION qede_stringify(QEDE_PMD_VERSION_MAJOR) "."     \
54                          qede_stringify(QEDE_PMD_VERSION_MINOR) "."     \
55                          qede_stringify(QEDE_PMD_VERSION_REVISION) "."  \
56                          qede_stringify(QEDE_PMD_VERSION_PATCH)
57
58 #define QEDE_PMD_DRV_VER_STR_SIZE NAME_SIZE
59 #define QEDE_PMD_VER_PREFIX "QEDE PMD"
60
61
62 #define QEDE_RSS_INDIR_INITED     (1 << 0)
63 #define QEDE_RSS_KEY_INITED       (1 << 1)
64 #define QEDE_RSS_CAPS_INITED      (1 << 2)
65
66 #define QEDE_MAX_RSS_CNT(edev)  ((edev)->dev_info.num_queues)
67 #define QEDE_MAX_TSS_CNT(edev)  ((edev)->dev_info.num_queues * \
68                                         (edev)->dev_info.num_tc)
69
70 #define QEDE_QUEUE_CNT(qdev) ((qdev)->num_queues)
71 #define QEDE_RSS_COUNT(qdev) ((qdev)->num_queues - (qdev)->fp_num_tx)
72 #define QEDE_TSS_COUNT(qdev) (((qdev)->num_queues - (qdev)->fp_num_rx) * \
73                                         (qdev)->num_tc)
74
75 #define QEDE_FASTPATH_TX        (1 << 0)
76 #define QEDE_FASTPATH_RX        (1 << 1)
77
78 #define QEDE_DUPLEX_FULL        1
79 #define QEDE_DUPLEX_HALF        2
80 #define QEDE_DUPLEX_UNKNOWN     0xff
81
82 #define QEDE_SUPPORTED_AUTONEG (1 << 6)
83 #define QEDE_SUPPORTED_PAUSE   (1 << 13)
84
85 #define QEDE_INIT_QDEV(eth_dev) (eth_dev->data->dev_private)
86
87 #define QEDE_INIT_EDEV(adapter) (&((struct qede_dev *)adapter)->edev)
88
89 #define QEDE_INIT(eth_dev) {                                    \
90         struct qede_dev *qdev = eth_dev->data->dev_private;     \
91         struct ecore_dev *edev = &qdev->edev;                   \
92 }
93
94 /************* QLogic 25G/40G/100G vendor/devices ids *************/
95 #define PCI_VENDOR_ID_QLOGIC            0x1077
96
97 #define CHIP_NUM_57980E                 0x1634
98 #define CHIP_NUM_57980S                 0x1629
99 #define CHIP_NUM_VF                     0x1630
100 #define CHIP_NUM_57980S_40              0x1634
101 #define CHIP_NUM_57980S_25              0x1656
102 #define CHIP_NUM_57980S_IOV             0x1664
103 #define CHIP_NUM_57980S_100             0x1644
104
105 #define PCI_DEVICE_ID_NX2_57980E        CHIP_NUM_57980E
106 #define PCI_DEVICE_ID_NX2_57980S        CHIP_NUM_57980S
107 #define PCI_DEVICE_ID_NX2_VF            CHIP_NUM_VF
108 #define PCI_DEVICE_ID_57980S_40         CHIP_NUM_57980S_40
109 #define PCI_DEVICE_ID_57980S_25         CHIP_NUM_57980S_25
110 #define PCI_DEVICE_ID_57980S_IOV        CHIP_NUM_57980S_IOV
111 #define PCI_DEVICE_ID_57980S_100        CHIP_NUM_57980S_100
112
113 #define QEDE_VXLAN_DEF_PORT             8472
114
115 extern char fw_file[];
116
117 /* Port/function states */
118 enum qede_dev_state {
119         QEDE_DEV_INIT, /* Init the chip and Slowpath */
120         QEDE_DEV_CONFIG, /* Create Vport/Fastpath resources */
121         QEDE_DEV_START, /* Start RX/TX queues, enable traffic */
122         QEDE_DEV_STOP, /* Deactivate vport and stop traffic */
123 };
124
125 struct qede_vlan_entry {
126         SLIST_ENTRY(qede_vlan_entry) list;
127         uint16_t vid;
128 };
129
130 struct qede_mcast_entry {
131         struct ether_addr mac;
132         SLIST_ENTRY(qede_mcast_entry) list;
133 };
134
135 struct qede_ucast_entry {
136         struct ether_addr mac;
137         uint16_t vlan;
138         uint16_t vni;
139         SLIST_ENTRY(qede_ucast_entry) list;
140 };
141
142 /*
143  *  Structure to store private data for each port.
144  */
145 struct qede_dev {
146         struct ecore_dev edev;
147         uint8_t protocol;
148         const struct qed_eth_ops *ops;
149         struct qed_dev_eth_info dev_info;
150         struct ecore_sb_info *sb_array;
151         struct qede_fastpath *fp_array;
152         uint8_t num_tc;
153         uint16_t mtu;
154         bool rss_enabled;
155         struct qed_update_vport_rss_params rss_params;
156         uint32_t flags;
157         bool gro_disable;
158         uint16_t num_queues;
159         uint8_t fp_num_tx;
160         uint8_t fp_num_rx;
161         enum qede_dev_state state;
162         SLIST_HEAD(vlan_list_head, qede_vlan_entry)vlan_list_head;
163         uint16_t configured_vlans;
164         bool accept_any_vlan;
165         struct ether_addr primary_mac;
166         SLIST_HEAD(mc_list_head, qede_mcast_entry) mc_list_head;
167         uint16_t num_mc_addr;
168         SLIST_HEAD(uc_list_head, qede_ucast_entry) uc_list_head;
169         uint16_t num_uc_addr;
170         bool handle_hw_err;
171         uint16_t num_tunn_filters;
172         uint16_t vxlan_filter_type;
173         char drv_ver[QEDE_PMD_DRV_VER_STR_SIZE];
174 };
175
176 /* Static functions */
177 static int qede_vlan_filter_set(struct rte_eth_dev *eth_dev,
178                                 uint16_t vlan_id, int on);
179
180 static int qede_rss_hash_update(struct rte_eth_dev *eth_dev,
181                                 struct rte_eth_rss_conf *rss_conf);
182
183 static int qede_rss_reta_update(struct rte_eth_dev *eth_dev,
184                                 struct rte_eth_rss_reta_entry64 *reta_conf,
185                                 uint16_t reta_size);
186
187 /* Non-static functions */
188 void qede_init_rss_caps(uint8_t *rss_caps, uint64_t hf);
189
190 int qed_fill_eth_dev_info(struct ecore_dev *edev,
191                                  struct qed_dev_eth_info *info);
192 int qede_dev_set_link_state(struct rte_eth_dev *eth_dev, bool link_up);
193
194 #endif /* _QEDE_ETHDEV_H_ */