netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: netdev@vger.kernel.org
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: [PATCH v2 05/12] ftgmac100: Pad small frames properly
Date: Mon, 10 Apr 2017 11:15:19 +1000	[thread overview]
Message-ID: <20170410011526.4509-6-benh@kernel.crashing.org> (raw)
In-Reply-To: <20170410011526.4509-1-benh@kernel.crashing.org>

Rather than just transmitting garbage past the end of the small
packet.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--

v2. Use eth_skb_pad (wrapper around skb_put_padto)
---
 drivers/net/ethernet/faraday/ftgmac100.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 84ae800..739916d 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -630,11 +630,17 @@ static void ftgmac100_tx_complete(struct ftgmac100 *priv)
 static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
 				     struct net_device *netdev)
 {
-	unsigned int len = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len;
 	struct ftgmac100 *priv = netdev_priv(netdev);
 	struct ftgmac100_txdes *txdes;
 	dma_addr_t map;
 
+	/* The HW doesn't pad small frames */
+	if (eth_skb_pad(skb)) {
+		netdev->stats.tx_dropped++;
+		return NETDEV_TX_OK;
+	}
+
+	/* Reject oversize packets */
 	if (unlikely(skb->len > MAX_PKT_SIZE)) {
 		if (net_ratelimit())
 			netdev_dbg(netdev, "tx packet too big\n");
@@ -655,7 +661,7 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
 	/* setup TX descriptor */
 	ftgmac100_txdes_set_skb(txdes, skb);
 	ftgmac100_txdes_set_dma_addr(txdes, map);
-	ftgmac100_txdes_set_buffer_size(txdes, len);
+	ftgmac100_txdes_set_buffer_size(txdes, skb->len);
 
 	ftgmac100_txdes_set_first_segment(txdes);
 	ftgmac100_txdes_set_last_segment(txdes);
-- 
2.9.3

  parent reply	other threads:[~2017-04-10  1:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10  1:15 [PATCH v2 00/12] ftgmac100: Rework batch 3 - TX path Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 01/12] ftgmac100: Add a tx timeout handler Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 02/12] ftgmac100: Move ftgmac100_hard_start_xmit() around Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 03/12] ftgmac100: Merge ftgmac100_xmit() into ftgmac100_hard_start_xmit() Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 04/12] ftgmac100: Factor tx packet dropping path Benjamin Herrenschmidt
2017-04-10  1:15 ` Benjamin Herrenschmidt [this message]
2017-04-10  1:15 ` [PATCH v2 06/12] ftgmac100: Store tx skbs in a separate array Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 07/12] ftgmac100: Cleanup tx queue handling Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 08/12] ftgmac100: Move the barrier out of ftgmac100_txdes_set_dma_own() Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 09/12] ftgmac100: Split tx packet freeing from ftgmac100_tx_complete_packet() Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 10/12] ftgmac100: Don't clear tx desc fields unnecessarily Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 11/12] ftgmac100: Add support for fragmented tx Benjamin Herrenschmidt
2017-04-10  1:15 ` [PATCH v2 12/12] ftgmac100: Remove tx descriptor accessors Benjamin Herrenschmidt
2017-04-10 20:04 ` [PATCH v2 00/12] ftgmac100: Rework batch 3 - TX path 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=20170410011526.4509-6-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --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).