diff e1000_implement_the_frame_transmission_chunk.patch @ 84:6432998a8245

Finish the patches on the rx/tx init and wip on the actual tx
author Louis Opter <louis@lse.epitech.net>
date Mon, 09 Jul 2012 06:44:51 +0200
parents 27f0e70df342
children 5dda73e7d728
line wrap: on
line diff
--- a/e1000_implement_the_frame_transmission_chunk.patch	Sun Jul 08 10:00:25 2012 +0200
+++ b/e1000_implement_the_frame_transmission_chunk.patch	Mon Jul 09 06:44:51 2012 +0200
@@ -1,20 +1,22 @@
 # HG changeset patch
-# Parent 1a5a83776de5ecff15e42930c7741f5b4f2ada13
+# Parent 72f11dd4265bb367278f34b23ecb5afa0f7f6fb7
 rathaxes: start to queue up packets in the TX ring on the e1000 sample
 
+diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in
+--- a/maintainers/CMakeScripts/Templates/MakefileLKM.in
++++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in
+@@ -1,6 +1,6 @@
+ # Disable this "coding-style" warning (seriously, you have to compile with
+ # -pedantic to get it...)
+-EXTRA_CFLAGS	= -Wno-declaration-after-statement
++EXTRA_CFLAGS	= -Wno-declaration-after-statement -std=gnu99
+ 
+ KDIR		= /lib/modules/$(shell uname -r)/build
+ obj-m		:= @LKM_OBJECTS@
 diff --git a/rathaxes/samples/e1000/e1000.blt b/rathaxes/samples/e1000/e1000.blt
 --- a/rathaxes/samples/e1000/e1000.blt
 +++ b/rathaxes/samples/e1000/e1000.blt
-@@ -597,7 +597,7 @@
- 
-         chunk   ::CALL()
-         {
--            // this is an hack for the scope
-+            // See #10
-             (void)1;
-             {
-                 int error;
-@@ -970,4 +970,31 @@
+@@ -964,4 +964,20 @@
              }
          }
      }
@@ -23,44 +25,143 @@
 +    {
 +        chunk   ::CALL()
 +        {
++            (void)1; // Issue 10
 +            /*
 +             * Put packets on the TX ring, must return NETDEV_TX_OK or
 +             * NETDEV_TX_BUSY.
 +             */
-+            (void)1; // See #10
 +            {
 +                ${Log::info("xmit: skbuff details:")};
++                ${skb.dump_infos()};
 +            }
-+            pr_info(
-+                    "\t     len = %-5u data_len = %-5u head_len = %-5u\n"
-+                    "\tnr_frags = %u\n"
-+                    "\tgso_size = %-5u gso_segs = %-5u gso_type = %-5u\n",
-+                    ${skb}->len,
-+                    ${skb}->data_len,
-+                    skb_headlen(${skb}),
-+                    skb_shinfo(${skb})->nr_frags,
-+                    skb_shinfo(${skb})->gso_size,
-+                    skb_shinfo(${skb})->gso_segs,
-+                    skb_shinfo(${skb})->gso_type
-+            );
 +        }
 +    }
  }
 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
 --- a/rathaxes/samples/e1000/e1000.rti
 +++ b/rathaxes/samples/e1000/e1000.rti
-@@ -70,6 +70,11 @@
+@@ -109,6 +109,11 @@
          provided chunk  ::CALL();
      }
  
-+    provided sequence   e1000::xmit(Ethernet::Device, Socket::SKBuff)
++    provided sequence   xmit(Ethernet::Device, Socket::SKBuff)
 +    {
 +        provided chunk  ::CALL();
 +    }
 +
