layerscape: add patches-5.4
[openwrt/staging/mkresin.git] / target / linux / layerscape / patches-5.4 / 701-net-0068-sdk_dpaa-ceetm-propagate-the-ceetm-channel-through-t.patch
1 From dfd2deb8bc482588999a4f03b5ab5d049e50fdb0 Mon Sep 17 00:00:00 2001
2 From: Camelia Groza <camelia.groza@nxp.com>
3 Date: Wed, 30 May 2018 14:51:35 +0300
4 Subject: [PATCH] sdk_dpaa: ceetm: propagate the ceetm channel through the
5 qdisc tree
6
7 Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
8 ---
9 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c | 61 +++++++++-------------
10 .../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h | 4 +-
11 2 files changed, 29 insertions(+), 36 deletions(-)
12
13 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
14 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
15 @@ -242,7 +242,6 @@ static int ceetm_config_lfq(struct qm_ce
16 /* Configure a prio ceetm class */
17 static int ceetm_config_prio_cls(struct ceetm_class *cls,
18 struct net_device *dev,
19 - struct qm_ceetm_channel *channel,
20 unsigned int id)
21 {
22 int err;
23 @@ -253,22 +252,22 @@ static int ceetm_config_prio_cls(struct
24 return err;
25
26 /* Claim and configure the CCG */
27 - err = ceetm_config_ccg(&cls->prio.ccg, channel, id, cls->prio.fq,
28 + err = ceetm_config_ccg(&cls->prio.ccg, cls->ch, id, cls->prio.fq,
29 dpa_priv);
30 if (err)
31 return err;
32
33 /* Claim and configure the CQ */
34 - err = qman_ceetm_cq_claim(&cls->prio.cq, channel, id, cls->prio.ccg);
35 + err = qman_ceetm_cq_claim(&cls->prio.cq, cls->ch, id, cls->prio.ccg);
36 if (err)
37 return err;
38
39 if (cls->shaped) {
40 - err = qman_ceetm_channel_set_cq_cr_eligibility(channel, id, 1);
41 + err = qman_ceetm_channel_set_cq_cr_eligibility(cls->ch, id, 1);
42 if (err)
43 return err;
44
45 - err = qman_ceetm_channel_set_cq_er_eligibility(channel, id, 1);
46 + err = qman_ceetm_channel_set_cq_er_eligibility(cls->ch, id, 1);
47 if (err)
48 return err;
49 }
50 @@ -284,7 +283,6 @@ static int ceetm_config_prio_cls(struct
51 /* Configure a wbfs ceetm class */
52 static int ceetm_config_wbfs_cls(struct ceetm_class *cls,
53 struct net_device *dev,
54 - struct qm_ceetm_channel *channel,
55 unsigned int id, int type)
56 {
57 int err;
58 @@ -295,17 +293,17 @@ static int ceetm_config_wbfs_cls(struct
59 return err;
60
61 /* Claim and configure the CCG */
62 - err = ceetm_config_ccg(&cls->wbfs.ccg, channel, id, cls->wbfs.fq,
63 + err = ceetm_config_ccg(&cls->wbfs.ccg, cls->ch, id, cls->wbfs.fq,
64 dpa_priv);
65 if (err)
66 return err;
67
68 /* Claim and configure the CQ */
69 if (type == WBFS_GRP_B)
70 - err = qman_ceetm_cq_claim_B(&cls->wbfs.cq, channel, id,
71 + err = qman_ceetm_cq_claim_B(&cls->wbfs.cq, cls->ch, id,
72 cls->wbfs.ccg);
73 else
74 - err = qman_ceetm_cq_claim_A(&cls->wbfs.cq, channel, id,
75 + err = qman_ceetm_cq_claim_A(&cls->wbfs.cq, cls->ch, id,
76 cls->wbfs.ccg);
77 if (err)
78 return err;
79 @@ -366,10 +364,10 @@ static void ceetm_cls_destroy(struct Qdi
80 cl->root.child = NULL;
81 }
82
83 - if (cl->root.ch && qman_ceetm_channel_release(cl->root.ch))
84 + if (cl->ch && qman_ceetm_channel_release(cl->ch))
85 pr_err(KBUILD_BASENAME
86 " : %s : error releasing the channel %d\n",
87 - __func__, cl->root.ch->idx);
88 + __func__, cl->ch->idx);
89
90 break;
91
92 @@ -766,6 +764,7 @@ static int ceetm_init_prio(struct Qdisc
93
94 priv->shaped = parent_cl->shaped;
95 priv->prio.qcount = qopt->qcount;
96 + priv->prio.ch = parent_cl->ch;
97
98 /* Create and configure qcount child classes */
99 for (i = 0; i < priv->prio.qcount; i++) {
100 @@ -790,6 +789,7 @@ static int ceetm_init_prio(struct Qdisc
101 child_cl->type = CEETM_PRIO;
102 child_cl->shaped = priv->shaped;
103 child_cl->prio.child = NULL;
104 + child_cl->ch = priv->prio.ch;
105
106 /* All shaped CQs have CR and ER enabled by default */
107 child_cl->prio.cr = child_cl->shaped;
108 @@ -798,8 +798,7 @@ static int ceetm_init_prio(struct Qdisc
109 child_cl->prio.cq = NULL;
110
111 /* Configure the corresponding hardware CQ */
112 - err = ceetm_config_prio_cls(child_cl, dev,
113 - parent_cl->root.ch, i);
114 + err = ceetm_config_prio_cls(child_cl, dev, i);
115 if (err) {
116 pr_err(KBUILD_BASENAME " : %s : failed to configure the ceetm prio class %X\n",
117 __func__, child_cl->common.classid);
118 @@ -831,7 +830,6 @@ static int ceetm_init_wbfs(struct Qdisc
119 struct ceetm_class *parent_cl, *child_cl, *root_cl;
120 struct Qdisc *parent_qdisc;
121 struct ceetm_qdisc *parent_priv;
122 - struct qm_ceetm_channel *channel;
123 struct net_device *dev = qdisc_dev(sch);
124
125 pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
126 @@ -904,8 +902,7 @@ static int ceetm_init_wbfs(struct Qdisc
127 priv->wbfs.qcount = qopt->qcount;
128 priv->wbfs.cr = qopt->cr;
129 priv->wbfs.er = qopt->er;
130 -
131 - channel = root_cl->root.ch;
132 + priv->wbfs.ch = parent_cl->ch;
133
134 /* Configure the hardware wbfs channel groups */
135 if (priv->wbfs.qcount == CEETM_MAX_WBFS_QCOUNT) {
136 @@ -920,7 +917,7 @@ static int ceetm_init_wbfs(struct Qdisc
137 /* Configure the group B */
138 priv->wbfs.group_type = WBFS_GRP_B;
139
140 - err = qman_ceetm_channel_get_group(channel, &small_group,
141 + err = qman_ceetm_channel_get_group(priv->wbfs.ch, &small_group,
142 &prio_a, &prio_b);
143 if (err) {
144 pr_err(KBUILD_BASENAME " : %s : failed to get group details\n",
145 @@ -938,7 +935,7 @@ static int ceetm_init_wbfs(struct Qdisc
146 /* Configure the small group A */
147 priv->wbfs.group_type = WBFS_GRP_A;
148
149 - err = qman_ceetm_channel_get_group(channel, &small_group,
150 + err = qman_ceetm_channel_get_group(priv->wbfs.ch, &small_group,
151 &prio_a, &prio_b);
152 if (err) {
153 pr_err(KBUILD_BASENAME " : %s : failed to get group details\n",
154 @@ -953,13 +950,13 @@ static int ceetm_init_wbfs(struct Qdisc
155 prio_b = prio_b ? : prio_a;
156 }
157
158 - err = qman_ceetm_channel_set_group(channel, small_group, prio_a,
159 + err = qman_ceetm_channel_set_group(priv->wbfs.ch, small_group, prio_a,
160 prio_b);
161 if (err)
162 goto err_init_wbfs;
163
164 if (priv->shaped) {
165 - err = qman_ceetm_channel_set_group_cr_eligibility(channel,
166 + err = qman_ceetm_channel_set_group_cr_eligibility(priv->wbfs.ch,
167 group_b,
168 priv->wbfs.cr);
169 if (err) {
170 @@ -968,7 +965,7 @@ static int ceetm_init_wbfs(struct Qdisc
171 goto err_init_wbfs;
172 }
173
174 - err = qman_ceetm_channel_set_group_er_eligibility(channel,
175 + err = qman_ceetm_channel_set_group_er_eligibility(priv->wbfs.ch,
176 group_b,
177 priv->wbfs.er);
178 if (err) {
179 @@ -1003,13 +1000,14 @@ static int ceetm_init_wbfs(struct Qdisc
180 child_cl->wbfs.fq = NULL;
181 child_cl->wbfs.cq = NULL;
182 child_cl->wbfs.weight = qopt->qweight[i];
183 + child_cl->ch = priv->wbfs.ch;
184
185 if (priv->wbfs.group_type == WBFS_GRP_B)
186 id = WBFS_GRP_B_OFFSET + i;
187 else
188 id = WBFS_GRP_A_OFFSET + i;
189
190 - err = ceetm_config_wbfs_cls(child_cl, dev, channel, id,
191 + err = ceetm_config_wbfs_cls(child_cl, dev, id,
192 priv->wbfs.group_type);
193 if (err) {
194 pr_err(KBUILD_BASENAME " : %s : failed to configure the ceetm wbfs class %X\n",
195 @@ -1178,9 +1176,6 @@ static int ceetm_change_wbfs(struct Qdis
196 {
197 int err;
198 bool group_b;
199 - struct qm_ceetm_channel *channel;
200 - struct ceetm_class *prio_class, *root_class;
201 - struct ceetm_qdisc *prio_qdisc;
202
203 if (qopt->qcount) {
204 pr_err("CEETM: the qcount can not be modified\n");
205 @@ -1206,14 +1201,10 @@ static int ceetm_change_wbfs(struct Qdis
206 if (!priv->shaped)
207 return 0;
208
209 - prio_class = priv->wbfs.parent;
210 - prio_qdisc = qdisc_priv(prio_class->parent);
211 - root_class = prio_qdisc->prio.parent;
212 - channel = root_class->root.ch;
213 group_b = priv->wbfs.group_type == WBFS_GRP_B;
214
215 if (qopt->cr != priv->wbfs.cr) {
216 - err = qman_ceetm_channel_set_group_cr_eligibility(channel,
217 + err = qman_ceetm_channel_set_group_cr_eligibility(priv->wbfs.ch,
218 group_b,
219 qopt->cr);
220 if (err)
221 @@ -1222,7 +1213,7 @@ static int ceetm_change_wbfs(struct Qdis
222 }
223
224 if (qopt->er != priv->wbfs.er) {
225 - err = qman_ceetm_channel_set_group_er_eligibility(channel,
226 + err = qman_ceetm_channel_set_group_er_eligibility(priv->wbfs.ch,
227 group_b,
228 qopt->er);
229 if (err)
230 @@ -1337,7 +1328,7 @@ static int ceetm_cls_change_root(struct
231
232 if (cl->shaped && cl->root.rate != copt->rate) {
233 bps = copt->rate << 3; /* Bps -> bps */
234 - err = qman_ceetm_channel_set_commit_rate_bps(cl->root.ch, bps,
235 + err = qman_ceetm_channel_set_commit_rate_bps(cl->ch, bps,
236 dev->mtu);
237 if (err)
238 goto change_cls_err;
239 @@ -1346,7 +1337,7 @@ static int ceetm_cls_change_root(struct
240
241 if (cl->shaped && cl->root.ceil != copt->ceil) {
242 bps = copt->ceil << 3; /* Bps -> bps */
243 - err = qman_ceetm_channel_set_excess_rate_bps(cl->root.ch, bps,
244 + err = qman_ceetm_channel_set_excess_rate_bps(cl->ch, bps,
245 dev->mtu);
246 if (err)
247 goto change_cls_err;
248 @@ -1354,7 +1345,7 @@ static int ceetm_cls_change_root(struct
249 }
250
251 if (!cl->shaped && cl->root.tbl != copt->tbl) {
252 - err = qman_ceetm_channel_set_weight(cl->root.ch, copt->tbl);
253 + err = qman_ceetm_channel_set_weight(cl->ch, copt->tbl);
254 if (err)
255 goto change_cls_err;
256 cl->root.tbl = copt->tbl;
257 @@ -1555,7 +1546,7 @@ static int ceetm_cls_change(struct Qdisc
258 goto claim_err;
259 }
260
261 - cl->root.ch = channel;
262 + cl->ch = channel;
263
264 if (cl->shaped) {
265 /* Configure the channel shaper */
266 --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
267 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.h
268 @@ -121,12 +121,14 @@ struct root_q {
269 struct prio_q {
270 __u16 qcount;
271 struct ceetm_class *parent;
272 + struct qm_ceetm_channel *ch;
273 };
274
275 struct wbfs_q {
276 __u16 qcount;
277 int group_type;
278 struct ceetm_class *parent;
279 + struct qm_ceetm_channel *ch;
280 __u16 cr;
281 __u16 er;
282 };
283 @@ -165,7 +167,6 @@ struct root_c {
284 bool wbfs_grp_b;
285 bool wbfs_grp_large;
286 struct Qdisc *child;
287 - struct qm_ceetm_channel *ch;
288 };
289
290 struct prio_c {
291 @@ -194,6 +195,7 @@ struct ceetm_class {
292 struct tcf_proto *filter_list; /* class attached filters */
293 struct tcf_block *block;
294 struct Qdisc *parent;
295 + struct qm_ceetm_channel *ch;
296 bool shaped;
297 int type; /* ROOT/PRIO/WBFS */
298 union {