aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/ixp425-eth/ixp425-eth-1.2/ixp400linuxethernetdriver-1_2-kernel26_hr_20050929.patch
blob: e4ef3f96c8d96591658884ff399a5dceced12fbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
diff -Naur ixp425_eth.orig/Makefile ixp425_eth/Makefile
--- ixp425_eth.orig/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ ixp425_eth/Makefile	2005-09-28 19:03:50.000000000 +0200
@@ -0,0 +1,36 @@
+obj-m := ixp425_eth.o
+
+PWD         := $(shell pwd)
+
+LINUX_SRC := $($(IX_TARGET)_KERNEL_DIR)
+
+OSAL_DIR := $(IX_XSCALE_SW)/../ixp_osal
+CFLAGS_ixp425_eth.o = -DWall \
+          -I$(IX_XSCALE_SW)/src/include \
+          -I$(OSAL_DIR)/ \
+          -I$(OSAL_DIR)/os/linux/include/ \
+          -I$(OSAL_DIR)/os/linux/include/modules/ \
+          -I$(OSAL_DIR)/os/linux/include/modules/ioMem/ \
+          -I$(OSAL_DIR)/os/linux/include/modules/core/ \
+          -I$(OSAL_DIR)/os/linux/include/modules/bufferMgt/ \
+          -I$(OSAL_DIR)/os/linux/include/core/  \
+          -I$(OSAL_DIR)/os/linux/include/platforms/ \
+          -I$(OSAL_DIR)/os/linux/include/platforms/ixp400/ \
+          -I$(OSAL_DIR)/os/linux/include/core/ \
+          -I$(OSAL_DIR)/include/ \
+          -I$(OSAL_DIR)/include/modules/ \
+          -I$(OSAL_DIR)/include/modules/bufferMgt/ \
+          -I$(OSAL_DIR)/include/modules/ioMem/ \
+          -I$(OSAL_DIR)/include/modules/core/ \
+          -I$(OSAL_DIR)/include/platforms/ \
+          -I$(OSAL_DIR)/include/platforms/ixp400/ \
+
+#	-DDEBUG 
+
+# -DDEBUG_DUMP
+
+default:
+	$(MAKE) ARCH=arm CROSS_COMPILE=$(LINUX_CROSS_COMPILE) V=1 -C $(LINUX_SRC) SUBDIRS=$(PWD) modules
+
+clean:
+	rm -f ixp425_eth.ko
diff -Naur ixp425_eth.orig/Readme-Kernel-2_6-Patch.txt ixp425_eth/Readme-Kernel-2_6-Patch.txt
--- ixp425_eth.orig/Readme-Kernel-2_6-Patch.txt	1970-01-01 01:00:00.000000000 +0100
+++ ixp425_eth/Readme-Kernel-2_6-Patch.txt	2005-09-28 20:26:19.000000000 +0200
@@ -0,0 +1,33 @@
+This file describes a patch to use version 1.2 of the ethernet driver
+for Intel Ixp4XX with Linux 2.6 kernels.
+
+Authors/History
+---------------
+
+This patch is based on the nslu2-linux project's patches for version
+1.1 of the same driver. The changes were adapted to version 1.2 by
+Hannes Reich & Cian Masterson.
+
+Status
+------
+
+This code has been tested on a Linksys NSLU2. It works in big-endian
+mode, performance seems around 10% faster than 1.4.
+
+The code does not work in little-endian mode. It appears as though the
+hardware is initialised correctly, but packet receive / transmit done
+callbacks are never called.
+
+The driver has not been tested in "polling mode".
+
+Licence Information
+-------------------
+
+This patch is licenced under the same terms as the original Ethernet
+driver (GPL v2).
+
+References
+----------
+
+The nslu2-linux project's patch for version 1.1 of the driver is at
+http://nslu.sourceforge.net/downloads/ixp425_eth.c.patch
\ No newline at end of file
diff -Naur ixp425_eth.orig/ixp425_eth.c ixp425_eth/ixp425_eth.c
--- ixp425_eth.orig/ixp425_eth.c	2005-08-26 21:44:19.000000000 +0200
+++ ixp425_eth/ixp425_eth.c	2005-09-02 00:01:59.000000000 +0200
@@ -47,21 +47,18 @@
  */
 #include <linux/config.h>
 #include <linux/module.h>
-#include <linux/kernel.h>
+#include <linux/moduleparam.h>
 #include <linux/init.h>
+#include <linux/kernel.h>
 #include <linux/ioport.h>
+#include <linux/device.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
-#include <linux/delay.h>
 #include <linux/mii.h>
-#include <linux/socket.h>
-#include <linux/cache.h>
 #include <asm/io.h>
 #include <asm/errno.h>
 #include <net/pkt_sched.h>
 #include <net/ip.h>
-#include <linux/sysctl.h>
-#include <linux/unistd.h>
 
 /*
  * Intel IXP400 Software specific header files
@@ -93,8 +90,8 @@
 MODULE_DESCRIPTION("IXP425 NPE Ethernet driver");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Intel Corporation");
-#define MODULE_NAME "ixp425_eth"
-#define MODULE_VERSION "1.2"
+#define DRV_NAME "ixp425_eth"
+#define DRV_VERSION "1.2A"
 
 /* Module parameters */
 static int npe_learning = 1; /* default : NPE learning & filtering enable */
@@ -122,26 +119,23 @@
  */
 static int netdev_max_backlog = 290;
 
-MODULE_PARM(npe_learning, "i");
+module_param(npe_learning, int, 4);
 MODULE_PARM_DESC(npe_learning, "If non-zero, NPE MAC Address Learning & Filtering feature will be enabled");
-MODULE_PARM(log_level, "i");
+module_param(log_level, int, 6);
 MODULE_PARM_DESC(log_level, "Set log level: 0 - None, 1 - Verbose, 2 - Debug");
-MODULE_PARM(no_csr_init, "i");
+module_param(no_csr_init, int, 0);
 MODULE_PARM_DESC(no_csr_init, "If non-zero, do not initialise Intel IXP400 Software Release core components");
-MODULE_PARM(no_phy_scan, "i");
+module_param(no_phy_scan, int, 0);
 MODULE_PARM_DESC(no_phy_scan, "If non-zero, use hard-coded phy addresses");
-MODULE_PARM(datapath_poll, "i");
+module_param(datapath_poll, int, 0);
 MODULE_PARM_DESC(datapath_poll, "If non-zero, use polling method for datapath instead of interrupts");
-MODULE_PARM(phy_reset, "i");
+module_param(phy_reset, int, 0);
 MODULE_PARM_DESC(phy_reset, "If non-zero, reset the phys");
