Commit b7b871f5 authored by Jakub Kicinski's avatar Jakub Kicinski

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.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 787e6144 e6991384
...@@ -25,23 +25,12 @@ void enetc_port_mac_wr(struct enetc_si *si, u32 reg, u32 val) ...@@ -25,23 +25,12 @@ void enetc_port_mac_wr(struct enetc_si *si, u32 reg, u32 val)
} }
EXPORT_SYMBOL_GPL(enetc_port_mac_wr); EXPORT_SYMBOL_GPL(enetc_port_mac_wr);
void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs) static void enetc_change_preemptible_tcs(struct enetc_ndev_priv *priv,
u8 preemptible_tcs)
{ {
u32 val; priv->preemptible_tcs = preemptible_tcs;
int tc; enetc_mm_commit_preemptible_tcs(priv);
for (tc = 0; tc < 8; tc++) {
val = enetc_port_rd(hw, ENETC_PTCFPR(tc));
if (preemptible_tcs & BIT(tc))
val |= ENETC_PTCFPR_FPE;
else
val &= ~ENETC_PTCFPR_FPE;
enetc_port_wr(hw, ENETC_PTCFPR(tc), val);
}
} }
EXPORT_SYMBOL_GPL(enetc_set_ptcfpr);
static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv)
{ {
...@@ -2659,7 +2648,7 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev) ...@@ -2659,7 +2648,7 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev)
enetc_debug_tx_ring_prios(priv); enetc_debug_tx_ring_prios(priv);
enetc_set_ptcfpr(hw, 0); enetc_change_preemptible_tcs(priv, 0);
} }
int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data)
...@@ -2714,7 +2703,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) ...@@ -2714,7 +2703,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data)
enetc_debug_tx_ring_prios(priv); enetc_debug_tx_ring_prios(priv);
enetc_set_ptcfpr(hw, mqprio->preemptible_tcs); enetc_change_preemptible_tcs(priv, mqprio->preemptible_tcs);
return 0; return 0;
......
...@@ -355,6 +355,9 @@ struct enetc_ndev_priv { ...@@ -355,6 +355,9 @@ struct enetc_ndev_priv {
u16 rx_bd_count, tx_bd_count; u16 rx_bd_count, tx_bd_count;
u16 msg_enable; u16 msg_enable;
u8 preemptible_tcs;
enum enetc_active_offloads active_offloads; enum enetc_active_offloads active_offloads;
u32 speed; /* store speed for compare update pspeed */ u32 speed; /* store speed for compare update pspeed */
...@@ -433,6 +436,7 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames, ...@@ -433,6 +436,7 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,
/* ethtool */ /* ethtool */
void enetc_set_ethtool_ops(struct net_device *ndev); void enetc_set_ethtool_ops(struct net_device *ndev);
void enetc_mm_link_state_update(struct enetc_ndev_priv *priv, bool link); void enetc_mm_link_state_update(struct enetc_ndev_priv *priv, bool link);
void enetc_mm_commit_preemptible_tcs(struct enetc_ndev_priv *priv);
/* control buffer descriptor ring (CBDR) */ /* control buffer descriptor ring (CBDR) */
int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count,
...@@ -486,7 +490,6 @@ static inline void enetc_cbd_free_data_mem(struct enetc_si *si, int size, ...@@ -486,7 +490,6 @@ static inline void enetc_cbd_free_data_mem(struct enetc_si *si, int size,
void enetc_reset_ptcmsdur(struct enetc_hw *hw); void enetc_reset_ptcmsdur(struct enetc_hw *hw);
void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu); void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu);
void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs);
#ifdef CONFIG_FSL_ENETC_QOS #ifdef CONFIG_FSL_ENETC_QOS
int enetc_qos_query_caps(struct net_device *ndev, void *type_data); int enetc_qos_query_caps(struct net_device *ndev, void *type_data);
......
...@@ -32,6 +32,12 @@ static const u32 enetc_port_regs[] = { ...@@ -32,6 +32,12 @@ static const u32 enetc_port_regs[] = {
ENETC_PM0_CMD_CFG, ENETC_PM0_MAXFRM, ENETC_PM0_IF_MODE ENETC_PM0_CMD_CFG, ENETC_PM0_MAXFRM, ENETC_PM0_IF_MODE
}; };
static const u32 enetc_port_mm_regs[] = {
ENETC_MMCSR, ENETC_PFPMR, ENETC_PTCFPR(0), ENETC_PTCFPR(1),
ENETC_PTCFPR(2), ENETC_PTCFPR(3), ENETC_PTCFPR(4), ENETC_PTCFPR(5),
ENETC_PTCFPR(6), ENETC_PTCFPR(7),
};
static int enetc_get_reglen(struct net_device *ndev) static int enetc_get_reglen(struct net_device *ndev)
{ {
struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_ndev_priv *priv = netdev_priv(ndev);
...@@ -45,6 +51,9 @@ static int enetc_get_reglen(struct net_device *ndev) ...@@ -45,6 +51,9 @@ static int enetc_get_reglen(struct net_device *ndev)
if (hw->port) if (hw->port)
len += ARRAY_SIZE(enetc_port_regs); len += ARRAY_SIZE(enetc_port_regs);
if (hw->port && !!(priv->si->hw_features & ENETC_SI_F_QBU))
len += ARRAY_SIZE(enetc_port_mm_regs);
len *= sizeof(u32) * 2; /* store 2 entries per reg: addr and value */ len *= sizeof(u32) * 2; /* store 2 entries per reg: addr and value */
return len; return len;
...@@ -90,6 +99,14 @@ static void enetc_get_regs(struct net_device *ndev, struct ethtool_regs *regs, ...@@ -90,6 +99,14 @@ static void enetc_get_regs(struct net_device *ndev, struct ethtool_regs *regs,
*buf++ = addr; *buf++ = addr;
*buf++ = enetc_rd(hw, addr); *buf++ = enetc_rd(hw, addr);
} }
if (priv->si->hw_features & ENETC_SI_F_QBU) {
for (i = 0; i < ARRAY_SIZE(enetc_port_mm_regs); i++) {
addr = ENETC_PORT_BASE + enetc_port_mm_regs[i];
*buf++ = addr;
*buf++ = enetc_rd(hw, addr);
}
}
} }
static const struct { static const struct {
...@@ -976,7 +993,9 @@ static int enetc_get_mm(struct net_device *ndev, struct ethtool_mm_state *state) ...@@ -976,7 +993,9 @@ static int enetc_get_mm(struct net_device *ndev, struct ethtool_mm_state *state)
lafs = ENETC_MMCSR_GET_LAFS(val); lafs = ENETC_MMCSR_GET_LAFS(val);
state->rx_min_frag_size = ethtool_mm_frag_size_add_to_min(lafs); state->rx_min_frag_size = ethtool_mm_frag_size_add_to_min(lafs);
state->tx_enabled = !!(val & ENETC_MMCSR_LPE); /* mirror of MMCSR_ME */ state->tx_enabled = !!(val & ENETC_MMCSR_LPE); /* mirror of MMCSR_ME */
state->tx_active = !!(val & ENETC_MMCSR_LPA); state->tx_active = state->tx_enabled &&
(state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED ||
state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED);
state->verify_enabled = !(val & ENETC_MMCSR_VDIS); state->verify_enabled = !(val & ENETC_MMCSR_VDIS);
state->verify_time = ENETC_MMCSR_GET_VT(val); state->verify_time = ENETC_MMCSR_GET_VT(val);
/* A verifyTime of 128 ms would exceed the 7 bit width /* A verifyTime of 128 ms would exceed the 7 bit width
...@@ -989,6 +1008,64 @@ static int enetc_get_mm(struct net_device *ndev, struct ethtool_mm_state *state) ...@@ -989,6 +1008,64 @@ static int enetc_get_mm(struct net_device *ndev, struct ethtool_mm_state *state)
return 0; return 0;
} }
static int enetc_mm_wait_tx_active(struct enetc_hw *hw, int verify_time)
{
int timeout = verify_time * USEC_PER_MSEC * ENETC_MM_VERIFY_RETRIES;
u32 val;
/* This will time out after the standard value of 3 verification
* attempts. To not sleep forever, it relies on a non-zero verify_time,
* guarantee which is provided by the ethtool nlattr policy.
*/
return read_poll_timeout(enetc_port_rd, val,
ENETC_MMCSR_GET_VSTS(val) == 3,
ENETC_MM_VERIFY_SLEEP_US, timeout,
true, hw, ENETC_MMCSR);
}
static void enetc_set_ptcfpr(struct enetc_hw *hw, u8 preemptible_tcs)
{
u32 val;
int tc;
for (tc = 0; tc < 8; tc++) {
val = enetc_port_rd(hw, ENETC_PTCFPR(tc));
if (preemptible_tcs & BIT(tc))
val |= ENETC_PTCFPR_FPE;
else
val &= ~ENETC_PTCFPR_FPE;
enetc_port_wr(hw, ENETC_PTCFPR(tc), val);
}
}
/* ENETC does not have an IRQ to notify changes to the MAC Merge TX status
* (active/inactive), but the preemptible traffic classes should only be
* committed to hardware once TX is active. Resort to polling.
*/
void enetc_mm_commit_preemptible_tcs(struct enetc_ndev_priv *priv)
{
struct enetc_hw *hw = &priv->si->hw;
u8 preemptible_tcs = 0;
u32 val;
int err;
val = enetc_port_rd(hw, ENETC_MMCSR);
if (!(val & ENETC_MMCSR_ME))
goto out;
if (!(val & ENETC_MMCSR_VDIS)) {
err = enetc_mm_wait_tx_active(hw, ENETC_MMCSR_GET_VT(val));
if (err)
goto out;
}
preemptible_tcs = priv->preemptible_tcs;
out:
enetc_set_ptcfpr(hw, preemptible_tcs);
}
/* FIXME: Workaround for the link partner's verification failing if ENETC /* FIXME: Workaround for the link partner's verification failing if ENETC
* priorly received too much express traffic. The documentation doesn't * priorly received too much express traffic. The documentation doesn't
* suggest this is needed. * suggest this is needed.
...@@ -1041,10 +1118,13 @@ static int enetc_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg, ...@@ -1041,10 +1118,13 @@ static int enetc_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
else else
priv->active_offloads &= ~ENETC_F_QBU; priv->active_offloads &= ~ENETC_F_QBU;
/* If link is up, enable MAC Merge right away */ /* If link is up, enable/disable MAC Merge right away */
if (!!(priv->active_offloads & ENETC_F_QBU) && if (!(val & ENETC_MMCSR_LINK_FAIL)) {
!(val & ENETC_MMCSR_LINK_FAIL)) if (!!(priv->active_offloads & ENETC_F_QBU))
val |= ENETC_MMCSR_ME; val |= ENETC_MMCSR_ME;
else
val &= ~ENETC_MMCSR_ME;
}
val &= ~ENETC_MMCSR_VT_MASK; val &= ~ENETC_MMCSR_VT_MASK;
val |= ENETC_MMCSR_VT(cfg->verify_time); val |= ENETC_MMCSR_VT(cfg->verify_time);
...@@ -1056,6 +1136,8 @@ static int enetc_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg, ...@@ -1056,6 +1136,8 @@ static int enetc_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg,
enetc_restart_emac_rx(priv->si); enetc_restart_emac_rx(priv->si);
enetc_mm_commit_preemptible_tcs(priv);
mutex_unlock(&priv->mm_lock); mutex_unlock(&priv->mm_lock);
return 0; return 0;
...@@ -1089,6 +1171,8 @@ void enetc_mm_link_state_update(struct enetc_ndev_priv *priv, bool link) ...@@ -1089,6 +1171,8 @@ void enetc_mm_link_state_update(struct enetc_ndev_priv *priv, bool link)
enetc_port_wr(hw, ENETC_MMCSR, val); enetc_port_wr(hw, ENETC_MMCSR, val);
enetc_mm_commit_preemptible_tcs(priv);
mutex_unlock(&priv->mm_lock); mutex_unlock(&priv->mm_lock);
} }
EXPORT_SYMBOL_GPL(enetc_mm_link_state_update); EXPORT_SYMBOL_GPL(enetc_mm_link_state_update);
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#define ENETC_MM_VERIFY_SLEEP_US USEC_PER_MSEC
#define ENETC_MM_VERIFY_RETRIES 3
/* ENETC device IDs */ /* ENETC device IDs */
#define ENETC_DEV_ID_PF 0xe100 #define ENETC_DEV_ID_PF 0xe100
#define ENETC_DEV_ID_VF 0xef00 #define ENETC_DEV_ID_VF 0xef00
......
...@@ -214,6 +214,16 @@ static int ethnl_set_mm(struct ethnl_req_info *req_info, struct genl_info *info) ...@@ -214,6 +214,16 @@ static int ethnl_set_mm(struct ethnl_req_info *req_info, struct genl_info *info)
return -ERANGE; return -ERANGE;
} }
if (cfg.verify_enabled && !cfg.tx_enabled) {
NL_SET_ERR_MSG(extack, "Verification requires TX enabled");
return -EINVAL;
}
if (cfg.tx_enabled && !cfg.pmac_enabled) {
NL_SET_ERR_MSG(extack, "TX enabled requires pMAC enabled");
return -EINVAL;
}
ret = dev->ethtool_ops->set_mm(dev, &cfg, extack); ret = dev->ethtool_ops->set_mm(dev, &cfg, extack);
return ret < 0 ? ret : 1; return ret < 0 ? ret : 1;
} }
......
...@@ -18,7 +18,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding ...@@ -18,7 +18,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding
NUM_NETIFS=0 NUM_NETIFS=0
source $lib_dir/lib.sh source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
source qos_lib.sh
swp=$NETIF_NO_CABLE swp=$NETIF_NO_CABLE
...@@ -371,7 +370,7 @@ test_tc_int_buf() ...@@ -371,7 +370,7 @@ test_tc_int_buf()
tc qdisc delete dev $swp root tc qdisc delete dev $swp root
} }
bail_on_lldpad bail_on_lldpad "configure DCB" "configure Qdiscs"
trap cleanup EXIT trap cleanup EXIT
setup_wait setup_wait
......
...@@ -54,31 +54,3 @@ measure_rate() ...@@ -54,31 +54,3 @@ measure_rate()
echo $ir $er echo $ir $er
return $ret return $ret
} }
bail_on_lldpad()
{
if systemctl is-active --quiet lldpad; then
cat >/dev/stderr <<-EOF
WARNING: lldpad is running
lldpad will likely configure DCB, and this test will
configure Qdiscs. mlxsw does not support both at the
same time, one of them is arbitrarily going to overwrite
the other. That will cause spurious failures (or,
unlikely, passes) of this test.
EOF
if [[ -z $ALLOW_LLDPAD ]]; then
cat >/dev/stderr <<-EOF
If you want to run the test anyway, please set
an environment variable ALLOW_LLDPAD to a
non-empty string.
EOF
exit 1
else
return
fi
fi
}
...@@ -79,7 +79,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding ...@@ -79,7 +79,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding
NUM_NETIFS=6 NUM_NETIFS=6
source $lib_dir/lib.sh source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
source qos_lib.sh
_1KB=1000 _1KB=1000
_100KB=$((100 * _1KB)) _100KB=$((100 * _1KB))
...@@ -393,7 +392,7 @@ test_qos_pfc() ...@@ -393,7 +392,7 @@ test_qos_pfc()
log_test "PFC" log_test "PFC"
} }
bail_on_lldpad bail_on_lldpad "configure DCB" "configure Qdiscs"
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
lib_dir=$(dirname $0)/../../../net/forwarding lib_dir=$(dirname $0)/../../../net/forwarding
source $lib_dir/sch_ets_core.sh source $lib_dir/sch_ets_core.sh
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
source qos_lib.sh
ALL_TESTS=" ALL_TESTS="
ping_ipv4 ping_ipv4
...@@ -78,5 +77,5 @@ collect_stats() ...@@ -78,5 +77,5 @@ collect_stats()
done done
} }
bail_on_lldpad bail_on_lldpad "configure DCB" "configure Qdiscs"
ets_run ets_run
...@@ -74,7 +74,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding ...@@ -74,7 +74,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding
source $lib_dir/lib.sh source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
source mlxsw_lib.sh source mlxsw_lib.sh
source qos_lib.sh
ipaddr() ipaddr()
{ {
......
...@@ -166,7 +166,7 @@ ecn_mirror_test() ...@@ -166,7 +166,7 @@ ecn_mirror_test()
uninstall_qdisc uninstall_qdisc
} }
bail_on_lldpad bail_on_lldpad "configure DCB" "configure Qdiscs"
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
...@@ -73,7 +73,7 @@ red_mirror_test() ...@@ -73,7 +73,7 @@ red_mirror_test()
uninstall_qdisc uninstall_qdisc
} }
bail_on_lldpad bail_on_lldpad "configure DCB" "configure Qdiscs"
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
source qos_lib.sh sch_tbf_pre_hook()
bail_on_lldpad {
bail_on_lldpad "configure DCB" "configure Qdiscs"
}
lib_dir=$(dirname $0)/../../../net/forwarding lib_dir=$(dirname $0)/../../../net/forwarding
TCFLAGS=skip_sw TCFLAGS=skip_sw
......
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
source qos_lib.sh sch_tbf_pre_hook()
bail_on_lldpad {
bail_on_lldpad "configure DCB" "configure Qdiscs"
}
lib_dir=$(dirname $0)/../../../net/forwarding lib_dir=$(dirname $0)/../../../net/forwarding
TCFLAGS=skip_sw TCFLAGS=skip_sw
......
#!/bin/bash #!/bin/bash
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
source qos_lib.sh sch_tbf_pre_hook()
bail_on_lldpad {
bail_on_lldpad "configure DCB" "configure Qdiscs"
}
lib_dir=$(dirname $0)/../../../net/forwarding lib_dir=$(dirname $0)/../../../net/forwarding
TCFLAGS=skip_sw TCFLAGS=skip_sw
......
...@@ -15,6 +15,7 @@ TEST_PROGS = bridge_igmp.sh \ ...@@ -15,6 +15,7 @@ TEST_PROGS = bridge_igmp.sh \
custom_multipath_hash.sh \ custom_multipath_hash.sh \
dual_vxlan_bridge.sh \ dual_vxlan_bridge.sh \
ethtool_extended_state.sh \ ethtool_extended_state.sh \
ethtool_mm.sh \
ethtool.sh \ ethtool.sh \
gre_custom_multipath_hash.sh \ gre_custom_multipath_hash.sh \
gre_inner_v4_multipath.sh \ gre_inner_v4_multipath.sh \
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
ALL_TESTS="
manual_with_verification_h1_to_h2
manual_with_verification_h2_to_h1
manual_without_verification_h1_to_h2
manual_without_verification_h2_to_h1
manual_failed_verification_h1_to_h2
manual_failed_verification_h2_to_h1
lldp
"
NUM_NETIFS=2
REQUIRE_MZ=no
PREEMPTIBLE_PRIO=0
source lib.sh
traffic_test()
{
local if=$1; shift
local src=$1; shift
local num_pkts=10000
local before=
local after=
local delta=
before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
after=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
delta=$((after - before))
# Allow an extra 1% tolerance for random packets sent by the stack
[ $delta -ge $num_pkts ] && [ $delta -le $((num_pkts + 100)) ]
}
manual_with_verification()
{
local tx=$1; shift
local rx=$1; shift
RET=0
# It isn't completely clear from IEEE 802.3-2018 Figure 99-5: Transmit
# Processing state diagram whether the "send_r" variable (send response
# to verification frame) should be taken into consideration while the
# MAC Merge TX direction is disabled. That being said, at least the
# NXP ENETC does not, and requires tx-enabled on in order to respond to
# the link partner's verification frames.
ethtool --set-mm $rx tx-enabled on
ethtool --set-mm $tx verify-enabled on tx-enabled on
# Wait for verification to finish
sleep 1
ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
grep -q 'SUCCEEDED'
check_err "$?" "Verification did not succeed"
ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
check_err "$?" "pMAC TX is not active"
traffic_test $tx "pmac"
check_err "$?" "Traffic did not get sent through $tx's pMAC"
ethtool --set-mm $tx verify-enabled off tx-enabled off
ethtool --set-mm $rx tx-enabled off
log_test "Manual configuration with verification: $tx to $rx"
}
manual_with_verification_h1_to_h2()
{
manual_with_verification $h1 $h2
}
manual_with_verification_h2_to_h1()
{
manual_with_verification $h2 $h1
}
manual_without_verification()
{
local tx=$1; shift
local rx=$1; shift
RET=0
ethtool --set-mm $tx verify-enabled off tx-enabled on
ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
grep -q 'DISABLED'
check_err "$?" "Verification is not disabled"
ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
check_err "$?" "pMAC TX is not active"
traffic_test $tx "pmac"
check_err "$?" "Traffic did not get sent through $tx's pMAC"
ethtool --set-mm $tx verify-enabled off tx-enabled off
log_test "Manual configuration without verification: $tx to $rx"
}
manual_without_verification_h1_to_h2()
{
manual_without_verification $h1 $h2
}
manual_without_verification_h2_to_h1()
{
manual_without_verification $h2 $h1
}
manual_failed_verification()
{
local tx=$1; shift
local rx=$1; shift
RET=0
ethtool --set-mm $rx pmac-enabled off
ethtool --set-mm $tx verify-enabled on tx-enabled on
# Wait for verification to time out
sleep 1
ethtool --json --show-mm $tx | jq -r '.[]."verify-status"' | \
grep -q 'SUCCEEDED'
check_fail "$?" "Verification succeeded when it shouldn't have"
ethtool --json --show-mm $tx | jq -r '.[]."tx-active"' | grep -q 'true'
check_fail "$?" "pMAC TX is active when it shouldn't have"
traffic_test $tx "emac"
check_err "$?" "Traffic did not get sent through $tx's eMAC"
ethtool --set-mm $tx verify-enabled off tx-enabled off
ethtool --set-mm $rx pmac-enabled on
log_test "Manual configuration with failed verification: $tx to $rx"
}
manual_failed_verification_h1_to_h2()
{
manual_failed_verification $h1 $h2
}
manual_failed_verification_h2_to_h1()
{
manual_failed_verification $h2 $h1
}
lldp_change_add_frag_size()
{
local add_frag_size=$1
lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
# Wait for TLVs to be received
sleep 2
lldptool -i $h2 -t -n -V addEthCaps | \
grep -q "Additional fragment size: $add_frag_size"
}
lldp()
{
RET=0
systemctl start lldpad
# Configure the interfaces to receive and transmit LLDPDUs
lldptool -L -i $h1 adminStatus=rxtx >/dev/null
lldptool -L -i $h2 adminStatus=rxtx >/dev/null
# Enable the transmission of Additional Ethernet Capabilities TLV
lldptool -T -i $h1 -V addEthCaps enableTx=yes >/dev/null
lldptool -T -i $h2 -V addEthCaps enableTx=yes >/dev/null
# Wait for TLVs to be received
sleep 2
lldptool -i $h1 -t -n -V addEthCaps | \
grep -q "Preemption capability active"
check_err "$?" "$h1 pMAC TX is not active"
lldptool -i $h2 -t -n -V addEthCaps | \
grep -q "Preemption capability active"
check_err "$?" "$h2 pMAC TX is not active"
lldp_change_add_frag_size 3
check_err "$?" "addFragSize 3"
lldp_change_add_frag_size 2
check_err "$?" "addFragSize 2"
lldp_change_add_frag_size 1
check_err "$?" "addFragSize 1"
lldp_change_add_frag_size 0
check_err "$?" "addFragSize 0"
traffic_test $h1 "pmac"
check_err "$?" "Traffic did not get sent through $h1's pMAC"
traffic_test $h2 "pmac"
check_err "$?" "Traffic did not get sent through $h2's pMAC"
systemctl stop lldpad
log_test "LLDP"
}
h1_create()
{
ip link set dev $h1 up
tc qdisc add dev $h1 root mqprio num_tc 4 map 0 1 2 3 \
queues 1@0 1@1 1@2 1@3 \
fp P E E E \
hw 1
ethtool --set-mm $h1 pmac-enabled on tx-enabled off verify-enabled off
}
h2_create()
{
ip link set dev $h2 up
ethtool --set-mm $h2 pmac-enabled on tx-enabled off verify-enabled off
tc qdisc add dev $h2 root mqprio num_tc 4 map 0 1 2 3 \
queues 1@0 1@1 1@2 1@3 \
fp P E E E \
hw 1
}
h1_destroy()
{
ethtool --set-mm $h1 pmac-enabled off tx-enabled off verify-enabled off
tc qdisc del dev $h1 root
ip link set dev $h1 down
}
h2_destroy()
{
tc qdisc del dev $h2 root
ethtool --set-mm $h2 pmac-enabled off tx-enabled off verify-enabled off
ip link set dev $h2 down
}
setup_prepare()
{
check_ethtool_mm_support
check_tc_fp_support
require_command lldptool
bail_on_lldpad "autoconfigure the MAC Merge layer" "configure it manually"
h1=${NETIFS[p1]}
h2=${NETIFS[p2]}
h1_create
h2_create
}
cleanup()
{
pre_cleanup
h2_destroy
h1_destroy
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
...@@ -120,6 +120,15 @@ check_tc_action_hw_stats_support() ...@@ -120,6 +120,15 @@ check_tc_action_hw_stats_support()
fi fi
} }
check_tc_fp_support()
{
tc qdisc add dev lo mqprio help 2>&1 | grep -q "fp "
if [[ $? -ne 0 ]]; then
echo "SKIP: iproute2 too old; tc is missing frame preemption support"
exit $ksft_skip
fi
}
check_ethtool_lanes_support() check_ethtool_lanes_support()
{ {
ethtool --help 2>&1| grep lanes &> /dev/null ethtool --help 2>&1| grep lanes &> /dev/null
...@@ -129,6 +138,15 @@ check_ethtool_lanes_support() ...@@ -129,6 +138,15 @@ check_ethtool_lanes_support()
fi fi
} }
check_ethtool_mm_support()
{
ethtool --help 2>&1| grep -- '--show-mm' &> /dev/null
if [[ $? -ne 0 ]]; then
echo "SKIP: ethtool too old; it is missing MAC Merge layer support"
exit $ksft_skip
fi
}
check_locked_port_support() check_locked_port_support()
{ {
if ! bridge -d link show | grep -q " locked"; then if ! bridge -d link show | grep -q " locked"; then
...@@ -787,6 +805,17 @@ ethtool_stats_get() ...@@ -787,6 +805,17 @@ ethtool_stats_get()
ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2 ethtool -S $dev | grep "^ *$stat:" | head -n 1 | cut -d: -f2
} }
ethtool_std_stats_get()
{
local dev=$1; shift
local grp=$1; shift
local name=$1; shift
local src=$1; shift
ethtool --json -S $dev --groups $grp -- --src $src | \
jq '.[]."'"$grp"'"."'$name'"'
}
qdisc_stats_get() qdisc_stats_get()
{ {
local dev=$1; shift local dev=$1; shift
...@@ -1887,3 +1916,34 @@ mldv1_done_get() ...@@ -1887,3 +1916,34 @@ mldv1_done_get()
payload_template_expand_checksum "$hbh$icmpv6" $checksum payload_template_expand_checksum "$hbh$icmpv6" $checksum
} }
bail_on_lldpad()
{
local reason1="$1"; shift
local reason2="$1"; shift
if systemctl is-active --quiet lldpad; then
cat >/dev/stderr <<-EOF
WARNING: lldpad is running
lldpad will likely $reason1, and this test will
$reason2. Both are not supported at the same time,
one of them is arbitrarily going to overwrite the
other. That will cause spurious failures (or, unlikely,
passes) of this test.
EOF
if [[ -z $ALLOW_LLDPAD ]]; then
cat >/dev/stderr <<-EOF
If you want to run the test anyway, please set
an environment variable ALLOW_LLDPAD to a
non-empty string.
EOF
exit 1
else
return
fi
fi
}
...@@ -57,6 +57,10 @@ tbf_root_test() ...@@ -57,6 +57,10 @@ tbf_root_test()
tc qdisc del dev $swp2 root tc qdisc del dev $swp2 root
} }
if type -t sch_tbf_pre_hook >/dev/null; then
sch_tbf_pre_hook
fi
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
...@@ -23,6 +23,10 @@ tbf_test() ...@@ -23,6 +23,10 @@ tbf_test()
tc qdisc del dev $swp2 root tc qdisc del dev $swp2 root
} }
if type -t sch_tbf_pre_hook >/dev/null; then
sch_tbf_pre_hook
fi
trap cleanup EXIT trap cleanup EXIT
setup_prepare setup_prepare
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment