All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] mlxsw: MAC profiles occupancy fix
@ 2021-12-14 10:21 Ido Schimmel
  2021-12-14 10:21 ` [PATCH net 1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ido Schimmel @ 2021-12-14 10:21 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, petrm, danieller, mlxsw, Ido Schimmel

Patch #1 fixes a router interface (RIF) MAC profiles occupancy bug that
was merged in the last cycle.

Patch #2 adds a selftest that fails without the fix.

Danielle Ratson (2):
  mlxsw: spectrum_router: Consolidate MAC profiles when possible
  selftests: mlxsw: Add a test case for MAC profiles consolidation

 .../ethernet/mellanox/mlxsw/spectrum_router.c |  3 +-
 .../drivers/net/mlxsw/rif_mac_profiles_occ.sh | 30 +++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible
  2021-12-14 10:21 [PATCH net 0/2] mlxsw: MAC profiles occupancy fix Ido Schimmel
@ 2021-12-14 10:21 ` Ido Schimmel
  2021-12-14 10:21 ` [PATCH net 2/2] selftests: mlxsw: Add a test case for MAC profiles consolidation Ido Schimmel
  2021-12-14 13:00 ` [PATCH net 0/2] mlxsw: MAC profiles occupancy fix patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2021-12-14 10:21 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, petrm, danieller, mlxsw, Ido Schimmel

From: Danielle Ratson <danieller@nvidia.com>

Currently, when setting a router interface (RIF) MAC address while the
MAC profile is not shared with other RIFs, the profile is edited so that
the new MAC address is assigned to it.

This does not take into account a situation in which the new MAC address
already matches an existing MAC profile. In that situation, two MAC
profiles will be occupied even though they hold MAC addresses from the
same profile.

In order to prevent that, add a check to ensure that editing a MAC
profile takes place only when the new MAC address does not match an
existing profile.

Fixes: 605d25cd782a6 ("mlxsw: spectrum_router: Add RIF MAC profiles support")
Reported-by: Maksym Yaremchuk <maksymy@nvidia.com>
Tested-by: Maksym Yaremchuk <maksymy@nvidia.com>
Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 2af0c6382609..764731eae2cd 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -8491,7 +8491,8 @@ mlxsw_sp_rif_mac_profile_replace(struct mlxsw_sp *mlxsw_sp,
 	u8 mac_profile;
 	int err;
 
-	if (!mlxsw_sp_rif_mac_profile_is_shared(rif))
+	if (!mlxsw_sp_rif_mac_profile_is_shared(rif) &&
+	    !mlxsw_sp_rif_mac_profile_find(mlxsw_sp, new_mac))
 		return mlxsw_sp_rif_mac_profile_edit(rif, new_mac);
 
 	err = mlxsw_sp_rif_mac_profile_get(mlxsw_sp, new_mac,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] selftests: mlxsw: Add a test case for MAC profiles consolidation
  2021-12-14 10:21 [PATCH net 0/2] mlxsw: MAC profiles occupancy fix Ido Schimmel
  2021-12-14 10:21 ` [PATCH net 1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible Ido Schimmel
@ 2021-12-14 10:21 ` Ido Schimmel
  2021-12-14 13:00 ` [PATCH net 0/2] mlxsw: MAC profiles occupancy fix patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2021-12-14 10:21 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, petrm, danieller, mlxsw, Ido Schimmel

From: Danielle Ratson <danieller@nvidia.com>

Add a test case to cover the bug fixed by the previous patch.

Edit the MAC address of one netdev so that it matches the MAC address of
the second netdev. Verify that the two MAC profiles were consolidated by
testing that the MAC profiles occupancy decreased by one.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 .../drivers/net/mlxsw/rif_mac_profiles_occ.sh | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh b/tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh
index b513f64d9092..026a126f584d 100755
--- a/tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh
+++ b/tools/testing/selftests/drivers/net/mlxsw/rif_mac_profiles_occ.sh
@@ -72,6 +72,35 @@ rif_mac_profile_replacement_test()
 	ip link set $h1.10 address $h1_10_mac
 }
 
+rif_mac_profile_consolidation_test()
+{
+	local count=$1; shift
+	local h1_20_mac
+
+	RET=0
+
+	if [[ $count -eq 1 ]]; then
+		return
+	fi
+
+	h1_20_mac=$(mac_get $h1.20)
+
+	# Set the MAC of $h1.20 to that of $h1.10 and confirm that they are
+	# using the same MAC profile.
+	ip link set $h1.20 address 00:11:11:11:11:11
+	check_err $?
+
+	occ=$(devlink -j resource show $DEVLINK_DEV \
+	      | jq '.[][][] | select(.name=="rif_mac_profiles") |.["occ"]')
+
+	[[ $occ -eq $((count - 1)) ]]
+	check_err $? "MAC profile occupancy did not decrease"
+
+	log_test "RIF MAC profile consolidation"
+
+	ip link set $h1.20 address $h1_20_mac
+}
+
 rif_mac_profile_shared_replacement_test()
 {
 	local count=$1; shift
@@ -104,6 +133,7 @@ rif_mac_profile_edit_test()
 	create_max_rif_mac_profiles $count
 
 	rif_mac_profile_replacement_test
+	rif_mac_profile_consolidation_test $count
 	rif_mac_profile_shared_replacement_test $count
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] mlxsw: MAC profiles occupancy fix
  2021-12-14 10:21 [PATCH net 0/2] mlxsw: MAC profiles occupancy fix Ido Schimmel
  2021-12-14 10:21 ` [PATCH net 1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible Ido Schimmel
  2021-12-14 10:21 ` [PATCH net 2/2] selftests: mlxsw: Add a test case for MAC profiles consolidation Ido Schimmel
@ 2021-12-14 13:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-14 13:00 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: netdev, davem, kuba, petrm, danieller, mlxsw

Hello:

This series was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 14 Dec 2021 12:21:35 +0200 you wrote:
> Patch #1 fixes a router interface (RIF) MAC profiles occupancy bug that
> was merged in the last cycle.
> 
> Patch #2 adds a selftest that fails without the fix.
> 
> Danielle Ratson (2):
>   mlxsw: spectrum_router: Consolidate MAC profiles when possible
>   selftests: mlxsw: Add a test case for MAC profiles consolidation
> 
> [...]

Here is the summary with links:
  - [net,1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible
    https://git.kernel.org/netdev/net/c/b442f2ea8462
  - [net,2/2] selftests: mlxsw: Add a test case for MAC profiles consolidation
    https://git.kernel.org/netdev/net/c/20617717cd21

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-14 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 10:21 [PATCH net 0/2] mlxsw: MAC profiles occupancy fix Ido Schimmel
2021-12-14 10:21 ` [PATCH net 1/2] mlxsw: spectrum_router: Consolidate MAC profiles when possible Ido Schimmel
2021-12-14 10:21 ` [PATCH net 2/2] selftests: mlxsw: Add a test case for MAC profiles consolidation Ido Schimmel
2021-12-14 13:00 ` [PATCH net 0/2] mlxsw: MAC profiles occupancy fix patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.