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