comparison e1000_implement_the_frame_transmission_chunk.patch @ 84:6432998a8245

Finish the patches on the rx/tx init and wip on the actual tx
author Louis Opter <louis@lse.epitech.net>
date Mon, 09 Jul 2012 06:44:51 +0200
parents 27f0e70df342
children 5dda73e7d728
comparison
equal deleted inserted replaced
83:27f0e70df342 84:6432998a8245
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 1a5a83776de5ecff15e42930c7741f5b4f2ada13 2 # Parent 72f11dd4265bb367278f34b23ecb5afa0f7f6fb7
3 rathaxes: start to queue up packets in the TX ring on the e1000 sample 3 rathaxes: start to queue up packets in the TX ring on the e1000 sample
4 4
5 diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in
6 --- a/maintainers/CMakeScripts/Templates/MakefileLKM.in
7 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in
8 @@ -1,6 +1,6 @@
9 # Disable this "coding-style" warning (seriously, you have to compile with
10 # -pedantic to get it...)
11 -EXTRA_CFLAGS = -Wno-declaration-after-statement
12 +EXTRA_CFLAGS = -Wno-declaration-after-statement -std=gnu99
13
14 KDIR = /lib/modules/$(shell uname -r)/build
15 obj-m := @LKM_OBJECTS@
5 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt 16 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
6 --- a/rathaxes/samples/e1000/e1000.blt 17 --- a/rathaxes/samples/e1000/e1000.blt
7 +++ b/rathaxes/samples/e1000/e1000.blt 18 +++ b/rathaxes/samples/e1000/e1000.blt
8 @@ -597,7 +597,7 @@ 19 @@ -964,4 +964,20 @@
9
10 chunk ::CALL()
11 {
12 - // this is an hack for the scope
13 + // See #10
14 (void)1;
15 {
16 int error;
17 @@ -970,4 +970,31 @@
18 } 20 }
19 } 21 }
20 } 22 }
21 + 23 +
22 + template sequence e1000::xmit(Ethernet::Device ctx, Socket::SKBuff skb) 24 + template sequence e1000::xmit(Ethernet::Device ctx, Socket::SKBuff skb)
23 + { 25 + {
24 + chunk ::CALL() 26 + chunk ::CALL()
25 + { 27 + {
28 + (void)1; // Issue 10
26 + /* 29 + /*
27 + * Put packets on the TX ring, must return NETDEV_TX_OK or 30 + * Put packets on the TX ring, must return NETDEV_TX_OK or
28 + * NETDEV_TX_BUSY. 31 + * NETDEV_TX_BUSY.
29 + */ 32 + */
30 + (void)1; // See #10
31 + { 33 + {
32 + ${Log::info("xmit: skbuff details:")}; 34 + ${Log::info("xmit: skbuff details:")};
35 + ${skb.dump_infos()};
33 + } 36 + }
34 + pr_info(
35 + "\t len = %-5u data_len = %-5u head_len = %-5u\n"
36 + "\tnr_frags = %u\n"
37 + "\tgso_size = %-5u gso_segs = %-5u gso_type = %-5u\n",
38 + ${skb}->len,
39 + ${skb}->data_len,
40 + skb_headlen(${skb}),
41 + skb_shinfo(${skb})->nr_frags,
42 + skb_shinfo(${skb})->gso_size,
43 + skb_shinfo(${skb})->gso_segs,
44 + skb_shinfo(${skb})->gso_type
45 + );
46 + } 37 + }
47 + } 38 + }
48 } 39 }
49 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti 40 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
50 --- a/rathaxes/samples/e1000/e1000.rti 41 --- a/rathaxes/samples/e1000/e1000.rti
51 +++ b/rathaxes/samples/e1000/e1000.rti 42 +++ b/rathaxes/samples/e1000/e1000.rti
52 @@ -70,6 +70,11 @@ 43 @@ -109,6 +109,11 @@
53 provided chunk ::CALL(); 44 provided chunk ::CALL();
54 } 45 }
55 46
56 + provided sequence e1000::xmit(Ethernet::Device, Socket::SKBuff) 47 + provided sequence xmit(Ethernet::Device, Socket::SKBuff)
57 + { 48 + {
58 + provided chunk ::CALL(); 49 + provided chunk ::CALL();
59 + } 50 + }
60 + 51 +
61 provided sequence e1000::register_read32(e1000::Context, e1000::Register) 52 provided sequence register_read32(e1000::Context, e1000::Register)
62 { 53 {
63 provided chunk LKM::prototypes(); 54 provided chunk LKM::prototypes();
55 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
56 --- a/rathaxes/samples/e1000/ethernet.blt
57 +++ b/rathaxes/samples/e1000/ethernet.blt
58 @@ -1,6 +1,51 @@
59 with Ethernet, PCI, LKM, Log
60 {
61 - template type Ethernet::Net()
62 + template type Ethernet::ProtocolId()
63 + {
64 + chunk LKM::prototypes()
65 + {
66 + static const char *rtx_ethernet_protocol_id_to_str(unsigned short);
67 + }
68 +
69 + chunk LKM::data()
70 + {
71 + static const struct
72 + {
73 + const unsigned short id;
74 + const char *name;
75 + } rtx_ethernet_proto_table[] =
76 + {
77 + { ETH_P_IP, "IPv4" },
78 + { ETH_P_IPV6, "IPv6" },
79 + { ETH_P_ARP, "ARP" },
80 + };
81 + }
82 +
83 + chunk LKM::code()
84 + {
85 + static const char *rtx_ethernet_protocol_id_to_str(unsigned short proto_id)
86 + {
87 + for (int i = 0;
88 + i != sizeof(rtx_ethernet_proto_table[0]) / sizeof(rtx_ethernet_proto_table);
89 + i++)
90 + if (proto_id == rtx_ethernet_proto_table[i].id)
91 + return rtx_ethernet_proto_table[i].name;
92 +
93 + return "Other";
94 + }
95 + }
96 +
97 + chunk to_str()
98 + {
99 + rtx_ethernet_protocol_id_to_str(${self});
100 + }
101 +
102 + map
103 + {
104 + }
105 + }
106 +
107 + template type Ethernet::AbstractDevice()
108 {
109 chunk LKM::includes()
110 {
111 @@ -17,11 +62,6 @@
112 }
113 }
114
115 - /*
116 - * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
117 - * from Linux. Ethernet::Device is the type that we use in the private
118 - * field of the struct net_device.
119 - */
120 template type Ethernet::Device()
121 {
122 chunk LKM::includes()
123 @@ -52,7 +92,7 @@
124 } *rtx_ethernet_dev_p;
125 }
126
127 - chunk ::init(Ethernet::Net net_dev, PCI::Device pci_dev)
128 + chunk ::init(Ethernet::AbstractDevice net_dev, PCI::Device pci_dev)
129 {
130 ${self} = netdev_priv(${net_dev});
131 /*
132 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
133 --- a/rathaxes/samples/e1000/ethernet.rti
134 +++ b/rathaxes/samples/e1000/ethernet.rti
135 @@ -1,11 +1,28 @@
136 interface Ethernet : Socket, PCI, LKM
137 {
138 - provided type Net
139 + provided type ProtocolId
140 + {
141 + chunk LKM::prototypes();
142 + chunk LKM::data();
143 + chunk LKM::code();
144 + method ::to_str();
145 + }
146 +
147 + /*
148 + * This is the abstract type used by the Kernel to represent an ethernet
149 + * device.
150 + */
151 + provided type AbstractDevice
152 {
153 chunk LKM::includes();
154 chunk ::decl();
155 }
156
157 + /*
158 + * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
159 + * from Linux. Ethernet::Device is the type that we use in the private
160 + * field of the struct net_device.
161 + */
162 provided type Device
163 {
164 chunk LKM::includes();
64 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx 165 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
65 --- a/rathaxes/samples/e1000/lkm.rtx 166 --- a/rathaxes/samples/e1000/lkm.rtx
66 +++ b/rathaxes/samples/e1000/lkm.rtx 167 +++ b/rathaxes/samples/e1000/lkm.rtx
67 @@ -46,6 +46,7 @@ 168 @@ -46,6 +46,7 @@
68 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) 169 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
70 Log::info("we have one packet to transmit!"); 171 Log::info("we have one packet to transmit!");
71 + e1000::xmit(dev, skb); 172 + e1000::xmit(dev, skb);
72 } 173 }
73 174
74 LKM::init() 175 LKM::init()
176 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
177 --- a/rathaxes/samples/e1000/socket.blt
178 +++ b/rathaxes/samples/e1000/socket.blt
179 @@ -1,4 +1,4 @@
180 -with Socket, LKM
181 +with Socket, LKM, Ethernet
182 {
183 template type Socket::SKBuff()
184 {
185 @@ -17,6 +17,32 @@
186 {
187 }
188
189 + chunk ::dump_infos()
190 + {
191 + /*
192 + * We should use a Rathaxes log abstraction instead of pr_info here,
193 + * but Rathaxes doesn't support functions with a variable number of
194 + * arguments yet.
195 + */
196 + unsigned short ethernet_proto = be16_to_cpu(${self}->protocol);
197 + ${cast local.ethernet_proto as Ethernet::ProtocolId};
198 +
199 + pr_info(
200 + "\tprotocol = %#-5x (%s)\n"
201 + "\t len = %-5u data_len = %-5u head_len = %-5u\n"
202 + "\tnr_frags = %u\n"
203 + "\tgso_size = %-5u gso_segs = %-5u gso_type = %-5u\n",
204 + ethernet_proto, "", // XXX: ${local.ethernet_proto.to_str()},
205 + ${self}->len,
206 + ${self}->data_len,
207 + skb_headlen(${self}),
208 + skb_shinfo(${self})->nr_frags,
209 + skb_shinfo(${self})->gso_size,
210 + skb_shinfo(${self})->gso_segs,
211 + skb_shinfo(${self})->gso_type
212 + );
213 + }
214 +
215 map
216 {
217 // some work may have to be done here in order
218 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
219 --- a/rathaxes/samples/e1000/socket.rti
220 +++ b/rathaxes/samples/e1000/socket.rti
221 @@ -1,8 +1,10 @@
222 interface Socket : LKM
223 {
224 - provided type Socket::SKBuff {
225 - chunk LKM::includes();
226 - chunk ::decl();
227 - method ::init();
228 + provided type Socket::SKBuff
229 + {
230 + chunk LKM::includes();
231 + chunk ::decl();
232 + method ::init();
233 + method ::dump_infos();
234 }
235 }