ramips: support jumbo frame on mt7621 up to 2k
[openwrt/openwrt.git] / target / linux / ramips / patches-4.4 / 0501-net-next-mediatek-add-the-drivers-core-files.patch
index e94c1fab05c095ce2e716862cf3b7b802c1b8d62..72ed2c5df10208e67197dbae082178e61e570c57 100644 (file)
@@ -27,7 +27,7 @@ we are on. The code to bring up the switches and external ports has also been
 split into separate files.
 
 Signed-off-by: John Crispin <blogic@openwrt.org>
-Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
 Signed-off-by: Michael Lee <igvtee@gmail.com>
 ---
  drivers/net/ethernet/mediatek/ethtool.c     |  235 ++++
@@ -57,7 +57,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 + *   GNU General Public License for more details.
 + *
 + *   Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
-+ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
++ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@nbd.name>
 + *   Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
 + */
 +
@@ -295,7 +295,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 + *   GNU General Public License for more details.
 + *
 + *   Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
-+ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
++ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@nbd.name>
 + *   Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
 + */
 +
@@ -315,7 +315,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 + *   the Free Software Foundation; version 2 of the License
 + *
 + *   Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
-+ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
++ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@nbd.name>
 + *   Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
 + */
 +
@@ -581,7 +581,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 + *   GNU General Public License for more details.
 + *
 + *   Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
-+ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
++ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@nbd.name>
 + *   Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
 + */
 +
@@ -600,7 +600,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +#endif
 --- /dev/null
 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -0,0 +1,1607 @@
+@@ -0,0 +1,1593 @@
 +/*   This program is free software; you can redistribute it and/or modify
 + *   it under the terms of the GNU General Public License as published by
 + *   the Free Software Foundation; version 2 of the License
@@ -611,7 +611,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 + *   GNU General Public License for more details.
 + *
 + *   Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
-+ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
++ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@nbd.name>
 + *   Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
 + */
 +
@@ -1400,20 +1400,6 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +      return NETDEV_TX_OK;
 +}
 +
-+static inline void fe_rx_vlan(struct sk_buff *skb)
-+{
-+      struct ethhdr *ehdr;
-+      u16 vlanid;
-+
-+      if (!__vlan_get_tag(skb, &vlanid)) {
-+              /* pop the vlan tag */
-+              ehdr = (struct ethhdr *)skb->data;
-+              memmove(skb->data + VLAN_HLEN, ehdr, ETH_ALEN * 2);
-+              skb_pull(skb, VLAN_HLEN);
-+              __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlanid);
-+      }
-+}
-+
 +static int fe_poll_rx(struct napi_struct *napi, int budget,
 +                    struct fe_priv *priv, u32 rx_intr)
 +{
@@ -1427,7 +1413,6 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +      u8 *data, *new_data;
 +      struct fe_rx_dma *rxd, trxd;
 +      int done = 0, pad;
-+      bool rx_vlan = netdev->features & NETIF_F_HW_VLAN_CTAG_RX;
 +
 +      if (netdev->features & NETIF_F_RXCSUM)
 +              checksum_bit = soc->checksum_bit;
@@ -1483,8 +1468,6 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +                      skb->ip_summed = CHECKSUM_UNNECESSARY;
 +              else
 +                      skb_checksum_none_assert(skb);
-+              if (rx_vlan)
-+                      fe_rx_vlan(skb);
 +              skb->protocol = eth_type_trans(skb, netdev);
 +
 +              stats->rx_packets++;
@@ -1962,6 +1945,10 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +      if (!(priv->flags & FE_FLAG_JUMBO_FRAME))
 +              return eth_change_mtu(dev, new_mtu);
 +
++      if (IS_ENABLED(CONFIG_SOC_MT7621))
++              if (new_mtu > 2048)
++                      return -EINVAL;
++
 +      frag_size = fe_max_frag_size(new_mtu);
 +      if (new_mtu < 68 || frag_size > PAGE_SIZE)
 +              return -EINVAL;
@@ -1985,15 +1972,17 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +              return 0;
 +
 +      fe_stop(dev);
-+      fwd_cfg = fe_r32(FE_GDMA1_FWD_CFG);
-+      if (new_mtu <= ETH_DATA_LEN) {
-+              fwd_cfg &= ~FE_GDM1_JMB_EN;
-+      } else {
-+              fwd_cfg &= ~(FE_GDM1_JMB_LEN_MASK << FE_GDM1_JMB_LEN_SHIFT);
-+              fwd_cfg |= (DIV_ROUND_UP(frag_size, 1024) <<
-+                              FE_GDM1_JMB_LEN_SHIFT) | FE_GDM1_JMB_EN;
++      if (!IS_ENABLED(CONFIG_SOC_MT7621)) {
++              fwd_cfg = fe_r32(FE_GDMA1_FWD_CFG);
++              if (new_mtu <= ETH_DATA_LEN) {
++                      fwd_cfg &= ~FE_GDM1_JMB_EN;
++              } else {
++                      fwd_cfg &= ~(FE_GDM1_JMB_LEN_MASK << FE_GDM1_JMB_LEN_SHIFT);
++                      fwd_cfg |= (DIV_ROUND_UP(frag_size, 1024) <<
++                                      FE_GDM1_JMB_LEN_SHIFT) | FE_GDM1_JMB_EN;
++              }
++              fe_w32(fwd_cfg, FE_GDMA1_FWD_CFG);
 +      }
-+      fe_w32(fwd_cfg, FE_GDMA1_FWD_CFG);
 +
 +      return fe_open(dev);
 +}
@@ -2098,10 +2087,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 +
 +      if (soc->init_data)
 +              soc->init_data(soc, netdev);
-+      /* fake NETIF_F_HW_VLAN_CTAG_RX for good GRO performance */
-+      netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
-+      netdev->vlan_features = netdev->hw_features &
-+              ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX);
++      netdev->vlan_features = netdev->hw_features & ~NETIF_F_HW_VLAN_CTAG_TX;
 +      netdev->features |= netdev->hw_features;
 +
 +      /* fake rx vlan filter func. to support tx vlan offload func */
@@ -2221,7 +2207,7 @@ Signed-off-by: Michael Lee <igvtee@gmail.com>
 + *   GNU General Public License for more details.
 + *
 + *   Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
-+ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
++ *   Copyright (C) 2009-2015 Felix Fietkau <nbd@nbd.name>
 + *   Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
 + */
 +