aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorKrzysztof Hałasa <khc@pm.waw.pl>2008-07-02 14:46:21 -0400
committerKrzysztof Hałasa <khc@pm.waw.pl>2008-07-23 17:05:56 -0400
commit64bef7630ad5b0ccfdd73973e95cf7b7e39224d0 (patch)
treef24c5b9fed2d3316e171b5e9773658a3c35c9bff /drivers/net
parent52e8a6a2d8dc19002d1757870d16051157ce999c (diff)
WAN: Port LMC driver to generic HDLC
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wan/Kconfig7
-rw-r--r--drivers/net/wan/Makefile1
-rw-r--r--drivers/net/wan/lmc/lmc_ioctl.h2
-rw-r--r--drivers/net/wan/lmc/lmc_main.c657
-rw-r--r--drivers/net/wan/lmc/lmc_media.c55
-rw-r--r--drivers/net/wan/lmc/lmc_proto.c146
-rw-r--r--drivers/net/wan/lmc/lmc_proto.h14
-rw-r--r--drivers/net/wan/lmc/lmc_var.h136
8 files changed, 365 insertions, 653 deletions
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 04c714aa7a6a..766b8bf2f7aa 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -61,7 +61,7 @@ config COSA
61# 61#
62config LANMEDIA 62config LANMEDIA
63 tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" 63 tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards"
64 depends on PCI && VIRT_TO_BUS 64 depends on PCI && VIRT_TO_BUS && HDLC
65 ---help--- 65 ---help---
66 Driver for the following Lan Media family of serial boards: 66 Driver for the following Lan Media family of serial boards:
67 67
@@ -78,9 +78,8 @@ config LANMEDIA
78 - LMC 5245 board connects directly to a T3 circuit saving the 78 - LMC 5245 board connects directly to a T3 circuit saving the
79 additional external hardware. 79 additional external hardware.
80 80
81 To change setting such as syncPPP vs Cisco HDLC or clock source you 81 To change setting such as clock source you will need lmcctl.
82 will need lmcctl. It is available at <ftp://ftp.lanmedia.com/> 82 It is available at <ftp://ftp.lanmedia.com/> (broken link).
83 (broken link).
84 83
85 To compile this driver as a module, choose M here: the 84 To compile this driver as a module, choose M here: the
86 module will be called lmc. 85 module will be called lmc.
diff --git a/drivers/net/wan/Makefile b/drivers/net/wan/Makefile
index 5d27a17792cb..102549605d09 100644
--- a/drivers/net/wan/Makefile
+++ b/drivers/net/wan/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_SEALEVEL_4021) += z85230.o sealevel.o
26obj-$(CONFIG_COSA) += cosa.o 26obj-$(CONFIG_COSA) += cosa.o
27obj-$(CONFIG_FARSYNC) += farsync.o 27obj-$(CONFIG_FARSYNC) += farsync.o
28obj-$(CONFIG_DSCC4) += dscc4.o 28obj-$(CONFIG_DSCC4) += dscc4.o
29obj-$(CONFIG_LANMEDIA) += syncppp.o
30obj-$(CONFIG_X25_ASY) += x25_asy.o 29obj-$(CONFIG_X25_ASY) += x25_asy.o
31 30
32obj-$(CONFIG_LANMEDIA) += lmc/ 31obj-$(CONFIG_LANMEDIA) += lmc/
diff --git a/drivers/net/wan/lmc/lmc_ioctl.h b/drivers/net/wan/lmc/lmc_ioctl.h
index 57dd861cd3db..72fb113a44ca 100644
--- a/drivers/net/wan/lmc/lmc_ioctl.h
+++ b/drivers/net/wan/lmc/lmc_ioctl.h
@@ -61,7 +61,7 @@
61/* 61/*
62 * IFTYPE defines 62 * IFTYPE defines
63 */ 63 */
64#define LMC_PPP 1 /* use sppp interface */ 64#define LMC_PPP 1 /* use generic HDLC interface */
65#define LMC_NET 2 /* use direct net interface */ 65#define LMC_NET 2 /* use direct net interface */
66#define LMC_RAW 3 /* use direct net interface */ 66#define LMC_RAW 3 /* use direct net interface */
67 67
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 62133cee446a..f64f4ca80b55 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -1,6 +1,7 @@
1 /* 1 /*
2 * Copyright (c) 1997-2000 LAN Media Corporation (LMC) 2 * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
3 * All rights reserved. www.lanmedia.com 3 * All rights reserved. www.lanmedia.com
4 * Generic HDLC port Copyright (C) 2008 Krzysztof Halasa <khc@pm.waw.pl>
4 * 5 *
5 * This code is written by: 6 * This code is written by:
6 * Andrew Stanley-Jones (asj@cban.com) 7 * Andrew Stanley-Jones (asj@cban.com)
@@ -36,8 +37,6 @@
36 * 37 *
37 */ 38 */
38 39
39/* $Id: lmc_main.c,v 1.36 2000/04/11 05:25:25 asj Exp $ */
40
41#include <linux/kernel.h> 40#include <linux/kernel.h>
42#include <linux/module.h> 41#include <linux/module.h>
43#include <linux/string.h> 42#include <linux/string.h>
@@ -49,6 +48,7 @@
49#include <linux/interrupt.h> 48#include <linux/interrupt.h>
50#include <linux/pci.h> 49#include <linux/pci.h>
51#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/hdlc.h>
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/in.h> 53#include <linux/in.h>
54#include <linux/if_arp.h> 54#include <linux/if_arp.h>
@@ -57,9 +57,6 @@
57#include <linux/skbuff.h> 57#include <linux/skbuff.h>
58#include <linux/inet.h> 58#include <linux/inet.h>
59#include <linux/bitops.h> 59#include <linux/bitops.h>
60
61#include <net/syncppp.h>
62
63#include <asm/processor.h> /* Processor type for cache alignment. */ 60#include <asm/processor.h> /* Processor type for cache alignment. */
64#include <asm/io.h> 61#include <asm/io.h>
65#include <asm/dma.h> 62#include <asm/dma.h>
@@ -78,8 +75,6 @@
78#include "lmc_debug.h" 75#include "lmc_debug.h"
79#include "lmc_proto.h" 76#include "lmc_proto.h"
80 77
81static int lmc_first_load = 0;
82
83static int LMC_PKT_BUF_SZ = 1542; 78static int LMC_PKT_BUF_SZ = 1542;
84 79
85static struct pci_device_id lmc_pci_tbl[] = { 80static struct pci_device_id lmc_pci_tbl[] = {
@@ -91,11 +86,10 @@ static struct pci_device_id lmc_pci_tbl[] = {
91}; 86};
92 87
93MODULE_DEVICE_TABLE(pci, lmc_pci_tbl); 88MODULE_DEVICE_TABLE(pci, lmc_pci_tbl);
94MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL v2");
95 90
96 91
97static int lmc_start_xmit(struct sk_buff *skb, struct net_device *dev); 92static int lmc_start_xmit(struct sk_buff *skb, struct net_device *dev);
98static int lmc_start_xmit(struct sk_buff *skb, struct net_device *dev);
99static int lmc_rx (struct net_device *dev); 93static int lmc_rx (struct net_device *dev);
100static int lmc_open(struct net_device *dev); 94static int lmc_open(struct net_device *dev);
101static int lmc_close(struct net_device *dev); 95static int lmc_close(struct net_device *dev);
@@ -114,20 +108,14 @@ static void lmc_driver_timeout(struct net_device *dev);
114 * linux reserves 16 device specific IOCTLs. We call them 108 * linux reserves 16 device specific IOCTLs. We call them
115 * LMCIOC* to control various bits of our world. 109 * LMCIOC* to control various bits of our world.
116 */ 110 */
117int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ 111int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
118{ 112{
119 lmc_softc_t *sc; 113 lmc_softc_t *sc = dev_to_sc(dev);
120 lmc_ctl_t ctl; 114 lmc_ctl_t ctl;
121 int ret; 115 int ret = -EOPNOTSUPP;
122 u_int16_t regVal; 116 u16 regVal;
123 unsigned long flags; 117 unsigned long flags;
124 118
125 struct sppp *sp;
126
127 ret = -EOPNOTSUPP;
128
129 sc = dev->priv;
130
131 lmc_trace(dev, "lmc_ioctl in"); 119 lmc_trace(dev, "lmc_ioctl in");
132 120
133 /* 121 /*
@@ -149,7 +137,6 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
149 break; 137 break;
150 138
151 case LMCIOCSINFO: /*fold01*/ 139 case LMCIOCSINFO: /*fold01*/
152 sp = &((struct ppp_device *) dev)->sppp;
153 if (!capable(CAP_NET_ADMIN)) { 140 if (!capable(CAP_NET_ADMIN)) {
154 ret = -EPERM; 141 ret = -EPERM;
155 break; 142 break;
@@ -175,25 +162,20 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
175 sc->TxDescriptControlInit &= ~LMC_TDES_ADD_CRC_DISABLE; 162 sc->TxDescriptControlInit &= ~LMC_TDES_ADD_CRC_DISABLE;
176 } 163 }
177 164
178 if (ctl.keepalive_onoff == LMC_CTL_OFF)
179 sp->pp_flags &= ~PP_KEEPALIVE; /* Turn off */
180 else
181 sp->pp_flags |= PP_KEEPALIVE; /* Turn on */
182
183 ret = 0; 165 ret = 0;
184 break; 166 break;
185 167
186 case LMCIOCIFTYPE: /*fold01*/ 168 case LMCIOCIFTYPE: /*fold01*/
187 { 169 {
188 u_int16_t old_type = sc->if_type; 170 u16 old_type = sc->if_type;
189 u_int16_t new_type; 171 u16 new_type;
190 172
191 if (!capable(CAP_NET_ADMIN)) { 173 if (!capable(CAP_NET_ADMIN)) {
192 ret = -EPERM; 174 ret = -EPERM;
193 break; 175 break;
194 } 176 }
195 177
196 if (copy_from_user(&new_type, ifr->ifr_data, sizeof(u_int16_t))) { 178 if (copy_from_user(&new_type, ifr->ifr_data, sizeof(u16))) {
197 ret = -EFAULT; 179 ret = -EFAULT;
198 break; 180 break;
199 } 181 }
@@ -206,15 +188,11 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
206 } 188 }
207 189
208 lmc_proto_close(sc); 190 lmc_proto_close(sc);
209 lmc_proto_detach(sc);
210 191
211 sc->if_type = new_type; 192 sc->if_type = new_type;
212// lmc_proto_init(sc);
213 lmc_proto_attach(sc); 193 lmc_proto_attach(sc);
214 lmc_proto_open(sc); 194 ret = lmc_proto_open(sc);
215 195 break;
216 ret = 0 ;
217 break ;
218 } 196 }
219 197
220 case LMCIOCGETXINFO: /*fold01*/ 198 case LMCIOCGETXINFO: /*fold01*/
@@ -241,51 +219,53 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
241 219
242 break; 220 break;
243 221
244 case LMCIOCGETLMCSTATS: /*fold01*/ 222 case LMCIOCGETLMCSTATS:
245 if (sc->lmc_cardtype == LMC_CARDTYPE_T1){ 223 if (sc->lmc_cardtype == LMC_CARDTYPE_T1) {
246 lmc_mii_writereg (sc, 0, 17, T1FRAMER_FERR_LSB); 224 lmc_mii_writereg(sc, 0, 17, T1FRAMER_FERR_LSB);
247 sc->stats.framingBitErrorCount += 225 sc->extra_stats.framingBitErrorCount +=
248 lmc_mii_readreg (sc, 0, 18) & 0xff; 226 lmc_mii_readreg(sc, 0, 18) & 0xff;
249 lmc_mii_writereg (sc, 0, 17, T1FRAMER_FERR_MSB); 227 lmc_mii_writereg(sc, 0, 17, T1FRAMER_FERR_MSB);
250 sc->stats.framingBitErrorCount += 228 sc->extra_stats.framingBitErrorCount +=
251 (lmc_mii_readreg (sc, 0, 18) & 0xff) << 8; 229 (lmc_mii_readreg(sc, 0, 18) & 0xff) << 8;
252 lmc_mii_writereg (sc, 0, 17, T1FRAMER_LCV_LSB); 230 lmc_mii_writereg(sc, 0, 17, T1FRAMER_LCV_LSB);
253 sc->stats.lineCodeViolationCount += 231 sc->extra_stats.lineCodeViolationCount +=
254 lmc_mii_readreg (sc, 0, 18) & 0xff; 232 lmc_mii_readreg(sc, 0, 18) & 0xff;
255 lmc_mii_writereg (sc, 0, 17, T1FRAMER_LCV_MSB); 233 lmc_mii_writereg(sc, 0, 17, T1FRAMER_LCV_MSB);
256 sc->stats.lineCodeViolationCount += 234 sc->extra_stats.lineCodeViolationCount +=
257 (lmc_mii_readreg (sc, 0, 18) & 0xff) << 8; 235 (lmc_mii_readreg(sc, 0, 18) & 0xff) << 8;
258 lmc_mii_writereg (sc, 0, 17, T1FRAMER_AERR); 236 lmc_mii_writereg(sc, 0, 17, T1FRAMER_AERR);
259 regVal = lmc_mii_readreg (sc, 0, 18) & 0xff; 237 regVal = lmc_mii_readreg(sc, 0, 18) & 0xff;
260 238
261 sc->stats.lossOfFrameCount += 239 sc->extra_stats.lossOfFrameCount +=
262 (regVal & T1FRAMER_LOF_MASK) >> 4; 240 (regVal & T1FRAMER_LOF_MASK) >> 4;
263 sc->stats.changeOfFrameAlignmentCount += 241 sc->extra_stats.changeOfFrameAlignmentCount +=
264 (regVal & T1FRAMER_COFA_MASK) >> 2; 242 (regVal & T1FRAMER_COFA_MASK) >> 2;
265 sc->stats.severelyErroredFrameCount += 243 sc->extra_stats.severelyErroredFrameCount +=
266 regVal & T1FRAMER_SEF_MASK; 244 regVal & T1FRAMER_SEF_MASK;
267 } 245 }
268 246 if (copy_to_user(ifr->ifr_data, &sc->lmc_device->stats,
269 if (copy_to_user(ifr->ifr_data, &sc->stats, 247 sizeof(sc->lmc_device->stats)) ||
270 sizeof (struct lmc_statistics))) 248 copy_to_user(ifr->ifr_data + sizeof(sc->lmc_device->stats),
271 ret = -EFAULT; 249 &sc->extra_stats, sizeof(sc->extra_stats)))
272 else 250 ret = -EFAULT;
273 ret = 0; 251 else
274 break; 252 ret = 0;
253 break;
275 254
276 case LMCIOCCLEARLMCSTATS: /*fold01*/ 255 case LMCIOCCLEARLMCSTATS:
277 if (!capable(CAP_NET_ADMIN)){ 256 if (!capable(CAP_NET_ADMIN)) {
278 ret = -EPERM; 257 ret = -EPERM;
279 break; 258 break;
280 } 259 }
281 260
282 memset (&sc->stats, 0, sizeof (struct lmc_statistics)); 261 memset(&sc->lmc_device->stats, 0, sizeof(sc->lmc_device->stats));
283 sc->stats.check = STATCHECK; 262 memset(&sc->extra_stats, 0, sizeof(sc->extra_stats));
284 sc->stats.version_size = (DRIVER_VERSION << 16) + 263 sc->extra_stats.check = STATCHECK;
285 sizeof (struct lmc_statistics); 264 sc->extra_stats.version_size = (DRIVER_VERSION << 16) +
286 sc->stats.lmc_cardtype = sc->lmc_cardtype; 265 sizeof(sc->lmc_device->stats) + sizeof(sc->extra_stats);
287 ret = 0; 266 sc->extra_stats.lmc_cardtype = sc->lmc_cardtype;
288 break; 267 ret = 0;
268 break;
289 269
290 case LMCIOCSETCIRCUIT: /*fold01*/ 270 case LMCIOCSETCIRCUIT: /*fold01*/
291 if (!capable(CAP_NET_ADMIN)){ 271 if (!capable(CAP_NET_ADMIN)){
@@ -641,14 +621,12 @@ int lmc_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
641/* the watchdog process that cruises around */ 621/* the watchdog process that cruises around */
642static void lmc_watchdog (unsigned long data) /*fold00*/ 622static void lmc_watchdog (unsigned long data) /*fold00*/
643{ 623{
644 struct net_device *dev = (struct net_device *) data; 624 struct net_device *dev = (struct net_device *)data;
645 lmc_softc_t *sc; 625 lmc_softc_t *sc = dev_to_sc(dev);
646 int link_status; 626 int link_status;
647 u_int32_t ticks; 627 u_int32_t ticks;
648 unsigned long flags; 628 unsigned long flags;
649 629
650 sc = dev->priv;
651
652 lmc_trace(dev, "lmc_watchdog in"); 630 lmc_trace(dev, "lmc_watchdog in");
653 631
654 spin_lock_irqsave(&sc->lmc_lock, flags); 632 spin_lock_irqsave(&sc->lmc_lock, flags);
@@ -677,22 +655,22 @@ static void lmc_watchdog (unsigned long data) /*fold00*/
677 * check for a transmit interrupt timeout 655 * check for a transmit interrupt timeout
678 * Has the packet xmt vs xmt serviced threshold been exceeded */ 656 * Has the packet xmt vs xmt serviced threshold been exceeded */
679 if (sc->lmc_taint_tx == sc->lastlmc_taint_tx && 657 if (sc->lmc_taint_tx == sc->lastlmc_taint_tx &&
680 sc->stats.tx_packets > sc->lasttx_packets && 658 sc->lmc_device->stats.tx_packets > sc->lasttx_packets &&
681 sc->tx_TimeoutInd == 0) 659 sc->tx_TimeoutInd == 0)
682 { 660 {
683 661
684 /* wait for the watchdog to come around again */ 662 /* wait for the watchdog to come around again */
685 sc->tx_TimeoutInd = 1; 663 sc->tx_TimeoutInd = 1;
686 } 664 }
687 else if (sc->lmc_taint_tx == sc->lastlmc_taint_tx && 665 else if (sc->lmc_taint_tx == sc->lastlmc_taint_tx &&
688 sc->stats.tx_packets > sc->lasttx_packets && 666 sc->lmc_device->stats.tx_packets > sc->lasttx_packets &&
689 sc->tx_TimeoutInd) 667 sc->tx_TimeoutInd)
690 { 668 {
691 669
692 LMC_EVENT_LOG(LMC_EVENT_XMTINTTMO, LMC_CSR_READ (sc, csr_status), 0); 670 LMC_EVENT_LOG(LMC_EVENT_XMTINTTMO, LMC_CSR_READ (sc, csr_status), 0);
693 671
694 sc->tx_TimeoutDisplay = 1; 672 sc->tx_TimeoutDisplay = 1;
695 sc->stats.tx_TimeoutCnt++; 673 sc->extra_stats.tx_TimeoutCnt++;
696 674
697 /* DEC chip is stuck, hit it with a RESET!!!! */ 675 /* DEC chip is stuck, hit it with a RESET!!!! */
698 lmc_running_reset (dev); 676 lmc_running_reset (dev);
@@ -712,13 +690,11 @@ static void lmc_watchdog (unsigned long data) /*fold00*/
712 /* reset the transmit timeout detection flag */ 690 /* reset the transmit timeout detection flag */
713 sc->tx_TimeoutInd = 0; 691 sc->tx_TimeoutInd = 0;
714 sc->lastlmc_taint_tx = sc->lmc_taint_tx; 692 sc->lastlmc_taint_tx = sc->lmc_taint_tx;
715 sc->lasttx_packets = sc->stats.tx_packets; 693 sc->lasttx_packets = sc->lmc_device->stats.tx_packets;
716 } 694 } else {
717 else
718 {
719 sc->tx_TimeoutInd = 0; 695 sc->tx_TimeoutInd = 0;
720 sc->lastlmc_taint_tx = sc->lmc_taint_tx; 696 sc->lastlmc_taint_tx = sc->lmc_taint_tx;
721 sc->lasttx_packets = sc->stats.tx_packets; 697 sc->lasttx_packets = sc->lmc_device->stats.tx_packets;
722 } 698 }
723 699
724 /* --- end time out check ----------------------------------- */ 700 /* --- end time out check ----------------------------------- */
@@ -748,19 +724,7 @@ static void lmc_watchdog (unsigned long data) /*fold00*/
748 sc->last_link_status = 1; 724 sc->last_link_status = 1;
749 /* lmc_reset (sc); Again why reset??? */ 725 /* lmc_reset (sc); Again why reset??? */
750 726
751 /* Inform the world that link protocol is back up. */
752 netif_carrier_on(dev); 727 netif_carrier_on(dev);
753
754 /* Now we have to tell the syncppp that we had an outage
755 * and that it should deal. Calling sppp_reopen here
756 * should do the trick, but we may have to call sppp_close
757 * when the link goes down, and call sppp_open here.
758 * Subject to more testing.
759 * --bbraun
760 */
761
762 lmc_proto_reopen(sc);
763
764 } 728 }
765 729
766 /* Call media specific watchdog functions */ 730 /* Call media specific watchdog functions */
@@ -816,114 +780,93 @@ kick_timer:
816 780
817} 781}
818 782
819static void lmc_setup(struct net_device * const dev) /*fold00*/ 783static int lmc_attach(struct net_device *dev, unsigned short encoding,
784 unsigned short parity)
820{ 785{
821 lmc_trace(dev, "lmc_setup in"); 786 if (encoding == ENCODING_NRZ && parity == PARITY_CRC16_PR1_CCITT)
822 787 return 0;
823 dev->type = ARPHRD_HDLC; 788 return -EINVAL;
824 dev->hard_start_xmit = lmc_start_xmit;
825 dev->open = lmc_open;
826 dev->stop = lmc_close;
827 dev->get_stats = lmc_get_stats;
828 dev->do_ioctl = lmc_ioctl;
829 dev->tx_timeout = lmc_driver_timeout;
830 dev->watchdog_timeo = (HZ); /* 1 second */
831
832 lmc_trace(dev, "lmc_setup out");
833} 789}
834 790
835
836static int __devinit lmc_init_one(struct pci_dev *pdev, 791static int __devinit lmc_init_one(struct pci_dev *pdev,
837 const struct pci_device_id *ent) 792 const struct pci_device_id *ent)
838{ 793{
839 struct net_device *dev; 794 lmc_softc_t *sc;
840 lmc_softc_t *sc; 795 struct net_device *dev;
841 u16 subdevice; 796 u16 subdevice;
842 u_int16_t AdapModelNum; 797 u16 AdapModelNum;
843 int err = -ENOMEM; 798 int err;
844 static int cards_found; 799 static int cards_found;
845#ifndef GCOM 800
846 /* We name by type not by vendor */ 801 /* lmc_trace(dev, "lmc_init_one in"); */
847 static const char lmcname[] = "hdlc%d"; 802
848#else 803 err = pci_enable_device(pdev);
849 /* 804 if (err) {
850 * GCOM uses LMC vendor name so that clients can know which card 805 printk(KERN_ERR "lmc: pci enable failed: %d\n", err);
851 * to attach to. 806 return err;
852 */ 807 }
853 static const char lmcname[] = "lmc%d";
854#endif
855
856
857 /*
858 * Allocate our own device structure
859 */
860 dev = alloc_netdev(sizeof(lmc_softc_t), lmcname, lmc_setup);
861 if (!dev) {
862 printk (KERN_ERR "lmc:alloc_netdev for device failed\n");
863 goto out1;
864 }
865
866 lmc_trace(dev, "lmc_init_one in");
867
868 err = pci_enable_device(pdev);
869 if (err) {
870 printk(KERN_ERR "lmc: pci enable failed:%d\n", err);
871 goto out2;
872 }
873
874 if (pci_request_regions(pdev, "lmc")) {
875 printk(KERN_ERR "lmc: pci_request_region failed\n");
876 err = -EIO;
877 goto out3;
878 }
879
880 pci_set_drvdata(pdev, dev);
881
882 if(lmc_first_load == 0){
883 printk(KERN_INFO "Lan Media Corporation WAN Driver Version %d.%d.%d\n",
884 DRIVER_MAJOR_VERSION, DRIVER_MINOR_VERSION,DRIVER_SUB_VERSION);
885 lmc_first_load = 1;
886 }
887
888 sc = dev->priv;
889 sc->lmc_device = dev;
890 sc->name = dev->name;
891
892 /* Initialize the sppp layer */
893 /* An ioctl can cause a subsequent detach for raw frame interface */
894 dev->ml_priv = sc;
895 sc->if_type = LMC_PPP;
896 sc->check = 0xBEAFCAFE;
897 dev->base_addr = pci_resource_start(pdev, 0);
898 dev->irq = pdev->irq;
899
900 SET_NETDEV_DEV(dev, &pdev->dev);
901
902 /*
903 * This will get the protocol layer ready and do any 1 time init's
904 * Must have a valid sc and dev structure
905 */
906 lmc_proto_init(sc);
907
908 lmc_proto_attach(sc);
909 808
910 /* 809 err = pci_request_regions(pdev, "lmc");
911 * Why were we changing this??? 810 if (err) {
912 dev->tx_queue_len = 100; 811 printk(KERN_ERR "lmc: pci_request_region failed\n");
913 */ 812 goto err_req_io;
813 }
914 814
915 /* Init the spin lock so can call it latter */ 815 /*
816 * Allocate our own device structure
817 */
818 sc = kzalloc(sizeof(lmc_softc_t), GFP_KERNEL);
819 if (!sc) {
820 err = -ENOMEM;
821 goto err_kzalloc;
822 }
916 823
917 spin_lock_init(&sc->lmc_lock); 824 dev = alloc_hdlcdev(sc);
918 pci_set_master(pdev); 825 if (!dev) {
826 printk(KERN_ERR "lmc:alloc_netdev for device failed\n");
827 goto err_hdlcdev;
828 }
919 829
920 printk ("%s: detected at %lx, irq %d\n", dev->name,
921 dev->base_addr, dev->irq);
922 830
923 if (register_netdev (dev) != 0) { 831 dev->type = ARPHRD_HDLC;
924 printk (KERN_ERR "%s: register_netdev failed.\n", dev->name); 832 dev_to_hdlc(dev)->xmit = lmc_start_xmit;
925 goto out4; 833 dev_to_hdlc(dev)->attach = lmc_attach;
926 } 834 dev->open = lmc_open;
835 dev->stop = lmc_close;
836 dev->get_stats = lmc_get_stats;
837 dev->do_ioctl = lmc_ioctl;
838 dev->tx_timeout = lmc_driver_timeout;
839 dev->watchdog_timeo = HZ; /* 1 second */
840 dev->tx_queue_len = 100;
841 sc->lmc_device = dev;
842 sc->name = dev->name;
843 sc->if_type = LMC_PPP;
844 sc->check = 0xBEAFCAFE;
845 dev->base_addr = pci_resource_start(pdev, 0);
846 dev->irq = pdev->irq;
847 pci_set_drvdata(pdev, dev);
848 SET_NETDEV_DEV(dev, &pdev->dev);
849
850 /*
851 * This will get the protocol layer ready and do any 1 time init's
852 * Must have a valid sc and dev structure
853 */
854 lmc_proto_attach(sc);
855
856 /* Init the spin lock so can call it latter */
857
858 spin_lock_init(&sc->lmc_lock);
859 pci_set_master(pdev);
860
861 printk(KERN_INFO "%s: detected at %lx, irq %d\n", dev->name,
862 dev->base_addr, dev->irq);
863
864 err = register_hdlc_device(dev);
865 if (err) {
866 printk(KERN_ERR "%s: register_netdev failed.\n", dev->name);
867 free_netdev(dev);
868 goto err_hdlcdev;
869 }
927 870
928 sc->lmc_cardtype = LMC_CARDTYPE_UNKNOWN; 871 sc->lmc_cardtype = LMC_CARDTYPE_UNKNOWN;
929 sc->lmc_timing = LMC_CTL_CLOCK_SOURCE_EXT; 872 sc->lmc_timing = LMC_CTL_CLOCK_SOURCE_EXT;
@@ -939,27 +882,27 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
939 882
940 switch (subdevice) { 883 switch (subdevice) {
941 case PCI_DEVICE_ID_LMC_HSSI: 884 case PCI_DEVICE_ID_LMC_HSSI:
942 printk ("%s: LMC HSSI\n", dev->name); 885 printk(KERN_INFO "%s: LMC HSSI\n", dev->name);
943 sc->lmc_cardtype = LMC_CARDTYPE_HSSI; 886 sc->lmc_cardtype = LMC_CARDTYPE_HSSI;
944 sc->lmc_media = &lmc_hssi_media; 887 sc->lmc_media = &lmc_hssi_media;
945 break; 888 break;
946 case PCI_DEVICE_ID_LMC_DS3: 889 case PCI_DEVICE_ID_LMC_DS3:
947 printk ("%s: LMC DS3\n", dev->name); 890 printk(KERN_INFO "%s: LMC DS3\n", dev->name);
948 sc->lmc_cardtype = LMC_CARDTYPE_DS3; 891 sc->lmc_cardtype = LMC_CARDTYPE_DS3;
949 sc->lmc_media = &lmc_ds3_media; 892 sc->lmc_media = &lmc_ds3_media;
950 break; 893 break;
951 case PCI_DEVICE_ID_LMC_SSI: 894 case PCI_DEVICE_ID_LMC_SSI:
952 printk ("%s: LMC SSI\n", dev->name); 895 printk(KERN_INFO "%s: LMC SSI\n", dev->name);
953 sc->lmc_cardtype = LMC_CARDTYPE_SSI; 896 sc->lmc_cardtype = LMC_CARDTYPE_SSI;
954 sc->lmc_media = &lmc_ssi_media; 897 sc->lmc_media = &lmc_ssi_media;
955 break; 898 break;
956 case PCI_DEVICE_ID_LMC_T1: 899 case PCI_DEVICE_ID_LMC_T1:
957 printk ("%s: LMC T1\n", dev->name); 900 printk(KERN_INFO "%s: LMC T1\n", dev->name);
958 sc->lmc_cardtype = LMC_CARDTYPE_T1; 901 sc->lmc_cardtype = LMC_CARDTYPE_T1;
959 sc->lmc_media = &lmc_t1_media; 902 sc->lmc_media = &lmc_t1_media;
960 break; 903 break;
961 default: 904 default:
962 printk (KERN_WARNING "%s: LMC UNKOWN CARD!\n", dev->name); 905 printk(KERN_WARNING "%s: LMC UNKOWN CARD!\n", dev->name);
963 break; 906 break;
964 } 907 }
965 908
@@ -977,32 +920,28 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
977 */ 920 */
978 AdapModelNum = (lmc_mii_readreg (sc, 0, 3) & 0x3f0) >> 4; 921 AdapModelNum = (lmc_mii_readreg (sc, 0, 3) & 0x3f0) >> 4;
979 922
980 if ((AdapModelNum == LMC_ADAP_T1 923 if ((AdapModelNum != LMC_ADAP_T1 || /* detect LMC1200 */
981 && subdevice == PCI_DEVICE_ID_LMC_T1) || /* detect LMC1200 */ 924 subdevice != PCI_DEVICE_ID_LMC_T1) &&
982 (AdapModelNum == LMC_ADAP_SSI 925 (AdapModelNum != LMC_ADAP_SSI || /* detect LMC1000 */
983 && subdevice == PCI_DEVICE_ID_LMC_SSI) || /* detect LMC1000 */ 926 subdevice != PCI_DEVICE_ID_LMC_SSI) &&
984 (AdapModelNum == LMC_ADAP_DS3 927 (AdapModelNum != LMC_ADAP_DS3 || /* detect LMC5245 */
985 && subdevice == PCI_DEVICE_ID_LMC_DS3) || /* detect LMC5245 */ 928 subdevice != PCI_DEVICE_ID_LMC_DS3) &&
986 (AdapModelNum == LMC_ADAP_HSSI 929 (AdapModelNum != LMC_ADAP_HSSI || /* detect LMC5200 */
987 && subdevice == PCI_DEVICE_ID_LMC_HSSI)) 930 subdevice != PCI_DEVICE_ID_LMC_HSSI))
988 { /* detect LMC5200 */ 931 printk(KERN_WARNING "%s: Model number (%d) miscompare for PCI"
932 " Subsystem ID = 0x%04x\n",
933 dev->name, AdapModelNum, subdevice);
989 934
990 }
991 else {
992 printk ("%s: Model number (%d) miscompare for PCI Subsystem ID = 0x%04x\n",
993 dev->name, AdapModelNum, subdevice);
994// return (NULL);
995 }
996 /* 935 /*
997 * reset clock 936 * reset clock
998 */ 937 */
999 LMC_CSR_WRITE (sc, csr_gp_timer, 0xFFFFFFFFUL); 938 LMC_CSR_WRITE (sc, csr_gp_timer, 0xFFFFFFFFUL);
1000 939
1001 sc->board_idx = cards_found++; 940 sc->board_idx = cards_found++;
1002 sc->stats.check = STATCHECK; 941 sc->extra_stats.check = STATCHECK;
1003 sc->stats.version_size = (DRIVER_VERSION << 16) + 942 sc->extra_stats.version_size = (DRIVER_VERSION << 16) +
1004 sizeof (struct lmc_statistics); 943 sizeof(sc->lmc_device->stats) + sizeof(sc->extra_stats);
1005 sc->stats.lmc_cardtype = sc->lmc_cardtype; 944 sc->extra_stats.lmc_cardtype = sc->lmc_cardtype;
1006 945
1007 sc->lmc_ok = 0; 946 sc->lmc_ok = 0;
1008 sc->last_link_status = 0; 947 sc->last_link_status = 0;
@@ -1010,58 +949,51 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
1010 lmc_trace(dev, "lmc_init_one out"); 949 lmc_trace(dev, "lmc_init_one out");
1011 return 0; 950 return 0;
1012 951
1013 out4: 952err_hdlcdev:
1014 lmc_proto_detach(sc); 953 pci_set_drvdata(pdev, NULL);
1015 out3: 954 kfree(sc);
1016 if (pdev) { 955err_kzalloc:
1017 pci_release_regions(pdev); 956 pci_release_regions(pdev);
1018 pci_set_drvdata(pdev, NULL); 957err_req_io:
1019 } 958 pci_disable_device(pdev);
1020 out2: 959 return err;
1021 free_netdev(dev);
1022 out1:
1023 return err;
1024} 960}
1025 961
1026/* 962/*
1027 * Called from pci when removing module. 963 * Called from pci when removing module.
1028 */ 964 */
1029static void __devexit lmc_remove_one (struct pci_dev *pdev) 965static void __devexit lmc_remove_one(struct pci_dev *pdev)
1030{ 966{
1031 struct net_device *dev = pci_get_drvdata(pdev); 967 struct net_device *dev = pci_get_drvdata(pdev);
1032 968
1033 if (dev) { 969 if (dev) {
1034 lmc_softc_t *sc = dev->priv; 970 printk(KERN_DEBUG "%s: removing...\n", dev->name);
1035 971 unregister_hdlc_device(dev);
1036 printk("%s: removing...\n", dev->name); 972 free_netdev(dev);
1037 lmc_proto_detach(sc); 973 pci_release_regions(pdev);
1038 unregister_netdev(dev); 974 pci_disable_device(pdev);
1039 free_netdev(dev); 975 pci_set_drvdata(pdev, NULL);
1040 pci_release_regions(pdev); 976 }
1041 pci_disable_device(pdev);
1042 pci_set_drvdata(pdev, NULL);
1043 }
1044} 977}
1045 978
1046/* After this is called, packets can be sent. 979/* After this is called, packets can be sent.
1047 * Does not initialize the addresses 980 * Does not initialize the addresses
1048 */ 981 */
1049static int lmc_open (struct net_device *dev) /*fold00*/ 982static int lmc_open(struct net_device *dev)
1050{ 983{
1051 lmc_softc_t *sc = dev->priv; 984 lmc_softc_t *sc = dev_to_sc(dev);
985 int err;
1052 986
1053 lmc_trace(dev, "lmc_open in"); 987 lmc_trace(dev, "lmc_open in");
1054 988
1055 lmc_led_on(sc, LMC_DS3_LED0); 989 lmc_led_on(sc, LMC_DS3_LED0);
1056 990
1057 lmc_dec_reset (sc); 991 lmc_dec_reset(sc);
1058 lmc_reset (sc); 992 lmc_reset(sc);
1059
1060 LMC_EVENT_LOG(LMC_EVENT_RESET1, LMC_CSR_READ (sc, csr_status), 0);
1061 LMC_EVENT_LOG(LMC_EVENT_RESET2,
1062 lmc_mii_readreg (sc, 0, 16),
1063 lmc_mii_readreg (sc, 0, 17));
1064 993
994 LMC_EVENT_LOG(LMC_EVENT_RESET1, LMC_CSR_READ(sc, csr_status), 0);
995 LMC_EVENT_LOG(LMC_EVENT_RESET2, lmc_mii_readreg(sc, 0, 16),
996 lmc_mii_readreg(sc, 0, 17));
1065 997
1066 if (sc->lmc_ok){ 998 if (sc->lmc_ok){
1067 lmc_trace(dev, "lmc_open lmc_ok out"); 999 lmc_trace(dev, "lmc_open lmc_ok out");
@@ -1106,14 +1038,14 @@ static int lmc_open (struct net_device *dev) /*fold00*/
1106 1038
1107 /* dev->flags |= IFF_UP; */ 1039 /* dev->flags |= IFF_UP; */
1108 1040
1109 lmc_proto_open(sc); 1041 if ((err = lmc_proto_open(sc)) != 0)
1042 return err;
1110 1043
1111 dev->do_ioctl = lmc_ioctl; 1044 dev->do_ioctl = lmc_ioctl;
1112 1045
1113 1046
1114 netif_start_queue(dev); 1047 netif_start_queue(dev);
1115 1048 sc->extra_stats.tx_tbusy0++;
1116 sc->stats.tx_tbusy0++ ;
1117 1049
1118 /* 1050 /*
1119 * select what interrupts we want to get 1051 * select what interrupts we want to get
@@ -1165,8 +1097,7 @@ static int lmc_open (struct net_device *dev) /*fold00*/
1165 1097
1166static void lmc_running_reset (struct net_device *dev) /*fold00*/ 1098static void lmc_running_reset (struct net_device *dev) /*fold00*/
1167{ 1099{
1168 1100 lmc_softc_t *sc = dev_to_sc(dev);
1169 lmc_softc_t *sc = (lmc_softc_t *) dev->priv;
1170 1101
1171 lmc_trace(dev, "lmc_runnig_reset in"); 1102 lmc_trace(dev, "lmc_runnig_reset in");
1172 1103
@@ -1184,7 +1115,7 @@ static void lmc_running_reset (struct net_device *dev) /*fold00*/
1184 netif_wake_queue(dev); 1115 netif_wake_queue(dev);
1185 1116
1186 sc->lmc_txfull = 0; 1117 sc->lmc_txfull = 0;
1187 sc->stats.tx_tbusy0++ ; 1118 sc->extra_stats.tx_tbusy0++;
1188 1119
1189 sc->lmc_intrmask = TULIP_DEFAULT_INTR_MASK; 1120 sc->lmc_intrmask = TULIP_DEFAULT_INTR_MASK;
1190 LMC_CSR_WRITE (sc, csr_intr, sc->lmc_intrmask); 1121 LMC_CSR_WRITE (sc, csr_intr, sc->lmc_intrmask);
@@ -1200,14 +1131,13 @@ static void lmc_running_reset (struct net_device *dev) /*fold00*/
1200 * This disables the timer for the watchdog and keepalives, 1131 * This disables the timer for the watchdog and keepalives,
1201 * and disables the irq for dev. 1132 * and disables the irq for dev.
1202 */ 1133 */
1203static int lmc_close (struct net_device *dev) /*fold00*/ 1134static int lmc_close(struct net_device *dev)
1204{ 1135{
1205 /* not calling release_region() as we should */ 1136 /* not calling release_region() as we should */
1206 lmc_softc_t *sc; 1137 lmc_softc_t *sc = dev_to_sc(dev);
1207 1138
1208 lmc_trace(dev, "lmc_close in"); 1139 lmc_trace(dev, "lmc_close in");
1209 1140
1210 sc = dev->priv;
1211 sc->lmc_ok = 0; 1141 sc->lmc_ok = 0;
1212 sc->lmc_media->set_link_status (sc, 0); 1142 sc->lmc_media->set_link_status (sc, 0);
1213 del_timer (&sc->timer); 1143 del_timer (&sc->timer);
@@ -1215,7 +1145,7 @@ static int lmc_close (struct net_device *dev) /*fold00*/
1215 lmc_ifdown (dev); 1145 lmc_ifdown (dev);
1216 1146
1217 lmc_trace(dev, "lmc_close out"); 1147 lmc_trace(dev, "lmc_close out");
1218 1148
1219 return 0; 1149 return 0;
1220} 1150}
1221 1151
@@ -1223,16 +1153,16 @@ static int lmc_close (struct net_device *dev) /*fold00*/
1223/* When the interface goes down, this is called */ 1153/* When the interface goes down, this is called */
1224static int lmc_ifdown (struct net_device *dev) /*fold00*/ 1154static int lmc_ifdown (struct net_device *dev) /*fold00*/
1225{ 1155{
1226 lmc_softc_t *sc = dev->priv; 1156 lmc_softc_t *sc = dev_to_sc(dev);
1227 u32 csr6; 1157 u32 csr6;
1228 int i; 1158 int i;
1229 1159
1230 lmc_trace(dev, "lmc_ifdown in"); 1160 lmc_trace(dev, "lmc_ifdown in");
1231 1161
1232 /* Don't let anything else go on right now */ 1162 /* Don't let anything else go on right now */
1233 // dev->start = 0; 1163 // dev->start = 0;
1234 netif_stop_queue(dev); 1164 netif_stop_queue(dev);
1235 sc->stats.tx_tbusy1++ ; 1165 sc->extra_stats.tx_tbusy1++;
1236 1166
1237 /* stop interrupts */ 1167 /* stop interrupts */
1238 /* Clear the interrupt mask */ 1168 /* Clear the interrupt mask */
@@ -1244,8 +1174,8 @@ static int lmc_ifdown (struct net_device *dev) /*fold00*/
1244 csr6 &= ~LMC_DEC_SR; /* Turn off the Receive bit */ 1174 csr6 &= ~LMC_DEC_SR; /* Turn off the Receive bit */
1245 LMC_CSR_WRITE (sc, csr_command, csr6); 1175 LMC_CSR_WRITE (sc, csr_command, csr6);
1246 1176
1247 sc->stats.rx_missed_errors += 1177 sc->lmc_device->stats.rx_missed_errors +=
1248 LMC_CSR_READ (sc, csr_missed_frames) & 0xffff; 1178 LMC_CSR_READ(sc, csr_missed_frames) & 0xffff;
1249 1179
1250 /* release the interrupt */ 1180 /* release the interrupt */
1251 if(sc->got_irq == 1){ 1181 if(sc->got_irq == 1){
@@ -1276,7 +1206,7 @@ static int lmc_ifdown (struct net_device *dev) /*fold00*/
1276 lmc_led_off (sc, LMC_MII16_LED_ALL); 1206 lmc_led_off (sc, LMC_MII16_LED_ALL);
1277 1207
1278 netif_wake_queue(dev); 1208 netif_wake_queue(dev);
1279 sc->stats.tx_tbusy0++ ; 1209 sc->extra_stats.tx_tbusy0++;
1280 1210
1281 lmc_trace(dev, "lmc_ifdown out"); 1211 lmc_trace(dev, "lmc_ifdown out");
1282 1212
@@ -1289,7 +1219,7 @@ static int lmc_ifdown (struct net_device *dev) /*fold00*/
1289static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/ 1219static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
1290{ 1220{
1291 struct net_device *dev = (struct net_device *) dev_instance; 1221 struct net_device *dev = (struct net_device *) dev_instance;
1292 lmc_softc_t *sc; 1222 lmc_softc_t *sc = dev_to_sc(dev);
1293 u32 csr; 1223 u32 csr;
1294 int i; 1224 int i;
1295 s32 stat; 1225 s32 stat;
@@ -1300,8 +1230,6 @@ static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
1300 1230
1301 lmc_trace(dev, "lmc_interrupt in"); 1231 lmc_trace(dev, "lmc_interrupt in");
1302 1232
1303 sc = dev->priv;
1304
1305 spin_lock(&sc->lmc_lock); 1233 spin_lock(&sc->lmc_lock);
1306 1234
1307 /* 1235 /*
@@ -1354,7 +1282,7 @@ static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
1354 1282
1355 int n_compl = 0 ; 1283 int n_compl = 0 ;
1356 /* reset the transmit timeout detection flag -baz */ 1284 /* reset the transmit timeout detection flag -baz */
1357 sc->stats.tx_NoCompleteCnt = 0; 1285 sc->extra_stats.tx_NoCompleteCnt = 0;
1358 1286
1359 badtx = sc->lmc_taint_tx; 1287 badtx = sc->lmc_taint_tx;
1360 i = badtx % LMC_TXDESCS; 1288 i = badtx % LMC_TXDESCS;
@@ -1378,27 +1306,25 @@ static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
1378 if (sc->lmc_txq[i] == NULL) 1306 if (sc->lmc_txq[i] == NULL)
1379 continue; 1307 continue;
1380 1308
1381 /* 1309 /*
1382 * Check the total error summary to look for any errors 1310 * Check the total error summary to look for any errors
1383 */ 1311 */
1384 if (stat & 0x8000) { 1312 if (stat & 0x8000) {
1385 sc->stats.tx_errors++; 1313 sc->lmc_device->stats.tx_errors++;
1386 if (stat & 0x4104) 1314 if (stat & 0x4104)
1387 sc->stats.tx_aborted_errors++; 1315 sc->lmc_device->stats.tx_aborted_errors++;
1388 if (stat & 0x0C00) 1316 if (stat & 0x0C00)
1389 sc->stats.tx_carrier_errors++; 1317 sc->lmc_device->stats.tx_carrier_errors++;
1390 if (stat & 0x0200) 1318 if (stat & 0x0200)
1391 sc->stats.tx_window_errors++; 1319 sc->lmc_device->stats.tx_window_errors++;
1392 if (stat & 0x0002) 1320 if (stat & 0x0002)
1393 sc->stats.tx_fifo_errors++; 1321 sc->lmc_device->stats.tx_fifo_errors++;
1394 } 1322 } else {
1395 else { 1323 sc->lmc_device->stats.tx_bytes += sc->lmc_txring[i].length & 0x7ff;
1396 1324
1397 sc->stats.tx_bytes += sc->lmc_txring[i].length & 0x7ff; 1325 sc->lmc_device->stats.tx_packets++;
1398
1399 sc->stats.tx_packets++;
1400 } 1326 }
1401 1327
1402 // dev_kfree_skb(sc->lmc_txq[i]); 1328 // dev_kfree_skb(sc->lmc_txq[i]);
1403 dev_kfree_skb_irq(sc->lmc_txq[i]); 1329 dev_kfree_skb_irq(sc->lmc_txq[i]);
1404 sc->lmc_txq[i] = NULL; 1330 sc->lmc_txq[i] = NULL;
@@ -1415,13 +1341,13 @@ static irqreturn_t lmc_interrupt (int irq, void *dev_instance) /*fold00*/
1415 LMC_EVENT_LOG(LMC_EVENT_TBUSY0, n_compl, 0); 1341 LMC_EVENT_LOG(LMC_EVENT_TBUSY0, n_compl, 0);
1416 sc->lmc_txfull = 0; 1342 sc->lmc_txfull = 0;
1417 netif_wake_queue(dev); 1343 netif_wake_queue(dev);
1418 sc->stats.tx_tbusy0++ ; 1344 sc->extra_stats.tx_tbusy0++;
1419 1345
1420 1346
1421#ifdef DEBUG 1347#ifdef DEBUG
1422 sc->stats.dirtyTx = badtx; 1348 sc->extra_stats.dirtyTx = badtx;
1423 sc->stats.lmc_next_tx = sc->lmc_next_tx; 1349 sc->extra_stats.lmc_next_tx = sc->lmc_next_tx;
1424 sc->stats.lmc_txfull = sc->lmc_txfull; 1350 sc->extra_stats.lmc_txfull = sc->lmc_txfull;
1425#endif 1351#endif
1426 sc->lmc_taint_tx = badtx; 1352 sc->lmc_taint_tx = badtx;
1427 1353
@@ -1476,9 +1402,9 @@ lmc_int_fail_out:
1476 return IRQ_RETVAL(handled); 1402 return IRQ_RETVAL(handled);
1477} 1403}
1478 1404
1479static int lmc_start_xmit (struct sk_buff *skb, struct net_device *dev) /*fold00*/ 1405static int lmc_start_xmit(struct sk_buff *skb, struct net_device *dev)
1480{ 1406{
1481 lmc_softc_t *sc; 1407 lmc_softc_t *sc = dev_to_sc(dev);
1482 u32 flag; 1408 u32 flag;
1483 int entry; 1409 int entry;
1484 int ret = 0; 1410 int ret = 0;
@@ -1486,8 +1412,6 @@ static int lmc_start_xmit (struct sk_buff *skb, struct net_device *dev) /*fold00
1486 1412
1487 lmc_trace(dev, "lmc_start_xmit in"); 1413 lmc_trace(dev, "lmc_start_xmit in");
1488 1414
1489 sc = dev->priv;
1490
1491 spin_lock_irqsave(&sc->lmc_lock, flags); 1415 spin_lock_irqsave(&sc->lmc_lock, flags);
1492 1416
1493 /* normal path, tbusy known to be zero */ 1417 /* normal path, tbusy known to be zero */
@@ -1532,8 +1456,8 @@ static int lmc_start_xmit (struct sk_buff *skb, struct net_device *dev) /*fold00
1532 if (sc->lmc_next_tx - sc->lmc_taint_tx >= LMC_TXDESCS - 1) 1456 if (sc->lmc_next_tx - sc->lmc_taint_tx >= LMC_TXDESCS - 1)
1533 { /* ring full, go busy */ 1457 { /* ring full, go busy */
1534 sc->lmc_txfull = 1; 1458 sc->lmc_txfull = 1;
1535 netif_stop_queue(dev); 1459 netif_stop_queue(dev);
1536 sc->stats.tx_tbusy1++ ; 1460 sc->extra_stats.tx_tbusy1++;
1537 LMC_EVENT_LOG(LMC_EVENT_TBUSY1, entry, 0); 1461 LMC_EVENT_LOG(LMC_EVENT_TBUSY1, entry, 0);
1538 } 1462 }
1539#endif 1463#endif
@@ -1550,7 +1474,7 @@ static int lmc_start_xmit (struct sk_buff *skb, struct net_device *dev) /*fold00
1550 * the watchdog timer handler. -baz 1474 * the watchdog timer handler. -baz
1551 */ 1475 */
1552 1476
1553 sc->stats.tx_NoCompleteCnt++; 1477 sc->extra_stats.tx_NoCompleteCnt++;
1554 sc->lmc_next_tx++; 1478 sc->lmc_next_tx++;
1555 1479
1556 /* give ownership to the chip */ 1480 /* give ownership to the chip */
@@ -1569,9 +1493,9 @@ static int lmc_start_xmit (struct sk_buff *skb, struct net_device *dev) /*fold00
1569} 1493}
1570 1494
1571 1495
1572static int lmc_rx (struct net_device *dev) /*fold00*/ 1496static int lmc_rx(struct net_device *dev)
1573{ 1497{
1574 lmc_softc_t *sc; 1498 lmc_softc_t *sc = dev_to_sc(dev);
1575 int i; 1499 int i;
1576 int rx_work_limit = LMC_RXDESCS; 1500 int rx_work_limit = LMC_RXDESCS;
1577 unsigned int next_rx; 1501 unsigned int next_rx;
@@ -1583,8 +1507,6 @@ static int lmc_rx (struct net_device *dev) /*fold00*/
1583 1507
1584 lmc_trace(dev, "lmc_rx in"); 1508 lmc_trace(dev, "lmc_rx in");
1585 1509
1586 sc = dev->priv;
1587
1588 lmc_led_on(sc, LMC_DS3_LED3); 1510 lmc_led_on(sc, LMC_DS3_LED3);
1589 1511
1590 rxIntLoopCnt = 0; /* debug -baz */ 1512 rxIntLoopCnt = 0; /* debug -baz */
@@ -1597,39 +1519,38 @@ static int lmc_rx (struct net_device *dev) /*fold00*/
1597 rxIntLoopCnt++; /* debug -baz */ 1519 rxIntLoopCnt++; /* debug -baz */
1598 len = ((stat & LMC_RDES_FRAME_LENGTH) >> RDES_FRAME_LENGTH_BIT_NUMBER); 1520 len = ((stat & LMC_RDES_FRAME_LENGTH) >> RDES_FRAME_LENGTH_BIT_NUMBER);
1599 if ((stat & 0x0300) != 0x0300) { /* Check first segment and last segment */ 1521 if ((stat & 0x0300) != 0x0300) { /* Check first segment and last segment */
1600 if ((stat & 0x0000ffff) != 0x7fff) { 1522 if ((stat & 0x0000ffff) != 0x7fff) {
1601 /* Oversized frame */ 1523 /* Oversized frame */
1602 sc->stats.rx_length_errors++; 1524 sc->lmc_device->stats.rx_length_errors++;
1603 goto skip_packet; 1525 goto skip_packet;
1604 } 1526 }
1605 } 1527 }
1606
1607 if(stat & 0x00000008){ /* Catch a dribbling bit error */
1608 sc->stats.rx_errors++;
1609 sc->stats.rx_frame_errors++;
1610 goto skip_packet;
1611 }
1612 1528
1529 if (stat & 0x00000008) { /* Catch a dribbling bit error */
1530 sc->lmc_device->stats.rx_errors++;
1531 sc->lmc_device->stats.rx_frame_errors++;
1532 goto skip_packet;
1533 }
1613 1534
1614 if(stat & 0x00000004){ /* Catch a CRC error by the Xilinx */
1615 sc->stats.rx_errors++;
1616 sc->stats.rx_crc_errors++;
1617 goto skip_packet;
1618 }
1619 1535
1536 if (stat & 0x00000004) { /* Catch a CRC error by the Xilinx */
1537 sc->lmc_device->stats.rx_errors++;
1538 sc->lmc_device->stats.rx_crc_errors++;
1539 goto skip_packet;
1540 }
1620 1541
1621 if (len > LMC_PKT_BUF_SZ){ 1542 if (len > LMC_PKT_BUF_SZ) {
1622 sc->stats.rx_length_errors++; 1543 sc->lmc_device->stats.rx_length_errors++;
1623 localLengthErrCnt++; 1544 localLengthErrCnt++;
1624 goto skip_packet; 1545 goto skip_packet;
1625 } 1546 }
1626 1547
1627 if (len < sc->lmc_crcSize + 2) { 1548 if (len < sc->lmc_crcSize + 2) {
1628 sc->stats.rx_length_errors++; 1549 sc->lmc_device->stats.rx_length_errors++;
1629 sc->stats.rx_SmallPktCnt++; 1550 sc->extra_stats.rx_SmallPktCnt++;
1630 localLengthErrCnt++; 1551 localLengthErrCnt++;
1631 goto skip_packet; 1552 goto skip_packet;
1632 } 1553 }
1633 1554
1634 if(stat & 0x00004000){ 1555 if(stat & 0x00004000){
1635 printk(KERN_WARNING "%s: Receiver descriptor error, receiver out of sync?\n", dev->name); 1556 printk(KERN_WARNING "%s: Receiver descriptor error, receiver out of sync?\n", dev->name);
@@ -1656,8 +1577,8 @@ static int lmc_rx (struct net_device *dev) /*fold00*/
1656 } 1577 }
1657 1578
1658 dev->last_rx = jiffies; 1579 dev->last_rx = jiffies;
1659 sc->stats.rx_packets++; 1580 sc->lmc_device->stats.rx_packets++;
1660 sc->stats.rx_bytes += len; 1581 sc->lmc_device->stats.rx_bytes += len;
1661 1582
1662 LMC_CONSOLE_LOG("recv", skb->data, len); 1583 LMC_CONSOLE_LOG("recv", skb->data, len);
1663 1584
@@ -1679,7 +1600,6 @@ static int lmc_rx (struct net_device *dev) /*fold00*/
1679 1600
1680 skb_put (skb, len); 1601 skb_put (skb, len);
1681 skb->protocol = lmc_proto_type(sc, skb); 1602 skb->protocol = lmc_proto_type(sc, skb);
1682 skb->protocol = htons(ETH_P_WAN_PPP);
1683 skb_reset_mac_header(skb); 1603 skb_reset_mac_header(skb);
1684 /* skb_reset_network_header(skb); */ 1604 /* skb_reset_network_header(skb); */
1685 skb->dev = dev; 1605 skb->dev = dev;
@@ -1704,7 +1624,7 @@ static int lmc_rx (struct net_device *dev) /*fold00*/
1704 * in which care we'll try to allocate the buffer 1624 * in which care we'll try to allocate the buffer
1705 * again. (once a second) 1625 * again. (once a second)
1706 */ 1626 */
1707 sc->stats.rx_BuffAllocErr++; 1627 sc->extra_stats.rx_BuffAllocErr++;
1708 LMC_EVENT_LOG(LMC_EVENT_RCVINT, stat, len); 1628 LMC_EVENT_LOG(LMC_EVENT_RCVINT, stat, len);
1709 sc->failed_recv_alloc = 1; 1629 sc->failed_recv_alloc = 1;
1710 goto skip_out_of_mem; 1630 goto skip_out_of_mem;
@@ -1739,16 +1659,14 @@ static int lmc_rx (struct net_device *dev) /*fold00*/
1739 * descriptors with bogus packets 1659 * descriptors with bogus packets
1740 * 1660 *
1741 if (localLengthErrCnt > LMC_RXDESCS - 3) { 1661 if (localLengthErrCnt > LMC_RXDESCS - 3) {
1742 sc->stats.rx_BadPktSurgeCnt++; 1662 sc->extra_stats.rx_BadPktSurgeCnt++;
1743 LMC_EVENT_LOG(LMC_EVENT_BADPKTSURGE, 1663 LMC_EVENT_LOG(LMC_EVENT_BADPKTSURGE, localLengthErrCnt,
1744 localLengthErrCnt, 1664 sc->extra_stats.rx_BadPktSurgeCnt);
1745 sc->stats.rx_BadPktSurgeCnt);
1746 } */ 1665 } */
1747 1666
1748 /* save max count of receive descriptors serviced */ 1667 /* save max count of receive descriptors serviced */
1749 if (rxIntLoopCnt > sc->stats.rxIntLoopCnt) { 1668 if (rxIntLoopCnt > sc->extra_stats.rxIntLoopCnt)
1750 sc->stats.rxIntLoopCnt = rxIntLoopCnt; /* debug -baz */ 1669 sc->extra_stats.rxIntLoopCnt = rxIntLoopCnt; /* debug -baz */
1751 }
1752 1670
1753#ifdef DEBUG 1671#ifdef DEBUG
1754 if (rxIntLoopCnt == 0) 1672 if (rxIntLoopCnt == 0)
@@ -1775,23 +1693,22 @@ skip_out_of_mem:
1775 return 0; 1693 return 0;
1776} 1694}
1777 1695
1778static struct net_device_stats *lmc_get_stats (struct net_device *dev) /*fold00*/ 1696static struct net_device_stats *lmc_get_stats(struct net_device *dev)
1779{ 1697{
1780 lmc_softc_t *sc = dev->priv; 1698 lmc_softc_t *sc = dev_to_sc(dev);
1781 unsigned long flags; 1699 unsigned long flags;
1782 1700
1783 lmc_trace(dev, "lmc_get_stats in"); 1701 lmc_trace(dev, "lmc_get_stats in");
1784 1702
1785
1786 spin_lock_irqsave(&sc->lmc_lock, flags); 1703 spin_lock_irqsave(&sc->lmc_lock, flags);
1787 1704
1788 sc->stats.rx_missed_errors += LMC_CSR_READ (sc, csr_missed_frames) & 0xffff; 1705 sc->lmc_device->stats.rx_missed_errors += LMC_CSR_READ(sc, csr_missed_frames) & 0xffff;
1789 1706
1790 spin_unlock_irqrestore(&sc->lmc_lock, flags); 1707 spin_unlock_irqrestore(&sc->lmc_lock, flags);
1791 1708
1792 lmc_trace(dev, "lmc_get_stats out"); 1709 lmc_trace(dev, "lmc_get_stats out");
1793 1710
1794 return (struct net_device_stats *) &sc->stats; 1711 return &sc->lmc_device->stats;
1795} 1712}
1796 1713
1797static struct pci_driver lmc_driver = { 1714static struct pci_driver lmc_driver = {
@@ -1970,7 +1887,7 @@ static void lmc_softreset (lmc_softc_t * const sc) /*fold00*/
1970 { 1887 {
1971 if (sc->lmc_txq[i] != NULL){ /* have buffer */ 1888 if (sc->lmc_txq[i] != NULL){ /* have buffer */
1972 dev_kfree_skb(sc->lmc_txq[i]); /* free it */ 1889 dev_kfree_skb(sc->lmc_txq[i]); /* free it */
1973 sc->stats.tx_dropped++; /* We just dropped a packet */ 1890 sc->lmc_device->stats.tx_dropped++; /* We just dropped a packet */
1974 } 1891 }
1975 sc->lmc_txq[i] = NULL; 1892 sc->lmc_txq[i] = NULL;
1976 sc->lmc_txring[i].status = 0x00000000; 1893 sc->lmc_txring[i].status = 0x00000000;
@@ -2061,7 +1978,7 @@ static void lmc_reset(lmc_softc_t * const sc) /*fold00*/
2061 */ 1978 */
2062 sc->lmc_media->init(sc); 1979 sc->lmc_media->init(sc);
2063 1980
2064 sc->stats.resetCount++; 1981 sc->extra_stats.resetCount++;
2065 lmc_trace(sc->lmc_device, "lmc_reset out"); 1982 lmc_trace(sc->lmc_device, "lmc_reset out");
2066} 1983}
2067 1984
@@ -2151,23 +2068,21 @@ static void lmc_initcsrs(lmc_softc_t * const sc, lmc_csrptr_t csr_base, /*fold00
2151 lmc_trace(sc->lmc_device, "lmc_initcsrs out"); 2068 lmc_trace(sc->lmc_device, "lmc_initcsrs out");
2152} 2069}
2153 2070
2154static void lmc_driver_timeout(struct net_device *dev) { /*fold00*/ 2071static void lmc_driver_timeout(struct net_device *dev)
2155 lmc_softc_t *sc; 2072{
2073 lmc_softc_t *sc = dev_to_sc(dev);
2156 u32 csr6; 2074 u32 csr6;
2157 unsigned long flags; 2075 unsigned long flags;
2158 2076
2159 lmc_trace(dev, "lmc_driver_timeout in"); 2077 lmc_trace(dev, "lmc_driver_timeout in");
2160 2078
2161 sc = dev->priv;
2162
2163 spin_lock_irqsave(&sc->lmc_lock, flags); 2079 spin_lock_irqsave(&sc->lmc_lock, flags);
2164 2080
2165 printk("%s: Xmitter busy|\n", dev->name); 2081 printk("%s: Xmitter busy|\n", dev->name);
2166 2082
2167 sc->stats.tx_tbusy_calls++ ; 2083 sc->extra_stats.tx_tbusy_calls++;
2168 if (jiffies - dev->trans_start < TX_TIMEOUT) { 2084 if (jiffies - dev->trans_start < TX_TIMEOUT)
2169 goto bug_out; 2085 goto bug_out;
2170 }
2171 2086
2172 /* 2087 /*
2173 * Chip seems to have locked up 2088 * Chip seems to have locked up
@@ -2178,7 +2093,7 @@ static void lmc_driver_timeout(struct net_device *dev) { /*fold00*/
2178 2093
2179 LMC_EVENT_LOG(LMC_EVENT_XMTPRCTMO, 2094 LMC_EVENT_LOG(LMC_EVENT_XMTPRCTMO,
2180 LMC_CSR_READ (sc, csr_status), 2095 LMC_CSR_READ (sc, csr_status),
2181 sc->stats.tx_ProcTimeout); 2096 sc->extra_stats.tx_ProcTimeout);
2182 2097
2183 lmc_running_reset (dev); 2098 lmc_running_reset (dev);
2184 2099
@@ -2195,8 +2110,8 @@ static void lmc_driver_timeout(struct net_device *dev) { /*fold00*/
2195 /* immediate transmit */ 2110 /* immediate transmit */
2196 LMC_CSR_WRITE (sc, csr_txpoll, 0); 2111 LMC_CSR_WRITE (sc, csr_txpoll, 0);
2197 2112
2198 sc->stats.tx_errors++; 2113 sc->lmc_device->stats.tx_errors++;
2199 sc->stats.tx_ProcTimeout++; /* -baz */ 2114 sc->extra_stats.tx_ProcTimeout++; /* -baz */
2200 2115
2201 dev->trans_start = jiffies; 2116 dev->trans_start = jiffies;
2202 2117
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index 1cc5834ebbc2..2e0711a956cc 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -425,7 +425,7 @@ lmc_ds3_set_scram (lmc_softc_t * const sc, int ie)
425static int 425static int
426lmc_ds3_get_link_status (lmc_softc_t * const sc) 426lmc_ds3_get_link_status (lmc_softc_t * const sc)
427{ 427{
428 u_int16_t link_status, link_status_11; 428 u16 link_status, link_status_11;
429 int ret = 1; 429 int ret = 1;
430 430
431 lmc_mii_writereg (sc, 0, 17, 7); 431 lmc_mii_writereg (sc, 0, 17, 7);
@@ -447,7 +447,7 @@ lmc_ds3_get_link_status (lmc_softc_t * const sc)
447 (link_status & LMC_FRAMER_REG0_OOFS)){ 447 (link_status & LMC_FRAMER_REG0_OOFS)){
448 ret = 0; 448 ret = 0;
449 if(sc->last_led_err[3] != 1){ 449 if(sc->last_led_err[3] != 1){
450 u16 r1; 450 u16 r1;
451 lmc_mii_writereg (sc, 0, 17, 01); /* Turn on Xbit error as our cisco does */ 451 lmc_mii_writereg (sc, 0, 17, 01); /* Turn on Xbit error as our cisco does */
452 r1 = lmc_mii_readreg (sc, 0, 18); 452 r1 = lmc_mii_readreg (sc, 0, 18);
453 r1 &= 0xfe; 453 r1 &= 0xfe;
@@ -460,7 +460,7 @@ lmc_ds3_get_link_status (lmc_softc_t * const sc)
460 else { 460 else {
461 lmc_led_off(sc, LMC_DS3_LED3); /* turn on red LED */ 461 lmc_led_off(sc, LMC_DS3_LED3); /* turn on red LED */
462 if(sc->last_led_err[3] == 1){ 462 if(sc->last_led_err[3] == 1){
463 u16 r1; 463 u16 r1;
464 lmc_mii_writereg (sc, 0, 17, 01); /* Turn off Xbit error */ 464 lmc_mii_writereg (sc, 0, 17, 01); /* Turn off Xbit error */
465 r1 = lmc_mii_readreg (sc, 0, 18); 465 r1 = lmc_mii_readreg (sc, 0, 18);
466 r1 |= 0x01; 466 r1 |= 0x01;
@@ -538,20 +538,19 @@ lmc_ds3_watchdog (lmc_softc_t * const sc)
538 * SSI methods 538 * SSI methods
539 */ 539 */
540 540
541static void 541static void lmc_ssi_init(lmc_softc_t * const sc)
542lmc_ssi_init (lmc_softc_t * const sc)
543{ 542{
544 u_int16_t mii17; 543 u16 mii17;
545 int cable; 544 int cable;
546 545
547 sc->ictl.cardtype = LMC_CTL_CARDTYPE_LMC1000; 546 sc->ictl.cardtype = LMC_CTL_CARDTYPE_LMC1000;
548 547
549 mii17 = lmc_mii_readreg (sc, 0, 17); 548 mii17 = lmc_mii_readreg(sc, 0, 17);
550 549
551 cable = (mii17 & LMC_MII17_SSI_CABLE_MASK) >> LMC_MII17_SSI_CABLE_SHIFT; 550 cable = (mii17 & LMC_MII17_SSI_CABLE_MASK) >> LMC_MII17_SSI_CABLE_SHIFT;
552 sc->ictl.cable_type = cable; 551 sc->ictl.cable_type = cable;
553 552
554 lmc_gpio_mkoutput (sc, LMC_GEP_SSI_TXCLOCK); 553 lmc_gpio_mkoutput(sc, LMC_GEP_SSI_TXCLOCK);
555} 554}
556 555
557static void 556static void
@@ -679,11 +678,11 @@ lmc_ssi_set_speed (lmc_softc_t * const sc, lmc_ctl_t * ctl)
679static int 678static int
680lmc_ssi_get_link_status (lmc_softc_t * const sc) 679lmc_ssi_get_link_status (lmc_softc_t * const sc)
681{ 680{
682 u_int16_t link_status; 681 u16 link_status;
683 u_int32_t ticks; 682 u_int32_t ticks;
684 int ret = 1; 683 int ret = 1;
685 int hw_hdsk = 1; 684 int hw_hdsk = 1;
686 685
687 /* 686 /*
688 * missing CTS? Hmm. If we require CTS on, we may never get the 687 * missing CTS? Hmm. If we require CTS on, we may never get the
689 * link to come up, so omit it in this test. 688 * link to come up, so omit it in this test.
@@ -718,9 +717,9 @@ lmc_ssi_get_link_status (lmc_softc_t * const sc)
718 } 717 }
719 else if (ticks == 0 ) { /* no clock found ? */ 718 else if (ticks == 0 ) { /* no clock found ? */
720 ret = 0; 719 ret = 0;
721 if(sc->last_led_err[3] != 1){ 720 if (sc->last_led_err[3] != 1) {
722 sc->stats.tx_lossOfClockCnt++; 721 sc->extra_stats.tx_lossOfClockCnt++;
723 printk(KERN_WARNING "%s: Lost Clock, Link Down\n", sc->name); 722 printk(KERN_WARNING "%s: Lost Clock, Link Down\n", sc->name);
724 } 723 }
725 sc->last_led_err[3] = 1; 724 sc->last_led_err[3] = 1;
726 lmc_led_on (sc, LMC_MII16_LED3); /* turn ON red LED */ 725 lmc_led_on (sc, LMC_MII16_LED3); /* turn ON red LED */
@@ -885,19 +884,13 @@ write_av9110 (lmc_softc_t * sc, u_int32_t n, u_int32_t m, u_int32_t v,
885 | LMC_GEP_SSI_GENERATOR)); 884 | LMC_GEP_SSI_GENERATOR));
886} 885}
887 886
888static void 887static void lmc_ssi_watchdog(lmc_softc_t * const sc)
889lmc_ssi_watchdog (lmc_softc_t * const sc)
890{ 888{
891 u_int16_t mii17 = lmc_mii_readreg (sc, 0, 17); 889 u16 mii17 = lmc_mii_readreg(sc, 0, 17);
892 if (((mii17 >> 3) & 7) == 7) 890 if (((mii17 >> 3) & 7) == 7)
893 { 891 lmc_led_off(sc, LMC_MII16_LED2);
894 lmc_led_off (sc, LMC_MII16_LED2); 892 else
895 } 893 lmc_led_on(sc, LMC_MII16_LED2);
896 else
897 {
898 lmc_led_on (sc, LMC_MII16_LED2);
899 }
900
901} 894}
902 895
903/* 896/*
@@ -927,7 +920,7 @@ lmc_t1_read (lmc_softc_t * const sc, int a)
927static void 920static void
928lmc_t1_init (lmc_softc_t * const sc) 921lmc_t1_init (lmc_softc_t * const sc)
929{ 922{
930 u_int16_t mii16; 923 u16 mii16;
931 int i; 924 int i;
932 925
933 sc->ictl.cardtype = LMC_CTL_CARDTYPE_LMC1200; 926 sc->ictl.cardtype = LMC_CTL_CARDTYPE_LMC1200;
@@ -1026,7 +1019,7 @@ lmc_t1_set_status (lmc_softc_t * const sc, lmc_ctl_t * ctl)
1026 */ static int 1019 */ static int
1027lmc_t1_get_link_status (lmc_softc_t * const sc) 1020lmc_t1_get_link_status (lmc_softc_t * const sc)
1028{ 1021{
1029 u_int16_t link_status; 1022 u16 link_status;
1030 int ret = 1; 1023 int ret = 1;
1031 1024
1032 /* LMC5245 (DS3) & LMC1200 (DS1) LED definitions 1025 /* LMC5245 (DS3) & LMC1200 (DS1) LED definitions
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
index 85315758198d..be9877ff551e 100644
--- a/drivers/net/wan/lmc/lmc_proto.c
+++ b/drivers/net/wan/lmc/lmc_proto.c
@@ -36,9 +36,6 @@
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
38#include <linux/bitops.h> 38#include <linux/bitops.h>
39
40#include <net/syncppp.h>
41
42#include <asm/processor.h> /* Processor type for cache alignment. */ 39#include <asm/processor.h> /* Processor type for cache alignment. */
43#include <asm/io.h> 40#include <asm/io.h>
44#include <asm/dma.h> 41#include <asm/dma.h>
@@ -50,48 +47,6 @@
50#include "lmc_ioctl.h" 47#include "lmc_ioctl.h"
51#include "lmc_proto.h" 48#include "lmc_proto.h"
52 49
53/*
54 * The compile-time variable SPPPSTUP causes the module to be
55 * compiled without referencing any of the sync ppp routines.
56 */
57#ifdef SPPPSTUB
58#define SPPP_detach(d) (void)0
59#define SPPP_open(d) 0
60#define SPPP_reopen(d) (void)0
61#define SPPP_close(d) (void)0
62#define SPPP_attach(d) (void)0
63#define SPPP_do_ioctl(d,i,c) -EOPNOTSUPP
64#else
65#define SPPP_attach(x) sppp_attach((x)->pd)
66#define SPPP_detach(x) sppp_detach((x)->pd->dev)
67#define SPPP_open(x) sppp_open((x)->pd->dev)
68#define SPPP_reopen(x) sppp_reopen((x)->pd->dev)
69#define SPPP_close(x) sppp_close((x)->pd->dev)
70#define SPPP_do_ioctl(x, y, z) sppp_do_ioctl((x)->pd->dev, (y), (z))
71#endif
72
73// init
74void lmc_proto_init(lmc_softc_t *sc) /*FOLD00*/
75{
76 lmc_trace(sc->lmc_device, "lmc_proto_init in");
77 switch(sc->if_type){
78 case LMC_PPP:
79 sc->pd = kmalloc(sizeof(struct ppp_device), GFP_KERNEL);
80 if (!sc->pd) {
81 printk("lmc_proto_init(): kmalloc failure!\n");
82 return;
83 }
84 sc->pd->dev = sc->lmc_device;
85 sc->if_ptr = sc->pd;
86 break;
87 case LMC_RAW:
88 break;
89 default:
90 break;
91 }
92 lmc_trace(sc->lmc_device, "lmc_proto_init out");
93}
94
95// attach 50// attach
96void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/ 51void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
97{ 52{
@@ -100,7 +55,6 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
100 case LMC_PPP: 55 case LMC_PPP:
101 { 56 {
102 struct net_device *dev = sc->lmc_device; 57 struct net_device *dev = sc->lmc_device;
103 SPPP_attach(sc);
104 dev->do_ioctl = lmc_ioctl; 58 dev->do_ioctl = lmc_ioctl;
105 } 59 }
106 break; 60 break;
@@ -108,7 +62,7 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
108 { 62 {
109 struct net_device *dev = sc->lmc_device; 63 struct net_device *dev = sc->lmc_device;
110 /* 64 /*
111 * They set a few basics because they don't use sync_ppp 65 * They set a few basics because they don't use HDLC
112 */ 66 */
113 dev->flags |= IFF_POINTOPOINT; 67 dev->flags |= IFF_POINTOPOINT;
114 68
@@ -124,88 +78,39 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
124 lmc_trace(sc->lmc_device, "lmc_proto_attach out"); 78 lmc_trace(sc->lmc_device, "lmc_proto_attach out");
125} 79}
126 80
127// detach 81int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd)
128void lmc_proto_detach(lmc_softc_t *sc) /*FOLD00*/
129{ 82{
130 switch(sc->if_type){ 83 lmc_trace(sc->lmc_device, "lmc_proto_ioctl");
131 case LMC_PPP: 84 if (sc->if_type == LMC_PPP)
132 SPPP_detach(sc); 85 return hdlc_ioctl(sc->lmc_device, ifr, cmd);
133 break; 86 return -EOPNOTSUPP;
134 case LMC_RAW: /* Tell someone we're detaching? */
135 break;
136 default:
137 break;
138 }
139
140} 87}
141 88
142// reopen 89int lmc_proto_open(lmc_softc_t *sc)
143void lmc_proto_reopen(lmc_softc_t *sc) /*FOLD00*/
144{ 90{
145 lmc_trace(sc->lmc_device, "lmc_proto_reopen in"); 91 int ret = 0;
146 switch(sc->if_type){
147 case LMC_PPP:
148 SPPP_reopen(sc);
149 break;
150 case LMC_RAW: /* Reset the interface after being down, prerape to receive packets again */
151 break;
152 default:
153 break;
154 }
155 lmc_trace(sc->lmc_device, "lmc_proto_reopen out");
156}
157 92
93 lmc_trace(sc->lmc_device, "lmc_proto_open in");
158 94
159// ioctl 95 if (sc->if_type == LMC_PPP) {
160int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd) /*FOLD00*/ 96 ret = hdlc_open(sc->lmc_device);
161{ 97 if (ret < 0)
162 lmc_trace(sc->lmc_device, "lmc_proto_ioctl out"); 98 printk(KERN_WARNING "%s: HDLC open failed: %d\n",
163 switch(sc->if_type){ 99 sc->name, ret);
164 case LMC_PPP: 100 }
165 return SPPP_do_ioctl (sc, ifr, cmd); 101
166 break; 102 lmc_trace(sc->lmc_device, "lmc_proto_open out");
167 default: 103 return ret;
168 return -EOPNOTSUPP;
169 break;
170 }
171 lmc_trace(sc->lmc_device, "lmc_proto_ioctl out");
172} 104}
173 105
174// open 106void lmc_proto_close(lmc_softc_t *sc)
175void lmc_proto_open(lmc_softc_t *sc) /*FOLD00*/
176{ 107{
177 int ret; 108 lmc_trace(sc->lmc_device, "lmc_proto_close in");
178 109
179 lmc_trace(sc->lmc_device, "lmc_proto_open in"); 110 if (sc->if_type == LMC_PPP)
180 switch(sc->if_type){ 111 hdlc_close(sc->lmc_device);
181 case LMC_PPP:
182 ret = SPPP_open(sc);
183 if(ret < 0)
184 printk("%s: syncPPP open failed: %d\n", sc->name, ret);
185 break;
186 case LMC_RAW: /* We're about to start getting packets! */
187 break;
188 default:
189 break;
190 }
191 lmc_trace(sc->lmc_device, "lmc_proto_open out");
192}
193
194// close
195 112
196void lmc_proto_close(lmc_softc_t *sc) /*FOLD00*/ 113 lmc_trace(sc->lmc_device, "lmc_proto_close out");
197{
198 lmc_trace(sc->lmc_device, "lmc_proto_close in");
199 switch(sc->if_type){
200 case LMC_PPP:
201 SPPP_close(sc);
202 break;
203 case LMC_RAW: /* Interface going down */
204 break;
205 default:
206 break;
207 }
208 lmc_trace(sc->lmc_device, "lmc_proto_close out");
209} 114}
210 115
211__be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/ 116__be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
@@ -213,8 +118,8 @@ __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
213 lmc_trace(sc->lmc_device, "lmc_proto_type in"); 118 lmc_trace(sc->lmc_device, "lmc_proto_type in");
214 switch(sc->if_type){ 119 switch(sc->if_type){
215 case LMC_PPP: 120 case LMC_PPP:
216 return htons(ETH_P_WAN_PPP); 121 return hdlc_type_trans(skb, sc->lmc_device);
217 break; 122 break;
218 case LMC_NET: 123 case LMC_NET:
219 return htons(ETH_P_802_2); 124 return htons(ETH_P_802_2);
220 break; 125 break;
@@ -245,4 +150,3 @@ void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
245 } 150 }
246 lmc_trace(sc->lmc_device, "lmc_proto_netif out"); 151 lmc_trace(sc->lmc_device, "lmc_proto_netif out");
247} 152}
248
diff --git a/drivers/net/wan/lmc/lmc_proto.h b/drivers/net/wan/lmc/lmc_proto.h
index ccaa69e8b3c7..662148c54644 100644
--- a/drivers/net/wan/lmc/lmc_proto.h
+++ b/drivers/net/wan/lmc/lmc_proto.h
@@ -1,16 +1,18 @@
1#ifndef _LMC_PROTO_H_ 1#ifndef _LMC_PROTO_H_
2#define _LMC_PROTO_H_ 2#define _LMC_PROTO_H_
3 3
4void lmc_proto_init(lmc_softc_t *sc); 4#include <linux/hdlc.h>
5
5void lmc_proto_attach(lmc_softc_t *sc); 6void lmc_proto_attach(lmc_softc_t *sc);
6void lmc_proto_detach(lmc_softc_t *sc);
7void lmc_proto_reopen(lmc_softc_t *sc);
8int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd); 7int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd);
9void lmc_proto_open(lmc_softc_t *sc); 8int lmc_proto_open(lmc_softc_t *sc);
10void lmc_proto_close(lmc_softc_t *sc); 9void lmc_proto_close(lmc_softc_t *sc);
11__be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb); 10__be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb);
12void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb); 11void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb);
13int lmc_skb_rawpackets(char *buf, char **start, off_t offset, int len, int unused);
14 12
15#endif 13static inline lmc_softc_t* dev_to_sc(struct net_device *dev)
14{
15 return (lmc_softc_t *)dev_to_hdlc(dev)->priv;
16}
16 17
18#endif
diff --git a/drivers/net/wan/lmc/lmc_var.h b/drivers/net/wan/lmc/lmc_var.h
index 6d003a39bfad..52e044209d50 100644
--- a/drivers/net/wan/lmc/lmc_var.h
+++ b/drivers/net/wan/lmc/lmc_var.h
@@ -1,8 +1,6 @@
1#ifndef _LMC_VAR_H_ 1#ifndef _LMC_VAR_H_
2#define _LMC_VAR_H_ 2#define _LMC_VAR_H_
3 3
4/* $Id: lmc_var.h,v 1.17 2000/04/06 12:16:47 asj Exp $ */
5
6 /* 4 /*
7 * Copyright (c) 1997-2000 LAN Media Corporation (LMC) 5 * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
8 * All rights reserved. www.lanmedia.com 6 * All rights reserved. www.lanmedia.com
@@ -19,23 +17,6 @@
19 17
20#include <linux/timer.h> 18#include <linux/timer.h>
21 19
22#ifndef __KERNEL__
23typedef signed char s8;
24typedef unsigned char u8;
25
26typedef signed short s16;
27typedef unsigned short u16;
28
29typedef signed int s32;
30typedef unsigned int u32;
31
32typedef signed long long s64;
33typedef unsigned long long u64;
34
35#define BITS_PER_LONG 32
36
37#endif
38
39/* 20/*
40 * basic definitions used in lmc include files 21 * basic definitions used in lmc include files
41 */ 22 */
@@ -45,9 +26,6 @@ typedef struct lmc___media lmc_media_t;
45typedef struct lmc___ctl lmc_ctl_t; 26typedef struct lmc___ctl lmc_ctl_t;
46 27
47#define lmc_csrptr_t unsigned long 28#define lmc_csrptr_t unsigned long
48#define u_int16_t u16
49#define u_int8_t u8
50#define tulip_uint32_t u32
51 29
52#define LMC_REG_RANGE 0x80 30#define LMC_REG_RANGE 0x80
53 31
@@ -244,46 +222,8 @@ struct lmc___media {
244 222
245#define STATCHECK 0xBEEFCAFE 223#define STATCHECK 0xBEEFCAFE
246 224
247/* Included in this structure are first 225struct lmc_extra_statistics
248 * - standard net_device_stats
249 * - some other counters used for debug and driver performance
250 * evaluation -baz
251 */
252struct lmc_statistics
253{ 226{
254 unsigned long rx_packets; /* total packets received */
255 unsigned long tx_packets; /* total packets transmitted */
256 unsigned long rx_bytes;
257 unsigned long tx_bytes;
258
259 unsigned long rx_errors; /* bad packets received */
260 unsigned long tx_errors; /* packet transmit problems */
261 unsigned long rx_dropped; /* no space in linux buffers */
262 unsigned long tx_dropped; /* no space available in linux */
263 unsigned long multicast; /* multicast packets received */
264 unsigned long collisions;
265
266 /* detailed rx_errors: */
267 unsigned long rx_length_errors;
268 unsigned long rx_over_errors; /* receiver ring buff overflow */
269 unsigned long rx_crc_errors; /* recved pkt with crc error */
270 unsigned long rx_frame_errors; /* recv'd frame alignment error */
271 unsigned long rx_fifo_errors; /* recv'r fifo overrun */
272 unsigned long rx_missed_errors; /* receiver missed packet */
273
274 /* detailed tx_errors */
275 unsigned long tx_aborted_errors;
276 unsigned long tx_carrier_errors;
277 unsigned long tx_fifo_errors;
278 unsigned long tx_heartbeat_errors;
279 unsigned long tx_window_errors;
280
281 /* for cslip etc */
282 unsigned long rx_compressed;
283 unsigned long tx_compressed;
284
285 /* -------------------------------------
286 * Custom stats & counters follow -baz */
287 u_int32_t version_size; 227 u_int32_t version_size;
288 u_int32_t lmc_cardtype; 228 u_int32_t lmc_cardtype;
289 229
@@ -325,27 +265,26 @@ struct lmc_statistics
325 u_int32_t check; 265 u_int32_t check;
326}; 266};
327 267
328
329typedef struct lmc_xinfo { 268typedef struct lmc_xinfo {
330 u_int32_t Magic0; /* BEEFCAFE */ 269 u_int32_t Magic0; /* BEEFCAFE */
331 270
332 u_int32_t PciCardType; 271 u_int32_t PciCardType;
333 u_int32_t PciSlotNumber; /* PCI slot number */ 272 u_int32_t PciSlotNumber; /* PCI slot number */
334 273
335 u_int16_t DriverMajorVersion; 274 u16 DriverMajorVersion;
336 u_int16_t DriverMinorVersion; 275 u16 DriverMinorVersion;
337 u_int16_t DriverSubVersion; 276 u16 DriverSubVersion;
338 277
339 u_int16_t XilinxRevisionNumber; 278 u16 XilinxRevisionNumber;
340 u_int16_t MaxFrameSize; 279 u16 MaxFrameSize;
341 280
342 u_int16_t t1_alarm1_status; 281 u16 t1_alarm1_status;
343 u_int16_t t1_alarm2_status; 282 u16 t1_alarm2_status;
344 283
345 int link_status; 284 int link_status;
346 u_int32_t mii_reg16; 285 u_int32_t mii_reg16;
347 286
348 u_int32_t Magic1; /* DEADBEEF */ 287 u_int32_t Magic1; /* DEADBEEF */
349} LMC_XINFO; 288} LMC_XINFO;
350 289
351 290
@@ -353,11 +292,10 @@ typedef struct lmc_xinfo {
353 * forward decl 292 * forward decl
354 */ 293 */
355struct lmc___softc { 294struct lmc___softc {
356 void *if_ptr; /* General purpose pointer (used by SPPP) */
357 char *name; 295 char *name;
358 u8 board_idx; 296 u8 board_idx;
359 struct lmc_statistics stats; 297 struct lmc_extra_statistics extra_stats;
360 struct net_device *lmc_device; 298 struct net_device *lmc_device;
361 299
362 int hang, rxdesc, bad_packet, some_counter; 300 int hang, rxdesc, bad_packet, some_counter;
363 u_int32_t txgo; 301 u_int32_t txgo;
@@ -381,7 +319,7 @@ struct lmc___softc {
381 unsigned int lmc_taint_tx, lmc_taint_rx; 319 unsigned int lmc_taint_tx, lmc_taint_rx;
382 int lmc_tx_start, lmc_txfull; 320 int lmc_tx_start, lmc_txfull;
383 int lmc_txbusy; 321 int lmc_txbusy;
384 u_int16_t lmc_miireg16; 322 u16 lmc_miireg16;
385 int lmc_ok; 323 int lmc_ok;
386 int last_link_status; 324 int last_link_status;
387 int lmc_cardtype; 325 int lmc_cardtype;
@@ -408,8 +346,7 @@ struct lmc___softc {
408 u32 num_int; 346 u32 num_int;
409 347
410 spinlock_t lmc_lock; 348 spinlock_t lmc_lock;
411 u_int16_t if_type; /* PPP or NET */ 349 u16 if_type; /* HDLC/PPP or NET */
412 struct ppp_device *pd;
413 350
414 /* Failure cases */ 351 /* Failure cases */
415 u8 failed_ring; 352 u8 failed_ring;
@@ -525,46 +462,9 @@ struct lmc___softc {
525#define LMC_ADAP_SSI 4 462#define LMC_ADAP_SSI 4
526#define LMC_ADAP_T1 5 463#define LMC_ADAP_T1 5
527 464
528#define HDLC_HDR_LEN 4
529#define HDLC_ADDR_LEN 1
530#define HDLC_SLARP 0x8035
531#define LMC_MTU 1500 465#define LMC_MTU 1500
532#define SLARP_LINECHECK 2
533 466
534#define LMC_CRC_LEN_16 2 /* 16-bit CRC */ 467#define LMC_CRC_LEN_16 2 /* 16-bit CRC */
535#define LMC_CRC_LEN_32 4 468#define LMC_CRC_LEN_32 4
536 469
537#ifdef LMC_HDLC
538/* definition of an hdlc header. */
539struct hdlc_hdr
540{
541 u8 address;
542 u8 control;
543 u16 type;
544};
545
546/* definition of a slarp header. */
547struct slarp
548{
549 long code;
550 union sl
551 {
552 struct
553 {
554 ulong address;
555 ulong mask;
556 ushort unused;
557 } add;
558 struct
559 {
560 ulong mysequence;
561 ulong yoursequence;
562 ushort reliability;
563 ulong time;
564 } chk;
565 } t;
566};
567#endif /* LMC_HDLC */
568
569
570#endif /* _LMC_VAR_H_ */ 470#endif /* _LMC_VAR_H_ */