2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
10 #ifndef _QEDE_ETHDEV_H_
11 #define _QEDE_ETHDEV_H_
13 #include <sys/queue.h>
15 #include <rte_ether.h>
16 #include <rte_ethdev.h>
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"
35 #include "qede_logs.h"
37 #include "qede_eth_if.h"
39 #include "qede_rxtx.h"
41 #define qede_stringify1(x...) #x
42 #define qede_stringify(x...) qede_stringify1(x)
45 #define QEDE_PMD_VER_PREFIX "QEDE PMD"
46 #define QEDE_PMD_VERSION_MAJOR 1
47 #define QEDE_PMD_VERSION_MINOR 2
48 #define QEDE_PMD_VERSION_REVISION 0
49 #define QEDE_PMD_VERSION_PATCH 1
51 #define QEDE_PMD_VERSION qede_stringify(QEDE_PMD_VERSION_MAJOR) "." \
52 qede_stringify(QEDE_PMD_VERSION_MINOR) "." \
53 qede_stringify(QEDE_PMD_VERSION_REVISION) "." \
54 qede_stringify(QEDE_PMD_VERSION_PATCH)
56 #define QEDE_PMD_DRV_VER_STR_SIZE NAME_SIZE
57 #define QEDE_PMD_VER_PREFIX "QEDE PMD"
60 #define QEDE_RSS_INDIR_INITED (1 << 0)
61 #define QEDE_RSS_KEY_INITED (1 << 1)
62 #define QEDE_RSS_CAPS_INITED (1 << 2)
64 #define QEDE_MAX_RSS_CNT(edev) ((edev)->dev_info.num_queues)
65 #define QEDE_MAX_TSS_CNT(edev) ((edev)->dev_info.num_queues * \
66 (edev)->dev_info.num_tc)
68 #define QEDE_QUEUE_CNT(qdev) ((qdev)->num_queues)
69 #define QEDE_RSS_COUNT(qdev) ((qdev)->num_queues - (qdev)->fp_num_tx)
70 #define QEDE_TSS_COUNT(qdev) (((qdev)->num_queues - (qdev)->fp_num_rx) * \
73 #define QEDE_FASTPATH_TX (1 << 0)
74 #define QEDE_FASTPATH_RX (1 << 1)
76 #define QEDE_DUPLEX_FULL 1
77 #define QEDE_DUPLEX_HALF 2
78 #define QEDE_DUPLEX_UNKNOWN 0xff
80 #define QEDE_SUPPORTED_AUTONEG (1 << 6)
81 #define QEDE_SUPPORTED_PAUSE (1 << 13)
83 #define QEDE_INIT_QDEV(eth_dev) (eth_dev->data->dev_private)
85 #define QEDE_INIT_EDEV(adapter) (&((struct qede_dev *)adapter)->edev)
87 #define QEDE_INIT(eth_dev) { \
88 struct qede_dev *qdev = eth_dev->data->dev_private; \
89 struct ecore_dev *edev = &qdev->edev; \
92 /************* QLogic 25G/40G/100G vendor/devices ids *************/
93 #define PCI_VENDOR_ID_QLOGIC 0x1077
95 #define CHIP_NUM_57980E 0x1634
96 #define CHIP_NUM_57980S 0x1629
97 #define CHIP_NUM_VF 0x1630
98 #define CHIP_NUM_57980S_40 0x1634
99 #define CHIP_NUM_57980S_25 0x1656
100 #define CHIP_NUM_57980S_IOV 0x1664
101 #define CHIP_NUM_57980S_100 0x1644
103 #define PCI_DEVICE_ID_NX2_57980E CHIP_NUM_57980E
104 #define PCI_DEVICE_ID_NX2_57980S CHIP_NUM_57980S
105 #define PCI_DEVICE_ID_NX2_VF CHIP_NUM_VF
106 #define PCI_DEVICE_ID_57980S_40 CHIP_NUM_57980S_40
107 #define PCI_DEVICE_ID_57980S_25 CHIP_NUM_57980S_25
108 #define PCI_DEVICE_ID_57980S_IOV CHIP_NUM_57980S_IOV
109 #define PCI_DEVICE_ID_57980S_100 CHIP_NUM_57980S_100
111 extern char fw_file
[];
113 /* Port/function states */
114 enum qede_dev_state
{
115 QEDE_DEV_INIT
, /* Init the chip and Slowpath */
116 QEDE_DEV_CONFIG
, /* Create Vport/Fastpath resources */
117 QEDE_DEV_START
, /* Start RX/TX queues, enable traffic */
118 QEDE_DEV_STOP
, /* Deactivate vport and stop traffic */
121 struct qede_vlan_entry
{
122 SLIST_ENTRY(qede_vlan_entry
) list
;
127 * Structure to store private data for each port.
130 struct ecore_dev edev
;
132 const struct qed_eth_ops
*ops
;
133 struct qed_dev_eth_info dev_info
;
134 struct ecore_sb_info
*sb_array
;
135 struct qede_fastpath
*fp_array
;
139 struct qed_update_vport_rss_params rss_params
;
145 enum qede_dev_state state
;
146 SLIST_HEAD(vlan_list_head
, qede_vlan_entry
)vlan_list_head
;
147 uint16_t configured_vlans
;
148 bool accept_any_vlan
;
149 struct ether_addr primary_mac
;
151 char drv_ver
[QEDE_PMD_DRV_VER_STR_SIZE
];
154 /* Static functions */
155 static int qede_vlan_filter_set(struct rte_eth_dev
*eth_dev
,
156 uint16_t vlan_id
, int on
);
158 static int qede_rss_hash_update(struct rte_eth_dev
*eth_dev
,
159 struct rte_eth_rss_conf
*rss_conf
);
161 static int qede_rss_reta_update(struct rte_eth_dev
*eth_dev
,
162 struct rte_eth_rss_reta_entry64
*reta_conf
,
165 /* Non-static functions */
166 void qede_init_rss_caps(uint8_t *rss_caps
, uint64_t hf
);
168 int qed_fill_eth_dev_info(struct ecore_dev
*edev
,
169 struct qed_dev_eth_info
*info
);
170 int qede_dev_set_link_state(struct rte_eth_dev
*eth_dev
, bool link_up
);
172 #endif /* _QEDE_ETHDEV_H_ */