ice: Block switchdev mode when ADQ is active and vice versa
Subsystems (3)
PATCH v2 1/1 ice: Block switchdev mode when ADQ is active and vice versa
ADQ and switchdev are not supported simultaneously. Enabling both at the same time can result in nullptr dereference.
To prevent this, check if ADQ is active when changing devlink mode to switchdev mode, and check if switchdev is active when enabling ADQ.
---
v2: Added netlink extack, changed error message to be more informative,
fixed typo in commit message
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 6 ++++++ drivers/net/ethernet/intel/ice/ice_main.c | 6 ++++++ 2 files changed, 12 insertions(+)
drivers/net/ethernet/intel/ice/ice_eswitch.c +6 -0
@@ -538,6 +538,12 @@ ice_eswitch_mode_set(struct devlink *devlink, u16 mode,break ;case DEVLINK_ESWITCH_MODE_SWITCHDEV : { +if (ice_is_adq_active (pf)) { +dev_err (ice_pf_to_dev (pf),"Couldn't change eswitch mode to switchdev - ADQ is active. Delete ADQ configs and try again, e.g. tc qdisc del dev $PF root" ); +NL_SET_ERR_MSG_MOD (extack,"Couldn't change eswitch mode to switchdev - ADQ is active. Delete ADQ configs and try again, e.g. tc qdisc del dev $PF root" ); +return -EOPNOTSUPP ; + } +dev_info (ice_pf_to_dev (pf),"PF %d changed eswitch mode to switchdev" , pf->hw.pf_id);NL_SET_ERR_MSG_MOD (extack,"Changed eswitch mode to switchdev" );
drivers/net/ethernet/intel/ice/ice_main.c +6 -0
@@ -8834,6 +8834,12 @@ ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } +if (ice_is_eswitch_mode_switchdev (pf)) { +netdev_err (netdev,"TC MQPRIO offload not supported, switchdev is enabled\n" ); + err = -EOPNOTSUPP ; + goto adev_unlock; + } +/* setup traffic classifier for receive side */ mutex_lock (&pf->tc_mutex); err =ice_setup_tc_mqprio_qdisc (netdev, type_data);
Signature · 1 line
2.41.0
Tony Nguyen
maintainerQuoted 10 lines · Marcin Szycik
ADQ and switchdev are not supported simultaneously. Enabling both at the same time can result in nullptr dereference.
To prevent this, check if ADQ is active when changing devlink mode to switchdev mode, and check if switchdev is active when enabling ADQ.
Fixes fbc7b27af0f9 ("ice: enable ndo_setup_tc support for mqprio_qdisc")Signed-off-by Marcin Szycik <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>---
...
drivers/net/ethernet/intel/ice/ice_main.c ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 8840
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c +4
-0@@ -8834,6 +8834,12 @@ ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } +if (ice_is_eswitch_mode_switchdev (pf)) { +netdev_err (netdev,"TC MQPRIO offload not supported, switchdev is enabled\n" ); + err = -EOPNOTSUPP ; + goto adev_unlock;
Does this need to be checked under adev locks?
drivers/net/ethernet/intel/ice/ice_main.c ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 8845
Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_main.c +2
-0+ } +/* setup traffic classifier for receive side */ mutex_lock (&pf->tc_mutex); err =ice_setup_tc_mqprio_qdisc (netdev, type_data);
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 14 lines · Tony Nguyen
Quoted 10 lines · Marcin Szycik
ADQ and switchdev are not supported simultaneously. Enabling both at the same time can result in nullptr dereference.
To prevent this, check if ADQ is active when changing devlink mode to switchdev mode, and check if switchdev is active when enabling ADQ.
Fixes fbc7b27af0f9 ("ice: enable ndo_setup_tc support for mqprio_qdisc")Signed-off-by Marcin Szycik <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>---
...
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_main.c ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 8839
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_main.c +3
-0@@ -8834,6 +8834,12 @@ ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, } } + if (ice_is_eswitch_mode_switchdev(pf)) { + netdev_err(netdev, "TC MQPRIO offload not supported, switchdev is enabled\n"); + err = -EOPNOTSUPP; + goto adev_unlock;Does this need to be checked under adev locks?
It doesn't. I'll move it above.
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_main.c ice_setup_tc(struct net_device *netdev, enum tc_setup_type type, · line 8845
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_main.c +2
-0+ } + /* setup traffic classifier for receive side */ mutex_lock(&pf->tc_mutex); err = ice_setup_tc_mqprio_qdisc(netdev, type_data);
Thank you for reviewing!
Marcin