-MODULE_PARM(netdev_max_backlog, "i");
+module_param(netdev_max_backlog, int, 4);
 MODULE_PARM_DESC(netdev_max_backlog, "Should be set to the value of /proc/sys/net/core/netdev_max_backlog (perf affecting)");
-MODULE_PARM(dev_max_count, "i");
+module_param(dev_max_count, int, 4);
 MODULE_PARM_DESC(dev_max_count, "Number of devices to initialize");
 
-/* devices will be called ixp0 and ixp1 */
-#define DEVICE_NAME "ixp"
-
 /* boolean values for PHY link speed, duplex, and autonegotiation */
 #define PHY_SPEED_10    0
 #define PHY_SPEED_100   1
@@ -257,36 +251,35 @@
  */
 /* Print kernel error */
 #define P_ERROR(args...) \
-    printk(KERN_ERR MODULE_NAME ": " args)
+    printk(KERN_ERR DRV_NAME ": " args)
 /* Print kernel warning */
 #define P_WARN(args...) \
-    printk(KERN_WARNING MODULE_NAME ": " args)
+    printk(KERN_WARNING DRV_NAME ": " args)
 /* Print kernel notice */
 #define P_NOTICE(args...) \
-    printk(KERN_NOTICE MODULE_NAME ": " args)
+    printk(KERN_NOTICE DRV_NAME ": " args)
 /* Print kernel info */
 #define P_INFO(args...) \
-    printk(KERN_INFO MODULE_NAME ": " args)
+    printk(KERN_INFO DRV_NAME ": " args)
 /* Print verbose message. Enabled/disabled by 'log_level' param */
 #define P_VERBOSE(args...) \
-    if (log_level >= 1) printk(MODULE_NAME ": " args)
+    if (log_level >= 1) printk(DRV_NAME ": " args)
 /* Print debug message. Enabled/disabled by 'log_level' param  */
 #define P_DEBUG(args...) \
     if (log_level >= 2) { \
-        printk("%s: %s()\n", MODULE_NAME, __FUNCTION__); \
+        printk("%s: %s()\n", DRV_NAME, __FUNCTION__); \
         printk(args); }
 
 #ifdef DEBUG
 /* Print trace message */
 #define TRACE \
-    if (log_level >= 2) printk("%s: %s(): line %d\n", MODULE_NAME, __FUNCTION__, __LINE__)
+    if (log_level >= 2) printk("%s: %s(): line %d\n", DRV_NAME, __FUNCTION__, __LINE__)
 #else
 /* no trace */
 #define TRACE 
 #endif
 
 /* extern Linux kernel data */
-extern struct softnet_data softnet_data[]; /* used to get the current queue level */
 extern unsigned long loops_per_jiffy; /* used to calculate CPU clock speed */
 
 /* internal Ethernet Access layer polling entry points */
@@ -295,10 +288,12 @@
 extern void 
 ixEthTxFrameDoneQMCallback(IxQMgrQId qId, IxQMgrCallbackId callbackId);
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void ixp425eth_poll_controller(struct net_device *dev);
+#endif
+
 /* Private device data */
 typedef struct {
-    spinlock_t lock;  /* multicast management lock */
-    
     unsigned int msdu_size;
     unsigned int replenish_size;
     unsigned int pkt_size;
@@ -338,17 +333,11 @@
     /* TX MBUF pool */
     IX_OSAL_MBUF_POOL *tx_pool;
 
-    /* id of thread for the link duplex monitoring */
-    int maintenanceCheckThreadId;
-
-    /* mutex locked by thread, until the thread exits */
-    struct semaphore *maintenanceCheckThreadComplete;
-
-    /* Used to stop the kernel thread for link monitoring. */
-    volatile BOOL maintenanceCheckStopped;
+    /* link duplex monitoring */
+    struct work_struct mii_job;
 
-    /* used for tx timeout */
-    struct tq_struct tq_timeout;
+    /* handle tx timeouts */
+    struct work_struct tx_timeout_job;
 
     /* used to control the message output */
     UINT32 devFlags;
@@ -370,11 +359,13 @@
  */
 
 /* values used inside the irq */
+#ifdef IXP425ETH_POLLING_MODE
 static unsigned long timer_countup_ticks;
+static unsigned int rx_queue_id = IX_QMGR_MAX_NUM_QUEUES;
+#endif
 static IxQMgrDispatcherFuncPtr dispatcherFunc;
 static struct timeval  irq_stamp;  /* time of interrupt */
 static unsigned int maxbacklog = RX_MBUF_POOL_SIZE;
-static unsigned int rx_queue_id = IX_QMGR_MAX_NUM_QUEUES;
 
 /* Implements a software queue for skbufs 
  * This queue is written in the tx done process and 
@@ -523,13 +514,18 @@
 #endif
 };
 
+/*
+ * Shared workqueue thread for device maintenance tasks.
+ */
+static struct workqueue_struct *npe_eth_workqueue;
+
 /* Mutex lock used to coordinate access to IxEthAcc functions
  * which manipulate the MII registers on the PHYs
  */
-static struct semaphore *miiAccessMutex;
+static DECLARE_MUTEX(miiAccessMutex);
 
 /* mutex locked when maintenance is being performed */
-static struct semaphore *maintenance_mutex;
+static DECLARE_MUTEX(maintenance_mutex);
 
 /* Flags which is set when the corresponding IRQ is running,
  */
@@ -592,7 +588,7 @@
     printk(">> mbuf:\n");
     hex_dump(mbuf, sizeof(*mbuf));
     printk(">> m_data:\n");
-    hex_dump(__va(IX_OSAL_MBUF_MDATA(mbuf)), IX_OSAL_MBUF_MLEN(mbuf));
+    hex_dump(IX_OSAL_MBUF_MDATA(mbuf), IX_OSAL_MBUF_MLEN(mbuf));
     printk("\n-------------------------\n");
 }
 
@@ -791,6 +787,8 @@
 #ifdef CONFIG_NETFILTER
 #if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
 /* We need to free the memory attached to the nf_bridge pointer to avoid a memory leak */
+	 nf_bridge_put(skb->nf_bridge);
+        skb->nf_bridge = NULL;
 
 #endif
 #endif /* CONFIG_NETFILTER */
@@ -1041,135 +1039,63 @@
  * KERNEL THREADS
  */
 
