This source file includes following definitions.
- loopback_xmit
- get_stats
- loopback_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <linux/config.h>
20 #include <linux/kernel.h>
21 #include <linux/sched.h>
22 #include <linux/fs.h>
23 #include <linux/types.h>
24 #include <linux/string.h>
25 #include <linux/socket.h>
26 #include <linux/errno.h>
27 #include <linux/fcntl.h>
28 #include <linux/in.h>
29 #include <linux/if_ether.h>
30
31 #include <asm/system.h>
32 #include <asm/segment.h>
33 #include <asm/io.h>
34
35 #include <linux/inet.h>
36 #include <linux/netdevice.h>
37 #include <linux/etherdevice.h>
38 #include <linux/skbuff.h>
39
40
41 static int
42 loopback_xmit(struct sk_buff *skb, struct device *dev)
43 {
44 struct enet_statistics *stats = (struct enet_statistics *)dev->priv;
45 int done;
46
47 DPRINTF((DBG_LOOPB, "loopback_xmit(dev=%X, skb=%X)\n", dev, skb));
48 if (skb == NULL || dev == NULL) return(0);
49
50 cli();
51 if (dev->tbusy != 0) {
52 sti();
53 stats->tx_errors++;
54 return(1);
55 }
56 dev->tbusy = 1;
57 sti();
58
59 done = dev_rint(skb->data, skb->len, 0, dev);
60 if (skb->free) kfree_skb(skb, FREE_WRITE);
61
62 while (done != 1) {
63 done = dev_rint(NULL, 0, 0, dev);
64 }
65 stats->tx_packets++;
66
67 dev->tbusy = 0;
68
69 #if 1
70 __asm__("cmpl $0,_intr_count\n\t"
71 "jne 1f\n\t"
72 "movl _bh_active,%%eax\n\t"
73 "testl _bh_mask,%%eax\n\t"
74 "je 1f\n\t"
75 "incl _intr_count\n\t"
76 "call _do_bottom_half\n\t"
77 "decl _intr_count\n"
78 "1:"
79 :
80 :
81 : "ax", "dx", "cx");
82 #endif
83
84 return(0);
85 }
86
87 static struct enet_statistics *
88 get_stats(struct device *dev)
89 {
90 return (struct enet_statistics *)dev->priv;
91 }
92
93
94 int
95 loopback_init(struct device *dev)
96 {
97 int i;
98
99 dev->mtu = 2000;
100 dev->tbusy = 0;
101 dev->hard_start_xmit = loopback_xmit;
102 dev->open = NULL;
103 #if 1
104 dev->hard_header = eth_header;
105 dev->hard_header_len = ETH_HLEN;
106 dev->addr_len = ETH_ALEN;
107 dev->type = ARPHRD_ETHER;
108 dev->type_trans = eth_type_trans;
109 dev->rebuild_header = eth_rebuild_header;
110 #else
111 dev->hard_header_length = 0;
112 dev->addr_len = 0;
113 dev->type = 0;
114 dev->hard_header = NULL;
115 dev->type_trans = NULL;
116 dev->rebuild_header = NULL;
117 #endif
118
119
120 dev->flags = IFF_LOOPBACK;
121 dev->family = AF_INET;
122 dev->pa_addr = in_aton("127.0.0.1");
123 dev->pa_brdaddr = in_aton("127.255.255.255");
124 dev->pa_mask = in_aton("255.0.0.0");
125 dev->pa_alen = sizeof(unsigned long);
126 dev->priv = kmalloc(sizeof(struct enet_statistics), GFP_KERNEL);
127 memset(dev->priv, 0, sizeof(struct enet_statistics));
128 dev->get_stats = get_stats;
129
130
131 for (i = 0; i < DEV_NUMBUFFS; i++)
132 skb_queue_head_init(&dev->buffs[i]);
133
134 return(0);
135 };