diff mbox series

[net-next,1/2] net: bridge: switchdev: refactor br_switchdev_fdb_notify

Message ID 20210414151540.1808871-1-olteanv@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] net: bridge: switchdev: refactor br_switchdev_fdb_notify | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: bridge@lists.linux-foundation.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 58 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Vladimir Oltean April 14, 2021, 3:15 p.m. UTC
From: Tobias Waldekranz <tobias@waldekranz.com>

Instead of having to add more and more arguments to
br_switchdev_fdb_call_notifiers, get rid of it and build the info
struct directly in br_switchdev_fdb_notify.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/bridge/br_switchdev.c | 41 +++++++++++----------------------------
 1 file changed, 11 insertions(+), 30 deletions(-)

Comments

Nikolay Aleksandrov April 14, 2021, 3:25 p.m. UTC | #1
On 14/04/2021 18:15, Vladimir Oltean wrote:
> From: Tobias Waldekranz <tobias@waldekranz.com>
> 
> Instead of having to add more and more arguments to
> br_switchdev_fdb_call_notifiers, get rid of it and build the info
> struct directly in br_switchdev_fdb_notify.
> 
> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/bridge/br_switchdev.c | 41 +++++++++++----------------------------
>  1 file changed, 11 insertions(+), 30 deletions(-)
> 

Hi,
Is there a PATCH 0/2 with overview and explanation of what's happening in this set ?
If there isn't one please add it and explain the motivation and the change.

Thanks,
 Nik

> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 1e24d9a2c9a7..c390f84adea2 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
> @@ -107,25 +107,16 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
>  	return 0;
>  }
>  
> -static void
> -br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
> -				u16 vid, struct net_device *dev,
> -				bool added_by_user, bool offloaded)
> -{
> -	struct switchdev_notifier_fdb_info info;
> -	unsigned long notifier_type;
> -
> -	info.addr = mac;
> -	info.vid = vid;
> -	info.added_by_user = added_by_user;
> -	info.offloaded = offloaded;
> -	notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE;
> -	call_switchdev_notifiers(notifier_type, dev, &info.info, NULL);
> -}
> -
>  void
>  br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
>  {
> +	struct switchdev_notifier_fdb_info info = {
> +		.addr = fdb->key.addr.addr,
> +		.vid = fdb->key.vlan_id,
> +		.added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags),
> +		.offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
> +	};
> +
>  	if (!fdb->dst)
>  		return;
>  	if (test_bit(BR_FDB_LOCAL, &fdb->flags))
> @@ -133,22 +124,12 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
>  
>  	switch (type) {
>  	case RTM_DELNEIGH:
> -		br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
> -						fdb->key.vlan_id,
> -						fdb->dst->dev,
> -						test_bit(BR_FDB_ADDED_BY_USER,
> -							 &fdb->flags),
> -						test_bit(BR_FDB_OFFLOADED,
> -							 &fdb->flags));
> +		call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
> +					 fdb->dst->dev, &info.info, NULL);
>  		break;
>  	case RTM_NEWNEIGH:
> -		br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
> -						fdb->key.vlan_id,
> -						fdb->dst->dev,
> -						test_bit(BR_FDB_ADDED_BY_USER,
> -							 &fdb->flags),
> -						test_bit(BR_FDB_OFFLOADED,
> -							 &fdb->flags));
> +		call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
> +					 fdb->dst->dev, &info.info, NULL);
>  		break;
>  	}
>  }
>
Vladimir Oltean April 14, 2021, 3:26 p.m. UTC | #2
On Wed, Apr 14, 2021 at 06:25:03PM +0300, Nikolay Aleksandrov wrote:
> On 14/04/2021 18:15, Vladimir Oltean wrote:
> > From: Tobias Waldekranz <tobias@waldekranz.com>
> > 
> > Instead of having to add more and more arguments to
> > br_switchdev_fdb_call_notifiers, get rid of it and build the info
> > struct directly in br_switchdev_fdb_notify.
> > 
> > Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
> > Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > ---
> >  net/bridge/br_switchdev.c | 41 +++++++++++----------------------------
> >  1 file changed, 11 insertions(+), 30 deletions(-)
> > 
> 
> Hi,
> Is there a PATCH 0/2 with overview and explanation of what's happening in this set ?
> If there isn't one please add it and explain the motivation and the change.
> 
> Thanks,
>  Nik

Nope, there isn't. Being a 2-patch series, and having the explanation
already provided in patch 2, I didn't consider a cover letter as
necessary. Change #1 is just preliminary refactoring.
diff mbox series

Patch

diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 1e24d9a2c9a7..c390f84adea2 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -107,25 +107,16 @@  int br_switchdev_set_port_flag(struct net_bridge_port *p,
 	return 0;
 }
 
-static void
-br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac,
-				u16 vid, struct net_device *dev,
-				bool added_by_user, bool offloaded)
-{
-	struct switchdev_notifier_fdb_info info;
-	unsigned long notifier_type;
-
-	info.addr = mac;
-	info.vid = vid;
-	info.added_by_user = added_by_user;
-	info.offloaded = offloaded;
-	notifier_type = adding ? SWITCHDEV_FDB_ADD_TO_DEVICE : SWITCHDEV_FDB_DEL_TO_DEVICE;
-	call_switchdev_notifiers(notifier_type, dev, &info.info, NULL);
-}
-
 void
 br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
 {
+	struct switchdev_notifier_fdb_info info = {
+		.addr = fdb->key.addr.addr,
+		.vid = fdb->key.vlan_id,
+		.added_by_user = test_bit(BR_FDB_ADDED_BY_USER, &fdb->flags),
+		.offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags),
+	};
+
 	if (!fdb->dst)
 		return;
 	if (test_bit(BR_FDB_LOCAL, &fdb->flags))
@@ -133,22 +124,12 @@  br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
 
 	switch (type) {
 	case RTM_DELNEIGH:
-		br_switchdev_fdb_call_notifiers(false, fdb->key.addr.addr,
-						fdb->key.vlan_id,
-						fdb->dst->dev,
-						test_bit(BR_FDB_ADDED_BY_USER,
-							 &fdb->flags),
-						test_bit(BR_FDB_OFFLOADED,
-							 &fdb->flags));
+		call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_DEVICE,
+					 fdb->dst->dev, &info.info, NULL);
 		break;
 	case RTM_NEWNEIGH:
-		br_switchdev_fdb_call_notifiers(true, fdb->key.addr.addr,
-						fdb->key.vlan_id,
-						fdb->dst->dev,
-						test_bit(BR_FDB_ADDED_BY_USER,
-							 &fdb->flags),
-						test_bit(BR_FDB_OFFLOADED,
-							 &fdb->flags));
+		call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_DEVICE,
+					 fdb->dst->dev, &info.info, NULL);
 		break;
 	}
 }