1 /****************************************************************************** |
|
2 * |
|
3 * drv_8139too.c |
|
4 * |
|
5 * EtherCAT-Treiber für RTL8139-kompatible Netzwerkkarten. |
|
6 * |
|
7 * Autoren: Wilhelm Hagemeister, Florian Pose |
|
8 * |
|
9 * $Date$ |
|
10 * $Author$ |
|
11 * |
|
12 * (C) Copyright IgH 2005 |
|
13 * Ingenieurgemeinschaft IgH |
|
14 * Heinz-Bäcker Str. 34 |
|
15 * D-45356 Essen |
|
16 * Tel.: +49 201/61 99 31 |
|
17 * Fax.: +49 201/61 98 36 |
|
18 * E-mail: sp@igh-essen.com |
|
19 * |
|
20 ******************************************************************************/ |
|
21 |
|
22 /* |
|
23 8139too.c: A RealTek RTL-8139 Fast Ethernet driver for Linux. |
|
24 |
|
25 Maintained by Jeff Garzik <jgarzik@mandrakesoft.com> |
|
26 Copyright 2000-2002 Jeff Garzik |
|
27 |
|
28 Much code comes from Donald Becker's rtl8139.c driver, |
|
29 versions 1.13 and older. This driver was originally based |
|
30 on rtl8139.c version 1.07. Header of rtl8139.c version 1.13: |
|
31 |
|
32 -----<snip>----- |
|
33 |
|
34 Written 1997-2001 by Donald Becker. |
|
35 This software may be used and distributed according to the |
|
36 terms of the GNU General Public License (GPL), incorporated |
|
37 herein by reference. Drivers based on or derived from this |
|
38 code fall under the GPL and must retain the authorship, |
|
39 copyright and license notice. This file is not a complete |
|
40 program and may only be used when the entire operating |
|
41 system is licensed under the GPL. |
|
42 |
|
43 This driver is for boards based on the RTL8129 and RTL8139 |
|
44 PCI ethernet chips. |
|
45 |
|
46 The author may be reached as becker@scyld.com, or C/O Scyld |
|
47 Computing Corporation 410 Severn Ave., Suite 210 Annapolis |
|
48 MD 21403 |
|
49 |
|
50 Support and updates available at |
|
51 http://www.scyld.com/network/rtl8139.html |
|
52 |
|
53 Twister-tuning table provided by Kinston |
|
54 <shangh@realtek.com.tw>. |
|
55 |
|
56 -----<snip>----- |
|
57 |
|
58 This software may be used and distributed according to the terms |
|
59 of the GNU General Public License, incorporated herein by reference. |
|
60 |
|
61 Contributors: |
|
62 |
|
63 Donald Becker - he wrote the original driver, kudos to him! |
|
64 (but please don't e-mail him for support, this isn't his driver) |
|
65 |
|
66 Tigran Aivazian - bug fixes, skbuff free cleanup |
|
67 |
|
68 Martin Mares - suggestions for PCI cleanup |
|
69 |
|
70 David S. Miller - PCI DMA and softnet updates |
|
71 |
|
72 Ernst Gill - fixes ported from BSD driver |
|
73 |
|
74 Daniel Kobras - identified specific locations of |
|
75 posted MMIO write bugginess |
|
76 |
|
77 Gerard Sharp - bug fix, testing and feedback |
|
78 |
|
79 David Ford - Rx ring wrap fix |
|
80 |
|
81 Dan DeMaggio - swapped RTL8139 cards with me, and allowed me |
|
82 to find and fix a crucial bug on older chipsets. |
|
83 |
|
84 Donald Becker/Chris Butterworth/Marcus Westergren - |
|
85 Noticed various Rx packet size-related buglets. |
|
86 |
|
87 Santiago Garcia Mantinan - testing and feedback |
|
88 |
|
89 Jens David - 2.2.x kernel backports |
|
90 |
|
91 Martin Dennett - incredibly helpful insight on undocumented |
|
92 features of the 8139 chips |
|
93 |
|
94 Jean-Jacques Michel - bug fix |
|
95 |
|
96 Tobias Ringström - Rx interrupt status checking suggestion |
|
97 |
|
98 Andrew Morton - Clear blocked signals, avoid |
|
99 buffer overrun setting current->comm. |
|
100 |
|
101 Kalle Olavi Niemitalo - Wake-on-LAN ioctls |
|
102 |
|
103 Robert Kuebel - Save kernel thread from dying on any signal. |
|
104 |
|
105 Submitting bug reports: |
|
106 |
|
107 "rtl8139-diag -mmmaaavvveefN" output |
|
108 enable RTL8139_DEBUG below, and look at 'dmesg' or kernel log |
|
109 |
|
110 See 8139too.txt for more details. |
|
111 |
|
112 */ |
|
113 |
|
114 #define DRV_NAME "8139too_ecat" |
|
115 #define DRV_VERSION "0.9.26" |
|
116 |
|
117 |
|
118 #include <linux/config.h> |
|
119 #include <linux/module.h> |
|
120 #include <linux/kernel.h> |
|
121 #include <linux/compiler.h> |
|
122 #include <linux/pci.h> |
|
123 #include <linux/init.h> |
|
124 #include <linux/ioport.h> |
|
125 #include <linux/netdevice.h> |
|
126 #include <linux/etherdevice.h> |
|
127 #include <linux/rtnetlink.h> |
|
128 #include <linux/delay.h> |
|
129 #include <linux/ethtool.h> |
|
130 #include <linux/mii.h> |
|
131 #include <linux/completion.h> |
|
132 #include <linux/crc32.h> |
|
133 #include <asm/io.h> |
|
134 #include <asm/uaccess.h> |
|
135 |
|
136 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
137 |
|
138 #include "ec_device.h" |
|
139 #include "ec_dbg.h" |
|
140 |
|
141 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
142 |
|
143 #define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION |
|
144 #define PFX DRV_NAME ": " |
|
145 |
|
146 |
|
147 /* enable PIO instead of MMIO, if CONFIG_8139TOO_PIO is selected */ |
|
148 #ifdef CONFIG_8139TOO_PIO |
|
149 #define USE_IO_OPS 1 |
|
150 #endif |
|
151 |
|
152 /* define to 1 to enable copious debugging info */ |
|
153 //#define RTL8139_DEBUG 1 |
|
154 #undef RTL8139_DEBUG |
|
155 |
|
156 /* define to 1 to disable lightweight runtime debugging checks */ |
|
157 #undef RTL8139_NDEBUG |
|
158 |
|
159 |
|
160 #ifdef RTL8139_DEBUG |
|
161 /* note: prints function name for you */ |
|
162 # define DPRINTK(fmt, args...) EC_DBG(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) |
|
163 #else |
|
164 # define DPRINTK(fmt, args...) |
|
165 #endif |
|
166 |
|
167 #ifdef RTL8139_NDEBUG |
|
168 # define assert(expr) do {} while (0) |
|
169 #else |
|
170 # define assert(expr) \ |
|
171 if(!(expr)) { \ |
|
172 printk( "Assertion failed! %s,%s,%s,line=%d\n", \ |
|
173 #expr,__FILE__,__FUNCTION__,__LINE__); \ |
|
174 } |
|
175 #endif |
|
176 |
|
177 |
|
178 /* A few user-configurable values. */ |
|
179 /* media options */ |
|
180 #define MAX_UNITS 8 |
|
181 static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
|
182 static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
|
183 |
|
184 /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ |
|
185 static int max_interrupt_work = 20; |
|
186 |
|
187 /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). |
|
188 The RTL chips use a 64 element hash table based on the Ethernet CRC. */ |
|
189 static int multicast_filter_limit = 32; |
|
190 |
|
191 /* bitmapped message enable number */ |
|
192 static int debug = -1; |
|
193 |
|
194 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
195 |
|
196 // Device index for EtherCAT device selection |
|
197 static int ec_device_index = -1; |
|
198 |
|
199 //#define ECAT_DEBUG |
|
200 |
|
201 EtherCAT_device_t rtl_ecat_dev; |
|
202 |
|
203 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
204 |
|
205 /* Size of the in-memory receive ring. */ |
|
206 #define RX_BUF_LEN_IDX 2 /* 0==8K, 1==16K, 2==32K, 3==64K */ |
|
207 #define RX_BUF_LEN (8192 << RX_BUF_LEN_IDX) |
|
208 #define RX_BUF_PAD 16 |
|
209 #define RX_BUF_WRAP_PAD 2048 /* spare padding to handle lack of packet wrap */ |
|
210 #define RX_BUF_TOT_LEN (RX_BUF_LEN + RX_BUF_PAD + RX_BUF_WRAP_PAD) |
|
211 |
|
212 /* Number of Tx descriptor registers. */ |
|
213 #define NUM_TX_DESC 4 |
|
214 |
|
215 /* max supported ethernet frame size -- must be at least (dev->mtu+14+4).*/ |
|
216 #define MAX_ETH_FRAME_SIZE 1536 |
|
217 |
|
218 /* Size of the Tx bounce buffers -- must be at least (dev->mtu+14+4). */ |
|
219 #define TX_BUF_SIZE MAX_ETH_FRAME_SIZE |
|
220 #define TX_BUF_TOT_LEN (TX_BUF_SIZE * NUM_TX_DESC) |
|
221 |
|
222 /* PCI Tuning Parameters |
|
223 Threshold is bytes transferred to chip before transmission starts. */ |
|
224 #define TX_FIFO_THRESH 256 /* In bytes, rounded down to 32 byte units. */ |
|
225 |
|
226 /* The following settings are log_2(bytes)-4: 0 == 16 bytes .. 6==1024, 7==end of packet. */ |
|
227 #define RX_FIFO_THRESH 7 /* Rx buffer level before first PCI xfer. */ |
|
228 #define RX_DMA_BURST 7 /* Maximum PCI burst, '6' is 1024 */ |
|
229 #define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ |
|
230 #define TX_RETRY 8 /* 0-15. retries = 16 + (TX_RETRY * 16) */ |
|
231 |
|
232 /* Operational parameters that usually are not changed. */ |
|
233 /* Time in jiffies before concluding the transmitter is hung. */ |
|
234 #define TX_TIMEOUT (6*HZ) |
|
235 |
|
236 |
|
237 enum { |
|
238 HAS_MII_XCVR = 0x010000, |
|
239 HAS_CHIP_XCVR = 0x020000, |
|
240 HAS_LNK_CHNG = 0x040000, |
|
241 }; |
|
242 |
|
243 #define RTL_NUM_STATS 4 /* number of ETHTOOL_GSTATS u64's */ |
|
244 #define RTL_REGS_VER 1 /* version of reg. data in ETHTOOL_GREGS */ |
|
245 #define RTL_MIN_IO_SIZE 0x80 |
|
246 #define RTL8139B_IO_SIZE 256 |
|
247 |
|
248 #define RTL8129_CAPS HAS_MII_XCVR |
|
249 #define RTL8139_CAPS HAS_CHIP_XCVR|HAS_LNK_CHNG |
|
250 |
|
251 typedef enum { |
|
252 RTL8139 = 0, |
|
253 RTL8139_CB, |
|
254 SMC1211TX, |
|
255 /*MPX5030,*/ |
|
256 DELTA8139, |
|
257 ADDTRON8139, |
|
258 DFE538TX, |
|
259 DFE690TXD, |
|
260 FE2000VX, |
|
261 ALLIED8139, |
|
262 RTL8129, |
|
263 FNW3603TX, |
|
264 FNW3800TX, |
|
265 } board_t; |
|
266 |
|
267 |
|
268 /* indexed by board_t, above */ |
|
269 static struct { |
|
270 const char *name; |
|
271 u32 hw_flags; |
|
272 } board_info[] __devinitdata = { |
|
273 { "RealTek RTL8139 Fast Ethernet", RTL8139_CAPS }, |
|
274 { "RealTek RTL8139B PCI/CardBus", RTL8139_CAPS }, |
|
275 { "SMC1211TX EZCard 10/100 (RealTek RTL8139)", RTL8139_CAPS }, |
|
276 /* { MPX5030, "Accton MPX5030 (RealTek RTL8139)", RTL8139_CAPS },*/ |
|
277 { "Delta Electronics 8139 10/100BaseTX", RTL8139_CAPS }, |
|
278 { "Addtron Technolgy 8139 10/100BaseTX", RTL8139_CAPS }, |
|
279 { "D-Link DFE-538TX (RealTek RTL8139)", RTL8139_CAPS }, |
|
280 { "D-Link DFE-690TXD (RealTek RTL8139)", RTL8139_CAPS }, |
|
281 { "AboCom FE2000VX (RealTek RTL8139)", RTL8139_CAPS }, |
|
282 { "Allied Telesyn 8139 CardBus", RTL8139_CAPS }, |
|
283 { "RealTek RTL8129", RTL8129_CAPS }, |
|
284 { "Planex FNW-3603-TX 10/100 CardBus", RTL8139_CAPS }, |
|
285 { "Planex FNW-3800-TX 10/100 CardBus", RTL8139_CAPS }, |
|
286 }; |
|
287 |
|
288 |
|
289 static struct pci_device_id rtl8139_pci_tbl[] __devinitdata = { |
|
290 {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, |
|
291 {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139_CB }, |
|
292 {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMC1211TX }, |
|
293 /* {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MPX5030 },*/ |
|
294 {0x1500, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DELTA8139 }, |
|
295 {0x4033, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ADDTRON8139 }, |
|
296 {0x1186, 0x1300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE538TX }, |
|
297 {0x1186, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DFE690TXD }, |
|
298 {0x13d1, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FE2000VX }, |
|
299 {0x1259, 0xa117, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ALLIED8139 }, |
|
300 {0x14ea, 0xab06, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3603TX }, |
|
301 {0x14ea, 0xab07, PCI_ANY_ID, PCI_ANY_ID, 0, 0, FNW3800TX }, |
|
302 |
|
303 #ifdef CONFIG_8139TOO_8129 |
|
304 {0x10ec, 0x8129, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8129 }, |
|
305 #endif |
|
306 |
|
307 /* some crazy cards report invalid vendor ids like |
|
308 * 0x0001 here. The other ids are valid and constant, |
|
309 * so we simply don't match on the main vendor id. |
|
310 */ |
|
311 {PCI_ANY_ID, 0x8139, 0x10ec, 0x8139, 0, 0, RTL8139 }, |
|
312 {PCI_ANY_ID, 0x8139, 0x1186, 0x1300, 0, 0, DFE538TX }, |
|
313 {PCI_ANY_ID, 0x8139, 0x13d1, 0xab06, 0, 0, FE2000VX }, |
|
314 |
|
315 {0,} |
|
316 }; |
|
317 MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl); |
|
318 |
|
319 static struct { |
|
320 const char str[ETH_GSTRING_LEN]; |
|
321 } ethtool_stats_keys[] = { |
|
322 { "early_rx" }, |
|
323 { "tx_buf_mapped" }, |
|
324 { "tx_timeouts" }, |
|
325 { "rx_lost_in_ring" }, |
|
326 }; |
|
327 |
|
328 /* The rest of these values should never change. */ |
|
329 |
|
330 /* Symbolic offsets to registers. */ |
|
331 enum RTL8139_registers { |
|
332 MAC0 = 0, /* Ethernet hardware address. */ |
|
333 MAR0 = 8, /* Multicast filter. */ |
|
334 TxStatus0 = 0x10, /* Transmit status (Four 32bit registers). */ |
|
335 TxAddr0 = 0x20, /* Tx descriptors (also four 32bit). */ |
|
336 RxBuf = 0x30, |
|
337 ChipCmd = 0x37, |
|
338 RxBufPtr = 0x38, |
|
339 RxBufAddr = 0x3A, |
|
340 IntrMask = 0x3C, |
|
341 IntrStatus = 0x3E, |
|
342 TxConfig = 0x40, |
|
343 ChipVersion = 0x43, |
|
344 RxConfig = 0x44, |
|
345 Timer = 0x48, /* A general-purpose counter. */ |
|
346 RxMissed = 0x4C, /* 24 bits valid, write clears. */ |
|
347 Cfg9346 = 0x50, |
|
348 Config0 = 0x51, |
|
349 Config1 = 0x52, |
|
350 FlashReg = 0x54, |
|
351 MediaStatus = 0x58, |
|
352 Config3 = 0x59, |
|
353 Config4 = 0x5A, /* absent on RTL-8139A */ |
|
354 HltClk = 0x5B, |
|
355 MultiIntr = 0x5C, |
|
356 TxSummary = 0x60, |
|
357 BasicModeCtrl = 0x62, |
|
358 BasicModeStatus = 0x64, |
|
359 NWayAdvert = 0x66, |
|
360 NWayLPAR = 0x68, |
|
361 NWayExpansion = 0x6A, |
|
362 /* Undocumented registers, but required for proper operation. */ |
|
363 FIFOTMS = 0x70, /* FIFO Control and test. */ |
|
364 CSCR = 0x74, /* Chip Status and Configuration Register. */ |
|
365 PARA78 = 0x78, |
|
366 PARA7c = 0x7c, /* Magic transceiver parameter register. */ |
|
367 Config5 = 0xD8, /* absent on RTL-8139A */ |
|
368 }; |
|
369 |
|
370 enum ClearBitMasks { |
|
371 MultiIntrClear = 0xF000, |
|
372 ChipCmdClear = 0xE2, |
|
373 Config1Clear = (1<<7)|(1<<6)|(1<<3)|(1<<2)|(1<<1), |
|
374 }; |
|
375 |
|
376 enum ChipCmdBits { |
|
377 CmdReset = 0x10, |
|
378 CmdRxEnb = 0x08, |
|
379 CmdTxEnb = 0x04, |
|
380 RxBufEmpty = 0x01, |
|
381 }; |
|
382 |
|
383 /* Interrupt register bits, using my own meaningful names. */ |
|
384 enum IntrStatusBits { |
|
385 PCIErr = 0x8000, |
|
386 PCSTimeout = 0x4000, |
|
387 RxFIFOOver = 0x40, |
|
388 RxUnderrun = 0x20, |
|
389 RxOverflow = 0x10, |
|
390 TxErr = 0x08, |
|
391 TxOK = 0x04, |
|
392 RxErr = 0x02, |
|
393 RxOK = 0x01, |
|
394 |
|
395 RxAckBits = RxFIFOOver | RxOverflow | RxOK, |
|
396 }; |
|
397 |
|
398 enum TxStatusBits { |
|
399 TxHostOwns = 0x2000, |
|
400 TxUnderrun = 0x4000, |
|
401 TxStatOK = 0x8000, |
|
402 TxOutOfWindow = 0x20000000, |
|
403 TxAborted = 0x40000000, |
|
404 TxCarrierLost = 0x80000000, |
|
405 }; |
|
406 enum RxStatusBits { |
|
407 RxMulticast = 0x8000, |
|
408 RxPhysical = 0x4000, |
|
409 RxBroadcast = 0x2000, |
|
410 RxBadSymbol = 0x0020, |
|
411 RxRunt = 0x0010, |
|
412 RxTooLong = 0x0008, |
|
413 RxCRCErr = 0x0004, |
|
414 RxBadAlign = 0x0002, |
|
415 RxStatusOK = 0x0001, |
|
416 }; |
|
417 |
|
418 /* Bits in RxConfig. */ |
|
419 enum rx_mode_bits { |
|
420 AcceptErr = 0x20, |
|
421 AcceptRunt = 0x10, |
|
422 AcceptBroadcast = 0x08, |
|
423 AcceptMulticast = 0x04, |
|
424 AcceptMyPhys = 0x02, |
|
425 AcceptAllPhys = 0x01, |
|
426 }; |
|
427 |
|
428 /* Bits in TxConfig. */ |
|
429 enum tx_config_bits { |
|
430 TxIFG1 = (1 << 25), /* Interframe Gap Time */ |
|
431 TxIFG0 = (1 << 24), /* Enabling these bits violates IEEE 802.3 */ |
|
432 TxLoopBack = (1 << 18) | (1 << 17), /* enable loopback test mode */ |
|
433 TxCRC = (1 << 16), /* DISABLE appending CRC to end of Tx packets */ |
|
434 TxClearAbt = (1 << 0), /* Clear abort (WO) */ |
|
435 TxDMAShift = 8, /* DMA burst value (0-7) is shifted this many bits */ |
|
436 TxRetryShift = 4, /* TXRR value (0-15) is shifted this many bits */ |
|
437 |
|
438 TxVersionMask = 0x7C800000, /* mask out version bits 30-26, 23 */ |
|
439 }; |
|
440 |
|
441 /* Bits in Config1 */ |
|
442 enum Config1Bits { |
|
443 Cfg1_PM_Enable = 0x01, |
|
444 Cfg1_VPD_Enable = 0x02, |
|
445 Cfg1_PIO = 0x04, |
|
446 Cfg1_MMIO = 0x08, |
|
447 LWAKE = 0x10, /* not on 8139, 8139A */ |
|
448 Cfg1_Driver_Load = 0x20, |
|
449 Cfg1_LED0 = 0x40, |
|
450 Cfg1_LED1 = 0x80, |
|
451 SLEEP = (1 << 1), /* only on 8139, 8139A */ |
|
452 PWRDN = (1 << 0), /* only on 8139, 8139A */ |
|
453 }; |
|
454 |
|
455 /* Bits in Config3 */ |
|
456 enum Config3Bits { |
|
457 Cfg3_FBtBEn = (1 << 0), /* 1 = Fast Back to Back */ |
|
458 Cfg3_FuncRegEn = (1 << 1), /* 1 = enable CardBus Function registers */ |
|
459 Cfg3_CLKRUN_En = (1 << 2), /* 1 = enable CLKRUN */ |
|
460 Cfg3_CardB_En = (1 << 3), /* 1 = enable CardBus registers */ |
|
461 Cfg3_LinkUp = (1 << 4), /* 1 = wake up on link up */ |
|
462 Cfg3_Magic = (1 << 5), /* 1 = wake up on Magic Packet (tm) */ |
|
463 Cfg3_PARM_En = (1 << 6), /* 0 = software can set twister parameters */ |
|
464 Cfg3_GNTSel = (1 << 7), /* 1 = delay 1 clock from PCI GNT signal */ |
|
465 }; |
|
466 |
|
467 /* Bits in Config4 */ |
|
468 enum Config4Bits { |
|
469 LWPTN = (1 << 2), /* not on 8139, 8139A */ |
|
470 }; |
|
471 |
|
472 /* Bits in Config5 */ |
|
473 enum Config5Bits { |
|
474 Cfg5_PME_STS = (1 << 0), /* 1 = PCI reset resets PME_Status */ |
|
475 Cfg5_LANWake = (1 << 1), /* 1 = enable LANWake signal */ |
|
476 Cfg5_LDPS = (1 << 2), /* 0 = save power when link is down */ |
|
477 Cfg5_FIFOAddrPtr = (1 << 3), /* Realtek internal SRAM testing */ |
|
478 Cfg5_UWF = (1 << 4), /* 1 = accept unicast wakeup frame */ |
|
479 Cfg5_MWF = (1 << 5), /* 1 = accept multicast wakeup frame */ |
|
480 Cfg5_BWF = (1 << 6), /* 1 = accept broadcast wakeup frame */ |
|
481 }; |
|
482 |
|
483 enum RxConfigBits { |
|
484 /* rx fifo threshold */ |
|
485 RxCfgFIFOShift = 13, |
|
486 RxCfgFIFONone = (7 << RxCfgFIFOShift), |
|
487 |
|
488 /* Max DMA burst */ |
|
489 RxCfgDMAShift = 8, |
|
490 RxCfgDMAUnlimited = (7 << RxCfgDMAShift), |
|
491 |
|
492 /* rx ring buffer length */ |
|
493 RxCfgRcv8K = 0, |
|
494 RxCfgRcv16K = (1 << 11), |
|
495 RxCfgRcv32K = (1 << 12), |
|
496 RxCfgRcv64K = (1 << 11) | (1 << 12), |
|
497 |
|
498 /* Disable packet wrap at end of Rx buffer */ |
|
499 RxNoWrap = (1 << 7), |
|
500 }; |
|
501 |
|
502 |
|
503 /* Twister tuning parameters from RealTek. |
|
504 Completely undocumented, but required to tune bad links on some boards. */ |
|
505 enum CSCRBits { |
|
506 CSCR_LinkOKBit = 0x0400, |
|
507 CSCR_LinkChangeBit = 0x0800, |
|
508 CSCR_LinkStatusBits = 0x0f000, |
|
509 CSCR_LinkDownOffCmd = 0x003c0, |
|
510 CSCR_LinkDownCmd = 0x0f3c0, |
|
511 }; |
|
512 |
|
513 |
|
514 enum Cfg9346Bits { |
|
515 Cfg9346_Lock = 0x00, |
|
516 Cfg9346_Unlock = 0xC0, |
|
517 }; |
|
518 |
|
519 #ifdef CONFIG_8139TOO_TUNE_TWISTER |
|
520 |
|
521 enum TwisterParamVals { |
|
522 PARA78_default = 0x78fa8388, |
|
523 PARA7c_default = 0xcb38de43, /* param[0][3] */ |
|
524 PARA7c_xxx = 0xcb38de43, |
|
525 }; |
|
526 |
|
527 static const unsigned long param[4][4] = { |
|
528 {0xcb39de43, 0xcb39ce43, 0xfb38de03, 0xcb38de43}, |
|
529 {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83}, |
|
530 {0xcb39de43, 0xcb39ce43, 0xcb39ce83, 0xcb39ce83}, |
|
531 {0xbb39de43, 0xbb39ce43, 0xbb39ce83, 0xbb39ce83} |
|
532 }; |
|
533 |
|
534 #endif /* CONFIG_8139TOO_TUNE_TWISTER */ |
|
535 |
|
536 typedef enum { |
|
537 CH_8139 = 0, |
|
538 CH_8139_K, |
|
539 CH_8139A, |
|
540 CH_8139B, |
|
541 CH_8130, |
|
542 CH_8139C, |
|
543 } chip_t; |
|
544 |
|
545 enum chip_flags { |
|
546 HasHltClk = (1 << 0), |
|
547 HasLWake = (1 << 1), |
|
548 }; |
|
549 |
|
550 |
|
551 /* directly indexed by chip_t, above */ |
|
552 const static struct { |
|
553 const char *name; |
|
554 u8 version; /* from RTL8139C docs */ |
|
555 u32 RxConfigMask; /* should clear the bits supported by this chip */ |
|
556 u32 flags; |
|
557 } rtl_chip_info[] = { |
|
558 { "RTL-8139", |
|
559 0x40, |
|
560 0xf0fe0040, /* XXX copied from RTL8139A, verify */ |
|
561 HasHltClk, |
|
562 }, |
|
563 |
|
564 { "RTL-8139 rev K", |
|
565 0x60, |
|
566 0xf0fe0040, |
|
567 HasHltClk, |
|
568 }, |
|
569 |
|
570 { "RTL-8139A", |
|
571 0x70, |
|
572 0xf0fe0040, |
|
573 HasHltClk, /* XXX undocumented? */ |
|
574 }, |
|
575 |
|
576 { "RTL-8139B", |
|
577 0x78, |
|
578 0xf0fc0040, |
|
579 HasLWake, |
|
580 }, |
|
581 |
|
582 { "RTL-8130", |
|
583 0x7C, |
|
584 0xf0fe0040, /* XXX copied from RTL8139A, verify */ |
|
585 HasLWake, |
|
586 }, |
|
587 |
|
588 { "RTL-8139C", |
|
589 0x74, |
|
590 0xf0fc0040, /* XXX copied from RTL8139B, verify */ |
|
591 HasLWake, |
|
592 }, |
|
593 |
|
594 }; |
|
595 |
|
596 struct rtl_extra_stats { |
|
597 unsigned long early_rx; |
|
598 unsigned long tx_buf_mapped; |
|
599 unsigned long tx_timeouts; |
|
600 unsigned long rx_lost_in_ring; |
|
601 }; |
|
602 |
|
603 struct rtl8139_private { |
|
604 void *mmio_addr; |
|
605 int drv_flags; |
|
606 struct pci_dev *pci_dev; |
|
607 struct net_device_stats stats; |
|
608 unsigned char *rx_ring; |
|
609 unsigned int cur_rx; /* Index into the Rx buffer of next Rx pkt. */ |
|
610 unsigned int tx_flag; |
|
611 unsigned long cur_tx; |
|
612 unsigned long dirty_tx; |
|
613 unsigned char *tx_buf[NUM_TX_DESC]; /* Tx bounce buffers */ |
|
614 unsigned char *tx_bufs; /* Tx bounce buffer region. */ |
|
615 dma_addr_t rx_ring_dma; |
|
616 dma_addr_t tx_bufs_dma; |
|
617 signed char phys[4]; /* MII device addresses. */ |
|
618 char twistie, twist_row, twist_col; /* Twister tune state. */ |
|
619 unsigned int default_port:4; /* Last dev->if_port value. */ |
|
620 spinlock_t lock; |
|
621 chip_t chipset; |
|
622 pid_t thr_pid; |
|
623 wait_queue_head_t thr_wait; |
|
624 struct completion thr_exited; |
|
625 u32 rx_config; |
|
626 struct rtl_extra_stats xstats; |
|
627 int time_to_die; |
|
628 struct mii_if_info mii; |
|
629 unsigned int regs_len; |
|
630 }; |
|
631 |
|
632 MODULE_AUTHOR ("Jeff Garzik <jgarzik@mandrakesoft.com>"); |
|
633 MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver"); |
|
634 MODULE_LICENSE("GPL"); |
|
635 |
|
636 MODULE_PARM (multicast_filter_limit, "i"); |
|
637 MODULE_PARM (max_interrupt_work, "i"); |
|
638 MODULE_PARM (media, "1-" __MODULE_STRING(MAX_UNITS) "i"); |
|
639 MODULE_PARM (full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i"); |
|
640 MODULE_PARM (debug, "i"); |
|
641 MODULE_PARM_DESC (debug, "8139too bitmapped message enable number"); |
|
642 MODULE_PARM_DESC (multicast_filter_limit, "8139too maximum number of filtered multicast addresses"); |
|
643 MODULE_PARM_DESC (max_interrupt_work, "8139too maximum events handled per interrupt"); |
|
644 MODULE_PARM_DESC (media, "8139too: Bits 4+9: force full duplex, bit 5: 100Mbps"); |
|
645 MODULE_PARM_DESC (full_duplex, "8139too: Force full duplex for board(s) (1)"); |
|
646 |
|
647 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
648 |
|
649 MODULE_PARM(ec_device_index, "i"); |
|
650 MODULE_PARM_DESC(ec_device_index, "Index of the device reserved for EtherCAT."); |
|
651 |
|
652 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
653 |
|
654 static int read_eeprom (void *ioaddr, int location, int addr_len); |
|
655 static int rtl8139_open (struct net_device *dev); |
|
656 static int mdio_read (struct net_device *dev, int phy_id, int location); |
|
657 static void mdio_write (struct net_device *dev, int phy_id, int location, |
|
658 int val); |
|
659 static int rtl8139_thread (void *data); |
|
660 static void rtl8139_tx_timeout (struct net_device *dev); |
|
661 static void rtl8139_init_ring (struct net_device *dev); |
|
662 static int rtl8139_start_xmit (struct sk_buff *skb, |
|
663 struct net_device *dev); |
|
664 static void rtl8139_interrupt (int irq, void *dev_instance, |
|
665 struct pt_regs *regs); |
|
666 static int rtl8139_close (struct net_device *dev); |
|
667 static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd); |
|
668 static struct net_device_stats *rtl8139_get_stats (struct net_device *dev); |
|
669 static void rtl8139_set_rx_mode (struct net_device *dev); |
|
670 static void __set_rx_mode (struct net_device *dev); |
|
671 static void rtl8139_hw_start (struct net_device *dev); |
|
672 |
|
673 #ifdef USE_IO_OPS |
|
674 |
|
675 #define RTL_R8(reg) inb (((unsigned long)ioaddr) + (reg)) |
|
676 #define RTL_R16(reg) inw (((unsigned long)ioaddr) + (reg)) |
|
677 #define RTL_R32(reg) ((unsigned long) inl (((unsigned long)ioaddr) + (reg))) |
|
678 #define RTL_W8(reg, val8) outb ((val8), ((unsigned long)ioaddr) + (reg)) |
|
679 #define RTL_W16(reg, val16) outw ((val16), ((unsigned long)ioaddr) + (reg)) |
|
680 #define RTL_W32(reg, val32) outl ((val32), ((unsigned long)ioaddr) + (reg)) |
|
681 #define RTL_W8_F RTL_W8 |
|
682 #define RTL_W16_F RTL_W16 |
|
683 #define RTL_W32_F RTL_W32 |
|
684 #undef readb |
|
685 #undef readw |
|
686 #undef readl |
|
687 #undef writeb |
|
688 #undef writew |
|
689 #undef writel |
|
690 #define readb(addr) inb((unsigned long)(addr)) |
|
691 #define readw(addr) inw((unsigned long)(addr)) |
|
692 #define readl(addr) inl((unsigned long)(addr)) |
|
693 #define writeb(val,addr) outb((val),(unsigned long)(addr)) |
|
694 #define writew(val,addr) outw((val),(unsigned long)(addr)) |
|
695 #define writel(val,addr) outl((val),(unsigned long)(addr)) |
|
696 |
|
697 #else |
|
698 |
|
699 /* write MMIO register, with flush */ |
|
700 /* Flush avoids rtl8139 bug w/ posted MMIO writes */ |
|
701 #define RTL_W8_F(reg, val8) do { writeb ((val8), ioaddr + (reg)); readb (ioaddr + (reg)); } while (0) |
|
702 #define RTL_W16_F(reg, val16) do { writew ((val16), ioaddr + (reg)); readw (ioaddr + (reg)); } while (0) |
|
703 #define RTL_W32_F(reg, val32) do { writel ((val32), ioaddr + (reg)); readl (ioaddr + (reg)); } while (0) |
|
704 |
|
705 |
|
706 #define MMIO_FLUSH_AUDIT_COMPLETE 1 |
|
707 #if MMIO_FLUSH_AUDIT_COMPLETE |
|
708 |
|
709 /* write MMIO register */ |
|
710 #define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg)) |
|
711 #define RTL_W16(reg, val16) writew ((val16), ioaddr + (reg)) |
|
712 #define RTL_W32(reg, val32) writel ((val32), ioaddr + (reg)) |
|
713 |
|
714 #else |
|
715 |
|
716 /* write MMIO register, then flush */ |
|
717 #define RTL_W8 RTL_W8_F |
|
718 #define RTL_W16 RTL_W16_F |
|
719 #define RTL_W32 RTL_W32_F |
|
720 |
|
721 #endif /* MMIO_FLUSH_AUDIT_COMPLETE */ |
|
722 |
|
723 /* read MMIO register */ |
|
724 #define RTL_R8(reg) readb (ioaddr + (reg)) |
|
725 #define RTL_R16(reg) readw (ioaddr + (reg)) |
|
726 #define RTL_R32(reg) ((unsigned long) readl (ioaddr + (reg))) |
|
727 |
|
728 #endif /* USE_IO_OPS */ |
|
729 |
|
730 static const u16 rtl8139_intr_mask = |
|
731 PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver | |
|
732 TxErr | TxOK | RxErr | RxOK; |
|
733 |
|
734 static const unsigned int rtl8139_rx_config = |
|
735 RxCfgRcv32K | RxNoWrap | |
|
736 (RX_FIFO_THRESH << RxCfgFIFOShift) | |
|
737 (RX_DMA_BURST << RxCfgDMAShift); |
|
738 |
|
739 static const unsigned int rtl8139_tx_config = |
|
740 (TX_DMA_BURST << TxDMAShift) | (TX_RETRY << TxRetryShift); |
|
741 |
|
742 static void __rtl8139_cleanup_dev (struct net_device *dev) |
|
743 { |
|
744 struct rtl8139_private *tp; |
|
745 struct pci_dev *pdev; |
|
746 |
|
747 assert (dev != NULL); |
|
748 assert (dev->priv != NULL); |
|
749 |
|
750 tp = dev->priv; |
|
751 assert (tp->pci_dev != NULL); |
|
752 pdev = tp->pci_dev; |
|
753 |
|
754 #ifndef USE_IO_OPS |
|
755 if (tp->mmio_addr) |
|
756 iounmap (tp->mmio_addr); |
|
757 #endif /* !USE_IO_OPS */ |
|
758 |
|
759 /* it's ok to call this even if we have no regions to free */ |
|
760 pci_release_regions (pdev); |
|
761 |
|
762 #ifndef RTL8139_NDEBUG |
|
763 /* poison memory before freeing */ |
|
764 memset (dev, 0xBC, |
|
765 sizeof (struct net_device) + |
|
766 sizeof (struct rtl8139_private)); |
|
767 #endif /* RTL8139_NDEBUG */ |
|
768 |
|
769 kfree (dev); |
|
770 |
|
771 pci_set_drvdata (pdev, NULL); |
|
772 } |
|
773 |
|
774 |
|
775 static void rtl8139_chip_reset (void *ioaddr) |
|
776 { |
|
777 int i; |
|
778 #ifdef ECAT_DEBUG |
|
779 int succ = 0; |
|
780 #endif |
|
781 /* Soft reset the chip. */ |
|
782 RTL_W8 (ChipCmd, CmdReset); |
|
783 |
|
784 /* Check that the chip has finished the reset. */ |
|
785 for (i = 1000; i > 0; i--) { |
|
786 barrier(); |
|
787 if ((RTL_R8 (ChipCmd) & CmdReset) == 0) { |
|
788 #ifdef ECAT_DEBUG |
|
789 succ = 1; |
|
790 #endif |
|
791 break; |
|
792 } |
|
793 udelay (10); |
|
794 } |
|
795 #ifdef ECAT_DEBUG |
|
796 EC_DBG("rtl8139 chipreset"); |
|
797 if(succ == 0) |
|
798 EC_DBG("failed"); |
|
799 else |
|
800 EC_DBG("success at count %d",i); |
|
801 #endif |
|
802 } |
|
803 |
|
804 |
|
805 static int __devinit rtl8139_init_board (struct pci_dev *pdev, |
|
806 struct net_device **dev_out) |
|
807 { |
|
808 void *ioaddr; |
|
809 struct net_device *dev; |
|
810 struct rtl8139_private *tp; |
|
811 u8 tmp8; |
|
812 int rc; |
|
813 unsigned int i; |
|
814 u32 pio_start, pio_end, pio_flags, pio_len; |
|
815 unsigned long mmio_start, mmio_end, mmio_flags, mmio_len; |
|
816 u32 tmp; |
|
817 |
|
818 assert (pdev != NULL); |
|
819 |
|
820 *dev_out = NULL; |
|
821 |
|
822 /* dev and dev->priv zeroed in alloc_etherdev */ |
|
823 dev = alloc_etherdev (sizeof (*tp)); |
|
824 if (dev == NULL) { |
|
825 EC_DBG (KERN_ERR PFX "%s: Unable to alloc new net device\n", pdev->slot_name); |
|
826 return -ENOMEM; |
|
827 } |
|
828 SET_MODULE_OWNER(dev); |
|
829 tp = dev->priv; |
|
830 tp->pci_dev = pdev; |
|
831 |
|
832 /* enable device (incl. PCI PM wakeup and hotplug setup) */ |
|
833 rc = pci_enable_device (pdev); |
|
834 if (rc) |
|
835 goto err_out; |
|
836 |
|
837 pio_start = pci_resource_start (pdev, 0); |
|
838 pio_end = pci_resource_end (pdev, 0); |
|
839 pio_flags = pci_resource_flags (pdev, 0); |
|
840 pio_len = pci_resource_len (pdev, 0); |
|
841 |
|
842 mmio_start = pci_resource_start (pdev, 1); |
|
843 mmio_end = pci_resource_end (pdev, 1); |
|
844 mmio_flags = pci_resource_flags (pdev, 1); |
|
845 mmio_len = pci_resource_len (pdev, 1); |
|
846 |
|
847 /* set this immediately, we need to know before |
|
848 * we talk to the chip directly */ |
|
849 DPRINTK("PIO region size == 0x%02X\n", pio_len); |
|
850 DPRINTK("MMIO region size == 0x%02lX\n", mmio_len); |
|
851 |
|
852 #ifdef USE_IO_OPS |
|
853 /* make sure PCI base addr 0 is PIO */ |
|
854 if (!(pio_flags & IORESOURCE_IO)) { |
|
855 EC_DBG (KERN_ERR PFX "%s: region #0 not a PIO resource, aborting\n", pdev->slot_name); |
|
856 rc = -ENODEV; |
|
857 goto err_out; |
|
858 } |
|
859 /* check for weird/broken PCI region reporting */ |
|
860 if (pio_len < RTL_MIN_IO_SIZE) { |
|
861 EC_DBG (KERN_ERR PFX "%s: Invalid PCI I/O region size(s), aborting\n", pdev->slot_name); |
|
862 rc = -ENODEV; |
|
863 goto err_out; |
|
864 } |
|
865 #else |
|
866 /* make sure PCI base addr 1 is MMIO */ |
|
867 if (!(mmio_flags & IORESOURCE_MEM)) { |
|
868 EC_DBG (KERN_ERR PFX "%s: region #1 not an MMIO resource, aborting\n", pdev->slot_name); |
|
869 rc = -ENODEV; |
|
870 goto err_out; |
|
871 } |
|
872 if (mmio_len < RTL_MIN_IO_SIZE) { |
|
873 EC_DBG (KERN_ERR PFX "%s: Invalid PCI mem region size(s), aborting\n", pdev->slot_name); |
|
874 rc = -ENODEV; |
|
875 goto err_out; |
|
876 } |
|
877 #endif |
|
878 |
|
879 rc = pci_request_regions (pdev, "8139too"); |
|
880 if (rc) |
|
881 goto err_out; |
|
882 |
|
883 /* enable PCI bus-mastering */ |
|
884 pci_set_master (pdev); |
|
885 |
|
886 #ifdef USE_IO_OPS |
|
887 ioaddr = (void *) pio_start; |
|
888 dev->base_addr = pio_start; |
|
889 tp->mmio_addr = ioaddr; |
|
890 tp->regs_len = pio_len; |
|
891 #else |
|
892 /* ioremap MMIO region */ |
|
893 ioaddr = ioremap (mmio_start, mmio_len); |
|
894 if (ioaddr == NULL) { |
|
895 EC_DBG (KERN_ERR PFX "%s: cannot remap MMIO, aborting\n", pdev->slot_name); |
|
896 rc = -EIO; |
|
897 goto err_out; |
|
898 } |
|
899 dev->base_addr = (long) ioaddr; |
|
900 tp->mmio_addr = ioaddr; |
|
901 tp->regs_len = mmio_len; |
|
902 #endif /* USE_IO_OPS */ |
|
903 |
|
904 /* Bring old chips out of low-power mode. */ |
|
905 RTL_W8 (HltClk, 'R'); |
|
906 |
|
907 /* check for missing/broken hardware */ |
|
908 if (RTL_R32 (TxConfig) == 0xFFFFFFFF) { |
|
909 EC_DBG (KERN_ERR PFX "%s: Chip not responding, ignoring board\n", |
|
910 pdev->slot_name); |
|
911 rc = -EIO; |
|
912 goto err_out; |
|
913 } |
|
914 |
|
915 /* identify chip attached to board */ |
|
916 tmp = RTL_R8 (ChipVersion); |
|
917 for (i = 0; i < ARRAY_SIZE (rtl_chip_info); i++) |
|
918 if (tmp == rtl_chip_info[i].version) { |
|
919 tp->chipset = i; |
|
920 goto match; |
|
921 } |
|
922 |
|
923 /* if unknown chip, assume array element #0, original RTL-8139 in this case */ |
|
924 EC_DBG (KERN_DEBUG PFX "%s: unknown chip version, assuming RTL-8139\n", |
|
925 pdev->slot_name); |
|
926 EC_DBG (KERN_DEBUG PFX "%s: TxConfig = 0x%lx\n", pdev->slot_name, RTL_R32 (TxConfig)); |
|
927 tp->chipset = 0; |
|
928 |
|
929 match: |
|
930 DPRINTK ("chipset id (%d) == index %d, '%s'\n", |
|
931 tmp, |
|
932 tp->chipset, |
|
933 rtl_chip_info[tp->chipset].name); |
|
934 |
|
935 if (tp->chipset >= CH_8139B) { |
|
936 u8 new_tmp8 = tmp8 = RTL_R8 (Config1); |
|
937 DPRINTK("PCI PM wakeup\n"); |
|
938 if ((rtl_chip_info[tp->chipset].flags & HasLWake) && |
|
939 (tmp8 & LWAKE)) |
|
940 new_tmp8 &= ~LWAKE; |
|
941 new_tmp8 |= Cfg1_PM_Enable; |
|
942 if (new_tmp8 != tmp8) { |
|
943 RTL_W8 (Cfg9346, Cfg9346_Unlock); |
|
944 RTL_W8 (Config1, tmp8); |
|
945 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
946 } |
|
947 if (rtl_chip_info[tp->chipset].flags & HasLWake) { |
|
948 tmp8 = RTL_R8 (Config4); |
|
949 if (tmp8 & LWPTN) |
|
950 RTL_W8 (Config4, tmp8 & ~LWPTN); |
|
951 } |
|
952 } else { |
|
953 DPRINTK("Old chip wakeup\n"); |
|
954 tmp8 = RTL_R8 (Config1); |
|
955 tmp8 &= ~(SLEEP | PWRDN); |
|
956 RTL_W8 (Config1, tmp8); |
|
957 } |
|
958 |
|
959 rtl8139_chip_reset (ioaddr); |
|
960 |
|
961 *dev_out = dev; |
|
962 return 0; |
|
963 |
|
964 err_out: |
|
965 __rtl8139_cleanup_dev (dev); |
|
966 return rc; |
|
967 } |
|
968 |
|
969 |
|
970 static int __devinit rtl8139_init_one (struct pci_dev *pdev, |
|
971 const struct pci_device_id *ent) |
|
972 { |
|
973 struct net_device *dev = NULL; |
|
974 struct rtl8139_private *tp; |
|
975 int i, addr_len, option; |
|
976 void *ioaddr; |
|
977 static int board_idx = -1; |
|
978 u8 pci_rev; |
|
979 |
|
980 assert (pdev != NULL); |
|
981 assert (ent != NULL); |
|
982 |
|
983 board_idx++; |
|
984 |
|
985 |
|
986 /* when we're built into the kernel, the driver version message |
|
987 * is only printed if at least one 8139 board has been found |
|
988 */ |
|
989 #ifndef MODULE |
|
990 { |
|
991 static int printed_version; |
|
992 if (!printed_version++) |
|
993 EC_DBG (KERN_INFO RTL8139_DRIVER_NAME "\n"); |
|
994 } |
|
995 #endif |
|
996 |
|
997 pci_read_config_byte(pdev, PCI_REVISION_ID, &pci_rev); |
|
998 |
|
999 if (pdev->vendor == PCI_VENDOR_ID_REALTEK && |
|
1000 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev >= 0x20) { |
|
1001 EC_DBG(KERN_INFO PFX "pci dev %s (id %04x:%04x rev %02x) is an enhanced 8139C+ chip\n", |
|
1002 pdev->slot_name, pdev->vendor, pdev->device, pci_rev); |
|
1003 EC_DBG(KERN_INFO PFX "Use the \"8139cp\" driver for improved performance and stability.\n"); |
|
1004 } |
|
1005 |
|
1006 i = rtl8139_init_board (pdev, &dev); |
|
1007 if (i < 0) |
|
1008 return i; |
|
1009 |
|
1010 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1011 |
|
1012 if (board_idx == ec_device_index) |
|
1013 { |
|
1014 EC_DBG("EtherCAT registering board %d.\n", board_idx); |
|
1015 |
|
1016 if (EtherCAT_device_assign(&rtl_ecat_dev, dev) < 0) |
|
1017 goto err_out; |
|
1018 |
|
1019 strcpy(dev->name,"ECAT"); //device name überschreiben |
|
1020 } |
|
1021 |
|
1022 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1023 |
|
1024 tp = dev->priv; |
|
1025 ioaddr = tp->mmio_addr; |
|
1026 |
|
1027 assert (ioaddr != NULL); |
|
1028 assert (dev != NULL); |
|
1029 assert (tp != NULL); |
|
1030 |
|
1031 addr_len = read_eeprom (ioaddr, 0, 8) == 0x8129 ? 8 : 6; |
|
1032 for (i = 0; i < 3; i++) |
|
1033 ((u16 *) (dev->dev_addr))[i] = |
|
1034 le16_to_cpu (read_eeprom (ioaddr, i + 7, addr_len)); |
|
1035 |
|
1036 /* The Rtl8139-specific entries in the device structure. */ |
|
1037 dev->open = rtl8139_open; |
|
1038 dev->hard_start_xmit = rtl8139_start_xmit; |
|
1039 dev->stop = rtl8139_close; |
|
1040 dev->get_stats = rtl8139_get_stats; |
|
1041 dev->set_multicast_list = rtl8139_set_rx_mode; |
|
1042 dev->do_ioctl = netdev_ioctl; |
|
1043 dev->tx_timeout = rtl8139_tx_timeout; |
|
1044 dev->watchdog_timeo = TX_TIMEOUT; |
|
1045 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM; |
|
1046 |
|
1047 dev->irq = pdev->irq; |
|
1048 |
|
1049 /* dev->priv/tp zeroed and aligned in init_etherdev */ |
|
1050 tp = dev->priv; |
|
1051 |
|
1052 /* note: tp->chipset set in rtl8139_init_board */ |
|
1053 tp->drv_flags = board_info[ent->driver_data].hw_flags; |
|
1054 tp->mmio_addr = ioaddr; |
|
1055 spin_lock_init (&tp->lock); |
|
1056 |
|
1057 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1058 |
|
1059 if (board_idx == ec_device_index) |
|
1060 { |
|
1061 rtl_ecat_dev.lock = &tp->lock; |
|
1062 } |
|
1063 |
|
1064 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1065 |
|
1066 init_waitqueue_head (&tp->thr_wait); |
|
1067 init_completion (&tp->thr_exited); |
|
1068 tp->mii.dev = dev; |
|
1069 tp->mii.mdio_read = mdio_read; |
|
1070 tp->mii.mdio_write = mdio_write; |
|
1071 tp->mii.phy_id_mask = 0x3f; |
|
1072 tp->mii.reg_num_mask = 0x1f; |
|
1073 |
|
1074 /* dev is fully set up and ready to use now */ |
|
1075 |
|
1076 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1077 |
|
1078 /* EtherCAT-Karten nicht beim Stack anmelden. */ |
|
1079 if (dev != rtl_ecat_dev.dev) |
|
1080 { |
|
1081 DPRINTK("About to register device named %s (%p)...\n", dev->name, dev); |
|
1082 i = register_netdev (dev); |
|
1083 if (i) goto err_out; |
|
1084 } |
|
1085 |
|
1086 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1087 |
|
1088 pci_set_drvdata (pdev, dev); |
|
1089 |
|
1090 EC_DBG (KERN_INFO "%s: %s at 0x%lx, " |
|
1091 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x, " |
|
1092 "IRQ %d\n", |
|
1093 dev->name, |
|
1094 board_info[ent->driver_data].name, |
|
1095 dev->base_addr, |
|
1096 dev->dev_addr[0], dev->dev_addr[1], |
|
1097 dev->dev_addr[2], dev->dev_addr[3], |
|
1098 dev->dev_addr[4], dev->dev_addr[5], |
|
1099 dev->irq); |
|
1100 |
|
1101 EC_DBG (KERN_DEBUG "%s: Identified 8139 chip type '%s'\n", |
|
1102 dev->name, rtl_chip_info[tp->chipset].name); |
|
1103 |
|
1104 /* Find the connected MII xcvrs. |
|
1105 Doing this in open() would allow detecting external xcvrs later, but |
|
1106 takes too much time. */ |
|
1107 #ifdef CONFIG_8139TOO_8129 |
|
1108 if (tp->drv_flags & HAS_MII_XCVR) { |
|
1109 int phy, phy_idx = 0; |
|
1110 for (phy = 0; phy < 32 && phy_idx < sizeof(tp->phys); phy++) { |
|
1111 int mii_status = mdio_read(dev, phy, 1); |
|
1112 if (mii_status != 0xffff && mii_status != 0x0000) { |
|
1113 u16 advertising = mdio_read(dev, phy, 4); |
|
1114 tp->phys[phy_idx++] = phy; |
|
1115 EC_DBG(KERN_INFO "%s: MII transceiver %d status 0x%4.4x " |
|
1116 "advertising %4.4x.\n", |
|
1117 dev->name, phy, mii_status, advertising); |
|
1118 } |
|
1119 } |
|
1120 if (phy_idx == 0) { |
|
1121 EC_DBG(KERN_INFO "%s: No MII transceivers found! Assuming SYM " |
|
1122 "transceiver.\n", |
|
1123 dev->name); |
|
1124 tp->phys[0] = 32; |
|
1125 } |
|
1126 } else |
|
1127 #endif |
|
1128 tp->phys[0] = 32; |
|
1129 tp->mii.phy_id = tp->phys[0]; |
|
1130 |
|
1131 /* The lower four bits are the media type. */ |
|
1132 option = (board_idx >= MAX_UNITS) ? 0 : media[board_idx]; |
|
1133 if (option > 0) { |
|
1134 tp->mii.full_duplex = (option & 0x210) ? 1 : 0; |
|
1135 tp->default_port = option & 0xFF; |
|
1136 if (tp->default_port) |
|
1137 tp->mii.force_media = 1; |
|
1138 } |
|
1139 if (board_idx < MAX_UNITS && full_duplex[board_idx] > 0) |
|
1140 tp->mii.full_duplex = full_duplex[board_idx]; |
|
1141 if (tp->mii.full_duplex) { |
|
1142 EC_DBG(KERN_INFO "%s: Media type forced to Full Duplex.\n", dev->name); |
|
1143 /* Changing the MII-advertised media because might prevent |
|
1144 re-connection. */ |
|
1145 tp->mii.force_media = 1; |
|
1146 } |
|
1147 if (tp->default_port) { |
|
1148 EC_DBG(KERN_INFO " Forcing %dMbps %s-duplex operation.\n", |
|
1149 (option & 0x20 ? 100 : 10), |
|
1150 (option & 0x10 ? "full" : "half")); |
|
1151 mdio_write(dev, tp->phys[0], 0, |
|
1152 ((option & 0x20) ? 0x2000 : 0) | /* 100Mbps? */ |
|
1153 ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */ |
|
1154 } |
|
1155 |
|
1156 /* Put the chip into low-power mode. */ |
|
1157 if (rtl_chip_info[tp->chipset].flags & HasHltClk) |
|
1158 RTL_W8 (HltClk, 'H'); /* 'R' would leave the clock running. */ |
|
1159 |
|
1160 return 0; |
|
1161 |
|
1162 err_out: |
|
1163 __rtl8139_cleanup_dev (dev); |
|
1164 return i; |
|
1165 } |
|
1166 |
|
1167 |
|
1168 static void __devexit rtl8139_remove_one (struct pci_dev *pdev) |
|
1169 { |
|
1170 struct net_device *dev = pci_get_drvdata (pdev); |
|
1171 struct rtl8139_private *np; |
|
1172 |
|
1173 assert (dev != NULL); |
|
1174 np = dev->priv; |
|
1175 assert (np != NULL); |
|
1176 |
|
1177 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1178 |
|
1179 if (dev != rtl_ecat_dev.dev) |
|
1180 { |
|
1181 unregister_netdev (dev); |
|
1182 } |
|
1183 |
|
1184 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1185 |
|
1186 __rtl8139_cleanup_dev (dev); |
|
1187 } |
|
1188 |
|
1189 |
|
1190 /* Serial EEPROM section. */ |
|
1191 |
|
1192 /* EEPROM_Ctrl bits. */ |
|
1193 #define EE_SHIFT_CLK 0x04 /* EEPROM shift clock. */ |
|
1194 #define EE_CS 0x08 /* EEPROM chip select. */ |
|
1195 #define EE_DATA_WRITE 0x02 /* EEPROM chip data in. */ |
|
1196 #define EE_WRITE_0 0x00 |
|
1197 #define EE_WRITE_1 0x02 |
|
1198 #define EE_DATA_READ 0x01 /* EEPROM chip data out. */ |
|
1199 #define EE_ENB (0x80 | EE_CS) |
|
1200 |
|
1201 /* Delay between EEPROM clock transitions. |
|
1202 No extra delay is needed with 33Mhz PCI, but 66Mhz may change this. |
|
1203 */ |
|
1204 |
|
1205 #define eeprom_delay() readl(ee_addr) |
|
1206 |
|
1207 /* The EEPROM commands include the alway-set leading bit. */ |
|
1208 #define EE_WRITE_CMD (5) |
|
1209 #define EE_READ_CMD (6) |
|
1210 #define EE_ERASE_CMD (7) |
|
1211 |
|
1212 static int __devinit read_eeprom (void *ioaddr, int location, int addr_len) |
|
1213 { |
|
1214 int i; |
|
1215 unsigned retval = 0; |
|
1216 void *ee_addr = ioaddr + Cfg9346; |
|
1217 int read_cmd = location | (EE_READ_CMD << addr_len); |
|
1218 |
|
1219 writeb (EE_ENB & ~EE_CS, ee_addr); |
|
1220 writeb (EE_ENB, ee_addr); |
|
1221 eeprom_delay (); |
|
1222 |
|
1223 /* Shift the read command bits out. */ |
|
1224 for (i = 4 + addr_len; i >= 0; i--) { |
|
1225 int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; |
|
1226 writeb (EE_ENB | dataval, ee_addr); |
|
1227 eeprom_delay (); |
|
1228 writeb (EE_ENB | dataval | EE_SHIFT_CLK, ee_addr); |
|
1229 eeprom_delay (); |
|
1230 } |
|
1231 writeb (EE_ENB, ee_addr); |
|
1232 eeprom_delay (); |
|
1233 |
|
1234 for (i = 16; i > 0; i--) { |
|
1235 writeb (EE_ENB | EE_SHIFT_CLK, ee_addr); |
|
1236 eeprom_delay (); |
|
1237 retval = |
|
1238 (retval << 1) | ((readb (ee_addr) & EE_DATA_READ) ? 1 : |
|
1239 0); |
|
1240 writeb (EE_ENB, ee_addr); |
|
1241 eeprom_delay (); |
|
1242 } |
|
1243 |
|
1244 /* Terminate the EEPROM access. */ |
|
1245 writeb (~EE_CS, ee_addr); |
|
1246 eeprom_delay (); |
|
1247 |
|
1248 return retval; |
|
1249 } |
|
1250 |
|
1251 /* MII serial management: mostly bogus for now. */ |
|
1252 /* Read and write the MII management registers using software-generated |
|
1253 serial MDIO protocol. |
|
1254 The maximum data clock rate is 2.5 Mhz. The minimum timing is usually |
|
1255 met by back-to-back PCI I/O cycles, but we insert a delay to avoid |
|
1256 "overclocking" issues. */ |
|
1257 #define MDIO_DIR 0x80 |
|
1258 #define MDIO_DATA_OUT 0x04 |
|
1259 #define MDIO_DATA_IN 0x02 |
|
1260 #define MDIO_CLK 0x01 |
|
1261 #define MDIO_WRITE0 (MDIO_DIR) |
|
1262 #define MDIO_WRITE1 (MDIO_DIR | MDIO_DATA_OUT) |
|
1263 |
|
1264 #define mdio_delay(mdio_addr) readb(mdio_addr) |
|
1265 |
|
1266 |
|
1267 static char mii_2_8139_map[8] = { |
|
1268 BasicModeCtrl, |
|
1269 BasicModeStatus, |
|
1270 0, |
|
1271 0, |
|
1272 NWayAdvert, |
|
1273 NWayLPAR, |
|
1274 NWayExpansion, |
|
1275 0 |
|
1276 }; |
|
1277 |
|
1278 |
|
1279 #ifdef CONFIG_8139TOO_8129 |
|
1280 /* Syncronize the MII management interface by shifting 32 one bits out. */ |
|
1281 static void mdio_sync (void *mdio_addr) |
|
1282 { |
|
1283 int i; |
|
1284 |
|
1285 for (i = 32; i >= 0; i--) { |
|
1286 writeb (MDIO_WRITE1, mdio_addr); |
|
1287 mdio_delay (mdio_addr); |
|
1288 writeb (MDIO_WRITE1 | MDIO_CLK, mdio_addr); |
|
1289 mdio_delay (mdio_addr); |
|
1290 } |
|
1291 } |
|
1292 #endif |
|
1293 |
|
1294 static int mdio_read (struct net_device *dev, int phy_id, int location) |
|
1295 { |
|
1296 struct rtl8139_private *tp = dev->priv; |
|
1297 int retval = 0; |
|
1298 #ifdef CONFIG_8139TOO_8129 |
|
1299 void *mdio_addr = tp->mmio_addr + Config4; |
|
1300 int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location; |
|
1301 int i; |
|
1302 #endif |
|
1303 |
|
1304 if (phy_id > 31) { /* Really a 8139. Use internal registers. */ |
|
1305 return location < 8 && mii_2_8139_map[location] ? |
|
1306 readw (tp->mmio_addr + mii_2_8139_map[location]) : 0; |
|
1307 } |
|
1308 |
|
1309 #ifdef CONFIG_8139TOO_8129 |
|
1310 mdio_sync (mdio_addr); |
|
1311 /* Shift the read command bits out. */ |
|
1312 for (i = 15; i >= 0; i--) { |
|
1313 int dataval = (mii_cmd & (1 << i)) ? MDIO_DATA_OUT : 0; |
|
1314 |
|
1315 writeb (MDIO_DIR | dataval, mdio_addr); |
|
1316 mdio_delay (mdio_addr); |
|
1317 writeb (MDIO_DIR | dataval | MDIO_CLK, mdio_addr); |
|
1318 mdio_delay (mdio_addr); |
|
1319 } |
|
1320 |
|
1321 /* Read the two transition, 16 data, and wire-idle bits. */ |
|
1322 for (i = 19; i > 0; i--) { |
|
1323 writeb (0, mdio_addr); |
|
1324 mdio_delay (mdio_addr); |
|
1325 retval = (retval << 1) | ((readb (mdio_addr) & MDIO_DATA_IN) ? 1 : 0); |
|
1326 writeb (MDIO_CLK, mdio_addr); |
|
1327 mdio_delay (mdio_addr); |
|
1328 } |
|
1329 #endif |
|
1330 |
|
1331 return (retval >> 1) & 0xffff; |
|
1332 } |
|
1333 |
|
1334 |
|
1335 static void mdio_write (struct net_device *dev, int phy_id, int location, |
|
1336 int value) |
|
1337 { |
|
1338 struct rtl8139_private *tp = dev->priv; |
|
1339 #ifdef CONFIG_8139TOO_8129 |
|
1340 void *mdio_addr = tp->mmio_addr + Config4; |
|
1341 int mii_cmd = (0x5002 << 16) | (phy_id << 23) | (location << 18) | value; |
|
1342 int i; |
|
1343 #endif |
|
1344 |
|
1345 if (phy_id > 31) { /* Really a 8139. Use internal registers. */ |
|
1346 void *ioaddr = tp->mmio_addr; |
|
1347 if (location == 0) { |
|
1348 RTL_W8 (Cfg9346, Cfg9346_Unlock); |
|
1349 RTL_W16 (BasicModeCtrl, value); |
|
1350 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
1351 } else if (location < 8 && mii_2_8139_map[location]) |
|
1352 RTL_W16 (mii_2_8139_map[location], value); |
|
1353 return; |
|
1354 } |
|
1355 |
|
1356 #ifdef CONFIG_8139TOO_8129 |
|
1357 mdio_sync (mdio_addr); |
|
1358 |
|
1359 /* Shift the command bits out. */ |
|
1360 for (i = 31; i >= 0; i--) { |
|
1361 int dataval = |
|
1362 (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0; |
|
1363 writeb (dataval, mdio_addr); |
|
1364 mdio_delay (mdio_addr); |
|
1365 writeb (dataval | MDIO_CLK, mdio_addr); |
|
1366 mdio_delay (mdio_addr); |
|
1367 } |
|
1368 /* Clear out extra bits. */ |
|
1369 for (i = 2; i > 0; i--) { |
|
1370 writeb (0, mdio_addr); |
|
1371 mdio_delay (mdio_addr); |
|
1372 writeb (MDIO_CLK, mdio_addr); |
|
1373 mdio_delay (mdio_addr); |
|
1374 } |
|
1375 #endif |
|
1376 } |
|
1377 |
|
1378 |
|
1379 static int rtl8139_open (struct net_device *dev) |
|
1380 { |
|
1381 struct rtl8139_private *tp = dev->priv; |
|
1382 int retval; |
|
1383 #ifdef RTL8139_DEBUG |
|
1384 void *ioaddr = tp->mmio_addr; |
|
1385 #endif |
|
1386 |
|
1387 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1388 |
|
1389 #ifdef ECAT_DEBUG |
|
1390 EC_DBG(KERN_DEBUG "%s: open\n", dev->name); |
|
1391 #endif |
|
1392 |
|
1393 if (dev != rtl_ecat_dev.dev) |
|
1394 { |
|
1395 retval = request_irq(dev->irq, rtl8139_interrupt, SA_SHIRQ, dev->name, dev); |
|
1396 if (retval) |
|
1397 return retval; |
|
1398 } |
|
1399 |
|
1400 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1401 |
|
1402 tp->tx_bufs = pci_alloc_consistent(tp->pci_dev, TX_BUF_TOT_LEN, |
|
1403 &tp->tx_bufs_dma); |
|
1404 tp->rx_ring = pci_alloc_consistent(tp->pci_dev, RX_BUF_TOT_LEN, |
|
1405 &tp->rx_ring_dma); |
|
1406 if (tp->tx_bufs == NULL || tp->rx_ring == NULL) |
|
1407 { |
|
1408 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1409 |
|
1410 if (dev != rtl_ecat_dev.dev) |
|
1411 { |
|
1412 free_irq(dev->irq, dev); |
|
1413 } |
|
1414 |
|
1415 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1416 |
|
1417 if (tp->tx_bufs) |
|
1418 pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN, |
|
1419 tp->tx_bufs, tp->tx_bufs_dma); |
|
1420 if (tp->rx_ring) |
|
1421 pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN, |
|
1422 tp->rx_ring, tp->rx_ring_dma); |
|
1423 |
|
1424 return -ENOMEM; |
|
1425 |
|
1426 } |
|
1427 |
|
1428 tp->mii.full_duplex = tp->mii.force_media; |
|
1429 tp->tx_flag = (TX_FIFO_THRESH << 11) & 0x003f0000; |
|
1430 tp->twistie = (tp->chipset == CH_8139_K) ? 1 : 0; |
|
1431 tp->time_to_die = 0; |
|
1432 |
|
1433 rtl8139_init_ring (dev); |
|
1434 rtl8139_hw_start (dev); |
|
1435 |
|
1436 DPRINTK ("%s: rtl8139_open() ioaddr %#lx IRQ %d" |
|
1437 " GP Pins %2.2x %s-duplex.\n", |
|
1438 dev->name, pci_resource_start (tp->pci_dev, 1), |
|
1439 dev->irq, RTL_R8 (MediaStatus), |
|
1440 tp->mii.full_duplex ? "full" : "half"); |
|
1441 |
|
1442 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1443 |
|
1444 if (dev != rtl_ecat_dev.dev) |
|
1445 { |
|
1446 EC_DBG(KERN_DEBUG "%s: starting kernel thread...\n", dev->name); |
|
1447 tp->thr_pid = kernel_thread (rtl8139_thread, dev, CLONE_FS | CLONE_FILES); |
|
1448 |
|
1449 if (tp->thr_pid < 0) |
|
1450 EC_DBG (KERN_WARNING "%s: unable to start kernel thread\n", |
|
1451 dev->name); |
|
1452 } |
|
1453 |
|
1454 #ifdef ECAT_DEBUG |
|
1455 EC_DBG(KERN_DEBUG "%s: open finished.\n", dev->name); |
|
1456 #endif |
|
1457 |
|
1458 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1459 |
|
1460 return 0; |
|
1461 } |
|
1462 |
|
1463 |
|
1464 static void rtl_check_media (struct net_device *dev) |
|
1465 { |
|
1466 struct rtl8139_private *tp = dev->priv; |
|
1467 |
|
1468 if (tp->phys[0] >= 0) { |
|
1469 u16 mii_lpa = mdio_read(dev, tp->phys[0], MII_LPA); |
|
1470 |
|
1471 if (mii_lpa == 0xffff) |
|
1472 ; /* Not there */ |
|
1473 else if ((mii_lpa & LPA_100FULL) == LPA_100FULL |
|
1474 || (mii_lpa & 0x00C0) == LPA_10FULL) |
|
1475 tp->mii.full_duplex = 1; |
|
1476 |
|
1477 EC_DBG (KERN_INFO "%s: Setting %s%s-duplex based on" |
|
1478 " auto-negotiated partner ability %4.4x.\n", |
|
1479 dev->name, mii_lpa == 0 ? "" : |
|
1480 (mii_lpa & 0x0180) ? "100mbps " : "10mbps ", |
|
1481 tp->mii.full_duplex ? "full" : "half", mii_lpa); |
|
1482 } |
|
1483 |
|
1484 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1485 |
|
1486 #ifdef ECAT_DEBUG |
|
1487 EC_DBG(KERN_DEBUG "rtl_check_media done.\n"); |
|
1488 #endif |
|
1489 |
|
1490 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1491 } |
|
1492 |
|
1493 /* Start the hardware at open or resume. */ |
|
1494 static void rtl8139_hw_start (struct net_device *dev) |
|
1495 { |
|
1496 struct rtl8139_private *tp = dev->priv; |
|
1497 void *ioaddr = tp->mmio_addr; |
|
1498 u32 i; |
|
1499 u8 tmp; |
|
1500 |
|
1501 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1502 |
|
1503 #ifdef ECAT_DEBUG |
|
1504 EC_DBG(KERN_DEBUG "%s: rtl8139_hw_start\n", dev->name); |
|
1505 #endif |
|
1506 |
|
1507 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1508 |
|
1509 /* Bring old chips out of low-power mode. */ |
|
1510 if (rtl_chip_info[tp->chipset].flags & HasHltClk) |
|
1511 RTL_W8 (HltClk, 'R'); |
|
1512 |
|
1513 rtl8139_chip_reset (ioaddr); |
|
1514 |
|
1515 /* unlock Config[01234] and BMCR register writes */ |
|
1516 RTL_W8_F (Cfg9346, Cfg9346_Unlock); |
|
1517 /* Restore our idea of the MAC address. */ |
|
1518 RTL_W32_F (MAC0 + 0, cpu_to_le32 (*(u32 *) (dev->dev_addr + 0))); |
|
1519 RTL_W32_F (MAC0 + 4, cpu_to_le32 (*(u32 *) (dev->dev_addr + 4))); |
|
1520 |
|
1521 /* Must enable Tx/Rx before setting transfer thresholds! */ |
|
1522 RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb); |
|
1523 |
|
1524 tp->rx_config = rtl8139_rx_config | AcceptBroadcast | AcceptMyPhys; |
|
1525 RTL_W32 (RxConfig, tp->rx_config); |
|
1526 |
|
1527 /* Check this value: the documentation for IFG contradicts ifself. */ |
|
1528 RTL_W32 (TxConfig, rtl8139_tx_config); |
|
1529 |
|
1530 tp->cur_rx = 0; |
|
1531 |
|
1532 rtl_check_media (dev); |
|
1533 |
|
1534 if (tp->chipset >= CH_8139B) { |
|
1535 /* Disable magic packet scanning, which is enabled |
|
1536 * when PM is enabled in Config1. It can be reenabled |
|
1537 * via ETHTOOL_SWOL if desired. */ |
|
1538 RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic); |
|
1539 } |
|
1540 |
|
1541 DPRINTK("init buffer addresses\n"); |
|
1542 |
|
1543 /* Lock Config[01234] and BMCR register writes */ |
|
1544 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
1545 |
|
1546 /* init Rx ring buffer DMA address */ |
|
1547 RTL_W32_F (RxBuf, tp->rx_ring_dma); |
|
1548 |
|
1549 /* init Tx buffer DMA addresses */ |
|
1550 for (i = 0; i < NUM_TX_DESC; i++) |
|
1551 RTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] - tp->tx_bufs)); |
|
1552 |
|
1553 RTL_W32 (RxMissed, 0); |
|
1554 |
|
1555 rtl8139_set_rx_mode (dev); |
|
1556 |
|
1557 /* no early-rx interrupts */ |
|
1558 RTL_W16 (MultiIntr, RTL_R16 (MultiIntr) & MultiIntrClear); |
|
1559 |
|
1560 /* make sure RxTx has started */ |
|
1561 tmp = RTL_R8 (ChipCmd); |
|
1562 if ((!(tmp & CmdRxEnb)) || (!(tmp & CmdTxEnb))) |
|
1563 RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb); |
|
1564 |
|
1565 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1566 |
|
1567 if (dev != rtl_ecat_dev.dev) |
|
1568 { |
|
1569 /* Enable all known interrupts by setting the interrupt mask. */ |
|
1570 RTL_W16 (IntrMask, rtl8139_intr_mask); |
|
1571 netif_start_queue (dev); |
|
1572 } |
|
1573 else |
|
1574 { |
|
1575 RTL_W16 (IntrMask, 0x0000); |
|
1576 } |
|
1577 |
|
1578 #ifdef ECAT_DEBUG |
|
1579 EC_DBG(KERN_DEBUG "%s: rtl8139_hw_start finished.\n", dev->name); |
|
1580 #endif |
|
1581 |
|
1582 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1583 } |
|
1584 |
|
1585 |
|
1586 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */ |
|
1587 static void rtl8139_init_ring (struct net_device *dev) |
|
1588 { |
|
1589 struct rtl8139_private *tp = dev->priv; |
|
1590 int i; |
|
1591 |
|
1592 tp->cur_rx = 0; |
|
1593 tp->cur_tx = 0; |
|
1594 tp->dirty_tx = 0; |
|
1595 |
|
1596 for (i = 0; i < NUM_TX_DESC; i++) |
|
1597 tp->tx_buf[i] = &tp->tx_bufs[i * TX_BUF_SIZE]; |
|
1598 } |
|
1599 |
|
1600 |
|
1601 /* This must be global for CONFIG_8139TOO_TUNE_TWISTER case */ |
|
1602 static int next_tick = 3 * HZ; |
|
1603 |
|
1604 #ifndef CONFIG_8139TOO_TUNE_TWISTER |
|
1605 static inline void rtl8139_tune_twister (struct net_device *dev, |
|
1606 struct rtl8139_private *tp) {} |
|
1607 #else |
|
1608 static void rtl8139_tune_twister (struct net_device *dev, |
|
1609 struct rtl8139_private *tp) |
|
1610 { |
|
1611 int linkcase; |
|
1612 void *ioaddr = tp->mmio_addr; |
|
1613 |
|
1614 /* This is a complicated state machine to configure the "twister" for |
|
1615 impedance/echos based on the cable length. |
|
1616 All of this is magic and undocumented. |
|
1617 */ |
|
1618 switch (tp->twistie) { |
|
1619 case 1: |
|
1620 if (RTL_R16 (CSCR) & CSCR_LinkOKBit) { |
|
1621 /* We have link beat, let us tune the twister. */ |
|
1622 RTL_W16 (CSCR, CSCR_LinkDownOffCmd); |
|
1623 tp->twistie = 2; /* Change to state 2. */ |
|
1624 next_tick = HZ / 10; |
|
1625 } else { |
|
1626 /* Just put in some reasonable defaults for when beat returns. */ |
|
1627 RTL_W16 (CSCR, CSCR_LinkDownCmd); |
|
1628 RTL_W32 (FIFOTMS, 0x20); /* Turn on cable test mode. */ |
|
1629 RTL_W32 (PARA78, PARA78_default); |
|
1630 RTL_W32 (PARA7c, PARA7c_default); |
|
1631 tp->twistie = 0; /* Bail from future actions. */ |
|
1632 } |
|
1633 break; |
|
1634 case 2: |
|
1635 /* Read how long it took to hear the echo. */ |
|
1636 linkcase = RTL_R16 (CSCR) & CSCR_LinkStatusBits; |
|
1637 if (linkcase == 0x7000) |
|
1638 tp->twist_row = 3; |
|
1639 else if (linkcase == 0x3000) |
|
1640 tp->twist_row = 2; |
|
1641 else if (linkcase == 0x1000) |
|
1642 tp->twist_row = 1; |
|
1643 else |
|
1644 tp->twist_row = 0; |
|
1645 tp->twist_col = 0; |
|
1646 tp->twistie = 3; /* Change to state 2. */ |
|
1647 next_tick = HZ / 10; |
|
1648 break; |
|
1649 case 3: |
|
1650 /* Put out four tuning parameters, one per 100msec. */ |
|
1651 if (tp->twist_col == 0) |
|
1652 RTL_W16 (FIFOTMS, 0); |
|
1653 RTL_W32 (PARA7c, param[(int) tp->twist_row] |
|
1654 [(int) tp->twist_col]); |
|
1655 next_tick = HZ / 10; |
|
1656 if (++tp->twist_col >= 4) { |
|
1657 /* For short cables we are done. |
|
1658 For long cables (row == 3) check for mistune. */ |
|
1659 tp->twistie = |
|
1660 (tp->twist_row == 3) ? 4 : 0; |
|
1661 } |
|
1662 break; |
|
1663 case 4: |
|
1664 /* Special case for long cables: check for mistune. */ |
|
1665 if ((RTL_R16 (CSCR) & |
|
1666 CSCR_LinkStatusBits) == 0x7000) { |
|
1667 tp->twistie = 0; |
|
1668 break; |
|
1669 } else { |
|
1670 RTL_W32 (PARA7c, 0xfb38de03); |
|
1671 tp->twistie = 5; |
|
1672 next_tick = HZ / 10; |
|
1673 } |
|
1674 break; |
|
1675 case 5: |
|
1676 /* Retune for shorter cable (column 2). */ |
|
1677 RTL_W32 (FIFOTMS, 0x20); |
|
1678 RTL_W32 (PARA78, PARA78_default); |
|
1679 RTL_W32 (PARA7c, PARA7c_default); |
|
1680 RTL_W32 (FIFOTMS, 0x00); |
|
1681 tp->twist_row = 2; |
|
1682 tp->twist_col = 0; |
|
1683 tp->twistie = 3; |
|
1684 next_tick = HZ / 10; |
|
1685 break; |
|
1686 |
|
1687 default: |
|
1688 /* do nothing */ |
|
1689 break; |
|
1690 } |
|
1691 } |
|
1692 #endif /* CONFIG_8139TOO_TUNE_TWISTER */ |
|
1693 |
|
1694 |
|
1695 static inline void rtl8139_thread_iter (struct net_device *dev, |
|
1696 struct rtl8139_private *tp, |
|
1697 void *ioaddr) |
|
1698 { |
|
1699 int mii_lpa; |
|
1700 |
|
1701 mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA); |
|
1702 |
|
1703 if (!tp->mii.force_media && mii_lpa != 0xffff) { |
|
1704 int duplex = (mii_lpa & LPA_100FULL) |
|
1705 || (mii_lpa & 0x01C0) == 0x0040; |
|
1706 if (tp->mii.full_duplex != duplex) { |
|
1707 tp->mii.full_duplex = duplex; |
|
1708 |
|
1709 if (mii_lpa) { |
|
1710 EC_DBG (KERN_INFO |
|
1711 "%s: Setting %s-duplex based on MII #%d link" |
|
1712 " partner ability of %4.4x.\n", |
|
1713 dev->name, |
|
1714 tp->mii.full_duplex ? "full" : "half", |
|
1715 tp->phys[0], mii_lpa); |
|
1716 } else { |
|
1717 EC_DBG(KERN_INFO"%s: media is unconnected, link down, or incompatible connection\n", |
|
1718 dev->name); |
|
1719 } |
|
1720 #if 0 |
|
1721 RTL_W8 (Cfg9346, Cfg9346_Unlock); |
|
1722 RTL_W8 (Config1, tp->mii.full_duplex ? 0x60 : 0x20); |
|
1723 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
1724 #endif |
|
1725 } |
|
1726 } |
|
1727 |
|
1728 next_tick = HZ * 60; |
|
1729 |
|
1730 rtl8139_tune_twister (dev, tp); |
|
1731 |
|
1732 DPRINTK ("%s: Media selection tick, Link partner %4.4x.\n", |
|
1733 dev->name, RTL_R16 (NWayLPAR)); |
|
1734 DPRINTK ("%s: Other registers are IntMask %4.4x IntStatus %4.4x\n", |
|
1735 dev->name, RTL_R16 (IntrMask), RTL_R16 (IntrStatus)); |
|
1736 DPRINTK ("%s: Chip config %2.2x %2.2x.\n", |
|
1737 dev->name, RTL_R8 (Config0), |
|
1738 RTL_R8 (Config1)); |
|
1739 } |
|
1740 |
|
1741 |
|
1742 static int rtl8139_thread (void *data) |
|
1743 { |
|
1744 struct net_device *dev = data; |
|
1745 struct rtl8139_private *tp = dev->priv; |
|
1746 unsigned long timeout; |
|
1747 |
|
1748 daemonize (); |
|
1749 reparent_to_init(); |
|
1750 spin_lock_irq(¤t->sigmask_lock); |
|
1751 sigemptyset(¤t->blocked); |
|
1752 recalc_sigpending(current); |
|
1753 spin_unlock_irq(¤t->sigmask_lock); |
|
1754 |
|
1755 strncpy (current->comm, dev->name, sizeof(current->comm) - 1); |
|
1756 current->comm[sizeof(current->comm) - 1] = '\0'; |
|
1757 |
|
1758 while (1) { |
|
1759 timeout = next_tick; |
|
1760 do { |
|
1761 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout); |
|
1762 } while (!signal_pending (current) && (timeout > 0)); |
|
1763 |
|
1764 if (signal_pending (current)) { |
|
1765 spin_lock_irq(¤t->sigmask_lock); |
|
1766 flush_signals(current); |
|
1767 spin_unlock_irq(¤t->sigmask_lock); |
|
1768 } |
|
1769 |
|
1770 if (tp->time_to_die) |
|
1771 break; |
|
1772 |
|
1773 rtnl_lock (); |
|
1774 rtl8139_thread_iter (dev, tp, tp->mmio_addr); |
|
1775 rtnl_unlock (); |
|
1776 } |
|
1777 |
|
1778 complete_and_exit (&tp->thr_exited, 0); |
|
1779 } |
|
1780 |
|
1781 |
|
1782 static void rtl8139_tx_clear (struct rtl8139_private *tp) |
|
1783 { |
|
1784 tp->cur_tx = 0; |
|
1785 tp->dirty_tx = 0; |
|
1786 |
|
1787 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */ |
|
1788 } |
|
1789 |
|
1790 |
|
1791 static void rtl8139_tx_timeout (struct net_device *dev) |
|
1792 { |
|
1793 struct rtl8139_private *tp = dev->priv; |
|
1794 void *ioaddr = tp->mmio_addr; |
|
1795 int i; |
|
1796 u8 tmp8; |
|
1797 unsigned long flags; |
|
1798 |
|
1799 DPRINTK ("%s: Transmit timeout, status %2.2x %4.4x " |
|
1800 "media %2.2x.\n", dev->name, |
|
1801 RTL_R8 (ChipCmd), |
|
1802 RTL_R16 (IntrStatus), |
|
1803 RTL_R8 (MediaStatus)); |
|
1804 |
|
1805 tp->xstats.tx_timeouts++; |
|
1806 |
|
1807 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1808 |
|
1809 EC_DBG(KERN_DEBUG "%s: tx_timeout\n", dev->name); |
|
1810 |
|
1811 if (dev == rtl_ecat_dev.dev) |
|
1812 { |
|
1813 if (rtl_ecat_dev.state != ECAT_DS_SENT) |
|
1814 { |
|
1815 EC_DBG(KERN_WARNING "EtherCAT: Wrong status at timeout: %i\n", |
|
1816 rtl_ecat_dev.state); |
|
1817 } |
|
1818 |
|
1819 rtl_ecat_dev.state = ECAT_DS_TIMEOUT; |
|
1820 } |
|
1821 |
|
1822 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1823 |
|
1824 /* disable Tx ASAP, if not already */ |
|
1825 tmp8 = RTL_R8 (ChipCmd); |
|
1826 if (tmp8 & CmdTxEnb) |
|
1827 RTL_W8 (ChipCmd, CmdRxEnb); |
|
1828 |
|
1829 /* Disable interrupts by clearing the interrupt mask. */ |
|
1830 RTL_W16 (IntrMask, 0x0000); |
|
1831 |
|
1832 /* Emit info to figure out what went wrong. */ |
|
1833 EC_DBG (KERN_DEBUG "%s: Tx queue start entry %ld dirty entry %ld.\n", |
|
1834 dev->name, tp->cur_tx, tp->dirty_tx); |
|
1835 for (i = 0; i < NUM_TX_DESC; i++) |
|
1836 EC_DBG (KERN_DEBUG "%s: Tx descriptor %d is %8.8lx.%s\n", |
|
1837 dev->name, i, RTL_R32 (TxStatus0 + (i * 4)), |
|
1838 i == (int) (tp->dirty_tx % NUM_TX_DESC) ? |
|
1839 " (queue head)" : ""); |
|
1840 |
|
1841 /* Stop a shared interrupt from scavenging while we are. */ |
|
1842 |
|
1843 spin_lock_irqsave (&tp->lock, flags); |
|
1844 rtl8139_tx_clear (tp); |
|
1845 spin_unlock_irqrestore (&tp->lock, flags); |
|
1846 |
|
1847 /* ...and finally, reset everything */ |
|
1848 rtl8139_hw_start (dev); |
|
1849 |
|
1850 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1851 |
|
1852 if (dev != rtl_ecat_dev.dev) netif_wake_queue (dev); |
|
1853 |
|
1854 EC_DBG(KERN_DEBUG "%s: tx_timeout finished.\n", dev->name); |
|
1855 |
|
1856 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1857 } |
|
1858 |
|
1859 static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) |
|
1860 { |
|
1861 struct rtl8139_private *tp = dev->priv; |
|
1862 void *ioaddr = tp->mmio_addr; |
|
1863 unsigned int entry; |
|
1864 unsigned int len = skb->len; |
|
1865 |
|
1866 /* Calculate the next Tx descriptor entry. */ |
|
1867 entry = tp->cur_tx % NUM_TX_DESC; |
|
1868 |
|
1869 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1870 |
|
1871 if (likely(len < TX_BUF_SIZE)) |
|
1872 { |
|
1873 skb_copy_and_csum_dev(skb, tp->tx_buf[entry]); |
|
1874 |
|
1875 // Socket buffer nicht löschen, wenn vom EtherCAT-device |
|
1876 if (dev != rtl_ecat_dev.dev) dev_kfree_skb(skb); |
|
1877 } |
|
1878 else |
|
1879 { |
|
1880 if (dev != rtl_ecat_dev.dev) dev_kfree_skb(skb); |
|
1881 tp->stats.tx_dropped++; |
|
1882 return 0; |
|
1883 } |
|
1884 |
|
1885 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1886 |
|
1887 /* Note: the chip doesn't have auto-pad! */ |
|
1888 spin_lock_irq(&tp->lock); |
|
1889 |
|
1890 RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), |
|
1891 tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); |
|
1892 |
|
1893 dev->trans_start = jiffies; |
|
1894 |
|
1895 tp->cur_tx++; |
|
1896 wmb(); |
|
1897 |
|
1898 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1899 |
|
1900 if (dev != rtl_ecat_dev.dev |
|
1901 && ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)) |
|
1902 { |
|
1903 netif_stop_queue (dev); |
|
1904 } |
|
1905 |
|
1906 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1907 |
|
1908 spin_unlock_irq(&tp->lock); |
|
1909 |
|
1910 DPRINTK ("%s: Queued Tx packet size %u to slot %d.\n", |
|
1911 dev->name, len, entry); |
|
1912 |
|
1913 return 0; |
|
1914 } |
|
1915 |
|
1916 |
|
1917 static void rtl8139_tx_interrupt (struct net_device *dev, |
|
1918 struct rtl8139_private *tp, |
|
1919 void *ioaddr) |
|
1920 { |
|
1921 unsigned long dirty_tx, tx_left; |
|
1922 |
|
1923 assert (dev != NULL); |
|
1924 assert (tp != NULL); |
|
1925 assert (ioaddr != NULL); |
|
1926 |
|
1927 dirty_tx = tp->dirty_tx; |
|
1928 tx_left = tp->cur_tx - dirty_tx; |
|
1929 |
|
1930 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1931 |
|
1932 if (dev == rtl_ecat_dev.dev) |
|
1933 { |
|
1934 rtl_ecat_dev.tx_intr_cnt++; |
|
1935 rdtscl(rtl_ecat_dev.tx_time); // Get CPU cycles |
|
1936 } |
|
1937 |
|
1938 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1939 |
|
1940 while (tx_left > 0) { |
|
1941 int entry = dirty_tx % NUM_TX_DESC; |
|
1942 int txstatus; |
|
1943 |
|
1944 txstatus = RTL_R32 (TxStatus0 + (entry * sizeof (u32))); |
|
1945 |
|
1946 if (!(txstatus & (TxStatOK | TxUnderrun | TxAborted))) |
|
1947 break; /* It still hasn't been Txed */ |
|
1948 |
|
1949 /* Note: TxCarrierLost is always asserted at 100mbps. */ |
|
1950 if (txstatus & (TxOutOfWindow | TxAborted)) { |
|
1951 /* There was an major error, log it. */ |
|
1952 DPRINTK ("%s: Transmit error, Tx status %8.8x.\n", |
|
1953 dev->name, txstatus); |
|
1954 tp->stats.tx_errors++; |
|
1955 if (txstatus & TxAborted) { |
|
1956 tp->stats.tx_aborted_errors++; |
|
1957 RTL_W32 (TxConfig, TxClearAbt); |
|
1958 RTL_W16 (IntrStatus, TxErr); |
|
1959 wmb(); |
|
1960 } |
|
1961 if (txstatus & TxCarrierLost) |
|
1962 tp->stats.tx_carrier_errors++; |
|
1963 if (txstatus & TxOutOfWindow) |
|
1964 tp->stats.tx_window_errors++; |
|
1965 |
|
1966 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
1967 |
|
1968 if (dev == rtl_ecat_dev.dev) |
|
1969 { |
|
1970 rtl_ecat_dev.state = ECAT_DS_ERROR; |
|
1971 } |
|
1972 |
|
1973 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
1974 |
|
1975 } else { |
|
1976 if (txstatus & TxUnderrun) { |
|
1977 /* Add 64 to the Tx FIFO threshold. */ |
|
1978 if (tp->tx_flag < 0x00300000) |
|
1979 tp->tx_flag += 0x00020000; |
|
1980 tp->stats.tx_fifo_errors++; |
|
1981 } |
|
1982 tp->stats.collisions += (txstatus >> 24) & 15; |
|
1983 tp->stats.tx_bytes += txstatus & 0x7ff; |
|
1984 tp->stats.tx_packets++; |
|
1985 } |
|
1986 |
|
1987 dirty_tx++; |
|
1988 tx_left--; |
|
1989 } |
|
1990 |
|
1991 #ifndef RTL8139_NDEBUG |
|
1992 if (tp->cur_tx - dirty_tx > NUM_TX_DESC) { |
|
1993 EC_DBG (KERN_ERR "%s: Out-of-sync dirty pointer, %ld vs. %ld.\n", |
|
1994 dev->name, dirty_tx, tp->cur_tx); |
|
1995 dirty_tx += NUM_TX_DESC; |
|
1996 } |
|
1997 #endif /* RTL8139_NDEBUG */ |
|
1998 |
|
1999 /* only wake the queue if we did work, and the queue is stopped */ |
|
2000 if (tp->dirty_tx != dirty_tx) { |
|
2001 tp->dirty_tx = dirty_tx; |
|
2002 mb(); |
|
2003 |
|
2004 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2005 |
|
2006 if (dev != rtl_ecat_dev.dev && netif_queue_stopped (dev)) |
|
2007 { |
|
2008 netif_wake_queue (dev); |
|
2009 } |
|
2010 |
|
2011 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2012 } |
|
2013 } |
|
2014 |
|
2015 |
|
2016 /* TODO: clean this up! Rx reset need not be this intensive */ |
|
2017 static void rtl8139_rx_err (u32 rx_status, struct net_device *dev, |
|
2018 struct rtl8139_private *tp, void *ioaddr) |
|
2019 { |
|
2020 u8 tmp8; |
|
2021 #ifdef CONFIG_8139_OLD_RX_RESET |
|
2022 int tmp_work; |
|
2023 #endif |
|
2024 |
|
2025 DPRINTK ("%s: Ethernet frame had errors, status %8.8x.\n", |
|
2026 dev->name, rx_status); |
|
2027 tp->stats.rx_errors++; |
|
2028 if (!(rx_status & RxStatusOK)) { |
|
2029 if (rx_status & RxTooLong) { |
|
2030 DPRINTK ("%s: Oversized Ethernet frame, status %4.4x!\n", |
|
2031 dev->name, rx_status); |
|
2032 /* A.C.: The chip hangs here. */ |
|
2033 } |
|
2034 if (rx_status & (RxBadSymbol | RxBadAlign)) |
|
2035 tp->stats.rx_frame_errors++; |
|
2036 if (rx_status & (RxRunt | RxTooLong)) |
|
2037 tp->stats.rx_length_errors++; |
|
2038 if (rx_status & RxCRCErr) |
|
2039 tp->stats.rx_crc_errors++; |
|
2040 } else { |
|
2041 tp->xstats.rx_lost_in_ring++; |
|
2042 } |
|
2043 |
|
2044 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2045 |
|
2046 if (dev == rtl_ecat_dev.dev) |
|
2047 { |
|
2048 rtl_ecat_dev.state = ECAT_DS_ERROR; |
|
2049 } |
|
2050 |
|
2051 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2052 |
|
2053 #ifndef CONFIG_8139_OLD_RX_RESET |
|
2054 tmp8 = RTL_R8 (ChipCmd); |
|
2055 RTL_W8 (ChipCmd, tmp8 & ~CmdRxEnb); |
|
2056 RTL_W8 (ChipCmd, tmp8); |
|
2057 RTL_W32 (RxConfig, tp->rx_config); |
|
2058 tp->cur_rx = 0; |
|
2059 #else |
|
2060 /* Reset the receiver, based on RealTek recommendation. (Bug?) */ |
|
2061 |
|
2062 /* disable receive */ |
|
2063 RTL_W8_F (ChipCmd, CmdTxEnb); |
|
2064 tmp_work = 200; |
|
2065 while (--tmp_work > 0) { |
|
2066 udelay(1); |
|
2067 tmp8 = RTL_R8 (ChipCmd); |
|
2068 if (!(tmp8 & CmdRxEnb)) |
|
2069 break; |
|
2070 } |
|
2071 if (tmp_work <= 0) |
|
2072 EC_DBG (KERN_WARNING PFX "rx stop wait too long\n"); |
|
2073 /* restart receive */ |
|
2074 tmp_work = 200; |
|
2075 while (--tmp_work > 0) { |
|
2076 RTL_W8_F (ChipCmd, CmdRxEnb | CmdTxEnb); |
|
2077 udelay(1); |
|
2078 tmp8 = RTL_R8 (ChipCmd); |
|
2079 if ((tmp8 & CmdRxEnb) && (tmp8 & CmdTxEnb)) |
|
2080 break; |
|
2081 } |
|
2082 if (tmp_work <= 0) |
|
2083 EC_DBG (KERN_WARNING PFX "tx/rx enable wait too long\n"); |
|
2084 |
|
2085 /* and reinitialize all rx related registers */ |
|
2086 RTL_W8_F (Cfg9346, Cfg9346_Unlock); |
|
2087 /* Must enable Tx/Rx before setting transfer thresholds! */ |
|
2088 RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb); |
|
2089 |
|
2090 tp->rx_config = rtl8139_rx_config | AcceptBroadcast | AcceptMyPhys; |
|
2091 RTL_W32 (RxConfig, tp->rx_config); |
|
2092 tp->cur_rx = 0; |
|
2093 |
|
2094 DPRINTK("init buffer addresses\n"); |
|
2095 |
|
2096 /* Lock Config[01234] and BMCR register writes */ |
|
2097 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
2098 |
|
2099 /* init Rx ring buffer DMA address */ |
|
2100 RTL_W32_F (RxBuf, tp->rx_ring_dma); |
|
2101 |
|
2102 /* A.C.: Reset the multicast list. */ |
|
2103 __set_rx_mode (dev); |
|
2104 #endif |
|
2105 } |
|
2106 |
|
2107 static void rtl8139_rx_interrupt (struct net_device *dev, |
|
2108 struct rtl8139_private *tp, void *ioaddr) |
|
2109 { |
|
2110 unsigned char *rx_ring; |
|
2111 u16 cur_rx; |
|
2112 |
|
2113 assert (dev != NULL); |
|
2114 assert (tp != NULL); |
|
2115 assert (ioaddr != NULL); |
|
2116 |
|
2117 rx_ring = tp->rx_ring; |
|
2118 cur_rx = tp->cur_rx; |
|
2119 |
|
2120 DPRINTK ("%s: In rtl8139_rx(), current %4.4x BufAddr %4.4x," |
|
2121 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, |
|
2122 RTL_R16 (RxBufAddr), |
|
2123 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); |
|
2124 |
|
2125 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2126 |
|
2127 if (dev == rtl_ecat_dev.dev) |
|
2128 { |
|
2129 rtl_ecat_dev.rx_intr_cnt++; |
|
2130 rdtscl(rtl_ecat_dev.rx_time); // Get CPU cycles |
|
2131 } |
|
2132 |
|
2133 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2134 |
|
2135 while ((RTL_R8 (ChipCmd) & RxBufEmpty) == 0) { |
|
2136 int ring_offset = cur_rx % RX_BUF_LEN; |
|
2137 u32 rx_status; |
|
2138 unsigned int rx_size; |
|
2139 unsigned int pkt_size; |
|
2140 struct sk_buff *skb; |
|
2141 |
|
2142 rmb(); |
|
2143 |
|
2144 /* read size+status of next frame from DMA ring buffer */ |
|
2145 rx_status = le32_to_cpu (*(u32 *) (rx_ring + ring_offset)); |
|
2146 rx_size = rx_status >> 16; |
|
2147 pkt_size = rx_size - 4; |
|
2148 |
|
2149 |
|
2150 DPRINTK ("%s: rtl8139_rx() status %4.4x, size %4.4x," |
|
2151 " cur %4.4x.\n", dev->name, rx_status, |
|
2152 rx_size, cur_rx); |
|
2153 |
|
2154 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2155 |
|
2156 #if RTL8139_DEBUG > 2 |
|
2157 if (dev == rtl_ecat_dev.dev) |
|
2158 { |
|
2159 int i; |
|
2160 DPRINTK("%s: Frame contents ", dev->name); |
|
2161 for (i = 0; i < 70; i++) EC_DBG(" %2.2x", rx_ring[ring_offset + i]); |
|
2162 EC_DBG(".\n"); |
|
2163 } |
|
2164 #endif |
|
2165 |
|
2166 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2167 |
|
2168 /* Packet copy from FIFO still in progress. |
|
2169 * Theoretically, this should never happen |
|
2170 * since EarlyRx is disabled. |
|
2171 */ |
|
2172 if (rx_size == 0xfff0) { |
|
2173 tp->xstats.early_rx++; |
|
2174 break; |
|
2175 } |
|
2176 |
|
2177 /* If Rx err or invalid rx_size/rx_status received |
|
2178 * (which happens if we get lost in the ring), |
|
2179 * Rx process gets reset, so we abort any further |
|
2180 * Rx processing. |
|
2181 */ |
|
2182 if ((rx_size > (MAX_ETH_FRAME_SIZE+4)) || |
|
2183 (rx_size < 8) || |
|
2184 (!(rx_status & RxStatusOK))) { |
|
2185 rtl8139_rx_err (rx_status, dev, tp, ioaddr); |
|
2186 return; |
|
2187 } |
|
2188 |
|
2189 /* Malloc up new buffer, compatible with net-2e. */ |
|
2190 /* Omit the four octet CRC from the length. */ |
|
2191 |
|
2192 /* TODO: consider allocating skb's outside of |
|
2193 * interrupt context, both to speed interrupt processing, |
|
2194 * and also to reduce the chances of having to |
|
2195 * drop packets here under memory pressure. |
|
2196 */ |
|
2197 |
|
2198 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2199 |
|
2200 if (dev != rtl_ecat_dev.dev) |
|
2201 { |
|
2202 skb = dev_alloc_skb(pkt_size + 2); |
|
2203 |
|
2204 if (skb) |
|
2205 { |
|
2206 skb->dev = dev; |
|
2207 skb_reserve(skb, 2); /* 16 byte align the IP fields. */ |
|
2208 eth_copy_and_sum(skb, &rx_ring[ring_offset + 4], pkt_size, 0); |
|
2209 skb_put (skb, pkt_size); |
|
2210 skb->protocol = eth_type_trans(skb, dev); // Entfernt auch den Ethernet Header! |
|
2211 netif_rx(skb); |
|
2212 |
|
2213 dev->last_rx = jiffies; |
|
2214 tp->stats.rx_bytes += pkt_size; |
|
2215 tp->stats.rx_packets++; |
|
2216 } |
|
2217 else |
|
2218 { |
|
2219 EC_DBG (KERN_WARNING |
|
2220 "%s: Memory squeeze, dropping packet.\n", |
|
2221 dev->name); |
|
2222 tp->stats.rx_dropped++; |
|
2223 } |
|
2224 } |
|
2225 else |
|
2226 { |
|
2227 if (rtl_ecat_dev.state != ECAT_DS_SENT) |
|
2228 { |
|
2229 EC_DBG(KERN_WARNING "EtherCAT: Received frame while not in SENT state!\n"); |
|
2230 } |
|
2231 else |
|
2232 { |
|
2233 // Copy received data to ethercat-device buffer, skip Ethernet-II header |
|
2234 memcpy(rtl_ecat_dev.rx_data, &rx_ring[ring_offset + 4] + ETH_HLEN, |
|
2235 pkt_size - ETH_HLEN); |
|
2236 rtl_ecat_dev.rx_data_length = pkt_size - ETH_HLEN; |
|
2237 |
|
2238 rtl_ecat_dev.state = ECAT_DS_RECEIVED; |
|
2239 |
|
2240 dev->last_rx = jiffies; |
|
2241 tp->stats.rx_bytes += pkt_size; |
|
2242 tp->stats.rx_packets++; |
|
2243 } |
|
2244 } |
|
2245 |
|
2246 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2247 |
|
2248 cur_rx = (cur_rx + rx_size + 4 + 3) & ~3; |
|
2249 RTL_W16 (RxBufPtr, cur_rx - 16); |
|
2250 |
|
2251 if (RTL_R16 (IntrStatus) & RxAckBits) |
|
2252 RTL_W16_F (IntrStatus, RxAckBits); |
|
2253 } |
|
2254 |
|
2255 DPRINTK ("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x," |
|
2256 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx, |
|
2257 RTL_R16 (RxBufAddr), |
|
2258 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd)); |
|
2259 |
|
2260 tp->cur_rx = cur_rx; |
|
2261 } |
|
2262 |
|
2263 |
|
2264 static void rtl8139_weird_interrupt (struct net_device *dev, |
|
2265 struct rtl8139_private *tp, |
|
2266 void *ioaddr, |
|
2267 int status, int link_changed) |
|
2268 { |
|
2269 DPRINTK ("%s: Abnormal interrupt, status %8.8x.\n", |
|
2270 dev->name, status); |
|
2271 |
|
2272 assert (dev != NULL); |
|
2273 assert (tp != NULL); |
|
2274 assert (ioaddr != NULL); |
|
2275 |
|
2276 /* Update the error count. */ |
|
2277 tp->stats.rx_missed_errors += RTL_R32 (RxMissed); |
|
2278 RTL_W32 (RxMissed, 0); |
|
2279 |
|
2280 if ((status & RxUnderrun) && link_changed && |
|
2281 (tp->drv_flags & HAS_LNK_CHNG)) { |
|
2282 /* Really link-change on new chips. */ |
|
2283 int lpar = RTL_R16 (NWayLPAR); |
|
2284 int duplex = (lpar & LPA_100FULL) || (lpar & 0x01C0) == 0x0040 |
|
2285 || tp->mii.force_media; |
|
2286 if (tp->mii.full_duplex != duplex) { |
|
2287 tp->mii.full_duplex = duplex; |
|
2288 #if 0 |
|
2289 RTL_W8 (Cfg9346, Cfg9346_Unlock); |
|
2290 RTL_W8 (Config1, tp->mii.full_duplex ? 0x60 : 0x20); |
|
2291 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
2292 #endif |
|
2293 } |
|
2294 status &= ~RxUnderrun; |
|
2295 } |
|
2296 |
|
2297 /* XXX along with rtl8139_rx_err, are we double-counting errors? */ |
|
2298 if (status & |
|
2299 (RxUnderrun | RxOverflow | RxErr | RxFIFOOver)) |
|
2300 tp->stats.rx_errors++; |
|
2301 |
|
2302 if (status & PCSTimeout) |
|
2303 tp->stats.rx_length_errors++; |
|
2304 if (status & (RxUnderrun | RxFIFOOver)) |
|
2305 tp->stats.rx_fifo_errors++; |
|
2306 if (status & PCIErr) { |
|
2307 u16 pci_cmd_status; |
|
2308 pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status); |
|
2309 pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status); |
|
2310 |
|
2311 EC_DBG (KERN_ERR "%s: PCI Bus error %4.4x.\n", |
|
2312 dev->name, pci_cmd_status); |
|
2313 } |
|
2314 } |
|
2315 |
|
2316 /* The interrupt handler does all of the Rx thread work and cleans up |
|
2317 after the Tx thread. */ |
|
2318 static void rtl8139_interrupt (int irq, void *dev_instance, |
|
2319 struct pt_regs *regs) |
|
2320 { |
|
2321 struct net_device *dev = (struct net_device *) dev_instance; |
|
2322 struct rtl8139_private *tp = dev->priv; |
|
2323 int boguscnt = max_interrupt_work; |
|
2324 void *ioaddr = tp->mmio_addr; |
|
2325 int ackstat, status; |
|
2326 int link_changed = 0; /* avoid bogus "uninit" warning */ |
|
2327 |
|
2328 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2329 |
|
2330 if (dev == rtl_ecat_dev.dev) |
|
2331 { |
|
2332 rtl_ecat_dev.intr_cnt++; |
|
2333 } |
|
2334 else |
|
2335 { |
|
2336 spin_lock(&tp->lock); |
|
2337 } |
|
2338 |
|
2339 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2340 |
|
2341 do { |
|
2342 status = RTL_R16 (IntrStatus); |
|
2343 |
|
2344 /* h/w no longer present (hotplug?) or major error, bail */ |
|
2345 if (status == 0xFFFF) |
|
2346 break; |
|
2347 |
|
2348 if ((status & |
|
2349 (PCIErr | PCSTimeout | RxUnderrun | RxOverflow | |
|
2350 RxFIFOOver | TxErr | TxOK | RxErr | RxOK)) == 0) |
|
2351 break; |
|
2352 |
|
2353 /* Acknowledge all of the current interrupt sources ASAP, but |
|
2354 an first get an additional status bit from CSCR. */ |
|
2355 if (status & RxUnderrun) |
|
2356 link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit; |
|
2357 |
|
2358 /* The chip takes special action when we clear RxAckBits, |
|
2359 * so we clear them later in rtl8139_rx_interrupt |
|
2360 */ |
|
2361 ackstat = status & ~(RxAckBits | TxErr); |
|
2362 RTL_W16 (IntrStatus, ackstat); |
|
2363 |
|
2364 DPRINTK ("%s: interrupt status=%#4.4x ackstat=%#4.4x new intstat=%#4.4x.\n", |
|
2365 dev->name, ackstat, status, RTL_R16 (IntrStatus)); |
|
2366 |
|
2367 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2368 |
|
2369 if ((dev == rtl_ecat_dev.dev || netif_running (dev)) && (status & RxAckBits)) |
|
2370 { |
|
2371 rtl8139_rx_interrupt (dev, tp, ioaddr); |
|
2372 } |
|
2373 |
|
2374 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2375 |
|
2376 /* Check uncommon events with one test. */ |
|
2377 if (status & (PCIErr | PCSTimeout | RxUnderrun | RxOverflow | |
|
2378 RxFIFOOver | RxErr)) |
|
2379 rtl8139_weird_interrupt (dev, tp, ioaddr, |
|
2380 status, link_changed); |
|
2381 |
|
2382 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2383 |
|
2384 if ((dev == rtl_ecat_dev.dev || netif_running (dev)) |
|
2385 && (status & (TxOK | TxErr))) |
|
2386 { |
|
2387 rtl8139_tx_interrupt (dev, tp, ioaddr); |
|
2388 if (status & TxErr) |
|
2389 RTL_W16 (IntrStatus, TxErr); |
|
2390 } |
|
2391 |
|
2392 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2393 |
|
2394 boguscnt--; |
|
2395 } while (boguscnt > 0); |
|
2396 |
|
2397 if (boguscnt <= 0) { |
|
2398 EC_DBG (KERN_WARNING "%s: Too much work at interrupt, " |
|
2399 "IntrStatus=0x%4.4x.\n", dev->name, status); |
|
2400 |
|
2401 /* Clear all interrupt sources. */ |
|
2402 RTL_W16 (IntrStatus, 0xffff); |
|
2403 } |
|
2404 |
|
2405 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2406 |
|
2407 if (dev != rtl_ecat_dev.dev) |
|
2408 { |
|
2409 spin_unlock (&tp->lock); |
|
2410 } |
|
2411 |
|
2412 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2413 |
|
2414 DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n", |
|
2415 dev->name, RTL_R16 (IntrStatus)); |
|
2416 } |
|
2417 |
|
2418 static int rtl8139_close (struct net_device *dev) |
|
2419 { |
|
2420 struct rtl8139_private *tp = dev->priv; |
|
2421 void *ioaddr = tp->mmio_addr; |
|
2422 int ret = 0; |
|
2423 unsigned long flags; |
|
2424 |
|
2425 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2426 |
|
2427 if (dev != rtl_ecat_dev.dev) |
|
2428 { |
|
2429 netif_stop_queue(dev); |
|
2430 |
|
2431 if (tp->thr_pid >= 0) { |
|
2432 tp->time_to_die = 1; |
|
2433 wmb(); |
|
2434 ret = kill_proc (tp->thr_pid, SIGTERM, 1); |
|
2435 if (ret) { |
|
2436 EC_DBG (KERN_ERR "%s: unable to signal thread\n", dev->name); |
|
2437 return ret; |
|
2438 } |
|
2439 wait_for_completion (&tp->thr_exited); |
|
2440 } |
|
2441 } |
|
2442 |
|
2443 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2444 |
|
2445 DPRINTK ("%s: Shutting down ethercard, status was 0x%4.4x.\n", |
|
2446 dev->name, RTL_R16 (IntrStatus)); |
|
2447 |
|
2448 spin_lock_irqsave(&tp->lock, flags); |
|
2449 |
|
2450 /* Stop the chip's Tx and Rx DMA processes. */ |
|
2451 RTL_W8 (ChipCmd, 0); |
|
2452 |
|
2453 /* Disable interrupts by clearing the interrupt mask. */ |
|
2454 RTL_W16 (IntrMask, 0); |
|
2455 |
|
2456 /* Update the error counts. */ |
|
2457 tp->stats.rx_missed_errors += RTL_R32 (RxMissed); |
|
2458 RTL_W32 (RxMissed, 0); |
|
2459 |
|
2460 spin_unlock_irqrestore (&tp->lock, flags); |
|
2461 synchronize_irq (); |
|
2462 |
|
2463 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2464 |
|
2465 if (dev != rtl_ecat_dev.dev) |
|
2466 { |
|
2467 free_irq(dev->irq, dev); |
|
2468 } |
|
2469 |
|
2470 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2471 |
|
2472 rtl8139_tx_clear (tp); |
|
2473 |
|
2474 pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN, |
|
2475 tp->rx_ring, tp->rx_ring_dma); |
|
2476 pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN, |
|
2477 tp->tx_bufs, tp->tx_bufs_dma); |
|
2478 tp->rx_ring = NULL; |
|
2479 tp->tx_bufs = NULL; |
|
2480 |
|
2481 /* Green! Put the chip in low-power mode. */ |
|
2482 RTL_W8 (Cfg9346, Cfg9346_Unlock); |
|
2483 |
|
2484 if (rtl_chip_info[tp->chipset].flags & HasHltClk) |
|
2485 RTL_W8 (HltClk, 'H'); /* 'R' would leave the clock running. */ |
|
2486 |
|
2487 return 0; |
|
2488 } |
|
2489 |
|
2490 |
|
2491 /* Get the ethtool Wake-on-LAN settings. Assumes that wol points to |
|
2492 kernel memory, *wol has been initialized as {ETHTOOL_GWOL}, and |
|
2493 other threads or interrupts aren't messing with the 8139. */ |
|
2494 static void netdev_get_wol (struct net_device *dev, struct ethtool_wolinfo *wol) |
|
2495 { |
|
2496 struct rtl8139_private *np = dev->priv; |
|
2497 void *ioaddr = np->mmio_addr; |
|
2498 |
|
2499 if (rtl_chip_info[np->chipset].flags & HasLWake) { |
|
2500 u8 cfg3 = RTL_R8 (Config3); |
|
2501 u8 cfg5 = RTL_R8 (Config5); |
|
2502 |
|
2503 wol->supported = WAKE_PHY | WAKE_MAGIC |
|
2504 | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST; |
|
2505 |
|
2506 wol->wolopts = 0; |
|
2507 if (cfg3 & Cfg3_LinkUp) |
|
2508 wol->wolopts |= WAKE_PHY; |
|
2509 if (cfg3 & Cfg3_Magic) |
|
2510 wol->wolopts |= WAKE_MAGIC; |
|
2511 /* (KON)FIXME: See how netdev_set_wol() handles the |
|
2512 following constants. */ |
|
2513 if (cfg5 & Cfg5_UWF) |
|
2514 wol->wolopts |= WAKE_UCAST; |
|
2515 if (cfg5 & Cfg5_MWF) |
|
2516 wol->wolopts |= WAKE_MCAST; |
|
2517 if (cfg5 & Cfg5_BWF) |
|
2518 wol->wolopts |= WAKE_BCAST; |
|
2519 } |
|
2520 } |
|
2521 |
|
2522 |
|
2523 /* Set the ethtool Wake-on-LAN settings. Return 0 or -errno. Assumes |
|
2524 that wol points to kernel memory and other threads or interrupts |
|
2525 aren't messing with the 8139. */ |
|
2526 static int netdev_set_wol (struct net_device *dev, |
|
2527 const struct ethtool_wolinfo *wol) |
|
2528 { |
|
2529 struct rtl8139_private *np = dev->priv; |
|
2530 void *ioaddr = np->mmio_addr; |
|
2531 u32 support; |
|
2532 u8 cfg3, cfg5; |
|
2533 |
|
2534 support = ((rtl_chip_info[np->chipset].flags & HasLWake) |
|
2535 ? (WAKE_PHY | WAKE_MAGIC |
|
2536 | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST) |
|
2537 : 0); |
|
2538 if (wol->wolopts & ~support) |
|
2539 return -EINVAL; |
|
2540 |
|
2541 cfg3 = RTL_R8 (Config3) & ~(Cfg3_LinkUp | Cfg3_Magic); |
|
2542 if (wol->wolopts & WAKE_PHY) |
|
2543 cfg3 |= Cfg3_LinkUp; |
|
2544 if (wol->wolopts & WAKE_MAGIC) |
|
2545 cfg3 |= Cfg3_Magic; |
|
2546 RTL_W8 (Cfg9346, Cfg9346_Unlock); |
|
2547 RTL_W8 (Config3, cfg3); |
|
2548 RTL_W8 (Cfg9346, Cfg9346_Lock); |
|
2549 |
|
2550 cfg5 = RTL_R8 (Config5) & ~(Cfg5_UWF | Cfg5_MWF | Cfg5_BWF); |
|
2551 /* (KON)FIXME: These are untested. We may have to set the |
|
2552 CRC0, Wakeup0 and LSBCRC0 registers too, but I have no |
|
2553 documentation. */ |
|
2554 if (wol->wolopts & WAKE_UCAST) |
|
2555 cfg5 |= Cfg5_UWF; |
|
2556 if (wol->wolopts & WAKE_MCAST) |
|
2557 cfg5 |= Cfg5_MWF; |
|
2558 if (wol->wolopts & WAKE_BCAST) |
|
2559 cfg5 |= Cfg5_BWF; |
|
2560 RTL_W8 (Config5, cfg5); /* need not unlock via Cfg9346 */ |
|
2561 |
|
2562 return 0; |
|
2563 } |
|
2564 |
|
2565 static int netdev_ethtool_ioctl (struct net_device *dev, void *useraddr) |
|
2566 { |
|
2567 struct rtl8139_private *np = dev->priv; |
|
2568 u32 ethcmd; |
|
2569 |
|
2570 /* dev_ioctl() in ../../net/core/dev.c has already checked |
|
2571 capable(CAP_NET_ADMIN), so don't bother with that here. */ |
|
2572 |
|
2573 if (get_user(ethcmd, (u32 *)useraddr)) |
|
2574 return -EFAULT; |
|
2575 |
|
2576 switch (ethcmd) { |
|
2577 |
|
2578 case ETHTOOL_GDRVINFO: { |
|
2579 struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO }; |
|
2580 strcpy (info.driver, DRV_NAME); |
|
2581 strcpy (info.version, DRV_VERSION); |
|
2582 strcpy (info.bus_info, np->pci_dev->slot_name); |
|
2583 info.regdump_len = np->regs_len; |
|
2584 if (copy_to_user (useraddr, &info, sizeof (info))) |
|
2585 return -EFAULT; |
|
2586 return 0; |
|
2587 } |
|
2588 |
|
2589 /* get settings */ |
|
2590 case ETHTOOL_GSET: { |
|
2591 struct ethtool_cmd ecmd = { ETHTOOL_GSET }; |
|
2592 spin_lock_irq(&np->lock); |
|
2593 mii_ethtool_gset(&np->mii, &ecmd); |
|
2594 spin_unlock_irq(&np->lock); |
|
2595 if (copy_to_user(useraddr, &ecmd, sizeof(ecmd))) |
|
2596 return -EFAULT; |
|
2597 return 0; |
|
2598 } |
|
2599 /* set settings */ |
|
2600 case ETHTOOL_SSET: { |
|
2601 int r; |
|
2602 struct ethtool_cmd ecmd; |
|
2603 if (copy_from_user(&ecmd, useraddr, sizeof(ecmd))) |
|
2604 return -EFAULT; |
|
2605 spin_lock_irq(&np->lock); |
|
2606 r = mii_ethtool_sset(&np->mii, &ecmd); |
|
2607 spin_unlock_irq(&np->lock); |
|
2608 return r; |
|
2609 } |
|
2610 /* restart autonegotiation */ |
|
2611 case ETHTOOL_NWAY_RST: { |
|
2612 return mii_nway_restart(&np->mii); |
|
2613 } |
|
2614 /* get link status */ |
|
2615 case ETHTOOL_GLINK: { |
|
2616 struct ethtool_value edata = {ETHTOOL_GLINK}; |
|
2617 edata.data = mii_link_ok(&np->mii); |
|
2618 if (copy_to_user(useraddr, &edata, sizeof(edata))) |
|
2619 return -EFAULT; |
|
2620 return 0; |
|
2621 } |
|
2622 |
|
2623 /* get message-level */ |
|
2624 case ETHTOOL_GMSGLVL: { |
|
2625 struct ethtool_value edata = {ETHTOOL_GMSGLVL}; |
|
2626 edata.data = debug; |
|
2627 if (copy_to_user(useraddr, &edata, sizeof(edata))) |
|
2628 return -EFAULT; |
|
2629 return 0; |
|
2630 } |
|
2631 /* set message-level */ |
|
2632 case ETHTOOL_SMSGLVL: { |
|
2633 struct ethtool_value edata; |
|
2634 if (copy_from_user(&edata, useraddr, sizeof(edata))) |
|
2635 return -EFAULT; |
|
2636 debug = edata.data; |
|
2637 return 0; |
|
2638 } |
|
2639 |
|
2640 case ETHTOOL_GWOL: |
|
2641 { |
|
2642 struct ethtool_wolinfo wol = { ETHTOOL_GWOL }; |
|
2643 spin_lock_irq (&np->lock); |
|
2644 netdev_get_wol (dev, &wol); |
|
2645 spin_unlock_irq (&np->lock); |
|
2646 if (copy_to_user (useraddr, &wol, sizeof (wol))) |
|
2647 return -EFAULT; |
|
2648 return 0; |
|
2649 } |
|
2650 |
|
2651 case ETHTOOL_SWOL: |
|
2652 { |
|
2653 struct ethtool_wolinfo wol; |
|
2654 int rc; |
|
2655 if (copy_from_user (&wol, useraddr, sizeof (wol))) |
|
2656 return -EFAULT; |
|
2657 spin_lock_irq (&np->lock); |
|
2658 rc = netdev_set_wol (dev, &wol); |
|
2659 spin_unlock_irq (&np->lock); |
|
2660 return rc; |
|
2661 } |
|
2662 |
|
2663 /* TODO: we are too slack to do reg dumping for pio, for now */ |
|
2664 #ifndef CONFIG_8139TOO_PIO |
|
2665 /* NIC register dump */ |
|
2666 case ETHTOOL_GREGS: { |
|
2667 struct ethtool_regs regs; |
|
2668 unsigned int regs_len = np->regs_len; |
|
2669 u8 *regbuf = kmalloc(regs_len, GFP_KERNEL); |
|
2670 int rc; |
|
2671 |
|
2672 if (!regbuf) |
|
2673 return -ENOMEM; |
|
2674 memset(regbuf, 0, regs_len); |
|
2675 |
|
2676 rc = copy_from_user(®s, useraddr, sizeof(regs)); |
|
2677 if (rc) { |
|
2678 rc = -EFAULT; |
|
2679 goto err_out_gregs; |
|
2680 } |
|
2681 |
|
2682 if (regs.len > regs_len) |
|
2683 regs.len = regs_len; |
|
2684 if (regs.len < regs_len) { |
|
2685 rc = -EINVAL; |
|
2686 goto err_out_gregs; |
|
2687 } |
|
2688 |
|
2689 regs.version = RTL_REGS_VER; |
|
2690 rc = copy_to_user(useraddr, ®s, sizeof(regs)); |
|
2691 if (rc) { |
|
2692 rc = -EFAULT; |
|
2693 goto err_out_gregs; |
|
2694 } |
|
2695 |
|
2696 useraddr += offsetof(struct ethtool_regs, data); |
|
2697 |
|
2698 spin_lock_irq(&np->lock); |
|
2699 memcpy_fromio(regbuf, np->mmio_addr, regs_len); |
|
2700 spin_unlock_irq(&np->lock); |
|
2701 |
|
2702 if (copy_to_user(useraddr, regbuf, regs_len)) |
|
2703 rc = -EFAULT; |
|
2704 |
|
2705 err_out_gregs: |
|
2706 kfree(regbuf); |
|
2707 return rc; |
|
2708 } |
|
2709 #endif /* CONFIG_8139TOO_PIO */ |
|
2710 |
|
2711 /* get string list(s) */ |
|
2712 case ETHTOOL_GSTRINGS: { |
|
2713 struct ethtool_gstrings estr = { ETHTOOL_GSTRINGS }; |
|
2714 |
|
2715 if (copy_from_user(&estr, useraddr, sizeof(estr))) |
|
2716 return -EFAULT; |
|
2717 if (estr.string_set != ETH_SS_STATS) |
|
2718 return -EINVAL; |
|
2719 |
|
2720 estr.len = RTL_NUM_STATS; |
|
2721 if (copy_to_user(useraddr, &estr, sizeof(estr))) |
|
2722 return -EFAULT; |
|
2723 if (copy_to_user(useraddr + sizeof(estr), |
|
2724 ðtool_stats_keys, |
|
2725 sizeof(ethtool_stats_keys))) |
|
2726 return -EFAULT; |
|
2727 return 0; |
|
2728 } |
|
2729 |
|
2730 /* get NIC-specific statistics */ |
|
2731 case ETHTOOL_GSTATS: { |
|
2732 struct ethtool_stats estats = { ETHTOOL_GSTATS }; |
|
2733 u64 *tmp_stats; |
|
2734 const unsigned int sz = sizeof(u64) * RTL_NUM_STATS; |
|
2735 int i; |
|
2736 |
|
2737 estats.n_stats = RTL_NUM_STATS; |
|
2738 if (copy_to_user(useraddr, &estats, sizeof(estats))) |
|
2739 return -EFAULT; |
|
2740 |
|
2741 tmp_stats = kmalloc(sz, GFP_KERNEL); |
|
2742 if (!tmp_stats) |
|
2743 return -ENOMEM; |
|
2744 memset(tmp_stats, 0, sz); |
|
2745 |
|
2746 i = 0; |
|
2747 tmp_stats[i++] = np->xstats.early_rx; |
|
2748 tmp_stats[i++] = np->xstats.tx_buf_mapped; |
|
2749 tmp_stats[i++] = np->xstats.tx_timeouts; |
|
2750 tmp_stats[i++] = np->xstats.rx_lost_in_ring; |
|
2751 if (i != RTL_NUM_STATS) |
|
2752 BUG(); |
|
2753 |
|
2754 i = copy_to_user(useraddr + sizeof(estats), tmp_stats, sz); |
|
2755 kfree(tmp_stats); |
|
2756 |
|
2757 if (i) |
|
2758 return -EFAULT; |
|
2759 return 0; |
|
2760 } |
|
2761 default: |
|
2762 break; |
|
2763 } |
|
2764 |
|
2765 return -EOPNOTSUPP; |
|
2766 } |
|
2767 |
|
2768 |
|
2769 static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
|
2770 { |
|
2771 struct rtl8139_private *np = dev->priv; |
|
2772 struct mii_ioctl_data *data = (struct mii_ioctl_data *) & rq->ifr_data; |
|
2773 int rc; |
|
2774 |
|
2775 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2776 |
|
2777 if (dev == rtl_ecat_dev.dev || !netif_running(dev)) |
|
2778 return -EINVAL; |
|
2779 |
|
2780 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2781 |
|
2782 if (cmd == SIOCETHTOOL) |
|
2783 rc = netdev_ethtool_ioctl(dev, (void *) rq->ifr_data); |
|
2784 |
|
2785 else { |
|
2786 spin_lock_irq(&np->lock); |
|
2787 rc = generic_mii_ioctl(&np->mii, data, cmd, NULL); |
|
2788 spin_unlock_irq(&np->lock); |
|
2789 } |
|
2790 |
|
2791 return rc; |
|
2792 } |
|
2793 |
|
2794 |
|
2795 static struct net_device_stats *rtl8139_get_stats (struct net_device *dev) |
|
2796 { |
|
2797 struct rtl8139_private *tp = dev->priv; |
|
2798 void *ioaddr = tp->mmio_addr; |
|
2799 unsigned long flags; |
|
2800 |
|
2801 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2802 |
|
2803 if (dev == rtl_ecat_dev.dev || netif_running(dev)) |
|
2804 { |
|
2805 spin_lock_irqsave (&tp->lock, flags); |
|
2806 tp->stats.rx_missed_errors += RTL_R32 (RxMissed); |
|
2807 RTL_W32 (RxMissed, 0); |
|
2808 spin_unlock_irqrestore (&tp->lock, flags); |
|
2809 } |
|
2810 |
|
2811 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2812 |
|
2813 return &tp->stats; |
|
2814 } |
|
2815 |
|
2816 /* Set or clear the multicast filter for this adaptor. |
|
2817 This routine is not state sensitive and need not be SMP locked. */ |
|
2818 |
|
2819 static void __set_rx_mode (struct net_device *dev) |
|
2820 { |
|
2821 struct rtl8139_private *tp = dev->priv; |
|
2822 void *ioaddr = tp->mmio_addr; |
|
2823 u32 mc_filter[2]; /* Multicast hash filter */ |
|
2824 int i, rx_mode; |
|
2825 u32 tmp; |
|
2826 |
|
2827 DPRINTK ("%s: rtl8139_set_rx_mode(%4.4x) done -- Rx config %8.8lx.\n", |
|
2828 dev->name, dev->flags, RTL_R32 (RxConfig)); |
|
2829 |
|
2830 /* Note: do not reorder, GCC is clever about common statements. */ |
|
2831 if (dev->flags & IFF_PROMISC) { |
|
2832 /* Unconditionally log net taps. */ |
|
2833 EC_DBG (KERN_NOTICE "%s: Promiscuous mode enabled.\n", |
|
2834 dev->name); |
|
2835 rx_mode = |
|
2836 AcceptBroadcast | AcceptMulticast | AcceptMyPhys | |
|
2837 AcceptAllPhys; |
|
2838 mc_filter[1] = mc_filter[0] = 0xffffffff; |
|
2839 } else if ((dev->mc_count > multicast_filter_limit) |
|
2840 || (dev->flags & IFF_ALLMULTI)) { |
|
2841 /* Too many to filter perfectly -- accept all multicasts. */ |
|
2842 rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; |
|
2843 mc_filter[1] = mc_filter[0] = 0xffffffff; |
|
2844 } else { |
|
2845 struct dev_mc_list *mclist; |
|
2846 rx_mode = AcceptBroadcast | AcceptMyPhys; |
|
2847 mc_filter[1] = mc_filter[0] = 0; |
|
2848 for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count; |
|
2849 i++, mclist = mclist->next) { |
|
2850 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26; |
|
2851 |
|
2852 mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); |
|
2853 rx_mode |= AcceptMulticast; |
|
2854 } |
|
2855 } |
|
2856 |
|
2857 /* We can safely update without stopping the chip. */ |
|
2858 tmp = rtl8139_rx_config | rx_mode; |
|
2859 if (tp->rx_config != tmp) { |
|
2860 RTL_W32_F (RxConfig, tmp); |
|
2861 tp->rx_config = tmp; |
|
2862 } |
|
2863 RTL_W32_F (MAR0 + 0, mc_filter[0]); |
|
2864 RTL_W32_F (MAR0 + 4, mc_filter[1]); |
|
2865 } |
|
2866 |
|
2867 static void rtl8139_set_rx_mode (struct net_device *dev) |
|
2868 { |
|
2869 unsigned long flags; |
|
2870 struct rtl8139_private *tp = dev->priv; |
|
2871 |
|
2872 spin_lock_irqsave (&tp->lock, flags); |
|
2873 __set_rx_mode(dev); |
|
2874 spin_unlock_irqrestore (&tp->lock, flags); |
|
2875 } |
|
2876 |
|
2877 #ifdef CONFIG_PM |
|
2878 |
|
2879 static int rtl8139_suspend (struct pci_dev *pdev, u32 state) |
|
2880 { |
|
2881 struct net_device *dev = pci_get_drvdata (pdev); |
|
2882 struct rtl8139_private *tp = dev->priv; |
|
2883 void *ioaddr = tp->mmio_addr; |
|
2884 unsigned long flags; |
|
2885 |
|
2886 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2887 |
|
2888 if (dev == rtl_ecat_dev.dev || !netif_running (dev)) |
|
2889 return 0; |
|
2890 |
|
2891 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2892 |
|
2893 netif_device_detach (dev); |
|
2894 |
|
2895 spin_lock_irqsave (&tp->lock, flags); |
|
2896 |
|
2897 /* Disable interrupts, stop Tx and Rx. */ |
|
2898 RTL_W16 (IntrMask, 0); |
|
2899 RTL_W8 (ChipCmd, 0); |
|
2900 |
|
2901 /* Update the error counts. */ |
|
2902 tp->stats.rx_missed_errors += RTL_R32 (RxMissed); |
|
2903 RTL_W32 (RxMissed, 0); |
|
2904 |
|
2905 spin_unlock_irqrestore (&tp->lock, flags); |
|
2906 return 0; |
|
2907 } |
|
2908 |
|
2909 |
|
2910 static int rtl8139_resume (struct pci_dev *pdev) |
|
2911 { |
|
2912 struct net_device *dev = pci_get_drvdata (pdev); |
|
2913 |
|
2914 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2915 |
|
2916 if (dev == rtl_ecat_dev.dev || !netif_running (dev)) |
|
2917 return 0; |
|
2918 |
|
2919 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2920 |
|
2921 netif_device_attach (dev); |
|
2922 |
|
2923 rtl8139_hw_start (dev); |
|
2924 return 0; |
|
2925 } |
|
2926 |
|
2927 #endif /* CONFIG_PM */ |
|
2928 |
|
2929 |
|
2930 static struct pci_driver rtl8139_pci_driver = { |
|
2931 .name = DRV_NAME, |
|
2932 .id_table = rtl8139_pci_tbl, |
|
2933 .probe = rtl8139_init_one, |
|
2934 .remove = __devexit_p(rtl8139_remove_one), |
|
2935 #ifdef CONFIG_PM |
|
2936 .suspend = rtl8139_suspend, |
|
2937 .resume = rtl8139_resume, |
|
2938 #endif /* CONFIG_PM */ |
|
2939 }; |
|
2940 |
|
2941 |
|
2942 static int rtl8139_init_module (void) |
|
2943 { |
|
2944 /* when we're a module, we always print a version message, |
|
2945 * even if no 8139 board is found. |
|
2946 */ |
|
2947 #ifdef MODULE |
|
2948 EC_DBG (KERN_INFO RTL8139_DRIVER_NAME "\n"); |
|
2949 #endif |
|
2950 |
|
2951 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2952 |
|
2953 EtherCAT_device_init(&rtl_ecat_dev); |
|
2954 |
|
2955 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2956 |
|
2957 return pci_module_init (&rtl8139_pci_driver); |
|
2958 } |
|
2959 |
|
2960 |
|
2961 static void rtl8139_cleanup_module (void) |
|
2962 { |
|
2963 pci_unregister_driver (&rtl8139_pci_driver); |
|
2964 |
|
2965 /* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ |
|
2966 |
|
2967 EtherCAT_device_clear(&rtl_ecat_dev); |
|
2968 |
|
2969 /* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ |
|
2970 } |
|
2971 |
|
2972 |
|
2973 module_init(rtl8139_init_module); |
|
2974 module_exit(rtl8139_cleanup_module); |
|