From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next v4 2/2] net: systemport: pad packets to a minimum of 64 bytes
Date: Fri, 9 May 2014 13:16:39 -0700 [thread overview]
Message-ID: <1399666599-19398-3-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1399666599-19398-1-git-send-email-f.fainelli@gmail.com>
The switch fabric which is used behind the Broadcom SYSTEMPORT Ethernet
controller will discard any incoming packet that is not 64 bytes or
more. Since the UniMAC hardware transmits up to the specified size, just
make sure that we properly pad the end of the packet with zeroes using
skb_padto() and set a minimum packet length of 64 bytes.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v4:
- respin due to first patch
Changes in v3:
- reword the commit message and comment to explain the special hardware
requirements
- print skb_len instead of skb->len in the DMA map failure error
Changes in v2:
- add missing skb_padto() to zero-out packets
drivers/net/ethernet/broadcom/bcmsysport.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index ac42a9e91f3a..dbae674384ea 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -821,6 +821,7 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
struct bcm_sysport_cb *cb;
struct netdev_queue *txq;
struct dma_desc *desc;
+ unsigned int skb_len;
dma_addr_t mapping;
u32 len_status;
u16 queue;
@@ -848,10 +849,22 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
}
}
- mapping = dma_map_single(kdev, skb->data, skb->len, DMA_TO_DEVICE);
+ /* The Ethernet switch we are interfaced with needs packets to be at
+ * least 64 bytes otherwise they will be discarded when they enter
+ * the switch port logic. The UniMAC hardware transmits up to the
+ * specified length.
+ */
+ if (skb_padto(skb, 64)) {
+ ret = NETDEV_TX_OK;
+ goto out;
+ }
+
+ skb_len = skb->len < 64 ? 64 : skb->len;
+
+ mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
if (dma_mapping_error(kdev, mapping)) {
netif_err(priv, tx_err, dev, "DMA map failed at %p (len=%d)\n",
- skb->data, skb->len);
+ skb->data, skb_len);
ret = NETDEV_TX_OK;
goto out;
}
@@ -860,14 +873,14 @@ static netdev_tx_t bcm_sysport_xmit(struct sk_buff *skb,
cb = &ring->cbs[ring->curr_desc];
cb->skb = skb;
dma_unmap_addr_set(cb, dma_addr, mapping);
- dma_unmap_len_set(cb, dma_len, skb->len);
+ dma_unmap_len_set(cb, dma_len, skb_len);
/* Fetch a descriptor entry from our pool */
desc = ring->desc_cpu;
desc->addr_lo = lower_32_bits(mapping);
len_status = upper_32_bits(mapping) & DESC_ADDR_HI_MASK;
- len_status |= (skb->len << DESC_LEN_SHIFT);
+ len_status |= (skb_len << DESC_LEN_SHIFT);
len_status |= (DESC_SOP | DESC_EOP | TX_STATUS_APP_CRC) <<
DESC_STATUS_SHIFT;
if (skb->ip_summed == CHECKSUM_PARTIAL)
--
1.9.1
next prev parent reply other threads:[~2014-05-09 20:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 20:16 [PATCH net-next v4 0/2] net: systemport: couple fixes Florian Fainelli
2014-05-09 20:16 ` [PATCH net-next v4 1/2] net: systemport: only update UMAC_CMD if something changed Florian Fainelli
2014-05-09 20:16 ` Florian Fainelli [this message]
2014-05-12 12:45 ` [PATCH net-next v4 2/2] net: systemport: pad packets to a minimum of 64 bytes David Laight
2014-05-14 0:18 ` Florian Fainelli
2014-05-14 0:36 ` Florian Fainelli
2014-05-14 8:51 ` David Laight
2014-05-14 16:09 ` Florian Fainelli
2014-05-13 16:48 ` [PATCH net-next v4 0/2] net: systemport: couple fixes 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=1399666599-19398-3-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.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).