* [PATCH] net: dsa: ocelot: Add support for QinQ Operation
@ 2020-07-22 5:50 hongbo.wang
2020-07-22 7:45 ` kernel test robot
2020-07-22 19:59 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: hongbo.wang @ 2020-07-22 5:50 UTC (permalink / raw)
To: xiaoliang.yang_1, allan.nielsen, po.liu, claudiu.manoil,
alexandru.marginean, vladimir.oltean, leoyang.li, mingkai.hu,
andrew, f.fainelli, vivien.didelot, davem, jiri, idosch, kuba,
vinicius.gomes, nikolay, roopa, netdev, linux-kernel,
horatiu.vultur, alexandre.belloni, UNGLinuxDriver, linux-devel
Cc: hongbo.wang
From: "hongbo.wang" <hongbo.wang@nxp.com>
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)
Signed-off-by: hongbo.wang <hongbo.wang@nxp.com>
---
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(-)
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index c69d9592a2b7..12b46cb6549c 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -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) {
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index f2d94b026d88..621277e875a5 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -144,6 +144,8 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port,
{
struct ocelot_port *ocelot_port = ocelot->ports[port];
u32 val = 0;
+ u32 tag_tpid = 0;
+ u32 port_tpid = 0;
if (ocelot_port->vid != vid) {
/* Always permit deleting the native VLAN (vid = 0) */
@@ -156,8 +158,14 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port,
ocelot_port->vid = vid;
}
- ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_VID(vid),
- REW_PORT_VLAN_CFG_PORT_VID_M,
+ if (ocelot_port->qinq_mode)
+ port_tpid = REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021AD);
+ else
+ port_tpid = REW_PORT_VLAN_CFG_PORT_TPID(ETH_P_8021Q);
+
+ ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_VID(vid) | port_tpid,
+ REW_PORT_VLAN_CFG_PORT_VID_M |
+ REW_PORT_VLAN_CFG_PORT_TPID_M,
REW_PORT_VLAN_CFG, port);
if (ocelot_port->vlan_aware && !ocelot_port->vid)
@@ -180,12 +188,28 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port,
else
/* Tag all frames */
val = REW_TAG_CFG_TAG_CFG(3);
+
+ if (ocelot_port->qinq_mode)
+ tag_tpid = REW_TAG_CFG_TAG_TPID_CFG(1);
+ else
+ tag_tpid = REW_TAG_CFG_TAG_TPID_CFG(0);
} else {
- /* Port tagging disabled. */
- val = REW_TAG_CFG_TAG_CFG(0);
+ if (ocelot_port->qinq_mode) {
+ if (ocelot_port->vid)
+ val = REW_TAG_CFG_TAG_CFG(1);
+ else
+ val = REW_TAG_CFG_TAG_CFG(3);
+
+ tag_tpid = REW_TAG_CFG_TAG_TPID_CFG(1);
+ } else {
+ /* Port tagging disabled. */
+ val = REW_TAG_CFG_TAG_CFG(0);
+ tag_tpid = REW_TAG_CFG_TAG_TPID_CFG(0);
+ }
}
- ocelot_rmw_gix(ocelot, val,
- REW_TAG_CFG_TAG_CFG_M,
+
+ ocelot_rmw_gix(ocelot, val | tag_tpid,
+ REW_TAG_CFG_TAG_CFG_M | REW_TAG_CFG_TAG_TPID_CFG_M,
REW_TAG_CFG, port);
return 0;
@@ -216,11 +240,15 @@ EXPORT_SYMBOL(ocelot_port_vlan_filtering);
/* Default vlan to clasify for untagged frames (may be zero) */
static void ocelot_port_set_pvid(struct ocelot *ocelot, int port, u16 pvid)
{
+ u32 tag_type = 0;
struct ocelot_port *ocelot_port = ocelot->ports[port];
+ if (ocelot_port->qinq_mode)
+ tag_type = ANA_PORT_VLAN_CFG_VLAN_TAG_TYPE;
+
ocelot_rmw_gix(ocelot,
- ANA_PORT_VLAN_CFG_VLAN_VID(pvid),
- ANA_PORT_VLAN_CFG_VLAN_VID_M,
+ ANA_PORT_VLAN_CFG_VLAN_VID(pvid) | tag_type,
+ ANA_PORT_VLAN_CFG_VLAN_VID_M | tag_type,
ANA_PORT_VLAN_CFG, port);
ocelot_port->pvid = pvid;
diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
index da369b12005f..cc394740078e 100644
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -556,6 +556,7 @@ struct ocelot_port {
struct regmap *target;
bool vlan_aware;
+ bool qinq_mode;
/* Ingress default VLAN (pvid) */
u16 pvid;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: dsa: ocelot: Add support for QinQ Operation
2020-07-22 5:50 [PATCH] net: dsa: ocelot: Add support for QinQ Operation hongbo.wang
@ 2020-07-22 7:45 ` kernel test robot
2020-07-22 19:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-07-22 7:45 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2731 bytes --]
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
Reported-by: kernel test robot <lkp@intel.com>
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
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 64659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: dsa: ocelot: Add support for QinQ Operation
2020-07-22 5:50 [PATCH] net: dsa: ocelot: Add support for QinQ Operation hongbo.wang
2020-07-22 7:45 ` kernel test robot
@ 2020-07-22 19:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-07-22 19:59 UTC (permalink / raw)
To: hongbo.wang
Cc: xiaoliang.yang_1, allan.nielsen, po.liu, claudiu.manoil,
alexandru.marginean, vladimir.oltean, leoyang.li, mingkai.hu,
andrew, f.fainelli, vivien.didelot, jiri, idosch, kuba,
vinicius.gomes, nikolay, roopa, netdev, linux-kernel,
horatiu.vultur, alexandre.belloni, UNGLinuxDriver, linux-devel
From: hongbo.wang@nxp.com
Date: Wed, 22 Jul 2020 13:50:48 +0800
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index c69d9592a2b7..12b46cb6549c 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-22 19:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 5:50 [PATCH] net: dsa: ocelot: Add support for QinQ Operation hongbo.wang
2020-07-22 7:45 ` kernel test robot
2020-07-22 19:59 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.