Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pgaskin/ee4a49f0376cf1b93f072322bf05c2ea to your computer and use it in GitHub Desktop.

Select an option

Save pgaskin/ee4a49f0376cf1b93f072322bf05c2ea to your computer and use it in GitHub Desktop.
Get rid of the forced vlan 1/2 tagging and split eth0/1 on the hAP ac2.
From 632be27eefda4638bcecd6068c3553f8f64ce4c8 Mon Sep 17 00:00:00 2001
From: Patrick Gaskin <patrick@pgaskin.net>
Date: Mon, 25 Apr 2022 03:08:05 -0400
Subject: [PATCH] ipq40xx: essedma: disable default vlan tagging for the
Mikrotik hAP ac2
This removes the separate WAN gmac eth1 and fixes VLAN tagging.
---
target/linux/ipq40xx/base-files/etc/board.d/02_network | 5 ++++-
.../files/arch/arm/boot/dts/qcom-ipq4018-hap-ac2.dts | 6 ++++++
.../files/drivers/net/ethernet/qualcomm/essedma/edma.c | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network
index 2aa4886e6a57..e4febddf74f4 100644
--- a/target/linux/ipq40xx/base-files/etc/board.d/02_network
+++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network
@@ -56,7 +56,6 @@ ipq40xx_setup_interfaces()
;;
asus,rt-ac42u|\
asus,rt-ac58u|\
- mikrotik,hap-ac2|\
mikrotik,hap-ac3|\
p2w,r619ac-64m|\
p2w,r619ac-128m|\
@@ -65,6 +64,10 @@ ipq40xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
;;
+ mikrotik,hap-ac2)
+ ucidef_add_switch "switch0" \
+ "0t@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
+ ;;
avm,fritzbox-4040|\
linksys,ea6350v3|\
linksys,ea8300)
diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-hap-ac2.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-hap-ac2.dts
index d03409b556ef..6f30d67019ad 100644
--- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-hap-ac2.dts
+++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4018-hap-ac2.dts
@@ -85,6 +85,8 @@
edma@c080000 {
status = "okay";
+ qcom,poll_required = <0>;
+ qcom,num_gmac = <1>;
};
};
@@ -271,3 +273,7 @@
qcom,ath10k-calibration-variant = "MikroTik-hAP-ac2";
};
+
+&gmac0 {
+ vlan_tag = <0 0x3f>;
+};
diff --git a/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.c b/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.c
index 80db1f0acbe4..43ec5482ee18 100644
--- a/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.c
+++ b/target/linux/ipq40xx/files/drivers/net/ethernet/qualcomm/essedma/edma.c
@@ -727,7 +727,7 @@ static u16 edma_rx_complete(struct edma_common_info *edma_cinfo,
edma_receive_checksum(rd, skb);
/* Process VLAN HW acceleration indication provided by HW */
- if (unlikely(adapter->default_vlan_tag != rd->rrd4)) {
+ if (likely(adapter->default_vlan_tag != rd->rrd4)) {
vlan = rd->rrd4;
if (likely(rd->rrd7 & EDMA_RRD_CVLAN))
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan);
From 50b8cb372ec27edd11c9877eaef4aa21764c0628 Mon Sep 17 00:00:00 2001
From: Patrick Gaskin <patrick@pgaskin.net>
Date: Mon, 25 Apr 2022 20:41:18 -0400
Subject: [PATCH] ipq40xx: ar40xx: HACK: isolate LAN ports at switch
initialization
This prevents leakage between LAN ports between the point when the
switch initializes and when OpenWrt configures the VLANs (~30s).
Each LAN port is assigned a consecutive VLAN, skipping the WAN one
(i.e., 1, 3, 4, 5, 6).
---
.../ipq40xx/files-5.10/drivers/net/mdio/ar40xx.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/target/linux/ipq40xx/files-5.10/drivers/net/mdio/ar40xx.c b/target/linux/ipq40xx/files-5.10/drivers/net/mdio/ar40xx.c
index f7ce42b9ff0a..4d88317c724d 100644
--- a/target/linux/ipq40xx/files-5.10/drivers/net/mdio/ar40xx.c
+++ b/target/linux/ipq40xx/files-5.10/drivers/net/mdio/ar40xx.c
@@ -1478,16 +1478,24 @@ static int
ar40xx_vlan_init(struct ar40xx_priv *priv)
{
int port;
+ int tmp;
unsigned long bmp;
/* By default Enable VLAN */
priv->vlan = 1;
- priv->vlan_table[AR40XX_LAN_VLAN] = priv->cpu_bmp | priv->lan_bmp;
+ priv->vlan_table[AR40XX_LAN_VLAN] = priv->cpu_bmp;
priv->vlan_table[AR40XX_WAN_VLAN] = priv->cpu_bmp | priv->wan_bmp;
priv->vlan_tagged = priv->cpu_bmp;
+
+ /* HACK: Isolate the LAN ports by default by assigning them consecutive VLANs (skipping the WAN VLAN) */
+ tmp = AR40XX_LAN_VLAN;
bmp = priv->lan_bmp;
- for_each_set_bit(port, &bmp, AR40XX_NUM_PORTS)
- priv->pvid[port] = AR40XX_LAN_VLAN;
+ for_each_set_bit(port, &bmp, AR40XX_NUM_PORTS) {
+ priv->vlan_table[tmp] = priv->cpu_bmp | (1 << port);
+ priv->pvid[port] = tmp;
+ if (++tmp == AR40XX_WAN_VLAN)
+ ++tmp;
+ }
bmp = priv->wan_bmp;
for_each_set_bit(port, &bmp, AR40XX_NUM_PORTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment