aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-12-15 13:35:37 -0500
committerDavid S. Miller <davem@davemloft.net>2017-12-15 13:35:37 -0500
commitd1fca67fee14c0b8097517f308320af16253023e (patch)
tree2f5330c057ba08509f2ca957c4592c20cff2f7e4
parent0a0606970fa882c504a87c45407559595ef5a134 (diff)
parent4a98795bc8ea148b1ebbbf001283e06430cffe36 (diff)
Merge branch 'net-sched-Make-qdisc-offload-uapi-uniform'
Yuval Mintz says: ==================== net: sched: Make qdisc offload uapi uniform Several qdiscs can already be offloaded to hardware, but there's an inconsistecy in regard to the uapi through which they indicate such an offload is taking place - indication is passed to the user via TCA_OPTIONS where each qdisc retains private logic for setting it. The recent addition of offloading to RED in 602f3baf2218 ("net_sch: red: Add offload ability to RED qdisc") caused the addition of yet another uapi field for this purpose - TC_RED_OFFLOADED. For clarity and prevention of bloat in the uapi we want to eliminate said added uapi, replacing it with a common mechanism that can be used to reflect offload status of the various qdiscs. The first patch introduces TCA_HW_OFFLOAD as the generic message meant for this purpose. The second changes the current RED implementation into setting the internal bits necessary for passing it, and the third removes TC_RED_OFFLOADED as its no longer needed. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sch_generic.h1
-rw-r--r--include/uapi/linux/pkt_sched.h1
-rw-r--r--include/uapi/linux/rtnetlink.h1
-rw-r--r--net/sched/sch_api.c2
-rw-r--r--net/sched/sch_red.c31
5 files changed, 19 insertions, 17 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 65d0d25f2648..83a3e47d5845 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -71,6 +71,7 @@ struct Qdisc {
71 * qdisc_tree_decrease_qlen() should stop. 71 * qdisc_tree_decrease_qlen() should stop.
72 */ 72 */
73#define TCQ_F_INVISIBLE 0x80 /* invisible by default in dump */ 73#define TCQ_F_INVISIBLE 0x80 /* invisible by default in dump */
74#define TCQ_F_OFFLOADED 0x200 /* qdisc is offloaded to HW */
74 u32 limit; 75 u32 limit;
75 const struct Qdisc_ops *ops; 76 const struct Qdisc_ops *ops;
76 struct qdisc_size_table __rcu *stab; 77 struct qdisc_size_table __rcu *stab;
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index af3cc2f4e1ad..37b5096ae97b 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -256,7 +256,6 @@ struct tc_red_qopt {
256#define TC_RED_ECN 1 256#define TC_RED_ECN 1
257#define TC_RED_HARDDROP 2 257#define TC_RED_HARDDROP 2
258#define TC_RED_ADAPTATIVE 4 258#define TC_RED_ADAPTATIVE 4
259#define TC_RED_OFFLOADED 8
260}; 259};
261 260
262struct tc_red_xstats { 261struct tc_red_xstats {
diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
index d8b5f80c2ea6..843e29aa3cac 100644
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -557,6 +557,7 @@ enum {
557 TCA_PAD, 557 TCA_PAD,
558 TCA_DUMP_INVISIBLE, 558 TCA_DUMP_INVISIBLE,
559 TCA_CHAIN, 559 TCA_CHAIN,
560 TCA_HW_OFFLOAD,
560 __TCA_MAX 561 __TCA_MAX
561}; 562};
562 563
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index b6c4f536876b..0f1eab99ff4e 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -795,6 +795,8 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
795 tcm->tcm_info = refcount_read(&q->refcnt); 795 tcm->tcm_info = refcount_read(&q->refcnt);
796 if (nla_put_string(skb, TCA_KIND, q->ops->id)) 796 if (nla_put_string(skb, TCA_KIND, q->ops->id))
797 goto nla_put_failure; 797 goto nla_put_failure;
798 if (nla_put_u8(skb, TCA_HW_OFFLOAD, !!(q->flags & TCQ_F_OFFLOADED)))
799 goto nla_put_failure;
798 if (q->ops->dump && q->ops->dump(q, skb) < 0) 800 if (q->ops->dump && q->ops->dump(q, skb) < 0)
799 goto nla_put_failure; 801 goto nla_put_failure;
800 qlen = q->q.qlen; 802 qlen = q->q.qlen;
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 9d874e60e032..f0747eb87dc4 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -157,6 +157,7 @@ static int red_offload(struct Qdisc *sch, bool enable)
157 .handle = sch->handle, 157 .handle = sch->handle,
158 .parent = sch->parent, 158 .parent = sch->parent,
159 }; 159 };
160 int err;
160 161
161 if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc) 162 if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
162 return -EOPNOTSUPP; 163 return -EOPNOTSUPP;
@@ -171,7 +172,14 @@ static int red_offload(struct Qdisc *sch, bool enable)
171 opt.command = TC_RED_DESTROY; 172 opt.command = TC_RED_DESTROY;
172 } 173 }
173 174
174 return dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED, &opt); 175 err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED, &opt);
176
177 if (!err && enable)
178 sch->flags |= TCQ_F_OFFLOADED;
179 else
180 sch->flags &= ~TCQ_F_OFFLOADED;
181
182 return err;
175} 183}
176 184
177static void red_destroy(struct Qdisc *sch) 185static void red_destroy(struct Qdisc *sch)
@@ -274,7 +282,7 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt)
274 return red_change(sch, opt); 282 return red_change(sch, opt);
275} 283}
276 284
277static int red_dump_offload(struct Qdisc *sch, struct tc_red_qopt *opt) 285static int red_dump_offload_stats(struct Qdisc *sch, struct tc_red_qopt *opt)
278{ 286{
279 struct net_device *dev = qdisc_dev(sch); 287 struct net_device *dev = qdisc_dev(sch);
280 struct tc_red_qopt_offload hw_stats = { 288 struct tc_red_qopt_offload hw_stats = {
@@ -286,21 +294,12 @@ static int red_dump_offload(struct Qdisc *sch, struct tc_red_qopt *opt)
286 .stats.qstats = &sch->qstats, 294 .stats.qstats = &sch->qstats,
287 }, 295 },
288 }; 296 };
289 int err;
290 297
291 opt->flags &= ~TC_RED_OFFLOADED; 298 if (!(sch->flags & TCQ_F_OFFLOADED))
292 if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
293 return 0;
294
295 err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED,
296 &hw_stats);
297 if (err == -EOPNOTSUPP)
298 return 0; 299 return 0;
299 300
300 if (!err) 301 return dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_RED,
301 opt->flags |= TC_RED_OFFLOADED; 302 &hw_stats);
302
303 return err;
304} 303}
305 304
306static int red_dump(struct Qdisc *sch, struct sk_buff *skb) 305static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
@@ -319,7 +318,7 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
319 int err; 318 int err;
320 319
321 sch->qstats.backlog = q->qdisc->qstats.backlog; 320 sch->qstats.backlog = q->qdisc->qstats.backlog;
322 err = red_dump_offload(sch, &opt); 321 err = red_dump_offload_stats(sch, &opt);
323 if (err) 322 if (err)
324 goto nla_put_failure; 323 goto nla_put_failure;
325 324
@@ -347,7 +346,7 @@ static int red_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
347 .marked = q->stats.prob_mark + q->stats.forced_mark, 346 .marked = q->stats.prob_mark + q->stats.forced_mark,
348 }; 347 };
349 348
350 if (tc_can_offload(dev) && dev->netdev_ops->ndo_setup_tc) { 349 if (sch->flags & TCQ_F_OFFLOADED) {
351 struct red_stats hw_stats = {0}; 350 struct red_stats hw_stats = {0};
352 struct tc_red_qopt_offload hw_stats_request = { 351 struct tc_red_qopt_offload hw_stats_request = {
353 .command = TC_RED_XSTATS, 352 .command = TC_RED_XSTATS,