Skip to content

Commit 84301f9

Browse files
committed
net: stmmac: Disable automatic FCS/Pad stripping
Author: Kurt Kanzenbach <kurt@linutronix.de> The stmmac has the possibility to automatically strip the padding/FCS for IEEE 802.3 type frames. This feature is enabled conditionally. Therefore, the stmmac receive path has to have a determination logic whether the FCS has to be stripped in software or not. In fact, for DSA this ACS feature is disabled and the determination logic doesn't check for it properly. For instance, when using DSA in combination with an older stmmac (pre version 4), the FCS is not stripped by hardware or software which is problematic. So either add another check for DSA to the fast path or simply disable ACS feature completely. The latter approach has been chosen, because most of the time the FCS is stripped in software anyway and it removes conditionals from the receive fast path. Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/87v8q8jjgh.fsf@kurt/ Link: https://lore.kernel.org/r/20220905130155.193640-1-kurt@linutronix.de Signed-off-by: Paolo Abeni <pabeni@redhat.com> (cherry picked from commit 929d434) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100606 Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
1 parent 8e0ff0b commit 84301f9

File tree

6 files changed

+6
-40
lines changed

6 files changed

+6
-40
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac100.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#define MAC_CONTROL_TE 0x00000008 /* Transmitter Enable */
5757
#define MAC_CONTROL_RE 0x00000004 /* Receiver Enable */
5858

59-
#define MAC_CORE_INIT (MAC_CONTROL_HBD | MAC_CONTROL_ASTP)
59+
#define MAC_CORE_INIT (MAC_CONTROL_HBD)
6060

6161
/* MAC FLOW CTRL defines */
6262
#define MAC_FLOW_CTRL_PT_MASK 0xffff0000 /* Pause Time Mask */

drivers/net/ethernet/stmicro/stmmac/dwmac1000.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ enum inter_frame_gap {
126126
#define GMAC_CONTROL_TE 0x00000008 /* Transmitter Enable */
127127
#define GMAC_CONTROL_RE 0x00000004 /* Receiver Enable */
128128

129-
#define GMAC_CORE_INIT (GMAC_CONTROL_JD | GMAC_CONTROL_PS | GMAC_CONTROL_ACS | \
129+
#define GMAC_CORE_INIT (GMAC_CONTROL_JD | GMAC_CONTROL_PS | \
130130
GMAC_CONTROL_BE | GMAC_CONTROL_DCRS)
131131

132132
/* GMAC Frame Filter defines */

drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/crc32.h>
1616
#include <linux/slab.h>
1717
#include <linux/ethtool.h>
18-
#include <net/dsa.h>
1918
#include <asm/io.h>
2019
#include "stmmac.h"
2120
#include "stmmac_pcs.h"
@@ -24,21 +23,13 @@
2423
static void dwmac1000_core_init(struct mac_device_info *hw,
2524
struct net_device *dev)
2625
{
27-
struct stmmac_priv *priv = netdev_priv(dev);
2826
void __iomem *ioaddr = hw->pcsr;
2927
u32 value = readl(ioaddr + GMAC_CONTROL);
3028
int mtu = dev->mtu;
3129

3230
/* Configure GMAC core */
3331
value |= GMAC_CORE_INIT;
3432

35-
/* Clear ACS bit because Ethernet switch tagging formats such as
36-
* Broadcom tags can look like invalid LLC/SNAP packets and cause the
37-
* hardware to truncate packets on reception.
38-
*/
39-
if (netdev_uses_dsa(dev) || !priv->plat->enh_desc)
40-
value &= ~GMAC_CONTROL_ACS;
41-
4233
if (mtu > 1500)
4334
value |= GMAC_CONTROL_2K;
4435
if (mtu > 2000)

drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*******************************************************************************/
1616

1717
#include <linux/crc32.h>
18-
#include <net/dsa.h>
1918
#include <asm/io.h>
2019
#include "stmmac.h"
2120
#include "dwmac100.h"
@@ -28,13 +27,6 @@ static void dwmac100_core_init(struct mac_device_info *hw,
2827

2928
value |= MAC_CORE_INIT;
3029

31-
/* Clear ASTP bit because Ethernet switch tagging formats such as
32-
* Broadcom tags can look like invalid LLC/SNAP packets and cause the
33-
* hardware to truncate packets on reception.
34-
*/
35-
if (netdev_uses_dsa(dev))
36-
value &= ~MAC_CONTROL_ASTP;
37-
3830
writel(value, ioaddr + MAC_CONTROL);
3931

4032
#ifdef STMMAC_VLAN_TAG_USED

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/slab.h>
1515
#include <linux/ethtool.h>
1616
#include <linux/io.h>
17-
#include <net/dsa.h>
1817
#include "stmmac.h"
1918
#include "stmmac_pcs.h"
2019
#include "dwmac4.h"

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5076,16 +5076,8 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
50765076
buf1_len = stmmac_rx_buf1_len(priv, p, status, len);
50775077
len += buf1_len;
50785078

5079-
/* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
5080-
* Type frames (LLC/LLC-SNAP)
5081-
*
5082-
* llc_snap is never checked in GMAC >= 4, so this ACS
5083-
* feature is always disabled and packets need to be
5084-
* stripped manually.
5085-
*/
5086-
if (likely(!(status & rx_not_ls)) &&
5087-
(likely(priv->synopsys_id >= DWMAC_CORE_4_00) ||
5088-
unlikely(status != llc_snap))) {
5079+
/* ACS is disabled; strip manually. */
5080+
if (likely(!(status & rx_not_ls))) {
50895081
buf1_len -= ETH_FCS_LEN;
50905082
len -= ETH_FCS_LEN;
50915083
}
@@ -5262,16 +5254,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
52625254
buf2_len = stmmac_rx_buf2_len(priv, p, status, len);
52635255
len += buf2_len;
52645256

5265-
/* ACS is set; GMAC core strips PAD/FCS for IEEE 802.3
5266-
* Type frames (LLC/LLC-SNAP)
5267-
*
5268-
* llc_snap is never checked in GMAC >= 4, so this ACS
5269-
* feature is always disabled and packets need to be
5270-
* stripped manually.
5271-
*/
5272-
if (likely(!(status & rx_not_ls)) &&
5273-
(likely(priv->synopsys_id >= DWMAC_CORE_4_00) ||
5274-
unlikely(status != llc_snap))) {
5257+
/* ACS is disabled; strip manually. */
5258+
if (likely(!(status & rx_not_ls))) {
52755259
if (buf2_len) {
52765260
buf2_len -= ETH_FCS_LEN;
52775261
len -= ETH_FCS_LEN;

0 commit comments

Comments
 (0)