layerscape: add patches-5.4
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 701-net-0051-sdk_dpaa-ceetm-use-the-tcf-block-infrastructure.patch
1 From ae72322610af7eb13fc9a67567fdac610d3d3d3d Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Wed, 17 Jan 2018 16:44:19 +0200
4 Subject: [PATCH] sdk_dpaa: ceetm: use the tcf block infrastructure
5
6 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
7 ---
8 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c | 31 +++++++++++++++-------
9 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h | 2 ++
10 2 files changed, 24 insertions(+), 9 deletions(-)
11
12 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
13 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
14 @@ -423,7 +423,7 @@ static void ceetm_cls_destroy(struct Qdi
15 free_percpu(cl->wbfs.cstats);
16 }
17
18 - tcf_destroy_chain(&cl->filter_list);
19 + tcf_block_put(cl->block);
20 kfree(cl);
21 }
22
23 @@ -440,11 +440,13 @@ static void ceetm_destroy(struct Qdisc *
24 __func__, sch->handle);
25
26 /* All filters need to be removed before destroying the classes */
27 - tcf_destroy_chain(&priv->filter_list);
28 + tcf_block_put(priv->block);
29
30 for (i = 0; i < priv->clhash.hashsize; i++) {
31 - hlist_for_each_entry(cl, &priv->clhash.hash[i], common.hnode)
32 - tcf_destroy_chain(&cl->filter_list);
33 + hlist_for_each_entry(cl, &priv->clhash.hash[i], common.hnode) {
34 + tcf_block_put(cl->block);
35 + cl->block = NULL;
36 + }
37 }
38
39 for (i = 0; i < priv->clhash.hashsize; i++) {
40 @@ -594,7 +596,7 @@ static int ceetm_init_root(struct Qdisc
41 /* Validate inputs */
42 if (sch->parent != TC_H_ROOT) {
43 pr_err("CEETM: a root ceetm qdisc can not be attached to a class\n");
44 - tcf_destroy_chain(&priv->filter_list);
45 + tcf_block_put(priv->block);
46 qdisc_class_hash_destroy(&priv->clhash);
47 return -EINVAL;
48 }
49 @@ -1053,6 +1055,10 @@ static int ceetm_init(struct Qdisc *sch,
50 return -EINVAL;
51 }
52
53 + ret = tcf_block_get(&priv->block, &priv->filter_list);
54 + if (ret)
55 + return ret;
56 +
57 ret = nla_parse_nested(tb, TCA_CEETM_QOPS, opt, ceetm_policy, NULL);
58 if (ret < 0) {
59 pr_err(KBUILD_BASENAME " : %s : tc error\n", __func__);
60 @@ -1521,6 +1527,12 @@ static int ceetm_cls_change(struct Qdisc
61 if (!cl)
62 return -ENOMEM;
63
64 + err = tcf_block_get(&cl->block, &cl->filter_list);
65 + if (err) {
66 + kfree(cl);
67 + return err;
68 + }
69 +
70 cl->type = copt->type;
71 cl->shaped = copt->shaped;
72 cl->root.rate = copt->rate;
73 @@ -1585,6 +1597,7 @@ channel_err:
74 pr_err(KBUILD_BASENAME " : %s : failed to release the channel %d\n",
75 __func__, channel->idx);
76 claim_err:
77 + tcf_block_put(cl->block);
78 kfree(cl);
79 return err;
80 }
81 @@ -1779,15 +1792,15 @@ static int ceetm_cls_dump_stats(struct Q
82 return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
83 }
84
85 -static struct tcf_proto **ceetm_tcf_chain(struct Qdisc *sch, unsigned long arg)
86 +static struct tcf_block *ceetm_tcf_block(struct Qdisc *sch, unsigned long arg)
87 {
88 struct ceetm_qdisc *priv = qdisc_priv(sch);
89 struct ceetm_class *cl = (struct ceetm_class *)arg;
90 - struct tcf_proto **fl = cl ? &cl->filter_list : &priv->filter_list;
91 + struct tcf_block *block = cl ? cl->block : priv->block;
92
93 pr_debug(KBUILD_BASENAME " : %s : class %X under qdisc %X\n", __func__,
94 cl ? cl->common.classid : 0, sch->handle);
95 - return fl;
96 + return block;
97 }
98
99 static unsigned long ceetm_tcf_bind(struct Qdisc *sch, unsigned long parent,
100 @@ -1816,7 +1829,7 @@ const struct Qdisc_class_ops ceetm_cls_o
101 .change = ceetm_cls_change,
102 .delete = ceetm_cls_delete,
103 .walk = ceetm_cls_walk,
104 - .tcf_chain = ceetm_tcf_chain,
105 + .tcf_block = ceetm_tcf_block,
106 .bind_tcf = ceetm_tcf_bind,
107 .unbind_tcf = ceetm_tcf_unbind,
108 .dump = ceetm_cls_dump,
109 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
110 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
111 @@ -141,6 +141,7 @@ struct ceetm_qdisc {
112 };
113 struct Qdisc_class_hash clhash;
114 struct tcf_proto *filter_list; /* qdisc attached filters */
115 + struct tcf_block *block;
116 };
117
118 /* CEETM Qdisc configuration parameters */
119 @@ -192,6 +193,7 @@ struct ceetm_class {
120 struct Qdisc_class_common common;
121 int refcnt; /* usage count of this class */
122 struct tcf_proto *filter_list; /* class attached filters */
123 + struct tcf_block *block;
124 struct Qdisc *parent;
125 bool shaped;
126 int type; /* ROOT/PRIO/WBFS */