: Spidernet RX-side patches
Subsystems (2)
cover : Spidernet RX-side patches
Andrew,
Please apply; these patches obsolete/replace the series of 16 patches I'd previously sent, by addressing problems raised by Christoph Hellwig and Jeff Garzik.
Most of te focus of this series of patches is to simplify the RX code be removing extraneous flags, branches, arguments, etc. The first few patches are the biggest: using dma_alloc_coherent for the rings, and removing a bogus tasklet that does work that could be better done in the poll loop. The rest are mostly cleanup.
--linas
PATCH 1/14 Spidernet DMA coalescing
The current driver code performs 512 DMA mappings of a bunch of 32-byte ring descriptor structures. This is silly, as they are all in contiguous memory. This patch changes the code to dma_map_coherent() each rx/tx ring as a whole.
----
drivers/net/spider_net.c | 103 +++++++++++++++++---------------------- drivers/net/spider_net.h | 17 +----- drivers/net/spider_net_ethtool.c | 4 - 3 files changed, 54 insertions(+), 70 deletions(-)
drivers/net/spider_net.c +47 -56
@@ -280,72 +280,67 @@ spider_net_free_chain(struct spider_net_ {struct spider_net_descr *descr; -for (descr = chain->tail; !descr->bus_addr; descr = descr->next) { -pci_unmap_single (card->pdev, descr->bus_addr, -SPIDER_NET_DESCR_SIZE ,PCI_DMA_BIDIRECTIONAL ); + descr = chain->ring; +do { descr->bus_addr =0 ; - } + descr->next_descr_addr =0 ; + descr = descr->next; + }while (descr != chain->ring); + +dma_free_coherent (&card->pdev->dev, chain->num_desc, + chain->ring, chain->dma_addr); }/** -* spider_net_init_chain - links descriptor chain +* spider_net_init_chain - alloc and link descriptor chain * @card: card structure * @chain: address of chain -* @start_descr: address of descriptor array -* @no: number of descriptors * -* we manage a circular list that mirrors the hardware structure, +* We manage a circular list that mirrors the hardware structure, * except that the hardware uses bus addresses. * -* returns 0 on success, <0 on failure +* Returns 0 on success, <0 on failure */ static int spider_net_init_chain (struct spider_net_card *card, -struct spider_net_descr_chain *chain, -struct spider_net_descr *start_descr, -int no) +struct spider_net_descr_chain *chain) {int i;struct spider_net_descr *descr;dma_addr_t buf; +size_t alloc_size; - descr = start_descr; -memset (descr,0 ,sizeof (*descr) * no); + alloc_size = chain->num_desc *sizeof (struct spider_net_descr ); -/* set up the hardware pointers in each descriptor */ -for (i=0 ; i<no; i++, descr++) { - descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; + chain->ring =dma_alloc_coherent (&card->pdev->dev, alloc_size, + &chain->dma_addr,GFP_KERNEL ); - buf =pci_map_single (card->pdev, descr, -SPIDER_NET_DESCR_SIZE , -PCI_DMA_BIDIRECTIONAL ); +if (!chain->ring) +return -ENOMEM ; -if (pci_dma_mapping_error (buf)) - goto iommu_error; + descr = chain->ring; +memset (descr,0 , alloc_size); + +/* Set up the hardware pointers in each descriptor */ + buf = chain->dma_addr; +for (i=0 ; i < chain->num_desc; i++, descr++) { + descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; descr->bus_addr = buf; + descr->next_descr_addr =0 ; descr->next = descr +1 ; descr->prev = descr -1 ; + buf +=sizeof (struct spider_net_descr ); }/* do actual circular list */ - (descr-1 )->next = start_descr; - start_descr->prev = descr-1 ; + (descr-1 )->next = chain->ring; + chain->ring->prev = descr-1 ;spin_lock_init (&chain->lock); - chain->head = start_descr; - chain->tail = start_descr; - + chain->head = chain->ring; + chain->tail = chain->ring;return 0 ; - -iommu_error: - descr = start_descr; -for (i=0 ; i < no; i++, descr++) -if (descr->bus_addr) -pci_unmap_single (card->pdev, descr->bus_addr, -SPIDER_NET_DESCR_SIZE , -PCI_DMA_BIDIRECTIONAL ); -return -ENOMEM ; }/**
@@ -707,7 +702,7 @@ spider_net_set_low_watermark(struct spid }/* If TX queue is short, don't even bother with interrupts */ -if (cnt < card->num_tx_desc/4 ) +if (cnt < card->tx_chain.num_desc/4 )return cnt;/* Set low-watermark 3/4th's of the way into the queue. */
@@ -1652,26 +1647,25 @@ spider_net_open(struct net_device *netde {struct spider_net_card *card =netdev_priv (netdev);struct spider_net_descr *descr; -int i, result; +int result; - result = -ENOMEM ; -if (spider_net_init_chain (card, &card->tx_chain, card->descr, - card->num_tx_desc)) + result =spider_net_init_chain (card, &card->tx_chain); +if (result) goto alloc_tx_failed; - card->low_watermark =NULL ; -/* rx_chain is after tx_chain, so offset is descr + tx_count */ -if (spider_net_init_chain (card, &card->rx_chain, - card->descr + card->num_tx_desc, - card->num_rx_desc)) + result =spider_net_init_chain (card, &card->rx_chain); +if (result) goto alloc_rx_failed; - descr = card->rx_chain.head; -for (i=0 ; i < card->num_rx_desc; i++, descr++) +/* Make a ring of of bus addresses */ + descr = card->rx_chain.ring; +do { descr->next_descr_addr = descr->next->bus_addr; + descr = descr->next; + }while (descr != card->rx_chain.ring); -/* allocate rx skbs */ +/* Allocate rx skbs */ if (spider_net_alloc_rx_skbs (card)) goto alloc_skbs_failed;
@@ -1924,6 +1918,7 @@ spider_net_stop(struct net_device *netde/* release chains */ spider_net_release_tx_chain (card,1 ); +spider_net_free_rx_chain_contents (card);spider_net_free_chain (card, &card->tx_chain);spider_net_free_chain (card, &card->rx_chain);
@@ -2054,8 +2049,8 @@ spider_net_setup_netdev(struct spider_ne card->options.rx_csum =SPIDER_NET_RX_CSUM_DEFAULT ; - card->num_tx_desc = tx_descriptors; - card->num_rx_desc = rx_descriptors; + card->tx_chain.num_desc = tx_descriptors; + card->rx_chain.num_desc = rx_descriptors;spider_net_setup_netdev_ops (netdev);
@@ -2104,12 +2099,8 @@ spider_net_alloc_card(void) {struct net_device *netdev;struct spider_net_card *card; -size_t alloc_size; - alloc_size =sizeof (*card) + -sizeof (struct spider_net_descr ) * rx_descriptors + -sizeof (struct spider_net_descr ) * tx_descriptors; - netdev =alloc_etherdev (alloc_size); + netdev =alloc_etherdev (sizeof (struct spider_net_card ));if (!netdev)return NULL ;
drivers/net/spider_net.h +5 -12
@@ -378,6 +378,9 @@ struct spider_net_descr_chain {spinlock_t lock;struct spider_net_descr *head;struct spider_net_descr *tail; +struct spider_net_descr *ring; +int num_desc; +dma_addr_t dma_addr; };/* descriptor data_status bits */
@@ -397,8 +400,6 @@ struct spider_net_descr_chain {* 701b8000 would be correct, but every packets gets that flag */ #define SPIDER_NET_DESTROY_RX_FLAGS 0x700b8000 -#define SPIDER_NET_DESCR_SIZE 32 -/* this will be bigger some time */ struct spider_net_options {int rx_csum;/* for rx: if 0 ip_summed=NONE,
@@ -441,25 +442,17 @@ struct spider_net_card {struct spider_net_descr_chain rx_chain;struct spider_net_descr *low_watermark; -struct net_device_stats netdev_stats; - -struct spider_net_options options; - -spinlock_t intmask_lock;struct tasklet_struct rxram_full_tl;struct timer_list tx_timer; -struct work_struct tx_timeout_task;atomic_t tx_timeout_task_counter;wait_queue_head_t waitq;/* for ethtool */ int msg_enable; -int num_rx_desc; -int num_tx_desc; +struct net_device_stats netdev_stats;struct spider_net_extra_stats spider_stats; - -struct spider_net_descr descr[0 ]; +struct spider_net_options options; }; #define pr_err(fmt,arg...) \
drivers/net/spider_net_ethtool.c +2 -2
@@ -158,9 +158,9 @@ spider_net_ethtool_get_ringparam(structstruct spider_net_card *card = netdev->priv; ering->tx_max_pending =SPIDER_NET_TX_DESCRIPTORS_MAX ; - ering->tx_pending = card->num_tx_desc; + ering->tx_pending = card->tx_chain.num_desc; ering->rx_max_pending =SPIDER_NET_RX_DESCRIPTORS_MAX ; - ering->rx_pending = card->num_rx_desc; + ering->rx_pending = card->rx_chain.num_desc; }static int spider_net_get_stats_count (struct net_device *netdev)
Re: [PATCH 1/14] Spidernet DMA coalescing
Quoted 5 lines · Linas Vepstas
The current driver code performs 512 DMA mappings of a bunch of 32-byte ring descriptor structures. This is silly, as they are all in contiguous memory. This patch changes the code to
dma_map_coherent()each rx/tx ring as a whole.
It's acutally dma_alloc_coherent now that you updated the patch :)
drivers/net/spider_net.c spider_net_free_chain(struct spider_net_ · line 322
Quoted 8 lines
drivers/net/spider_net.c +6
-0+ chain->ring =dma_alloc_coherent (&card->pdev->dev, alloc_size, + &chain->dma_addr,GFP_KERNEL ); +if (!chain->ring) +return -ENOMEM ; + descr = chain->ring; +memset (descr,0 , alloc_size);
dma_alloc_coherent is defined to zero the allocated memory, so you won't need this memset.
Re: [PATCH 1/14] Spidernet DMA coalescing
Quoted 12 lines · Christoph Hellwig
Quoted 5 lines · Linas Vepstas
The current driver code performs 512 DMA mappings of a bunch of 32-byte ring descriptor structures. This is silly, as they are all in contiguous memory. This patch changes the code to
dma_map_coherent()each rx/tx ring as a whole.It's acutally
dma_alloc_coherentnow that you updated the patch :)Quoted 3 lines
drivers/net/spider_net.c +2
-0+ chain->ring =dma_alloc_coherent (&card->pdev->dev, alloc_size, + &chain->dma_addr,GFP_KERNEL );
Quoted 8 lines
drivers/net/spider_net.c spider_net_free_chain(struct spider_net_ · line 322
Quoted 5 lines
drivers/net/spider_net.c +4
-0+if (!chain->ring) +return -ENOMEM ; + descr = chain->ring; +memset (descr,0 , alloc_size);
dma_alloc_coherentis defined to zero the allocated memory, so you won't need this memset.
Being unclear on the concept, should a send a new version of this patch, or should I send a new patch that removes this?
--linas
Re: [PATCH 1/14] Spidernet DMA coalescing
Quoted 2 lines · Linas Vepstas
Being unclear on the concept, should a send a new version of this patch, or should I send a new patch that removes this?
For just the memset issue an incremental patch would be fine. But given the small mistake in the patch description a resend with the fixed description mighrt be in order here.
Revised: [PATCH 1/14] Spidernet DMA coalescing
Andrew,
I'm hoping its not irritatingly obthersome to ask you to rip out the first patch of this series, and replace it with the one below.
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Linas Vepstas
Being unclear on the concept, should a send a new version of this patch, or should I send a new patch that removes this?
For just the memset issue an incremental patch would be fine. But given the small mistake in the patch description a resend with the fixed description mighrt be in order here.
--linas
The current driver code performs 512 DMA mappings of a bunch of 32-byte ring descriptor structures. This is silly, as they are all in contiguous memory. This patch changes the code to dma_alloc_coherent() each rx/tx ring as a whole.
----
drivers/net/spider_net.c | 101 +++++++++++++++++---------------------- drivers/net/spider_net.h | 17 +----- drivers/net/spider_net_ethtool.c | 4 - 3 files changed, 52 insertions(+), 70 deletions(-)
drivers/net/spider_net.c +45 -56
@@ -280,72 +280,65 @@ spider_net_free_chain(struct spider_net_ {struct spider_net_descr *descr; -for (descr = chain->tail; !descr->bus_addr; descr = descr->next) { -pci_unmap_single (card->pdev, descr->bus_addr, -SPIDER_NET_DESCR_SIZE ,PCI_DMA_BIDIRECTIONAL ); + descr = chain->ring; +do { descr->bus_addr =0 ; - } + descr->next_descr_addr =0 ; + descr = descr->next; + }while (descr != chain->ring); + +dma_free_coherent (&card->pdev->dev, chain->num_desc, + chain->ring, chain->dma_addr); }/** -* spider_net_init_chain - links descriptor chain +* spider_net_init_chain - alloc and link descriptor chain * @card: card structure * @chain: address of chain -* @start_descr: address of descriptor array -* @no: number of descriptors * -* we manage a circular list that mirrors the hardware structure, +* We manage a circular list that mirrors the hardware structure, * except that the hardware uses bus addresses. * -* returns 0 on success, <0 on failure +* Returns 0 on success, <0 on failure */ static int spider_net_init_chain (struct spider_net_card *card, -struct spider_net_descr_chain *chain, -struct spider_net_descr *start_descr, -int no) +struct spider_net_descr_chain *chain) {int i;struct spider_net_descr *descr;dma_addr_t buf; +size_t alloc_size; - descr = start_descr; -memset (descr,0 ,sizeof (*descr) * no); + alloc_size = chain->num_desc *sizeof (struct spider_net_descr ); -/* set up the hardware pointers in each descriptor */ -for (i=0 ; i<no; i++, descr++) { - descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; + chain->ring =dma_alloc_coherent (&card->pdev->dev, alloc_size, + &chain->dma_addr,GFP_KERNEL ); - buf =pci_map_single (card->pdev, descr, -SPIDER_NET_DESCR_SIZE , -PCI_DMA_BIDIRECTIONAL ); +if (!chain->ring) +return -ENOMEM ; -if (pci_dma_mapping_error (buf)) - goto iommu_error; +/* Set up the hardware pointers in each descriptor */ + descr = chain->ring; + buf = chain->dma_addr; +for (i=0 ; i < chain->num_desc; i++, descr++) { + descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; descr->bus_addr = buf; + descr->next_descr_addr =0 ; descr->next = descr +1 ; descr->prev = descr -1 ; + buf +=sizeof (struct spider_net_descr ); }/* do actual circular list */ - (descr-1 )->next = start_descr; - start_descr->prev = descr-1 ; + (descr-1 )->next = chain->ring; + chain->ring->prev = descr-1 ;spin_lock_init (&chain->lock); - chain->head = start_descr; - chain->tail = start_descr; - + chain->head = chain->ring; + chain->tail = chain->ring;return 0 ; - -iommu_error: - descr = start_descr; -for (i=0 ; i < no; i++, descr++) -if (descr->bus_addr) -pci_unmap_single (card->pdev, descr->bus_addr, -SPIDER_NET_DESCR_SIZE , -PCI_DMA_BIDIRECTIONAL ); -return -ENOMEM ; }/**
@@ -707,7 +700,7 @@ spider_net_set_low_watermark(struct spid }/* If TX queue is short, don't even bother with interrupts */ -if (cnt < card->num_tx_desc/4 ) +if (cnt < card->tx_chain.num_desc/4 )return cnt;/* Set low-watermark 3/4th's of the way into the queue. */
@@ -1652,26 +1645,25 @@ spider_net_open(struct net_device *netde {struct spider_net_card *card =netdev_priv (netdev);struct spider_net_descr *descr; -int i, result; +int result; - result = -ENOMEM ; -if (spider_net_init_chain (card, &card->tx_chain, card->descr, - card->num_tx_desc)) + result =spider_net_init_chain (card, &card->tx_chain); +if (result) goto alloc_tx_failed; - card->low_watermark =NULL ; -/* rx_chain is after tx_chain, so offset is descr + tx_count */ -if (spider_net_init_chain (card, &card->rx_chain, - card->descr + card->num_tx_desc, - card->num_rx_desc)) + result =spider_net_init_chain (card, &card->rx_chain); +if (result) goto alloc_rx_failed; - descr = card->rx_chain.head; -for (i=0 ; i < card->num_rx_desc; i++, descr++) +/* Make a ring of of bus addresses */ + descr = card->rx_chain.ring; +do { descr->next_descr_addr = descr->next->bus_addr; + descr = descr->next; + }while (descr != card->rx_chain.ring); -/* allocate rx skbs */ +/* Allocate rx skbs */ if (spider_net_alloc_rx_skbs (card)) goto alloc_skbs_failed;
@@ -1924,6 +1916,7 @@ spider_net_stop(struct net_device *netde/* release chains */ spider_net_release_tx_chain (card,1 ); +spider_net_free_rx_chain_contents (card);spider_net_free_chain (card, &card->tx_chain);spider_net_free_chain (card, &card->rx_chain);
@@ -2054,8 +2047,8 @@ spider_net_setup_netdev(struct spider_ne card->options.rx_csum =SPIDER_NET_RX_CSUM_DEFAULT ; - card->num_tx_desc = tx_descriptors; - card->num_rx_desc = rx_descriptors; + card->tx_chain.num_desc = tx_descriptors; + card->rx_chain.num_desc = rx_descriptors;spider_net_setup_netdev_ops (netdev);
@@ -2104,12 +2097,8 @@ spider_net_alloc_card(void) {struct net_device *netdev;struct spider_net_card *card; -size_t alloc_size; - alloc_size =sizeof (*card) + -sizeof (struct spider_net_descr ) * rx_descriptors + -sizeof (struct spider_net_descr ) * tx_descriptors; - netdev =alloc_etherdev (alloc_size); + netdev =alloc_etherdev (sizeof (struct spider_net_card ));if (!netdev)return NULL ;
drivers/net/spider_net.h +5 -12
@@ -378,6 +378,9 @@ struct spider_net_descr_chain {spinlock_t lock;struct spider_net_descr *head;struct spider_net_descr *tail; +struct spider_net_descr *ring; +int num_desc; +dma_addr_t dma_addr; };/* descriptor data_status bits */
@@ -397,8 +400,6 @@ struct spider_net_descr_chain {* 701b8000 would be correct, but every packets gets that flag */ #define SPIDER_NET_DESTROY_RX_FLAGS 0x700b8000 -#define SPIDER_NET_DESCR_SIZE 32 -/* this will be bigger some time */ struct spider_net_options {int rx_csum;/* for rx: if 0 ip_summed=NONE,
@@ -441,25 +442,17 @@ struct spider_net_card {struct spider_net_descr_chain rx_chain;struct spider_net_descr *low_watermark; -struct net_device_stats netdev_stats; - -struct spider_net_options options; - -spinlock_t intmask_lock;struct tasklet_struct rxram_full_tl;struct timer_list tx_timer; -struct work_struct tx_timeout_task;atomic_t tx_timeout_task_counter;wait_queue_head_t waitq;/* for ethtool */ int msg_enable; -int num_rx_desc; -int num_tx_desc; +struct net_device_stats netdev_stats;struct spider_net_extra_stats spider_stats; - -struct spider_net_descr descr[0 ]; +struct spider_net_options options; }; #define pr_err(fmt,arg...) \
drivers/net/spider_net_ethtool.c +2 -2
@@ -158,9 +158,9 @@ spider_net_ethtool_get_ringparam(structstruct spider_net_card *card = netdev->priv; ering->tx_max_pending =SPIDER_NET_TX_DESCRIPTORS_MAX ; - ering->tx_pending = card->num_tx_desc; + ering->tx_pending = card->tx_chain.num_desc; ering->rx_max_pending =SPIDER_NET_RX_DESCRIPTORS_MAX ; - ering->rx_pending = card->num_rx_desc; + ering->rx_pending = card->rx_chain.num_desc; }static int spider_net_get_stats_count (struct net_device *netdev)
Re: [PATCH 1/14] Spidernet DMA coalescing
In reply to Linas VepstasQuoted 5 lines · Linas Vepstas
The current driver code performs 512 DMA mappings of a bunch of 32-byte ring descriptor structures. This is silly, as they are all in contiguous memory. This patch changes the code to
dma_map_coherent()each rx/tx ring as a whole.Signed-off-by Linas Vepstas <[email protected]>Cc James K Lewis <[email protected]>Cc Arnd Bergmann <[email protected]>
applied 1-13 of 14 to netdev-2.6.git#upstream
PATCH 2/14 Spidernet add net_ratelimit to suppress long output
In reply to Linas VepstasThis patch adds net_ratelimit to many of the printks in order to limit extraneous warning messages (created in response to Bug 28554). This patch supercedes all previous ratelimit patches.
This has been tested, please apply.
From: James K Lewis <[email protected]>
----
drivers/net/spider_net.c | 11 +++++------ drivers/net/spider_net.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/net/spider_net.c +5 -6
@@ -1038,11 +1038,10 @@ spider_net_decode_one_descr(struct spideif ( (status !=SPIDER_NET_DESCR_COMPLETE ) && (status !=SPIDER_NET_DESCR_FRAME_END ) ) { -if (netif_msg_rx_err (card)) { +if (netif_msg_rx_err (card))pr_err ("%s: RX descriptor with state %d\n" , card->netdev->name, status); - card->spider_stats.rx_desc_unk_state++; - } + card->spider_stats.rx_desc_unk_state++; goto refill; }
@@ -1361,7 +1360,7 @@ spider_net_handle_error_irq(struct spidecase SPIDER_NET_GRFAFLLINT :/* fallthrough */ case SPIDER_NET_GRMFLLINT :if (netif_msg_intr (card) &&net_ratelimit ()) -pr_debug ("Spider RX RAM full, incoming packets " +pr_err ("Spider RX RAM full, incoming packets " "might be discarded!\n" );spider_net_rx_irq_off (card);tasklet_schedule (&card->rxram_full_tl);
@@ -1379,7 +1378,7 @@ spider_net_handle_error_irq(struct spidecase SPIDER_NET_GDCDCEINT :/* fallthrough */ case SPIDER_NET_GDBDCEINT :/* fallthrough */ case SPIDER_NET_GDADCEINT : -if (netif_msg_intr (card)) +if (netif_msg_intr (card) &&net_ratelimit ())pr_err ("got descriptor chain end interrupt, " "restarting DMAC %c.\n" ,'D' -(i-SPIDER_NET_GDDDCEINT )/3 );
@@ -1450,7 +1449,7 @@ spider_net_handle_error_irq(struct spidebreak ; } -if ((show_error) && (netif_msg_intr (card))) +if ((show_error) && (netif_msg_intr (card)) &&net_ratelimit ()) pr_err("Got error interrupt on %s, GHIINT0STS = 0x%08x, " "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n", card->netdev->name,
drivers/net/spider_net.h +1 -1
@@ -24,7 +24,7 @@#ifndef _SPIDER_NET_H#define _SPIDER_NET_H -#define VERSION "1.6 A" +#define VERSION "1.6 B"#include "sungem_phy.h"
Re: [PATCH 2/14] Spidernet add net_ratelimit to suppress long output
Quoted 2 lines · Linas Vepstas
This patch adds
net_ratelimitto many of the printks in order to limit extraneous warning messages (created in response to Bug 28554).
Bug 28554 in which bug tracking system? I can't find it in LTC or kernel.org bugzilla.
cheers
Signature · 8 lines
Michael Ellerman OzLabs, IBM Australia Development Lab wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
Re: [PATCH 2/14] Spidernet add net_ratelimit to suppress long output
It is in the LTC Bugzilla. I just checked and it is still there :)
Jim
Quoted 9 lines · Michael Ellerman
Quoted 2 lines · Linas Vepstas
This patch adds
net_ratelimitto many of the printks in order to limit extraneous warning messages (created in response to Bug 28554).Bug 28554 in which bug tracking system? I can't find it in LTC or kernel.org bugzilla.
cheers
PATCH 3/14 Spidernet remove rxramfull tasklet
In reply to Linas VepstasGet rid of the rxramfull tasklet, and let the NAPI poll routine deal with this situation. (The rxramfull interrupt is simply stating that the h/w has run out of room for incoming packets).
----
drivers/net/spider_net.c | 24 +----------------------- drivers/net/spider_net.h | 1 - 2 files changed, 1 insertion(+), 24 deletions(-)
drivers/net/spider_net.c +1 -23
@@ -1221,24 +1221,6 @@ spider_net_set_mac(struct net_device *ne }/** -* spider_net_handle_rxram_full - cleans up RX ring upon RX RAM full interrupt -* @card: card structure -* -* spider_net_handle_rxram_full empties the RX ring so that spider can put -* more packets in it and empty its RX RAM. This is called in bottom half -* context -*/ -static void -spider_net_handle_rxram_full (struct spider_net_card *card) -{ -while (spider_net_decode_one_descr (card,0 )) - ; -spider_net_enable_rxchtails (card); -spider_net_enable_rxdmac (card); -netif_rx_schedule (card->netdev); -} - -/** * spider_net_handle_error_irq - handles errors raised by an interrupt * @card: card structure * @status_reg: interrupt status register 0 (GHIINT0STS)
@@ -1363,7 +1345,7 @@ spider_net_handle_error_irq(struct spidepr_err ("Spider RX RAM full, incoming packets " "might be discarded!\n" );spider_net_rx_irq_off (card); -tasklet_schedule (&card->rxram_full_tl); +netif_rx_schedule (card->netdev); show_error =0 ;break ;
@@ -1895,7 +1877,6 @@ spider_net_stop(struct net_device *netde {struct spider_net_card *card =netdev_priv (netdev); -tasklet_kill (&card->rxram_full_tl);netif_poll_disable (netdev);netif_carrier_off (netdev);netif_stop_queue (netdev);
@@ -2037,9 +2018,6 @@ spider_net_setup_netdev(struct spider_nepci_set_drvdata (card->pdev, netdev); - card->rxram_full_tl.data = (unsigned long ) card; - card->rxram_full_tl.func = - (void (*)(unsigned long )) spider_net_handle_rxram_full;init_timer (&card->tx_timer); card->tx_timer.function = (void (*)(unsigned long )) spider_net_cleanup_tx_ring;
drivers/net/spider_net.h +0 -1
@@ -442,7 +442,6 @@ struct spider_net_card {struct spider_net_descr_chain rx_chain;struct spider_net_descr *low_watermark; -struct tasklet_struct rxram_full_tl;struct timer_list tx_timer;struct work_struct tx_timeout_task;atomic_t tx_timeout_task_counter;
PATCH 4/14 Spidernet cleanup un-needed API
In reply to Linas VepstasThere is no need to pass a flag into spider_net_decode_one_descr() so remove this, and perform some othre minor cleanup.
----
drivers/net/spider_net.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-)
drivers/net/spider_net.c +12 -23
@@ -910,7 +910,6 @@ spider_net_do_ioctl(struct net_device *n* spider_net_pass_skb_up - takes an skb from a descriptor and passes it on * @descr: descriptor to process * @card: card structure -* @napi: whether caller is in NAPI context * * returns 1 on success, 0 if no packet was passed to the stack *
@@ -919,7 +918,7 @@ spider_net_do_ioctl(struct net_device *n*/ static int spider_net_pass_skb_up (struct spider_net_descr *descr, -struct spider_net_card *card,int napi) +struct spider_net_card *card) {struct sk_buff *skb;struct net_device *netdev;
@@ -972,10 +971,7 @@ spider_net_pass_skb_up(struct spider_net }/* pass skb up to stack */ -if (napi) -netif_receive_skb (skb); -else -netif_rx_ni (skb); +netif_receive_skb (skb);/* update netdevice statistics */ card->netdev_stats.rx_packets++;
@@ -987,16 +983,15 @@ spider_net_pass_skb_up(struct spider_net/** * spider_net_decode_one_descr - processes an rx descriptor * @card: card structure -* @napi: whether caller is in NAPI context * -* returns 1 if a packet has been sent to the stack, otherwise 0 +* Returns 1 if a packet has been sent to the stack, otherwise 0 * -* processes an rx descriptor by iommu-unmapping the data buffer and passing +* Processes an rx descriptor by iommu-unmapping the data buffer and passing * the packet up to the stack. This function is called in softirq * context, e.g. either bottom half from interrupt or NAPI polling context */ static int -spider_net_decode_one_descr (struct spider_net_card *card,int napi) +spider_net_decode_one_descr (struct spider_net_card *card) {struct spider_net_descr_chain *chain = &card->rx_chain;struct spider_net_descr *descr = chain->tail;
@@ -1005,18 +1000,15 @@ spider_net_decode_one_descr(struct spide status =spider_net_get_descr_status (descr); -if (status ==SPIDER_NET_DESCR_CARDOWNED ) { -/* nothing in the descriptor yet */ - result=0 ; - goto out; - } +/* nothing in the descriptor yet */ +if (status ==SPIDER_NET_DESCR_CARDOWNED ) +return 0 ;if (status ==SPIDER_NET_DESCR_NOT_IN_USE ) {/* not initialized yet, the ring must be empty */ spider_net_refill_rx_chain (card);spider_net_enable_rxdmac (card); - result=0 ; - goto out; +return 0 ; }/* descriptor definitively used -- move on tail */
@@ -1046,13 +1038,10 @@ spider_net_decode_one_descr(struct spide }/* ok, we've got a packet in descr */ - result =spider_net_pass_skb_up (descr, card, napi); + result =spider_net_pass_skb_up (descr, card); refill: - descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ;/* change the descriptor state: */ -if (!napi) -spider_net_refill_rx_chain (card); -out: + descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ;return result; }
@@ -1079,7 +1068,7 @@ spider_net_poll(struct net_device *netde packets_to_do =min (*budget, netdev->quota);while (packets_to_do) { -if (spider_net_decode_one_descr (card,1 )) { +if (spider_net_decode_one_descr (card)) { packets_done++; packets_to_do--; }else {
PATCH 5/14 Spidernet RX skb mem leak
In reply to Linas VepstasOne of the unlikely error branches has an skb memory leak. Fix this by handling the error conditions consistently.
----
drivers/net/spider_net.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/spider_net.c +9 -9
@@ -913,8 +913,8 @@ spider_net_do_ioctl(struct net_device *n* * returns 1 on success, 0 if no packet was passed to the stack * -* iommu-unmaps the skb, fills out skb structure and passes the data to the -* stack. The descriptor state is not changed. +* Fills out skb structure and passes the data to the stack. +* The descriptor state is not changed. */ static int spider_net_pass_skb_up(struct spider_net_descr *descr,
@@ -929,10 +929,6 @@ spider_net_pass_skb_up(struct spider_net netdev = card->netdev; -/* unmap descriptor */ -pci_unmap_single (card->pdev, descr->buf_addr,SPIDER_NET_MAX_FRAME , -PCI_DMA_FROMDEVICE ); -/* the cases we'll throw away the packet immediately */ if (data_error &SPIDER_NET_DESTROY_RX_FLAGS ) {if (netif_msg_rx_err (card))
@@ -1015,6 +1011,11 @@ spider_net_decode_one_descr(struct spide chain->tail = descr->next; result =0 ; + +/* unmap descriptor */ +pci_unmap_single (card->pdev, descr->buf_addr, +SPIDER_NET_MAX_FRAME ,PCI_DMA_FROMDEVICE ); +if ( (status ==SPIDER_NET_DESCR_RESPONSE_ERROR ) || (status ==SPIDER_NET_DESCR_PROTECTION_ERROR ) || (status ==SPIDER_NET_DESCR_FORCE_END ) ) {
@@ -1022,8 +1023,6 @@ spider_net_decode_one_descr(struct spidepr_err ("%s: dropping RX descriptor with state %d\n" , card->netdev->name, status); card->netdev_stats.rx_dropped++; -pci_unmap_single (card->pdev, descr->buf_addr, -SPIDER_NET_MAX_FRAME ,PCI_DMA_FROMDEVICE );dev_kfree_skb_irq (descr->skb); goto refill; }
@@ -1031,9 +1030,10 @@ spider_net_decode_one_descr(struct spideif ( (status !=SPIDER_NET_DESCR_COMPLETE ) && (status !=SPIDER_NET_DESCR_FRAME_END ) ) {if (netif_msg_rx_err (card)) -pr_err ("%s: RX descriptor with state %d\n" , +pr_err ("%s: RX descriptor with unkown state %d\n" , card->netdev->name, status); card->spider_stats.rx_desc_unk_state++; +dev_kfree_skb_irq (descr->skb); goto refill; }
PATCH 6/14 Spidernet another skb mem leak
In reply to Linas VepstasAnother skb leak in an error branch. Fix this by adding call to dev_kfree_skb_irq() after moving to a more appropriate spot.
----
drivers/net/spider_net.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/net/spider_net.c +12 -11
@@ -926,19 +926,8 @@ spider_net_pass_skb_up(struct spider_net data_status = descr->data_status; data_error = descr->data_error; - netdev = card->netdev; -/* the cases we'll throw away the packet immediately */ -if (data_error &SPIDER_NET_DESTROY_RX_FLAGS ) { -if (netif_msg_rx_err (card)) -pr_err ("error in received descriptor found, " -"data_status=x%08x, data_error=x%08x\n" , - data_status, data_error); - card->spider_stats.rx_desc_error++; -return 0 ; - } - skb = descr->skb; skb->dev = netdev;skb_put (skb, descr->valid_size);
@@ -1037,6 +1026,18 @@ spider_net_decode_one_descr(struct spide goto refill; } +/* The cases we'll throw away the packet immediately */ +if (descr->data_error &SPIDER_NET_DESTROY_RX_FLAGS ) { +if (netif_msg_rx_err (card)) +pr_err ("%s: error in received descriptor found, " +"data_status=x%08x, data_error=x%08x\n" , + card->netdev->name, + descr->data_status, descr->data_error); + card->spider_stats.rx_desc_error++; +dev_kfree_skb_irq (descr->skb); + goto refill; + } +/* ok, we've got a packet in descr */ result =spider_net_pass_skb_up (descr, card); refill:
PATCH 7/14 Spidernet Cleanup return codes
In reply to Linas VepstasSimplify the somewhat convoluted use of return codes in the rx buffer handling.
----
drivers/net/spider_net.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
drivers/net/spider_net.c +12 -20
@@ -911,12 +911,10 @@ spider_net_do_ioctl(struct net_device *n* @descr: descriptor to process * @card: card structure * -* returns 1 on success, 0 if no packet was passed to the stack -* * Fills out skb structure and passes the data to the stack. * The descriptor state is not changed. */ -static int +static void spider_net_pass_skb_up (struct spider_net_descr *descr,struct spider_net_card *card) {
@@ -961,8 +959,6 @@ spider_net_pass_skb_up(struct spider_net/* update netdevice statistics */ card->netdev_stats.rx_packets++; card->netdev_stats.rx_bytes += skb->len; - -return 1 ; }/**
@@ -981,7 +977,6 @@ spider_net_decode_one_descr(struct spidestruct spider_net_descr_chain *chain = &card->rx_chain;struct spider_net_descr *descr = chain->tail;int status; -int result; status =spider_net_get_descr_status (descr);
@@ -999,8 +994,6 @@ spider_net_decode_one_descr(struct spide/* descriptor definitively used -- move on tail */ chain->tail = descr->next; - result =0 ; -/* unmap descriptor */ pci_unmap_single (card->pdev, descr->buf_addr,SPIDER_NET_MAX_FRAME ,PCI_DMA_FROMDEVICE );
@@ -1012,8 +1005,7 @@ spider_net_decode_one_descr(struct spidepr_err ("%s: dropping RX descriptor with state %d\n" , card->netdev->name, status); card->netdev_stats.rx_dropped++; -dev_kfree_skb_irq (descr->skb); - goto refill; + goto bad_desc; } if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
@@ -1022,8 +1014,7 @@ spider_net_decode_one_descr(struct spidepr_err ("%s: RX descriptor with unkown state %d\n" , card->netdev->name, status); card->spider_stats.rx_desc_unk_state++; -dev_kfree_skb_irq (descr->skb); - goto refill; + goto bad_desc; }/* The cases we'll throw away the packet immediately */
@@ -1033,17 +1024,18 @@ spider_net_decode_one_descr(struct spide"data_status=x%08x, data_error=x%08x\n" , card->netdev->name, descr->data_status, descr->data_error); - card->spider_stats.rx_desc_error++; -dev_kfree_skb_irq (descr->skb); - goto refill; + goto bad_desc; } -/* ok, we've got a packet in descr */ - result =spider_net_pass_skb_up (descr, card); -refill: -/* change the descriptor state: */ +/* Ok, we've got a packet in descr */ +spider_net_pass_skb_up (descr, card); descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; -return result; +return 1 ; + +bad_desc: +dev_kfree_skb_irq (descr->skb); + descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; +return 0 ; }/**
PATCH 8/14 Spidernet RX Refill
In reply to Linas VepstasThe invocation of the rx ring refill routine is haphazard, it can be called from a central location.
----
drivers/net/spider_net.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/spider_net.c +4 -9
@@ -980,17 +980,11 @@ spider_net_decode_one_descr(struct spide status =spider_net_get_descr_status (descr); -/* nothing in the descriptor yet */ -if (status ==SPIDER_NET_DESCR_CARDOWNED ) +/* Nothing in the descriptor, or ring must be empty */ +if ((status ==SPIDER_NET_DESCR_CARDOWNED ) || + (status ==SPIDER_NET_DESCR_NOT_IN_USE ))return 0 ; -if (status ==SPIDER_NET_DESCR_NOT_IN_USE ) { -/* not initialized yet, the ring must be empty */ -spider_net_refill_rx_chain (card); -spider_net_enable_rxdmac (card); -return 0 ; - } -/* descriptor definitively used -- move on tail */ chain->tail = descr->next;
@@ -1074,6 +1068,7 @@ spider_net_poll(struct net_device *netde netdev->quota -= packets_done; *budget -= packets_done;spider_net_refill_rx_chain (card); +spider_net_enable_rxdmac (card);/* if all packets are in the stack, enable interrupts and return 0 */ /* if not, return 1 */
PATCH 9/14 Spidernet Remove unused variable
In reply to Linas VepstasRemove unused variable; this makes code easier to read. Tweak commentary.
----
drivers/net/spider_net.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/spider_net.c +6 -7
@@ -367,21 +367,20 @@ spider_net_free_rx_chain_contents(struct }/** -* spider_net_prepare_rx_descr - reinitializes a rx descriptor +* spider_net_prepare_rx_descr - Reinitialize RX descriptor * @card: card structure * @descr: descriptor to re-init * -* return 0 on succes, <0 on failure +* Return 0 on succes, <0 on failure. * -* allocates a new rx skb, iommu-maps it and attaches it to the descriptor. -* Activate the descriptor state-wise +* Allocates a new rx skb, iommu-maps it and attaches it to the +* descriptor. Mark the descriptor as activated, ready-to-use. */ static int spider_net_prepare_rx_descr (struct spider_net_card *card,struct spider_net_descr *descr) {dma_addr_t buf; -int error =0 ;int offset;int bufsize;
@@ -409,7 +408,7 @@ spider_net_prepare_rx_descr(struct spide (SPIDER_NET_RXBUF_ALIGN -1 );if (offset)skb_reserve (descr->skb,SPIDER_NET_RXBUF_ALIGN - offset); -/* io-mmu-map the skb */ +/* iommu-map the skb */ buf =pci_map_single (card->pdev, descr->skb->data,SPIDER_NET_MAX_FRAME ,PCI_DMA_FROMDEVICE ); descr->buf_addr = buf;
@@ -424,7 +423,7 @@ spider_net_prepare_rx_descr(struct spideSPIDER_NET_DMAC_NOINTR_COMPLETE ; } -return error; +return 0 ; }/**
PATCH 10/14 Spidernet RX Chain tail
In reply to Linas VepstasTell the hardware the location of the rx ring tail. More punctuation cleanup.
----
drivers/net/spider_net.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/spider_net.c +8 -7
@@ -487,10 +487,10 @@ spider_net_refill_rx_chain(struct spider }/** -* spider_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains +* spider_net_alloc_rx_skbs - Allocates rx skbs in rx descriptor chains * @card: card structure * -* returns 0 on success, <0 on failure +* Returns 0 on success, <0 on failure. */ static int spider_net_alloc_rx_skbs (struct spider_net_card *card)
@@ -501,17 +501,18 @@ spider_net_alloc_rx_skbs(struct spider_n result = -ENOMEM ; chain = &card->rx_chain; -/* put at least one buffer into the chain. if this fails, -* we've got a problem. if not, spider_net_refill_rx_chain -* will do the rest at the end of this function */ +/* Put at least one buffer into the chain. if this fails, +* we've got a problem. If not, spider_net_refill_rx_chain +* will do the rest at the end of this function. */ if (spider_net_prepare_rx_descr (card, chain->head)) goto error;else chain->head = chain->head->next; -/* this will allocate the rest of the rx buffers; if not, it's -* business as usual later on */ +/* This will allocate the rest of the rx buffers; +* if not, it's business as usual later on. */ spider_net_refill_rx_chain (card); +spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;
PATCH 11/14 Spidernet Memory barrier
In reply to Linas VepstasAdd memory barrier to make sure that the rest of the RX descriptor state is flushed to memory before we tell the hardware that its ready to go.
----
drivers/net/spider_net.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/spider_net.c +1 -0
@@ -419,6 +419,7 @@ spider_net_prepare_rx_descr(struct spide card->spider_stats.rx_iommu_map_error++; descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; }else { +wmb (); descr->dmac_cmd_status =SPIDER_NET_DESCR_CARDOWNED |SPIDER_NET_DMAC_NOINTR_COMPLETE ; }
PATCH 12/14 Spidernet Avoid possible RX chain corruption
In reply to Linas VepstasDelete possible source of chain corruption; the hardware already knows the location of the tail, and writing it again is likely to mess it up.
----
drivers/net/spider_net.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/spider_net.c +0 -1
@@ -513,7 +513,6 @@ spider_net_alloc_rx_skbs(struct spider_n/* This will allocate the rest of the rx buffers; * if not, it's business as usual later on. */ spider_net_refill_rx_chain (card); -spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;
Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
Quoted 18 lines · Linas Vepstas
Delete possible source of chain corruption; the hardware already knows the location of the tail, and writing it again is likely to mess it up.
Signed-off-by Linas Vepstas <[email protected]>Cc James K Lewis <[email protected]>Cc Arnd Bergmann <[email protected]>----
drivers/net/spider_net.c | 1 - 1 file changed, 1 deletion(-)Index:
linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
drivers/net/spider_net.c spider_net_alloc_rx_skbs(struct spider_n · line 517
Quoted 6 lines
drivers/net/spider_net.c +0
-1@@ -513,7 +513,6 @@ spider_net_alloc_rx_skbs(struct spider_n/* This will allocate the rest of the rx buffers; * if not, it's business as usual later on. */ spider_net_refill_rx_chain (card); -spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;
Didn't you just add that line?
From "[PATCH 10/14] Spidernet RX Chain tail":
drivers/net/spider_net.c
Quoted 12 lines
drivers/net/spider_net.c +0
-0@@ -501,17 +501,18 @@ spider_net_alloc_rx_skbs(struct spider_n<snip comment change>
drivers/net/spider_net.c +3
-2-/* this will allocate the rest of the rx buffers; if not, it's -* business as usual later on */ +/* This will allocate the rest of the rx buffers; +* if not, it's business as usual later on. */ spider_net_refill_rx_chain (card); +spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;
cheers
Signature · 8 lines
Michael Ellerman OzLabs, IBM Australia Development Lab wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
Quoted 6 lines · Michael Ellerman
drivers/net/spider_net.c spider_net_alloc_rx_skbs(struct spider_n · line 517
Quoted 4 lines
drivers/net/spider_net.c +0
-1spider_net_refill_rx_chain (card); -spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;Didn't you just add that line?
Dagnabbit. The earlier pach was moving around existing code. Or, more precisely, trying to maintain the general function of the old code even while moving things around.
Later on, when I started looking at what the danged function actually did, and the context it was in, I realized that it was a bad idea to call the thing. So then I removed it. :-/
How should I handle this proceedurally? Resend the patch sequence? Let it slide?
--linas
Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
Quoted 12 lines · Linas Vepstas
Quoted 6 lines · Michael Ellerman
drivers/net/spider_net.c spider_net_alloc_rx_skbs(struct spider_n · line 517
Quoted 4 lines
drivers/net/spider_net.c +0
-1spider_net_refill_rx_chain (card); -spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;Didn't you just add that line?
Dagnabbit. The earlier pach was moving around existing code. Or, more precisely, trying to maintain the general function of the old code even while moving things around.
Quoted 6 lines
Later on, when I started looking at what the danged function actually did, and the context it was in, I realized that it was a bad idea to call the thing. So then I removed it. :-/
How should I handle this proceedurally? Resend the patch sequence? Let it slide?
Just keep it as is in this case. In case you have to redo the patch series for some other reason or for similar cases in the future put the patch to remove things in front of the one that reorders the surrounding bits.
Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
In reply to Linas VepstasQuoted 12 lines · Linas Vepstas
Quoted 6 lines · Michael Ellerman
drivers/net/spider_net.c spider_net_alloc_rx_skbs(struct spider_n · line 517
Quoted 4 lines
drivers/net/spider_net.c +0
-1spider_net_refill_rx_chain (card); -spider_net_enable_rxchtails (card);spider_net_enable_rxdmac (card);return 0 ;Didn't you just add that line?
Dagnabbit. The earlier pach was moving around existing code. Or, more precisely, trying to maintain the general function of the old code even while moving things around.
Quoted 6 lines
Later on, when I started looking at what the danged function actually did, and the context it was in, I realized that it was a bad idea to call the thing. So then I removed it. :-/
How should I handle this proceedurally? Resend the patch sequence? Let it slide?
If it was my code I'd redo the series, it's confusing and it's going to look confused in the git history IMHO.
Currently the driver calls spider_net_enable_rxchtails() from spider_net_enable_card() and spider_net_handle_rxram_full().
Your patch 3/14 removes spider_net_handle_rxram_full() entirely, leaving spider_net_enable_card() as the only caller of spider_net_enable_rxchtails().
Patch 10/14 adds a call to spider_net_enable_rxchtails() in spider_net_alloc_rx_skbs(), and nothing else (except comment changes).
Patch 12/14 removes the call to spider_net_enable_rxchtails() in spider_net_alloc_rx_skbs(), and nothing else.
So as far as I can tell you should just drop 10/14 and 12/14.
My worry is that amongst all that rearranging of code, it's not clear what the semantic change is. Admittedly I don't know the driver that well, but that's kind of the point - if you and Jim get moved onto a new project, someone needs to be able to pick up the driver and maintain it.
cheers
Signature · 8 lines
Michael Ellerman OzLabs, IBM Australia Development Lab wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
PATCH 13/14 Spidernet RX Debugging printout
In reply to Linas VepstasAdd some debugging and error printing.
The show_rx_chain() prints out the status of the rx chain, which shows that the status of the descriptors gets messed up after the second & subsequent RX ramfulls.
Print out contents of bad packets if error occurs.
----
drivers/net/spider_net.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
drivers/net/spider_net.c +46 -0
@@ -961,6 +961,34 @@ spider_net_pass_skb_up(struct spider_net card->netdev_stats.rx_bytes += skb->len; } +#ifdef DEBUG +static void show_rx_chain (struct spider_net_card *card) +{ +struct spider_net_descr_chain *chain = &card->rx_chain; +struct spider_net_descr *start= chain->tail; +struct spider_net_descr *descr= start; +int status; + +int cnt =0 ; +int cstat =spider_net_get_descr_status (descr); +printk (KERN_INFO "RX chain tail at descr=%ld\n" , + (start - card->descr) - card->tx_chain.num_desc); + status = cstat; +do + { + status =spider_net_get_descr_status (descr); +if (cstat != status) { +printk (KERN_INFO "Have %d descrs with stat=x%08x\n" , cnt, cstat); + cstat = status; + cnt =0 ; + } + cnt ++; + descr = descr->next; + }while (descr != start); +printk (KERN_INFO "Last %d descrs with stat=x%08x\n" , cnt, cstat); +} +#endif +/** * spider_net_decode_one_descr - processes an rx descriptor * @card: card structure
@@ -1021,6 +1049,24 @@ spider_net_decode_one_descr(struct spide goto bad_desc; } +if (descr->dmac_cmd_status &0xfefe ) { +pr_err ("%s: bad status, cmd_status=x%08x\n" , + card->netdev->name, + descr->dmac_cmd_status); +pr_err ("buf_addr=x%08x\n" , descr->buf_addr); +pr_err ("buf_size=x%08x\n" , descr->buf_size); +pr_err ("next_descr_addr=x%08x\n" , descr->next_descr_addr); +pr_err ("result_size=x%08x\n" , descr->result_size); +pr_err ("valid_size=x%08x\n" , descr->valid_size); +pr_err ("data_status=x%08x\n" , descr->data_status); +pr_err ("data_error=x%08x\n" , descr->data_error); +pr_err ("bus_addr=x%08x\n" , descr->bus_addr); +pr_err ("which=%ld\n" , descr - card->rx_chain.ring); + + card->spider_stats.rx_desc_error++; + goto bad_desc; + } +/* Ok, we've got a packet in descr */ spider_net_pass_skb_up (descr, card); descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ;
PATCH 14/14 Spidernet Rework RX linked list
In reply to Linas VepstasMake the hardware perceive the RX descriptor ring as a null-terminated linked list, instead of a circular ring.
----
drivers/net/spider_net.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/spider_net.c +4 -8
@@ -419,9 +419,13 @@ spider_net_prepare_rx_descr(struct spide card->spider_stats.rx_iommu_map_error++; descr->dmac_cmd_status =SPIDER_NET_DESCR_NOT_IN_USE ; }else { + descr->next_descr_addr =0 ;wmb (); descr->dmac_cmd_status =SPIDER_NET_DESCR_CARDOWNED |SPIDER_NET_DMAC_NOINTR_COMPLETE ; + +wmb (); + descr->prev->next_descr_addr = descr->bus_addr; }return 0 ;
@@ -1650,7 +1654,6 @@ int spider_net_open(struct net_device *netdev) {struct spider_net_card *card =netdev_priv (netdev); -struct spider_net_descr *descr;int result; result =spider_net_init_chain (card, &card->tx_chain);
@@ -1662,13 +1665,6 @@ spider_net_open(struct net_device *netdeif (result) goto alloc_rx_failed; -/* Make a ring of of bus addresses */ - descr = card->rx_chain.ring; -do { - descr->next_descr_addr = descr->next->bus_addr; - descr = descr->next; - }while (descr != card->rx_chain.ring); -/* Allocate rx skbs */ if (spider_net_alloc_rx_skbs (card)) goto alloc_skbs_failed;