[PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

Subsystems: networking drivers, networking [dsa], the rest

STALE1775d

6 messages, 4 authors, 2021-10-02 · open the first message on its own page

[PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: 2021-09-22 14:44:20

Now that the sja1105 driver is finally sane enough again to stop having
a ternary VLAN awareness state, we can remove priv->vlan_aware and query
DSA for the ds->vlan_filtering value (for SJA1105, VLAN filtering is a
global property).

Also drop the paranoid checking that DSA calls ->port_vlan_filtering
multiple times without the VLAN awareness state changing. It doesn't,
the same check is present inside dsa_port_vlan_filtering too.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/dsa/sja1105/sja1105.h      |  1 -
 drivers/net/dsa/sja1105/sja1105_main.c |  9 ++-------
 drivers/net/dsa/sja1105/sja1105_vl.c   | 13 +++++++++----
 3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h
index 5e5d24e7c02b..b83a5114348c 100644
--- a/drivers/net/dsa/sja1105/sja1105.h
+++ b/drivers/net/dsa/sja1105/sja1105.h
@@ -226,7 +226,6 @@ struct sja1105_private {
 	bool rgmii_tx_delay[SJA1105_MAX_NUM_PORTS];
 	phy_interface_t phy_mode[SJA1105_MAX_NUM_PORTS];
 	bool fixed_link[SJA1105_MAX_NUM_PORTS];
-	bool vlan_aware;
 	unsigned long ucast_egress_floods;
 	unsigned long bcast_egress_floods;
 	const struct sja1105_info *info;
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 181d814bd4e7..4d2114449cd6 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -1802,7 +1802,7 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
 		u64_to_ether_addr(l2_lookup.macaddr, macaddr);
 
 		/* We need to hide the dsa_8021q VLANs from the user. */
-		if (!priv->vlan_aware)
+		if (!dsa_port_is_vlan_filtering(ds, port))
 			l2_lookup.vlanid = 0;
 		rc = cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data);
 		if (rc)
@@ -2295,11 +2295,6 @@ int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
 		tpid2 = ETH_P_SJA1105;
 	}
 
-	if (priv->vlan_aware == enabled)
-		return 0;
-
-	priv->vlan_aware = enabled;
-
 	table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];
 	general_params = table->entries;
 	/* EtherType used to identify inner tagged (C-tag) VLAN traffic */
@@ -2332,7 +2327,7 @@ int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled,
 	 */
 	table = &priv->static_config.tables[BLK_IDX_L2_LOOKUP_PARAMS];
 	l2_lookup_params = table->entries;