-/* flush the pending signals for a thread and 
- * check if a thread is killed  (e.g. system shutdown)
- */
-static BOOL dev_thread_signal_killed(void)
-{
-    int killed = FALSE;
-    if (signal_pending (current))
-    {
-	spin_lock_irq(&current->sigmask_lock);
-	if (sigismember(&(current->pending.signal), SIGKILL)
-	    || sigismember(&(current->pending.signal), SIGTERM))
-	{
-	    /* someone kills this thread */
-	    killed = TRUE;
-	}
-	flush_signals(current);
-	spin_unlock_irq(&current->sigmask_lock);
-    }
-    return killed;
-}
-
-/* This timer will check the PHY for the link duplex and
+/* This workqueue job will check the PHY for the link duplex and
  * update the MAC accordingly. It also executes some buffer
  * maintenance to release mbuf in excess or replenish after
  * a severe starvation
  *
  * This function loops and wake up every 3 seconds.
  */
-static int dev_media_check_thread (void* arg)
+static void dev_media_check_work (void* arg)
 {
     struct net_device *dev = (struct net_device *) arg;
     priv_data_t *priv = dev->priv;
-    int linkUp;
-    int speed100;
-    int fullDuplex = -1; /* unknown duplex mode */
-    int newDuplex;
-    int autonegotiate;
-    unsigned phyNum = phyAddresses[priv->port_id];
-    int res;
 
-    TRACE;
 
-    /* Lock the mutex for this thread.
-       This mutex can be used to wait until the thread exits
-    */
-    down (priv->maintenanceCheckThreadComplete);
-
-    daemonize();
-    reparent_to_init();
-    spin_lock_irq(&current->sigmask_lock);
-    sigemptyset(&current->blocked);
-    recalc_sigpending(current);
-    spin_unlock_irq(&current->sigmask_lock);
-    
-    snprintf(current->comm, sizeof(current->comm), "ixp425 %s", dev->name);
+    /*
+     * Determine the link status
+     */
 
-    TRACE;
-    
-    while (1)
+    if (default_phy_cfg[priv->port_id].linkMonitor)
     {
-	/* We may have been woken up by a signal. If so, we need to
-	 * flush it out and check for thread termination 
-	 */ 
-	if (dev_thread_signal_killed())
-	{
-	    priv->maintenanceCheckStopped = TRUE;
-	}
-
-	/* If the interface is down, or the thread is killed,
-	 * or gracefully aborted, we need to exit this loop
-	 */
-	if (priv->maintenanceCheckStopped)
-	{
-	    break;
-	}
-	
-	/*
-	 * Determine the link status
-	 */
+	int linkUp;
+	int speed100;
+	int fullDuplex = -1; /* unknown duplex mode */
+	int newDuplex;
+	int autonegotiate;
+	unsigned phyNum = phyAddresses[priv->port_id];
+	int res;
 
 	TRACE;
 
-	if (default_phy_cfg[priv->port_id].linkMonitor)
-	{
-	    /* lock the MII register access mutex */
-	    down(miiAccessMutex);
+	/* lock the MII register access mutex */
+	down(&miiAccessMutex);
 	    
-	    res = ixEthMiiLinkStatus(phyNum,
-				     &linkUp,
-				     &speed100,
-				     &newDuplex, 
-				     &autonegotiate);
-	    /* release the MII register access mutex */
-	    up(miiAccessMutex);
-
-	    /* We may have been woken up by a signal. If so, we need to
-	     * flush it out and check for thread termination 
-	     */ 
-	    if (dev_thread_signal_killed())
-	    {
-		priv->maintenanceCheckStopped = TRUE;
-	    }
+	res = ixEthMiiLinkStatus(phyNum,
+				 &linkUp,
+				 &speed100,
+				 &newDuplex, 
+				 &autonegotiate);
+	/* release the MII register access mutex */
+	up(&miiAccessMutex);
+
+	if (res != IX_ETH_ACC_SUCCESS)
+	{
+	    P_WARN("ixEthMiiLinkStatus failed on PHY%d.\n"
+		   "\tCan't determine\nthe auto negotiated parameters. "
+		   "Using default values.\n",
+		   phyNum); 
+            /* this shouldn't happen. exit the thread if it does */
+            goto out;
+	}
 	    
-	    /* If the interface is down, or the thread is killed,
-	     * or gracefully aborted, we need to exit this loop
-	     */
-	    if (priv->maintenanceCheckStopped)
-	    {
-		break;
-	    }
-	
-	    if (res != IX_ETH_ACC_SUCCESS)
+	if (linkUp)
+	{
+	    if (! netif_carrier_ok(dev))
 	    {
-		P_WARN("ixEthMiiLinkStatus failed on PHY%d.\n"
-		       "\tCan't determine\nthe auto negotiated parameters. "
-		       "Using default values.\n",
-		       phyNum); 
-		/* something is bad, gracefully stops the loop */
-		priv->maintenanceCheckStopped = TRUE;
-		break;
+		/* inform the kernel of a change in link state */
+		netif_carrier_on(dev);
 	    }
-	    
-	    if (linkUp)
-	    {
-		if (! netif_carrier_ok(dev))
-		{
-		    /* inform the kernel of a change in link state */
-		    netif_carrier_on(dev);
-		}
 
 		/*
 		 * Update the MAC mode to match the PHY mode if 
@@ -1218,18 +1144,14 @@
 	 * long
 	 */
 	dev_buff_maintenance(dev);
-    
-	/* Now sleep for 3 seconds */
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout(MEDIA_CHECK_INTERVAL);
-    } /* while (1) ... */
-
-    /* free the mutex for this thread. */
-    up (priv->maintenanceCheckThreadComplete);
-
-    return 0;
+	/* reschedule to run in 3 seconds */
+	queue_delayed_work(npe_eth_workqueue, &priv->mii_job, 3*HZ);
+out:
+	return;
 }
 
+#ifdef IXP425ETH_POLLING_MODE
+
 /*
  * TIMERS
  *
@@ -1263,12 +1185,14 @@
     restore_flags(flags);
 }
 
+#endif /* IXP425ETH_POLLING_MODE */
+
 /* Internal ISR : run a few thousand times per second and calls 
  * the queue manager dispatcher entry point.
  */
-static void dev_qmgr_os_isr(int irg, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dev_qmgr_os_isr(int irg, void *dev_id, struct pt_regs *regs)
 {
-    int qlevel = softnet_data[0].input_pkt_queue.qlen;
+    int qlevel = __get_cpu_var(softnet_data).input_pkt_queue.qlen;
 
     /* at the interrupt entry, the queue contains already a few entries 
      * so it is safe to decrease the number of entries
@@ -1302,14 +1226,17 @@
 
     /* call the queue manager entry point */
     dispatcherFunc(IX_QMGR_QUELOW_GROUP);
+    return IRQ_HANDLED;
 }
 
+#ifdef IXP425ETH_POLLING_MODE
+
 /* Internal ISR : run a few thousand times per second and calls 
  * the ethernet entry point.
  */
-static void dev_poll_os_isr(int irg, void *dev_id, struct pt_regs *regs)
+static irqreturn_t dev_poll_os_isr(int irg, void *dev_id, struct pt_regs *regs)
 {
-    int qlevel = softnet_data[0].input_pkt_queue.qlen;
+    int qlevel = __get_cpu_var(softnet_data).input_pkt_queue.qlen;
     dev_pmu_timer_restart(); /* set up the timer for the next interrupt */
 
     /* at the interrupt entry, the queue contains already a few entries 
@@ -1346,6 +1273,7 @@
     ixEthRxFrameQMCallback(rx_queue_id,0);
     ixEthTxFrameDoneQMCallback(0,0);
    
+    return IRQ_HANDLED;
 }
 
 /* initialize the PMU timer */
@@ -1400,46 +1328,33 @@
     restore_flags(flags);
 }
 
-/* This timer will call ixEthDBDatabaseMaintenance every
- * IX_ETH_DB_MAINTENANCE_TIME jiffies
- */
-static void maintenance_timer_cb(unsigned long data);
-
-static struct timer_list maintenance_timer = {
-    function:&maintenance_timer_cb
-};
+#endif /* IXP425ETH_POLLING_MODE */
 
-static void maintenance_timer_task(void *data);
 
-/* task spawned by timer interrupt for EthDB maintenance */
-static struct tq_struct tq_maintenance = {
-  routine:maintenance_timer_task
-};
+static void db_maintenance_code(void *data);
+static DECLARE_WORK(db_maintenance_job, db_maintenance_code, NULL);
 
-static void maintenance_timer_set(void)
+static inline
+void schedule_db_maintenance(void)
 {
-    maintenance_timer.expires = jiffies + DB_MAINTENANCE_TIME;
-    add_timer(&maintenance_timer);
+    queue_delayed_work(npe_eth_workqueue, &db_maintenance_job,
+                       DB_MAINTENANCE_TIME);
 }
 
-static void maintenance_timer_clear(void)
+static inline
+void cancel_db_maintenance(void)
 {
-    del_timer_sync(&maintenance_timer);
+    cancel_delayed_work(&db_maintenance_job);
 }
 
-static void maintenance_timer_task(void *data)
+static void db_maintenance_code(void *data)
 {
-    down(maintenance_mutex);
+    down(&maintenance_mutex);
     ixEthDBDatabaseMaintenance();
-    up(maintenance_mutex);
+    up(&maintenance_mutex);
+    schedule_db_maintenance();
 }
 
-static void maintenance_timer_cb(unsigned long data)
-{
-    schedule_task(&tq_maintenance);
-
-    maintenance_timer_set();
-}
 
 /*
  *  DATAPLANE
@@ -1553,7 +1468,7 @@
 	 * and its constants are taken from the eth_type_trans()
 	 * function.
 	 */
-	struct ethhdr *eth = skb->mac.ethernet;
+	struct ethhdr *eth = eth_hdr(skb);
 	unsigned short hproto = ntohs(eth->h_proto);
 	
 	if (hproto >= 1536)
@@ -1595,7 +1510,7 @@
 	     * mode is set This costs
 	     * a lookup inside the packet payload.
 	     */
-	    struct ethhdr *eth = skb->mac.ethernet;
+	    struct ethhdr *eth = eth_hdr(skb);
 	    unsigned char *hdest = eth->h_dest;
 	    
 	    if (memcmp(hdest, dev->dev_addr, ETH_ALEN)!=0)
@@ -1654,7 +1569,7 @@
     dev = (struct net_device *)callbackTag;
     priv = dev->priv;
 
-    qlevel = softnet_data[0].input_pkt_queue.qlen;
+    qlevel = __get_cpu_var(softnet_data).input_pkt_queue.qlen;
     /* check if the system accepts more traffic and
      * against chained mbufs 
      */
@@ -1754,10 +1669,6 @@
 
     TRACE;
 
-    /* if called from irq handler, lock already acquired */
-    if (!in_irq())
-	spin_lock_irq(&priv->lock);
-
     /* clear multicast addresses that were set the last time (if exist) */
     ixEthAccPortMulticastAddressLeaveAll (priv->port_id);
 
@@ -1838,10 +1749,10 @@
     }
 
 Exit:
-    if (!in_irq())
-	spin_unlock_irq(&priv->lock);
+    return;
 }
 
+#ifdef IXP425ETH_POLLING_MODE
 /* The QMgr dispatch entry point can be called from the 
  * IX_OSAL_IXP400_QM1_IRQ_LVL irq (which will trigger
  * an interrupt for every packet) or a timer (which will
@@ -1893,8 +1804,8 @@
     /* poll the datapath from a timer IRQ */
     if (request_irq(IX_OSAL_IXP400_XSCALE_PMU_IRQ_LVL,
                     dev_poll_os_isr,
-                    SA_SHIRQ,
-                    MODULE_NAME,
+                    SA_SHIRQ | SA_SAMPLE_RANDOM,
+                    DRV_NAME,
                     (void *)IRQ_ANY_PARAMETER))
     {
         P_ERROR("Failed to reassign irq to PMU timer interrupt!\n");
@@ -1918,6 +1829,8 @@
   return 0;
 }
 
+#endif /* IXP425ETH_POLLING_MODE */
+
 /* Enable the MAC port.
  * Called on do_dev_open, dev_tx_timeout and mtu size changes
  */
@@ -1946,23 +1859,6 @@
 	return convert_error_ethAcc(res);	
     }
 
-    /* restart the link-monitoring thread if necessary */
-    if (priv->maintenanceCheckStopped)
-    {
-	/* Starts the driver monitoring thread, if configured */
-	priv->maintenanceCheckStopped = FALSE;
-	
-	priv->maintenanceCheckThreadId = 
-	    kernel_thread(dev_media_check_thread,
-			  (void *) dev,
-			  CLONE_FS | CLONE_FILES);
-	if (priv->maintenanceCheckThreadId < 0)
-	{
-	    P_ERROR("%s: Failed to start thread for media checks\n", dev->name);
-	    priv->maintenanceCheckStopped = TRUE;
-	}
-    }
-
     /* force replenish if necessary */
     dev_rx_buff_prealloc(priv);
 
@@ -2019,38 +1915,11 @@
 static void port_disable(struct net_device *dev)
 {
     priv_data_t *priv = dev->priv;
-    int res;
     IX_STATUS status;
 
     P_DEBUG("port_disable(%s)\n", dev->name);
 
-    if (!netif_queue_stopped(dev))
-    {
-        dev->trans_start = jiffies;
-        netif_stop_queue(dev);
-    }
-
-    if (priv->maintenanceCheckStopped)
-    {
-	/* thread is not running */
-    }
-    else
-    {
-	/* thread is running */
-	priv->maintenanceCheckStopped = TRUE;
-	/* Wake up the media-check thread with a signal.
-	   It will check the 'running' flag and exit */
-	if ((res = kill_proc (priv->maintenanceCheckThreadId, SIGKILL, 1)))
-	{
-	    P_ERROR("%s: unable to signal thread\n", dev->name);
-	}
-	else
-	{
-	    /* wait for the thread to exit. */
-	    down (priv->maintenanceCheckThreadComplete);
-	    up (priv->maintenanceCheckThreadComplete);
-	}
-    }
+    netif_stop_queue(dev);
 
     /* Set callbacks when port is disabled */
     ixEthAccPortTxDoneCallbackRegister(priv->port_id, 
@@ -2100,7 +1969,6 @@
             ixEthAccPortTxDoneCallbackRegister(priv->port_id, 
                                                tx_done_queue_stopped_cb,
                                                (UINT32)dev);
-            dev->trans_start = jiffies;
             netif_stop_queue (dev);
         }
 	return 0;
@@ -2143,12 +2011,19 @@
     int res;
 
     /* prevent the maintenance task from running while bringing up port */
-    down(maintenance_mutex);
+    down(&maintenance_mutex);
 
     /* bring up the port */
     res = port_enable(dev);
 
-    up(maintenance_mutex);
+    up(&maintenance_mutex);
+
+    if(!res)
+    {
+	/* schedule mii job to run in 3 seconds */
+	priv_data_t *priv = dev->priv;	
+	queue_delayed_work(npe_eth_workqueue, &priv->mii_job, 3*HZ);
+    }
 
     return res;
 }
@@ -2158,28 +2033,34 @@
  */
 static int do_dev_stop(struct net_device *dev)
 {
+    priv_data_t *priv = dev->priv;
+
     TRACE;
 
+    cancel_delayed_work(&priv->mii_job);
+    cancel_delayed_work(&priv->tx_timeout_job);
+    netif_stop_queue(dev);
+    netif_carrier_off(dev);
     /* prevent the maintenance task from running while bringing up port */
-    down(maintenance_mutex);
+    down(&maintenance_mutex);
 
     /* bring the port down */
     port_disable(dev);
 
-    up(maintenance_mutex);
+    up(&maintenance_mutex);
 
     return 0;
 }
 
 static void
-dev_tx_timeout_task(void *dev_id)
+dev_tx_timeout_work(void *arg)
 {
-    struct net_device *dev = (struct net_device *)dev_id;
+    struct net_device *dev = (struct net_device *)arg;
     priv_data_t *priv = dev->priv;
 
     P_WARN("%s: Tx Timeout for port %d\n", dev->name, priv->port_id);
 
-    down(maintenance_mutex);
+    down(&maintenance_mutex);
     port_disable(dev);
 
     /* Note to user: Consider performing other reset operations here
@@ -2202,7 +2083,7 @@
 	port_enable(dev);
     }
 
-    up(maintenance_mutex);
+    up(&maintenance_mutex);
 }
 
 
@@ -2212,8 +2093,7 @@
     priv_data_t *priv = dev->priv;
 
     TRACE;
-    schedule_task(&priv->tq_timeout);
-    
+    queue_work(npe_eth_workqueue, &priv->tx_timeout_job);
 }
 
 /* update the maximum msdu value for this device */
@@ -2270,14 +2150,14 @@
     }
 
     /* safer to stop maintenance task while bringing port down and up */
-    down(maintenance_mutex);
+    down(&maintenance_mutex);
 
     if (ixEthDBFilteringPortMaximumFrameSizeSet(priv->port_id, 
 						new_msdu_size))
     {
 	P_ERROR("%s: ixEthDBFilteringPortMaximumFrameSizeSet failed for port %d\n",
 		dev->name, priv->port_id);
-	up(maintenance_mutex);
+	up(&maintenance_mutex);
 
 	return -1;
     }
@@ -2287,7 +2167,7 @@
     /* update the driver mtu value */
     dev->mtu = new_mtu_size;
 
-    up(maintenance_mutex);
+    up(&maintenance_mutex);
 
     return 0;
 }
