net/atlantic: fix flow control by sync settings on Rx
[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 /* Macsec stuff */
63 struct aq_macsec_config {
64         struct {
65                 u32 macsec_enabled;
66                 u32 encryption_enabled;
67                 u32 replay_protection_enabled;
68         } common;
69
70         struct {
71                 u32 idx;
72                 u32 mac[2]; /* 6 bytes */
73         } txsc;
74
75         struct {
76                 u32 idx;
77                 u32 an; /* association number on the local side */
78                 u32 pn; /* packet number on the local side */
79                 u32 key[4]; /* 128 bit key */
80         } txsa;
81
82         struct {
83                 u32 mac[2]; /* 6 bytes */
84                 u32 pi;
85         } rxsc;
86
87         struct {
88                 u32 idx;
89                 u32 an; /* association number on the remote side */
90                 u32 pn; /* packet number on the remote side */
91                 u32 key[4]; /* 128 bit key */
92         } rxsa;
93 };
94
95 struct aq_hw_cfg_s {
96         bool is_lro;
97         bool is_rss;
98         unsigned int num_rss_queues;
99         int wol;
100
101         int link_speed_msk;
102         int irq_type;
103         int irq_mask;
104         unsigned int vecs;
105
106         bool vlan_strip;
107         uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS];
108         uint32_t flow_control;
109
110         struct aq_rss_parameters aq_rss;
111         struct aq_macsec_config aq_macsec;
112 };
113
114 struct aq_hw_s {
115         u16 device_id;
116         u16 vendor_id;
117         bool adapter_stopped;
118
119         u8 rbl_enabled:1;
120         struct aq_hw_cfg_s *aq_nic_cfg;
121         const struct aq_fw_ops *aq_fw_ops;
122         void *mmio;
123
124         struct aq_hw_link_status_s aq_link_status;
125         bool is_autoneg;
126
127         struct hw_aq_atl_utils_mbox mbox;
128         struct hw_atl_stats_s last_stats;
129         struct aq_stats_s curr_stats;
130
131         u32 caps_lo;
132
133         u64 speed;
134         unsigned int chip_features;
135         u32 fw_ver_actual;
136         u32 mbox_addr;
137         u32 rpc_addr;
138         u32 rpc_tid;
139         struct hw_aq_atl_utils_fw_rpc rpc;
140 };
141
142 struct aq_fw_ops {
143         int (*init)(struct aq_hw_s *self);
144
145         int (*deinit)(struct aq_hw_s *self);
146
147         int (*reset)(struct aq_hw_s *self);
148
149         int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
150
151         int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
152
153         int (*set_state)(struct aq_hw_s *self,
154                         enum hal_atl_utils_fw_state_e state);
155
156         int (*update_link_status)(struct aq_hw_s *self);
157
158         int (*update_stats)(struct aq_hw_s *self);
159
160         int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
161                         u8 *mac);
162
163         int (*get_temp)(struct aq_hw_s *self, int *temp);
164
165         int (*get_cable_len)(struct aq_hw_s *self, int *cable_len);
166
167         int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);
168
169         int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
170                         u32 *supported_rates);
171
172         int (*get_flow_control)(struct aq_hw_s *self, u32 *fc);
173         int (*set_flow_control)(struct aq_hw_s *self);
174
175         int (*led_control)(struct aq_hw_s *self, u32 mode);
176
177         int (*get_eeprom)(struct aq_hw_s *self, int dev_addr,
178                           u32 *data, u32 len, u32 offset);
179
180         int (*set_eeprom)(struct aq_hw_s *self, int dev_addr,
181                           u32 *data, u32 len, u32 offset);
182
183         int (*send_macsec_req)(struct aq_hw_s *self,
184                                struct macsec_msg_fw_request *req,
185                                struct macsec_msg_fw_response *response);
186 };
187
188 struct atl_sw_stats {
189         u64 crcerrs;
190         u64 errbc;
191         u64 mspdc;
192         u64 mpctotal;
193         u64 mpc[8];
194         u64 mlfc;
195         u64 mrfc;
196         u64 rlec;
197         u64 lxontxc;
198         u64 lxonrxc;
199         u64 lxofftxc;
200         u64 lxoffrxc;
201         u64 pxontxc[8];
202         u64 pxonrxc[8];
203         u64 pxofftxc[8];
204         u64 pxoffrxc[8];
205         u64 gprc;
206         u64 bprc;
207         u64 mprc;
208         u64 gptc;
209         u64 gorc;
210         u64 gotc;
211         u64 tor;
212         u64 tpr;
213         u64 tpt;
214         u64 mptc;
215         u64 bptc;
216         u64 xec;
217         u64 fccrc;
218         u64 ldpcec;
219         u64 pcrc8ec;
220
221         u64 rx_nombuf;
222         u64 q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
223         u64 q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
224         u64 q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
225         u64 q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
226         u64 q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
227 };
228
229 #endif