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