-     provided sequence   e1000::register_read32(e1000::Context, e1000::Register)
+     provided sequence   register_read32(e1000::Context, e1000::Register)
      {
          provided chunk  LKM::prototypes();
+diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
+--- a/rathaxes/samples/e1000/ethernet.blt
++++ b/rathaxes/samples/e1000/ethernet.blt
+@@ -1,6 +1,51 @@
+ with Ethernet, PCI, LKM, Log
+ {
+-    template type Ethernet::Net()
++    template type   Ethernet::ProtocolId()
++    {
++        chunk LKM::prototypes()
++        {
++            static const char   *rtx_ethernet_protocol_id_to_str(unsigned short);
++        }
++
++        chunk LKM::data()
++        {
++            static const struct
++            {
++                const unsigned short    id;
++                const char              *name;
++            } rtx_ethernet_proto_table[] =
++            {
++                { ETH_P_IP,     "IPv4"  },
++                { ETH_P_IPV6,   "IPv6"  },
++                { ETH_P_ARP,    "ARP"   },
++            };
++        }
++
++        chunk LKM::code()
++        {
++            static const char   *rtx_ethernet_protocol_id_to_str(unsigned short proto_id)
++            {
++                for (int i = 0;
++                     i != sizeof(rtx_ethernet_proto_table[0]) / sizeof(rtx_ethernet_proto_table);
++                     i++)
++                    if (proto_id == rtx_ethernet_proto_table[i].id)
++                        return rtx_ethernet_proto_table[i].name;
++
++                return "Other";
++            }
++        }
++
++        chunk to_str()
++        {
++            rtx_ethernet_protocol_id_to_str(${self});
++        }
++
++        map
++        {
++        }
++    }
++
++    template type   Ethernet::AbstractDevice()
+     {
+         chunk LKM::includes()
+         {
+@@ -17,11 +62,6 @@
+         }
+     }
+ 
+-    /*
+-     * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
+-     * from Linux. Ethernet::Device is the type that we use in the private
+-     * field of the struct net_device.
+-     */
+     template type   Ethernet::Device()
+     {
+         chunk LKM::includes()
+@@ -52,7 +92,7 @@
+             } *rtx_ethernet_dev_p;
+         }
+ 
+-        chunk ::init(Ethernet::Net net_dev, PCI::Device pci_dev)
++        chunk ::init(Ethernet::AbstractDevice net_dev, PCI::Device pci_dev)
+         {
+             ${self} = netdev_priv(${net_dev});
+             /*
+diff --git a/rathaxes/samples/e1000/ethernet.rti b/rathaxes/samples/e1000/ethernet.rti
+--- a/rathaxes/samples/e1000/ethernet.rti
++++ b/rathaxes/samples/e1000/ethernet.rti
+@@ -1,11 +1,28 @@
+ interface Ethernet : Socket, PCI, LKM
+ {
+-    provided type   Net
++    provided type   ProtocolId
++    {
++        chunk       LKM::prototypes();
++        chunk       LKM::data();
++        chunk       LKM::code();
++        method      ::to_str();
++    }
++
++    /*
++     * This is the abstract type used by the Kernel to represent an ethernet
++     * device.
++     */
++    provided type   AbstractDevice
+     {
+         chunk       LKM::includes();
+         chunk       ::decl();
+     }
+ 
++    /*
++     * Unlike PCI::Device, Ethernet::Device doesn't match the struct net_device
++     * from Linux. Ethernet::Device is the type that we use in the private
++     * field of the struct net_device.
++     */
+     provided type   Device
+     {
+         chunk       LKM::includes();
 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
 --- a/rathaxes/samples/e1000/lkm.rtx
 +++ b/rathaxes/samples/e1000/lkm.rtx
@@ -72,3 +173,63 @@
      }
  
      LKM::init()
+diff --git a/rathaxes/samples/e1000/socket.blt b/rathaxes/samples/e1000/socket.blt
+--- a/rathaxes/samples/e1000/socket.blt
++++ b/rathaxes/samples/e1000/socket.blt
+@@ -1,4 +1,4 @@
+-with Socket, LKM
++with Socket, LKM, Ethernet
+ {
+     template type Socket::SKBuff()
+     {
+@@ -17,6 +17,32 @@
+         {
+         }
+ 
++        chunk ::dump_infos()
++        {
++            /*
++             * We should use a Rathaxes log abstraction instead of pr_info here,
++             * but Rathaxes doesn't support functions with a variable number of
++             * arguments yet.
++             */
++            unsigned short ethernet_proto = be16_to_cpu(${self}->protocol);
++            ${cast local.ethernet_proto as Ethernet::ProtocolId};
++
++            pr_info(
++                    "\tprotocol = %#-5x (%s)\n"
++                    "\t     len = %-5u data_len = %-5u head_len = %-5u\n"
++                    "\tnr_frags = %u\n"
++                    "\tgso_size = %-5u gso_segs = %-5u gso_type = %-5u\n",
++                    ethernet_proto, "", // XXX: ${local.ethernet_proto.to_str()},
++                    ${self}->len,
++                    ${self}->data_len,
++                    skb_headlen(${self}),
++                    skb_shinfo(${self})->nr_frags,
++                    skb_shinfo(${self})->gso_size,
++                    skb_shinfo(${self})->gso_segs,
++                    skb_shinfo(${self})->gso_type
++            );
++        }
++
+         map
+         {
+             // some work may have to be done here in order
+diff --git a/rathaxes/samples/e1000/socket.rti b/rathaxes/samples/e1000/socket.rti
+--- a/rathaxes/samples/e1000/socket.rti
++++ b/rathaxes/samples/e1000/socket.rti
+@@ -1,8 +1,10 @@
+ interface Socket : LKM
+ {
+-    provided type Socket::SKBuff {
+-        chunk LKM::includes();
+-        chunk ::decl();
+-        method ::init();
++    provided type Socket::SKBuff
++    {
++        chunk   LKM::includes();
++        chunk   ::decl();
++        method  ::init();
++        method  ::dump_infos();
+     }
+ }