annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1 # HG changeset patch
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
2 # Parent 42d6e2a573d077772c1a9c697cc066337569b129
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
3 rathaxes: start to queue up packets in the TX ring on the e1000 sample
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
4
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
5 diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
6 --- a/maintainers/CMakeScripts/Templates/MakefileLKM.in
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
7 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
8 @@ -1,6 +1,6 @@
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
9 # Disable this "coding-style" warning (seriously, you have to compile with
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
10 # -pedantic to get it...)
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
11 -EXTRA_CFLAGS = -Wno-declaration-after-statement
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
12 +EXTRA_CFLAGS = -Wno-declaration-after-statement -std=gnu99
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
13
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
14 KDIR = /lib/modules/$(shell uname -r)/build
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
15 obj-m := @LKM_OBJECTS@
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
16 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
17 --- a/rathaxes/samples/e1000/e1000.blt
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
18 +++ b/rathaxes/samples/e1000/e1000.blt
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
19 @@ -332,6 +332,30 @@
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
20 }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
21 }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
22
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
23 + template type e1000::TxFlags()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
24 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
25 + chunk LKM::includes()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
26 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
27 + static const ${e1000::TxFlags} force_enum_rtx_e1000_tx_flags_decl;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
28 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
29 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
30 + chunk ::decl()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
31 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
32 + enum rtx_e1000_tx_flags
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
33 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
34 + E1000_TX_FLAGS_CSUM = 0x00000001,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
35 + E1000_TX_FLAGS_VLAN = 0x00000002,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
36 + E1000_TX_FLAGS_TSO = 0x00000004,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
37 + E1000_TX_FLAGS_IPV4 = 0x00000008,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
38 + E1000_TX_FLAGS_NO_FCS = 0x00000010,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
39 + };
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
40 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
41 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
42 + map
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
43 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
44 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
45 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
46 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
47 template sequence e1000::create_device()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
48 {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
49 chunk Ethernet::create_device(PCI::Device pdev, Ethernet::Device rtx_ether_ctx)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
50 @@ -964,4 +988,86 @@
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
51 }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
52 }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
53 }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
54 +
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
55 + template sequence e1000::_xmit_tso_cksum_offload(Ethernet::Device ctx, Socket::SKBuff skb)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
56 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
57 + chunk ::CALL()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
58 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
59 + if (skb_is_gso(${skb}) || ${skb}->ip_summed == CHECKSUM_PARTIAL)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
60 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
61 + ${Log::info("xmit: the packet needs to be fragmented and/or checksummed but this not implemented yet!")};
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
62 + return NETDEV_TX_OK;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
63 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
64 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
65 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
66 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
67 + template sequence e1000::_xmit_map_skbuff(Ethernet::Device ctx, Socket::SKBuff skb)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
68 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
69 + chunk ::CALL()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
70 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
71 + dma_addr_t buff_addr = dma_map_single(
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
72 + &${ctx}->pci_dev->dev,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
73 + ${skb}->data,
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
74 + skb_headlen(${skb}),
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
75 + DMA_TO_DEVICE);
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
76 + if (dma_mapping_error(&${ctx}->pci_dev->dev, buff_addr))
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
77 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
78 + ${Log::info("xmit: can't DMA map a SKBuff")};
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
79 + goto err_dma_map;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
80 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
81 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
82 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
83 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
84 + template sequence e1000::_xmit_update_tx_ring(Ethernet::Device, Socket::SKBuff skb)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
85 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
86 + chunk ::CALL()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
87 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
88 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
89 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
90 +
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
91 + template sequence e1000::xmit(Ethernet::Device ctx, Socket::SKBuff skb)
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
92 + {
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
93 + chunk ::CALL()
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
94 + {
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
95 + typedef unsigned long int dma_addr_t;
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
96 +
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
97 + (void)1; // Issue 10
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
98 + /*
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
99 + * Put packets on the TX ring, must return NETDEV_TX_OK or
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
100 + * NETDEV_TX_BUSY.
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
101 + */
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
102 + {
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
103 + ${Log::info("xmit: skbuff details:")};
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
104 + ${skb.dump_infos()};
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
105 + }
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
106 +
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
107 + /*
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
108 + * The transmission is going to be several steps:
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
109 + * 1. TCP Segmentation Offload & Checksum Offloading: pick a
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
110 + * descriptor from the tx ring and fill it as a contex
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
111 + * descriptor to allow the card to slice into several packets
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
112 + * according to the MSS;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
113 + * 2. DMA Map the skbuff data as slices of 4096;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
114 + * 3. Signal the hardware that data is available via a tx desc.
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
115 + */
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
116 +
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
117 + /* 1. Offloading */
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
118 + { // workaround #10 (and it's useful to workaround #47 too)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
119 + ${e1000::_xmit_tso_cksum_offload(ctx, skb)};
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
120 + }
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
121 +
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
122 + /* 2. Map the data */
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
123 + {
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
124 + ${e1000::_xmit_map_skbuff(ctx, skb)};
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
125 + }
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
126 +
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
127 + /* 3. Update the TX Ring */
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
128 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
129 + ${e1000::_xmit_update_tx_ring(ctx, skb)};
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
130 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
131 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
132 + err_dma_map:
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
133 + return NETDEV_TX_OK;
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
134 + }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
135 + }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
136 }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
137 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
138 --- a/rathaxes/samples/e1000/e1000.rti
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
139 +++ b/rathaxes/samples/e1000/e1000.rti
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
140 @@ -51,6 +51,12 @@
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
141 method decl();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
142 }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
143
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
144 + provided type TxFlags
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
145 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
146 + chunk LKM::includes();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
147 + chunk ::decl();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
148 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
149 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
150 provided sequence create_device()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
151 {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
152 provided chunk Ethernet::create_device(PCI::Device, Ethernet::Device);
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
153 @@ -109,6 +115,26 @@
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
154 provided chunk ::CALL();
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
155 }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
156
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
157 + provided sequence _xmit_tso_cksum_offload(Ethernet::Device, Socket::SKBuff)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
158 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
159 + provided chunk ::CALL();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
160 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
161 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
162 + provided sequence _xmit_map_skbuff(Ethernet::Device, Socket::SKBuff)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
163 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
164 + provided chunk ::CALL();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
165 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
166 +
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
167 + provided sequence _xmit_update_tx_ring(Ethernet::Device, Socket::SKBuff)
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
168 + {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
169 + provided chunk ::CALL();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
170 + }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
171 +
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
172 + provided sequence xmit(Ethernet::Device, Socket::SKBuff)
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
173 + {
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
174 + provided chunk ::CALL();
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
175 + }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
176 +
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
177 provided sequence register_read32(e1000::Context, e1000::Register)
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
178 {
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
179 provided chunk LKM::prototypes();
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
180 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
181 --- a/rathaxes/samples/e1000/ethernet.blt
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
182 +++ b/rathaxes/samples/e1000/ethernet.blt
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
183 @@ -1,6 +1,51 @@
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
184 with Ethernet, PCI, LKM, Log
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
185 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
186 - template type Ethernet::Net()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
187 + template type Ethernet::ProtocolId()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
188 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
189 + chunk LKM::prototypes()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
190 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
191 + static const char *rtx_ethernet_protocol_id_to_str(unsigned short);
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
192 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
193 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
194 + chunk LKM::data()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
195 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
196 + static const struct
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
197 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
198 + const unsigned short id;
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
199 + const char *name;
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
200 + } rtx_ethernet_proto_table[] =
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
201 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
202 + { ETH_P_IP, "IPv4" },
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
203 + { ETH_P_IPV6, "IPv6" },
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
204 + { ETH_P_ARP, "ARP" },
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
205 + };
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
206 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
207 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
208 + chunk LKM::code()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
209 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
210 + static const char *rtx_ethernet_protocol_id_to_str(unsigned short proto_id)
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
211 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
212 + for (int i = 0;
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
213 + i != sizeof(rtx_ethernet_proto_table[0]) / sizeof(rtx_ethernet_proto_table);
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
214 + i++)
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
215 + if (proto_id == rtx_ethernet_proto_table[i].id)
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
216 + return rtx_ethernet_proto_table[i].name;
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
217 +
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
218 + return "Unknown";
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
219 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
220 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
221 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
222 + chunk to_str()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
223 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
224 + rtx_ethernet_protocol_id_to_str(${self});
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
225 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
226 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
227 + map
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
228 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
229 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
230 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
231 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
232 + template type Ethernet::AbstractDevice()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
233 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
234 chunk LKM::includes()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
235 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
236 @@ -17,11 +62,6 @@
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
237 }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
238 }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
239
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
240 - /*
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
241 - * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
242 - * from Linux. Ethernet::Device is the type that we use in the private
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
243 - * field of the struct net_device.
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
244 - */
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
245 template type Ethernet::Device()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
246 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
247 chunk LKM::includes()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
248 @@ -52,7 +92,7 @@
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
249 } *rtx_ethernet_dev_p;
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
250 }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
251
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
252 - chunk ::init(Ethernet::Net net_dev, PCI::Device pci_dev)
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
253 + chunk ::init(Ethernet::AbstractDevice net_dev, PCI::Device pci_dev)
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
254 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
255 ${self} = netdev_priv(${net_dev});
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
256 /*
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
257 @@ -100,11 +140,11 @@
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
258 {
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
259 static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev)
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
260 {
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
261 - ${cast local.dev as Ethernet::Device};
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
262 + struct rtx_ethernet_dev* rtx_ethernet_dev = netdev_priv(dev);
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
263 +
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
264 + ${cast local.rtx_ethernet_dev as Ethernet::Device};
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
265 ${cast local.skb as Socket::SKBuff};
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
266 - ${pointcut ::IMPLEMENTATION(local.dev, local.skb)};
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
267 -
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
268 - return 0;
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
269 + ${pointcut ::IMPLEMENTATION(local.rtx_ethernet_dev, local.skb)};
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
270 }
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
271 }
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
272 }
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
273 diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
274 --- a/rathaxes/samples/e1000/ethernet.rti
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
275 +++ b/rathaxes/samples/e1000/ethernet.rti
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
276 @@ -1,16 +1,33 @@
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
277 interface Ethernet : Socket, PCI, LKM
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
278 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
279 - provided type Net
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
280 + provided type ProtocolId
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
281 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
282 + chunk LKM::prototypes();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
283 + chunk LKM::data();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
284 + chunk LKM::code();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
285 + method ::to_str();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
286 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
287 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
288 + /*
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
289 + * This is the abstract type used by the Kernel to represent an ethernet
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
290 + * device.
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
291 + */
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
292 + provided type AbstractDevice
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
293 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
294 chunk LKM::includes();
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
295 method decl();
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
296 }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
297
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
298 + /*
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
299 + * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
300 + * from Linux. Ethernet::Device is the type that we use in the private
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
301 + * field of the struct net_device.
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
302 + */
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
303 provided type Device
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
304 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
305 chunk LKM::includes();
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
306 method decl();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
307 - method init(Ethernet::Net, PCI::Device);
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
308 + method init(Ethernet::AbstractDevice, PCI::Device);
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
309 }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
310
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
311 required variable ::string ifname;
83
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
312 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
313 --- a/rathaxes/samples/e1000/lkm.rtx
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
314 +++ b/rathaxes/samples/e1000/lkm.rtx
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
315 @@ -46,6 +46,7 @@
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
316 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
317 {
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
318 Log::info("we have one packet to transmit!");
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
319 + e1000::xmit(dev, skb);
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
320 }
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
321
27f0e70df342 Wip on the transmission, tx init done, and tx hooked from Ethernet send
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
322 LKM::init()
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
323 @@ -79,4 +80,10 @@
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
324 * 4096, 8192 and 16384 bytes:
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
325 */
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
326 e1000::rx_buffer_len = 2048;
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
327 + /*
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
328 + * 4096 bytes maximum per transmit descriptor is used on Linux and FreeBSD,
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
329 + * 2048 on Minix and HelenOS, I can't find why. If I understand the Intel
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
330 + * man correctly, the maximum should be 16288 (see section 3.3.3).
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
331 + */
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
332 + e1000::tx_max_data_per_desc = 4096;
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
333 }
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
334 diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
335 --- a/rathaxes/samples/e1000/socket.blt
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
336 +++ b/rathaxes/samples/e1000/socket.blt
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
337 @@ -1,4 +1,4 @@
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
338 -with Socket, LKM
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
339 +with Socket, LKM, Ethernet
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
340 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
341 template type Socket::SKBuff()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
342 {
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
343 @@ -10,13 +10,41 @@
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
344
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
345 chunk ::decl()
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
346 {
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
347 - struct sk_buff;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
348 + typedef struct sk_buff *rtx_socket_skbuff_p;
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
349 }
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
350
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
351 chunk ::init()
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
352 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
353 }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
354
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
355 + chunk ::dump_infos()
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
356 + {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
357 + /*
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
358 + * We should use a Rathaxes log abstraction instead of pr_info here,
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
359 + * but Rathaxes doesn't support functions with a variable number of
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
360 + * arguments yet.
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
361 + */
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
362 + unsigned short ethernet_proto = be16_to_cpu(${self}->protocol);
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
363 + ${cast local.ethernet_proto as Ethernet::ProtocolId};
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
364 +
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
365 + static const char * const ip_summed_values[] = {
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
366 + "none", "unnecessary", "complete", "partial"
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
367 + };
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
368 +
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
369 + pr_info(
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
370 + "\t protocol = %#-5x (%s)\n"
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
371 + "\t len = %-5u data_len = %-5u head_len = %-5u\n"
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
372 + "\t nr_frags = %u\n"
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
373 + "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u\n"
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
374 + "\tip_summed = %d (%s)",
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
375 + ethernet_proto, "", // XXX: ${local.ethernet_proto.to_str()},
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
376 + ${self}->len, ${self}->data_len, skb_headlen(${self}),
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
377 + skb_shinfo(${self})->nr_frags,
85
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
378 + skb_shinfo(${self})->gso_size, skb_shinfo(${self})->gso_segs, skb_shinfo(${self})->gso_type,
5dda73e7d728 Add my WIP on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 84
diff changeset
379 + ${self}->ip_summed, ip_summed_values[${self}->ip_summed]
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
380 + );
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
381 + }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
382 +
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
383 map
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
384 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
385 // some work may have to be done here in order
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
386 diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
387 --- a/rathaxes/samples/e1000/socket.rti
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
388 +++ b/rathaxes/samples/e1000/socket.rti
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
389 @@ -1,8 +1,10 @@
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
390 interface Socket : LKM
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
391 {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
392 - provided type Socket::SKBuff {
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
393 + provided type Socket::SKBuff
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
394 + {
86
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
395 chunk LKM::includes();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
396 - method decl();
c99e69966dd3 WIP/Cleanup on the tranmission
Louis Opter <louis@lse.epitech.net>
parents: 85
diff changeset
397 - method init();
84
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
398 + chunk ::decl();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
399 + method ::init();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
400 + method ::dump_infos();
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
401 }
6432998a8245 Finish the patches on the rx/tx init and wip on the actual tx
Louis Opter <louis@lse.epitech.net>
parents: 83
diff changeset
402 }