diff mbox series

[RFC,net-next,1/4] net: dsa: microchip: modify vlan_add function prototype

Message ID 20220729151733.6032-2-arun.ramadoss@microchip.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: microchip: vlan configuration for bridge_vlan_unaware ports | 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 success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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 success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 137 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Arun Ramadoss July 29, 2022, 3:17 p.m. UTC
To use the vlan_add from the function other the .port_vlan_add dsa hook,
changed the ksz8_vlan_add and ksz9477_vlan_del function prototype which
uses only the vlan->vid and vlan->flags.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
 drivers/net/dsa/microchip/ksz8.h       |  5 ++---
 drivers/net/dsa/microchip/ksz8795.c    | 19 +++++++++----------
 drivers/net/dsa/microchip/ksz9477.c    | 25 ++++++++++---------------
 drivers/net/dsa/microchip/ksz9477.h    |  4 +---
 drivers/net/dsa/microchip/ksz_common.c |  2 +-
 drivers/net/dsa/microchip/ksz_common.h |  4 +---
 6 files changed, 24 insertions(+), 35 deletions(-)

Comments

Vladimir Oltean Aug. 2, 2022, 10:32 a.m. UTC | #1
On Fri, Jul 29, 2022 at 08:47:30PM +0530, Arun Ramadoss wrote:
> diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h
> index 42c50cc4d853..6529f2e2426a 100644
> --- a/drivers/net/dsa/microchip/ksz8.h
> +++ b/drivers/net/dsa/microchip/ksz8.h
> @@ -38,9 +38,8 @@ int ksz8_mdb_del(struct ksz_device *dev, int port,
>  		 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
>  int ksz8_port_vlan_filtering(struct ksz_device *dev, int port, bool flag,
>  			     struct netlink_ext_ack *extack);
> -int ksz8_port_vlan_add(struct ksz_device *dev, int port,
> -		       const struct switchdev_obj_port_vlan *vlan,
> -		       struct netlink_ext_ack *extack);
> +int ksz8_port_vlan_add(struct ksz_device *dev, int port, u16 vlan_vid,

I don't see an impediment to naming "vlan_vid" just "vid".

> +		       u16 flags);
>  int ksz8_port_vlan_del(struct ksz_device *dev, int port,
>  		       const struct switchdev_obj_port_vlan *vlan);

Won't you convert vlan_del too?
Arun Ramadoss Aug. 2, 2022, 1:58 p.m. UTC | #2
Hi Vladimir,
Thanks for the comment

On Tue, 2022-08-02 at 13:32 +0300, Vladimir Oltean wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> On Fri, Jul 29, 2022 at 08:47:30PM +0530, Arun Ramadoss wrote:
> > diff --git a/drivers/net/dsa/microchip/ksz8.h
> > b/drivers/net/dsa/microchip/ksz8.h
> > index 42c50cc4d853..6529f2e2426a 100644
> > --- a/drivers/net/dsa/microchip/ksz8.h
> > +++ b/drivers/net/dsa/microchip/ksz8.h
> > @@ -38,9 +38,8 @@ int ksz8_mdb_del(struct ksz_device *dev, int
> > port,
> >                const struct switchdev_obj_port_mdb *mdb, struct
> > dsa_db db);
> >  int ksz8_port_vlan_filtering(struct ksz_device *dev, int port,
> > bool flag,
> >                            struct netlink_ext_ack *extack);
> > -int ksz8_port_vlan_add(struct ksz_device *dev, int port,
> > -                    const struct switchdev_obj_port_vlan *vlan,
> > -                    struct netlink_ext_ack *extack);
> > +int ksz8_port_vlan_add(struct ksz_device *dev, int port, u16
> > vlan_vid,
> 
> I don't see an impediment to naming "vlan_vid" just "vid".

Ok, I will name it as vid.

> 
> > +                    u16 flags);
> >  int ksz8_port_vlan_del(struct ksz_device *dev, int port,
> >                      const struct switchdev_obj_port_vlan *vlan);
> 
> Won't you convert vlan_del too?

I will change it too.
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz8.h b/drivers/net/dsa/microchip/ksz8.h
index 42c50cc4d853..6529f2e2426a 100644
--- a/drivers/net/dsa/microchip/ksz8.h
+++ b/drivers/net/dsa/microchip/ksz8.h
@@ -38,9 +38,8 @@  int ksz8_mdb_del(struct ksz_device *dev, int port,
 		 const struct switchdev_obj_port_mdb *mdb, struct dsa_db db);
 int ksz8_port_vlan_filtering(struct ksz_device *dev, int port, bool flag,
 			     struct netlink_ext_ack *extack);
-int ksz8_port_vlan_add(struct ksz_device *dev, int port,
-		       const struct switchdev_obj_port_vlan *vlan,
-		       struct netlink_ext_ack *extack);
+int ksz8_port_vlan_add(struct ksz_device *dev, int port, u16 vlan_vid,
+		       u16 flags);
 int ksz8_port_vlan_del(struct ksz_device *dev, int port,
 		       const struct switchdev_obj_port_vlan *vlan);
 int ksz8_port_mirror_add(struct ksz_device *dev, int port,
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index c79a5128235f..5dd73e994142 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -962,11 +962,10 @@  static void ksz8_port_enable_pvid(struct ksz_device *dev, int port, bool state)
 	}
 }
 
