Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/dev/aq/aq_device.h
96295 views
1
/*
2
* aQuantia Corporation Network Driver
3
* Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
*
9
* (1) Redistributions of source code must retain the above
10
* copyright notice, this list of conditions and the following
11
* disclaimer.
12
*
13
* (2) Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
*
18
* (3)The name of the author may not be used to endorse or promote
19
* products derived from this software without specific prior
20
* written permission.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
23
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
26
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
#ifndef _AQ_DEVICE_H_
36
#define _AQ_DEVICE_H_
37
38
#include "aq_hw.h"
39
40
enum aq_media_type {
41
AQ_MEDIA_TYPE_UNKNOWN = 0,
42
AQ_MEDIA_TYPE_FIBRE,
43
AQ_MEDIA_TYPE_TP,
44
};
45
46
#define AQ_LINK_UNKNOWN 0x00000000
47
#define AQ_LINK_100M 0x00000001
48
#define AQ_LINK_1G 0x00000002
49
#define AQ_LINK_2G5 0x00000004
50
#define AQ_LINK_5G 0x00000008
51
#define AQ_LINK_10G 0x00000010
52
53
#define AQ_LINK_ALL (AQ_LINK_100M | AQ_LINK_1G | AQ_LINK_2G5 | AQ_LINK_5G | \
54
AQ_LINK_10G )
55
56
struct aq_stats_s {
57
uint64_t prc;
58
uint64_t uprc;
59
uint64_t mprc;
60
uint64_t bprc;
61
uint64_t cprc;
62
uint64_t erpr;
63
uint64_t dpc;
64
uint64_t brc;
65
uint64_t ubrc;
66
uint64_t mbrc;
67
uint64_t bbrc;
68
69
uint64_t ptc;
70
uint64_t uptc;
71
uint64_t mptc;
72
uint64_t bptc;
73
uint64_t erpt;
74
uint64_t btc;
75
uint64_t ubtc;
76
uint64_t mbtc;
77
uint64_t bbtc;
78
};
79
80
enum aq_dev_state_e {
81
AQ_DEV_STATE_UNLOAD,
82
AQ_DEV_STATE_PCI_STOP,
83
AQ_DEV_STATE_DOWN,
84
AQ_DEV_STATE_UP,
85
};
86
87
struct aq_rx_filters {
88
unsigned int rule_cnt;
89
struct aq_rx_filter_vlan vlan_filters[AQ_HW_VLAN_MAX_FILTERS];
90
struct aq_rx_filter_l2 etype_filters[AQ_HW_ETYPE_MAX_FILTERS];
91
};
92
93
struct aq_vlan_tag {
94
SLIST_ENTRY(aq_vlan_tag) next;
95
uint16_t tag;
96
};
97
98
struct aq_dev {
99
device_t dev;
100
if_ctx_t ctx;
101
if_softc_ctx_t scctx;
102
if_shared_ctx_t sctx;
103
struct ifmedia * media;
104
105
struct aq_hw hw;
106
107
enum aq_media_type media_type;
108
uint32_t link_speeds;
109
uint32_t chip_features;
110
uint32_t mbox_addr;
111
uint8_t mac_addr[ETHER_ADDR_LEN];
112
uint64_t admin_ticks;
113
struct if_irq irq;
114
int msix;
115
116
int mmio_rid;
117
struct resource * mmio_res;
118
bus_space_tag_t mmio_tag;
119
bus_space_handle_t mmio_handle;
120
bus_size_t mmio_size;
121
122
struct aq_ring *tx_rings[HW_ATL_B0_RINGS_MAX];
123
struct aq_ring *rx_rings[HW_ATL_B0_RINGS_MAX];
124
uint32_t tx_rings_count;
125
uint32_t rx_rings_count;
126
bool linkup;
127
int media_active;
128
129
struct aq_hw_stats_s last_stats;
130
struct aq_stats_s curr_stats;
131
132
bitstr_t *vlan_tags;
133
int mcnt;
134
135
uint8_t rss_key[HW_ATL_RSS_HASHKEY_SIZE];
136
uint8_t rss_table[HW_ATL_RSS_INDIRECTION_TABLE_MAX];
137
};
138
139
typedef struct aq_dev aq_dev_t;
140
141
int aq_update_hw_stats(aq_dev_t *aq_dev);
142
void aq_initmedia(aq_dev_t *aq_dev);
143
int aq_linkstat_isr(void *arg);
144
int aq_isr_rx(void *arg);
145
void aq_mediastatus_update(aq_dev_t *aq_dev, uint32_t link_speed, const struct aq_hw_fc_info *fc_neg);
146
void aq_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr);
147
int aq_mediachange(struct ifnet *ifp);
148
void aq_if_update_admin_status(if_ctx_t ctx);
149
150
#endif // _AQ_DEVICE_H_
151
152