All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: jim@jklewis.com
Cc: Jeff Garzik <jgarzik@pobox.com>, Andrew Morton <akpm@osdl.org>,
	netdev <netdev@vger.kernel.org>, Work <jklewis@us.ibm.com>
Subject: [PATCH] spidernet: fix transmit routine.
Date: Fri, 10 Nov 2006 10:50:38 -0800	[thread overview]
Message-ID: <20061110105038.200a74d0@freekitty> (raw)
In-Reply-To: <1163181046.4422.11.camel@localhost.localdomain>

Try this patch instead (I don't have the hardware to even build).


Fix spider_net transmit routine:
 1. use skb_padto properly
 2. don't return -ENOMEM. Only valid returns from device transmit
    routine are NETDEV_TX_OK, BUSY, LOCKED

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
---
 drivers/net/spider_net.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 418138d..cd7f13c 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -644,22 +644,18 @@ spider_net_prepare_tx_descr(struct spide
 	struct spider_net_descr *descr;
 	dma_addr_t buf;
 	unsigned long flags;
-	int length;
 
-	length = skb->len;
-	if (length < ETH_ZLEN) {
-		if (skb_pad(skb, ETH_ZLEN-length))
-			return 0;
-		length = ETH_ZLEN;
-	}
+	if (skb_padto(skb, ETH_ZLEN))
+		return NETDEV_TX_OK;
 
-	buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE);
+	buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
 	if (pci_dma_mapping_error(buf)) {
 		if (netif_msg_tx_err(card) && net_ratelimit())
 			pr_err("could not iommu-map packet (%p, %i). "
-				  "Dropping packet\n", skb->data, length);
+				  "Dropping packet\n", skb->data, skb->len);
 		card->spider_stats.tx_iommu_map_error++;
-		return -ENOMEM;
+		dev_kfree_skb(skb);
+		return NETDEV_TX_OK;
 	}
 
 	spin_lock_irqsave(&card->tx_chain.lock, flags);
@@ -667,7 +663,7 @@ spider_net_prepare_tx_descr(struct spide
 	card->tx_chain.head = descr->next;
 
 	descr->buf_addr = buf;
-	descr->buf_size = length;
+	descr->buf_size = skb->len;
 	descr->next_descr_addr = 0;
 	descr->skb = skb;
 	descr->data_status = 0;
@@ -690,7 +686,7 @@ spider_net_prepare_tx_descr(struct spide
 	descr->prev->next_descr_addr = descr->bus_addr;
 
 	card->netdev->trans_start = jiffies; /* set netdev watchdog timer */
-	return 0;
+	return NETDEV_TX_OK;
 }
 
 static int
-- 
1.4.1


  parent reply	other threads:[~2006-11-10 19:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-10 17:50 [PATCH] Spidernet - remove ETH_ZLEN check in earlier patch Jim Lewis
2006-11-10 17:58 ` Stephen Hemminger
2006-11-10 18:50 ` Stephen Hemminger [this message]
     [not found]   ` <OFF9C5DB9C.8DD003F3-ON87257222.0068A615-86257222.006950CA@us.ibm.com>
2006-11-10 19:30     ` [PATCH] spidernet: fix transmit routine Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061110105038.200a74d0@freekitty \
    --to=shemminger@osdl.org \
    --cc=akpm@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=jim@jklewis.com \
    --cc=jklewis@us.ibm.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.