Mercurial > archived > louis > epitech > mq > rathaxes
view rathaxes_start_to_implement_sk_buff_in_the_lkm.patch @ 20:ecf2a0e61fff
rathaxes: add sk_buff stuff
author | Thomas Sanchez <thomas.sanchz@gmail.com> |
---|---|
date | Sat, 07 Jan 2012 12:46:45 +0100 |
parents | |
children | 65523c345b40 |
line wrap: on
line source
# HG changeset patch # Parent c979b95fd7fbc4c38849cf42a458a50d8d2d6901 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 diff -r c979b95fd7fb rathaxes/samples/lkm/CMakeLists.txt --- a/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 12:15:32 2012 +0100 +++ b/rathaxes/samples/lkm/CMakeLists.txt Sat Jan 07 12:46:06 2012 +0100 @@ -1,6 +1,6 @@ ADD_RATHAXES_SOURCES(lkm lkm.rtx - RTI log.rti lkm.rti pci.rti ethernet.rti - BLT log.blt lkm.blt pci.blt ethernet.blt) + RTI log.rti lkm.rti pci.rti socket.rti ethernet.rti + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt) # We can't name lkm since it's already used as the target name to generate the # source (with ADD_RATHAXES_SOURCES). diff -r c979b95fd7fb rathaxes/samples/lkm/ethernet.blt --- a/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 12:15:32 2012 +0100 +++ b/rathaxes/samples/lkm/ethernet.blt Sat Jan 07 12:46:06 2012 +0100 @@ -1,4 +1,4 @@ -with Ethernet, PCI, LKM +with Ethernet, Socket, PCI, LKM { template type Ethernet::Device() { @@ -51,6 +51,24 @@ } } + template sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) + { + chunk LKM::prototypes() + { + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev); + } + + chunk LKM::code() + { + static int rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev) + { + ${pointcut ::IMPLEMENTATION}; + + return 0; + } + } + } + template sequence Ethernet::close(Ethernet::Device dev) { chunk LKM::prototypes() @@ -100,7 +118,7 @@ { .ndo_open = rtx_ethernet_open, .ndo_stop = rtx_ethernet_close, - .ndo_start_xmit = NULL, + .ndo_start_xmit = rtx_ethernet_xmit, }; } diff -r c979b95fd7fb rathaxes/samples/lkm/ethernet.rti --- a/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 12:15:32 2012 +0100 +++ b/rathaxes/samples/lkm/ethernet.rti Sat Jan 07 12:46:06 2012 +0100 @@ -1,4 +1,4 @@ -interface Ethernet : PCI, LKM +interface Ethernet : Socket, PCI, LKM { provided type Ethernet::Device; @@ -10,6 +10,12 @@ provided chunk LKM::code; } + required sequence Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) + { + provided chunk LKM::prototypes; + provided chunk LKM::code; + } + required sequence Ethernet::close(Ethernet::Device) { provided chunk LKM::prototypes; diff -r c979b95fd7fb rathaxes/samples/lkm/lkm.rtx --- a/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 12:15:32 2012 +0100 +++ b/rathaxes/samples/lkm/lkm.rtx Sat Jan 07 12:46:06 2012 +0100 @@ -15,6 +15,11 @@ Log::info("Got an interruption"); } + Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb) + { + Log::info("We have one packet to transmit!"); + } + PCI::probe(PCI::Device dev) { Log::info("Probe the device"); diff -r c979b95fd7fb rathaxes/samples/lkm/socket.blt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rathaxes/samples/lkm/socket.blt Sat Jan 07 12:46:06 2012 +0100 @@ -0,0 +1,27 @@ +with Socket, LKM +{ + template type Socket::SKBuff() + { + chunk LKM::includes() + { + #include <linux/sk_buff.h> + } + + chunk ::decl() + { + struct sk_buff; + } + + chunk ::init() + { + } + + map + { + // some work may have to be done here in order + // to access to some field of the sk_buff. + // We should determine if all the sk_buff managment + // can be abstracted from the user. + } + } +} diff -r c979b95fd7fb rathaxes/samples/lkm/socket.rti --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rathaxes/samples/lkm/socket.rti Sat Jan 07 12:46:06 2012 +0100 @@ -0,0 +1,4 @@ +interface Socket : LKM +{ + provided type Socket::SKBuff; +}