@@ -2316,27 +2196,27 @@
         /* Read MII PHY register */
 	case SIOCGMIIREG:		
 	case SIOCDEVPRIVATE+1:
-	    down (miiAccessMutex);     /* lock the MII register access mutex */
+	    down (&miiAccessMutex);     /* lock the MII register access mutex */
 	    if ((res = ixEthAccMiiReadRtn (data->phy_id, data->reg_num, &data->val_out)))
 	    {
 		P_ERROR("Error reading MII reg %d on phy %d\n",
 		       data->reg_num, data->phy_id);
 		res = -1;
 	    }
-	    up (miiAccessMutex);	/* release the MII register access mutex */
+	    up (&miiAccessMutex);	/* release the MII register access mutex */
 	    return res;
 
 	/* Write MII PHY register */
 	case SIOCSMIIREG:
 	case SIOCDEVPRIVATE+2:
-	    down (miiAccessMutex);     /* lock the MII register access mutex */
+	    down (&miiAccessMutex);     /* lock the MII register access mutex */
 	    if ((res = ixEthAccMiiWriteRtn (data->phy_id, data->reg_num, data->val_in)))
 	    {
 		P_ERROR("Error writing MII reg %d on phy %d\n",
                         data->reg_num, data->phy_id);
 		res = -1;
 	    }
