changeset 135:9c6ae3a2e180

Wip, fixes + workarounds
author Louis Opter <kalessin@kalessin.fr>
date Sat, 11 Jan 2014 18:42:05 -0800
parents 79226bb06e6a
children 8229a46ec658
files rathaxes_sample_e1000_rewrite_device_dependent_code.patch
diffstat 1 files changed, 20 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/rathaxes_sample_e1000_rewrite_device_dependent_code.patch	Sat Jan 11 16:34:30 2014 -0800
+++ b/rathaxes_sample_e1000_rewrite_device_dependent_code.patch	Sat Jan 11 18:42:05 2014 -0800
@@ -696,7 +696,7 @@
          {
              E1000_TXD_DTYP_D        = 0x00100000, /* Data Descriptor */
              E1000_TXD_DTYP_C        = 0x00000000, /* Context Descriptor */
-@@ -701,326 +140,683 @@
+@@ -701,326 +140,687 @@
          }
      }
  
@@ -898,17 +898,19 @@
 +        chunk Ethernet::adapter_init_context(Ethernet::Device rtx_ether_ctx, Builtin::symbol io_addr)
 +        {
 +            {
-+                ${e1000::Context.ref} hw_ctx = &${local.rtx_ether_ctx}->hw_ctx;
-+                ${local.hw_ctx.init(local.rtx_ether_ctx, local.io_addr)};
-+                ${local.hw_ctx.rx_ring.init(local.hw_ctx.io, config.rx_ring_size)};
-+                ${local.hw_ctx.tx_ring.init(local.hw_ctx.io, config.tx_ring_size)};
++                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
++                // XXX doesn't work: ${local.hw_ctx.init(rtx_ether_ctx, io_addr)};
++                ${local.hw_ctx.net_dev} = ${rtx_ether_ctx};
++                ${local.hw_ctx.io_addr} = ${io_addr};
++                ${local.hw_ctx.rx_ring.init(local.hw_ctx, config.rx_ring_size)};
++                ${local.hw_ctx.tx_ring.init(local.hw_ctx, config.tx_ring_size)};
 +            }
 +        }
 +
 +        chunk Ethernet::adapter_reset(Ethernet::Device rtx_ether_ctx)
 +        {
 +            {
-+                ${e1000::Context.ref} hw_ctx = &${local.rtx_ether_ctx}->hw_ctx;
++                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +                // XXX #46: ${local.hw_ctx.io.write32(E1000_CTRL, E1000_CMD_RST)};
 +                rtx_e1000_reg_write32(hw_ctx, E1000_CTRL, E1000_CMD_RST);
 +                udelay(10); // TODO: abstract udelay too...
@@ -919,7 +921,7 @@
 +        chunk Ethernet::adapter_load_mac_address(Ethernet::Device rtx_ether_ctx)
 +        {
 +            {
-+                ${e1000::Context.ref} hw_ctx = &${local.rtx_ether_ctx}->hw_ctx;
++                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +                // Shamelessly borrowed from Minix
 +                for (int i = 0; i < 3; ++i) {
 +                    rtx_e1000_reg_write32(hw_ctx, E1000_EEPROM_READ, (i << 8) | 1);
@@ -932,8 +934,8 @@
 +                    // accessed directly here. But since we need to take it in
 +                    // parameter (so we can get back our e1000::Context) it
 +                    // seems inadequate to set this in another way:
-+                    ${local.rtx_ether_ctx.dev_addr}[i * 2] = value & 0xff;
-+                    ${local.rtx_ether_ctx.dev_addr}[i * 2 + 1] = (value >> 8) & 0xff;
++                    ${rtx_ether_ctx.dev_addr}[i * 2] = value & 0xff;
++                    ${rtx_ether_ctx.dev_addr}[i * 2 + 1] = (value >> 8) & 0xff;
 +                }
 +
 +                ${Log::info("mac address loaded from the EEPROM")};
@@ -946,7 +948,7 @@
 +        chunk Ethernet::adapter_setup_rx_tx(Ethernet::Device rtx_ether_ctx)
 +        {
 +            {
-+                ${e1000::Context.ref} hw_ctx = &${local.rtx_ether_ctx}->hw_ctx;
++                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +
 +                // "General Configuration" (section 14.3):
 +                //
@@ -1001,7 +1003,7 @@
 +        chunk Ethernet::adapter_enable_interrupts(Ethernet::Device)
 +        {
 +            {
-+                ${e1000::Context.ref} hw_ctx = &${local.rtx_ether_ctx}->hw_ctx;
++                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +                rtx_e1000_reg_write32(
 +                    hw_ctx,
 +                    E1000_IMS,
@@ -1025,7 +1027,7 @@
 +        chunk Ethernet::adapter_handle_interrupt(Ethernet::Device rtx_ether_ctx)
 +        {
 +            {
-+                ${e1000::Context.ref} hw_ctx = &${local.rtx_ether_ctx}->hw_ctx;
++                ${e1000::Context.ref} hw_ctx = &${rtx_ether_ctx}->hw_ctx;
 +                unsigned int icr = rtx_e1000_reg_read32(hw_ctx, E1000_ICR);
 +                pr_info("%s: interrupt received, ICR: 0x%x", ${config.name}, icr);
 +                if (icr) {
@@ -1209,8 +1211,8 @@
 +//                      goto err_skbuffs_alloc;
 +//                  }
 +//                  /* TODO: recuperer le dma handle et le placer correctement dans le descripteur. */
-+//                  ${DMA::map(local.rtx_ether_ctx.device, local.skbuff.data, local.skbuff.len, RTX_DMA_FROM_DEVICE)}
-+//                  if (${DMA::map(local.rtx_ether_ctx.device, local.skbuff.data, local.skbuff.len, RTX_DMA_FROM_DEVICE)}) {
++//                  ${DMA::map(rtx_ether_ctx.device, local.skbuff.data, local.skbuff.len, RTX_DMA_FROM_DEVICE)}
++//                  if (${DMA::map(rtx_ether_ctx.device, local.skbuff.data, local.skbuff.len, RTX_DMA_FROM_DEVICE)}) {
 +//                      ${Log::info("adapter_init_rx: cannot dma-map a skbuff for the rx ring")};
 +//                      goto err_skbuffs_map;
 +//                  }
@@ -1335,7 +1337,8 @@
 +        method init(e1000::Context hw_ctx, Builtin::number desc_count)
          {
 -            rtx_e1000_register_write32(${ctx}, ${reg_offset}, ${value});
-+            ${self.ring.init(hw_ctx, desc_count, self.desc_size)};
++            // XXX doesn't work: ${self.ring.init(hw_ctx, desc_count, self.desc_size)};
++            rtx_e1000_ring_init(&${self}, ${hw_ctx}, ${desc_count}, ${self.desc_size});
 +        }
 +
 +        method alloc()
@@ -1420,7 +1423,8 @@
 -        {
 -            /* FIXME: See issue #54 */
 -            static void rtx_e1000_register_unset32(/*const*/ ${e1000::Context.ref}, unsigned int, unsigned int);
-+            ${self.ring.init(hw_ctx, desc_count, self.desc_size)};
++            // XXX doesn't work: ${self.ring.init(hw_ctx, desc_count, self.desc_size)};
++            rtx_e1000_ring_init(&${self}, ${hw_ctx}, ${desc_count}, ${self.desc_size});
          }
  
 -        chunk   LKM::code()