changeset 86:c99e69966dd3

WIP/Cleanup on the tranmission
author Louis Opter <louis@lse.epitech.net>
date Tue, 18 Sep 2012 08:57:14 +0200
parents 5dda73e7d728
children e9736ab70995
files e1000_implement_the_frame_transmission_chunk.patch
diffstat 1 files changed, 136 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/e1000_implement_the_frame_transmission_chunk.patch	Fri Sep 14 08:58:35 2012 +0200
+++ b/e1000_implement_the_frame_transmission_chunk.patch	Tue Sep 18 08:57:14 2012 +0200
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent 41aa481c1ba8a54a7291ac2630f2eebc50022f33
+# Parent 42d6e2a573d077772c1a9c697cc066337569b129
 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
@@ -16,11 +16,78 @@
 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
-@@ -964,4 +964,52 @@
+@@ -332,6 +332,30 @@
+         }
+     }
+ 
++    template type   e1000::TxFlags()
++    {
++        chunk LKM::includes()
++        {
++            static const ${e1000::TxFlags}  force_enum_rtx_e1000_tx_flags_decl;
++        }
++
++        chunk ::decl()
++        {
++            enum    rtx_e1000_tx_flags
++            {
++                E1000_TX_FLAGS_CSUM     = 0x00000001,
++                E1000_TX_FLAGS_VLAN     = 0x00000002,
++                E1000_TX_FLAGS_TSO      = 0x00000004,
++                E1000_TX_FLAGS_IPV4     = 0x00000008,
++                E1000_TX_FLAGS_NO_FCS   = 0x00000010,
++            };
++        }
++
++        map
++        {
++        }
++    }
++
+     template sequence   e1000::create_device()
+     {
+         chunk Ethernet::create_device(PCI::Device pdev, Ethernet::Device rtx_ether_ctx)
+@@ -964,4 +988,86 @@
              }
          }
      }
 +
++    template sequence   e1000::_xmit_tso_cksum_offload(Ethernet::Device ctx, Socket::SKBuff skb)
++    {
++        chunk   ::CALL()
++        {
++            if (skb_is_gso(${skb}) || ${skb}->ip_summed == CHECKSUM_PARTIAL)
++            {
++                ${Log::info("xmit: the packet needs to be fragmented and/or checksummed but this not implemented yet!")};
++                return NETDEV_TX_OK;
++            }
++        }
++    }
++
++    template sequence   e1000::_xmit_map_skbuff(Ethernet::Device ctx, Socket::SKBuff skb)
++    {
++        chunk   ::CALL()
++        {
++            dma_addr_t buff_addr = dma_map_single(
++                    &${ctx}->pci_dev->dev,
++                    ${skb}->data,
++                    skb_headlen(${skb}),
++                    DMA_TO_DEVICE);
++            if (dma_mapping_error(&${ctx}->pci_dev->dev, buff_addr))
++            {
++                ${Log::info("xmit: can't DMA map a SKBuff")};
++                goto err_dma_map;
++            }
++        }
++    }
++
++    template sequence   e1000::_xmit_update_tx_ring(Ethernet::Device, Socket::SKBuff skb)
++    {
++        chunk   ::CALL()
++        {
++        }
++    }
++
 +    template sequence   e1000::xmit(Ethernet::Device ctx, Socket::SKBuff skb)
 +    {
 +        chunk   ::CALL()
@@ -39,32 +106,30 @@
 +
 +            /*
 +             * The transmission is going to be several steps:
-+             * - TCP Segmentation Offload & Checksum Offloading: pick a
-+             *   descriptor from the tx ring and fill it as a context descriptor
-+             *   to allow the card to slice into several packets according to
-+             *   the MSS;
-+             * - DMA Map the skbuff data as slices of 4096;
-+             * - Signal the hardware that data is available via a tx desc.
++             * 1. TCP Segmentation Offload & Checksum Offloading: pick a
++             *    descriptor from the tx ring and fill it as a contex
++             *    descriptor to allow the card to slice into several packets
++             *    according to the MSS;
++             * 2. DMA Map the skbuff data as slices of 4096;
++             * 3. Signal the hardware that data is available via a tx desc.
 +             */
 +
-+            if (skb_is_gso(${skb}) || ${skb}->ip_summed == CHECKSUM_PARTIAL)
-+            {
-+                ${Log::info("xmit: the packet needs to be fragmented and/or checksummed but this not implemented yet!")};
-+                return NETDEV_TX_OK;
++            /* 1. Offloading */
++            { // workaround #10 (and it's useful to workaround #47 too)
++                ${e1000::_xmit_tso_cksum_offload(ctx, skb)};
 +            }
 +
-+            /* XXX ${ctx} expands into skb */
-+            dma_addr_t buff_addr = dma_map_single(
-+                    &${ctx}->pci_dev->dev,
-+                    ${skb}->data,
-+                    skb_headlen(${skb}),
-+                    DMA_TO_DEVICE);
-+            if (dma_mapping_error(&${ctx}->pci_dev->dev, buff_addr))
++            /* 2. Map the data */
 +            {
-+                ${Log::info("xmit: can't DMA map a SKBuff")};
-+                /* now what, should I free the skb? */
++                ${e1000::_xmit_map_skbuff(ctx, skb)};
 +            }
 +
++            /* 3. Update the TX Ring */
++            {
++                ${e1000::_xmit_update_tx_ring(ctx, skb)};
++            }
++
++        err_dma_map:
 +            return NETDEV_TX_OK;
 +        }
 +    }
@@ -72,10 +137,38 @@
 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
-@@ -109,6 +109,11 @@
+@@ -51,6 +51,12 @@
+         method      decl();
+     }
+ 
++    provided type   TxFlags
++    {
++        chunk       LKM::includes();
++        chunk       ::decl();
++    }
++
+     provided sequence   create_device()
+     {
+         provided chunk  Ethernet::create_device(PCI::Device, Ethernet::Device);
+@@ -109,6 +115,26 @@
          provided chunk  ::CALL();
      }
  
++    provided sequence   _xmit_tso_cksum_offload(Ethernet::Device, Socket::SKBuff)
++    {
++        provided chunk  ::CALL();
++    }
++
++    provided sequence   _xmit_map_skbuff(Ethernet::Device, Socket::SKBuff)
++    {
++        provided chunk  ::CALL();
++    }
++
++    provided sequence   _xmit_update_tx_ring(Ethernet::Device, Socket::SKBuff)
++    {
++        provided chunk  ::CALL();
++    }
++
 +    provided sequence   xmit(Ethernet::Device, Socket::SKBuff)
 +    {
 +        provided chunk  ::CALL();
@@ -180,7 +273,7 @@
 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 @@
+@@ -1,16 +1,33 @@
  interface Ethernet : Socket, PCI, LKM
  {
 -    provided type   Net
@@ -199,7 +292,7 @@
 +    provided type   AbstractDevice
      {
          chunk       LKM::includes();
-         chunk       ::decl();
+         method       decl();
      }
  
 +    /*
@@ -210,6 +303,12 @@
      provided type   Device
      {
          chunk       LKM::includes();
+         method      decl();
+-        method      init(Ethernet::Net, PCI::Device);
++        method      init(Ethernet::AbstractDevice, PCI::Device);
+     }
+ 
+     required variable ::string  ifname;
 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
@@ -241,7 +340,15 @@
  {
      template type Socket::SKBuff()
      {
-@@ -17,6 +17,34 @@
+@@ -10,13 +10,41 @@
+ 
+         chunk ::decl()
+         {
+-            struct sk_buff;
++            typedef struct sk_buff  *rtx_socket_skbuff_p;
+         }
+ 
+         chunk ::init()
          {
          }
  
@@ -264,7 +371,7 @@
 +                    "\t      len = %-5u data_len = %-5u head_len = %-5u\n"
 +                    "\t nr_frags = %u\n"
 +                    "\t gso_size = %-5u gso_segs = %-5u gso_type = %-5u\n"
-+                    "\tip_summed = %d\n (%s)",
++                    "\tip_summed = %d (%s)",
 +                    ethernet_proto, "", // XXX: ${local.ethernet_proto.to_str()},
 +                    ${self}->len, ${self}->data_len, skb_headlen(${self}),
 +                    skb_shinfo(${self})->nr_frags,
@@ -283,12 +390,11 @@
  interface Socket : LKM
  {
 -    provided type Socket::SKBuff {
--        chunk LKM::includes();
--        chunk ::decl();
--        method ::init();
 +    provided type Socket::SKBuff
 +    {
-+        chunk   LKM::includes();
+         chunk   LKM::includes();
+-        method  decl();
+-        method  init();
 +        chunk   ::decl();
 +        method  ::init();
 +        method  ::dump_infos();