aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Einon <mark.einon@gmail.com>2011-10-19 20:18:37 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-23 04:07:10 -0400
commit562550b02bbe9e376b05c5ff7d7ef12e7c32fc30 (patch)
tree46c6cadbbeac90f77d51b98c77f106ccff7203b9 /drivers
parent1c1c1b5fda62419615c8fda99359206b2b279489 (diff)
staging: et131x: move et1310_rx.h contents into et131x.c
Move et1310_rx.h contents into et131x.c and delete et1310_rx.h Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/et131x/et1310_rx.h243
-rw-r--r--drivers/staging/et131x/et131x.c181
2 files changed, 180 insertions, 244 deletions
diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h
deleted file mode 100644
index b3b1bc959d19..000000000000
--- a/drivers/staging/et131x/et1310_rx.h
+++ /dev/null
@@ -1,243 +0,0 @@
1/*
2 * Agere Systems Inc.
3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4 *
5 * Copyright © 2005 Agere Systems Inc.
6 * All rights reserved.
7 * http://www.agere.com
8 *
9 * Copyright (c) 2011 Mark Einon <mark.einon@gmail.com>
10 *
11 *------------------------------------------------------------------------------
12 *
13 * et1310_rx.h - Defines, structs, enums, prototypes, etc. pertaining to data
14 * reception.
15 *
16 *------------------------------------------------------------------------------
17 *
18 * SOFTWARE LICENSE
19 *
20 * This software is provided subject to the following terms and conditions,
21 * which you should read carefully before using the software. Using this
22 * software indicates your acceptance of these terms and conditions. If you do
23 * not agree with these terms and conditions, do not use the software.
24 *
25 * Copyright © 2005 Agere Systems Inc.
26 * All rights reserved.
27 *
28 * Redistribution and use in source or binary forms, with or without
29 * modifications, are permitted provided that the following conditions are met:
30 *
31 * . Redistributions of source code must retain the above copyright notice, this
32 * list of conditions and the following Disclaimer as comments in the code as
33 * well as in the documentation and/or other materials provided with the
34 * distribution.
35 *
36 * . Redistributions in binary form must reproduce the above copyright notice,
37 * this list of conditions and the following Disclaimer in the documentation
38 * and/or other materials provided with the distribution.
39 *
40 * . Neither the name of Agere Systems Inc. nor the names of the contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * Disclaimer
45 *
46 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
47 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
48 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
49 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
50 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
51 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
57 * DAMAGE.
58 *
59 */
60
61#ifndef __ET1310_RX_H__
62#define __ET1310_RX_H__
63
64#define USE_FBR0 true
65
66#ifdef USE_FBR0
67/* #define FBR0_BUFFER_SIZE 256 */
68#endif
69
70/* #define FBR1_BUFFER_SIZE 2048 */
71
72#define FBR_CHUNKS 32
73
74#define MAX_DESC_PER_RING_RX 1024
75
76/* number of RFDs - default and min */
77#ifdef USE_FBR0
78#define RFD_LOW_WATER_MARK 40
79#define NIC_MIN_NUM_RFD 64
80#define NIC_DEFAULT_NUM_RFD 1024
81#else
82#define RFD_LOW_WATER_MARK 20
83#define NIC_MIN_NUM_RFD 64
84#define NIC_DEFAULT_NUM_RFD 256
85#endif
86
87#define NUM_PACKETS_HANDLED 256
88
89#define ALCATEL_BAD_STATUS 0xe47f0000
90#define ALCATEL_MULTICAST_PKT 0x01000000
91#define ALCATEL_BROADCAST_PKT 0x02000000
92
93/* typedefs for Free Buffer Descriptors */
94struct fbr_desc {
95 u32 addr_lo;
96 u32 addr_hi;
97 u32 word2; /* Bits 10-31 reserved, 0-9 descriptor */
98};
99
100/* Packet Status Ring Descriptors
101 *
102 * Word 0:
103 *
104 * top 16 bits are from the Alcatel Status Word as enumerated in
105 * PE-MCXMAC Data Sheet IPD DS54 0210-1 (also IPD-DS80 0205-2)
106 *
107 * 0: hp hash pass
108 * 1: ipa IP checksum assist
109 * 2: ipp IP checksum pass
110 * 3: tcpa TCP checksum assist
111 * 4: tcpp TCP checksum pass
112 * 5: wol WOL Event
113 * 6: rxmac_error RXMAC Error Indicator
114 * 7: drop Drop packet
115 * 8: ft Frame Truncated
116 * 9: jp Jumbo Packet
117 * 10: vp VLAN Packet
118 * 11-15: unused
119 * 16: asw_prev_pkt_dropped e.g. IFG too small on previous
120 * 17: asw_RX_DV_event short receive event detected
121 * 18: asw_false_carrier_event bad carrier since last good packet
122 * 19: asw_code_err one or more nibbles signalled as errors
123 * 20: asw_CRC_err CRC error
124 * 21: asw_len_chk_err frame length field incorrect
125 * 22: asw_too_long frame length > 1518 bytes
126 * 23: asw_OK valid CRC + no code error
127 * 24: asw_multicast has a multicast address
128 * 25: asw_broadcast has a broadcast address
129 * 26: asw_dribble_nibble spurious bits after EOP
130 * 27: asw_control_frame is a control frame
131 * 28: asw_pause_frame is a pause frame
132 * 29: asw_unsupported_op unsupported OP code
133 * 30: asw_VLAN_tag VLAN tag detected
134 * 31: asw_long_evt Rx long event
135 *
136 * Word 1:
137 * 0-15: length length in bytes
138 * 16-25: bi Buffer Index
139 * 26-27: ri Ring Index
140 * 28-31: reserved
141 */
142
143struct pkt_stat_desc {
144 u32 word0;
145 u32 word1;
146};
147
148/* Typedefs for the RX DMA status word */
149
150/*
151 * rx status word 0 holds part of the status bits of the Rx DMA engine
152 * that get copied out to memory by the ET-1310. Word 0 is a 32 bit word
153 * which contains the Free Buffer ring 0 and 1 available offset.
154 *
155 * bit 0-9 FBR1 offset
156 * bit 10 Wrap flag for FBR1
157 * bit 16-25 FBR0 offset
158 * bit 26 Wrap flag for FBR0
159 */
160
161/*
162 * RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine
163 * that get copied out to memory by the ET-1310. Word 3 is a 32 bit word
164 * which contains the Packet Status Ring available offset.
165 *
166 * bit 0-15 reserved
167 * bit 16-27 PSRoffset
168 * bit 28 PSRwrap
169 * bit 29-31 unused
170 */
171
172/*
173 * struct rx_status_block is a structure representing the status of the Rx
174 * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020
175 */
176struct rx_status_block {
177 u32 word0;
178 u32 word1;
179};
180
181/*
182 * Structure for look-up table holding free buffer ring pointers
183 */
184struct fbr_lookup {
185 void *virt[MAX_DESC_PER_RING_RX];
186 void *buffer1[MAX_DESC_PER_RING_RX];
187 void *buffer2[MAX_DESC_PER_RING_RX];
188 u32 bus_high[MAX_DESC_PER_RING_RX];
189 u32 bus_low[MAX_DESC_PER_RING_RX];
190};
191
192/*
193 * struct rx_ring is the sructure representing the adaptor's local
194 * reference(s) to the rings
195 */
196struct rx_ring {
197#ifdef USE_FBR0
198 void *fbr0_ring_virtaddr;
199 dma_addr_t fbr0_ring_physaddr;
200 void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
201 dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
202 uint64_t fbr0_real_physaddr;
203 uint64_t fbr0_offset;
204 u32 local_fbr0_full;
205 u32 fbr0_num_entries;
206 u32 fbr0_buffsize;
207#endif
208 void *fbr1_ring_virtaddr;
209 dma_addr_t fbr1_ring_physaddr;
210 void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
211 dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
212 uint64_t fbr1_real_physaddr;
213 uint64_t fbr1_offset;
214 struct fbr_lookup *fbr[2]; /* One per ring */
215 u32 local_fbr1_full;
216 u32 fbr1_num_entries;
217 u32 fbr1_buffsize;
218
219 void *ps_ring_virtaddr;
220 dma_addr_t ps_ring_physaddr;
221 u32 local_psr_full;
222 u32 psr_num_entries;
223
224 struct rx_status_block *rx_status_block;
225 dma_addr_t rx_status_bus;
226
227 struct list_head recv_buff_pool;
228
229 /* RECV */
230 struct list_head recv_list;
231 u32 num_ready_recv;
232
233 u32 num_rfd;
234
235 bool unfinished_receives;
236
237 struct list_head recv_packet_pool;
238
239 /* lookaside lists */
240 struct kmem_cache *recv_lookaside;
241};
242
243#endif /* __ET1310_RX_H__ */
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 402ab7f7ae27..484a626a81fa 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -82,7 +82,6 @@
82#include <linux/phy.h> 82#include <linux/phy.h>
83 83
84#include "et1310_tx.h" 84#include "et1310_tx.h"
85#include "et1310_rx.h"
86#include "et131x.h" 85#include "et131x.h"
87 86
88MODULE_AUTHOR("Victor Soriano <vjsoriano@agere.com>"); 87MODULE_AUTHOR("Victor Soriano <vjsoriano@agere.com>");
@@ -186,6 +185,186 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
186#define PARM_TX_NUM_BUFS_DEF 4 185#define PARM_TX_NUM_BUFS_DEF 4
187#define PARM_DMA_CACHE_DEF 0 186#define PARM_DMA_CACHE_DEF 0
188 187
188/* RX defines */
189#define USE_FBR0 true
190
191#ifdef USE_FBR0
192/* #define FBR0_BUFFER_SIZE 256 */
193#endif
194
195/* #define FBR1_BUFFER_SIZE 2048 */
196
197#define FBR_CHUNKS 32
198
199#define MAX_DESC_PER_RING_RX 1024
200
201/* number of RFDs - default and min */
202#ifdef USE_FBR0
203#define RFD_LOW_WATER_MARK 40
204#define NIC_MIN_NUM_RFD 64
205#define NIC_DEFAULT_NUM_RFD 1024
206#else
207#define RFD_LOW_WATER_MARK 20
208#define NIC_MIN_NUM_RFD 64
209#define NIC_DEFAULT_NUM_RFD 256
210#endif
211
212#define NUM_PACKETS_HANDLED 256
213
214#define ALCATEL_BAD_STATUS 0xe47f0000
215#define ALCATEL_MULTICAST_PKT 0x01000000
216#define ALCATEL_BROADCAST_PKT 0x02000000
217
218/* typedefs for Free Buffer Descriptors */
219struct fbr_desc {
220 u32 addr_lo;
221 u32 addr_hi;
222 u32 word2; /* Bits 10-31 reserved, 0-9 descriptor */
223};
224
225/* Packet Status Ring Descriptors
226 *
227 * Word 0:
228 *
229 * top 16 bits are from the Alcatel Status Word as enumerated in
230 * PE-MCXMAC Data Sheet IPD DS54 0210-1 (also IPD-DS80 0205-2)
231 *
232 * 0: hp hash pass
233 * 1: ipa IP checksum assist
234 * 2: ipp IP checksum pass
235 * 3: tcpa TCP checksum assist
236 * 4: tcpp TCP checksum pass
237 * 5: wol WOL Event
238 * 6: rxmac_error RXMAC Error Indicator
239 * 7: drop Drop packet
240 * 8: ft Frame Truncated
241 * 9: jp Jumbo Packet
242 * 10: vp VLAN Packet
243 * 11-15: unused
244 * 16: asw_prev_pkt_dropped e.g. IFG too small on previous
245 * 17: asw_RX_DV_event short receive event detected
246 * 18: asw_false_carrier_event bad carrier since last good packet
247 * 19: asw_code_err one or more nibbles signalled as errors
248 * 20: asw_CRC_err CRC error
249 * 21: asw_len_chk_err frame length field incorrect
250 * 22: asw_too_long frame length > 1518 bytes
251 * 23: asw_OK valid CRC + no code error
252 * 24: asw_multicast has a multicast address
253 * 25: asw_broadcast has a broadcast address
254 * 26: asw_dribble_nibble spurious bits after EOP
255 * 27: asw_control_frame is a control frame
256 * 28: asw_pause_frame is a pause frame
257 * 29: asw_unsupported_op unsupported OP code
258 * 30: asw_VLAN_tag VLAN tag detected
259 * 31: asw_long_evt Rx long event
260 *
261 * Word 1:
262 * 0-15: length length in bytes
263 * 16-25: bi Buffer Index
264 * 26-27: ri Ring Index
265 * 28-31: reserved
266 */
267
268struct pkt_stat_desc {
269 u32 word0;
270 u32 word1;
271};
272
273/* Typedefs for the RX DMA status word */
274
275/*
276 * rx status word 0 holds part of the status bits of the Rx DMA engine
277 * that get copied out to memory by the ET-1310. Word 0 is a 32 bit word
278 * which contains the Free Buffer ring 0 and 1 available offset.
279 *
280 * bit 0-9 FBR1 offset
281 * bit 10 Wrap flag for FBR1
282 * bit 16-25 FBR0 offset
283 * bit 26 Wrap flag for FBR0
284 */
285
286/*
287 * RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine
288 * that get copied out to memory by the ET-1310. Word 3 is a 32 bit word
289 * which contains the Packet Status Ring available offset.
290 *
291 * bit 0-15 reserved
292 * bit 16-27 PSRoffset
293 * bit 28 PSRwrap
294 * bit 29-31 unused
295 */
296
297/*
298 * struct rx_status_block is a structure representing the status of the Rx
299 * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020
300 */
301struct rx_status_block {
302 u32 word0;
303 u32 word1;
304};
305
306/*
307 * Structure for look-up table holding free buffer ring pointers
308 */
309struct fbr_lookup {
310 void *virt[MAX_DESC_PER_RING_RX];
311 void *buffer1[MAX_DESC_PER_RING_RX];
312 void *buffer2[MAX_DESC_PER_RING_RX];
313 u32 bus_high[MAX_DESC_PER_RING_RX];
314 u32 bus_low[MAX_DESC_PER_RING_RX];
315};
316
317/*
318 * struct rx_ring is the sructure representing the adaptor's local
319 * reference(s) to the rings
320 */
321struct rx_ring {
322#ifdef USE_FBR0
323 void *fbr0_ring_virtaddr;
324 dma_addr_t fbr0_ring_physaddr;
325 void *fbr0_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
326 dma_addr_t fbr0_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
327 uint64_t fbr0_real_physaddr;
328 uint64_t fbr0_offset;
329 u32 local_fbr0_full;
330 u32 fbr0_num_entries;
331 u32 fbr0_buffsize;
332#endif
333 void *fbr1_ring_virtaddr;
334 dma_addr_t fbr1_ring_physaddr;
335 void *fbr1_mem_virtaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
336 dma_addr_t fbr1_mem_physaddrs[MAX_DESC_PER_RING_RX / FBR_CHUNKS];
337 uint64_t fbr1_real_physaddr;
338 uint64_t fbr1_offset;
339 struct fbr_lookup *fbr[2]; /* One per ring */
340 u32 local_fbr1_full;
341 u32 fbr1_num_entries;
342 u32 fbr1_buffsize;
343
344 void *ps_ring_virtaddr;
345 dma_addr_t ps_ring_physaddr;
346 u32 local_psr_full;
347 u32 psr_num_entries;
348
349 struct rx_status_block *rx_status_block;
350 dma_addr_t rx_status_bus;
351
352 struct list_head recv_buff_pool;
353
354 /* RECV */
355 struct list_head recv_list;
356 u32 num_ready_recv;
357
358 u32 num_rfd;
359
360 bool unfinished_receives;
361
362 struct list_head recv_packet_pool;
363
364 /* lookaside lists */
365 struct kmem_cache *recv_lookaside;
366};
367
189/* ADAPTER defines */ 368/* ADAPTER defines */
190/* 369/*
191 * Do not change these values: if changed, then change also in respective 370 * Do not change these values: if changed, then change also in respective