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