c200a1fadb7951442667e392caaf05792470cc36
[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 #include <pthread.h>
14
15 typedef uint8_t         u8;
16 typedef int8_t          s8;
17 typedef uint16_t        u16;
18 typedef int16_t         s16;
19 typedef uint32_t        u32;
20 typedef int32_t         s32;
21 typedef uint64_t        u64;
22
23 #define min(a, b)       RTE_MIN(a, b)
24 #define max(a, b)       RTE_MAX(a, b)
25
26 #include "hw_atl/hw_atl_b0_internal.h"
27 #include "hw_atl/hw_atl_utils.h"
28
29 struct aq_hw_link_status_s {
30         unsigned int mbps;
31 };
32
33 struct aq_stats_s {
34         u64 uprc;
35         u64 mprc;
36         u64 bprc;
37         u64 erpt;
38         u64 uptc;
39         u64 mptc;
40         u64 bptc;
41         u64 erpr;
42         u64 mbtc;
43         u64 bbtc;
44         u64 mbrc;
45         u64 bbrc;
46         u64 ubrc;
47         u64 ubtc;
48         u64 dpc;
49         u64 dma_pkt_rc;
50         u64 dma_pkt_tc;
51         u64 dma_oct_rc;
52         u64 dma_oct_tc;
53 };
54
55 struct aq_rss_parameters {
56         u16 base_cpu_number;
57         u16 indirection_table_size;
58         u16 hash_secret_key_size;
59         u32 hash_secret_key[HW_ATL_B0_RSS_HASHKEY_BITS / 8];
60         u8 indirection_table[HW_ATL_B0_RSS_REDIRECTION_MAX];
61 };
62
63 /* Macsec stuff */
64 struct aq_macsec_config {
65         struct {
66                 u32 macsec_enabled;
67                 u32 encryption_enabled;
68                 u32 replay_protection_enabled;
69         } common;
70
71         struct {
72                 u32 idx;
73                 u32 mac[2]; /* 6 bytes */
74         } txsc;
75
76         struct {
77                 u32 idx;
78                 u32 an; /* association number on the local side */
79                 u32 pn; /* packet number on the local side */
80                 u32 key[4]; /* 128 bit key */
81         } txsa;
82
83         struct {
84                 u32 mac[2]; /* 6 bytes */
85                 u32 pi;
86         } rxsc;
87
88         struct {
89                 u32 idx;
90                 u32 an; /* association number on the remote side */
91                 u32 pn; /* packet number on the remote side */
92                 u32 key[4]; /* 128 bit key */
93         } rxsa;
94 };
95
96 struct aq_hw_cfg_s {
97         bool is_lro;
98         bool is_rss;
99         unsigned int num_rss_queues;
100         int wol;
101
102         int link_speed_msk;
103         int irq_type;
104         int irq_mask;
105         unsigned int vecs;
106
107         bool vlan_strip;
108         uint32_t vlan_filter[HW_ATL_B0_MAX_VLAN_IDS];
109         uint32_t flow_control;
110
111         struct aq_rss_parameters aq_rss;
112         struct aq_macsec_config aq_macsec;
113 };
114
115 struct aq_hw_s {
116         u16 device_id;
117         u16 vendor_id;
118         bool adapter_stopped;
119
120         u8 rbl_enabled:1;
121         struct aq_hw_cfg_s *aq_nic_cfg;
122         const struct aq_fw_ops *aq_fw_ops;
123         void *mmio;
124
125         struct aq_hw_link_status_s aq_link_status;
126         bool is_autoneg;
127
128         struct hw_aq_atl_utils_mbox mbox;
129         struct hw_atl_stats_s last_stats;
130         struct aq_stats_s curr_stats;
131
132         u32 caps_lo;
133
134         u64 speed;
135         unsigned int chip_features;
136         u32 fw_ver_actual;
137         u32 mbox_addr;
138         u32 rpc_addr;
139         u32 rpc_tid;
140         struct hw_aq_atl_utils_fw_rpc rpc;
141
142         pthread_mutex_t mbox_mutex;
143 };
144
145 struct aq_fw_ops {
146         int (*init)(struct aq_hw_s *self);
147
148         int (*deinit)(struct aq_hw_s *self);
149
150         int (*reset)(struct aq_hw_s *self);
151
152         int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
153
154         int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
155
156         int (*set_state)(struct aq_hw_s *self,
157                         enum hal_atl_utils_fw_state_e state);
158
159         int (*update_link_status)(struct aq_hw_s *self);
160
161         int (*update_stats)(struct aq_hw_s *self);
162
163         int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
164                         u8 *mac);
165
166         int (*get_temp)(struct aq_hw_s *self, int *temp);
167
168         int (*get_cable_len)(struct aq_hw_s *self, int *cable_len);
169
170         int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);
171
172         int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
173                         u32 *supported_rates);
174
175         int (*get_flow_control)(struct aq_hw_s *self, u32 *fc);
176         int (*set_flow_control)(struct aq_hw_s *self);
177
178         int (*led_control)(struct aq_hw_s *self, u32 mode);
179
180         int (*get_eeprom)(struct aq_hw_s *self, int dev_addr,
181                           u32 *data, u32 len, u32 offset);
182
183         int (*set_eeprom)(struct aq_hw_s *self, int dev_addr,
184                           u32 *data, u32 len, u32 offset);
185
186         int (*send_macsec_req)(struct aq_hw_s *self,
187                                struct macsec_msg_fw_request *req,
188                                struct macsec_msg_fw_response *response);
189 };
190
191 struct atl_sw_stats {
192         u64 crcerrs;
193         u64 errbc;
194         u64 mspdc;
195         u64 mpctotal;
196         u64 mpc[8];
197         u64 mlfc;
198         u64 mrfc;
199         u64 rlec;
200         u64 lxontxc;
201         u64 lxonrxc;
202         u64 lxofftxc;
203         u64 lxoffrxc;
204         u64 pxontxc[8];
205         u64 pxonrxc[8];
206         u64 pxofftxc[8];
207         u64 pxoffrxc[8];
208         u64 gprc;
209         u64 bprc;
210         u64 mprc;
211         u64 gptc;
212         u64 gorc;
213         u64 gotc;
214         u64 tor;
215         u64 tpr;
216         u64 tpt;
217         u64 mptc;
218         u64 bptc;
219         u64 xec;
220         u64 fccrc;
221         u64 ldpcec;
222         u64 pcrc8ec;
223
224         u64 rx_nombuf;
225         u64 q_ipackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
226         u64 q_opackets[RTE_ETHDEV_QUEUE_STAT_CNTRS];
227         u64 q_ibytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
228         u64 q_obytes[RTE_ETHDEV_QUEUE_STAT_CNTRS];
229         u64 q_errors[RTE_ETHDEV_QUEUE_STAT_CNTRS];
230 };
231
232 #endif