-int ksz8_port_vlan_add(struct ksz_device *dev, int port,
-		       const struct switchdev_obj_port_vlan *vlan,
-		       struct netlink_ext_ack *extack)
+int ksz8_port_vlan_add(struct ksz_device *dev, int port, u16 vlan_vid,
+		       u16 flags)
 {
-	bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+	bool untagged = flags & BRIDGE_VLAN_INFO_UNTAGGED;
 	struct ksz_port *p = &dev->ports[port];
 	u16 data, new_pvid = 0;
 	u8 fid, member, valid;
@@ -979,7 +978,7 @@  int ksz8_port_vlan_add(struct ksz_device *dev, int port,
 	 * Ignore VID 0, which is always untagged.
 	 * Ignore CPU port, which will always be tagged.
 	 */
-	if (untagged != p->remove_tag && vlan->vid != 0 &&
+	if (untagged != p->remove_tag && vlan_vid != 0 &&
 	    port != dev->cpu_port) {
 		unsigned int vid;
 
@@ -989,7 +988,7 @@  int ksz8_port_vlan_add(struct ksz_device *dev, int port,
 		 */
 		for (vid = 1; vid < dev->info->num_vlans; ++vid) {
 			/* Skip the VID we are going to add or reconfigure */
-			if (vid == vlan->vid)
+			if (vid == vlan_vid)
 				continue;
 
 			ksz8_from_vlan(dev, dev->vlan_cache[vid].table[0],
@@ -1002,7 +1001,7 @@  int ksz8_port_vlan_add(struct ksz_device *dev, int port,
 		p->remove_tag = untagged;
 	}
 
-	ksz8_r_vlan_table(dev, vlan->vid, &data);
+	ksz8_r_vlan_table(dev, vlan_vid, &data);
 	ksz8_from_vlan(dev, data, &fid, &member, &valid);
 
 	/* First time to setup the VLAN entry. */
@@ -1014,11 +1013,11 @@  int ksz8_port_vlan_add(struct ksz_device *dev, int port,
 	member |= BIT(port);
 
 	ksz8_to_vlan(dev, fid, member, valid, &data);
-	ksz8_w_vlan_table(dev, vlan->vid, data);
+	ksz8_w_vlan_table(dev, vlan_vid, data);
 
 	/* change PVID */
-	if (vlan->flags & BRIDGE_VLAN_INFO_PVID)
-		new_pvid = vlan->vid;
+	if (flags & BRIDGE_VLAN_INFO_PVID)
+		new_pvid = vlan_vid;
 
 	if (new_pvid) {
 		u16 vid;
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 4b14d80d27ed..81d24b89958b 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -370,21 +370,18 @@  int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
 	return 0;
 }
 
-int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
-			  const struct switchdev_obj_port_vlan *vlan,
-			  struct netlink_ext_ack *extack)
+int ksz9477_port_vlan_add(struct ksz_device *dev, int port, u16 vlan_vid,
+			  u16 flags)
 {
 	u32 vlan_table[3];
-	bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
+	bool untagged = flags & BRIDGE_VLAN_INFO_UNTAGGED;
 	int err;
 
-	err = ksz9477_get_vlan_table(dev, vlan->vid, vlan_table);
-	if (err) {
-		NL_SET_ERR_MSG_MOD(extack, "Failed to get vlan table");
+	err = ksz9477_get_vlan_table(dev, vlan_vid, vlan_table);
+	if (err)
 		return err;
-	}
 
-	vlan_table[0] = VLAN_VALID | (vlan->vid & VLAN_FID_M);
+	vlan_table[0] = VLAN_VALID | (vlan_vid & VLAN_FID_M);
 	if (untagged)
 		vlan_table[1] |= BIT(port);
 	else
@@ -393,15 +390,13 @@  int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
 
 	vlan_table[2] |= BIT(port) | BIT(dev->cpu_port);
 
-	err = ksz9477_set_vlan_table(dev, vlan->vid, vlan_table);
-	if (err) {
-		NL_SET_ERR_MSG_MOD(extack, "Failed to set vlan table");
+	err = ksz9477_set_vlan_table(dev, vlan_vid, vlan_table);
+	if (err)
 		return err;
-	}
 
 	/* change PVID */
-	if (vlan->flags & BRIDGE_VLAN_INFO_PVID)
-		ksz_pwrite16(dev, port, REG_PORT_DEFAULT_VID, vlan->vid);
+	if (flags & BRIDGE_VLAN_INFO_PVID)
+		ksz_pwrite16(dev, port, REG_PORT_DEFAULT_VID, vlan_vid);
 
 	return 0;
 }
diff --git a/drivers/net/dsa/microchip/ksz9477.h b/drivers/net/dsa/microchip/ksz9477.h
index cd278b307b3c..30a1fff9b8ec 100644
--- a/drivers/net/dsa/microchip/ksz9477.h
+++ b/drivers/net/dsa/microchip/ksz9477.h
@@ -25,9 +25,7 @@  void ksz9477_freeze_mib(struct ksz_device *dev, int port, bool freeze);
 void ksz9477_port_init_cnt(struct ksz_device *dev, int port);
 int ksz9477_port_vlan_filtering(struct ksz_device *dev, int port,
 				bool flag, struct netlink_ext_ack *extack);
-int ksz9477_port_vlan_add(struct ksz_device *dev, int port,
-			  const struct switchdev_obj_port_vlan *vlan,
-			  struct netlink_ext_ack *extack);
+int ksz9477_port_vlan_add(struct ksz_device *dev, int port, u16 vid, u16 flags);
 int ksz9477_port_vlan_del(struct ksz_device *dev, int port,
 			  const struct switchdev_obj_port_vlan *vlan);
 int ksz9477_port_mirror_add(struct ksz_device *dev, int port,
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 02e58760cf7b..97dbccb065a9 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1351,7 +1351,7 @@  static int ksz_port_vlan_add(struct dsa_switch *ds, int port,
 	if (!dev->dev_ops->vlan_add)
 		return -EOPNOTSUPP;
 
-	return dev->dev_ops->vlan_add(dev, port, vlan, extack);
+	return dev->dev_ops->vlan_add(dev, port, vlan->vid, vlan->flags);
 }
 
 static int ksz_port_vlan_del(struct dsa_switch *ds, int port,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 764ada3a0f42..9bb378b79a94 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -267,9 +267,7 @@  struct ksz_dev_ops {
 	void (*r_mib_stat64)(struct ksz_device *dev, int port);
 	int  (*vlan_filtering)(struct ksz_device *dev, int port,
 			       bool flag, struct netlink_ext_ack *extack);
-	int  (*vlan_add)(struct ksz_device *dev, int port,
-			 const struct switchdev_obj_port_vlan *vlan,
-			 struct netlink_ext_ack *extack);
+	int  (*vlan_add)(struct ksz_device *dev, int port, u16 vid, u16 flags);
 	int  (*vlan_del)(struct ksz_device *dev, int port,
 			 const struct switchdev_obj_port_vlan *vlan);
 	int (*mirror_add)(struct ksz_device *dev, int port,