Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'ethtool-mm-api-consolidation'

Vladimir Oltean says:

====================
ethtool mm API consolidation

This series consolidates the behavior of the 2 drivers that implement
the ethtool MAC Merge layer by making NXP ENETC commit its preemptible
traffic classes to hardware only when MM TX is active (same as Ocelot).

Then, after resolving an issue with the ENETC driver, it restricts user
space from entering 2 states which don't make sense:

- pmac-enabled off tx-enabled on verify-enabled *
- pmac-enabled * tx-enabled off verify-enabled on

Then, it introduces a selftest (ethtool_mm.sh) which puts everything
together and tests all valid configurations known to me.

This is simultaneously the v2 of "[PATCH net-next 0/2] ethtool mm API
improvements":
https://lore.kernel.org/netdev/20230415173454.3970647-1-vladimir.oltean@nxp.com/
which had caused some problems to openlldp. Those were solved in the
meantime, see:
https://github.com/intel/openlldp/commit/11171b474f6f3cbccac5d608b7f26b32ff72c651

and of "[RFC PATCH net-next] selftests: forwarding: add a test for MAC
Merge layer":
https://lore.kernel.org/netdev/20230210221243.228932-1-vladimir.oltean@nxp.com/
====================

Link: https://lore.kernel.org/r/20230418111459.811553-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+486 -66
+6 -17
drivers/net/ethernet/freescale/enetc/enetc.c
··· 25 25 } 26 26 EXPORT_SYMBOL_GPL(enetc_port_mac_wr); 27 27 28 - void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs) 28 + static void enetc_change_preemptible_tcs(struct enetc_ndev_priv *priv, 29 + u8 preemptible_tcs) 29 30 { 30 - u32 val; 31 - int tc; 32 - 33 - for (tc = 0; tc < 8; tc++) { 34 - val = enetc_port_rd(hw, ENETC_PTCFPR(tc)); 35 - 36 - if (preemptible_tcs & BIT(tc)) 37 - val |= ENETC_PTCFPR_FPE; 38 - else 39 - val &= ~ENETC_PTCFPR_FPE; 40 - 41 - enetc_port_wr(hw, ENETC_PTCFPR(tc), val); 42 - } 31 + priv->preemptible_tcs = preemptible_tcs; 32 + enetc_mm_commit_preemptible_tcs(priv); 43 33 } 44 - EXPORT_SYMBOL_GPL(enetc_set_ptcfpr); 45 34 46 35 static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) 47 36 { ··· 2648 2659 2649 2660 enetc_debug_tx_ring_prios(priv); 2650 2661 2651 - enetc_set_ptcfpr(hw, 0); 2662 + enetc_change_preemptible_tcs(priv, 0); 2652 2663 } 2653 2664 2654 2665 int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) ··· 2703 2714 2704 2715 enetc_debug_tx_ring_prios(priv); 2705 2716 2706 - enetc_set_ptcfpr(hw, mqprio->preemptible_tcs); 2717 + enetc_change_preemptible_tcs(priv, mqprio->preemptible_tcs); 2707 2718 2708 2719 return 0; 2709 2720
+4 -1
drivers/net/ethernet/freescale/enetc/enetc.h
··· 355 355 u16 rx_bd_count, tx_bd_count; 356 356 357 357 u16 msg_enable; 358 + 359 + u8 preemptible_tcs; 360 + 358 361 enum enetc_active_offloads active_offloads; 359 362 360 363 u32 speed; /* store speed for compare update pspeed */ ··· 436 433 /* ethtool */ 437 434 void enetc_set_ethtool_ops(struct net_device *ndev); 438 435 void enetc_mm_link_state_update(struct enetc_ndev_priv *priv, bool link); 436 + void enetc_mm_commit_preemptible_tcs(struct enetc_ndev_priv *priv); 439 437 440 438 /* control buffer descriptor ring (CBDR) */ 441 439 int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, ··· 490 486 491 487 void enetc_reset_ptcmsdur(struct enetc_hw *hw); 492 488 void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu); 493 - void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs); 494 489 495 490 #ifdef CONFIG_FSL_ENETC_QOS 496 491 int enetc_qos_query_caps(struct net_device *ndev, void *type_data);
+89 -5
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
··· 32 32 ENETC_PM0_CMD_CFG, ENETC_PM0_MAXFRM, ENETC_PM0_IF_MODE 33 33 }; 34 34 35 + static const u32 enetc_port_mm_regs[] = { 36 + ENETC_MMCSR, ENETC_PFPMR, ENETC_PTCFPR(0), ENETC_PTCFPR(1), 37 + ENETC_PTCFPR(2), ENETC_PTCFPR(3), ENETC_PTCFPR(4), ENETC_PTCFPR(5), 38 + ENETC_PTCFPR(6), ENETC_PTCFPR(7), 39 + }; 40 + 35 41 static int enetc_get_reglen(struct net_device *ndev) 36 42 { 37 43 struct enetc_ndev_priv *priv = netdev_priv(ndev); ··· 50 44 51 45 if (hw->port) 52 46 len += ARRAY_SIZE(enetc_port_regs); 47 + 48 + if (hw->port && !!(priv->si->hw_features & ENETC_SI_F_QBU)) 49 + len += ARRAY_SIZE(enetc_port_mm_regs); 53 50 54 51 len *= sizeof(u32) * 2; /* store 2 entries per reg: addr and value */ 55 52 ··· 98 89 addr = ENETC_PORT_BASE + enetc_port_regs[i]; 99 90 *buf++ = addr; 100 91 *buf++ = enetc_rd(hw, addr); 92 + } 93 + 94 + if (priv->si->hw_features & ENETC_SI_F_QBU) { 95 + for (i = 0; i < ARRAY_SIZE(enetc_port_mm_regs); i++) { 96 + addr = ENETC_PORT_BASE + enetc_port_mm_regs[i]; 97 + *buf++ = addr; 98 + *buf++ = enetc_rd(hw, addr); 99 + } 101 100 } 102 101 } 103 102 ··· 993 976 lafs = ENETC_MMCSR_GET_LAFS(val); 994 977 state->rx_min_frag_size = ethtool_mm_frag_size_add_to_min(lafs); 995 978 state->tx_enabled = !!(val & ENETC_MMCSR_LPE); /* mirror of MMCSR_ME */ 996 - state->tx_active = !!(val & ENETC_MMCSR_LPA); 979 + state->tx_active = state->tx_enabled && 980 + (state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED || 981 + state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED); 997 982 state->verify_enabled = !(val & ENETC_MMCSR_VDIS); 998 983 state->verify_time = ENETC_MMCSR_GET_VT(val); 999 984 /* A verifyTime of 128 ms would exceed the 7 bit width ··· 1006 987 mutex_unlock(&priv->mm_lock); 1007 988 1008 989 return 0; 990 + } 991 + 992 + static int enetc_mm_wait_tx_active(struct enetc_hw *hw, int verify_time) 993 + { 994 + int timeout = verify_time * USEC_PER_MSEC * ENETC_MM_VERIFY_RETRIES; 995 + u32 val; 996 + 997 + /* This will time out after the standard value of 3 verification 998 + * attempts. To not sleep forever, it relies on a non-zero verify_time, 999 + * guarantee which is provided by the ethtool nlattr policy. 1000 + */ 1001 + return read_poll_timeout(enetc_port_rd, val, 1002 + ENETC_MMCSR_GET_VSTS(val) == 3, 1003 + ENETC_MM_VERIFY_SLEEP_US, timeout, 1004 + true, hw, ENETC_MMCSR); 1005 + } 1006 + 1007 + static void enetc_set_ptcfpr(struct enetc_hw *hw, u8 preemptible_tcs) 1008 + { 1009 + u32 val; 1010 + int tc; 1011 + 1012 + for (tc = 0; tc < 8; tc++) { 1013 + val = enetc_port_rd(hw, ENETC_PTCFPR(tc)); 1014 + 1015 + if (preemptible_tcs & BIT(tc)) 1016 + val |= ENETC_PTCFPR_FPE; 1017 + else 1018 + val &= ~ENETC_PTCFPR_FPE; 1019 + 1020 + enetc_port_wr(hw, ENETC_PTCFPR(tc), val); 1021 + } 1022 + } 1023 + 1024 + /* ENETC does not have an IRQ to notify changes to the MAC Merge TX status 1025 + * (active/inactive), but the preemptible traffic classes should only be 1026 + * committed to hardware once TX is active. Resort to polling. 1027 + */ 1028 + void enetc_mm_commit_preemptible_tcs(struct enetc_ndev_priv *priv) 1029 + { 1030 + struct enetc_hw *hw = &priv->si->hw; 1031 + u8 preemptible_tcs = 0; 1032 + u32 val; 1033 + int err; 1034 + 1035 + val = enetc_port_rd(hw, ENETC_MMCSR); 1036 + if (!(val & ENETC_MMCSR_ME)) 1037 + goto out; 1038 + 1039 + if (!(val & ENETC_MMCSR_VDIS)) { 1040 + err = enetc_mm_wait_tx_active(hw, ENETC_MMCSR_GET_VT(val)); 1041 + if (err) 1042 + goto out; 1043 + } 1044 + 1045 + preemptible_tcs = priv->preemptible_tcs; 1046 + out: 1047 + enetc_set_ptcfpr(hw, preemptible_tcs); 1009 1048 } 1010 1049 1011 1050 /* FIXME: Workaround for the link partner's verification failing if ENETC ··· 1118 1041 else 1119 1042 priv->active_offloads &= ~ENETC_F_QBU; 1120 1043 1121 - /* If link is up, enable MAC Merge right away */ 1122 - if (!!(priv->active_offloads & ENETC_F_QBU) && 1123 - !(val & ENETC_MMCSR_LINK_FAIL)) 1124 - val |= ENETC_MMCSR_ME; 1044 + /* If link is up, enable/disable MAC Merge right away */ 1045 + if (!(val & ENETC_MMCSR_LINK_FAIL)) { 1046 + if (!!(priv->active_offloads & ENETC_F_QBU)) 1047 + val |= ENETC_MMCSR_ME; 1048 + else 1049 + val &= ~ENETC_MMCSR_ME; 1050 + } 1125 1051 1126 1052 val &= ~ENETC_MMCSR_VT_MASK; 1127 1053 val |= ENETC_MMCSR_VT(cfg->verify_time); ··· 1135 1055 enetc_port_wr(hw, ENETC_MMCSR, val); 1136 1056 1137 1057 enetc_restart_emac_rx(priv->si); 1058 + 1059 + enetc_mm_commit_preemptible_tcs(priv); 1138 1060 1139 1061 mutex_unlock(&priv->mm_lock); 1140 1062 ··· 1170 1088 } 1171 1089 1172 1090 enetc_port_wr(hw, ENETC_MMCSR, val); 1091 + 1092 + enetc_mm_commit_preemptible_tcs(priv); 1173 1093 1174 1094 mutex_unlock(&priv->mm_lock); 1175 1095 }
+3
drivers/net/ethernet/freescale/enetc/enetc_hw.h
··· 3 3 4 4 #include <linux/bitops.h> 5 5 6 + #define ENETC_MM_VERIFY_SLEEP_US USEC_PER_MSEC 7 + #define ENETC_MM_VERIFY_RETRIES 3 8 + 6 9 /* ENETC device IDs */ 7 10 #define ENETC_DEV_ID_PF 0xe100 8 11 #define ENETC_DEV_ID_VF 0xef00
+10
net/ethtool/mm.c
··· 214 214 return -ERANGE; 215 215 } 216 216 217 + if (cfg.verify_enabled && !cfg.tx_enabled) { 218 + NL_SET_ERR_MSG(extack, "Verification requires TX enabled"); 219 + return -EINVAL; 220 + } 221 + 222 + if (cfg.tx_enabled && !cfg.pmac_enabled) { 223 + NL_SET_ERR_MSG(extack, "TX enabled requires pMAC enabled"); 224 + return -EINVAL; 225 + } 226 + 217 227 ret = dev->ethtool_ops->set_mm(dev, &cfg, extack); 218 228 return ret < 0 ? ret : 1; 219 229 }
+1 -2
tools/testing/selftests/drivers/net/mlxsw/qos_headroom.sh
··· 18 18 NUM_NETIFS=0 19 19 source $lib_dir/lib.sh 20 20 source $lib_dir/devlink_lib.sh 21 - source qos_lib.sh 22 21 23 22 swp=$NETIF_NO_CABLE 24 23 ··· 370 371 tc qdisc delete dev $swp root 371 372 } 372 373 373 - bail_on_lldpad 374 + bail_on_lldpad "configure DCB" "configure Qdiscs" 374 375 375 376 trap cleanup EXIT 376 377 setup_wait
-28
tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh
··· 54 54 echo $ir $er 55 55 return $ret 56 56 } 57 - 58 - bail_on_lldpad() 59 - { 60 - if systemctl is-active --quiet lldpad; then 61 - 62 - cat >/dev/stderr <<-EOF 63 - WARNING: lldpad is running 64 - 65 - lldpad will likely configure DCB, and this test will 66 - configure Qdiscs. mlxsw does not support both at the 67 - same time, one of them is arbitrarily going to overwrite 68 - the other. That will cause spurious failures (or, 69 - unlikely, passes) of this test. 70 - EOF 71 - 72 - if [[ -z $ALLOW_LLDPAD ]]; then 73 - cat >/dev/stderr <<-EOF 74 - 75 - If you want to run the test anyway, please set 76 - an environment variable ALLOW_LLDPAD to a 77 - non-empty string. 78 - EOF 79 - exit 1 80 - else 81 - return 82 - fi 83 - fi 84 - }
+1 -2
tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh
··· 79 79 NUM_NETIFS=6 80 80 source $lib_dir/lib.sh 81 81 source $lib_dir/devlink_lib.sh 82 - source qos_lib.sh 83 82 84 83 _1KB=1000 85 84 _100KB=$((100 * _1KB)) ··· 392 393 log_test "PFC" 393 394 } 394 395 395 - bail_on_lldpad 396 + bail_on_lldpad "configure DCB" "configure Qdiscs" 396 397 397 398 trap cleanup EXIT 398 399 setup_prepare
+1 -2
tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh
··· 5 5 lib_dir=$(dirname $0)/../../../net/forwarding 6 6 source $lib_dir/sch_ets_core.sh 7 7 source $lib_dir/devlink_lib.sh 8 - source qos_lib.sh 9 8 10 9 ALL_TESTS=" 11 10 ping_ipv4 ··· 77 78 done 78 79 } 79 80 80 - bail_on_lldpad 81 + bail_on_lldpad "configure DCB" "configure Qdiscs" 81 82 ets_run
-1
tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh
··· 74 74 source $lib_dir/lib.sh 75 75 source $lib_dir/devlink_lib.sh 76 76 source mlxsw_lib.sh 77 - source qos_lib.sh 78 77 79 78 ipaddr() 80 79 {
+1 -1
tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh
··· 166 166 uninstall_qdisc 167 167 } 168 168 169 - bail_on_lldpad 169 + bail_on_lldpad "configure DCB" "configure Qdiscs" 170 170 171 171 trap cleanup EXIT 172 172 setup_prepare
+1 -1
tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh
··· 73 73 uninstall_qdisc 74 74 } 75 75 76 - bail_on_lldpad 76 + bail_on_lldpad "configure DCB" "configure Qdiscs" 77 77 78 78 trap cleanup EXIT 79 79 setup_prepare
+4 -2
tools/testing/selftests/drivers/net/mlxsw/sch_tbf_ets.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - source qos_lib.sh 5 - bail_on_lldpad 4 + sch_tbf_pre_hook() 5 + { 6 + bail_on_lldpad "configure DCB" "configure Qdiscs" 7 + } 6 8 7 9 lib_dir=$(dirname $0)/../../../net/forwarding 8 10 TCFLAGS=skip_sw
+4 -2
tools/testing/selftests/drivers/net/mlxsw/sch_tbf_prio.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - source qos_lib.sh 5 - bail_on_lldpad 4 + sch_tbf_pre_hook() 5 + { 6 + bail_on_lldpad "configure DCB" "configure Qdiscs" 7 + } 6 8 7 9 lib_dir=$(dirname $0)/../../../net/forwarding 8 10 TCFLAGS=skip_sw
+4 -2
tools/testing/selftests/drivers/net/mlxsw/sch_tbf_root.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - source qos_lib.sh 5 - bail_on_lldpad 4 + sch_tbf_pre_hook() 5 + { 6 + bail_on_lldpad "configure DCB" "configure Qdiscs" 7 + } 6 8 7 9 lib_dir=$(dirname $0)/../../../net/forwarding 8 10 TCFLAGS=skip_sw
+1
tools/testing/selftests/net/forwarding/Makefile
··· 15 15 custom_multipath_hash.sh \ 16 16 dual_vxlan_bridge.sh \ 17 17 ethtool_extended_state.sh \ 18 + ethtool_mm.sh \ 18 19 ethtool.sh \ 19 20 gre_custom_multipath_hash.sh \ 20 21 gre_inner_v4_multipath.sh \
+288
tools/testing/selftests/net/forwarding/ethtool_mm.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + ALL_TESTS=" 5 + manual_with_verification_h1_to_h2 6 + manual_with_verification_h2_to_h1 7 + manual_without_verification_h1_to_h2 8 + manual_without_verification_h2_to_h1 9 + manual_failed_verification_h1_to_h2 10 + manual_failed_verification_h2_to_h1 11 + lldp 12 + " 13 + 14 + NUM_NETIFS=2 15 + REQUIRE_MZ=no 16 + PREEMPTIBLE_PRIO=0 17 + source lib.sh 18 + 19 + traffic_test() 20 + { 21 + local if=$1; shift 22 + local src=$1; shift 23 + local num_pkts=10000 24 + local before= 25 + local after= 26 + local delta= 27 + 28 + before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src) 29 + 30 + $MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO 31 + 32 + after=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src) 33 + 34 + delta=$((after - before)) 35 + 36 + # Allow an extra 1% tolerance for random packets sent by the stack 37 + [ $delta -ge $num_pkts ] && [ $delta -le $((num_pkts + 100)) ] 38 + } 39 + 40 + manual_with_verification() 41 + { 42 + local tx=$1; shift 43 + local rx=$1; shift 44 + 45 + RET=0 46 + 47 + # It isn't completely clear from IEEE 802.3-2018 Figure 99-5: Transmit 48 + # Processing state diagram whether the "send_r" variable (send response 49 + # to verification frame) should be taken into consideration while the 50 + # MAC Merge TX direction is disabled. That being said, at least the 51 + # NXP ENETC does not, and requires tx-enabled on in order to respond to 52 + # the link partner's verification frames. 53 + ethtool --set-mm $rx tx-enabled on 54 + ethtool --set-mm $tx verify-enabled on tx-enabled on 55 + 56 + # Wait for verification to finish 57 + sleep 1 58 + 59 + ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \ 60 + grep -q 'SUCCEEDED' 61 + check_err "$?" "Verification did not succeed" 62 + 63 + ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true' 64 + check_err "$?" "pMAC TX is not active" 65 + 66 + traffic_test $tx "pmac" 67 + check_err "$?" "Traffic did not get sent through $tx's pMAC" 68 + 69 + ethtool --set-mm $tx verify-enabled off tx-enabled off 70 + ethtool --set-mm $rx tx-enabled off 71 + 72 + log_test "Manual configuration with verification: $tx to $rx" 73 + } 74 + 75 + manual_with_verification_h1_to_h2() 76 + { 77 + manual_with_verification $h1 $h2 78 + } 79 + 80 + manual_with_verification_h2_to_h1() 81 + { 82 + manual_with_verification $h2 $h1 83 + } 84 + 85 + manual_without_verification() 86 + { 87 + local tx=$1; shift 88 + local rx=$1; shift 89 + 90 + RET=0 91 + 92 + ethtool --set-mm $tx verify-enabled off tx-enabled on 93 + 94 + ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \ 95 + grep -q 'DISABLED' 96 + check_err "$?" "Verification is not disabled" 97 + 98 + ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true' 99 + check_err "$?" "pMAC TX is not active" 100 + 101 + traffic_test $tx "pmac" 102 + check_err "$?" "Traffic did not get sent through $tx's pMAC" 103 + 104 + ethtool --set-mm $tx verify-enabled off tx-enabled off 105 + 106 + log_test "Manual configuration without verification: $tx to $rx" 107 + } 108 + 109 + manual_without_verification_h1_to_h2() 110 + { 111 + manual_without_verification $h1 $h2 112 + } 113 + 114 + manual_without_verification_h2_to_h1() 115 + { 116 + manual_without_verification $h2 $h1 117 + } 118 + 119 + manual_failed_verification() 120 + { 121 + local tx=$1; shift 122 + local rx=$1; shift 123 + 124 + RET=0 125 + 126 + ethtool --set-mm $rx pmac-enabled off 127 + ethtool --set-mm $tx verify-enabled on tx-enabled on 128 + 129 + # Wait for verification to time out 130 + sleep 1 131 + 132 + ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \ 133 + grep -q 'SUCCEEDED' 134 + check_fail "$?" "Verification succeeded when it shouldn't have" 135 + 136 + ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true' 137 + check_fail "$?" "pMAC TX is active when it shouldn't have" 138 + 139 + traffic_test $tx "emac" 140 + check_err "$?" "Traffic did not get sent through $tx's eMAC" 141 + 142 + ethtool --set-mm $tx verify-enabled off tx-enabled off 143 + ethtool --set-mm $rx pmac-enabled on 144 + 145 + log_test "Manual configuration with failed verification: $tx to $rx" 146 + } 147 + 148 + manual_failed_verification_h1_to_h2() 149 + { 150 + manual_failed_verification $h1 $h2 151 + } 152 + 153 + manual_failed_verification_h2_to_h1() 154 + { 155 + manual_failed_verification $h2 $h1 156 + } 157 + 158 + lldp_change_add_frag_size() 159 + { 160 + local add_frag_size=$1 161 + 162 + lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null 163 + # Wait for TLVs to be received 164 + sleep 2 165 + lldptool -i $h2 -t -n -V addEthCaps | \ 166 + grep -q "Additional fragment size: $add_frag_size" 167 + } 168 + 169 + lldp() 170 + { 171 + RET=0 172 + 173 + systemctl start lldpad 174 + 175 + # Configure the interfaces to receive and transmit LLDPDUs 176 + lldptool -L -i $h1 adminStatus=rxtx >/dev/null 177 + lldptool -L -i $h2 adminStatus=rxtx >/dev/null 178 + 179 + # Enable the transmission of Additional Ethernet Capabilities TLV 180 + lldptool -T -i $h1 -V addEthCaps enableTx=yes >/dev/null 181 + lldptool -T -i $h2 -V addEthCaps enableTx=yes >/dev/null 182 + 183 + # Wait for TLVs to be received 184 + sleep 2 185 + 186 + lldptool -i $h1 -t -n -V addEthCaps | \ 187 + grep -q "Preemption capability active" 188 + check_err "$?" "$h1 pMAC TX is not active" 189 + 190 + lldptool -i $h2 -t -n -V addEthCaps | \ 191 + grep -q "Preemption capability active" 192 + check_err "$?" "$h2 pMAC TX is not active" 193 + 194 + lldp_change_add_frag_size 3 195 + check_err "$?" "addFragSize 3" 196 + 197 + lldp_change_add_frag_size 2 198 + check_err "$?" "addFragSize 2" 199 + 200 + lldp_change_add_frag_size 1 201 + check_err "$?" "addFragSize 1" 202 + 203 + lldp_change_add_frag_size 0 204 + check_err "$?" "addFragSize 0" 205 + 206 + traffic_test $h1 "pmac" 207 + check_err "$?" "Traffic did not get sent through $h1's pMAC" 208 + 209 + traffic_test $h2 "pmac" 210 + check_err "$?" "Traffic did not get sent through $h2's pMAC" 211 + 212 + systemctl stop lldpad 213 + 214 + log_test "LLDP" 215 + } 216 + 217 + h1_create() 218 + { 219 + ip link set dev $h1 up 220 + 221 + tc qdisc add dev $h1 root mqprio num_tc 4 map 0 1 2 3 \ 222 + queues 1@0 1@1 1@2 1@3 \ 223 + fp P E E E \ 224 + hw 1 225 + 226 + ethtool --set-mm $h1 pmac-enabled on tx-enabled off verify-enabled off 227 + } 228 + 229 + h2_create() 230 + { 231 + ip link set dev $h2 up 232 + 233 + ethtool --set-mm $h2 pmac-enabled on tx-enabled off verify-enabled off 234 + 235 + tc qdisc add dev $h2 root mqprio num_tc 4 map 0 1 2 3 \ 236 + queues 1@0 1@1 1@2 1@3 \ 237 + fp P E E E \ 238 + hw 1 239 + } 240 + 241 + h1_destroy() 242 + { 243 + ethtool --set-mm $h1 pmac-enabled off tx-enabled off verify-enabled off 244 + 245 + tc qdisc del dev $h1 root 246 + 247 + ip link set dev $h1 down 248 + } 249 + 250 + h2_destroy() 251 + { 252 + tc qdisc del dev $h2 root 253 + 254 + ethtool --set-mm $h2 pmac-enabled off tx-enabled off verify-enabled off 255 + 256 + ip link set dev $h2 down 257 + } 258 + 259 + setup_prepare() 260 + { 261 + check_ethtool_mm_support 262 + check_tc_fp_support 263 + require_command lldptool 264 + bail_on_lldpad "autoconfigure the MAC Merge layer" "configure it manually" 265 + 266 + h1=${NETIFS[p1]} 267 + h2=${NETIFS[p2]} 268 + 269 + h1_create 270 + h2_create 271 + } 272 + 273 + cleanup() 274 + { 275 + pre_cleanup 276 + 277 + h2_destroy 278 + h1_destroy 279 + } 280 + 281 + trap cleanup EXIT 282 + 283 + setup_prepare 284 + setup_wait 285 + 286 + tests_run 287 + 288 + exit $EXIT_STATUS
+60
tools/testing/selftests/net/forwarding/lib.sh
··· 120 120 fi 121 121 } 122 122 123 + check_tc_fp_support() 124 + { 125 + tc qdisc add dev lo mqprio help 2>&1 | grep -q "fp " 126 + if [[ $? -ne 0 ]]; then 127 + echo "SKIP: iproute2 too old; tc is missing frame preemption support" 128 + exit $ksft_skip 129 + fi 130 + } 131 + 123 132 check_ethtool_lanes_support() 124 133 { 125 134 ethtool --help 2>&1| grep lanes &> /dev/null 126 135 if [[ $? -ne 0 ]]; then 127 136 echo "SKIP: ethtool too old; it is missing lanes support" 137 + exit $ksft_skip 138 + fi 139 + } 140 + 141 + check_ethtool_mm_support() 142 + { 143 + ethtool --help 2>&1| grep -- '--show-mm' &> /dev/null 144 + if [[ $? -ne 0 ]]; then 145 + echo "SKIP: ethtool too old; it is missing MAC Merge layer support" 128 146 exit $ksft_skip 129 147 fi 130 148 } ··· 803 785 local stat=$1; shift 804 786 805 787 ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2 788 + } 789 + 790 + ethtool_std_stats_get() 791 + { 792 + local dev=$1; shift 793 + local grp=$1; shift 794 + local name=$1; shift 795 + local src=$1; shift 796 + 797 + ethtool --json -S $dev --groups $grp -- --src $src | \ 798 + jq '.[]."'"$grp"'"."'$name'"' 806 799 } 807 800 808 801 qdisc_stats_get() ··· 1915 1886 local checksum=$(payload_template_calc_checksum ${sudohdr}${icmpv6}) 1916 1887 1917 1888 payload_template_expand_checksum "$hbh$icmpv6" $checksum 1889 + } 1890 + 1891 + bail_on_lldpad() 1892 + { 1893 + local reason1="$1"; shift 1894 + local reason2="$1"; shift 1895 + 1896 + if systemctl is-active --quiet lldpad; then 1897 + 1898 + cat >/dev/stderr <<-EOF 1899 + WARNING: lldpad is running 1900 + 1901 + lldpad will likely $reason1, and this test will 1902 + $reason2. Both are not supported at the same time, 1903 + one of them is arbitrarily going to overwrite the 1904 + other. That will cause spurious failures (or, unlikely, 1905 + passes) of this test. 1906 + EOF 1907 + 1908 + if [[ -z $ALLOW_LLDPAD ]]; then 1909 + cat >/dev/stderr <<-EOF 1910 + 1911 + If you want to run the test anyway, please set 1912 + an environment variable ALLOW_LLDPAD to a 1913 + non-empty string. 1914 + EOF 1915 + exit 1 1916 + else 1917 + return 1918 + fi 1919 + fi 1918 1920 }
+4
tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh
··· 57 57 tc qdisc del dev $swp2 root 58 58 } 59 59 60 + if type -t sch_tbf_pre_hook >/dev/null; then 61 + sch_tbf_pre_hook 62 + fi 63 + 60 64 trap cleanup EXIT 61 65 62 66 setup_prepare
+4
tools/testing/selftests/net/forwarding/sch_tbf_root.sh
··· 23 23 tc qdisc del dev $swp2 root 24 24 } 25 25 26 + if type -t sch_tbf_pre_hook >/dev/null; then 27 + sch_tbf_pre_hook 28 + fi 29 + 26 30 trap cleanup EXIT 27 31 28 32 setup_prepare