mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
net: dsa: move dsa_tree_notify() and dsa_broadcast() to switch.c
There isn't an intuitive place for these 2 cross-chip notifier functions according to the function-to-file classification based on names (dsa_switch_*() goes to switch.c), but I consider these to be part of the cross-chip notifier handling, therefore part of switch.c. Move them there to reduce bloat in dsa2.c (the place where all code with no better place to go goes). Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
0c603136e1
commit
6dbdfce773
@ -31,52 +31,6 @@ LIST_HEAD(dsa_tree_list);
|
||||
/* Track the bridges with forwarding offload enabled */
|
||||
static unsigned long dsa_fwd_offloading_bridges;
|
||||
|
||||
/**
|
||||
* dsa_tree_notify - Execute code for all switches in a DSA switch tree.
|
||||
* @dst: collection of struct dsa_switch devices to notify.
|
||||
* @e: event, must be of type DSA_NOTIFIER_*
|
||||
* @v: event-specific value.
|
||||
*
|
||||
* Given a struct dsa_switch_tree, this can be used to run a function once for
|
||||
* each member DSA switch. The other alternative of traversing the tree is only
|
||||
* through its ports list, which does not uniquely list the switches.
|
||||
*/
|
||||
int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v)
|
||||
{
|
||||
struct raw_notifier_head *nh = &dst->nh;
|
||||
int err;
|
||||
|
||||
err = raw_notifier_call_chain(nh, e, v);
|
||||
|
||||
return notifier_to_errno(err);
|
||||
}
|
||||
|
||||
/**
|
||||
* dsa_broadcast - Notify all DSA trees in the system.
|
||||
* @e: event, must be of type DSA_NOTIFIER_*
|
||||
* @v: event-specific value.
|
||||
*
|
||||
* Can be used to notify the switching fabric of events such as cross-chip
|
||||
* bridging between disjoint trees (such as islands of tagger-compatible
|
||||
* switches bridged by an incompatible middle switch).
|
||||
*
|
||||
* WARNING: this function is not reliable during probe time, because probing
|
||||
* between trees is asynchronous and not all DSA trees might have probed.
|
||||
*/
|
||||
int dsa_broadcast(unsigned long e, void *v)
|
||||
{
|
||||
struct dsa_switch_tree *dst;
|
||||
int err = 0;
|
||||
|
||||
list_for_each_entry(dst, &dsa_tree_list, list) {
|
||||
err = dsa_tree_notify(dst, e, v);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* dsa_lag_map() - Map LAG structure to a linear LAG array
|
||||
* @dst: Tree in which to record the mapping.
|
||||
|
@ -175,8 +175,6 @@ void dsa_lag_unmap(struct dsa_switch_tree *dst, struct dsa_lag *lag);
|
||||
struct dsa_lag *dsa_tree_lag_find(struct dsa_switch_tree *dst,
|
||||
const struct net_device *lag_dev);
|
||||
struct net_device *dsa_tree_find_first_master(struct dsa_switch_tree *dst);
|
||||
int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v);
|
||||
int dsa_broadcast(unsigned long e, void *v);
|
||||
int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,
|
||||
const struct dsa_device_ops *tag_ops,
|
||||
const struct dsa_device_ops *old_tag_ops);
|
||||
|
@ -1016,6 +1016,52 @@ static int dsa_switch_event(struct notifier_block *nb,
|
||||
return notifier_from_errno(err);
|
||||
}
|
||||
|
||||
/**
|
||||
* dsa_tree_notify - Execute code for all switches in a DSA switch tree.
|
||||
* @dst: collection of struct dsa_switch devices to notify.
|
||||
* @e: event, must be of type DSA_NOTIFIER_*
|
||||
* @v: event-specific value.
|
||||
*
|
||||
* Given a struct dsa_switch_tree, this can be used to run a function once for
|
||||
* each member DSA switch. The other alternative of traversing the tree is only
|
||||
* through its ports list, which does not uniquely list the switches.
|
||||
*/
|
||||
int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v)
|
||||
{
|
||||
struct raw_notifier_head *nh = &dst->nh;
|
||||
int err;
|
||||
|
||||
err = raw_notifier_call_chain(nh, e, v);
|
||||
|
||||
return notifier_to_errno(err);
|
||||
}
|
||||
|
||||
/**
|
||||
* dsa_broadcast - Notify all DSA trees in the system.
|
||||
* @e: event, must be of type DSA_NOTIFIER_*
|
||||
* @v: event-specific value.
|
||||
*
|
||||
* Can be used to notify the switching fabric of events such as cross-chip
|
||||
* bridging between disjoint trees (such as islands of tagger-compatible
|
||||
* switches bridged by an incompatible middle switch).
|
||||
*
|
||||
* WARNING: this function is not reliable during probe time, because probing
|
||||
* between trees is asynchronous and not all DSA trees might have probed.
|
||||
*/
|
||||
int dsa_broadcast(unsigned long e, void *v)
|
||||
{
|
||||
struct dsa_switch_tree *dst;
|
||||
int err = 0;
|
||||
|
||||
list_for_each_entry(dst, &dsa_tree_list, list) {
|
||||
err = dsa_tree_notify(dst, e, v);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int dsa_switch_register_notifier(struct dsa_switch *ds)
|
||||
{
|
||||
ds->nb.notifier_call = dsa_switch_event;
|
||||
|
@ -3,8 +3,12 @@
|
||||
#ifndef __DSA_SWITCH_H
|
||||
#define __DSA_SWITCH_H
|
||||
|
||||
struct dsa_switch_tree;
|
||||
struct dsa_switch;
|
||||
|
||||
int dsa_tree_notify(struct dsa_switch_tree *dst, unsigned long e, void *v);
|
||||
int dsa_broadcast(unsigned long e, void *v);
|
||||
|
||||
int dsa_switch_register_notifier(struct dsa_switch *ds);
|
||||
void dsa_switch_unregister_notifier(struct dsa_switch *ds);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user