Skip to contentSkip to conversation

net: dsa: ocelot: Add support for QinQ Operation

PATCH In review [email protected] 3 participants 3 messages Jul 22, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: ocelot: Add support for QinQ Operation

From: "hongbo.wang" <[email protected]>

This featue can be test using network test tools

    TX-tool -----> swp0  -----> swp1 -----> RX-tool

TX-tool simulates Customer that will send and receive packets with single VLAN tag(CTAG), RX-tool simulates Service-Provider that will send and receive packets with double VLAN tag(STAG and CTAG). This refers to "4.3.3 Provider Bridges and Q-in-Q Operation" in VSC99599_1_00_TS.pdf.

The related test commands:
1.
ip link add dev br0 type bridge
ip link set dev swp0 master br0
ip link set dev swp1 master br0
2.
ip link add link swp0 name swp0.111 type vlan id 111
ip link add link swp1 name swp1.111 type vlan protocol 802.1ad id 111 3.
bridge vlan add dev swp0 vid 100 pvid
bridge vlan add dev swp1 vid 100
bridge vlan del dev swp1 vid 1 pvid
bridge vlan add dev swp1 vid 200 pvid untagged
Result:

Customer(tpid:8100 vid:111) -> swp0 -> swp1 -> Service-Provider(STAG \
                    tpid:88A8 vid:100, CTAG tpid:8100 vid:111)
---
 drivers/net/dsa/ocelot/felix.c     |  8 ++++++
 drivers/net/ethernet/mscc/ocelot.c | 44 ++++++++++++++++++++++++------
 include/soc/mscc/ocelot.h          |  1 +
 3 files changed, 45 insertions(+), 8 deletions(-)
drivers/net/dsa/ocelot/felix.c +8 -0
index c69d9592a2b7..12b46cb6549c 100644
@@ -132,9 +132,13 @@ static void felix_vlan_add(struct dsa_switch *ds, int port,
 {
 	struct ocelot *ocelot = ds->priv;
 	u16 flags = vlan->flags;
+	struct ocelot_port *ocelot_port = ocelot->ports[port];
 	u16 vid;
 	int err;
 
+	if (vlan->proto == ETH_P_8021AD)
+		ocelot_port->qinq_mode = true;
+
 	if (dsa_is_cpu_port(ds, port))
 		flags &= ~BRIDGE_VLAN_INFO_UNTAGGED;
 
@@ -154,9 +158,13 @@ static int felix_vlan_del(struct dsa_switch *ds, int port,
 			  const struct switchdev_obj_port_vlan *vlan)
 {
 	struct ocelot *ocelot = ds->priv;
+	struct ocelot_port *ocelot_port = ocelot->ports[port];
 	u16 vid;
 	int err;
 
+	if (vlan->proto == ETH_P_8021AD)
+		ocelot_port->qinq_mode = false;
+
 	for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
 		err = ocelot_vlan_del(ocelot, port, vid);
 		if (err) {
drivers/net/ethernet/mscc/ocelot.c +36 -8

73 lines not on this page · raw message

include/soc/mscc/ocelot.h +1 -0
index da369b12005f..cc394740078e 100644
@@ -556,6 +556,7 @@ struct ocelot_port {
 	struct regmap			*target;
 
 	bool				vlan_aware;
+	bool				qinq_mode;
 
 	/* Ingress default VLAN (pvid) */
 	u16				pvid;
Signature · 1 line
2.17.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200721]
[also build test ERROR on v5.8-rc6]
[cannot apply to linus/master v5.8-rc6 v5.8-rc5 v5.8-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/hongbo-wang-nxp-com/net-dsa-ocelot-Add-support-for-QinQ-Operation/20200722-134907
base:    de2e69cfe54a8f2ed4b75f09d3110c514f45d38e
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/net/dsa/ocelot/felix.c: In function 'felix_vlan_add':

>> drivers/net/dsa/ocelot/felix.c:139:10: error: 'const struct switchdev_obj_port_vlan' has no member named 'proto'
     139 |  if (vlan->proto == ETH_P_8021AD)
         |          ^~
   drivers/net/dsa/ocelot/felix.c: In function 'felix_vlan_del':
   drivers/net/dsa/ocelot/felix.c:165:10: error: 'const struct switchdev_obj_port_vlan' has no member named 'proto'
     165 |  if (vlan->proto == ETH_P_8021AD)
         |          ^~

vim +139 drivers/net/dsa/ocelot/felix.c

129
130 static void felix_vlan_add(struct dsa_switch *ds, int port,
131 const struct switchdev_obj_port_vlan *vlan)
132 {
133 struct ocelot *ocelot = ds->priv;
134 u16 flags = vlan->flags;
135 struct ocelot_port *ocelot_port = ocelot->ports[port];
136 u16 vid;
137 int err;
138

 > 139		if (vlan->proto == ETH_P_8021AD)

140 ocelot_port->qinq_mode = true;
141
142 if (dsa_is_cpu_port(ds, port))
143 flags &= ~BRIDGE_VLAN_INFO_UNTAGGED;
144
145 for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
146 err = ocelot_vlan_add(ocelot, port, vid,
147 flags & BRIDGE_VLAN_INFO_PVID,
148 flags & BRIDGE_VLAN_INFO_UNTAGGED);
149 if (err) {
150 dev_err(ds->dev, "Failed to add VLAN %d to port %d: %d\n",
151 vid, port, err);
152 return;
153 }
154 }
155 }
156

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#2 lore raw
In reply to [email protected]

From: [email protected]
Date: Wed, 22 Jul 2020 13:50:48 +0800

drivers/net/dsa/ocelot/felix.c static void felix_vlan_add(struct dsa_switch *ds, int port, · line 137

Quoted 11 lines
drivers/net/dsa/ocelot/felix.c +1 -0
index c69d9592a2b7..12b46cb6549c 100644
@@ -132,9 +132,13 @@ static void felix_vlan_add(struct dsa_switch *ds, int port,
 {
 	struct ocelot *ocelot = ds->priv;
 	u16 flags = vlan->flags;
+	struct ocelot_port *ocelot_port = ocelot->ports[port];
 	u16 vid;
 	int err;

Please use reverse christmas tree ordering for local variables.