Skip to content

Commit eb60020

Browse files
committed
Merge branch 'mlxsw-dedicated-router-notification-block'
Ido Schimmel says: ==================== mlxsw: A dedicated notifier block for router code Petr says: Currently all netdevice events are handled in the centralized notifier handler maintained by spectrum.c. Since a number of events are involving router code, spectrum.c needs to dispatch them to spectrum_router.c. The spectrum module therefore needs to know more about the router code than it should have, and there is are several API points through which the two modules communicate. In this patchset, move bulk of the router-related event handling to the router code. Some of the knowledge has to stay: spectrum.c cannot veto events that the router supports, and vice versa. But beyond that, the two can ignore each other's details, which leads to more focused and simpler code. As a side effect, this fixes L3 HW stats support on tunnel netdevices. The patch set progresses as follows: - In patch #1, change spectrum code to not bounce L3 enslavement, which the router code supports. - In patch #2, add a new do-nothing notifier block to the router code. - In patches #3-#6, move router-specific event handling to the router module. In patch #7, clean up a comment. - In patch #8, use the advantage that all router event handling is in the router code and clean up taking router lock. - mlxsw supports L3 HW stats on tunnels as of this patchset. Patches #9 and #10 therefore add a selftest for L3 HW stats support on tunnels. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9f88af2 + 813f97a commit eb60020

File tree

8 files changed

+259
-122
lines changed

8 files changed

+259
-122
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,9 +3122,8 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
31223122
}
31233123
}
31243124

