[OpenWrt-Devel] [PATCH 5/5] lantiq/xrx200-net: change VLAN untagged ports and PVID handling

Martin Schiller mschiller at tdt.de
Thu Feb 18 08:13:16 EST 2016


This patch adds the xrx200sw_set_port_pvid() function and removes the
xrx200sw_fixup_pvids() function and the restriction that a switch port can only
be an untagged member of one VLAN group.

There are situations, where an switch port needs to be a member of multiple
VLAN groups without VLAN tagging enabled, so it's not possible to set the
PVID automatically like the xrx200sw_fixup_pvids() did it before and has to
be specified explicitly.

Signed-off-by: Martin Schiller <mschiller at tdt.de>
---
 .../0025-NET-MIPS-lantiq-adds-xrx200-net.patch     | 76 ++++++++--------------
 1 file changed, 26 insertions(+), 50 deletions(-)

diff --git a/target/linux/lantiq/patches-4.4/0025-NET-MIPS-lantiq-adds-xrx200-net.patch b/target/linux/lantiq/patches-4.4/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
index 9d598a3..b7f4965 100644
--- a/target/linux/lantiq/patches-4.4/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
+++ b/target/linux/lantiq/patches-4.4/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
@@ -209,7 +209,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +};
 --- /dev/null
 +++ b/drivers/net/ethernet/lantiq_xrx200.c
-@@ -0,0 +1,1852 @@
+@@ -0,0 +1,1828 @@
 +/*
 + *   This program is free software; you can redistribute it and/or modify it
 + *   under the terms of the GNU General Public License version 2 as published
@@ -639,48 +639,6 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +	return 0;
 +}
 +
-+static void xrx200sw_fixup_pvids(void)
-+{
-+	int index, p, portmap, untagged;
-+	struct xrx200_pce_table_entry tem;
-+	struct xrx200_pce_table_entry tev;
-+
-+	portmap = 0;
-+	for (p = 0; p < XRX200_MAX_PORT; p++)
-+		portmap |= BIT(p);
-+
-+	tem.table = XRX200_PCE_VLANMAP_IDX;
-+	tev.table = XRX200_PCE_ACTVLAN_IDX;
-+
-+	for (index = XRX200_MAX_VLAN; index-- > 0;)
-+	{
-+		tev.index = index;
-+		xrx200_pce_table_entry_read(&tev);
-+
-+		if (tev.valid == 0)
-+			continue;
-+
-+		tem.index = index;
-+		xrx200_pce_table_entry_read(&tem);
-+
-+		if (tem.val[0] == 0)
-+			continue;
-+
-+		untagged = portmap & (tem.val[1] ^ tem.val[2]);
-+
-+		for (p = 0; p < XRX200_MAX_PORT; p++)
-+			if (untagged & BIT(p))
-+			{
-+				portmap &= ~BIT(p);
-+				xrx200sw_write_x(index, XRX200_PCE_DEFPVID_PVID, p);
-+			}
-+
-+		for (p = 0; p < XRX200_MAX_PORT; p++)
-+			if (portmap & BIT(p))
-+				xrx200sw_write_x(index, XRX200_PCE_DEFPVID_PVID, p);
-+	}
-+}
-+
 +// swconfig interface
 +static void xrx200_hw_init(struct xrx200_hw *hw);
 +
@@ -761,7 +719,6 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +	tem.val[0] = val->value.i;
 +	xrx200_pce_table_entry_write(&tem);
 +
-+	xrx200sw_fixup_pvids();
 +	return 0;
 +}
 +
@@ -833,9 +790,6 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +
 +		if (tem.val[0] == 0)
 +			continue;
-+
-+		if ((untagged & (tem.val[1] ^ tem.val[2])) && (val->port_vlan != i))
-+			return -EINVAL;
 +	}
 +
 +	tem.index = val->port_vlan;
@@ -859,8 +813,6 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +	tem.val[2] = tagmap;
 +	xrx200_pce_table_entry_write(&tem);
 +
-+	xrx200sw_fixup_pvids();
-+
 +	return 0;
 +}
 +
@@ -909,7 +861,6 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +	tev.valid = val->value.i;
 +	xrx200_pce_table_entry_write(&tev);
 +
-+	xrx200sw_fixup_pvids();
 +	return 0;
 +}
 +
@@ -942,6 +893,30 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +	return 0;
 +}
 +
++static int xrx200sw_set_port_pvid(struct switch_dev *dev, int port, int val)
++{
++	int i;
++	struct xrx200_pce_table_entry tev;
++
++	if (port >= XRX200_MAX_PORT)
++		return -EINVAL;
++
++	tev.table = XRX200_PCE_ACTVLAN_IDX;
++
++	for (i = 0; i < XRX200_MAX_VLAN; i++)
++	{
++		tev.index = i;
++		xrx200_pce_table_entry_read(&tev);
++		if (tev.key[0] == val)
++		{
++			xrx200sw_write_x(i, XRX200_PCE_DEFPVID_PVID, port);
++			return 0;
++		}
++	}
++
++	return -EINVAL;
++}
++
 +static int xrx200sw_get_port_link(struct switch_dev *dev,
 +				  int port,
 +				  struct switch_port_link *link)
@@ -1083,6 +1058,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +	.get_vlan_ports = xrx200sw_get_vlan_ports,
 +	.set_vlan_ports = xrx200sw_set_vlan_ports,
 +	.get_port_pvid = xrx200sw_get_port_pvid,
++	.set_port_pvid = xrx200sw_set_port_pvid,
 +	.reset_switch = xrx200sw_reset_switch,
 +	.get_port_link = xrx200sw_get_port_link,
 +//	.get_port_stats = xrx200sw_get_port_stats, //TODO
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list