Mercurial > archived > louis > epitech > mq > rathaxes
view rathaxes_start_to_implement_sk_buff_in_the_lkm.patch @ 23:f0ab7ee21dd8
Merge
author | Louis Opter <kalessin@kalessin.fr> |
---|---|
date | Sat, 07 Jan 2012 19:28:54 +0100 |
parents | 65523c345b40 |
children | 60dd543b67b0 |
line wrap: on
line source
# HG changeset patch # Parent 7ed8c85f91b681a259ea6f7fcb39ec9ed4591a57 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 --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt --- a/rathaxes/samples/lkm/CMakeLists.txt +++ b/rathaxes/samples/lkm/CMakeLists.txt @@ -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 e1000.rti + BLT log.blt lkm.blt pci.blt socket.blt ethernet.blt e1000.blt) # We can't name lkm since it's already used as the target name to generate the # source (with ADD_RATHAXES_SOURCES). diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt new file mode 100644 --- /dev/null +++ b/rathaxes/samples/lkm/e1000.blt @@ -0,0 +1,40 @@ +with e1000, Ethernet, Socket, PCI, LKM, Log +{ + template type e1000::Context() + { + chunk LKM::includes() + { + /* + * Force the generation of the structure in the "headers part, we + * have to do this since we do not use the structure in this blt + * (we hacked a bit and used it in ethernet.blt directly). + */ + typedef int ${e1000::Context}; /* CNorm __std__ workaround */ + ${e1000::Context} force_declaration_in_includes; + } + + chunk ::decl() + { + struct rtx_e1000_ctx + { + unsigned char *bar; + }; + } + + map + { + } + } + + template sequence e1000::create() + { + chunk ::CALL + { + int bars = pci_select_bars(pdev, IORESOURCE_MEM); + if (pci_enable_device_mem(pdev)) + { + ${Log::info("e1000::create: pci_enable_device_mem failed")}; + } + } + } +} diff --git a/rathaxes/samples/lkm/e1000.rti b/rathaxes/samples/lkm/e1000.rti new file mode 100644 --- /dev/null +++ b/rathaxes/samples/lkm/e1000.rti @@ -0,0 +1,10 @@ +interface e1000 : Socket, Ethernet, PCI, LKM +{ + provided type e1000::Context; + + /* Not sure if we need the argument */ + provided sequence e1000::create() + { + provided chunk ::CALL; + } +} diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt --- a/rathaxes/samples/lkm/ethernet.blt +++ b/rathaxes/samples/lkm/ethernet.blt @@ -1,4 +1,4 @@ -with Ethernet, PCI, LKM +with Ethernet, Socket, PCI, LKM { template type Ethernet::Device() { @@ -18,8 +18,11 @@ * I think it's useless to use the ${PCI::Device} "abstraction" * here, since we are already in a Linux specific context here. */ - struct pci_dev *pci_dev; - struct net_device *net_dev; + struct pci_dev *pci_dev; + struct net_device *net_dev; + + /* while waiting on issue #8 */ + struct rtx_e1000_ctx hw_ctx; }; } @@ -51,6 +54,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 +121,7 @@ { .ndo_open = rtx_ethernet_open, .ndo_stop = rtx_ethernet_close, - .ndo_start_xmit = NULL, + .ndo_start_xmit = rtx_ethernet_xmit, }; } diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti --- a/rathaxes/samples/lkm/ethernet.rti +++ b/rathaxes/samples/lkm/ethernet.rti @@ -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 --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx --- a/rathaxes/samples/lkm/lkm.rtx +++ b/rathaxes/samples/lkm/lkm.rtx @@ -15,10 +15,16 @@ 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"); Ethernet::init(dev); + e1000::create(); } PCI::remove(PCI::Device dev) diff --git a/rathaxes/samples/lkm/socket.blt b/rathaxes/samples/lkm/socket.blt new file mode 100644 --- /dev/null +++ b/rathaxes/samples/lkm/socket.blt @@ -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 --git a/rathaxes/samples/lkm/socket.rti b/rathaxes/samples/lkm/socket.rti new file mode 100644 --- /dev/null +++ b/rathaxes/samples/lkm/socket.rti @@ -0,0 +1,4 @@ +interface Socket : LKM +{ + provided type Socket::SKBuff; +}