mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 14:13:16 +00:00
d59d69f9e1
Manually rebased: backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch Removed upstreamed: backport-5.15/060-v6.0-01-tools-build-Add-feature-test-for-init_disassemble_in.patch[1] backport-5.15/060-v6.0-02-tools-include-add-dis-asm-compat.h-to-handle-version.patch[2] backport-5.15/060-v6.0-03-tools-perf-Fix-compilation-error-with-new-binutils.patch[3] backport-5.15/060-v6.0-04-tools-bpf_jit_disasm-Fix-compilation-error-with-new-.patch[4] backport-5.15/060-v6.0-05-tools-bpftool-Fix-compilation-error-with-new-binutil.patch[5] pending-5.15/733-02-net-ethernet-mtk_eth_soc-fix-RX-data-corruption-issu.patch[6] bcm47xx/patches-5.15/170-bgmac-fix-initial-chip-reset-to-support-BCM5358.patch[7] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=51b99dc38c1a053e2e732d7f9e2740e343ae7eae 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=451c9d7b16169645ed291ebb2ca9844caa088f2d 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=97f005c0bdbaf656a7808586d234965385a06c58 4. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=1c27fab243333821375e4d63128d60093fdbe149 5. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=4441a90091931fd81607567961dc122f24f735bb 6. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=2adc29350a5b4669544566f71f208d2abaec60ab 7. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.103&id=04bfc5bcdfc0fdb73587487c71b04d63807ae15a Build system: x86_64 Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia <therealgraysky@proton.me>
193 lines
5.3 KiB
Diff
193 lines
5.3 KiB
Diff
From: Felix Fietkau <nbd@nbd.name>
|
|
Date: Fri, 28 Oct 2022 11:01:12 +0200
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: fix VLAN rx hardware
|
|
acceleration
|
|
|
|
- enable VLAN untagging for PDMA rx
|
|
- make it possible to disable the feature via ethtool
|
|
- pass VLAN tag to the DSA driver
|
|
- untag special tag on PDMA only if no non-DSA devices are in use
|
|
- disable special tag untagging on 7986 for now, since it's not working yet
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
---
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
@@ -23,6 +23,7 @@
|
|
#include <linux/jhash.h>
|
|
#include <linux/bitfield.h>
|
|
#include <net/dsa.h>
|
|
+#include <net/dst_metadata.h>
|
|
|
|
#include "mtk_eth_soc.h"
|
|
#include "mtk_wed.h"
|
|
@@ -1974,16 +1975,22 @@ static int mtk_poll_rx(struct napi_struc
|
|
htons(RX_DMA_VPID(trxd.rxd4)),
|
|
RX_DMA_VID(trxd.rxd4));
|
|
} else if (trxd.rxd2 & RX_DMA_VTAG) {
|
|
- __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
|
|
+ __vlan_hwaccel_put_tag(skb, htons(RX_DMA_VPID(trxd.rxd3)),
|
|
RX_DMA_VID(trxd.rxd3));
|
|
}
|
|
+ }
|
|
+
|
|
+ /* When using VLAN untagging in combination with DSA, the
|
|
+ * hardware treats the MTK special tag as a VLAN and untags it.
|
|
+ */
|
|
+ if (skb_vlan_tag_present(skb) && netdev_uses_dsa(netdev)) {
|
|
+ unsigned int port = ntohs(skb->vlan_proto) & GENMASK(2, 0);
|
|
|
|
- /* If the device is attached to a dsa switch, the special
|
|
- * tag inserted in VLAN field by hw switch can * be offloaded
|
|
- * by RX HW VLAN offload. Clear vlan info.
|
|
- */
|
|
- if (netdev_uses_dsa(netdev))
|
|
- __vlan_hwaccel_clear_tag(skb);
|
|
+ if (port < ARRAY_SIZE(eth->dsa_meta) &&
|
|
+ eth->dsa_meta[port])
|
|
+ skb_dst_set_noref(skb, ð->dsa_meta[port]->dst);
|
|
+
|
|
+ __vlan_hwaccel_clear_tag(skb);
|
|
}
|
|
|
|
skb_record_rx_queue(skb, 0);
|
|
@@ -2800,15 +2807,30 @@ static netdev_features_t mtk_fix_feature
|
|
|
|
static int mtk_set_features(struct net_device *dev, netdev_features_t features)
|
|
{
|
|
- int err = 0;
|
|
+ struct mtk_mac *mac = netdev_priv(dev);
|
|
+ struct mtk_eth *eth = mac->hw;
|
|
+ netdev_features_t diff = dev->features ^ features;
|
|
+ int i;
|
|
+
|
|
+ if ((diff & NETIF_F_LRO) && !(features & NETIF_F_LRO))
|
|
+ mtk_hwlro_netdev_disable(dev);
|
|
|
|
- if (!((dev->features ^ features) & NETIF_F_LRO))
|
|
+ /* Set RX VLAN offloading */
|
|
+ if (!(diff & NETIF_F_HW_VLAN_CTAG_RX))
|
|
return 0;
|
|
|
|
- if (!(features & NETIF_F_LRO))
|
|
- mtk_hwlro_netdev_disable(dev);
|
|
+ mtk_w32(eth, !!(features & NETIF_F_HW_VLAN_CTAG_RX),
|
|
+ MTK_CDMP_EG_CTRL);
|
|
|
|
- return err;
|
|
+ /* sync features with other MAC */
|
|
+ for (i = 0; i < MTK_MAC_COUNT; i++) {
|
|
+ if (!eth->netdev[i] || eth->netdev[i] == dev)
|
|
+ continue;
|
|
+ eth->netdev[i]->features &= ~NETIF_F_HW_VLAN_CTAG_RX;
|
|
+ eth->netdev[i]->features |= features & NETIF_F_HW_VLAN_CTAG_RX;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
}
|
|
|
|
/* wait for DMA to finish whatever it is doing before we start using it again */
|
|
@@ -3105,11 +3127,45 @@ found:
|
|
return NOTIFY_DONE;
|
|
}
|
|
|
|
+static bool mtk_uses_dsa(struct net_device *dev)
|
|
+{
|
|
+#if IS_ENABLED(CONFIG_NET_DSA)
|
|
+ return netdev_uses_dsa(dev) &&
|
|
+ dev->dsa_ptr->tag_ops->proto == DSA_TAG_PROTO_MTK;
|
|
+#else
|
|
+ return false;
|
|
+#endif
|
|
+}
|
|
+
|
|
static int mtk_open(struct net_device *dev)
|
|
{
|
|
struct mtk_mac *mac = netdev_priv(dev);
|
|
struct mtk_eth *eth = mac->hw;
|
|
- int err;
|
|
+ int i, err;
|
|
+
|
|
+ if (mtk_uses_dsa(dev) && !eth->prog) {
|
|
+ for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) {
|
|
+ struct metadata_dst *md_dst = eth->dsa_meta[i];
|
|
+
|
|
+ if (md_dst)
|
|
+ continue;
|
|
+
|
|
+ md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
|
|
+ GFP_KERNEL);
|
|
+ if (!md_dst)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ md_dst->u.port_info.port_id = i;
|
|
+ eth->dsa_meta[i] = md_dst;
|
|
+ }
|
|
+ } else {
|
|
+ /* Hardware special tag parsing needs to be disabled if at least
|
|
+ * one MAC does not use DSA.
|
|
+ */
|
|
+ u32 val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
|
|
+ val &= ~MTK_CDMP_STAG_EN;
|
|
+ mtk_w32(eth, val, MTK_CDMP_IG_CTRL);
|
|
+ }
|
|
|
|
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
|
|
if (err) {
|
|
@@ -3632,6 +3688,10 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
*/
|
|
val = mtk_r32(eth, MTK_CDMQ_IG_CTRL);
|
|
mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL);
|
|
+ if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
|
|
+ val = mtk_r32(eth, MTK_CDMP_IG_CTRL);
|
|
+ mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL);
|
|
+ }
|
|
|
|
/* Enable RX VLan Offloading */
|
|
mtk_w32(eth, 1, MTK_CDMP_EG_CTRL);
|
|
@@ -3865,6 +3925,12 @@ static int mtk_free_dev(struct mtk_eth *
|
|
free_netdev(eth->netdev[i]);
|
|
}
|
|
|
|
+ for (i = 0; i < ARRAY_SIZE(eth->dsa_meta); i++) {
|
|
+ if (!eth->dsa_meta[i])
|
|
+ break;
|
|
+ metadata_dst_free(eth->dsa_meta[i]);
|
|
+ }
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
@@ -22,6 +22,9 @@
|
|
#include <linux/bpf_trace.h>
|
|
#include "mtk_ppe.h"
|
|
|
|
+#define MTK_MAX_DSA_PORTS 7
|
|
+#define MTK_DSA_PORT_MASK GENMASK(2, 0)
|
|
+
|
|
#define MTK_QDMA_NUM_QUEUES 16
|
|
#define MTK_QDMA_PAGE_SIZE 2048
|
|
#define MTK_MAX_RX_LENGTH 1536
|
|
@@ -105,6 +108,9 @@
|
|
#define MTK_CDMQ_IG_CTRL 0x1400
|
|
#define MTK_CDMQ_STAG_EN BIT(0)
|
|
|
|
+/* CDMQ Exgress Control Register */
|
|
+#define MTK_CDMQ_EG_CTRL 0x1404
|
|
+
|
|
/* CDMP Ingress Control Register */
|
|
#define MTK_CDMP_IG_CTRL 0x400
|
|
#define MTK_CDMP_STAG_EN BIT(0)
|
|
@@ -1166,6 +1172,8 @@ struct mtk_eth {
|
|
|
|
int ip_align;
|
|
|
|
+ struct metadata_dst *dsa_meta[MTK_MAX_DSA_PORTS];
|
|
+
|
|
struct mtk_ppe *ppe[2];
|
|
struct rhashtable flow_table;
|
|
|