# HG changeset patch # User Louis Opter # Date 1334451218 -7200 # Node ID 0354cceee7108a5d65faa05da82c9ba23ab6ab75 # Parent f07f6c6d6cd47598ee413fc6ab674067571339ec WIP on e1000, try to add the code to free the RX ring when shutting the interface down diff -r f07f6c6d6cd4 -r 0354cceee710 e1000_initialize_reception.patch --- a/e1000_initialize_reception.patch Sun Apr 15 01:39:59 2012 +0200 +++ b/e1000_initialize_reception.patch Sun Apr 15 02:53:38 2012 +0200 @@ -1,5 +1,5 @@ # HG changeset patch -# Parent 0d14f4eef173e65c3430393966e5f7e3bef7a8b2 +# Parent d8fce7ee2b630bf8bd681fa4d66832b82c5e6de2 rathaxes: initialize reception on the e1000 sample: - This is documented in details in the sections 14.4 and 3.2 of the @@ -173,7 +173,7 @@ * "General Configuration" (section 14.3): * * - CTRL.ASDE/CTRL.SLU: Let the PHY handle the speed detection & -@@ -478,22 +574,152 @@ +@@ -478,22 +574,181 @@ * - Finally, initialize all the statistic registers from * E1000_CRCERRS to E1000_TSCTFC. */ @@ -193,17 +193,17 @@ - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCAL, 0); - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCT, 0); - rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_FCTTV, 0); -- int i = 0; + rtx_e1000_register_write32(hw_ctx, E1000_FCAH, 0); + rtx_e1000_register_write32(hw_ctx, E1000_FCAL, 0); + rtx_e1000_register_write32(hw_ctx, E1000_FCT, 0); + rtx_e1000_register_write32(hw_ctx, E1000_FCTTV, 0); + int i = 0; /* CNorm workaround, the init part of for isn't generated */ - for (i = 0; i != 64; ++i) -- rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_CRCERRS + i * 4, 0); ++ for (i = 0; i != 64; ++i) + rtx_e1000_register_write32(hw_ctx, E1000_CRCERRS + i * 4, 0); + -+ //${Log::info("setup_device: general configuration done")}; ++ { ++ ${Log::info("setup_device: general configuration done")}; ++ } + + /* + * Receive initialization: @@ -231,7 +231,9 @@ + *(unsigned short *)(&${ctx}->net_dev->dev_addr[4])); + rtx_e1000_register_set32(hw_ctx, E1000_RAH, E1000_RAH_AV); + -+ //${Log::info("setup_device: program receieve address done")}; ++ { ++ ${Log::info("setup_device: program receieve address done")}; ++ } + + /* 2. Initialize the MTA */ + @@ -239,7 +241,9 @@ + for (i = 0; i != 128; ++i) + rtx_e1000_register_write32(hw_ctx, E1000_MTA + i * 4, 0); + -+ //${Log::info("setup_device: MTA init done")}; ++ { ++ ${Log::info("setup_device: MTA init done")}; ++ } + + /* 4. Setup the receive descriptor ring */ + @@ -257,7 +261,9 @@ + goto err_rx_ring_alloc; + } + -+ //${Log::info("setup_device: descriptors allocated")}; ++ { ++ ${Log::info("setup_device: descriptors allocated")}; ++ } + + /* + * Allocate the skbuffs, map them for DMA, and write their address @@ -293,7 +299,9 @@ + hw_ctx->rx_ring.dma_skbuffs[i]); + } + -+ //${Log::info("setup_device: skbuffs allocated")}; ++ { ++ ${Log::info("setup_device: skbuffs allocated")}; ++ } + + /* + * XXX: We can't return here since we are not in a function but in @@ -330,6 +338,27 @@ + { + chunk ::CALL() + { ++ typedef unsigned long int dma_addr_t; ++ ++ typedef int ${e1000::Context}; ++ ${e1000::Context} hw_ctx; ++ hw_ctx = &${ctx}->hw_ctx; ++ ++ /* Free the rx ring: */ + int i = 0; +- for (i = 0; i != 64; ++i) +- rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_CRCERRS + i * 4, 0); ++ for (i = 0; i != ${config.rx_ring_size}; ++i) ++ { ++ dma_unmap_single( ++ &${ctx}->pci_dev->dev, ++ (dma_addr_t)hw_ctx->rx_ring.dma_skbuffs[i], ++ ${config.rx_buffer_len}, ++ DMA_FROM_DEVICE); ++ dev_kfree_skb(hw_ctx->rx_ring.skbuffs[i]); ++ } ++ dma_free_coherent(&${ctx}->pci_dev->dev, hw_ctx->rx_ring.size, ++ hw_ctx->rx_ring.base, (dma_addr_t)hw_ctx->rx_ring.dma_base); + } }