[openwrt/openwrt] ramips: fix reporting effective VLAN ID on MT7621 switches

LEDE Commits lede-commits at lists.infradead.org
Wed Feb 14 07:43:40 PST 2018


jow pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/dc7a1e855513d415ac0837b34400b98052c2090c

commit dc7a1e855513d415ac0837b34400b98052c2090c
Author: Jo-Philipp Wich <jo at mein.io>
AuthorDate: Tue Feb 13 15:58:48 2018 +0100

    ramips: fix reporting effective VLAN ID on MT7621 switches
    
    On MT7621, the REG_ESW_VLAN_VTIM reads are undefined, causing swconfig
    to always report `vid: 0` in swconfig show output.
    
    Since a 4K VLAN table is used on this platform, the VLAN ID always
    correponds to the actual VLAN table index so provide a specific MT7621
    implementation of the get_vid callback which returns the table index
    as VLAN ID.
    
    Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
 .../files-4.9/drivers/net/ethernet/mtk/mt7530.c    | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c b/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
index 21f8926..5216cb5 100644
--- a/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
+++ b/target/linux/ramips/files-4.9/drivers/net/ethernet/mtk/mt7530.c
@@ -479,6 +479,14 @@ mt7530_set_vid(struct switch_dev *dev, const struct switch_attr *attr,
 }
 
 static int
+mt7621_get_vid(struct switch_dev *dev, const struct switch_attr *attr,
+		struct switch_val *val)
+{
+	val->value.i = val->port_vlan;
+	return 0;
+}
+
+static int
 mt7530_get_vid(struct switch_dev *dev, const struct switch_attr *attr,
 		struct switch_val *val)
 {
@@ -835,6 +843,17 @@ static const struct switch_attr mt7621_port[] = {
 	},
 };
 
+static const struct switch_attr mt7621_vlan[] = {
+	{
+		.type = SWITCH_TYPE_INT,
+		.name = "vid",
+		.description = "VLAN ID (0-4094)",
+		.set = mt7530_set_vid,
+		.get = mt7621_get_vid,
+		.max = 4094,
+	},
+};
+
 static const struct switch_attr mt7530_port[] = {
 	{
 		.type = SWITCH_TYPE_STRING,
@@ -866,8 +885,8 @@ static const struct switch_dev_ops mt7621_ops = {
 		.n_attr = ARRAY_SIZE(mt7621_port),
 	},
 	.attr_vlan = {
-		.attr = mt7530_vlan,
-		.n_attr = ARRAY_SIZE(mt7530_vlan),
+		.attr = mt7621_vlan,
+		.n_attr = ARRAY_SIZE(mt7621_vlan),
 	},
 	.get_vlan_ports = mt7530_get_vlan_ports,
 	.set_vlan_ports = mt7530_set_vlan_ports,



More information about the lede-commits mailing list