From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Vinicius Costa Gomes <vinicius.gomes@intel.com>,
Kurt Kanzenbach <kurt@linutronix.de>,
Jacob Keller <jacob.e.keller@intel.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
Simon Horman <simon.horman@corigine.com>
Subject: [PATCH v5 net-next 10/17] net/sched: mqprio: add extack messages for queue count validation
Date: Thu, 2 Feb 2023 02:36:14 +0200 [thread overview]
Message-ID: <20230202003621.2679603-11-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com>
To make mqprio more user-friendly, create netlink extended ack messages
which say exactly what is wrong about the queue counts. This uses the
new support for printf-formatted extack messages.
Example:
$ tc qdisc add dev eno0 root handle 1: mqprio num_tc 8 \
map 0 1 2 3 4 5 6 7 queues 3@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 0
Error: sch_mqprio: TC 0 queues 3@0 overlap with TC 1 queues 1@1.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
---
v4->v5: change extack message to say full TXQ range of TC i
v1->v4: none
net/sched/sch_mqprio.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 466fbcb5de08..3b6832278d83 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -36,28 +36,44 @@ static bool intervals_overlap(int a, int b, int c, int d)
}
static int mqprio_validate_queue_counts(struct net_device *dev,
- const struct tc_mqprio_qopt *qopt)
+ const struct tc_mqprio_qopt *qopt,
+ struct netlink_ext_ack *extack)
{
int i, j;
for (i = 0; i < qopt->num_tc; i++) {
unsigned int last = qopt->offset[i] + qopt->count[i];
+ if (!qopt->count[i]) {
+ NL_SET_ERR_MSG_FMT_MOD(extack, "No queues for TC %d",
+ i);
+ return -EINVAL;
+ }
+
/* Verify the queue count is in tx range being equal to the
* real_num_tx_queues indicates the last queue is in use.
*/
if (qopt->offset[i] >= dev->real_num_tx_queues ||
- !qopt->count[i] ||
- last > dev->real_num_tx_queues)
+ last > dev->real_num_tx_queues) {
+ NL_SET_ERR_MSG_FMT_MOD(extack,
+ "Queues %d:%d for TC %d exceed the %d TX queues available",
+ qopt->count[i], qopt->offset[i],
+ i, dev->real_num_tx_queues);
return -EINVAL;
+ }
/* Verify that the offset and counts do not overlap */
for (j = i + 1; j < qopt->num_tc; j++) {
if (intervals_overlap(qopt->offset[i], last,
qopt->offset[j],
qopt->offset[j] +
- qopt->count[j]))
+ qopt->count[j])) {
+ NL_SET_ERR_MSG_FMT_MOD(extack,
+ "TC %d queues %d@%d overlap with TC %d queues %d@%d",
+ i, qopt->count[i], qopt->offset[i],
+ j, qopt->count[j], qopt->offset[j]);
return -EINVAL;
+ }
}
}
@@ -65,7 +81,8 @@ static int mqprio_validate_queue_counts(struct net_device *dev,
}
static int mqprio_enable_offload(struct Qdisc *sch,
- const struct tc_mqprio_qopt *qopt)
+ const struct tc_mqprio_qopt *qopt,
+ struct netlink_ext_ack *extack)
{
struct tc_mqprio_qopt_offload mqprio = {.qopt = *qopt};
struct mqprio_sched *priv = qdisc_priv(sch);
@@ -140,7 +157,8 @@ static void mqprio_destroy(struct Qdisc *sch)
}
static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
- const struct tc_mqprio_caps *caps)
+ const struct tc_mqprio_caps *caps,
+ struct netlink_ext_ack *extack)
{
int i, err;
@@ -166,7 +184,7 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt,
* provided queue counts (or to request validation on its behalf).
*/
if (!qopt->hw || caps->validate_queue_counts) {
- err = mqprio_validate_queue_counts(dev, qopt);
+ err = mqprio_validate_queue_counts(dev, qopt, extack);
if (err)
return err;
}
@@ -294,7 +312,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt,
&caps, sizeof(caps));
qopt = nla_data(opt);
- if (mqprio_parse_opt(dev, qopt, &caps))
+ if (mqprio_parse_opt(dev, qopt, &caps, extack))
return -EINVAL;
len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt));
@@ -328,7 +346,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt,
* supplied and verified mapping
*/
if (qopt->hw) {
- err = mqprio_enable_offload(sch, qopt);
+ err = mqprio_enable_offload(sch, qopt, extack);
if (err)
return err;
} else {
--
2.34.1
next prev parent reply other threads:[~2023-02-02 0:37 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 0:36 [PATCH v5 net-next 00/17] ENETC mqprio/taprio cleanup Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 01/17] net: enetc: simplify enetc_num_stack_tx_queues() Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 02/17] net: enetc: allow the enetc_reconfigure() callback to fail Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 03/17] net: enetc: recalculate num_real_tx_queues when XDP program attaches Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 04/17] net: enetc: ensure we always have a minimum number of TXQs for stack Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 05/17] net/sched: mqprio: refactor nlattr parsing to a separate function Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 06/17] net/sched: mqprio: refactor offloading and unoffloading to dedicated functions Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 07/17] net/sched: move struct tc_mqprio_qopt_offload from pkt_cls.h to pkt_sched.h Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 08/17] net/sched: mqprio: allow reverse TC:TXQ mappings Vladimir Oltean
2023-02-03 16:18 ` Simon Horman
2023-02-05 11:55 ` Gerhard Engleder
2023-02-05 12:22 ` Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 09/17] net/sched: mqprio: allow offloading drivers to request queue count validation Vladimir Oltean
2023-02-02 0:36 ` Vladimir Oltean [this message]
2023-02-02 0:36 ` [PATCH v5 net-next 11/17] net/sched: taprio: centralize mqprio qopt validation Vladimir Oltean
2023-02-03 16:32 ` Simon Horman
2023-02-05 12:10 ` Gerhard Engleder
2023-02-05 12:23 ` Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 12/17] net/sched: refactor mqprio qopt reconstruction to a library function Vladimir Oltean
2023-02-03 16:33 ` Simon Horman
2023-02-02 0:36 ` [PATCH v5 net-next 13/17] net/sched: taprio: pass mqprio queue configuration to ndo_setup_tc() Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 14/17] net/sched: taprio: only calculate gate mask per TXQ for igc, stmmac and tsnep Vladimir Oltean
2023-02-02 8:04 ` Roger Quadros
2023-02-02 12:31 ` Vladimir Oltean
2023-02-02 20:05 ` Roger Quadros
2023-02-02 0:36 ` [PATCH v5 net-next 15/17] net: enetc: request mqprio to validate the queue counts Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 16/17] net: enetc: act upon the requested mqprio queue configuration Vladimir Oltean
2023-02-02 0:36 ` [PATCH v5 net-next 17/17] net: enetc: act upon mqprio queue config in taprio offload Vladimir Oltean
2023-02-02 20:54 ` [PATCH v5 net-next 00/17] ENETC mqprio/taprio cleanup Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230202003621.2679603-11-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=kurt@linutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.com \
--cc=vinicius.gomes@intel.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).