blob: 044a48175c42e4d4076d950cc23b0a2ffc162765 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001 /*
2 * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
3 * All rights reserved. www.lanmedia.com
4 *
5 * This code is written by:
6 * Andrew Stanley-Jones (asj@cban.com)
7 * Rob Braun (bbraun@vix.com),
8 * Michael Graff (explorer@vix.com) and
9 * Matt Thomas (matt@3am-software.com).
10 *
11 * With Help By:
12 * David Boggs
13 * Ron Crane
14 * Allan Cox
15 *
16 * This software may be used and distributed according to the terms
17 * of the GNU General Public License version 2, incorporated herein by reference.
18 *
19 * Driver for the LanMedia LMC5200, LMC5245, LMC1000, LMC1200 cards.
20 */
21
22#include <linux/kernel.h>
23#include <linux/string.h>
24#include <linux/timer.h>
25#include <linux/ptrace.h>
26#include <linux/errno.h>
27#include <linux/ioport.h>
28#include <linux/slab.h>
29#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/in.h>
31#include <linux/if_arp.h>
32#include <linux/netdevice.h>
33#include <linux/etherdevice.h>
34#include <linux/skbuff.h>
35#include <linux/inet.h>
36#include <linux/workqueue.h>
37#include <linux/proc_fs.h>
38#include <linux/bitops.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <asm/processor.h> /* Processor type for cache alignment. */
40#include <asm/io.h>
41#include <asm/dma.h>
42#include <linux/smp.h>
43
44#include "lmc.h"
45#include "lmc_var.h"
46#include "lmc_debug.h"
47#include "lmc_ioctl.h"
48#include "lmc_proto.h"
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050// attach
51void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
52{
53 lmc_trace(sc->lmc_device, "lmc_proto_attach in");
Krzysztof Hałasa991990a2009-01-08 22:52:11 +010054 if (sc->if_type == LMC_NET) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 struct net_device *dev = sc->lmc_device;
56 /*
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020057 * They set a few basics because they don't use HDLC
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 */
59 dev->flags |= IFF_POINTOPOINT;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 dev->hard_header_len = 0;
61 dev->addr_len = 0;
62 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 lmc_trace(sc->lmc_device, "lmc_proto_attach out");
64}
65
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020066int lmc_proto_ioctl(lmc_softc_t *sc, struct ifreq *ifr, int cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067{
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020068 lmc_trace(sc->lmc_device, "lmc_proto_ioctl");
69 if (sc->if_type == LMC_PPP)
70 return hdlc_ioctl(sc->lmc_device, ifr, cmd);
71 return -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020074int lmc_proto_open(lmc_softc_t *sc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020076 int ret = 0;
77
78 lmc_trace(sc->lmc_device, "lmc_proto_open in");
79
80 if (sc->if_type == LMC_PPP) {
81 ret = hdlc_open(sc->lmc_device);
82 if (ret < 0)
83 printk(KERN_WARNING "%s: HDLC open failed: %d\n",
84 sc->name, ret);
85 }
86
87 lmc_trace(sc->lmc_device, "lmc_proto_open out");
88 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
90
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020091void lmc_proto_close(lmc_softc_t *sc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020093 lmc_trace(sc->lmc_device, "lmc_proto_close in");
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020095 if (sc->if_type == LMC_PPP)
96 hdlc_close(sc->lmc_device);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Krzysztof Hałasa64bef762008-07-02 20:46:21 +020098 lmc_trace(sc->lmc_device, "lmc_proto_close out");
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
Al Viro904584012007-12-22 17:52:52 +0000101__be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
103 lmc_trace(sc->lmc_device, "lmc_proto_type in");
104 switch(sc->if_type){
105 case LMC_PPP:
Krzysztof Hałasa64bef762008-07-02 20:46:21 +0200106 return hdlc_type_trans(skb, sc->lmc_device);
107 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 case LMC_NET:
109 return htons(ETH_P_802_2);
110 break;
111 case LMC_RAW: /* Packet type for skbuff kind of useless */
112 return htons(ETH_P_802_2);
113 break;
114 default:
115 printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
116 return htons(ETH_P_802_2);
117 break;
118 }
119 lmc_trace(sc->lmc_device, "lmc_proto_tye out");
120
121}
122
123void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
124{
125 lmc_trace(sc->lmc_device, "lmc_proto_netif in");
126 switch(sc->if_type){
127 case LMC_PPP:
128 case LMC_NET:
129 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 netif_rx(skb);
131 break;
132 case LMC_RAW:
133 break;
134 }
135 lmc_trace(sc->lmc_device, "lmc_proto_netif out");
136}