-	l2_lookup_params->shared_learn = !priv->vlan_aware;
+	l2_lookup_params->shared_learn = !enabled;
 
 	for (port = 0; port < ds->num_ports; port++) {
 		if (dsa_is_unused_port(ds, port))
diff --git a/drivers/net/dsa/sja1105/sja1105_vl.c b/drivers/net/dsa/sja1105/sja1105_vl.c
index ec7b65daec20..0f77ec78094b 100644
--- a/drivers/net/dsa/sja1105/sja1105_vl.c
+++ b/drivers/net/dsa/sja1105/sja1105_vl.c
@@ -494,13 +494,16 @@ int sja1105_vl_redirect(struct sja1105_private *priv, int port,
 			bool append)
 {
 	struct sja1105_rule *rule = sja1105_rule_find(priv, cookie);
+	struct dsa_switch *ds = priv->ds;
 	int rc;
 
-	if (!priv->vlan_aware && key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
+	if (!dsa_port_is_vlan_filtering(ds, port) &&
+	    key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
 		NL_SET_ERR_MSG_MOD(extack,
 				   "Can only redirect based on DMAC");
 		return -EOPNOTSUPP;
-	} else if (priv->vlan_aware && key->type != SJA1105_KEY_VLAN_AWARE_VL) {
+	} else if (dsa_port_is_vlan_filtering(ds, port) &&
+		   key->type != SJA1105_KEY_VLAN_AWARE_VL) {
 		NL_SET_ERR_MSG_MOD(extack,
 				   "Can only redirect based on {DMAC, VID, PCP}");
 		return -EOPNOTSUPP;
@@ -592,11 +595,13 @@ int sja1105_vl_gate(struct sja1105_private *priv, int port,
 		return -ERANGE;
 	}
 
-	if (!priv->vlan_aware && key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
+	if (!dsa_port_is_vlan_filtering(ds, port) &&
+	    key->type != SJA1105_KEY_VLAN_UNAWARE_VL) {
 		NL_SET_ERR_MSG_MOD(extack,
 				   "Can only gate based on DMAC");
 		return -EOPNOTSUPP;
-	} else if (priv->vlan_aware && key->type != SJA1105_KEY_VLAN_AWARE_VL) {
+	} else if (dsa_port_is_vlan_filtering(ds, port) &&
+		   key->type != SJA1105_KEY_VLAN_AWARE_VL) {
 		NL_SET_ERR_MSG_MOD(extack,
 				   "Can only gate based on {DMAC, VID, PCP}");
 		return -EOPNOTSUPP;
-- 
2.25.1

Re: [PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2021-09-22 16:10:09

On 9/22/21 7:44 AM, Vladimir Oltean wrote:
Now that the sja1105 driver is finally sane enough again to stop having
a ternary VLAN awareness state, we can remove priv->vlan_aware and query
DSA for the ds->vlan_filtering value (for SJA1105, VLAN filtering is a
global property).

Also drop the paranoid checking that DSA calls ->port_vlan_filtering
multiple times without the VLAN awareness state changing. It doesn't,
the same check is present inside dsa_port_vlan_filtering too.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

Re: [PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

From: Vladimir Oltean <olteanv@gmail.com>
Date: 2021-09-22 16:24:50

On Wed, Sep 22, 2021 at 05:44:01PM +0300, Vladimir Oltean wrote:
+	if (!dsa_port_is_vlan_filtering(ds, port) &&
omg, what did I just send....
I amended the commit a few times but forgot to format-patch it again.
The dsa_port_is_vlan_filtering prototype takes a "dp" argument, this
patch doesn't even build. Please toss it to the bin where it belongs.

Re: [PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

From: Vladimir Oltean <olteanv@gmail.com>
Date: 2021-09-22 18:38:44

On Wed, Sep 22, 2021 at 07:24:43PM +0300, Vladimir Oltean wrote:
On Wed, Sep 22, 2021 at 05:44:01PM +0300, Vladimir Oltean wrote:
quoted
+	if (!dsa_port_is_vlan_filtering(ds, port) &&
omg, what did I just send....
I amended the commit a few times but forgot to format-patch it again.
The dsa_port_is_vlan_filtering prototype takes a "dp" argument, this
patch doesn't even build. Please toss it to the bin where it belongs.
Superseded by v2 which has message ID 20210922183655.2680551-1-vladimir.oltean@nxp.com
Florian, please note that I did not preserve your Reviewed-by tag, due
to the patch looking fairly differently now.

Re: [PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2021-09-22 18:40:29

On 9/22/21 11:38 AM, Vladimir Oltean wrote:
On Wed, Sep 22, 2021 at 07:24:43PM +0300, Vladimir Oltean wrote:
quoted
On Wed, Sep 22, 2021 at 05:44:01PM +0300, Vladimir Oltean wrote:
quoted
+	if (!dsa_port_is_vlan_filtering(ds, port) &&
omg, what did I just send....
I amended the commit a few times but forgot to format-patch it again.
The dsa_port_is_vlan_filtering prototype takes a "dp" argument, this
patch doesn't even build. Please toss it to the bin where it belongs.
Superseded by v2 which has message ID 20210922183655.2680551-1-vladimir.oltean@nxp.com
Florian, please note that I did not preserve your Reviewed-by tag, due
to the patch looking fairly differently now.
Yes I completely missed that argument misuse, the changes look logically
correct, too quick in reviewing I guess :)
-- 
Florian

Re: [PATCH net-next] net: dsa: sja1105: stop using priv->vlan_aware

From: kernel test robot <hidden>
Date: 2021-10-02 04:29:13

Hi Vladimir,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on horms-ipvs/master linus/master v5.15-rc3 next-20210922]
[cannot apply to net-next/master]
[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/Vladimir-Oltean/net-dsa-sja1105-stop-using-priv-vlan_aware/20210929-173132
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git f936bb42aeb94a069bec7c9e04100d199c372956
config: nios2-allyesconfig (attached as .config)
compiler: nios2-linux-gcc (GCC) 11.2.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
        # https://github.com/0day-ci/linux/commit/a2bec1580b66ebe935cb356f0eb9ceda834a14ab
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Vladimir-Oltean/net-dsa-sja1105-stop-using-priv-vlan_aware/20210929-173132
        git checkout a2bec1580b66ebe935cb356f0eb9ceda834a14ab
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=nios2 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>

All errors (new ones prefixed by >>):

   drivers/net/dsa/sja1105/sja1105_main.c: In function 'sja1105_fdb_dump':
quoted
drivers/net/dsa/sja1105/sja1105_main.c:1805:49: error: passing argument 1 of 'dsa_port_is_vlan_filtering' from incompatible pointer type [-Werror=incompatible-pointer-types]
    1805 |                 if (!dsa_port_is_vlan_filtering(ds, port))
         |                                                 ^~
         |                                                 |
         |                                                 struct dsa_switch *
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_main.c:25:
   include/net/dsa.h:548:70: note: expected 'const struct dsa_port *' but argument is of type 'struct dsa_switch *'
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~
quoted
drivers/net/dsa/sja1105/sja1105_main.c:1805:22: error: too many arguments to function 'dsa_port_is_vlan_filtering'
    1805 |                 if (!dsa_port_is_vlan_filtering(ds, port))
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_main.c:25:
   include/net/dsa.h:548:20: note: declared here
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
   drivers/net/dsa/sja1105/sja1105_vl.c: In function 'sja1105_vl_redirect':
quoted
drivers/net/dsa/sja1105/sja1105_vl.c:500:41: error: passing argument 1 of 'dsa_port_is_vlan_filtering' from incompatible pointer type [-Werror=incompatible-pointer-types]
     500 |         if (!dsa_port_is_vlan_filtering(ds, port) &&
         |                                         ^~
         |                                         |
         |                                         struct dsa_switch *
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_vl.h:7,
                    from drivers/net/dsa/sja1105/sja1105_vl.c:6:
   include/net/dsa.h:548:70: note: expected 'const struct dsa_port *' but argument is of type 'struct dsa_switch *'
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~
quoted
drivers/net/dsa/sja1105/sja1105_vl.c:500:14: error: too many arguments to function 'dsa_port_is_vlan_filtering'
     500 |         if (!dsa_port_is_vlan_filtering(ds, port) &&
         |              ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_vl.h:7,
                    from drivers/net/dsa/sja1105/sja1105_vl.c:6:
   include/net/dsa.h:548:20: note: declared here
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/sja1105/sja1105_vl.c:505:47: error: passing argument 1 of 'dsa_port_is_vlan_filtering' from incompatible pointer type [-Werror=incompatible-pointer-types]
     505 |         } else if (dsa_port_is_vlan_filtering(ds, port) &&
         |                                               ^~
         |                                               |
         |                                               struct dsa_switch *
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_vl.h:7,
                    from drivers/net/dsa/sja1105/sja1105_vl.c:6:
   include/net/dsa.h:548:70: note: expected 'const struct dsa_port *' but argument is of type 'struct dsa_switch *'
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                                               ~~~~~~~~~~~~~~~~~~~~~~~^~
   drivers/net/dsa/sja1105/sja1105_vl.c:505:20: error: too many arguments to function 'dsa_port_is_vlan_filtering'
     505 |         } else if (dsa_port_is_vlan_filtering(ds, port) &&
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_vl.h:7,
                    from drivers/net/dsa/sja1105/sja1105_vl.c:6:
   include/net/dsa.h:548:20: note: declared here
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/sja1105/sja1105_vl.c: In function 'sja1105_vl_gate':
quoted
drivers/net/dsa/sja1105/sja1105_vl.c:598:41: error: 'ds' undeclared (first use in this function)
     598 |         if (!dsa_port_is_vlan_filtering(ds, port) &&
         |                                         ^~
   drivers/net/dsa/sja1105/sja1105_vl.c:598:41: note: each undeclared identifier is reported only once for each function it appears in
   drivers/net/dsa/sja1105/sja1105_vl.c:598:14: error: too many arguments to function 'dsa_port_is_vlan_filtering'
     598 |         if (!dsa_port_is_vlan_filtering(ds, port) &&
         |              ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_vl.h:7,
                    from drivers/net/dsa/sja1105/sja1105_vl.c:6:
   include/net/dsa.h:548:20: note: declared here
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/dsa/sja1105/sja1105_vl.c:603:20: error: too many arguments to function 'dsa_port_is_vlan_filtering'
     603 |         } else if (dsa_port_is_vlan_filtering(ds, port) &&
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/dsa/sja1105.h:13,
                    from drivers/net/dsa/sja1105/sja1105.h:10,
                    from drivers/net/dsa/sja1105/sja1105_vl.h:7,
                    from drivers/net/dsa/sja1105/sja1105_vl.c:6:
   include/net/dsa.h:548:20: note: declared here
     548 | static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors


vim +/dsa_port_is_vlan_filtering +1805 drivers/net/dsa/sja1105/sja1105_main.c

  1765	
  1766	static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
  1767				    dsa_fdb_dump_cb_t *cb, void *data)
  1768	{
  1769		struct sja1105_private *priv = ds->priv;
  1770		struct device *dev = ds->dev;
  1771		int i;
  1772	
  1773		for (i = 0; i < SJA1105_MAX_L2_LOOKUP_COUNT; i++) {
  1774			struct sja1105_l2_lookup_entry l2_lookup = {0};
  1775			u8 macaddr[ETH_ALEN];
  1776			int rc;
  1777	
  1778			rc = sja1105_dynamic_config_read(priv, BLK_IDX_L2_LOOKUP,
  1779							 i, &l2_lookup);
  1780			/* No fdb entry at i, not an issue */
  1781			if (rc == -ENOENT)
  1782				continue;
  1783			if (rc) {
  1784				dev_err(dev, "Failed to dump FDB: %d\n", rc);
  1785				return rc;
  1786			}
  1787	
  1788			/* FDB dump callback is per port. This means we have to
  1789			 * disregard a valid entry if it's not for this port, even if
  1790			 * only to revisit it later. This is inefficient because the
  1791			 * 1024-sized FDB table needs to be traversed 4 times through
  1792			 * SPI during a 'bridge fdb show' command.
  1793			 */
  1794			if (!(l2_lookup.destports & BIT(port)))
  1795				continue;
  1796	
  1797			/* We need to hide the FDB entry for unknown multicast */
  1798			if (l2_lookup.macaddr == SJA1105_UNKNOWN_MULTICAST &&
  1799			    l2_lookup.mask_macaddr == SJA1105_UNKNOWN_MULTICAST)
  1800				continue;
  1801	
  1802			u64_to_ether_addr(l2_lookup.macaddr, macaddr);
  1803	
  1804			/* We need to hide the dsa_8021q VLANs from the user. */
1805			if (!dsa_port_is_vlan_filtering(ds, port))
  1806				l2_lookup.vlanid = 0;
  1807			rc = cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data);
  1808			if (rc)
  1809				return rc;
  1810		}
  1811		return 0;
  1812	}
  1813	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help