Skip to contentSkip to conversation

ice: Block switchdev mode when ADQ is acvite and vice versa

PATCH Superseded Marcin Szycik 4 participants 7 messages Aug 1, 2023 – Aug 3, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Block switchdev mode when ADQ is acvite 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.

Fixes fbc7b27af0f9 ("ice: enable ndo_setup_tc support for mqprio_qdisc")
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
 2 files changed, 11 insertions(+)
drivers/net/ethernet/intel/ice/ice_eswitch.c +5 -0
index ad0a007b7398..2ea5aaceee11 100644
@@ -538,6 +538,11 @@ 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), "switchdev cannot be configured - ADQ is active. Delete ADQ configs using TC and try again\n");
+			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
index cf92c39467c8..2468b6018613 100644
@@ -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
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 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.

Quoted 7 lines
Fixes fbc7b27af0f9 ("ice: enable ndo_setup_tc support for mqprio_qdisc")
---
  drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
  drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
  2 files changed, 11 insertions(+)
#2 lore raw
In reply to Marcin Szycik
Quoted 18 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")
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
 2 files changed, 11 insertions(+)
drivers/net/ethernet/intel/ice/ice_eswitch.c +0 -0
index ad0a007b7398..2ea5aaceee11 100644

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 542

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -0
@@ -538,6 +538,11 @@ 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), "switchdev cannot be configured - ADQ is active. Delete ADQ configs using TC and try again\n");

It needs to be reported through netlink extack.

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 548

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +3 -0
+			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");

Thanks

#3 lore raw
Quoted 14 lines · Thu, Aug 03, 2023 at 03:11:26PM CEST, [email protected] wrote:
Quoted 13 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")
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
 2 files changed, 11 insertions(+)
Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 542

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -0
index ad0a007b7398..2ea5aaceee11 100644
@@ -538,6 +538,11 @@ 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), "switchdev cannot be configured - ADQ is active. Delete ADQ configs using TC and try again\n");

Does this provide sufficient hint to the user? I mean, what's ADQ and how it is related to TC objects? Please be more precise.

Quoted 12 lines

It needs to be reported through netlink extack.

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 548

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +3 -0
+			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");

Thanks

#6 lore raw
In reply to Leon Romanovsky
Quoted 14 lines · Leon Romanovsky
Quoted 13 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")
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
 2 files changed, 11 insertions(+)
Quoted 12 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 542

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -0
index ad0a007b7398..2ea5aaceee11 100644
@@ -538,6 +538,11 @@ 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), "switchdev cannot be configured - ADQ is active. Delete ADQ configs using TC and try again\n");

It needs to be reported through netlink extack.

Will do, thanks!

Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 548

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +3 -0
+			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");

Thanks

#4 lore raw
In reply to Jiri Pirko
Quoted 15 lines · Jiri Pirko
Quoted 14 lines · Thu, Aug 03, 2023 at 03:11:26PM CEST, [email protected] wrote:
Quoted 13 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")
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
 2 files changed, 11 insertions(+)
Quoted 13 lines
Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 542

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -0
index ad0a007b7398..2ea5aaceee11 100644
@@ -538,6 +538,11 @@ 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), "switchdev cannot be configured - ADQ is active. Delete ADQ configs using TC and try again\n");

Does this provide sufficient hint to the user? I mean, what's ADQ and how it is related to TC objects? Please be more precise.

Application Device Queues, a conflicting feature unrelated to switchdev. If it's enabled, there's a good chance the user knows what it is because they configured it.

Could you suggest a better error message?

Quoted 5 lines
Quoted 5 lines

It needs to be reported through netlink extack.

Quoted 10 lines
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 548

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +3 -0
+			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");

Thanks

Regards,
Marcin
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw
Quoted 32 lines · Thu, Aug 03, 2023 at 05:11:16PM CEST, [email protected] wrote:
Quoted 15 lines · Jiri Pirko
Quoted 14 lines · Thu, Aug 03, 2023 at 03:11:26PM CEST, [email protected] wrote:
Quoted 13 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")
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 5 +++++
 drivers/net/ethernet/intel/ice/ice_main.c    | 6 ++++++
 2 files changed, 11 insertions(+)
Quoted 13 lines
Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 542

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +2 -0
index ad0a007b7398..2ea5aaceee11 100644
@@ -538,6 +538,11 @@ 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), "switchdev cannot be configured - ADQ is active. Delete ADQ configs using TC and try again\n");

Does this provide sufficient hint to the user? I mean, what's ADQ and how it is related to TC objects? Please be more precise.

Quoted 5 lines

Application Device Queues, a conflicting feature unrelated to switchdev. If it's enabled, there's a good chance the user knows what it is because they configured it.

Could you suggest a better error message?

The user would need to know what he needs to do in order to make this work. So it would be nice to hint what rules need to be removed.

Quoted 19 lines
Quoted 6 lines
Quoted 6 lines

It needs to be reported through netlink extack.

Quoted 10 lines
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_eswitch.c ice_eswitch_mode_set(struct devlink *devlink, u16 mode, · line 548

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +3 -0
+			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");

Thanks

Regards,
Marcin