mlxsw: Various updates
Subsystems (4)
cover mlxsw: Various updates
This patchset contains various updates to the mlxsw driver and related selftests.
Patches #1-#5 contain various updates to mlxsw selftests. The most significant change is the conversion of the DCB selftests to use the new iproute2 DCB support.
Patches #6-#9 contain mostly trivial changes to the driver itself. No user facing changes.
Patches #10-#11 remove support for SwitchX-2 and SwitchIB ASICs that did not see any updates in the last 4-5 years and will not see any in the future. See individual commit messages for detailed explanation as to why it is OK to remove these drivers from the kernel.
Amit Cohen (2):
mlxsw: Remove Mellanox SwitchIB ASIC support
mlxsw: Remove Mellanox SwitchX-2 ASIC support
Danielle Ratson (3):
selftests: mlxsw: Make the unsplit array global in port_scale test
mlxsw: spectrum_buffers: Switch function arguments
mlxsw: Verify the accessed index doesn't exceed the array length
Ido Schimmel (3):
selftests: mlxsw: Make sampling test more robust
mlxsw: core: Avoid unnecessary EMAD buffer copy
mlxsw: spectrum_router: Avoid missing error code warning
Petr Machata (3):
selftests: mlxsw: qos_headroom: Convert to iproute2 dcb
selftests: mlxsw: qos_pfc: Convert to iproute2 dcb
selftests: mlxsw: qos_lib: Drop __mlnx_qos
drivers/net/ethernet/mellanox/mlxsw/Kconfig | 22 - drivers/net/ethernet/mellanox/mlxsw/Makefile | 4 - drivers/net/ethernet/mellanox/mlxsw/core.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/ib.h | 9 - drivers/net/ethernet/mellanox/mlxsw/minimal.c | 4 + drivers/net/ethernet/mellanox/mlxsw/pci.c | 5 - drivers/net/ethernet/mellanox/mlxsw/pci.h | 3 - .../net/ethernet/mellanox/mlxsw/spectrum.c | 5 + .../mellanox/mlxsw/spectrum_buffers.c | 6 +- .../ethernet/mellanox/mlxsw/spectrum_ptp.c | 3 + .../ethernet/mellanox/mlxsw/spectrum_router.c | 9 +- .../mellanox/mlxsw/spectrum_switchdev.c | 4 + .../net/ethernet/mellanox/mlxsw/switchib.c | 595 ------ .../net/ethernet/mellanox/mlxsw/switchx2.c | 1691 ----------------- .../selftests/drivers/net/mlxsw/port_scale.sh | 4 +- .../drivers/net/mlxsw/qos_headroom.sh | 69 +- .../selftests/drivers/net/mlxsw/qos_lib.sh | 14 - .../selftests/drivers/net/mlxsw/qos_pfc.sh | 24 +- .../selftests/drivers/net/mlxsw/tc_sample.sh | 12 +- 19 files changed, 83 insertions(+), 2402 deletions(-) delete mode 100644 drivers/net/ethernet/mellanox/mlxsw/ib.h delete mode 100644 drivers/net/ethernet/mellanox/mlxsw/switchib.c delete mode 100644 drivers/net/ethernet/mellanox/mlxsw/switchx2.c
Signature · 1 line
2.31.1
PATCH 1/11 selftests: mlxsw: Make the unsplit array global in port_scale test
From: Danielle Ratson <[email protected]>
Currently, the array of the ports that were split in the port_scale test is local, so the port_cleanup() unsplits an empty array.
Make the array global so the cleanup will be preformed properly.
--- tools/testing/selftests/drivers/net/mlxsw/port_scale.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/mlxsw/port_scale.sh +3 -1
@@ -7,6 +7,8 @@ PORT_NUM_NETIFS=0 +declare -a unsplit + port_setup_prepare() { :
@@ -20,12 +22,12 @@ port_cleanup() devlink port unsplit $port check_err $? "Did not unsplit $netdev" done + unsplit=() } split_all_ports() { local should_fail=$1; shift - local -a unsplit # Loop over the splittable netdevs and create tuples of netdev along # with its width. For example:
Signature · 1 line
2.31.1
PATCH 2/11 selftests: mlxsw: Make sampling test more robust
In reply to Ido SchimmelThe test sometimes fails with an error message such as:
TEST: tc sample (w/ flower) rate (egress) [FAIL]
Expected 100 packets, got 70 packets, which is -30% off. Required accuracy is +-25%
Make the test more robust by generating more packets, therefore increasing the number of expected samples. Decrease the transmission delay in order not to needlessly prolong the test.
--- .../testing/selftests/drivers/net/mlxsw/tc_sample.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh +6 -6
@@ -234,15 +234,15 @@ __tc_sample_rate_test() psample_capture_start - ip vrf exec v$h1 $MZ $h1 -c 3200 -d 1msec -p 64 -A 192.0.2.1 \ + ip vrf exec v$h1 $MZ $h1 -c 320000 -d 100usec -p 64 -A 192.0.2.1 \ -B $dip -t udp dp=52768,sp=42768 -q psample_capture_stop pkts=$(grep -e "group 1 " $CAPTURE_FILE | wc -l) - pct=$((100 * (pkts - 100) / 100)) + pct=$((100 * (pkts - 10000) / 10000)) (( -25 <= pct && pct <= 25)) - check_err $? "Expected 100 packets, got $pkts packets, which is $pct% off. Required accuracy is +-25%" + check_err $? "Expected 10000 packets, got $pkts packets, which is $pct% off. Required accuracy is +-25%" log_test "tc sample rate ($desc)"
@@ -587,15 +587,15 @@ __tc_sample_acl_rate_test() psample_capture_start - ip vrf exec v$h1 $MZ $h1 -c 3200 -d 1msec -p 64 -A 192.0.2.1 \ + ip vrf exec v$h1 $MZ $h1 -c 320000 -d 100usec -p 64 -A 192.0.2.1 \ -B 198.51.100.1 -t udp dp=52768,sp=42768 -q psample_capture_stop pkts=$(grep -e "group 1 " $CAPTURE_FILE | wc -l) - pct=$((100 * (pkts - 100) / 100)) + pct=$((100 * (pkts - 10000) / 10000)) (( -25 <= pct && pct <= 25)) - check_err $? "Expected 100 packets, got $pkts packets, which is $pct% off. Required accuracy is +-25%" + check_err $? "Expected 10000 packets, got $pkts packets, which is $pct% off. Required accuracy is +-25%" # Setup a filter that should not match any packet and make sure packets # are not sampled.
Signature · 1 line
2.31.1
PATCH 3/11 selftests: mlxsw: qos_headroom: Convert to iproute2 dcb
In reply to Ido SchimmelFrom: Petr Machata <[email protected]>
There is a dedicated tool for configuration of DCB in iproute2 now. Use it in the selftest instead of mlnx_qos.
--- .../drivers/net/mlxsw/qos_headroom.sh | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/qos_headroom.sh +35 -34
@@ -29,37 +29,38 @@ cleanup() get_prio_pg() { - __mlnx_qos -i $swp | sed -n '/^PFC/,/^[^[:space:]]/p' | - grep buffer | sed 's/ \+/ /g' | cut -d' ' -f 2- + # Produces a string of numbers "<B0> <B1> ... <B7> ", where BX is number + # of buffer that priority X is mapped to. + dcb -j buffer show dev $swp | + jq -r '[.prio_buffer | .[] | tostring + " "] | add' } get_prio_pfc() { - __mlnx_qos -i $swp | sed -n '/^PFC/,/^[^[:space:]]/p' | - grep enabled | sed 's/ \+/ /g' | cut -d' ' -f 2- + # Produces a string of numbers "<P0> <P1> ... <P7> ", where PX denotes + # whether priority X has PFC enabled (the value is 1) or disabled (0). + dcb -j pfc show dev $swp | + jq -r '[.prio_pfc | .[] | if . then "1 " else "0 " end] | add' } get_prio_tc() { - __mlnx_qos -i $swp | sed -n '/^tc/,$p' | - awk '/^tc/ { TC = $2 } - /priority:/ { PRIO[$2]=TC } - END { - for (i in PRIO) - printf("%d ", PRIO[i]) - }' + # Produces a string of numbers "<T0> <T1> ... <T7> ", where TC is number + # of TC that priority X is mapped to. + dcb -j ets show dev $swp | + jq -r '[.prio_tc | .[] | tostring + " "] | add' } get_buf_size() { local idx=$1; shift - __mlnx_qos -i $swp | grep Receive | sed 's/.*: //' | cut -d, -f $((idx + 1)) + dcb -j buffer show dev $swp | jq ".buffer_size[$idx]" } get_tot_size() { - __mlnx_qos -i $swp | grep Receive | sed 's/.*total_size=//' + dcb -j buffer show dev $swp | jq '.total_size' } check_prio_pg()
@@ -121,18 +122,18 @@ test_dcb_ets() { RET=0 - __mlnx_qos -i $swp --prio_tc=0,2,4,6,1,3,5,7 > /dev/null + dcb ets set dev $swp prio-tc 0:0 1:2 2:4 3:6 4:1 5:3 6:5 7:7 check_prio_pg "0 2 4 6 1 3 5 7 " check_prio_tc "0 2 4 6 1 3 5 7 " check_prio_pfc "0 0 0 0 0 0 0 0 " - __mlnx_qos -i $swp --prio_tc=0,0,0,0,0,0,0,0 > /dev/null + dcb ets set dev $swp prio-tc all:0 check_prio_pg "0 0 0 0 0 0 0 0 " check_prio_tc "0 0 0 0 0 0 0 0 " - __mlnx_qos -i $swp --prio2buffer=1,3,5,7,0,2,4,6 &> /dev/null + dcb buffer set dev $swp prio-buffer 0:1 1:3 2:5 3:7 4:0 5:2 6:4 7:6 2>/dev/null check_fail $? "prio2buffer accepted in DCB mode" log_test "Configuring headroom through ETS"
@@ -174,7 +175,7 @@ test_pfc() { RET=0 - __mlnx_qos -i $swp --prio_tc=0,0,0,0,0,1,2,3 > /dev/null + dcb ets set dev $swp prio-tc all:0 5:1 6:2 7:3 local buf0size=$(get_buf_size 0) local buf1size=$(get_buf_size 1)
@@ -193,7 +194,7 @@ test_pfc() RET=0 - __mlnx_qos -i $swp --pfc=0,0,0,0,0,1,1,1 --cable_len=0 > /dev/null + dcb pfc set dev $swp prio-pfc all:off 5:on 6:on 7:on delay 0 check_prio_pg "0 0 0 0 0 1 2 3 " check_prio_pfc "0 0 0 0 0 1 1 1 "
@@ -210,7 +211,7 @@ test_pfc() RET=0 - __mlnx_qos -i $swp --pfc=0,0,0,0,0,1,1,1 --cable_len=1000 > /dev/null + dcb pfc set dev $swp delay 1000 check_buf_size 0 "== $buf0size" check_buf_size 1 "> $buf1size"
@@ -221,8 +222,8 @@ test_pfc() RET=0 - __mlnx_qos -i $swp --pfc=0,0,0,0,0,0,0,0 --cable_len=0 > /dev/null - __mlnx_qos -i $swp --prio_tc=0,0,0,0,0,0,0,0 > /dev/null + dcb pfc set dev $swp prio-pfc all:off delay 0 + dcb ets set dev $swp prio-tc all:0 check_prio_pg "0 0 0 0 0 0 0 0 " check_prio_tc "0 0 0 0 0 0 0 0 "
@@ -242,13 +243,13 @@ test_tc_priomap() { RET=0 - __mlnx_qos -i $swp --prio_tc=0,1,2,3,4,5,6,7 > /dev/null + dcb ets set dev $swp prio-tc 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7 check_prio_pg "0 1 2 3 4 5 6 7 " tc qdisc replace dev $swp root handle 1: bfifo limit 1.5M check_prio_pg "0 0 0 0 0 0 0 0 " - __mlnx_qos -i $swp --prio2buffer=1,3,5,7,0,2,4,6 > /dev/null + dcb buffer set dev $swp prio-buffer 0:1 1:3 2:5 3:7 4:0 5:2 6:4 7:6 check_prio_pg "1 3 5 7 0 2 4 6 " tc qdisc delete dev $swp root
@@ -256,9 +257,9 @@ test_tc_priomap() # Clean up. tc qdisc replace dev $swp root handle 1: bfifo limit 1.5M - __mlnx_qos -i $swp --prio2buffer=0,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp prio-buffer all:0 tc qdisc delete dev $swp root - __mlnx_qos -i $swp --prio_tc=0,0,0,0,0,0,0,0 > /dev/null + dcb ets set dev $swp prio-tc all:0 log_test "TC: priomap" }
@@ -270,12 +271,12 @@ test_tc_sizes() RET=0 - __mlnx_qos -i $swp --buffer_size=$size,0,0,0,0,0,0,0 &> /dev/null + dcb buffer set dev $swp buffer-size all:0 0:$size 2>/dev/null check_fail $? "buffer_size should fail before qdisc is added" tc qdisc replace dev $swp root handle 1: bfifo limit 1.5M - __mlnx_qos -i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 0:$size check_err $? "buffer_size should pass after qdisc is added" check_buf_size 0 "== $size" "set size: "
@@ -283,26 +284,26 @@ test_tc_sizes() check_buf_size 0 "== $size" "set MTU: " mtu_restore $swp - __mlnx_qos -i $swp --buffer_size=0,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 # After replacing the qdisc for the same kind, buffer_size still has to # work. tc qdisc replace dev $swp root handle 1: bfifo limit 1M - __mlnx_qos -i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 0:$size check_buf_size 0 "== $size" "post replace, set size: " - __mlnx_qos -i $swp --buffer_size=0,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 # Likewise after replacing for a different kind. tc qdisc replace dev $swp root handle 2: prio bands 8 - __mlnx_qos -i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 0:$size check_buf_size 0 "== $size" "post replace different kind, set size: " tc qdisc delete dev $swp root - __mlnx_qos -i $swp --buffer_size=$size,0,0,0,0,0,0,0 &> /dev/null + dcb buffer set dev $swp buffer-size all:0 0:$size 2>/dev/null check_fail $? "buffer_size should fail after qdisc is deleted" log_test "TC: buffer size"
@@ -363,10 +364,10 @@ test_tc_int_buf() tc qdisc replace dev $swp root handle 1: bfifo limit 1.5M test_int_buf "TC: " - __mlnx_qos -i $swp --buffer_size=$size,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 0:$size test_int_buf "TC+buffsize: " - __mlnx_qos -i $swp --buffer_size=0,0,0,0,0,0,0,0 > /dev/null + dcb buffer set dev $swp buffer-size all:0 tc qdisc delete dev $swp root }
Signature · 1 line
2.31.1
PATCH 4/11 selftests: mlxsw: qos_pfc: Convert to iproute2 dcb
In reply to Ido SchimmelFrom: Petr Machata <[email protected]>
There is a dedicated tool for configuration of DCB in iproute2 now. Use it in the selftest instead of mlnx_qos.
--- .../selftests/drivers/net/mlxsw/qos_pfc.sh | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh +12 -12
@@ -171,7 +171,7 @@ switch_create() # assignment. tc qdisc replace dev $swp1 root handle 1: \ ets bands 8 strict 8 priomap 7 6 - __mlnx_qos -i $swp1 --prio2buffer=0,1,0,0,0,0,0,0 >/dev/null + dcb buffer set dev $swp1 prio-buffer all:0 1:1 # $swp2 # -----
@@ -209,8 +209,8 @@ switch_create() # the lossless prio into a buffer of its own. Don't bother with buffer # sizes though, there is not going to be any pressure in the "backward" # direction. - __mlnx_qos -i $swp3 --prio2buffer=0,1,0,0,0,0,0,0 >/dev/null - __mlnx_qos -i $swp3 --pfc=0,1,0,0,0,0,0,0 >/dev/null + dcb buffer set dev $swp3 prio-buffer all:0 1:1 + dcb pfc set dev $swp3 prio-pfc all:off 1:on # $swp4 # -----
@@ -226,11 +226,11 @@ switch_create() # Configure qdisc so that we can hand-tune headroom. tc qdisc replace dev $swp4 root handle 1: \ ets bands 8 strict 8 priomap 7 6 - __mlnx_qos -i $swp4 --prio2buffer=0,1,0,0,0,0,0,0 >/dev/null - __mlnx_qos -i $swp4 --pfc=0,1,0,0,0,0,0,0 >/dev/null + dcb buffer set dev $swp4 prio-buffer all:0 1:1 + dcb pfc set dev $swp4 prio-pfc all:off 1:on # PG0 will get autoconfigured to Xoff, give PG1 arbitrarily 100K, which # is (-2*MTU) about 80K of delay provision. - __mlnx_qos -i $swp4 --buffer_size=0,$_100KB,0,0,0,0,0,0 >/dev/null + dcb buffer set dev $swp4 buffer-size all:0 1:$_100KB # bridges # -------
@@ -273,9 +273,9 @@ switch_destroy() # $swp4 # ----- - __mlnx_qos -i $swp4 --buffer_size=0,0,0,0,0,0,0,0 >/dev/null - __mlnx_qos -i $swp4 --pfc=0,0,0,0,0,0,0,0 >/dev/null - __mlnx_qos -i $swp4 --prio2buffer=0,0,0,0,0,0,0,0 >/dev/null + dcb buffer set dev $swp4 buffer-size all:0 + dcb pfc set dev $swp4 prio-pfc all:off + dcb buffer set dev $swp4 prio-buffer all:0 tc qdisc del dev $swp4 root devlink_tc_bind_pool_th_restore $swp4 1 ingress
@@ -288,8 +288,8 @@ switch_destroy() # $swp3 # ----- - __mlnx_qos -i $swp3 --pfc=0,0,0,0,0,0,0,0 >/dev/null - __mlnx_qos -i $swp3 --prio2buffer=0,0,0,0,0,0,0,0 >/dev/null + dcb pfc set dev $swp3 prio-pfc all:off + dcb buffer set dev $swp3 prio-buffer all:0 tc qdisc del dev $swp3 root devlink_tc_bind_pool_th_restore $swp3 1 egress
@@ -315,7 +315,7 @@ switch_destroy() # $swp1 # ----- - __mlnx_qos -i $swp1 --prio2buffer=0,0,0,0,0,0,0,0 >/dev/null + dcb buffer set dev $swp1 prio-buffer all:0 tc qdisc del dev $swp1 root devlink_tc_bind_pool_th_restore $swp1 1 ingress
Signature · 1 line
2.31.1
PATCH 5/11 selftests: mlxsw: qos_lib: Drop __mlnx_qos
In reply to Ido SchimmelFrom: Petr Machata <[email protected]>
Now that the two users of this helper have been converted to iproute2 dcb, it is not necessary anymore. Drop it.
--- .../testing/selftests/drivers/net/mlxsw/qos_lib.sh | 14 -------------- 1 file changed, 14 deletions(-)
tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh +0 -14
@@ -82,17 +82,3 @@ bail_on_lldpad() fi fi } - -__mlnx_qos() -{ - local err - - mlnx_qos "$@" 2>/dev/null - err=$? - - if ((err)); then - echo "Error ($err) in mlnx_qos $@" >/dev/stderr - fi - - return $err -}
Signature · 1 line
2.31.1
PATCH 6/11 mlxsw: spectrum_buffers: Switch function arguments
In reply to Ido SchimmelFrom: Danielle Ratson <[email protected]>
In the call path:
mlxsw_sp_hdroom_bufs_reset_sizes()
mlxsw_sp_hdroom_int_buf_size_get()
->int_buf_size_get()The 'speed' and 'mtu' arguments were mistakenly switched twice. The two bugs thus canceled each other.
Clean this up by switching the arguments in both call sites, so that they are passed in the right order.
Found during manual code inspection.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +3 -3
@@ -364,7 +364,7 @@ static u16 mlxsw_sp_hdroom_buf_delay_get(const struct mlxsw_sp *mlxsw_sp,static u32 mlxsw_sp_hdroom_int_buf_size_get (struct mlxsw_sp *mlxsw_sp,int mtu,u32 speed) { -u32 buffsize = mlxsw_sp->sb_ops->int_buf_size_get (speed, mtu); +u32 buffsize = mlxsw_sp->sb_ops->int_buf_size_get (mtu, speed);return mlxsw_sp_bytes_cells (mlxsw_sp, buffsize) +1 ; }
@@ -388,8 +388,8 @@ void mlxsw_sp_hdroom_bufs_reset_sizes(struct mlxsw_sp_port *mlxsw_sp_port,int i;/* Internal buffer. */ - reserve_cells =mlxsw_sp_hdroom_int_buf_size_get (mlxsw_sp, mlxsw_sp_port->max_speed, - mlxsw_sp_port->max_mtu); + reserve_cells =mlxsw_sp_hdroom_int_buf_size_get (mlxsw_sp, mlxsw_sp_port->max_mtu, + mlxsw_sp_port->max_speed); reserve_cells =mlxsw_sp_port_headroom_8x_adjust (mlxsw_sp_port, reserve_cells); hdroom->int_buf.reserve_cells = reserve_cells;
Signature · 1 line
2.31.1
PATCH 7/11 mlxsw: Verify the accessed index doesn't exceed the array length
In reply to Ido SchimmelFrom: Danielle Ratson <[email protected]>
There are few cases in which an array index queried from a fw register, is accessed without any validation that it doesn't exceed the array length.
Add a proper length validation, so accessing memory past the end of an array will be forbidden.
--- drivers/net/ethernet/mellanox/mlxsw/minimal.c | 4 ++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 5 +++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c | 3 +++ drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 3 +++ drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 4 ++++ 5 files changed, 19 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/minimal.c +4 -0
@@ -234,6 +234,7 @@ static void mlxsw_m_port_remove(struct mlxsw_m *mlxsw_m, u8 local_port)static int mlxsw_m_port_module_map (struct mlxsw_m *mlxsw_m,u8 local_port,u8 *last_module) { +unsigned int max_ports =mlxsw_core_max_ports (mlxsw_m->core);u8 module, width;int err;
@@ -249,6 +250,9 @@ static int mlxsw_m_port_module_map(struct mlxsw_m *mlxsw_m, u8 local_port,if (module == *last_module)return 0 ; *last_module = module; + +if (WARN_ON_ONCE (module >= max_ports)) +return -EINVAL ; mlxsw_m->module_to_port[module] = ++mlxsw_m->max_ports;return 0 ;
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +5 -0
@@ -2125,9 +2125,14 @@ static void mlxsw_sp_pude_event_func(const struct mlxsw_reg_info *reg,struct mlxsw_sp *mlxsw_sp = priv;struct mlxsw_sp_port *mlxsw_sp_port;enum mlxsw_reg_pude_oper_status status; +unsigned int max_ports;u8 local_port; + max_ports =mlxsw_core_max_ports (mlxsw_sp->core); local_port =mlxsw_reg_pude_local_port_get (pude_pl); + +if (WARN_ON_ONCE (local_port >= max_ports)) +return ; mlxsw_sp_port = mlxsw_sp->ports[local_port];if (!mlxsw_sp_port)return ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +3 -0
@@ -568,10 +568,13 @@ void mlxsw_sp1_ptp_got_timestamp(struct mlxsw_sp *mlxsw_sp, bool ingress, u8 domain_number, u16 sequence_id, u64 timestamp) { + unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);struct mlxsw_sp_port *mlxsw_sp_port;struct mlxsw_sp1_ptp_key key;u8 types; +if (WARN_ON_ONCE (local_port >= max_ports)) +return ; mlxsw_sp_port = mlxsw_sp->ports[local_port];if (!mlxsw_sp_port)return ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +3 -0
@@ -2282,6 +2282,7 @@ static void mlxsw_sp_router_neigh_ent_ipv4_process(struct mlxsw_sp *mlxsw_sp, char *rauhtd_pl, int ent_index) { +u64 max_rifs =MLXSW_CORE_RES_GET (mlxsw_sp->core,MAX_RIFS );struct net_device *dev;struct neighbour *n;__be32 dipn;
@@ -2290,6 +2291,8 @@ static void mlxsw_sp_router_neigh_ent_ipv4_process(struct mlxsw_sp *mlxsw_sp,mlxsw_reg_rauhtd_ent_ipv4_unpack (rauhtd_pl, ent_index, &rif, &dip); +if (WARN_ON_ONCE (rif >= max_rifs)) +return ;if (!mlxsw_sp->router->rifs[rif]) {dev_err_ratelimited (mlxsw_sp->bus_info->dev,"Incorrect RIF in neighbour entry\n" );return ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +4 -0
@@ -2520,6 +2520,7 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp, char *sfn_pl, int rec_index, bool adding) { + unsigned int max_ports = mlxsw_core_max_ports(mlxsw_sp->core);struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;struct mlxsw_sp_bridge_device *bridge_device;struct mlxsw_sp_bridge_port *bridge_port;
@@ -2532,6 +2533,9 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,int err;mlxsw_reg_sfn_mac_unpack (sfn_pl, rec_index, mac, &fid, &local_port); + +if (WARN_ON_ONCE (local_port >= max_ports)) +return ; mlxsw_sp_port = mlxsw_sp->ports[local_port];if (!mlxsw_sp_port) {dev_err_ratelimited (mlxsw_sp->bus_info->dev,"Incorrect local port in FDB notification\n" );
Signature · 1 line
2.31.1
PATCH 8/11 mlxsw: core: Avoid unnecessary EMAD buffer copy
In reply to Ido Schimmelmlxsw_emad_transmit() takes care of sending EMAD transactions to the device. Since these transactions can time out, the driver performs up to 5 retransmissions, each time copying the skb with the original request.
The data of the skb does not change throughout the process, so there is no need to copy it each time. Instead, only the skb itself can be copied. Therefore, use skb_clone() instead of skb_copy().
This reduces the latency of the function by about 16%.
--- drivers/net/ethernet/mellanox/mlxsw/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/core.c +1 -1
@@ -630,7 +630,7 @@ static int mlxsw_emad_transmit(struct mlxsw_core *mlxsw_core,struct sk_buff *skb;int err; - skb =skb_copy (trans->tx_skb,GFP_KERNEL ); + skb =skb_clone (trans->tx_skb,GFP_KERNEL );if (!skb)return -ENOMEM ;
Signature · 1 line
2.31.1
PATCH 9/11 mlxsw: spectrum_router: Avoid missing error code warning
In reply to Ido SchimmelExplicitly set the error code to zero before the goto statement to avoid the following smatch warning:
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3598 mlxsw_sp_nexthop_group_refresh() warn: missing error code 'err'
The warning is a false positive, but the change both suppresses the warning and makes it clear to future readers that this is not an error path.
The original report and discussion can be found here [1].
[1] https://lore.kernel.org/lkml/[email protected]/
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +4 -2
@@ -3844,8 +3844,8 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,bool offload_change = false;u32 adj_index;bool old_adj_index_valid; -int i, err2, err =0 ;u32 old_adj_index; +int i, err2, err;if (!nhgi->gateway)return mlxsw_sp_nexthop_fib_entries_update (mlxsw_sp, nh_grp);
@@ -3875,11 +3875,13 @@ mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp,return 0 ; }mlxsw_sp_nexthop_group_normalize (nhgi); -if (!nhgi->sum_norm_weight) +if (!nhgi->sum_norm_weight) {/* No neigh of this group is connected so we just set * the trap and let everthing flow through kernel. */ + err =0 ; goto set_trap; + } ecmp_size = nhgi->sum_norm_weight; err =mlxsw_sp_fix_adj_grp_size (mlxsw_sp, &ecmp_size);
Signature · 1 line
2.31.1
PATCH 10/11 mlxsw: Remove Mellanox SwitchIB ASIC support
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Initial support for the Mellanox SwitchIB and SwitchIB-2 ASICs was added in October 2016, but since then development of this driver stopped. Therefore, the driver does not support any offloads and simply registers devlink ports for its front panel ports, rendering it irrelevant for deployment.
Given the driver is not used by any users and that there is no intention of investing in its development, remove it from the kernel.
--- drivers/net/ethernet/mellanox/mlxsw/Kconfig | 11 - drivers/net/ethernet/mellanox/mlxsw/Makefile | 2 - drivers/net/ethernet/mellanox/mlxsw/pci.h | 2 - .../net/ethernet/mellanox/mlxsw/switchib.c | 595 ------------------ 4 files changed, 610 deletions(-) delete mode 100644 drivers/net/ethernet/mellanox/mlxsw/switchib.c
drivers/net/ethernet/mellanox/mlxsw/Kconfig +0 -11
@@ -49,17 +49,6 @@ config MLXSW_I2C To compile this driver as a module, choose M here: the module will be called mlxsw_i2c. -config MLXSW_SWITCHIB - tristate "Mellanox Technologies SwitchIB and SwitchIB-2 support" - depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV - default m - help - This driver supports Mellanox Technologies SwitchIB and SwitchIB-2 - Infiniband Switch ASICs. - - To compile this driver as a module, choose M here: the - module will be called mlxsw_switchib. - config MLXSW_SWITCHX2 tristate "Mellanox Technologies SwitchX-2 support" depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV
drivers/net/ethernet/mellanox/mlxsw/Makefile +0 -2
@@ -8,8 +8,6 @@ obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o mlxsw_pci-objs := pci.o obj-$(CONFIG_MLXSW_I2C) += mlxsw_i2c.o mlxsw_i2c-objs := i2c.o -obj-$(CONFIG_MLXSW_SWITCHIB) += mlxsw_switchib.o -mlxsw_switchib-objs := switchib.o obj-$(CONFIG_MLXSW_SWITCHX2) += mlxsw_switchx2.o mlxsw_switchx2-objs := switchx2.o obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o
drivers/net/ethernet/mellanox/mlxsw/pci.h +0 -2
@@ -10,8 +10,6 @@#define PCI_DEVICE_ID_MELLANOX_SPECTRUM 0xcb84#define PCI_DEVICE_ID_MELLANOX_SPECTRUM2 0xcf6c#define PCI_DEVICE_ID_MELLANOX_SPECTRUM3 0xcf70 -#define PCI_DEVICE_ID_MELLANOX_SWITCHIB 0xcb20 -#define PCI_DEVICE_ID_MELLANOX_SWITCHIB2 0xcf08#if IS_ENABLED (CONFIG_MLXSW_PCI )
drivers/net/ethernet/mellanox/mlxsw/switchib.c deleted +0 -595
595 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 11/11 mlxsw: Remove Mellanox SwitchX-2 ASIC support
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Initial support for the Mellanox SwitchX-2 ASIC was added in July 2015. Since then all development efforts shifted towards the Mellanox Spectrum ASICs and development of this driver stopped beside trivial fixes and refactoring. Therefore, the driver does not support any switch offloads and simply traps all traffic to the CPU, rendering it irrelevant for deployment.
In addition, support for this ASIC was dropped by Mellanox a few years ago.
Given the driver is not used by any users and that there is no intention of investing in its development, remove it from the kernel.
--- drivers/net/ethernet/mellanox/mlxsw/Kconfig | 11 - drivers/net/ethernet/mellanox/mlxsw/Makefile | 2 - drivers/net/ethernet/mellanox/mlxsw/ib.h | 9 - drivers/net/ethernet/mellanox/mlxsw/pci.c | 5 - drivers/net/ethernet/mellanox/mlxsw/pci.h | 1 - .../net/ethernet/mellanox/mlxsw/switchx2.c | 1691 ----------------- 6 files changed, 1719 deletions(-) delete mode 100644 drivers/net/ethernet/mellanox/mlxsw/ib.h delete mode 100644 drivers/net/ethernet/mellanox/mlxsw/switchx2.c
drivers/net/ethernet/mellanox/mlxsw/Kconfig +0 -11
@@ -49,17 +49,6 @@ config MLXSW_I2C To compile this driver as a module, choose M here: the module will be called mlxsw_i2c. -config MLXSW_SWITCHX2 - tristate "Mellanox Technologies SwitchX-2 support" - depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV - default m - help - This driver supports Mellanox Technologies SwitchX-2 Ethernet - Switch ASICs. - - To compile this driver as a module, choose M here: the - module will be called mlxsw_switchx2. - config MLXSW_SPECTRUM tristate "Mellanox Technologies Spectrum family support" depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && VLAN_8021Q
drivers/net/ethernet/mellanox/mlxsw/Makefile +0 -2
@@ -8,8 +8,6 @@ obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o mlxsw_pci-objs := pci.o obj-$(CONFIG_MLXSW_I2C) += mlxsw_i2c.o mlxsw_i2c-objs := i2c.o -obj-$(CONFIG_MLXSW_SWITCHX2) += mlxsw_switchx2.o -mlxsw_switchx2-objs := switchx2.o obj-$(CONFIG_MLXSW_SPECTRUM) += mlxsw_spectrum.o mlxsw_spectrum-objs := spectrum.o spectrum_buffers.o \ spectrum_switchdev.o spectrum_router.o \
drivers/net/ethernet/mellanox/mlxsw/ib.h deleted +0 -9
@@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ -/* Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved */ - -#ifndef _MLXSW_IB_H -#define _MLXSW_IB_H - -#define MLXSW_IB_DEFAULT_MTU 4096 - -#endif /* _MLXSW_IB_H */
drivers/net/ethernet/mellanox/mlxsw/pci.c +0 -5
@@ -1426,11 +1426,6 @@ static int mlxsw_pci_sys_ready_wait(struct mlxsw_pci *mlxsw_pci,unsigned long end;u32 val; -if (id->device ==PCI_DEVICE_ID_MELLANOX_SWITCHX2 ) { -msleep (MLXSW_PCI_SW_RESET_TIMEOUT_MSECS ); -return 0 ; - } -/* We must wait for the HW to become responsive. */ msleep (MLXSW_PCI_SW_RESET_WAIT_MSECS );
drivers/net/ethernet/mellanox/mlxsw/pci.h +0 -1
@@ -6,7 +6,6 @@#include <linux/pci.h> -#define PCI_DEVICE_ID_MELLANOX_SWITCHX2 0xc738#define PCI_DEVICE_ID_MELLANOX_SPECTRUM 0xcb84#define PCI_DEVICE_ID_MELLANOX_SPECTRUM2 0xcf6c#define PCI_DEVICE_ID_MELLANOX_SPECTRUM3 0xcf70
drivers/net/ethernet/mellanox/mlxsw/switchx2.c deleted +0 -1691
1,691 lines not on this page · raw message
Signature · 1 line
2.31.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Mon, 17 May 2021 20:03:50 +0300 you wrote:
This patchset contains various updates to the mlxsw driver and related selftests.
Patches #1-#5 contain various updates to mlxsw selftests. The most significant change is the conversion of the DCB selftests to use the new iproute2 DCB support.
[...]
Here is the summary with links:
- [net-next,01/11] selftests: mlxsw: Make the unsplit array global in port_scale test
https://git.kernel.org/netdev/net-next/c/5d01071e64b6 - [net-next,02/11] selftests: mlxsw: Make sampling test more robust https://git.kernel.org/netdev/net-next/c/16355c0b101e - [net-next,03/11] selftests: mlxsw: qos_headroom: Convert to iproute2 dcb https://git.kernel.org/netdev/net-next/c/9a1cac062d3e - [net-next,04/11] selftests: mlxsw: qos_pfc: Convert to iproute2 dcb https://git.kernel.org/netdev/net-next/c/b0bab2298ec9 - [net-next,05/11] selftests: mlxsw: qos_lib: Drop __mlnx_qos https://git.kernel.org/netdev/net-next/c/b4d786941b58 - [net-next,06/11] mlxsw: spectrum_buffers: Switch function arguments https://git.kernel.org/netdev/net-next/c/ece5df874d3a - [net-next,07/11] mlxsw: Verify the accessed index doesn't exceed the array length https://git.kernel.org/netdev/net-next/c/837ec05cfea0 - [net-next,08/11] mlxsw: core: Avoid unnecessary EMAD buffer copy https://git.kernel.org/netdev/net-next/c/8c2b58e65d01 - [net-next,09/11] mlxsw: spectrum_router: Avoid missing error code warning https://git.kernel.org/netdev/net-next/c/51746a353b44 - [net-next,10/11] mlxsw: Remove Mellanox SwitchIB ASIC support https://git.kernel.org/netdev/net-next/c/9b43fbb8ce24 - [net-next,11/11] mlxsw: Remove Mellanox SwitchX-2 ASIC support https://git.kernel.org/netdev/net-next/c/b0d80c013b04
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html