Mercurial > archived > louis > epitech > mq > rathaxes
comparison rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch @ 21:052f9209ca09
rathaxes:: add the ifs
author | Thomas Sanchez <thomas.sanchz@gmail.com> |
---|---|
date | Sat, 07 Jan 2012 18:30:20 +0100 |
parents | 670925d566c7 |
children | 65523c345b40 |
comparison
equal
deleted
inserted
replaced
20:ecf2a0e61fff | 21:052f9209ca09 |
---|---|
1 # HG changeset patch | 1 # HG changeset patch |
2 # Parent 5c8a128a8804aa592e3ccc74e86e109d0b577896 | 2 # Parent 2d1319eabf8acf2a7afeb6c8061d7a2c4793655f |
3 rathaxes: start to implement the Ethernet subsystem in linux LKM sample | 3 rathaxes: start to implement the Ethernet subsystem in linux LKM sample |
4 | 4 |
5 diff -r 5c8a128a8804 rathaxes/samples/lkm/CMakeLists.txt | 5 diff -r 2d1319eabf8a rathaxes/samples/lkm/CMakeLists.txt |
6 --- a/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 11:23:27 2012 +0100 | 6 --- a/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 18:13:48 2012 +0100 |
7 +++ b/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 12:15:32 2012 +0100 | 7 +++ b/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 18:27:27 2012 +0100 |
8 @@ -1,6 +1,6 @@ | 8 @@ -1,6 +1,6 @@ |
9 ADD_RATHAXES_SOURCES(lkm lkm.rtx | 9 ADD_RATHAXES_SOURCES(lkm lkm.rtx |
10 - RTI log.rti lkm.rti pci.rti | 10 - RTI log.rti lkm.rti pci.rti |
11 - BLT log.blt lkm.blt pci.blt) | 11 - BLT log.blt lkm.blt pci.blt) |
12 + RTI log.rti lkm.rti pci.rti ethernet.rti | 12 + RTI log.rti lkm.rti pci.rti ethernet.rti |
13 + BLT log.blt lkm.blt pci.blt ethernet.blt) | 13 + BLT log.blt lkm.blt pci.blt ethernet.blt) |
14 | 14 |
15 # We can't name lkm since it's already used as the target name to generate the | 15 # We can't name lkm since it's already used as the target name to generate the |
16 # source (with ADD_RATHAXES_SOURCES). | 16 # source (with ADD_RATHAXES_SOURCES). |
17 diff -r 5c8a128a8804 rathaxes/samples/lkm/ethernet.blt | 17 diff -r 2d1319eabf8a rathaxes/samples/lkm/ethernet.blt |
18 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 18 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
19 +++ b/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 12:15:32 2012 +0100 | 19 +++ b/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 18:27:27 2012 +0100 |
20 @@ -0,0 +1,164 @@ | 20 @@ -0,0 +1,173 @@ |
21 +with Ethernet, PCI, LKM | 21 +with Ethernet, PCI, LKM |
22 +{ | 22 +{ |
23 + template type Ethernet::Device() | 23 + template type Ethernet::Device() |
24 + { | 24 + { |
25 + chunk LKM::includes() | 25 + chunk LKM::includes() |
131 + * dialect. | 131 + * dialect. |
132 + */ | 132 + */ |
133 + typedef int ${Ethernet::Device}; | 133 + typedef int ${Ethernet::Device}; |
134 + ${Ethernet::Device} *rtx_ether_ctx; | 134 + ${Ethernet::Device} *rtx_ether_ctx; |
135 + struct net_device *net_dev; | 135 + struct net_device *net_dev; |
136 + | 136 + int error; |
137 + | |
138 + error = 0; | |
137 + net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx)); | 139 + net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx)); |
138 + //if (net_dev == NULL) | 140 + if (net_dev == 0) |
139 + // How should we raise the error in the parent context? | 141 + { |
142 + //Log::info("Cannot allocate memory"); | |
143 + // is it the thing to do? | |
144 + return -ENOMEM; | |
145 + } | |
140 + strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name)); | 146 + strlcpy(net_dev->name, ${config.ifname}, sizeof(net_dev->name)); |
141 + net_dev->irq = pdev->irq; | 147 + net_dev->irq = pdev->irq; |
142 + // Maybe we should try ${rtx_ether_ctx.init()} here: | 148 + // Maybe we should try ${rtx_ether_ctx.init()} here: |
143 + rtx_ether_ctx = netdev_priv(net_dev); | 149 + rtx_ether_ctx = netdev_priv(net_dev); |
144 + //rtx_ether_ctx->pci_dev = ${pdev}; | 150 + //rtx_ether_ctx->pci_dev = ${pdev}; |
154 + * That's why we cheated a bit and named all the arguments pdev. | 160 + * That's why we cheated a bit and named all the arguments pdev. |
155 + */ | 161 + */ |
156 + //SET_NETDEV_DEV(net_dev, &${pdev}->dev); | 162 + //SET_NETDEV_DEV(net_dev, &${pdev}->dev); |
157 + SET_NETDEV_DEV(net_dev, &pdev->dev); | 163 + SET_NETDEV_DEV(net_dev, &pdev->dev); |
158 + net_dev->netdev_ops = &rtx_ether_ops; | 164 + net_dev->netdev_ops = &rtx_ether_ops; |
159 + | 165 + if ((error = register_netdev(net_dev))) |
160 + /* if (*/register_netdev(net_dev);/*)*/ | 166 + { |
161 + // Handle the error | 167 + // Log::info("Cannot register the driver"); |
168 + // is it the thing to do? | |
169 + return error; | |
170 + } | |
162 + | 171 + |
163 + /* same problem as above with ${pdev} */ | 172 + /* same problem as above with ${pdev} */ |
164 + //pci_set_drvdata(${pdev}, net_dev); | 173 + //pci_set_drvdata(${pdev}, net_dev); |
165 + pci_set_drvdata(pdev, net_dev); | 174 + pci_set_drvdata(pdev, net_dev); |
166 + } | 175 + } |
180 + */ | 189 + */ |
181 + free_netdev(net_dev); | 190 + free_netdev(net_dev); |
182 + } | 191 + } |
183 + } | 192 + } |
184 +} | 193 +} |
185 diff -r 5c8a128a8804 rathaxes/samples/lkm/ethernet.rti | 194 diff -r 2d1319eabf8a rathaxes/samples/lkm/ethernet.rti |
186 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 195 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
187 +++ b/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 12:15:32 2012 +0100 | 196 +++ b/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 18:27:27 2012 +0100 |
188 @@ -0,0 +1,37 @@ | 197 @@ -0,0 +1,37 @@ |
189 +interface Ethernet : PCI, LKM | 198 +interface Ethernet : PCI, LKM |
190 +{ | 199 +{ |
191 + provided type Ethernet::Device; | 200 + provided type Ethernet::Device; |
192 + | 201 + |
221 + provided sequence Ethernet::exit(PCI::Device) | 230 + provided sequence Ethernet::exit(PCI::Device) |
222 + { | 231 + { |
223 + provided chunk ::CALL; | 232 + provided chunk ::CALL; |
224 + } | 233 + } |
225 +} | 234 +} |
226 diff -r 5c8a128a8804 rathaxes/samples/lkm/lkm.rtx | 235 diff -r 2d1319eabf8a rathaxes/samples/lkm/lkm.rtx |
227 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 11:23:27 2012 +0100 | 236 --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 18:13:48 2012 +0100 |
228 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 12:15:32 2012 +0100 | 237 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 18:27:27 2012 +0100 |
229 @@ -1,13 +1,30 @@ | 238 @@ -1,13 +1,30 @@ |
230 device LKM use LKM, PCI, Log | 239 device LKM use LKM, PCI, Log |
231 { | 240 { |
232 + Ethernet::open(Ethernet::Device dev) | 241 + Ethernet::open(Ethernet::Device dev) |
233 + { | 242 + { |
264 PCI::vendor_id = 0x8086; | 273 PCI::vendor_id = 0x8086; |
265 PCI::product_id = 0x100f; | 274 PCI::product_id = 0x100f; |
266 + | 275 + |
267 + Ethernet::ifname = "rtx%d"; | 276 + Ethernet::ifname = "rtx%d"; |
268 } | 277 } |
269 diff -r 5c8a128a8804 rathaxes/samples/lkm/pci.blt | 278 diff -r 2d1319eabf8a rathaxes/samples/lkm/pci.blt |
270 --- a/rathaxes/samples/lkm/pci.blt Sat Jan 07 11:23:27 2012 +0100 | 279 --- a/rathaxes/samples/lkm/pci.blt Sat Jan 07 18:13:48 2012 +0100 |
271 +++ b/rathaxes/samples/lkm/pci.blt Sat Jan 07 12:15:32 2012 +0100 | 280 +++ b/rathaxes/samples/lkm/pci.blt Sat Jan 07 18:27:27 2012 +0100 |
272 @@ -11,15 +11,12 @@ | 281 @@ -11,15 +11,12 @@ |
273 | 282 |
274 chunk ::decl() | 283 chunk ::decl() |
275 { | 284 { |
276 - struct rtx_pci_device | 285 - struct rtx_pci_device |
315 - | 324 - |
316 int err; | 325 int err; |
317 - ${PCI::Device} *dev = NULL; | 326 - ${PCI::Device} *dev = NULL; |
318 | 327 |
319 err = pci_enable_device(pdev); | 328 err = pci_enable_device(pdev); |
320 // if (err < 0) /* `if' doesn't work */ | 329 if (err < 0) |
321 @@ -52,8 +55,6 @@ | 330 @@ -52,8 +55,6 @@ |
322 | 331 |
323 ${pointcut ::IMPLEMENTATION}; | 332 ${pointcut ::IMPLEMENTATION}; |
324 | 333 |
325 - pci_set_drvdata(pdev, dev); | 334 - pci_set_drvdata(pdev, dev); |