dbf0654db326038730b388888c57ca920adc3af5
[dpdk.git] / drivers / net / ngbe / base / ngbe_type.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _NGBE_TYPE_H_
7 #define _NGBE_TYPE_H_
8
9 #define NGBE_FRAME_SIZE_DFT       (1522) /* Default frame size, +FCS */
10
11 #define NGBE_ALIGN              128 /* as intel did */
12 #define NGBE_ISB_SIZE           16
13
14 #include "ngbe_status.h"
15 #include "ngbe_osdep.h"
16 #include "ngbe_devids.h"
17
18 struct ngbe_thermal_diode_data {
19         s16 temp;
20         s16 alarm_thresh;
21         s16 dalarm_thresh;
22 };
23
24 struct ngbe_thermal_sensor_data {
25         struct ngbe_thermal_diode_data sensor[1];
26 };
27
28 enum ngbe_eeprom_type {
29         ngbe_eeprom_unknown = 0,
30         ngbe_eeprom_spi,
31         ngbe_eeprom_flash,
32         ngbe_eeprom_none /* No NVM support */
33 };
34
35 enum ngbe_mac_type {
36         ngbe_mac_unknown = 0,
37         ngbe_mac_em,
38         ngbe_mac_em_vf,
39         ngbe_num_macs
40 };
41
42 enum ngbe_phy_type {
43         ngbe_phy_unknown = 0,
44         ngbe_phy_none,
45         ngbe_phy_rtl,
46         ngbe_phy_mvl,
47         ngbe_phy_mvl_sfi,
48         ngbe_phy_yt8521s,
49         ngbe_phy_yt8521s_sfi,
50         ngbe_phy_zte,
51         ngbe_phy_cu_mtd,
52 };
53
54 enum ngbe_media_type {
55         ngbe_media_type_unknown = 0,
56         ngbe_media_type_fiber,
57         ngbe_media_type_fiber_qsfp,
58         ngbe_media_type_copper,
59         ngbe_media_type_backplane,
60         ngbe_media_type_cx4,
61         ngbe_media_type_virtual
62 };
63
64 struct ngbe_hw;
65
66 struct ngbe_addr_filter_info {
67         u32 mta_in_use;
68 };
69
70 /* Bus parameters */
71 struct ngbe_bus_info {
72         void (*set_lan_id)(struct ngbe_hw *hw);
73
74         u16 func;
75         u8 lan_id;
76 };
77
78 struct ngbe_rom_info {
79         s32 (*init_params)(struct ngbe_hw *hw);
80         s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
81
82         enum ngbe_eeprom_type type;
83         u32 semaphore_delay;
84         u16 word_size;
85         u16 address_bits;
86         u16 word_page_size;
87         u32 sw_addr;
88         u32 saved_version;
89         u16 cksum_devcap;
90 };
91
92 struct ngbe_mac_info {
93         s32 (*init_hw)(struct ngbe_hw *hw);
94         s32 (*reset_hw)(struct ngbe_hw *hw);
95         s32 (*stop_hw)(struct ngbe_hw *hw);
96         s32 (*get_mac_addr)(struct ngbe_hw *hw, u8 *mac_addr);
97         s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
98         void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
99
100         /* RAR */
101         s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
102                           u32 enable_addr);
103         s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
104         s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
105         s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
106         s32 (*init_rx_addrs)(struct ngbe_hw *hw);
107
108         /* Manageability interface */
109         s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
110         s32 (*check_overtemp)(struct ngbe_hw *hw);
111
112         enum ngbe_mac_type type;
113         u8 addr[ETH_ADDR_LEN];
114         u8 perm_addr[ETH_ADDR_LEN];
115         s32 mc_filter_type;
116         u32 mcft_size;
117         u32 num_rar_entries;
118         u32 max_tx_queues;
119         u32 max_rx_queues;
120         struct ngbe_thermal_sensor_data  thermal_sensor_data;
121         bool set_lben;
122 };
123
124 struct ngbe_phy_info {
125         s32 (*identify)(struct ngbe_hw *hw);
126         s32 (*reset_hw)(struct ngbe_hw *hw);
127         s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
128                                 u32 device_type, u16 *phy_data);
129         s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
130                                 u32 device_type, u16 phy_data);
131         s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
132                                 u32 device_type, u16 *phy_data);
133         s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
134                                 u32 device_type, u16 phy_data);
135
136         enum ngbe_media_type media_type;
137         enum ngbe_phy_type type;
138         u32 addr;
139         u32 id;
140         u32 revision;
141         u32 phy_semaphore_mask;
142         bool reset_disable;
143 };
144
145 struct ngbe_hw {
146         void IOMEM *hw_addr;
147         void *back;
148         struct ngbe_mac_info mac;
149         struct ngbe_addr_filter_info addr_ctrl;
150         struct ngbe_phy_info phy;
151         struct ngbe_rom_info rom;
152         struct ngbe_bus_info bus;
153         u16 device_id;
154         u16 vendor_id;
155         u16 sub_device_id;
156         u16 sub_system_id;
157         bool adapter_stopped;
158
159         uint64_t isb_dma;
160         void IOMEM *isb_mem;
161
162         bool is_pf;
163 };
164
165 #include "ngbe_regs.h"
166 #include "ngbe_dummy.h"
167
168 #endif /* _NGBE_TYPE_H_ */