3125-
/* Initialize netdevice notifier after router and SPAN is initialized,
3126-
* so that the event handler can use router structures and call SPAN
3127-
* respin.
3125+
/* Initialize netdevice notifier after SPAN is initialized, so that the
3126+
* event handler can call SPAN respin.
31283127
*/
31293128
mlxsw_sp->netdevice_nb.notifier_call = mlxsw_sp_netdevice_event;
31303129
err = register_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp),
@@ -4525,7 +4524,8 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *lower_dev,
45254524
!netif_is_lag_master(upper_dev) &&
45264525
!netif_is_bridge_master(upper_dev) &&
45274526
!netif_is_ovs_master(upper_dev) &&
4528-
!netif_is_macvlan(upper_dev)) {
4527+
!netif_is_macvlan(upper_dev) &&
4528+
!netif_is_l3_master(upper_dev)) {
45294529
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
45304530
return -EINVAL;
45314531
}
@@ -4724,7 +4724,8 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev,
47244724
case NETDEV_PRECHANGEUPPER:
47254725
upper_dev = info->upper_dev;
47264726
if (!netif_is_bridge_master(upper_dev) &&
4727-
!netif_is_macvlan(upper_dev)) {
4727+
!netif_is_macvlan(upper_dev) &&
4728+
!netif_is_l3_master(upper_dev)) {
47284729
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
47294730
return -EINVAL;
47304731
}
@@ -4763,9 +4764,6 @@ static int mlxsw_sp_netdevice_port_vlan_event(struct net_device *vlan_dev,
47634764
} else if (netif_is_macvlan(upper_dev)) {
47644765
if (!info->linking)
47654766
mlxsw_sp_rif_macvlan_del(mlxsw_sp, upper_dev);
4766-
} else {
4767-
err = -EINVAL;
4768-
WARN_ON(1);
47694767
}
47704768
break;
47714769
}
@@ -4813,7 +4811,8 @@ static int mlxsw_sp_netdevice_bridge_vlan_event(struct net_device *vlan_dev,
48134811
switch (event) {
48144812
case NETDEV_PRECHANGEUPPER:
48154813
upper_dev = info->upper_dev;
4816-
if (!netif_is_macvlan(upper_dev)) {
4814+
if (!netif_is_macvlan(upper_dev) &&
4815+
!netif_is_l3_master(upper_dev)) {
48174816
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
48184817
return -EOPNOTSUPP;
48194818
}
@@ -4874,7 +4873,9 @@ static int mlxsw_sp_netdevice_bridge_event(struct net_device *br_dev,
48744873
switch (event) {
48754874
case NETDEV_PRECHANGEUPPER:
48764875
upper_dev = info->upper_dev;
4877-
if (!is_vlan_dev(upper_dev) && !netif_is_macvlan(upper_dev)) {
4876+
if (!is_vlan_dev(upper_dev) &&
4877+
!netif_is_macvlan(upper_dev) &&
4878+
!netif_is_l3_master(upper_dev)) {
48784879
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
48794880
return -EOPNOTSUPP;
48804881
}
@@ -4918,25 +4919,20 @@ static int mlxsw_sp_netdevice_macvlan_event(struct net_device *macvlan_dev,
49184919
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(macvlan_dev);
49194920
struct netdev_notifier_changeupper_info *info = ptr;
49204921
struct netlink_ext_ack *extack;
4922+
struct net_device *upper_dev;
49214923

49224924
if (!mlxsw_sp || event != NETDEV_PRECHANGEUPPER)
49234925
return 0;
49244926

49254927
extack = netdev_notifier_info_to_extack(&info->info);
4928+
upper_dev = info->upper_dev;
49264929

4927-
/* VRF enslavement is handled in mlxsw_sp_netdevice_vrf_event() */
4928-
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
4929-
4930-
return -EOPNOTSUPP;
4931-
}
4932-
4933-
static bool mlxsw_sp_is_vrf_event(unsigned long event, void *ptr)
4934-
{
4935-
struct netdev_notifier_changeupper_info *info = ptr;
4930+
if (!netif_is_l3_master(upper_dev)) {
4931+
NL_SET_ERR_MSG_MOD(extack, "Unknown upper device type");
4932+
return -EOPNOTSUPP;
4933+
}
49364934

4937-
if (event != NETDEV_PRECHANGEUPPER && event != NETDEV_CHANGEUPPER)
4938-
return false;
4939-
return netif_is_l3_master(info->upper_dev);
4935+
return 0;
49404936
}
49414937

49424938
static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,
@@ -5007,22 +5003,6 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,
50075003
return 0;
50085004
}
50095005

5010-
static bool mlxsw_sp_netdevice_event_is_router(unsigned long event)
5011-
{
5012-
switch (event) {
5013-
case NETDEV_PRE_CHANGEADDR:
5014-
case NETDEV_CHANGEADDR:
5015-
case NETDEV_CHANGEMTU:
5016-
case NETDEV_OFFLOAD_XSTATS_ENABLE:
5017-
case NETDEV_OFFLOAD_XSTATS_DISABLE:
5018-
case NETDEV_OFFLOAD_XSTATS_REPORT_USED:
5019-
case NETDEV_OFFLOAD_XSTATS_REPORT_DELTA:
5020-
return true;
5021-
default:
5022-
return false;
5023-
}
5024-
}
5025-
50265006
static int mlxsw_sp_netdevice_event(struct notifier_block *nb,
50275007
unsigned long event, void *ptr)
50285008
{
@@ -5041,16 +5021,6 @@ static int mlxsw_sp_netdevice_event(struct notifier_block *nb,
50415021

50425022
if (netif_is_vxlan(dev))
50435023
err = mlxsw_sp_netdevice_vxlan_event(mlxsw_sp, dev, event, ptr);
5044-
if (mlxsw_sp_netdev_is_ipip_ol(mlxsw_sp, dev))
5045-
err = mlxsw_sp_netdevice_ipip_ol_event(mlxsw_sp, dev,
5046-
event, ptr);
5047-
else if (mlxsw_sp_netdev_is_ipip_ul(mlxsw_sp, dev))
5048-
err = mlxsw_sp_netdevice_ipip_ul_event(mlxsw_sp, dev,
5049-
event, ptr);
5050-
else if (mlxsw_sp_netdevice_event_is_router(event))
5051-
err = mlxsw_sp_netdevice_router_port_event(dev, event, ptr);
5052-
else if (mlxsw_sp_is_vrf_event(event, ptr))
5053-
err = mlxsw_sp_netdevice_vrf_event(dev, event, ptr);
50545024
else if (mlxsw_sp_port_dev_check(dev))
50555025
err = mlxsw_sp_netdevice_port_event(dev, dev, event, ptr);
50565026
else if (netif_is_lag_master(dev))

drivers/net/ethernet/mellanox/mlxsw/spectrum.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -718,29 +718,12 @@ union mlxsw_sp_l3addr {
718718
int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp,
719719
struct netlink_ext_ack *extack);
720720
void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp);
721-
int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
722-
unsigned long event, void *ptr);
723721
void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp,
724722
const struct net_device *macvlan_dev);
725723
int mlxsw_sp_inetaddr_valid_event(struct notifier_block *unused,
726724
unsigned long event, void *ptr);
727725
int mlxsw_sp_inet6addr_valid_event(struct notifier_block *unused,
728726
unsigned long event, void *ptr);
729-
int mlxsw_sp_netdevice_vrf_event(struct net_device *l3_dev, unsigned long event,
730-
struct netdev_notifier_changeupper_info *info);
731-
bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp,
732-
const struct net_device *dev);
733-
bool mlxsw_sp_netdev_is_ipip_ul(struct mlxsw_sp *mlxsw_sp,
734-
const struct net_device *dev);
735-
int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp,
736-
struct net_device *l3_dev,
737-
unsigned long event,
738-
struct netdev_notifier_info *info);
739-
int
740-
mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp,
741-
struct net_device *l3_dev,
742-
unsigned long event,
743-
struct netdev_notifier_info *info);
744727
int
745728
mlxsw_sp_port_vlan_router_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
746729
struct net_device *l3_dev,

0 commit comments

Comments
 (0)