1 // SPDX-License-Identifier: GPL-2.0-only
2  /*
3   * Copyright (c) 1997-2000 LAN Media Corporation (LMC)
4   * All rights reserved.  www.lanmedia.com
5   *
6   * This code is written by:
7   * Andrew Stanley-Jones (asj@cban.com)
8   * Rob Braun (bbraun@vix.com),
9   * Michael Graff (explorer@vix.com) and
10   * Matt Thomas (matt@3am-software.com).
11   *
12   * With Help By:
13   * David Boggs
14   * Ron Crane
15   * Allan Cox
16   *
17   * Driver for the LanMedia LMC5200, LMC5245, LMC1000, LMC1200 cards.
18   */
19 
20 #include <linux/kernel.h>
21 #include <linux/string.h>
22 #include <linux/timer.h>
23 #include <linux/ptrace.h>
24 #include <linux/errno.h>
25 #include <linux/ioport.h>
26 #include <linux/interrupt.h>
27 #include <linux/in.h>
28 #include <linux/if_arp.h>
29 #include <linux/netdevice.h>
30 #include <linux/etherdevice.h>
31 #include <linux/skbuff.h>
32 #include <linux/inet.h>
33 #include <linux/workqueue.h>
34 #include <linux/proc_fs.h>
35 #include <linux/bitops.h>
36 #include <asm/processor.h>             /* Processor type for cache alignment. */
37 #include <asm/io.h>
38 #include <asm/dma.h>
39 #include <linux/smp.h>
40 
41 #include "lmc.h"
42 #include "lmc_var.h"
43 #include "lmc_debug.h"
44 #include "lmc_ioctl.h"
45 #include "lmc_proto.h"
46 
47 // attach
lmc_proto_attach(lmc_softc_t * sc)48 void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
49 {
50     if (sc->if_type == LMC_NET) {
51             struct net_device *dev = sc->lmc_device;
52             /*
53 	     * They set a few basics because they don't use HDLC
54              */
55             dev->flags |= IFF_POINTOPOINT;
56             dev->hard_header_len = 0;
57             dev->addr_len = 0;
58         }
59 }
60 
lmc_proto_open(lmc_softc_t * sc)61 int lmc_proto_open(lmc_softc_t *sc)
62 {
63 	int ret = 0;
64 
65 	if (sc->if_type == LMC_PPP) {
66 		ret = hdlc_open(sc->lmc_device);
67 		if (ret < 0)
68 			printk(KERN_WARNING "%s: HDLC open failed: %d\n",
69 			       sc->name, ret);
70 	}
71 	return ret;
72 }
73 
lmc_proto_close(lmc_softc_t * sc)74 void lmc_proto_close(lmc_softc_t *sc)
75 {
76 	if (sc->if_type == LMC_PPP)
77 		hdlc_close(sc->lmc_device);
78 }
79 
lmc_proto_type(lmc_softc_t * sc,struct sk_buff * skb)80 __be16 lmc_proto_type(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
81 {
82     switch(sc->if_type){
83     case LMC_PPP:
84 	    return hdlc_type_trans(skb, sc->lmc_device);
85     case LMC_NET:
86         return htons(ETH_P_802_2);
87     case LMC_RAW: /* Packet type for skbuff kind of useless */
88         return htons(ETH_P_802_2);
89     default:
90         printk(KERN_WARNING "%s: No protocol set for this interface, assuming 802.2 (which is wrong!!)\n", sc->name);
91         return htons(ETH_P_802_2);
92     }
93 }
94 
lmc_proto_netif(lmc_softc_t * sc,struct sk_buff * skb)95 void lmc_proto_netif(lmc_softc_t *sc, struct sk_buff *skb) /*FOLD00*/
96 {
97     switch(sc->if_type){
98     case LMC_PPP:
99     case LMC_NET:
100     default:
101         netif_rx(skb);
102         break;
103     case LMC_RAW:
104         break;
105     }
106 }
107