diff mbox series

[net-next,08/12] net/sched: mqprio: add an extack message to mqprio_parse_opt()

Message ID 20230216232126.3402975-9-vladimir.oltean@nxp.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Add tc-mqprio and tc-taprio support for preemptible traffic classes | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean Feb. 16, 2023, 11:21 p.m. UTC
Ferenc reports that a combination of poor iproute2 defaults and obscure
cases where the kernel returns -EINVAL make it difficult to understand
what is wrong with this command:

$ ip link add veth0 numtxqueues 8 numrxqueues 8 type veth peer name veth1
$ tc qdisc add dev veth0 root mqprio num_tc 8 map 0 1 2 3 4 5 6 7 \
        queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7
RTNETLINK answers: Invalid argument

Hopefully with this patch, the cause is clearer:

Error: Device does not support hardware offload.

This was rejected because iproute2 defaults to "hw 1" if the option is
not specified.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230204135307.1036988-3-vladimir.oltean@nxp.com/#25215636
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/sched/sch_mqprio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Ferenc Fejes Feb. 17, 2023, 7:24 a.m. UTC | #1
Hi Vladimir!

On Fri, 2023-02-17 at 01:21 +0200, Vladimir Oltean wrote:
> Ferenc reports that a combination of poor iproute2 defaults and
> obscure
> cases where the kernel returns -EINVAL make it difficult to
> understand
> what is wrong with this command:
> 
> $ ip link add veth0 numtxqueues 8 numrxqueues 8 type veth peer name
> veth1
> $ tc qdisc add dev veth0 root mqprio num_tc 8 map 0 1 2 3 4 5 6 7 \
>         queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7
> RTNETLINK answers: Invalid argument
> 
> Hopefully with this patch, the cause is clearer:
> 
> Error: Device does not support hardware offload.

Much better, great improvement!

> 
> This was rejected because iproute2 defaults to "hw 1" if the option
> is
> not specified.
> 
> Link:
> https://patchwork.kernel.org/project/netdevbpf/patch/20230204135307.1036988-3-vladimir.oltean@nxp.com/#25215636
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/sched/sch_mqprio.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
> index 18eda5fade81..52cfc0ec2e23 100644
> --- a/net/sched/sch_mqprio.c
> +++ b/net/sched/sch_mqprio.c
> @@ -134,8 +134,11 @@ static int mqprio_parse_opt(struct net_device
> *dev, struct tc_mqprio_qopt *qopt,
>         /* If ndo_setup_tc is not present then hardware doesn't
> support offload
>          * and we should return an error.
>          */
> -       if (qopt->hw && !dev->netdev_ops->ndo_setup_tc)
> +       if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) {
> +               NL_SET_ERR_MSG(extack,
> +                              "Device does not support hardware
> offload");
>                 return -EINVAL;
> +       }
>  
>         return 0;
>  }

Thanks for doing this!

Best,
Ferenc
Vladimir Oltean Feb. 20, 2023, 10:47 a.m. UTC | #2
Hi Ferenc,

On Fri, Feb 17, 2023 at 07:24:07AM +0000, Ferenc Fejes wrote:
> Much better, great improvement!

Would appreciate a formal review/test tag on v2 :)
diff mbox series

Patch

diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 18eda5fade81..52cfc0ec2e23 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -134,8 +134,11 @@  static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
 	/* If ndo_setup_tc is not present then hardware doesn't support offload
 	 * and we should return an error.
 	 */
-	if (qopt->hw && !dev->netdev_ops->ndo_setup_tc)
+	if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) {
+		NL_SET_ERR_MSG(extack,
+			       "Device does not support hardware offload");
 		return -EINVAL;
+	}
 
 	return 0;
 }