-	    up (miiAccessMutex);	/* release the MII register access mutex */
+	    up (&miiAccessMutex);	/* release the MII register access mutex */
 	    return res;
 
 	/* set the MTU size */
@@ -2373,7 +2253,7 @@
 
     TRACE;
 
-    invalidate_dcache_range((unsigned int)&ethStats, sizeof(ethStats));
+    IX_ACC_DATA_CACHE_INVALIDATE(&ethStats, sizeof(ethStats));
     if ((res = ixEthAccMibIIStatsGetClear(priv->port_id, &ethStats)))
     {
 	P_ERROR("%s: ixEthAccMibIIStatsGet failed for port %d, res = %d\n",
@@ -2462,8 +2342,8 @@
      */
     if (request_irq(IX_OSAL_IXP400_QM1_IRQ_LVL,
                     dev_qmgr_os_isr,
-                    SA_SHIRQ,
-                    MODULE_NAME,
+                    SA_SHIRQ | SA_SAMPLE_RANDOM,
+                    DRV_NAME,
                     (void *)IRQ_ANY_PARAMETER))
     {
         P_ERROR("Failed to request_irq to Queue Manager interrupt!\n");
@@ -2582,15 +2462,6 @@
     BOOL physcan[IXP425_ETH_ACC_MII_MAX_ADDR];
     int i, phy_found, num_phys_to_set, dev_count;
 
-    /* initialise the MII register access mutex */
-    miiAccessMutex = (struct semaphore *) kmalloc(sizeof(struct semaphore), GFP_KERNEL);
-    if (!miiAccessMutex)
-	return -ENOMEM;
-
-    init_MUTEX(miiAccessMutex);
-
-    TRACE;
-
     /* detect the PHYs (ethMii requires the PHYs to be detected) 
      * and provides a maximum number of PHYs to search for.
      */
@@ -2680,8 +2551,8 @@
 	if (port_id == IX_ETH_PORT_1) npe_id = "B";
 	if (port_id == IX_ETH_PORT_2) npe_id = "C";
 
-	P_INFO("%s%d is using NPE%s and the PHY at address %d\n",
-	       DEVICE_NAME, dev_count, npe_id, phyAddresses[port_id]);
+	P_INFO("npe%d is using NPE%s and the PHY at address %d\n",
+	       dev_count, npe_id, phyAddresses[port_id]);
 
 	/* Set the MAC to the same duplex mode as the phy */
 	ixEthAccPortDuplexModeSet(port_id,
@@ -2693,12 +2564,11 @@
 }
 
 /* set port MAC addr and update the dev struct if successfull */
-int dev_set_mac_address(struct net_device *dev, void *addr)
+int dev_set_mac_address(struct net_device *dev, struct sockaddr *saddr)
 {
     int res;
     priv_data_t *priv = dev->priv;
     IxEthAccMacAddr npeMacAddr;
-    struct sockaddr *saddr = (struct sockaddr *)addr;
 
     /* Get MAC addr from parameter */
     memcpy(&npeMacAddr.macAddress,
@@ -2758,7 +2628,7 @@
 
 static struct Qdisc_ops dev_qdisc_ops =
 {
-	NULL, NULL, "ixp425_eth", 0,
+	NULL, NULL, DRV_NAME, 0,
 	dev_qdisc_no_enqueue, 
 	dev_qdisc_no_dequeue,
 	dev_qdisc_no_enqueue, 
@@ -2771,35 +2641,13 @@
 /* Initialize device structs.
  * Resource allocation is deffered until do_dev_open
  */
-static int __devinit dev_eth_probe(struct net_device *dev)
+static int __devinit dev_eth_probe(struct device *dev)
 {
-    static int found_devices = 0;
-    priv_data_t *priv;
-
-    TRACE;
-
-    /* there is a limited number of devices */
-    if (found_devices >= dev_max_count) /* module parameter */
-	return -ENODEV;
-
-    SET_MODULE_OWNER(dev);
-
-    /* set device name */
-    strcpy(dev->name, found_devices ? DEVICE_NAME "1" : DEVICE_NAME "0");
-
-    /* allocate and initialize priv struct */
-    priv = dev->priv = kmalloc(sizeof(priv_data_t), GFP_KERNEL);
-    if (dev->priv == NULL)
-	return -ENOMEM;
-
-    memset(dev->priv, 0, sizeof(priv_data_t));
-
-    TRACE;
-
-    /* set the mapping between port ID and devices 
-     * 
-     */
-    priv->port_id  = default_portId[found_devices];
+    int res = -ENOMEM;
+    struct platform_device *pdev = to_platform_device(dev);
+    struct net_device *ndev = dev_get_drvdata(dev);
+    priv_data_t *priv = (priv_data_t*)ndev->priv;
+    priv->port_id  = pdev->id;
 
     TRACE;
 
@@ -2809,9 +2657,8 @@
     if(priv->rx_pool == NULL)
     {
 	P_ERROR("%s: Buffer RX Pool init failed on port %d\n",
-		dev->name, priv->port_id);
-	kfree(dev->priv);
-	return -ENOMEM;
+		ndev->name, priv->port_id);
+	goto out;
     }
 
     TRACE;
@@ -2822,45 +2669,38 @@
     if(priv->tx_pool == NULL)
     {
 	P_ERROR("%s: Buffer TX Pool init failed on port %d\n",
-		dev->name, priv->port_id);
-	kfree(dev->priv);
-	return -ENOMEM;
+		ndev->name, priv->port_id);
+	goto out;
     }
 
-     TRACE;
+    TRACE;
 
-   /* initialise the MII register access mutex */
-    priv->maintenanceCheckThreadComplete = (struct semaphore *)
-	kmalloc(sizeof(struct semaphore), GFP_KERNEL);
-    if (!priv->maintenanceCheckThreadComplete)
-    {
-	kfree(dev->priv);
-	return -ENOMEM;
-    }
-    priv->lock = SPIN_LOCK_UNLOCKED;
-    init_MUTEX(priv->maintenanceCheckThreadComplete);
-    priv->maintenanceCheckStopped = TRUE;
-
-    /* initialize ethernet device (default handlers) */
-    ether_setup(dev);
+    /* initialise the MII and tx timeout jobs */
+    INIT_WORK(&priv->mii_job, dev_media_check_work, ndev);
+    INIT_WORK(&priv->tx_timeout_job, dev_tx_timeout_work, ndev);
 
     TRACE;
 
-     /* fill in dev struct callbacks with customized handlers */
-    dev->open = do_dev_open;
-    dev->stop = do_dev_stop;
+    /* initialize ethernet device (default handlers) */
+    ether_setup(ndev);
 
-    dev->hard_start_xmit = dev_hard_start_xmit;
+     /* fill in dev struct callbacks with customized handlers */
+    ndev->open = do_dev_open;
+    ndev->stop = do_dev_stop;
 
-    dev->watchdog_timeo = DEV_WATCHDOG_TIMEO;
-    dev->tx_timeout = dev_tx_timeout;
-    dev->change_mtu = dev_change_mtu;
-    dev->do_ioctl = do_dev_ioctl;
-    dev->get_stats = dev_get_stats;
-    dev->set_multicast_list = dev_set_multicast_list;
-    dev->flags |= IFF_MULTICAST;
+    ndev->hard_start_xmit = dev_hard_start_xmit;
 
-    dev->set_mac_address = dev_set_mac_address;
+    ndev->watchdog_timeo = DEV_WATCHDOG_TIMEO;
+    ndev->tx_timeout = dev_tx_timeout;
+    ndev->change_mtu = dev_change_mtu;
+    ndev->do_ioctl = do_dev_ioctl;
+    ndev->get_stats = dev_get_stats;
+    ndev->set_multicast_list = dev_set_multicast_list;
+    ndev->flags |= IFF_MULTICAST;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+    ndev->poll_controller = ixp425eth_poll_controller;
+#endif
+    ndev->set_mac_address = dev_set_mac_address;
 
     TRACE;
 
@@ -2878,22 +2718,22 @@
      *
      */
 
-    memcpy(dev->dev_addr, 
+    memcpy(ndev->dev_addr, 
 	   &default_mac_addr[priv->port_id].macAddress,
 	   IX_IEEE803_MAC_ADDRESS_SIZE);
 
     /* possibly remove this test and the message when a valid MAC address 
      * is not hardcoded in the driver source code. 
      */
-    if (is_valid_ether_addr(dev->dev_addr))
+    if (is_valid_ether_addr(ndev->dev_addr))
     {
 	P_WARN("Use default MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x for port %d\n",
-	       (unsigned)dev->dev_addr[0],
-	       (unsigned)dev->dev_addr[1],
-	       (unsigned)dev->dev_addr[2],
-	       (unsigned)dev->dev_addr[3],
-	       (unsigned)dev->dev_addr[4],
-	       (unsigned)dev->dev_addr[5],
+	       (unsigned)ndev->dev_addr[0],
+	       (unsigned)ndev->dev_addr[1],
+	       (unsigned)ndev->dev_addr[2],
+	       (unsigned)ndev->dev_addr[3],
+	       (unsigned)ndev->dev_addr[4],
+	       (unsigned)ndev->dev_addr[5],
 	       priv->port_id);
     }
     
@@ -2903,62 +2743,132 @@
      */
     TRACE;
 
-    dev_change_msdu(dev, dev->mtu + dev->hard_header_len + VLAN_HDR);
-
-    priv->tq_timeout.routine = dev_tx_timeout_task;
-    priv->tq_timeout.data = (void *)dev;
+    dev_change_msdu(ndev, ndev->mtu + ndev->hard_header_len + VLAN_HDR);
 
 #ifdef CONFIG_IXP425_ETH_QDISC_ENABLED
     /* configure and enable a fast TX queuing discipline */
     TRACE;
 
-    priv->qdisc = qdisc_create_dflt(dev, &dev_qdisc_ops);
-    dev->qdisc_sleeping = priv->qdisc;
-    dev->qdisc = priv->qdisc;
+    priv->qdisc = qdisc_create_dflt(ndev, &dev_qdisc_ops);
+    ndev->qdisc_sleeping = priv->qdisc;
+    ndev->qdisc = priv->qdisc;
     
-    if (!dev->qdisc_sleeping)
+    if (!ndev->qdisc_sleeping)
     {
 	P_ERROR("%s: qdisc_create_dflt failed on port %d\n",
-		dev->name, priv->port_id);
-	kfree(dev->priv);
-	return -ENOMEM;
+		ndev->name, priv->port_id);
+	goto out;
     }
 #endif
 
     /* set the internal maximum queueing capabilities */
-    dev->tx_queue_len = TX_MBUF_POOL_SIZE;
+    ndev->tx_queue_len = TX_MBUF_POOL_SIZE;
 
-    if (!netif_queue_stopped(dev))
-    {
-	TRACE;
+    if ((res = register_netdev(ndev)))
+        P_ERROR("Failed to register netdev. res = %d\n", res);
+out:
+    return res;
+}
 
-        dev->trans_start = jiffies;
-        netif_stop_queue(dev);
-    }
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/*
+ * Polling receive - used by netconsole and other diagnostic tools
+ * to allow network i/o with interrupts disabled.
+ * (stolen from 8139too.c by siddy)
+ */
+static void ixp425eth_poll_controller(struct net_device *dev)
+{
+        disable_irq(dev->irq);
+        dev_qmgr_os_isr(dev->irq, dev, NULL);
+        enable_irq(dev->irq);
+}
+#endif
 
-    found_devices++;
+static int __devinit npe_eth_init_device(struct device *dev)
+{
+    int res = -ENOMEM;
+    int ixRes = 0;
+    struct platform_device *pdev = to_platform_device(dev);
+    struct net_device *ndev = alloc_etherdev(sizeof(priv_data_t));
+    if (ndev == NULL) {
+        P_ERROR("could not allocate device.\n");
+        goto out;
+    }
+    SET_MODULE_OWNER(ndev);
+    SET_NETDEV_DEV(ndev, dev);
+    ixEthAccTxSchedulingDisciplineSet(pdev->id, FIFO_NO_PRIORITY);
+    dev_set_drvdata(dev, ndev);
+    res = dev_eth_probe(dev);
+    if (res == 0) {
+        /* This was added in v0.1.8 of the driver. It seems that we need to
+         * enable the port before the user can set a mac address for the port
+         * using 'ifconfig hw ether ...'. To enable the port we must first
+         * register Q callbacks, so we register the portDisable callbacks to
+         * ensure that no buffers are passed up to the kernel until the port is
+         * brought up properly (ifconfig up)
+         */
+        if ((ixRes = ixEthAccPortTxDoneCallbackRegister(pdev->id, 
+						      tx_done_disable_cb,
+						      (UINT32)dev)))
 
-    TRACE;
+	{
+	    TRACE;
+	    res = convert_error_ethAcc(ixRes);
+	    goto out;
+	}
+        if ((ixRes = ixEthAccPortRxCallbackRegister(pdev->id, 
+						  rx_disable_cb, 
+						  (UINT32)dev)))
+	{
+	    TRACE;
+	    res = convert_error_ethAcc(ixRes);
+	    goto out;
+	}
+        port_enable(ndev);
+    } else {
+        dev_set_drvdata(dev, NULL);
+        kfree(ndev);
+    }
+out:
+    return res;
+}
 
+static int __devexit npe_eth_fini_device(struct device *dev)
+{
+    struct net_device *ndev = dev_get_drvdata(dev);
+    dev_set_drvdata(dev, NULL);
+    unregister_netdev(ndev);
+    kfree(ndev);
     return 0;
 }
 
-
 /* Module initialization and cleanup */
 
 #ifdef MODULE
 
-static struct net_device ixp425_devices[IX_ETH_ACC_NUMBER_OF_PORTS];
+static struct device_driver npe_eth_driver = {
+    .name       = DRV_NAME,
+    .bus        = &platform_bus_type,
+    .probe      = npe_eth_init_device,
+    .remove     = npe_eth_fini_device,
+};
 
-int init_module(void)
-{
-    int res, dev_count;
-    IxEthAccPortId portId;
-    struct net_device *dev;
+static struct platform_device npe_eth_devs[] = {
+    {
+        .name   = DRV_NAME,
+        .id     = IX_ETH_PORT_1,
+    },
+    {
+        .name   = DRV_NAME,
+        .id     = IX_ETH_PORT_2,
+    }
+};
 
-    TRACE;
+static int __init ixp425_eth_init(void)
+{
+    int res;
 
-    P_INFO("Initializing IXP425 NPE Ethernet driver software v. " MODULE_VERSION " \n");
+    P_INFO("Initializing IXP425 NPE Ethernet driver software v. " DRV_VERSION " \n");
 
     TRACE;
 
@@ -3037,82 +2947,16 @@
 
     TRACE;
 
-    /* Initialise the driver structure */
-    for (dev_count = 0; 
-	 dev_count < dev_max_count;  /* module parameter */
-	 dev_count++)
-    {
-	portId = default_portId[dev_count];
-
-	dev = &ixp425_devices[dev_count];
-
-	dev->init = dev_eth_probe;
-
-        TRACE;
-
-	if ((res = register_netdev(dev)))
-	{
-	    TRACE;
-
-	    P_ERROR("Failed to register netdev. res = %d\n", res);
-	    return res;
-	}
-
-        TRACE;
-
-	/* register "safe" callbacks. This ensure that no traffic will be 
-	 * sent to the stack until the port is brought up (ifconfig up)
-	 */
-        if ((res = ixEthAccPortTxDoneCallbackRegister(portId, 
-						      tx_done_disable_cb,
-						      (UINT32)dev)))
-
-	{
-	    TRACE;
-	    return convert_error_ethAcc(res);
-	}
-        if ((res = ixEthAccPortRxCallbackRegister(portId, 
-						  rx_disable_cb, 
-						  (UINT32)dev)))
-	{
-	    TRACE;
-	    return convert_error_ethAcc(res);
-	}
-    }
-
-    TRACE;
-
-    if (no_csr_init == 0 && datapath_poll != 0 ) /* module parameter */
-    {
-      /* The QMgr dispatch entry point is called from the 
-       * IX_OSAL_IXP400_QM1_IRQ_LVL irq (which will trigger
-       * an interrupt for every packet)
-       * This function setup the datapath in polling mode
-       * for better performances.
-       */
-
-        if ((res = ethAcc_datapath_poll_setup()))
-	{
-	    TRACE;
-	    return res;
-	}
-    }
-
-    TRACE;
-
-    /* initialise the DB Maintenance task mutex */
-    maintenance_mutex = (struct semaphore *) kmalloc(sizeof(struct semaphore), GFP_KERNEL);
-    if (!maintenance_mutex)
+    npe_eth_workqueue = create_workqueue(DRV_NAME);
+    if (npe_eth_workqueue == NULL)
 	return -ENOMEM;
 
-    init_MUTEX(maintenance_mutex);
-
     TRACE;
 
     /* Do not start the EthDB maintenance thread if learning & filtering feature is disabled */
     if (npe_learning) /* module parameter */
     {
-        maintenance_timer_set();
+        schedule_db_maintenance();
     }
 
     TRACE;
@@ -3127,12 +2971,29 @@
     }
     netdev_max_backlog /= BACKLOG_TUNE;
 
+    res = driver_register(&npe_eth_driver);
+    if (res != 0) {
+        P_ERROR("Failed to register NPE EThernet driver (res = %d)\n", res);
+        return res;
+    }
+
     TRACE;
 
+    res = platform_device_register(&npe_eth_devs[0]);
+    if (res != 0) {
+        P_ERROR("Failed to register NPE platform device 0 (res = %d)\n", res);
+        return res;
+    }
+    res = platform_device_register(&npe_eth_devs[1]);
+    if (res != 0) {
+        P_ERROR("Failed to register NPE platform device 1 (res = %d)\n", res);
+        return res;
+    }
+
     return 0;
 }
 
-void cleanup_module(void)
+static void __exit ixp425_eth_exit(void)
 {
     int dev_count;
 
@@ -3147,7 +3008,9 @@
     {
 	TRACE;
 
+#ifdef IXP425ETH_POLLING_MODE
 	dev_pmu_timer_disable(); /* stop the timer */
+#endif
     
 	if (irq_pmu_used) 
         {
@@ -3169,19 +3032,10 @@
 
     TRACE;
 
-    /* stop the maintenance timer */
-    maintenance_timer_clear();
-
-    TRACE;
-
-    /* Wait for maintenance task to complete (if started) */
-    if (npe_learning) /* module parameter */
-    {
-	TRACE;
-
-	down(maintenance_mutex);
-	up(maintenance_mutex);
-    }
+    /* stop the maintenance timer and destroy the driver's work queue */
+    cancel_db_maintenance();
+    flush_workqueue(npe_eth_workqueue);
+    destroy_workqueue(npe_eth_workqueue);
 
     TRACE;
 
@@ -3194,37 +3048,39 @@
 	 dev_count < dev_max_count;  /* module parameter */
 	 dev_count++)
     {
-	struct net_device *dev = &ixp425_devices[dev_count];
-	priv_data_t *priv = dev->priv;
-	if (priv != NULL)
+	IxEthAccPortId portId = default_portId[dev_count];
+	
+	if (default_npeImageId[portId] == IX_ETH_NPE_B_IMAGE_ID)
 	{
-	    IxEthAccPortId portId = default_portId[dev_count];
-
-	    if (default_npeImageId[portId] == IX_ETH_NPE_B_IMAGE_ID)
+	    if (IX_SUCCESS != ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEB))
 	    {
-		if (IX_SUCCESS != ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEB))
-		{
-		    P_NOTICE("Error Halting NPE for Ethernet port %d!\n", portId);
-		}
+		P_NOTICE("Error Halting NPE for Ethernet port %d!\n", portId);
 	    }
-	    if (default_npeImageId[portId] == IX_ETH_NPE_C_IMAGE_ID)
+	}
+	if (default_npeImageId[portId] == IX_ETH_NPE_C_IMAGE_ID)
+	{
+	    if (IX_SUCCESS != ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEC))
 	    {
-		if (IX_SUCCESS != ixNpeDlNpeStopAndReset(IX_NPEDL_NPEID_NPEC))
-		{
-		    P_NOTICE("Error Halting NPE for Ethernet port %d!\n", portId);
-		}
+		P_NOTICE("Error Halting NPE for Ethernet port %d!\n", portId);
 	    }
-	    unregister_netdev(dev);
-	    kfree(dev->priv);
-	    dev->priv = NULL;
 	}
     }
 
     TRACE;
 
+    driver_unregister(&npe_eth_driver);
+    platform_device_unregister(&npe_eth_devs[1]);
+    platform_device_unregister(&npe_eth_devs[0]);
+
+    TRACE;
+
     P_VERBOSE("IXP425 NPE Ethernet driver software uninstalled\n");
 }
 
 #endif /* MODULE */
 
+module_init(ixp425_eth_init);
+module_exit(ixp425_eth_exit);
+
+