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 #define FXP_NTXCB 128
47
48
49
50
51 #define FXP_NRFABUFS_MIN 4
52 #define FXP_NRFABUFS_MAX 64
53
54
55
56
57
58
59 #ifndef FXP_INT_DELAY
60 #define FXP_INT_DELAY 128
61 #endif
62
63
64
65
66
67
68 #ifndef FXP_BUNDLE_MAX
69 #define FXP_BUNDLE_MAX 16
70 #endif
71
72
73
74
75
76
77
78
79 #ifndef FXP_MIN_SIZE_MASK
80 #define FXP_MIN_SIZE_MASK 0xFFFF
81 #endif
82
83
84
85
86
87
88 struct fxp_txsw {
89 struct fxp_txsw *tx_next;
90 struct mbuf *tx_mbuf;
91 bus_dmamap_t tx_map;
92 bus_addr_t tx_off;
93 struct fxp_cb_tx *tx_cb;
94 };
95
96 struct fxp_ctrl {
97 struct fxp_cb_tx tx_cb[FXP_NTXCB];
98 struct fxp_stats stats;
99 union {
100 struct fxp_cb_mcs mcs;
101 struct fxp_cb_ias ias;
102 struct fxp_cb_config cfg;
103 struct fxp_cb_ucode code;
104 } u;
105 };
106
107 struct fxp_softc {
108 struct device sc_dev;
109 void *sc_ih;
110 bus_space_tag_t sc_st;
111 bus_space_handle_t sc_sh;
112 bus_dma_tag_t sc_dmat;
113 struct arpcom sc_arpcom;
114 struct mii_data sc_mii;
115 struct mbuf *rfa_headm;
116 struct mbuf *rfa_tailm;
117 int sc_flags;
118 #define FXPF_MWI_ENABLE 0x10
119 #define FXPF_DISABLE_STANDBY 0x20
120 #define FXPF_UCODE 0x40
121 #define FXPF_RECV_WORKAROUND 0x80
122 struct timeout stats_update_to;
123 int rx_idle_secs;
124 struct fxp_cb_tx *cbl_base;
125 int phy_primary_addr;
126 int phy_primary_device;
127 int phy_10Mbps_only;
128 int eeprom_size;
129 int rx_bufs;
130 void *sc_sdhook;
131 void *sc_powerhook;
132 struct fxp_txsw txs[FXP_NTXCB];
133 struct fxp_txsw *sc_cbt_cons, *sc_cbt_prod, *sc_cbt_prev;
134 int sc_cbt_cnt;
135 bus_dmamap_t tx_cb_map;
136 bus_dma_segment_t sc_cb_seg;
137 int sc_cb_nseg;
138 struct fxp_ctrl *sc_ctrl;
139 bus_dmamap_t sc_rxmaps[FXP_NRFABUFS_MAX];
140 int sc_rxfree;
141 u_int32_t sc_revision;
142 u_int16_t sc_int_delay;
143 u_int16_t sc_bundle_max;
144 u_int16_t sc_min_size_mask;
145
146 };
147
148
149 #define CSR_READ_1(sc, reg) \
150 bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
151 #define CSR_READ_2(sc, reg) \
152 bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
153 #define CSR_READ_4(sc, reg) \
154 bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
155 #define CSR_WRITE_1(sc, reg, val) \
156 bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
157 #define CSR_WRITE_2(sc, reg, val) \
158 bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
159 #define CSR_WRITE_4(sc, reg, val) \
160 bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
161
162 extern int fxp_intr(void *);
163 extern int fxp_attach(struct fxp_softc *, const char *);
164
165 #define FXP_RXMAP_GET(sc) ((sc)->sc_rxmaps[(sc)->sc_rxfree++])
166 #define FXP_RXMAP_PUT(sc,map) ((sc)->sc_rxmaps[--(sc)->sc_rxfree] = (map))
167
168 #define FXP_TXCB_SYNC(sc, txs, p) \
169 bus_dmamap_sync((sc)->sc_dmat, (sc)->tx_cb_map, (txs)->tx_off, \
170 sizeof(struct fxp_cb_tx), (p))
171
172 #define FXP_MCS_SYNC(sc, p) \
173 bus_dmamap_sync((sc)->sc_dmat, (sc)->tx_cb_map, \
174 offsetof(struct fxp_ctrl, u.mcs), sizeof(struct fxp_cb_mcs), (p))
175
176 #define FXP_IAS_SYNC(sc, p) \
177 bus_dmamap_sync((sc)->sc_dmat, (sc)->tx_cb_map, \
178 offsetof(struct fxp_ctrl, u.ias), sizeof(struct fxp_cb_ias), (p))
179
180 #define FXP_CFG_SYNC(sc, p) \
181 bus_dmamap_sync((sc)->sc_dmat, (sc)->tx_cb_map, \
182 offsetof(struct fxp_ctrl, u.cfg), sizeof(struct fxp_cb_config), (p))
183
184 #define FXP_UCODE_SYNC(sc, p) \
185 bus_dmamap_sync((sc)->sc_dmat, (sc)->tx_cb_map, \
186 offsetof(struct fxp_ctrl, u.code), sizeof(struct fxp_cb_ucode), (p))
187
188 #define FXP_STATS_SYNC(sc, p) \
189 bus_dmamap_sync((sc)->sc_dmat, (sc)->tx_cb_map, \
190 offsetof(struct fxp_ctrl, stats), sizeof(struct fxp_stats), (p))
191
192 #define FXP_MBUF_SYNC(sc, m, p) \
193 bus_dmamap_sync((sc)->sc_dmat, (m), 0, (m)->dm_mapsize, (p))