net/atlantic: add link status and interrupt management
[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         uint32_t flow_control;
74
75         struct aq_rss_parameters aq_rss;
76 };
77
78 struct aq_hw_s {
79         u16 device_id;
80         u16 vendor_id;
81         bool adapter_stopped;
82
83         u8 rbl_enabled:1;
84         struct aq_hw_cfg_s *aq_nic_cfg;
85         const struct aq_fw_ops *aq_fw_ops;
86         void *mmio;
87
88         struct aq_hw_link_status_s aq_link_status;
89         bool is_autoneg;
90
91         struct hw_aq_atl_utils_mbox mbox;
92         struct hw_atl_stats_s last_stats;
93         struct aq_stats_s curr_stats;
94
95         u64 speed;
96         unsigned int chip_features;
97         u32 fw_ver_actual;
98         u32 mbox_addr;
99         u32 rpc_addr;
100         u32 rpc_tid;
101         struct hw_aq_atl_utils_fw_rpc rpc;
102 };
103
104 struct aq_fw_ops {
105         int (*init)(struct aq_hw_s *self);
106
107         int (*deinit)(struct aq_hw_s *self);
108
109         int (*reset)(struct aq_hw_s *self);
110
111         int (*get_mac_permanent)(struct aq_hw_s *self, u8 *mac);
112
113         int (*set_link_speed)(struct aq_hw_s *self, u32 speed);
114
115         int (*set_state)(struct aq_hw_s *self,
116                         enum hal_atl_utils_fw_state_e state);
117
118         int (*update_link_status)(struct aq_hw_s *self);
119
120         int (*update_stats)(struct aq_hw_s *self);
121
122         int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
123                         u8 *mac);
124
125         int (*get_temp)(struct aq_hw_s *self, int *temp);
126
127         int (*get_cable_len)(struct aq_hw_s *self, int *cable_len);
128
129         int (*set_eee_rate)(struct aq_hw_s *self, u32 speed);
130
131         int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
132                         u32 *supported_rates);
133
134         int (*set_flow_control)(struct aq_hw_s *self);
135
136         int (*led_control)(struct aq_hw_s *self, u32 mode);
137
138         int (*get_eeprom)(struct aq_hw_s *self, u32 *data, u32 len);
139
140         int (*set_eeprom)(struct aq_hw_s *self, u32 *data, u32 len);
141 };
142
143 #endif