From: Stephen Hemminger <shemminger@vyatta.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH 7/9] sky2: skb recycling
Date: Wed, 17 Jun 2009 10:30:38 -0700 [thread overview]
Message-ID: <20090617173140.244124173@vyatta.com> (raw)
In-Reply-To: 20090617173031.703636683@vyatta.com
[-- Attachment #1: sky2-recycle.patch --]
[-- Type: text/plain, Size: 3026 bytes --]
This patch implements skb recycling. It reclaims transmitted skb's
for use in the receive ring.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/sky2.c 2009-06-17 10:29:57.400008862 -0700
+++ b/drivers/net/sky2.c 2009-06-17 10:29:58.250810500 -0700
@@ -1176,6 +1176,7 @@ static void sky2_rx_clean(struct sky2_po
re->skb = NULL;
}
}
+ skb_queue_purge(&sky2->rx_recycle);
}
/* Basic MII support */
@@ -1252,6 +1253,12 @@ static void sky2_vlan_rx_register(struct
}
#endif
+/* Amount of required worst case padding in rx buffer */
+static inline unsigned sky2_rx_pad(const struct sky2_hw *hw)
+{
+ return (hw->flags & SKY2_HW_RAM_BUFFER) ? 8 : 2;
+}
+
/*
* Allocate an skb for receiving. If the MTU is large enough
* make the skb non-linear with a fragment list of pages.
@@ -1261,6 +1268,13 @@ static struct sk_buff *sky2_rx_alloc(str
struct sk_buff *skb;
int i;
+ skb = __skb_dequeue(&sky2->rx_recycle);
+ if (!skb)
+ skb = netdev_alloc_skb(sky2->netdev, sky2->rx_data_size
+ + sky2_rx_pad(sky2->hw));
+ if (!skb)
+ goto nomem;
+
if (sky2->hw->flags & SKY2_HW_RAM_BUFFER) {
unsigned char *start;
/*
@@ -1269,18 +1283,10 @@ static struct sk_buff *sky2_rx_alloc(str
* The buffer returned from netdev_alloc_skb is
* aligned except if slab debugging is enabled.
*/
- skb = netdev_alloc_skb(sky2->netdev, sky2->rx_data_size + 8);
- if (!skb)
- goto nomem;
start = PTR_ALIGN(skb->data, 8);
skb_reserve(skb, start - skb->data);
- } else {
- skb = netdev_alloc_skb(sky2->netdev,
- sky2->rx_data_size + NET_IP_ALIGN);
- if (!skb)
- goto nomem;
+ } else
skb_reserve(skb, NET_IP_ALIGN);
- }
for (i = 0; i < sky2->rx_nfrags; i++) {
struct page *page = alloc_page(GFP_ATOMIC);
@@ -1357,6 +1363,8 @@ static int sky2_rx_start(struct sky2_por
sky2->rx_data_size = size;
+ skb_queue_head_init(&sky2->rx_recycle);
+
/* Fill Rx ring */
for (i = 0; i < sky2->rx_pending; i++) {
re = sky2->rx_ring + i;
@@ -1764,14 +1772,22 @@ static void sky2_tx_complete(struct sky2
}
if (le->ctrl & EOP) {
+ struct sk_buff *skb = re->skb;
+
if (unlikely(netif_msg_tx_done(sky2)))
printk(KERN_DEBUG "%s: tx done %u\n",
dev->name, idx);
dev->stats.tx_packets++;
- dev->stats.tx_bytes += re->skb->len;
+ dev->stats.tx_bytes += skb->len;
+
+ if (skb_queue_len(&sky2->rx_recycle) < sky2->rx_pending
+ && skb_recycle_check(skb, sky2->rx_data_size
+ + sky2_rx_pad(sky2->hw)))
+ __skb_queue_head(&sky2->rx_recycle, skb);
+ else
+ dev_kfree_skb_any(skb);
- dev_kfree_skb_any(re->skb);
sky2->tx_next = RING_NEXT(idx, TX_RING_SIZE);
}
}
--- a/drivers/net/sky2.h 2009-06-17 10:29:17.200758602 -0700
+++ b/drivers/net/sky2.h 2009-06-17 10:29:58.252811835 -0700
@@ -2028,6 +2028,7 @@ struct sky2_port {
u16 rx_pending;
u16 rx_data_size;
u16 rx_nfrags;
+ struct sk_buff_head rx_recycle;
#ifdef SKY2_VLAN_TAG_USED
u16 rx_tag;
--
next prev parent reply other threads:[~2009-06-17 17:34 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-17 17:30 [PATCH 0/9] sky2 driver patches Stephen Hemminger
2009-06-17 17:30 ` [PATCH 1/9] sky2: turn off pause during shutdown Stephen Hemminger
2009-06-18 1:50 ` David Miller
2009-06-17 17:30 ` [PATCH 2/9] sky2: more receive shutdown Stephen Hemminger
2009-06-18 1:50 ` David Miller
2009-06-20 7:14 ` Graham Murray
2009-06-22 5:13 ` Graham Murray
2009-06-17 17:30 ` [PATCH 3/9] sky2: PCI irq issues Stephen Hemminger
2009-06-18 1:50 ` David Miller
2009-06-17 17:30 ` [PATCH 4/9] sky2: fix shutdown synchronization Stephen Hemminger
2009-06-18 1:50 ` David Miller
2009-06-18 23:25 ` Mike McCormack
2009-06-18 23:41 ` Stephen Hemminger
2009-06-18 23:53 ` Mike McCormack
2009-06-17 17:30 ` [PATCH 5/9] sky2: receive counter update Stephen Hemminger
2009-06-18 1:51 ` David Miller
2009-06-17 17:30 ` [PATCH 6/9] sky2: reduce default transmit ring Stephen Hemminger
2009-06-18 1:51 ` David Miller
2009-06-17 17:30 ` Stephen Hemminger [this message]
2009-06-18 1:51 ` [PATCH 7/9] sky2: skb recycling David Miller
2009-06-18 21:13 ` Brandeburg, Jesse
2009-06-18 21:22 ` Stephen Hemminger
2009-06-17 17:30 ` [PATCH 8/9] sky2: add GRO support Stephen Hemminger
2009-06-18 1:52 ` David Miller
2009-06-17 17:30 ` [PATCH 9/9] sky2: version 1.23 Stephen Hemminger
2009-06-18 1:52 ` David Miller
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=20090617173140.244124173@vyatta.com \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--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 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).