0eabc21b2bc8022e5f8224e2e89a51cbb9213acd
[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 /* Bus parameters */
67 struct ngbe_bus_info {
68         void (*set_lan_id)(struct ngbe_hw *hw);
69
70         u16 func;
71         u8 lan_id;
72 };
73
74 struct ngbe_rom_info {
75         s32 (*init_params)(struct ngbe_hw *hw);
76         s32 (*validate_checksum)(struct ngbe_hw *hw, u16 *checksum_val);
77
78         enum ngbe_eeprom_type type;
79         u32 semaphore_delay;
80         u16 word_size;
81         u16 address_bits;
82         u16 word_page_size;
83         u32 sw_addr;
84         u32 saved_version;
85         u16 cksum_devcap;
86 };
87
88 struct ngbe_mac_info {
89         s32 (*init_hw)(struct ngbe_hw *hw);
90         s32 (*reset_hw)(struct ngbe_hw *hw);
91         s32 (*stop_hw)(struct ngbe_hw *hw);
92         s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
93         void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
94
95         /* Manageability interface */
96         s32 (*init_thermal_sensor_thresh)(struct ngbe_hw *hw);
97         s32 (*check_overtemp)(struct ngbe_hw *hw);
98
99         enum ngbe_mac_type type;
100         u32 max_tx_queues;
101         u32 max_rx_queues;
102         struct ngbe_thermal_sensor_data  thermal_sensor_data;
103         bool set_lben;
104 };
105
106 struct ngbe_phy_info {
107         s32 (*identify)(struct ngbe_hw *hw);
108         s32 (*reset_hw)(struct ngbe_hw *hw);
109         s32 (*read_reg)(struct ngbe_hw *hw, u32 reg_addr,
110                                 u32 device_type, u16 *phy_data);
111         s32 (*write_reg)(struct ngbe_hw *hw, u32 reg_addr,
112                                 u32 device_type, u16 phy_data);
113         s32 (*read_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
114                                 u32 device_type, u16 *phy_data);
115         s32 (*write_reg_unlocked)(struct ngbe_hw *hw, u32 reg_addr,
116                                 u32 device_type, u16 phy_data);
117
118         enum ngbe_media_type media_type;
119         enum ngbe_phy_type type;
120         u32 addr;
121         u32 id;
122         u32 revision;
123         u32 phy_semaphore_mask;
124         bool reset_disable;
125 };
126
127 struct ngbe_hw {
128         void IOMEM *hw_addr;
129         void *back;
130         struct ngbe_mac_info mac;
131         struct ngbe_phy_info phy;
132         struct ngbe_rom_info rom;
133         struct ngbe_bus_info bus;
134         u16 device_id;
135         u16 vendor_id;
136         u16 sub_device_id;
137         u16 sub_system_id;
138         bool adapter_stopped;
139
140         uint64_t isb_dma;
141         void IOMEM *isb_mem;
142
143         bool is_pf;
144 };
145
146 #include "ngbe_regs.h"
147 #include "ngbe_dummy.h"
148
149 #endif /* _NGBE_TYPE_H_ */