1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/*-
* Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef IF_AEVAR_H
#define IF_AEVAR_H
/*
* Supported chips identifiers.
*/
#define VENDORID_ATTANSIC 0x1969
#define DEVICEID_ATTANSIC_L2 0x2048
/* How much to wait for reset to complete (10 microsecond units). */
#define AE_RESET_TIMEOUT 100
/* How much to wait for device to enter idle state (100 microsecond units). */
#define AE_IDLE_TIMEOUT 100
/* How much to wait for MDIO to do the work (2 microsecond units). */
#define AE_MDIO_TIMEOUT 10
/* How much to wait for VPD reading operation to complete (2 ms units). */
#define AE_VPD_TIMEOUT 10
/* How much to wait for send operation to complete (HZ units). */
#define AE_TX_TIMEOUT 5
/* Default PHY address. */
#define AE_PHYADDR_DEFAULT 0
/* Tx packet descriptor header format. */
typedef struct ae_txd {
uint16_t len;
uint16_t vlan;
} __packed ae_txd_t;
/* Tx status descriptor format. */
typedef struct ae_txs {
uint16_t len;
uint16_t flags;
} __packed ae_txs_t;
/* Rx packet descriptor format. */
typedef struct ae_rxd {
uint16_t len;
uint16_t flags;
uint16_t vlan;
uint16_t __pad;
uint8_t data[1528];
} __packed ae_rxd_t;
/* Statistics. */
typedef struct ae_stats {
uint32_t rx_bcast;
uint32_t rx_mcast;
uint32_t rx_pause;
uint32_t rx_ctrl;
uint32_t rx_crcerr;
uint32_t rx_codeerr;
uint32_t rx_runt;
uint32_t rx_frag;
uint32_t rx_trunc;
uint32_t rx_align;
uint32_t tx_bcast;
uint32_t tx_mcast;
uint32_t tx_pause;
uint32_t tx_ctrl;
uint32_t tx_defer;
uint32_t tx_excdefer;
uint32_t tx_singlecol;
uint32_t tx_multicol;
uint32_t tx_latecol;
uint32_t tx_abortcol;
uint32_t tx_underrun;
} ae_stats_t;
/* Software state structure. */
typedef struct ae_softc {
struct ifnet *ifp;
device_t dev;
device_t miibus;
struct resource *mem[1];
struct resource_spec *spec_mem;
struct resource *irq[1];
struct resource_spec *spec_irq;
void *intrhand;
struct mtx mtx;
int phyaddr;
uint8_t eaddr[ETHER_ADDR_LEN];
uint8_t flags;
int if_flags;
struct callout tick_ch;
/* Tasks. */
struct task int_task;
struct task tx_task;
struct task link_task;
struct taskqueue *tq;
/* DMA tags. */
bus_dma_tag_t dma_parent_tag;
bus_dma_tag_t dma_rxd_tag;
bus_dma_tag_t dma_txd_tag;
bus_dma_tag_t dma_txs_tag;
bus_dmamap_t dma_rxd_map;
bus_dmamap_t dma_txd_map;
bus_dmamap_t dma_txs_map;
bus_addr_t dma_rxd_busaddr;
bus_addr_t dma_txd_busaddr;
bus_addr_t dma_txs_busaddr;
char *rxd_base_dma; /* Start of allocated area. */
ae_rxd_t *rxd_base; /* Start of RxD ring. */
char *txd_base; /* Start of TxD ring. */
ae_txs_t *txs_base; /* Start of TxS ring. */
/* Ring pointers. */
unsigned int rxd_cur;
unsigned int txd_cur;
unsigned int txs_cur;
unsigned int txs_ack;
unsigned int txd_ack;
int tx_inproc; /* Active Tx frames in ring. */
int wd_timer;
ae_stats_t stats;
} ae_softc_t;
#define AE_LOCK(_sc) mtx_lock(&(_sc)->mtx)
#define AE_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
#define AE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED)
#define BUS_ADDR_LO(x) ((uint64_t) (x) & 0xFFFFFFFF)
#define BUS_ADDR_HI(x) ((uint64_t) (x) >> 32)
#define AE_FLAG_LINK 0x01 /* Has link. */
#define AE_FLAG_DETACH 0x02 /* Is detaching. */
#define AE_FLAG_TXAVAIL 0x04 /* Tx'es available. */
#define AE_FLAG_MSI 0x08 /* Using MSI. */
#define AE_FLAG_PMG 0x10 /* Supports PCI power management. */
#endif /* IF_AEVAR_H */
|