* [PATCH 0/14]: Spidernet RX-side patches
@ 2006-12-13 21:00 Linas Vepstas
2006-12-13 21:06 ` [PATCH 1/14] Spidernet DMA coalescing Linas Vepstas
` (13 more replies)
0 siblings, 14 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:00 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 1/14] Spidernet DMA coalescing
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
@ 2006-12-13 21:06 ` Linas Vepstas
2006-12-14 11:05 ` Christoph Hellwig
2006-12-26 21:09 ` Jeff Garzik
2006-12-13 21:08 ` [PATCH 2/14] Spidernet add net_ratelimit to suppress long output Linas Vepstas
` (12 subsequent siblings)
13 siblings, 2 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:06 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
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 <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
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(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 11:55:53.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 13:04:04.000000000 -0600
@@ -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;
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-13 11:55:53.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h 2006-12-13 12:04:02.000000000 -0600
@@ -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...) \
Index: linux-2.6.19-git7/drivers/net/spider_net_ethtool.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net_ethtool.c 2006-11-29 15:57:37.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net_ethtool.c 2006-12-13 12:59:25.000000000 -0600
@@ -158,9 +158,9 @@ spider_net_ethtool_get_ringparam(struct
struct 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)
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 2/14] Spidernet add net_ratelimit to suppress long output
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
2006-12-13 21:06 ` [PATCH 1/14] Spidernet DMA coalescing Linas Vepstas
@ 2006-12-13 21:08 ` Linas Vepstas
2006-12-13 23:31 ` Michael Ellerman
2006-12-13 21:10 ` [PATCH 3/14] Spidernet remove rxramfull tasklet Linas Vepstas
` (11 subsequent siblings)
13 siblings, 1 reply; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:08 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
This 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 <jklewis@us.ibm.com>
Signed-off-by: James K Lewis <jklewis@us.ibm.com>
Signed-off-by: Linas Vepstas <jlinas@austin.ibm.com>
----
drivers/net/spider_net.c | 11 +++++------
drivers/net/spider_net.h | 2 +-
2 files changed, 6 insertions(+), 7 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 13:04:04.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 13:19:59.000000000 -0600
@@ -1038,11 +1038,10 @@ spider_net_decode_one_descr(struct spide
if ( (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 spide
case 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 spide
case 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 spide
break;
}
- 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,
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-13 12:04:02.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h 2006-12-13 13:19:59.000000000 -0600
@@ -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"
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 3/14] Spidernet remove rxramfull tasklet
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
2006-12-13 21:06 ` [PATCH 1/14] Spidernet DMA coalescing Linas Vepstas
2006-12-13 21:08 ` [PATCH 2/14] Spidernet add net_ratelimit to suppress long output Linas Vepstas
@ 2006-12-13 21:10 ` Linas Vepstas
2006-12-13 21:12 ` [PATCH 4/14] Spidernet cleanup un-needed API Linas Vepstas
` (10 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:10 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Get 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).
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 24 +-----------------------
drivers/net/spider_net.h | 1 -
2 files changed, 1 insertion(+), 24 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:24:04.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:24:07.000000000 -0600
@@ -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 spide
pr_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_ne
pci_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;
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-13 14:24:04.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h 2006-12-13 14:24:07.000000000 -0600
@@ -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;
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 4/14] Spidernet cleanup un-needed API
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (2 preceding siblings ...)
2006-12-13 21:10 ` [PATCH 3/14] Spidernet remove rxramfull tasklet Linas Vepstas
@ 2006-12-13 21:12 ` Linas Vepstas
2006-12-13 21:15 ` [PATCH 5/14] Spidernet RX skb mem leak Linas Vepstas
` (9 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:12 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
There is no need to pass a flag into spider_net_decode_one_descr()
so remove this, and perform some othre minor cleanup.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:24:07.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:24:13.000000000 -0600
@@ -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 {
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 5/14] Spidernet RX skb mem leak
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (3 preceding siblings ...)
2006-12-13 21:12 ` [PATCH 4/14] Spidernet cleanup un-needed API Linas Vepstas
@ 2006-12-13 21:15 ` Linas Vepstas
2006-12-13 21:16 ` [PATCH 6/14] Spidernet another " Linas Vepstas
` (8 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:15 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
One of the unlikely error branches has an skb memory leak.
Fix this by handling the error conditions consistently.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:24:13.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:24:16.000000000 -0600
@@ -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 spide
pr_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 spide
if ( (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;
}
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 6/14] Spidernet another skb mem leak
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (4 preceding siblings ...)
2006-12-13 21:15 ` [PATCH 5/14] Spidernet RX skb mem leak Linas Vepstas
@ 2006-12-13 21:16 ` Linas Vepstas
2006-12-13 21:17 ` [PATCH 7/14] Spidernet Cleanup return codes Linas Vepstas
` (7 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:16 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Another skb leak in an error branch. Fix this by adding
call to dev_kfree_skb_irq() after moving to a more
appropriate spot.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:24:16.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:24:20.000000000 -0600
@@ -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:
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 7/14] Spidernet Cleanup return codes
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (5 preceding siblings ...)
2006-12-13 21:16 ` [PATCH 6/14] Spidernet another " Linas Vepstas
@ 2006-12-13 21:17 ` Linas Vepstas
2006-12-13 21:18 ` [PATCH 8/14] Spidernet RX Refill Linas Vepstas
` (6 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:17 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Simplify the somewhat convoluted use of return codes
in the rx buffer handling.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:24:20.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:27:35.000000000 -0600
@@ -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 spide
struct 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 spide
pr_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 spide
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;
+ 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;
}
/**
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 8/14] Spidernet RX Refill
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (6 preceding siblings ...)
2006-12-13 21:17 ` [PATCH 7/14] Spidernet Cleanup return codes Linas Vepstas
@ 2006-12-13 21:18 ` Linas Vepstas
2006-12-13 21:19 ` [PATCH 9/14] Spidernet Remove unused variable Linas Vepstas
` (5 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:18 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
The invocation of the rx ring refill routine is haphazard,
it can be called from a central location.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:27:35.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:28:11.000000000 -0600
@@ -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 */
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 9/14] Spidernet Remove unused variable
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (7 preceding siblings ...)
2006-12-13 21:18 ` [PATCH 8/14] Spidernet RX Refill Linas Vepstas
@ 2006-12-13 21:19 ` Linas Vepstas
2006-12-13 21:20 ` [PATCH 10/14] Spidernet RX Chain tail Linas Vepstas
` (4 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:19 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Remove unused variable; this makes code easier to read.
Tweak commentary.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:28:11.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:28:15.000000000 -0600
@@ -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 spide
SPIDER_NET_DMAC_NOINTR_COMPLETE;
}
- return error;
+ return 0;
}
/**
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 10/14] Spidernet RX Chain tail
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (8 preceding siblings ...)
2006-12-13 21:19 ` [PATCH 9/14] Spidernet Remove unused variable Linas Vepstas
@ 2006-12-13 21:20 ` Linas Vepstas
2006-12-13 21:22 ` [PATCH 11/14] Spidernet Memory barrier Linas Vepstas
` (3 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:20 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Tell the hardware the location of the rx ring tail.
More punctuation cleanup.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:28:15.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:28:19.000000000 -0600
@@ -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;
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 11/14] Spidernet Memory barrier
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (9 preceding siblings ...)
2006-12-13 21:20 ` [PATCH 10/14] Spidernet RX Chain tail Linas Vepstas
@ 2006-12-13 21:22 ` Linas Vepstas
2006-12-13 21:23 ` [PATCH 12/14] Spidernet Avoid possible RX chain corruption Linas Vepstas
` (2 subsequent siblings)
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:22 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Add 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.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 1 +
1 file changed, 1 insertion(+)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:28:19.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:28:23.000000000 -0600
@@ -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;
}
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 12/14] Spidernet Avoid possible RX chain corruption
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (10 preceding siblings ...)
2006-12-13 21:22 ` [PATCH 11/14] Spidernet Memory barrier Linas Vepstas
@ 2006-12-13 21:23 ` Linas Vepstas
2006-12-14 0:22 ` Michael Ellerman
2006-12-13 21:23 ` [PATCH 13/14] Spidernet RX Debugging printout Linas Vepstas
2006-12-13 21:25 ` [PATCH 14/14] Spidernet Rework RX linked list Linas Vepstas
13 siblings, 1 reply; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:23 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
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 <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 1 -
1 file changed, 1 deletion(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:28:23.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:28:25.000000000 -0600
@@ -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;
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 13/14] Spidernet RX Debugging printout
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (11 preceding siblings ...)
2006-12-13 21:23 ` [PATCH 12/14] Spidernet Avoid possible RX chain corruption Linas Vepstas
@ 2006-12-13 21:23 ` Linas Vepstas
2006-12-13 21:25 ` [PATCH 14/14] Spidernet Rework RX linked list Linas Vepstas
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:23 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Add 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.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:30:43.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:32:13.000000000 -0600
@@ -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;
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 14/14] Spidernet Rework RX linked list
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
` (12 preceding siblings ...)
2006-12-13 21:23 ` [PATCH 13/14] Spidernet RX Debugging printout Linas Vepstas
@ 2006-12-13 21:25 ` Linas Vepstas
13 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-13 21:25 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, netdev, Christoph Hellwig, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
Make the hardware perceive the RX descriptor ring as a
null-terminated linked list, instead of a circular ring.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
drivers/net/spider_net.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:32:13.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:33:21.000000000 -0600
@@ -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 *netde
if (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;
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 2/14] Spidernet add net_ratelimit to suppress long output
2006-12-13 21:08 ` [PATCH 2/14] Spidernet add net_ratelimit to suppress long output Linas Vepstas
@ 2006-12-13 23:31 ` Michael Ellerman
2006-12-14 6:13 ` Jim Lewis
0 siblings, 1 reply; 26+ messages in thread
From: Michael Ellerman @ 2006-12-13 23:31 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
On Wed, 2006-12-13 at 15:08 -0600, Linas Vepstas wrote:
> This patch adds net_ratelimit to 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
--
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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
2006-12-13 21:23 ` [PATCH 12/14] Spidernet Avoid possible RX chain corruption Linas Vepstas
@ 2006-12-14 0:22 ` Michael Ellerman
2006-12-14 17:15 ` Linas Vepstas
0 siblings, 1 reply; 26+ messages in thread
From: Michael Ellerman @ 2006-12-14 0:22 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
[-- Attachment #1: Type: text/plain, Size: 1880 bytes --]
On Wed, 2006-12-13 at 15:23 -0600, Linas Vepstas wrote:
> 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 <linas@austin.ibm.com>
> Cc: James K Lewis <jklewis@us.ibm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
>
> ----
>
> drivers/net/spider_net.c | 1 -
> 1 file changed, 1 deletion(-)
>
> Index: linux-2.6.19-git7/drivers/net/spider_net.c
> ===================================================================
> --- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:28:23.000000000 -0600
> +++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-13 14:28:25.000000000 -0600
> @@ -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":
> @@ -501,17 +501,18 @@ spider_net_alloc_rx_skbs(struct spider_n
>
> <snip comment change>
>
> - /* 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
--
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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 2/14] Spidernet add net_ratelimit to suppress long output
2006-12-13 23:31 ` Michael Ellerman
@ 2006-12-14 6:13 ` Jim Lewis
0 siblings, 0 replies; 26+ messages in thread
From: Jim Lewis @ 2006-12-14 6:13 UTC (permalink / raw)
To: michael
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik
It is in the LTC Bugzilla. I just checked and it is still there :)
Jim
On Thu, 2006-12-14 at 10:31 +1100, Michael Ellerman wrote:
> On Wed, 2006-12-13 at 15:08 -0600, Linas Vepstas wrote:
> > This patch adds net_ratelimit to 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
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 1/14] Spidernet DMA coalescing
2006-12-13 21:06 ` [PATCH 1/14] Spidernet DMA coalescing Linas Vepstas
@ 2006-12-14 11:05 ` Christoph Hellwig
2006-12-14 17:07 ` Linas Vepstas
2006-12-26 21:09 ` Jeff Garzik
1 sibling, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2006-12-14 11:05 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
On Wed, Dec 13, 2006 at 03:06:59PM -0600, Linas Vepstas wrote:
>
> 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 :)
> + 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.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 1/14] Spidernet DMA coalescing
2006-12-14 11:05 ` Christoph Hellwig
@ 2006-12-14 17:07 ` Linas Vepstas
2006-12-14 17:35 ` Christoph Hellwig
0 siblings, 1 reply; 26+ messages in thread
From: Linas Vepstas @ 2006-12-14 17:07 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Andrew Morton, Arnd Bergmann, netdev, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
On Thu, Dec 14, 2006 at 11:05:17AM +0000, Christoph Hellwig wrote:
> On Wed, Dec 13, 2006 at 03:06:59PM -0600, Linas Vepstas wrote:
> >
> > 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 :)
>
> > + 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.
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
2006-12-14 0:22 ` Michael Ellerman
@ 2006-12-14 17:15 ` Linas Vepstas
2006-12-14 17:36 ` Christoph Hellwig
2006-12-15 1:48 ` Michael Ellerman
0 siblings, 2 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-14 17:15 UTC (permalink / raw)
To: Michael Ellerman
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
On Thu, Dec 14, 2006 at 11:22:43AM +1100, Michael Ellerman wrote:
> > 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?
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
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 1/14] Spidernet DMA coalescing
2006-12-14 17:07 ` Linas Vepstas
@ 2006-12-14 17:35 ` Christoph Hellwig
2006-12-14 19:38 ` Revised: " Linas Vepstas
0 siblings, 1 reply; 26+ messages in thread
From: Christoph Hellwig @ 2006-12-14 17:35 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
On Thu, Dec 14, 2006 at 11:07:37AM -0600, Linas Vepstas wrote:
> 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.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
2006-12-14 17:15 ` Linas Vepstas
@ 2006-12-14 17:36 ` Christoph Hellwig
2006-12-15 1:48 ` Michael Ellerman
1 sibling, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2006-12-14 17:36 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Christoph Hellwig, Arnd Bergmann, netdev,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
On Thu, Dec 14, 2006 at 11:15:11AM -0600, Linas Vepstas wrote:
> On Thu, Dec 14, 2006 at 11:22:43AM +1100, Michael Ellerman wrote:
> > > 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?
>
> 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?
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.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Revised: [PATCH 1/14] Spidernet DMA coalescing
2006-12-14 17:35 ` Christoph Hellwig
@ 2006-12-14 19:38 ` Linas Vepstas
0 siblings, 0 replies; 26+ messages in thread
From: Linas Vepstas @ 2006-12-14 19:38 UTC (permalink / raw)
To: Christoph Hellwig, Andrew Morton
Cc: Andrew Morton, Arnd Bergmann, netdev, linuxppc-dev,
Jens Osterkamp, jgarzik, James K Lewis
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.
On Thu, Dec 14, 2006 at 05:35:34PM +0000, Christoph Hellwig wrote:
> On Thu, Dec 14, 2006 at 11:07:37AM -0600, Linas Vepstas wrote:
> > 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.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
----
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(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 14:23:11.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-14 11:02:59.000000000 -0600
@@ -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;
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-13 14:23:11.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h 2006-12-14 11:01:37.000000000 -0600
@@ -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...) \
Index: linux-2.6.19-git7/drivers/net/spider_net_ethtool.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net_ethtool.c 2006-12-13 14:23:11.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net_ethtool.c 2006-12-13 14:23:24.000000000 -0600
@@ -158,9 +158,9 @@ spider_net_ethtool_get_ringparam(struct
struct 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)
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 12/14] Spidernet Avoid possible RX chain corruption
2006-12-14 17:15 ` Linas Vepstas
2006-12-14 17:36 ` Christoph Hellwig
@ 2006-12-15 1:48 ` Michael Ellerman
1 sibling, 0 replies; 26+ messages in thread
From: Michael Ellerman @ 2006-12-15 1:48 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, jgarzik, James K Lewis
[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]
On Thu, 2006-12-14 at 11:15 -0600, Linas Vepstas wrote:
> On Thu, Dec 14, 2006 at 11:22:43AM +1100, Michael Ellerman wrote:
> > > 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?
>
> 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?
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
--
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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 1/14] Spidernet DMA coalescing
2006-12-13 21:06 ` [PATCH 1/14] Spidernet DMA coalescing Linas Vepstas
2006-12-14 11:05 ` Christoph Hellwig
@ 2006-12-26 21:09 ` Jeff Garzik
1 sibling, 0 replies; 26+ messages in thread
From: Jeff Garzik @ 2006-12-26 21:09 UTC (permalink / raw)
To: Linas Vepstas
Cc: Andrew Morton, Arnd Bergmann, netdev, Christoph Hellwig,
linuxppc-dev, Jens Osterkamp, James K Lewis
Linas Vepstas wrote:
> 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 <linas@austin.ibm.com>
> Cc: James K Lewis <jklewis@us.ibm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
applied 1-13 of 14 to netdev-2.6.git#upstream
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2006-12-26 21:09 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-13 21:00 [PATCH 0/14]: Spidernet RX-side patches Linas Vepstas
2006-12-13 21:06 ` [PATCH 1/14] Spidernet DMA coalescing Linas Vepstas
2006-12-14 11:05 ` Christoph Hellwig
2006-12-14 17:07 ` Linas Vepstas
2006-12-14 17:35 ` Christoph Hellwig
2006-12-14 19:38 ` Revised: " Linas Vepstas
2006-12-26 21:09 ` Jeff Garzik
2006-12-13 21:08 ` [PATCH 2/14] Spidernet add net_ratelimit to suppress long output Linas Vepstas
2006-12-13 23:31 ` Michael Ellerman
2006-12-14 6:13 ` Jim Lewis
2006-12-13 21:10 ` [PATCH 3/14] Spidernet remove rxramfull tasklet Linas Vepstas
2006-12-13 21:12 ` [PATCH 4/14] Spidernet cleanup un-needed API Linas Vepstas
2006-12-13 21:15 ` [PATCH 5/14] Spidernet RX skb mem leak Linas Vepstas
2006-12-13 21:16 ` [PATCH 6/14] Spidernet another " Linas Vepstas
2006-12-13 21:17 ` [PATCH 7/14] Spidernet Cleanup return codes Linas Vepstas
2006-12-13 21:18 ` [PATCH 8/14] Spidernet RX Refill Linas Vepstas
2006-12-13 21:19 ` [PATCH 9/14] Spidernet Remove unused variable Linas Vepstas
2006-12-13 21:20 ` [PATCH 10/14] Spidernet RX Chain tail Linas Vepstas
2006-12-13 21:22 ` [PATCH 11/14] Spidernet Memory barrier Linas Vepstas
2006-12-13 21:23 ` [PATCH 12/14] Spidernet Avoid possible RX chain corruption Linas Vepstas
2006-12-14 0:22 ` Michael Ellerman
2006-12-14 17:15 ` Linas Vepstas
2006-12-14 17:36 ` Christoph Hellwig
2006-12-15 1:48 ` Michael Ellerman
2006-12-13 21:23 ` [PATCH 13/14] Spidernet RX Debugging printout Linas Vepstas
2006-12-13 21:25 ` [PATCH 14/14] Spidernet Rework RX linked list Linas Vepstas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).