New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / net / atlantic / atl_types.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Aquantia Corporation
3  */
4 #ifndef ATL_TYPES_H
5 #define ATL_TYPES_H
6
7 #include <stdint.h>
8 #include <stddef.h>
9 #include <inttypes.h>
10 #include <string.h>
11 #include <stdbool.h>
12 #include <netinet/in.h>
13
14 typedef uint8_t         u8;
15 typedef int8_t          s8;
16 typedef uint16_t        u16;
17 typedef int16_t         s16;
18 typedef uint32_t        u32;
19 typedef int32_t         s32;
20 typedef uint64_t        u64;
21
22 #define min(a, b)       RTE_MIN(a, b)
23 #define max(a, b)       RTE_MAX(a, b)
24
25 #include "hw_atl/hw_atl_b0_internal.h"
26 #include "hw_atl/hw_atl_utils.h"
27
28 struct aq_hw_link_status_s {
29         unsigned int mbps;
30 };
31
32 struct aq_stats_s {
33         u64 uprc;
34         u64 mprc;
35         u64 bprc;
36         u64 erpt;
37         u64 uptc;
38         u64 mptc;
39         u64 bptc;
40         u64 erpr;
41         u64 mbtc;
42         u64 bbtc;
43         u64 mbrc;
44         u64 bbrc;
45         u64 ubrc;
46         u64 ubtc;
47         u64 dpc;
48         u64 dma_pkt_rc;
49         u64 dma_pkt_tc;
50         u64 dma_oct_rc;
51         u64 dma_oct_tc;
52 };
53
54 struct aq_rss_parameters {
55         u16 base_cpu_number;
56         u16 indirection_table_size;
57         u16 hash_secret_key_size;
58         u32 hash_secret_key[HW_ATL_B0_RSS_HASHKEY_BITS / 8];
59         u8 indirection_table[HW_ATL_B0_RSS_REDIRECTION_MAX];
60 };
61
62 struct aq_hw_cfg_s {
63         bool is_lro;
64         bool is_rss;
65         unsigned int num_rss_queues;
66         int wol;
67
68         int link_speed_msk;
69         int irq_type;
70         int irq_mask;
71         unsigned int vecs;
72
73         bool vlan_strip;
74         uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS];
75         uint32_t flow_control;
76
77         struct aq_rss_parameters aq_rss;
78 };
79
80 struct aq_hw_s {
81         u16 device_id;
82         u16 vendor_id;
83         bool adapter_stopped;
84
85         u8 rbl_enabled:1;
86         struct aq_hw_cfg_s *aq_nic_cfg;
87         const struct aq_fw_ops *aq_fw_ops;
88         void *mmio;
89
90         struct aq_hw_link_status_s aq_link_status;
91         bool is_autoneg;
92
93         struct hw_aq_atl_utils_mbox mbox;
94         struct hw_atl_stats_s last_stats;
95         struct aq_stats_s curr_stats;
96
97         u64 speed;
98         unsigned int chip_features;
99         u32 fw_ver_actual;
100         u32 mbox_addr;
101         u32 rpc_addr;
102         u32 rpc_tid;
103         struct hw_aq_atl_utils_fw_rpc rpc;
104 };
105
106 struct aq_fw_ops {
107         int (*init)(struct aq_hw_s *self);
108
109         int (*deinit)(struct aq_hw_s *self);
110
111         int (*reset)(struct aq_hw_s *self);
112
113         int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
114
115         int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
116
117         int (*set_state)(struct aq_hw_s *self,
118                         enum hal_atl_utils_fw_state_e state);
119
120         int (*update_link_status)(struct aq_hw_s *self);
121
122         int (*update_stats)(struct aq_hw_s *self);
123
124         int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
125                         u8 *mac);
126
127         int (*get_temp)(struct aq_hw_s *self, int *temp);
128
129         int (*get_cable_len)(struct aq_hw_s *self, int *cable_len);
130
131         int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);
132
133         int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
134                         u32 *supported_rates);
135
136         int (*set_flow_control)(struct aq_hw_s *self);
137
138         int (*led_control)(struct aq_hw_s *self, u32 mode);
139
140         int (*get_eeprom)(struct aq_hw_s *self, u32 *data, u32 len);
141
142         int (*set_eeprom)(struct aq_hw_s *self, u32 *data, u32 len);
143 };
144
145 struct atl_sw_stats {
146         u64 crcerrs;
147         u64 errbc;
148         u64 mspdc;
149         u64 mpctotal;
150         u64 mpc[8];
151         u64 mlfc;
152         u64 mrfc;
153         u64 rlec;
154         u64 lxontxc;
155         u64 lxonrxc;
156         u64 lxofftxc;
157         u64 lxoffrxc;
158         u64 pxontxc[8];
159         u64 pxonrxc[8];
160         u64 pxofftxc[8];
161         u64 pxoffrxc[8];
162         u64 gprc;
163         u64 bprc;
164         u64 mprc;
165         u64 gptc;
166         u64 gorc;
167         u64 gotc;
168         u64 tor;
169         u64 tpr;
170         u64 tpt;
171         u64 mptc;
172         u64 bptc;
173         u64 xec;
174         u64 fccrc;
175         u64 ldpcec;
176         u64 pcrc8ec;
177
178         u64 rx_nombuf;
179         u64 q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
180         u64 q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
181         u64 q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
182         u64 q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
183         u64 q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
184 };
185
186 #endif