From: Sergei Antonov <saproj@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, andrew@lunn.ch,
Sergei Antonov <saproj@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>
Subject: [PATCH v4 net-next] net: ftmac100: support mtu > 1500
Date: Wed, 19 Oct 2022 19:20:58 +0300 [thread overview]
Message-ID: <20221019162058.289712-1-saproj@gmail.com> (raw)
The ftmac100 controller considers some packets FTL (frame
too long) and drops them. An example of a dropped packet:
6 bytes - dst MAC
6 bytes - src MAC
2 bytes - EtherType IPv4 (0800)
1504 bytes - IPv4 packet
Do the following to let the driver receive these packets.
Set FTMAC100_MACCR_RX_FTL when mtu>1500 in the MAC Control Register.
For received packets marked with FTMAC100_RXDES0_FTL check if packet
length (with FCS excluded) is within expected limits, that is not
greater than netdev->mtu + 14 (Ethernet headers). Otherwise trigger
an error.
Fixes: 8d77c036b57c ("net: add Faraday FTMAC100 10/100 Ethernet driver")
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Suggested-by: Vladimir Oltean <olteanv@gmail.com>
---
drivers/net/ethernet/faraday/ftmac100.c | 29 ++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index d95d78230828..f89b53845f21 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -159,6 +159,7 @@ static void ftmac100_set_mac(struct ftmac100 *priv, const unsigned char *mac)
static int ftmac100_start_hw(struct ftmac100 *priv)
{
struct net_device *netdev = priv->netdev;
+ unsigned int maccr;
if (ftmac100_reset(priv))
return -EIO;
@@ -175,7 +176,20 @@ static int ftmac100_start_hw(struct ftmac100 *priv)
ftmac100_set_mac(priv, netdev->dev_addr);
- iowrite32(MACCR_ENABLE_ALL, priv->base + FTMAC100_OFFSET_MACCR);
+ maccr = MACCR_ENABLE_ALL;
+
+ /* We have to set FTMAC100_MACCR_RX_FTL in case MTU > 1500
+ * and do extra length check in ftmac100_rx_packet_error().
+ * Otherwise the controller silently drops these packets.
+ *
+ * When the MTU of the interface is standard 1500, rely on
+ * the controller's functionality to drop too long packets
+ * and save some CPU time.
+ */
+ if (netdev->mtu > 1500)
+ maccr |= FTMAC100_MACCR_RX_FTL;
+
+ iowrite32(maccr, priv->base + FTMAC100_OFFSET_MACCR);
return 0;
}
@@ -337,9 +351,18 @@ static bool ftmac100_rx_packet_error(struct ftmac100 *priv,
error = true;
}
- if (unlikely(ftmac100_rxdes_frame_too_long(rxdes))) {
+ /* If the frame-too-long flag FTMAC100_RXDES0_FTL is set, check
+ * if ftmac100_rxdes_frame_length(rxdes) exceeds the currently
+ * set MTU plus ETH_HLEN.
+ * The controller would set FTMAC100_RXDES0_FTL for all incoming
+ * frames longer than 1518 (includeing FCS) in the presense of
+ * FTMAC100_MACCR_RX_FTL in the MAC Control Register.
+ */
+ if (unlikely(ftmac100_rxdes_frame_too_long(rxdes) &&
+ ftmac100_rxdes_frame_length(rxdes) > netdev->mtu + ETH_HLEN)) {
if (net_ratelimit())
- netdev_info(netdev, "rx frame too long\n");
+ netdev_info(netdev, "rx frame too long (%u)\n",
+ ftmac100_rxdes_frame_length(rxdes));
netdev->stats.rx_length_errors++;
error = true;
--
2.34.1
next reply other threads:[~2022-10-19 16:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 16:20 Sergei Antonov [this message]
2022-10-19 16:25 ` [PATCH v4 net-next] net: ftmac100: support mtu > 1500 Sergei Antonov
2022-10-19 16:55 ` Vladimir Oltean
2022-10-19 18:36 ` Sergei Antonov
2022-10-19 18:42 ` Vladimir Oltean
2022-10-24 15:50 ` Sergei Antonov
2022-10-24 16:09 ` Andrew Lunn
2022-10-24 16:21 ` Vladimir Oltean
2022-10-24 16:24 ` Vladimir Oltean
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=20221019162058.289712-1-saproj@gmail.com \
--to=saproj@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/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).