diff mbox series

[v7,net-next,8/9] net: dsa: mv88e6xxx: add blackhole ATU entries

Message ID 20221009174052.1927483-9-netdev@kapio-technology.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Extend locked port feature with FDB locked flag (MAC-Auth/MAB) | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 0 this patch: 4
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang fail Errors and warnings before: 0 this patch: 3
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 4
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns WARNING: line length of 90 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Hans Schultz Oct. 9, 2022, 5:40 p.m. UTC
Blackhole FDB entries can now be added, deleted or replaced in the
driver ATU.

Signed-off-by: Hans J. Schultz <netdev@kapio-technology.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 60 +++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)

Comments

kernel test robot Oct. 10, 2022, 7:45 a.m. UTC | #1
Hi Hans,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Hans-J-Schultz/Extend-locked-port-feature-with-FDB-locked-flag-MAC-Auth-MAB/20221010-125833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 0326074ff4652329f2a1a9c8685104576bd8d131
config: parisc-randconfig-r004-20221010
compiler: hppa-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/bceb3d02ac2eb92d0fd72b1ce4ed17dbe407c086
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Hans-J-Schultz/Extend-locked-port-feature-with-FDB-locked-flag-MAC-Auth-MAB/20221010-125833
        git checkout bceb3d02ac2eb92d0fd72b1ce4ed17dbe407c086
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/net/dsa/mv88e6xxx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/dsa/mv88e6xxx/chip.c:2776:5: warning: no previous prototype for 'mv88e6xxx_blackhole_fdb_add' [-Wmissing-prototypes]
    2776 | int mv88e6xxx_blackhole_fdb_add(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/dsa/mv88e6xxx/chip.c:2782:5: warning: no previous prototype for 'mv88e6xxx_blackhole_fdb_del' [-Wmissing-prototypes]
    2782 | int mv88e6xxx_blackhole_fdb_del(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/mv88e6xxx_blackhole_fdb_add +2776 drivers/net/dsa/mv88e6xxx/chip.c

  2775	
> 2776	int mv88e6xxx_blackhole_fdb_add(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
  2777	{
  2778		return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid,
  2779							 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
  2780	}
  2781	
> 2782	int mv88e6xxx_blackhole_fdb_del(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
  2783	{
  2784		return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid,
  2785							 MV88E6XXX_G1_ATU_DATA_STATE_UC_UNUSED);
  2786	}
  2787
kernel test robot Oct. 10, 2022, 12:54 p.m. UTC | #2
Hi Hans,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Hans-J-Schultz/Extend-locked-port-feature-with-FDB-locked-flag-MAC-Auth-MAB/20221010-125833
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 0326074ff4652329f2a1a9c8685104576bd8d131
config: x86_64-randconfig-s032-20221010
compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/bceb3d02ac2eb92d0fd72b1ce4ed17dbe407c086
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Hans-J-Schultz/Extend-locked-port-feature-with-FDB-locked-flag-MAC-Auth-MAB/20221010-125833
        git checkout bceb3d02ac2eb92d0fd72b1ce4ed17dbe407c086
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/dsa/mv88e6xxx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/net/dsa/mv88e6xxx/chip.c:2776:5: sparse: sparse: symbol 'mv88e6xxx_blackhole_fdb_add' was not declared. Should it be static?
>> drivers/net/dsa/mv88e6xxx/chip.c:2782:5: sparse: sparse: symbol 'mv88e6xxx_blackhole_fdb_del' was not declared. Should it be static?
Hans Schultz Oct. 10, 2022, 1:59 p.m. UTC | #3
On 2022-10-10 14:54, kernel test robot wrote:
> Hi Hans,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on net-next/master]
> 
> url:
> https://github.com/intel-lab-lkp/linux/commits/Hans-J-Schultz/Extend-locked-port-feature-with-FDB-locked-flag-MAC-Auth-MAB/20221010-125833
> base:
> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
> 0326074ff4652329f2a1a9c8685104576bd8d131
> config: x86_64-randconfig-s032-20221010
> compiler: gcc-11 (Debian 11.3.0-5) 11.3.0
> reproduce:
>         # apt-get install sparse
>         # sparse version: v0.6.4-39-gce1a6720-dirty
>         #
> https://github.com/intel-lab-lkp/linux/commit/bceb3d02ac2eb92d0fd72b1ce4ed17dbe407c086
>         git remote add linux-review 
> https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review
> Hans-J-Schultz/Extend-locked-port-feature-with-FDB-locked-flag-MAC-Auth-MAB/20221010-125833
>         git checkout bceb3d02ac2eb92d0fd72b1ce4ed17dbe407c086
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
> O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/net/dsa/mv88e6xxx/
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> 
> sparse warnings: (new ones prefixed by >>)
>>> drivers/net/dsa/mv88e6xxx/chip.c:2776:5: sparse: sparse: symbol 
>>> 'mv88e6xxx_blackhole_fdb_add' was not declared. Should it be static?
>>> drivers/net/dsa/mv88e6xxx/chip.c:2782:5: sparse: sparse: symbol 
>>> 'mv88e6xxx_blackhole_fdb_del' was not declared. Should it be static?

Hi, yes they should both be static.
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 71843fe87f77..3c4ebb2a5301 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2735,6 +2735,56 @@  static int mv88e6xxx_vlan_msti_set(struct dsa_switch *ds,
 	return err;
 }
 
+static int mv88e6xxx_blackhole_fdb_loadpurge(struct dsa_switch *ds,
+					     const unsigned char *addr, u16 vid, u8 state)
+{
+	struct mv88e6xxx_chip *chip = ds->priv;
+	struct mv88e6xxx_atu_entry entry;
+	struct mv88e6xxx_vtu_entry vlan;
+
+	u16 fid = 0;
+	int err;
+
+	if (vid == 0) {
+		fid = MV88E6XXX_FID_BRIDGED;
+	} else {
+		mv88e6xxx_reg_lock(chip);
+		err = mv88e6xxx_vtu_get(chip, vid, &vlan);
+		mv88e6xxx_reg_unlock(chip);
+		if (err)
+			return err;
+
+		/* switchdev expects -EOPNOTSUPP to honor software VLANs */
+		if (!vlan.valid)
+			return -EOPNOTSUPP;
+
+		fid = vlan.fid;
+	}
+
+	ether_addr_copy(entry.mac, addr);
+	entry.portvec = MV88E6XXX_G1_ATU_DATA_PORT_VECTOR_NO_EGRESS;
+	entry.state = state;
+	entry.trunk = false;
+
+	mv88e6xxx_reg_lock(chip);
+	err = mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
+	mv88e6xxx_reg_unlock(chip);
+
+	return err;
+}
+
+int mv88e6xxx_blackhole_fdb_add(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
+{
+	return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid,
+						 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
+}
+
+int mv88e6xxx_blackhole_fdb_del(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
+{
+	return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid,
+						 MV88E6XXX_G1_ATU_DATA_STATE_UC_UNUSED);
+}
+
 static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
 				  const unsigned char *addr, u16 vid,
 				  u16 fdb_flags, struct dsa_db db)
@@ -2742,9 +2792,10 @@  static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
 	struct mv88e6xxx_chip *chip = ds->priv;
 	int err;
 
-	/* Ignore entries with flags set */
-	if (fdb_flags)
+	if (fdb_flags & DSA_FDB_FLAG_LOCKED)
 		return 0;
+	if (fdb_flags & DSA_FDB_FLAG_BLACKHOLE)
+		return mv88e6xxx_blackhole_fdb_add(ds, addr, vid);
 
 	if (mv88e6xxx_port_is_locked(chip, port))
 		mv88e6xxx_atu_locked_entry_find_purge(ds, port, addr, vid);
@@ -2765,9 +2816,10 @@  static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
 	bool locked_found = false;
 	int err = 0;
 
-	/* Ignore entries with flags set */
-	if (fdb_flags)
+	if (fdb_flags & DSA_FDB_FLAG_LOCKED)
 		return 0;
+	if (fdb_flags & DSA_FDB_FLAG_BLACKHOLE)
+		return mv88e6xxx_blackhole_fdb_del(ds, addr, vid);
 
 	if (mv88e6xxx_port_is_locked(chip, port))
 		locked_found = mv88e6xxx_atu_locked_entry_find_purge(ds, port, addr, vid);