netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aring@mojatatu.com>
To: jhs@mojatatu.com
Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
	netdev@vger.kernel.org, kernel@mojatatu.com,
	Alexander Aring <aring@mojatatu.com>,
	David Ahern <dsahern@gmail.com>
Subject: [PATCHv4 net-next 13/14] net: sch: sch_cbs: add extack support
Date: Wed, 20 Dec 2017 12:35:23 -0500	[thread overview]
Message-ID: <20171220173524.25874-14-aring@mojatatu.com> (raw)
In-Reply-To: <20171220173524.25874-1-aring@mojatatu.com>

This patch adds extack support for the cbs qdisc implementation by
adding NL_SET_ERR_MSG in validation of user input.
Also it serves to illustrate a use case of how the infrastructure ops
api changes are to be used by individual qdiscs.

Cc: David Ahern <dsahern@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Alexander Aring <aring@mojatatu.com>
---
 net/sched/sch_cbs.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
index 8bf6e163d29c..cdd96b9a27bc 100644
--- a/net/sched/sch_cbs.c
+++ b/net/sched/sch_cbs.c
@@ -219,14 +219,17 @@ static void cbs_disable_offload(struct net_device *dev,
 }
 
 static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q,
-			      const struct tc_cbs_qopt *opt)
+			      const struct tc_cbs_qopt *opt,
+			      struct netlink_ext_ack *extack)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
 	struct tc_cbs_qopt_offload cbs = { };
 	int err;
 
-	if (!ops->ndo_setup_tc)
+	if (!ops->ndo_setup_tc) {
+		NL_SET_ERR_MSG(extack, "Specified device does not support cbs offload");
 		return -EOPNOTSUPP;
+	}
 
 	cbs.queue = q->queue;
 
@@ -237,8 +240,10 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q,
 	cbs.sendslope = opt->sendslope;
 
 	err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_CBS, &cbs);
-	if (err < 0)
+	if (err < 0) {
+		NL_SET_ERR_MSG(extack, "Specified device failed to setup cbs hardware offload");
 		return err;
+	}
 
 	q->enqueue = cbs_enqueue_offload;
 	q->dequeue = cbs_dequeue_offload;
@@ -255,12 +260,14 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt,
 	struct tc_cbs_qopt *qopt;
 	int err;
 
-	err = nla_parse_nested(tb, TCA_CBS_MAX, opt, cbs_policy, NULL);
+	err = nla_parse_nested(tb, TCA_CBS_MAX, opt, cbs_policy, extack);
 	if (err < 0)
 		return err;
 
-	if (!tb[TCA_CBS_PARMS])
+	if (!tb[TCA_CBS_PARMS]) {
+		NL_SET_ERR_MSG(extack, "Missing CBS parameter which are mandatory");
 		return -EINVAL;
+	}
 
 	qopt = nla_data(tb[TCA_CBS_PARMS]);
 
@@ -277,7 +284,7 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt,
 
 		cbs_disable_offload(dev, q);
 	} else {
-		err = cbs_enable_offload(dev, q, qopt);
+		err = cbs_enable_offload(dev, q, qopt, extack);
 		if (err < 0)
 			return err;
 	}
@@ -298,8 +305,10 @@ static int cbs_init(struct Qdisc *sch, struct nlattr *opt,
 	struct cbs_sched_data *q = qdisc_priv(sch);
 	struct net_device *dev = qdisc_dev(sch);
 
-	if (!opt)
+	if (!opt) {
+		NL_SET_ERR_MSG(extack, "Missing CBS qdisc options  which are mandatory");
 		return -EINVAL;
+	}
 
 	q->queue = sch->dev_queue - netdev_get_tx_queue(dev, 0);
 
-- 
2.11.0

  parent reply	other threads:[~2017-12-20 17:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 17:35 [PATCHv4 net-next 00/14] net: sched: sch: introduce extack support Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 01/14] net: sched: fix coding style issues Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 02/14] net: sched: sch_api: handle generic qdisc errors Alexander Aring
2017-12-26 11:53   ` Jiri Pirko
2017-12-20 17:35 ` [PATCHv4 net-next 03/14] net: sched: sch: add extack for init callback Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 04/14] net: sched: sch: add extack for change qdisc ops Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 05/14] net: sched: sch: add extack to change class Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 06/14] net: sched: sch: add extack for block callback Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 07/14] net: sched: sch: add extack for graft callback Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 08/14] net: sch: api: add extack support in qdisc_get_rtab Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 09/14] net: sch: api: add extack support in tcf_block_get Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 10/14] net: sch: api: add extack support in qdisc_alloc Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 11/14] net: sch: api: add extack support in qdisc_create_dflt Alexander Aring
2017-12-20 17:35 ` [PATCHv4 net-next 12/14] net: sch: sch_cbq: add extack support Alexander Aring
2017-12-20 17:35 ` Alexander Aring [this message]
2017-12-20 17:35 ` [PATCHv4 net-next 14/14] net: sch: sch_drr: " Alexander Aring
2017-12-21 17:42 ` [PATCHv4 net-next 00/14] net: sched: sch: introduce " David Miller

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=20171220173524.25874-14-aring@mojatatu.com \
    --to=aring@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kernel@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --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).