comparison e1000_implement_the_frame_transmission_chunk.patch @ 86:c99e69966dd3

WIP/Cleanup on the tranmission
author Louis Opter <louis@lse.epitech.net>
date Tue, 18 Sep 2012 08:57:14 +0200
parents 5dda73e7d728
children e9736ab70995
comparison
equal deleted inserted replaced
85:5dda73e7d728 86:c99e69966dd3
1 # HG changeset patch 1 # HG changeset patch
2 # Parent 41aa481c1ba8a54a7291ac2630f2eebc50022f33 2 # Parent 42d6e2a573d077772c1a9c697cc066337569b129
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 5 diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in
6 --- a/maintainers/CMakeScripts/Templates/MakefileLKM.in 6 --- a/maintainers/CMakeScripts/Templates/MakefileLKM.in
7 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in 7 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in
14 KDIR = /lib/modules/$(shell uname -r)/build 14 KDIR = /lib/modules/$(shell uname -r)/build
15 obj-m := @LKM_OBJECTS@ 15 obj-m := @LKM_OBJECTS@
16 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
17 --- a/rathaxes/samples/e1000/e1000.blt 17 --- a/rathaxes/samples/e1000/e1000.blt
18 +++ b/rathaxes/samples/e1000/e1000.blt 18 +++ b/rathaxes/samples/e1000/e1000.blt
19 @@ -964,4 +964,52 @@ 19 @@ -332,6 +332,30 @@
20 }
21 }
22
23 + template type e1000::TxFlags()
24 + {
25 + chunk LKM::includes()
26 + {
27 + static const ${e1000::TxFlags} force_enum_rtx_e1000_tx_flags_decl;
28 + }
29 +
30 + chunk ::decl()
31 + {
32 + enum rtx_e1000_tx_flags
33 + {
34 + E1000_TX_FLAGS_CSUM = 0x00000001,
35 + E1000_TX_FLAGS_VLAN = 0x00000002,
36 + E1000_TX_FLAGS_TSO = 0x00000004,
37 + E1000_TX_FLAGS_IPV4 = 0x00000008,
38 + E1000_TX_FLAGS_NO_FCS = 0x00000010,
39 + };
40 + }
41 +
42 + map
43 + {
44 + }
45 + }
46 +
47 template sequence e1000::create_device()
48 {
49 chunk Ethernet::create_device(PCI::Device pdev, Ethernet::Device rtx_ether_ctx)
50 @@ -964,4 +988,86 @@
20 } 51 }
21 } 52 }
22 } 53 }
23 + 54 +
24 + template sequence e1000::xmit(Ethernet::Device ctx, Socket::SKBuff skb) 55 + template sequence e1000::_xmit_tso_cksum_offload(Ethernet::Device ctx, Socket::SKBuff skb)
25 + { 56 + {
26 + chunk ::CALL() 57 + chunk ::CALL()
27 + { 58 + {
28 + typedef unsigned long int dma_addr_t;
29 +
30 + (void)1; // Issue 10
31 + /*
32 + * Put packets on the TX ring, must return NETDEV_TX_OK or
33 + * NETDEV_TX_BUSY.
34 + */
35 + {
36 + ${Log::info("xmit: skbuff details:")};
37 + ${skb.dump_infos()};
38 + }
39 +
40 + /*
41 + * The transmission is going to be several steps:
42 + * - TCP Segmentation Offload & Checksum Offloading: pick a
43 + * descriptor from the tx ring and fill it as a context descriptor
44 + * to allow the card to slice into several packets according to
45 + * the MSS;
46 + * - DMA Map the skbuff data as slices of 4096;
47 + * - Signal the hardware that data is available via a tx desc.
48 + */
49 +
50 + if (skb_is_gso(${skb}) || ${skb}->ip_summed == CHECKSUM_PARTIAL) 59 + if (skb_is_gso(${skb}) || ${skb}->ip_summed == CHECKSUM_PARTIAL)
51 + { 60 + {
52 + ${Log::info("xmit: the packet needs to be fragmented and/or checksummed but this not implemented yet!")}; 61 + ${Log::info("xmit: the packet needs to be fragmented and/or checksummed but this not implemented yet!")};
53 + return NETDEV_TX_OK; 62 + return NETDEV_TX_OK;
54 + } 63 + }
55 + 64 + }
56 + /* XXX ${ctx} expands into skb */ 65 + }
66 +
67 + template sequence e1000::_xmit_map_skbuff(Ethernet::Device ctx, Socket::SKBuff skb)
68 + {
69 + chunk ::CALL()
70 + {
57 + dma_addr_t buff_addr = dma_map_single( 71 + dma_addr_t buff_addr = dma_map_single(
58 + &${ctx}->pci_dev->dev, 72 + &${ctx}->pci_dev->dev,
59 + ${skb}->data, 73 + ${skb}->data,
60 + skb_headlen(${skb}), 74 + skb_headlen(${skb}),
61 + DMA_TO_DEVICE); 75 + DMA_TO_DEVICE);
62 + if (dma_mapping_error(&${ctx}->pci_dev->dev, buff_addr)) 76 + if (dma_mapping_error(&${ctx}->pci_dev->dev, buff_addr))
63 + { 77 + {
64 + ${Log::info("xmit: can't DMA map a SKBuff")}; 78 + ${Log::info("xmit: can't DMA map a SKBuff")};
65 + /* now what, should I free the skb? */ 79 + goto err_dma_map;
66 + } 80 + }
67 + 81 + }
82 + }
83 +
84 + template sequence e1000::_xmit_update_tx_ring(Ethernet::Device, Socket::SKBuff skb)
85 + {
86 + chunk ::CALL()
87 + {
88 + }
89 + }
90 +
91 + template sequence e1000::xmit(Ethernet::Device ctx, Socket::SKBuff skb)
92 + {
93 + chunk ::CALL()
94 + {
95 + typedef unsigned long int dma_addr_t;
96 +
97 + (void)1; // Issue 10
98 + /*
99 + * Put packets on the TX ring, must return NETDEV_TX_OK or
100 + * NETDEV_TX_BUSY.
101 + */
102 + {
103 + ${Log::info("xmit: skbuff details:")};
104 + ${skb.dump_infos()};
105 + }
106 +
107 + /*
108 + * The transmission is going to be several steps:
109 + * 1. TCP Segmentation Offload & Checksum Offloading: pick a
110 + * descriptor from the tx ring and fill it as a contex
111 + * descriptor to allow the card to slice into several packets
112 + * according to the MSS;
113 + * 2. DMA Map the skbuff data as slices of 4096;
114 + * 3. Signal the hardware that data is available via a tx desc.
115 + */
116 +
117 + /* 1. Offloading */
118 + { // workaround #10 (and it's useful to workaround #47 too)
119 + ${e1000::_xmit_tso_cksum_offload(ctx, skb)};
120 + }
121 +
122 + /* 2. Map the data */
123 + {
124 + ${e1000::_xmit_map_skbuff(ctx, skb)};
125 + }
126 +
127 + /* 3. Update the TX Ring */
128 + {
129 + ${e1000::_xmit_update_tx_ring(ctx, skb)};
130 + }
131 +
132 + err_dma_map:
68 + return NETDEV_TX_OK; 133 + return NETDEV_TX_OK;
69 + } 134 + }
70 + } 135 + }
71 } 136 }
72 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti 137 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
73 --- a/rathaxes/samples/e1000/e1000.rti 138 --- a/rathaxes/samples/e1000/e1000.rti
74 +++ b/rathaxes/samples/e1000/e1000.rti 139 +++ b/rathaxes/samples/e1000/e1000.rti
75 @@ -109,6 +109,11 @@ 140 @@ -51,6 +51,12 @@
141 method decl();
142 }
143
144 + provided type TxFlags
145 + {
146 + chunk LKM::includes();
147 + chunk ::decl();
148 + }
149 +
150 provided sequence create_device()
151 {
152 provided chunk Ethernet::create_device(PCI::Device, Ethernet::Device);
153 @@ -109,6 +115,26 @@
76 provided chunk ::CALL(); 154 provided chunk ::CALL();
77 } 155 }
78 156
157 + provided sequence _xmit_tso_cksum_offload(Ethernet::Device, Socket::SKBuff)
158 + {
159 + provided chunk ::CALL();
160 + }
161 +
162 + provided sequence _xmit_map_skbuff(Ethernet::Device, Socket::SKBuff)
163 + {
164 + provided chunk ::CALL();
165 + }
166 +
167 + provided sequence _xmit_update_tx_ring(Ethernet::Device, Socket::SKBuff)
168 + {
169 + provided chunk ::CALL();
170 + }
171 +
79 + provided sequence xmit(Ethernet::Device, Socket::SKBuff) 172 + provided sequence xmit(Ethernet::Device, Socket::SKBuff)
80 + { 173 + {
81 + provided chunk ::CALL(); 174 + provided chunk ::CALL();
82 + } 175 + }
83 + 176 +
178 } 271 }
179 } 272 }
180 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti 273 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
181 --- a/rathaxes/samples/e1000/ethernet.rti 274 --- a/rathaxes/samples/e1000/ethernet.rti
182 +++ b/rathaxes/samples/e1000/ethernet.rti 275 +++ b/rathaxes/samples/e1000/ethernet.rti
183 @@ -1,11 +1,28 @@ 276 @@ -1,16 +1,33 @@
184 interface Ethernet : Socket, PCI, LKM 277 interface Ethernet : Socket, PCI, LKM
185 { 278 {
186 - provided type Net 279 - provided type Net
187 + provided type ProtocolId 280 + provided type ProtocolId
188 + { 281 + {
197 + * device. 290 + * device.
198 + */ 291 + */
199 + provided type AbstractDevice 292 + provided type AbstractDevice
200 { 293 {
201 chunk LKM::includes(); 294 chunk LKM::includes();
202 chunk ::decl(); 295 method decl();
203 } 296 }
204 297
205 + /* 298 + /*
206 + * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device 299 + * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
207 + * from Linux. Ethernet::Device is the type that we use in the private 300 + * from Linux. Ethernet::Device is the type that we use in the private
208 + * field of the struct net_device. 301 + * field of the struct net_device.
209 + */ 302 + */
210 provided type Device 303 provided type Device
211 { 304 {
212 chunk LKM::includes(); 305 chunk LKM::includes();
306 method decl();
307 - method init(Ethernet::Net, PCI::Device);
308 + method init(Ethernet::AbstractDevice, PCI::Device);
309 }
310
311 required variable ::string ifname;
213 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx 312 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
214 --- a/rathaxes/samples/e1000/lkm.rtx 313 --- a/rathaxes/samples/e1000/lkm.rtx
215 +++ b/rathaxes/samples/e1000/lkm.rtx 314 +++ b/rathaxes/samples/e1000/lkm.rtx
216 @@ -46,6 +46,7 @@ 315 @@ -46,6 +46,7 @@
217 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) 316 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
239 -with Socket, LKM 338 -with Socket, LKM
240 +with Socket, LKM, Ethernet 339 +with Socket, LKM, Ethernet
241 { 340 {
242 template type Socket::SKBuff() 341 template type Socket::SKBuff()
243 { 342 {
244 @@ -17,6 +17,34 @@ 343 @@ -10,13 +10,41 @@
344
345 chunk ::decl()
346 {
347 - struct sk_buff;
348 + typedef struct sk_buff *rtx_socket_skbuff_p;
349 }
350
351 chunk ::init()
245 { 352 {
246 } 353 }
247 354
248 + chunk ::dump_infos() 355 + chunk ::dump_infos()
249 + { 356 + {
262 + pr_info( 369 + pr_info(
263 + "\t protocol = %#-5x (%s)\n" 370 + "\t protocol = %#-5x (%s)\n"
264 + "\t len = %-5u data_len = %-5u head_len = %-5u\n" 371 + "\t len = %-5u data_len = %-5u head_len = %-5u\n"
265 + "\t nr_frags = %u\n" 372 + "\t nr_frags = %u\n"
266 + "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u\n" 373 + "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u\n"
267 + "\tip_summed = %d\n (%s)", 374 + "\tip_summed = %d (%s)",
268 + ethernet_proto, "", // XXX: ${local.ethernet_proto.to_str()}, 375 + ethernet_proto, "", // XXX: ${local.ethernet_proto.to_str()},
269 + ${self}->len, ${self}->data_len, skb_headlen(${self}), 376 + ${self}->len, ${self}->data_len, skb_headlen(${self}),
270 + skb_shinfo(${self})->nr_frags, 377 + skb_shinfo(${self})->nr_frags,
271 + skb_shinfo(${self})->gso_size, skb_shinfo(${self})->gso_segs, skb_shinfo(${self})->gso_type, 378 + skb_shinfo(${self})->gso_size, skb_shinfo(${self})->gso_segs, skb_shinfo(${self})->gso_type,
272 + ${self}->ip_summed, ip_summed_values[${self}->ip_summed] 379 + ${self}->ip_summed, ip_summed_values[${self}->ip_summed]
281 +++ b/rathaxes/samples/e1000/socket.rti 388 +++ b/rathaxes/samples/e1000/socket.rti
282 @@ -1,8 +1,10 @@ 389 @@ -1,8 +1,10 @@
283 interface Socket : LKM 390 interface Socket : LKM
284 { 391 {
285 - provided type Socket::SKBuff { 392 - provided type Socket::SKBuff {
286 - chunk LKM::includes();
287 - chunk ::decl();
288 - method ::init();
289 + provided type Socket::SKBuff 393 + provided type Socket::SKBuff
290 + { 394 + {
291 + chunk LKM::includes(); 395 chunk LKM::includes();
396 - method decl();
397 - method init();
292 + chunk ::decl(); 398 + chunk ::decl();
293 + method ::init(); 399 + method ::init();
294 + method ::dump_infos(); 400 + method ::dump_infos();
295 } 401 }
296 } 402 }