Mercurial > archived > louis > epitech > mq > rathaxes
annotate rathaxes_start_to_implement_sk_buff_in_the_lkm.patch @ 30:b4ca25b88690
Finish patches on the CMake library and on #includes
author | Louis Opter <louis@lse.epitech.net> |
---|---|
date | Sat, 07 Jan 2012 21:11:13 +0100 |
parents | 1b7399e39afd |
children |
rev | line source |
---|---|
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
1 # HG changeset patch |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
2 # Parent 86594bdb2ed616f9cbbafe8d78bccc676f832f49 |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
3 rathaxes: add sk_buff abstraction and add the implementation of the xmit function for the ethernet system. We have a fully (empty) functionnal ethernet driver |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
4 |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
5 diff -r 86594bdb2ed6 rathaxes/samples/lkm/CMakeLists.txt |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
6 --- a/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 20:51:10 2012 +0100 |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
7 +++ b/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 20:51:27 2012 +0100 |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
8 @@ -1,6 +1,6 @@ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
9 ADD_RATHAXES_SOURCES(lkm lkm.rtx |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
10 - RTI log.rti lkm.rti pci.rti ethernet.rti |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
11 - BLT log.blt lkm.blt pci.blt ethernet.blt) |
23 | 12 + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti e1000.rti |
13 + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) | |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
14 |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
15 # We can't name lkm since it's already used as the target name to generate the |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
16 # source (with ADD_RATHAXES_SOURCES). |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
17 diff -r 86594bdb2ed6 rathaxes/samples/lkm/e1000.blt |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
18 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
19 +++ b/rathaxes/samples/lkm/e1000.blt Sat Jan 07 20:51:27 2012 +0100 |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
20 @@ -0,0 +1,72 @@ |
23 | 21 +with e1000, Ethernet, Socket, PCI, LKM, Log |
22 +{ | |
23 + template type e1000::Context() | |
24 + { | |
25 + chunk LKM::includes() | |
26 + { | |
27 + /* | |
28 + * Force the generation of the structure in the "headers part, we | |
29 + * have to do this since we do not use the structure in this blt | |
30 + * (we hacked a bit and used it in ethernet.blt directly). | |
31 + */ | |
32 + typedef int ${e1000::Context}; /* CNorm __std__ workaround */ | |
33 + ${e1000::Context} force_declaration_in_includes; | |
34 + } | |
35 + | |
36 + chunk ::decl() | |
37 + { | |
38 + struct rtx_e1000_ctx | |
39 + { | |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
40 + int bars; |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
41 + unsigned char /* __iomem */ *ioaddr; |
23 | 42 + }; |
43 + } | |
44 + | |
45 + map | |
46 + { | |
47 + } | |
48 + } | |
49 + | |
50 + template sequence e1000::create() | |
51 + { | |
52 + chunk ::CALL | |
53 + { | |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
54 + rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM); |
23 | 55 + if (pci_enable_device_mem(pdev)) |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
56 + { |
23 | 57 + ${Log::info("e1000::create: pci_enable_device_mem failed")}; |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
58 + } |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
59 + |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
60 + if (pci_request_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars, ${config.name})) |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
61 + { |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
62 + ${Log::info("e1000::create: pci_request_selected_regions failed")}; |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
63 + } |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
64 + |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
65 + if (${config.set_master}) |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
66 + { |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
67 + pci_set_master(pdev); |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
68 + } |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
69 + |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
70 + /* 0 here is for BAR_0: */ |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
71 + rtx_ether_ctx->hw_ctx.ioaddr = pci_ioremap_bar(pdev, 0); |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
72 + if (!rtx_ether_ctx->hw_ctx.ioaddr) |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
73 + { |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
74 + ${Log::info("e1000::create: pci_ioremap_bar failed")}; |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
75 + } |
23 | 76 + } |
77 + } | |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
78 + |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
79 + template sequence e1000::destroy() |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
80 + { |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
81 + chunk ::CALL |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
82 + { |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
83 + // XXX: add a check in order to avoid freeing none allocated |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
84 + // resources. |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
85 + struct net_device *net_dev = pci_get_drvdata(pdev); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
86 + struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
87 + iounmap(rtx_ether_ctx->hw_ctx.ioaddr); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
88 + pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
89 + pci_release_region(pdev, 0); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
90 + } |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
91 + } |
23 | 92 +} |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
93 diff -r 86594bdb2ed6 rathaxes/samples/lkm/e1000.rti |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
94 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
95 +++ b/rathaxes/samples/lkm/e1000.rti Sat Jan 07 20:51:27 2012 +0100 |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
96 @@ -0,0 +1,15 @@ |
23 | 97 +interface e1000 : Socket, Ethernet, PCI, LKM |
98 +{ | |
99 + provided type e1000::Context; | |
100 + | |
101 + /* Not sure if we need the argument */ | |
102 + provided sequence e1000::create() | |
103 + { | |
104 + provided chunk ::CALL; | |
105 + } | |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
106 + |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
107 + provided sequence e1000::destroy() |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
108 + { |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
109 + provided chunk ::CALL; |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
110 + } |
23 | 111 +} |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
112 diff -r 86594bdb2ed6 rathaxes/samples/lkm/ethernet.blt |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
113 --- a/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 20:51:10 2012 +0100 |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
114 +++ b/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 20:51:27 2012 +0100 |
23 | 115 @@ -18,8 +18,11 @@ |
116 * I think it's useless to use the ${PCI::Device} "abstraction" | |
117 * here, since we are already in a Linux specific context here. | |
118 */ | |
119 - struct pci_dev *pci_dev; | |
120 - struct net_device *net_dev; | |
121 + struct pci_dev *pci_dev; | |
122 + struct net_device *net_dev; | |
123 + | |
124 + /* while waiting on issue #8 */ | |
125 + struct rtx_e1000_ctx hw_ctx; | |
126 }; | |
127 } | |
128 | |
129 @@ -51,6 +54,24 @@ | |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
130 } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
131 } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
132 |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
133 + template sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
134 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
135 + chunk LKM::prototypes() |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
136 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
137 + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev); |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
138 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
139 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
140 + chunk LKM::code() |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
141 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
142 + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
143 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
144 + ${pointcut ::IMPLEMENTATION}; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
145 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
146 + return 0; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
147 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
148 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
149 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
150 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
151 template sequence Ethernet::close(Ethernet::Device dev) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
152 { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
153 chunk LKM::prototypes() |
23 | 154 @@ -100,7 +121,7 @@ |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
155 { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
156 .ndo_open = rtx_ethernet_open, |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
157 .ndo_stop = rtx_ethernet_close, |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
158 - .ndo_start_xmit = NULL, |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
159 + .ndo_start_xmit = rtx_ethernet_xmit, |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
160 }; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
161 } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
162 |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
163 @@ -159,9 +180,6 @@ |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
164 { |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
165 chunk ::CALL |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
166 { |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
167 - struct net_device *net_dev; |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
168 - |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
169 - net_dev = pci_get_drvdata(pdev); // should be ${pdev}, see above |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
170 unregister_netdev(net_dev); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
171 /* |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
172 * If we had some cleanup todo with struct rtx_ether_ctx we would |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
173 diff -r 86594bdb2ed6 rathaxes/samples/lkm/ethernet.rti |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
174 --- a/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 20:51:10 2012 +0100 |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
175 +++ b/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 20:51:27 2012 +0100 |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
176 @@ -1,4 +1,4 @@ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
177 -interface Ethernet : PCI, LKM |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
178 +interface Ethernet : Socket, PCI, LKM |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
179 { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
180 provided type Ethernet::Device; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
181 |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
182 @@ -10,6 +10,12 @@ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
183 provided chunk LKM::code; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
184 } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
185 |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
186 + required sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
187 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
188 + provided chunk LKM::prototypes; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
189 + provided chunk LKM::code; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
190 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
191 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
192 required sequence Ethernet::close(Ethernet::Device) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
193 { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
194 provided chunk LKM::prototypes; |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
195 diff -r 86594bdb2ed6 rathaxes/samples/lkm/lkm.rtx |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
196 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 20:51:10 2012 +0100 |
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
197 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 20:51:27 2012 +0100 |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
198 @@ -15,15 +15,22 @@ |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
199 Log::info("Got an interruption"); |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
200 } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
201 |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
202 + Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
203 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
204 + Log::info("We have one packet to transmit!"); |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
205 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
206 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
207 PCI::probe(PCI::Device dev) |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
208 { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
209 Log::info("Probe the device"); |
23 | 210 Ethernet::init(dev); |
211 + e1000::create(); | |
212 } | |
213 | |
214 PCI::remove(PCI::Device dev) | |
26
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
215 { |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
216 Log::info("Remove the pci device"); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
217 + e1000::destroy(); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
218 Ethernet::exit(dev); |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
219 } |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
220 |
8eac832f763d
rathaxes: free the pci resources
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
25
diff
changeset
|
221 @@ -45,10 +52,11 @@ |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
222 LKM::name = "hello"; |
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
223 LKM::author = "Rathaxes"; |
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
224 LKM::description = "Hello World Loadable Kernel Module (LKM)"; |
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
225 - LKM::license = "BSD"; |
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
226 + LKM::license = "GPL"; |
24
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
227 |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
228 PCI::vendor_id = 0x8086; |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
229 PCI::product_id = 0x100f; |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
230 + PCI::set_master = true; |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
231 |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
232 Ethernet::ifname = "rtx%d"; |
60dd543b67b0
WIP on the e1000 pci stuff
Louis Opter <louis@lse.epitech.net>
parents:
23
diff
changeset
|
233 } |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
234 diff -r 86594bdb2ed6 rathaxes/samples/lkm/socket.blt |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
235 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
236 +++ b/rathaxes/samples/lkm/socket.blt Sat Jan 07 20:51:27 2012 +0100 |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
237 @@ -0,0 +1,27 @@ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
238 +with Socket, LKM |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
239 +{ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
240 + template type Socket::SKBuff() |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
241 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
242 + chunk LKM::includes() |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
243 + { |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
244 + #include <linux/skbuff.h> |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
245 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
246 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
247 + chunk ::decl() |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
248 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
249 + struct sk_buff; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
250 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
251 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
252 + chunk ::init() |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
253 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
254 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
255 + |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
256 + map |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
257 + { |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
258 + // some work may have to be done here in order |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
259 + // to access to some field of the sk_buff. |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
260 + // We should determine if all the sk_buff managment |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
261 + // can be abstracted from the user. |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
262 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
263 + } |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
264 +} |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
265 diff -r 86594bdb2ed6 rathaxes/samples/lkm/socket.rti |
25
e330b0cea45e
rathaxes: workaround resolution bug + update the license since we use pci_ioremap which is only available for gpl driver
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
24
diff
changeset
|
266 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
29
1b7399e39afd
rathaxes: fix bad include name
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
26
diff
changeset
|
267 +++ b/rathaxes/samples/lkm/socket.rti Sat Jan 07 20:51:27 2012 +0100 |
20
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
268 @@ -0,0 +1,4 @@ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
269 +interface Socket : LKM |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
270 +{ |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
271 + provided type Socket::SKBuff; |
ecf2a0e61fff
rathaxes: add sk_buff stuff
Thomas Sanchez <thomas.sanchz@gmail.com>
parents:
diff
changeset
|
272 +} |