From: Mike McCormack <mikem@ring3k.org>
To: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH resend] sky2: Account for VLAN tag in tx_le_req
Date: Mon, 14 Sep 2009 08:07:41 +0900 [thread overview]
Message-ID: <4AAD7B3D.7010403@ring3k.org> (raw)
With VLAN enabled, tx_le_req could return fewer list elements than required,
leading to a potential wrap around of the transmit ring buffer.
Signed-off-by: Mike McCormack <mikem@ring3k.org>
---
drivers/net/sky2.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 00bc65a..c8ebc03 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1563,7 +1563,7 @@ static inline int tx_avail(const struct sky2_port *sky2)
}
/* Estimate of number of transmit list elements required */
-static unsigned tx_le_req(const struct sk_buff *skb)
+static unsigned tx_le_req(const struct sk_buff *skb, int vlan_tag)
{
unsigned count;
@@ -1573,6 +1573,9 @@ static unsigned tx_le_req(const struct sk_buff *skb)
if (skb_is_gso(skb))
++count;
+ else if (sizeof(dma_addr_t) == sizeof(u32) && vlan_tag)
+ ++count;
+
if (skb->ip_summed == CHECKSUM_PARTIAL)
++count;
@@ -1611,8 +1614,13 @@ static netdev_tx_t sky2_xmit_frame(struct sk_buff *skb,
u16 slot;
u16 mss;
u8 ctrl;
+ unsigned vlan_tag = 0;
+
+#ifdef SKY2_VLAN_TAG_USED
+ vlan_tag = sky2->vlgrp && vlan_tx_tag_present(skb);
+#endif
- if (unlikely(tx_avail(sky2) < tx_le_req(skb)))
+ if (unlikely(tx_avail(sky2) < tx_le_req(skb, vlan_tag)))
return NETDEV_TX_BUSY;
len = skb_headlen(skb);
@@ -1657,7 +1665,7 @@ static netdev_tx_t sky2_xmit_frame(struct sk_buff *skb,
ctrl = 0;
#ifdef SKY2_VLAN_TAG_USED
/* Add VLAN tag, can piggyback on LRGLEN or ADDR64 */
- if (sky2->vlgrp && vlan_tx_tag_present(skb)) {
+ if (vlan_tag) {
if (!le) {
le = get_tx_le(sky2, &slot);
le->addr = 0;
--
1.5.6.5
next reply other threads:[~2009-09-13 23:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-13 23:07 Mike McCormack [this message]
2009-09-14 16:12 ` [PATCH alt] sky2: transmit ring accounting Stephen Hemminger
2009-09-15 9:50 ` 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=4AAD7B3D.7010403@ring3k.org \
--to=mikem@ring3k.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.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.