From: Sergei Antonov <saproj@gmail.com>
To: netdev@vger.kernel.org
Cc: olteanv@gmail.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
Sergei Antonov <saproj@gmail.com>, Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH v3 net] net: ftmac100: support frames with DSA tag
Date: Thu, 13 Oct 2022 18:57:24 +0300 [thread overview]
Message-ID: <20221013155724.2911050-1-saproj@gmail.com> (raw)
Fixes the problem when frames coming from DSA were discarded.
DSA tag might make frame size >1518. Such frames are discarded
by the controller when FTMAC100_MACCR_RX_FTL is not set in the
MAC Control Register, see datasheet [1].
Set FTMAC100_MACCR_RX_FTL 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. In the presence of DSA netdev->mtu is 1504 to accommodate
for VLAN tag.
[1]
https://bitbucket.org/Kasreyn/mkrom-uc7112lx/src/master/documents/FIC8120_DS_v1.2.pdf
Fixes: 8d77c036b57c ("net: add Faraday FTMAC100 10/100 Ethernet driver")
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Suggested-by: Andrew Lunn <andrew@lunn.ch>
---
v2 -> v3:
* Corrected the explanation of the problem: datasheet is correct.
* Rewrote the code to use the currently set mtu to handle DSA frames.
v1 -> v2:
* Typos in description fixed.
drivers/net/ethernet/faraday/ftmac100.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index d95d78230828..9187331e83dc 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -154,6 +154,7 @@ static void ftmac100_set_mac(struct ftmac100 *priv, const unsigned char *mac)
FTMAC100_MACCR_CRC_APD | \
FTMAC100_MACCR_FULLDUP | \
FTMAC100_MACCR_RX_RUNT | \
+ FTMAC100_MACCR_RX_FTL | \
FTMAC100_MACCR_RX_BROADPKT)
static int ftmac100_start_hw(struct ftmac100 *priv)
@@ -337,9 +338,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-13 15:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 15:57 Sergei Antonov [this message]
2022-10-17 15:55 ` [PATCH v3 net] net: ftmac100: support frames with DSA tag Vladimir Oltean
2022-10-19 13:57 ` Sergei Antonov
2022-10-19 14:02 ` Vladimir Oltean
2022-10-19 16:19 ` Sergei Antonov
2022-10-19 16:31 ` 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=20221013155724.2911050-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).