1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
From fec484580477d93cd69e5355be68e6f5bf1a1e54 Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Mon, 9 Dec 2019 18:20:05 +0200
Subject: [PATCH] sdk_dpaa: ceetm: coding style cleanup
Fix checkpatch warnings and use reverse Christmas tree variable ordering
throughout the driver.
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
.../ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c | 145 +++++++++++----------
1 file changed, 76 insertions(+), 69 deletions(-)
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_ceetm.c
@@ -1,4 +1,5 @@
/* Copyright 2008-2016 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -47,10 +48,10 @@ struct Qdisc_ops ceetm_qdisc_ops;
static void get_dcp_and_sp(struct net_device *dev, enum qm_dc_portal *dcp_id,
unsigned int *sp_id)
{
- uint32_t channel;
- t_LnxWrpFmPortDev *port_dev;
struct dpa_priv_s *dpa_priv = netdev_priv(dev);
struct mac_device *mac_dev = dpa_priv->mac_dev;
+ t_LnxWrpFmPortDev *port_dev;
+ uint32_t channel;
port_dev = (t_LnxWrpFmPortDev *)mac_dev->port_dev[TX];
channel = port_dev->txCh;
@@ -75,7 +76,7 @@ static void dpaa_drain_fqs(struct net_de
struct qman_fq *fq;
int ret, i;
- for (i = 0; i < DPAA_ETH_TX_QUEUES; i ++) {
+ for (i = 0; i < DPAA_ETH_TX_QUEUES; i++) {
fq = priv->egress_fqs[i];
while (true) {
ret = qman_query_fq_np(fq, &np);
@@ -96,7 +97,7 @@ static void dpaa_drain_fqs(struct net_de
static void ceetm_drain_class(struct ceetm_class *cl)
{
struct qm_mcr_ceetm_cq_query cq_query;
- struct qm_ceetm_cq *cq;
+ struct qm_ceetm_cq *cq = NULL;
unsigned int idx;
int ret;
@@ -108,10 +109,10 @@ static void ceetm_drain_class(struct cee
/* The ROOT classes aren't directly linked to CEETM CQs */
return;
case CEETM_PRIO:
- cq = (struct qm_ceetm_cq*)cl->prio.cq;
+ cq = (struct qm_ceetm_cq *)cl->prio.cq;
break;
case CEETM_WBFS:
- cq = (struct qm_ceetm_cq*)cl->wbfs.cq;
+ cq = (struct qm_ceetm_cq *)cl->wbfs.cq;
break;
}
@@ -190,10 +191,14 @@ static void ceetm_ern(struct qman_portal
/* Congestion State Change Notification callback */
static void ceetm_cscn(struct qm_ceetm_ccg *ccg, void *cb_ctx, int congested)
{
- struct ceetm_fq *ceetm_fq = (struct ceetm_fq *)cb_ctx;
- struct dpa_priv_s *dpa_priv = netdev_priv(ceetm_fq->net_dev);
- struct ceetm_class *cls = ceetm_fq->ceetm_cls;
struct ceetm_class_stats *cstats = NULL;
+ struct dpa_priv_s *dpa_priv;
+ struct ceetm_fq *ceetm_fq;
+ struct ceetm_class *cls;
+
+ ceetm_fq = (struct ceetm_fq *)cb_ctx;
+ dpa_priv = netdev_priv(ceetm_fq->net_dev);
+ cls = ceetm_fq->ceetm_cls;
switch (cls->type) {
case CEETM_PRIO:
@@ -236,10 +241,10 @@ static int ceetm_config_ccg(struct qm_ce
struct qm_ceetm_channel *channel, unsigned int id,
struct ceetm_fq *fq, struct dpa_priv_s *dpa_priv)
{
- int err;
- u32 cs_th;
- u16 ccg_mask;
struct qm_ceetm_ccg_params ccg_params;
+ u16 ccg_mask;
+ u32 cs_th;
+ int err;
err = qman_ceetm_ccg_claim(ccg, channel, id, ceetm_cscn, fq);
if (err)
@@ -284,9 +289,9 @@ static int ceetm_config_ccg(struct qm_ce
static int ceetm_config_lfq(struct qm_ceetm_cq *cq, struct ceetm_fq *fq,
struct qm_ceetm_lfq **lfq)
{
- int err;
u64 context_a;
u32 context_b;
+ int err;
err = qman_ceetm_lfq_claim(lfq, cq);
if (err)
@@ -316,8 +321,8 @@ static int ceetm_config_prio_cls(struct
struct net_device *dev,
unsigned int id)
{
- int err;
struct dpa_priv_s *dpa_priv = netdev_priv(dev);
+ int err;
err = ceetm_alloc_fq(&cls->prio.fq, dev, cls);
if (err)
@@ -357,8 +362,8 @@ static int ceetm_config_wbfs_cls(struct
struct net_device *dev,
unsigned int id, int type)
{
- int err;
struct dpa_priv_s *dpa_priv = netdev_priv(dev);
+ int err;
err = ceetm_alloc_fq(&cls->wbfs.fq, dev, cls);
if (err)
@@ -517,11 +522,11 @@ static void ceetm_cls_destroy(struct Qdi
/* Destroy a ceetm qdisc */
static void ceetm_destroy(struct Qdisc *sch)
{
- unsigned int ntx, i;
- struct hlist_node *next;
- struct ceetm_class *cl;
struct ceetm_qdisc *priv = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch);
+ struct hlist_node *next;
+ struct ceetm_class *cl;
+ unsigned int ntx, i;
pr_debug(KBUILD_BASENAME " : %s : destroy qdisc %X\n",
__func__, sch->handle);
@@ -592,13 +597,13 @@ static void ceetm_destroy(struct Qdisc *
static int ceetm_dump(struct Qdisc *sch, struct sk_buff *skb)
{
+ struct ceetm_qdisc *priv = qdisc_priv(sch);
+ struct net_device *dev = qdisc_dev(sch);
+ struct ceetm_qdisc_stats *qstats;
+ struct tc_ceetm_qopt qopt;
struct Qdisc *qdisc;
unsigned int ntx, i;
struct nlattr *nest;
- struct tc_ceetm_qopt qopt;
- struct ceetm_qdisc_stats *qstats;
- struct net_device *dev = qdisc_dev(sch);
- struct ceetm_qdisc *priv = qdisc_priv(sch);
pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
@@ -673,17 +678,20 @@ static int ceetm_init_root(struct Qdisc
struct tc_ceetm_qopt *qopt,
struct netlink_ext_ack *extack)
{
+ struct net_device *dev = qdisc_dev(sch);
+ unsigned int i, sp_id, parent_id;
struct netdev_queue *dev_queue;
- struct Qdisc *qdisc;
+ struct dpa_priv_s *dpa_priv;
+ struct mac_device *mac_dev;
enum qm_dc_portal dcp_id;
- unsigned int i, sp_id, parent_id;
+ struct qm_ceetm_lni *lni;
+ struct qm_ceetm_sp *sp;
+ struct Qdisc *qdisc;
int err;
u64 bps;
- struct qm_ceetm_sp *sp;
- struct qm_ceetm_lni *lni;
- struct net_device *dev = qdisc_dev(sch);
- struct dpa_priv_s *dpa_priv = netdev_priv(dev);
- struct mac_device *mac_dev = dpa_priv->mac_dev;
+
+ dpa_priv = netdev_priv(dev);
+ mac_dev = dpa_priv->mac_dev;
pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
@@ -711,9 +719,8 @@ static int ceetm_init_root(struct Qdisc
priv->root.qdiscs = kcalloc(dev->num_tx_queues,
sizeof(priv->root.qdiscs[0]),
GFP_KERNEL);
- if (!priv->root.qdiscs) {
+ if (!priv->root.qdiscs)
return -ENOMEM;
- }
for (i = 0; i < dev->num_tx_queues; i++) {
dev_queue = netdev_get_tx_queue(dev, i);
@@ -811,11 +818,11 @@ static int ceetm_init_root(struct Qdisc
static int ceetm_init_prio(struct Qdisc *sch, struct ceetm_qdisc *priv,
struct tc_ceetm_qopt *qopt)
{
- int err;
- unsigned int i;
struct ceetm_class *parent_cl, *child_cl;
struct net_device *dev = qdisc_dev(sch);
struct Qdisc *root_qdisc = dev->qdisc;
+ unsigned int i;
+ int err;
pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
@@ -852,11 +859,8 @@ static int ceetm_init_prio(struct Qdisc
/* Create and configure qcount child classes */
for (i = 0; i < priv->prio.qcount; i++) {
child_cl = kzalloc(sizeof(*child_cl), GFP_KERNEL);
- if (!child_cl) {
- pr_err(KBUILD_BASENAME " : %s : kzalloc() failed\n",
- __func__);
+ if (!child_cl)
return -ENOMEM;
- }
child_cl->prio.cstats = alloc_percpu(struct ceetm_class_stats);
if (!child_cl->prio.cstats) {
@@ -906,12 +910,12 @@ err_init_prio_cls:
static int ceetm_init_wbfs(struct Qdisc *sch, struct ceetm_qdisc *priv,
struct tc_ceetm_qopt *qopt)
{
- int err, group_b, small_group;
- unsigned int i, id, prio_a, prio_b;
struct ceetm_class *parent_cl, *child_cl, *tmp_cl, *root_cl = NULL;
struct Qdisc *root_qdisc, *parent_qdisc = NULL;
- struct ceetm_qdisc *root_priv;
struct net_device *dev = qdisc_dev(sch);
+ unsigned int i, id, prio_a, prio_b;
+ int err, group_b, small_group;
+ struct ceetm_qdisc *root_priv;
pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
@@ -1070,11 +1074,8 @@ static int ceetm_init_wbfs(struct Qdisc
/* Create qcount child classes */
for (i = 0; i < priv->wbfs.qcount; i++) {
child_cl = kzalloc(sizeof(*child_cl), GFP_KERNEL);
- if (!child_cl) {
- pr_err(KBUILD_BASENAME " : %s : kzalloc() failed\n",
- __func__);
+ if (!child_cl)
return -ENOMEM;
- }
child_cl->wbfs.cstats = alloc_percpu(struct ceetm_class_stats);
if (!child_cl->wbfs.cstats) {
@@ -1138,11 +1139,11 @@ err_init_wbfs_cls:
static int ceetm_init(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
- struct tc_ceetm_qopt *qopt;
- struct nlattr *tb[TCA_CEETM_QOPS + 1];
- int ret;
struct ceetm_qdisc *priv = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch);
+ struct nlattr *tb[TCA_CEETM_QOPS + 1];
+ struct tc_ceetm_qopt *qopt;
+ int ret;
pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
@@ -1158,7 +1159,8 @@ static int ceetm_init(struct Qdisc *sch,
if (ret)
return ret;
- ret = nla_parse_nested_deprecated(tb, TCA_CEETM_QOPS, opt, ceetm_policy, NULL);
+ ret = nla_parse_nested_deprecated(tb, TCA_CEETM_QOPS, opt,
+ ceetm_policy, NULL);
if (ret < 0) {
pr_err(KBUILD_BASENAME " : %s : tc error\n", __func__);
return ret;
@@ -1265,8 +1267,8 @@ change_err:
static int ceetm_change_wbfs(struct Qdisc *sch, struct ceetm_qdisc *priv,
struct tc_ceetm_qopt *qopt)
{
- int err;
bool group_b;
+ int err;
if (qopt->qcount) {
pr_err("CEETM: the qcount can not be modified\n");
@@ -1324,15 +1326,16 @@ change_err:
static int ceetm_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
- struct tc_ceetm_qopt *qopt;
- struct nlattr *tb[TCA_CEETM_QOPS + 1];
- int ret;
struct ceetm_qdisc *priv = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch);
+ struct nlattr *tb[TCA_CEETM_QOPS + 1];
+ struct tc_ceetm_qopt *qopt;
+ int ret;
pr_debug(KBUILD_BASENAME " : %s : qdisc %X\n", __func__, sch->handle);
- ret = nla_parse_nested_deprecated(tb, TCA_CEETM_QOPS, opt, ceetm_policy, NULL);
+ ret = nla_parse_nested_deprecated(tb, TCA_CEETM_QOPS, opt,
+ ceetm_policy, NULL);
if (ret < 0) {
pr_err(KBUILD_BASENAME " : %s : tc error\n", __func__);
return ret;
@@ -1381,8 +1384,8 @@ static int ceetm_change(struct Qdisc *sc
*/
static void ceetm_attach(struct Qdisc *sch)
{
- struct net_device *dev = qdisc_dev(sch);
struct ceetm_qdisc *priv = qdisc_priv(sch);
+ struct net_device *dev = qdisc_dev(sch);
struct Qdisc *qdisc, *old_qdisc;
unsigned int i;
@@ -1461,8 +1464,8 @@ static int ceetm_cls_change_prio(struct
}
if (cl->prio.cr != (bool)copt->cr) {
- err = qman_ceetm_channel_set_cq_cr_eligibility(
- cl->prio.cq->parent,
+ err = qman_ceetm_channel_set_cq_cr_eligibility
+ (cl->prio.cq->parent,
cl->prio.cq->idx,
copt->cr);
if (err)
@@ -1471,8 +1474,8 @@ static int ceetm_cls_change_prio(struct
}
if (cl->prio.er != (bool)copt->er) {
- err = qman_ceetm_channel_set_cq_er_eligibility(
- cl->prio.cq->parent,
+ err = qman_ceetm_channel_set_cq_er_eligibility
+ (cl->prio.cq->parent,
cl->prio.cq->idx,
copt->er);
if (err)
@@ -1517,15 +1520,15 @@ static int ceetm_cls_change(struct Qdisc
struct nlattr **tca, unsigned long *arg,
struct netlink_ext_ack *extack)
{
- int err;
- u64 bps;
- struct ceetm_qdisc *priv;
struct ceetm_class *cl = (struct ceetm_class *)*arg;
+ struct net_device *dev = qdisc_dev(sch);
struct nlattr *opt = tca[TCA_OPTIONS];
struct nlattr *tb[__TCA_CEETM_MAX];
- struct tc_ceetm_copt *copt;
struct qm_ceetm_channel *channel;
- struct net_device *dev = qdisc_dev(sch);
+ struct tc_ceetm_copt *copt;
+ struct ceetm_qdisc *priv;
+ int err;
+ u64 bps;
pr_debug(KBUILD_BASENAME " : %s : classid %X under qdisc %X\n",
__func__, classid, sch->handle);
@@ -1552,7 +1555,8 @@ static int ceetm_cls_change(struct Qdisc
return -EINVAL;
}
- err = nla_parse_nested_deprecated(tb, TCA_CEETM_COPT, opt, ceetm_policy, NULL);
+ err = nla_parse_nested_deprecated(tb, TCA_CEETM_COPT, opt,
+ ceetm_policy, NULL);
if (err < 0) {
pr_err(KBUILD_BASENAME " : %s : tc error\n", __func__);
return -EINVAL;
@@ -1714,8 +1718,8 @@ static int ceetm_cls_dump(struct Qdisc *
struct sk_buff *skb, struct tcmsg *tcm)
{
struct ceetm_class *cl = (struct ceetm_class *)arg;
- struct nlattr *nest;
struct tc_ceetm_copt copt;
+ struct nlattr *nest;
pr_debug(KBUILD_BASENAME " : %s : class %X under qdisc %X\n",
__func__, cl->common.classid, sch->handle);
@@ -1770,8 +1774,8 @@ nla_put_failure:
static int ceetm_cls_delete(struct Qdisc *sch, unsigned long arg)
{
- struct ceetm_qdisc *priv = qdisc_priv(sch);
struct ceetm_class *cl = (struct ceetm_class *)arg;
+ struct ceetm_qdisc *priv = qdisc_priv(sch);
pr_debug(KBUILD_BASENAME " : %s : class %X under qdisc %X\n",
__func__, cl->common.classid, sch->handle);
@@ -1818,12 +1822,12 @@ static int ceetm_cls_graft(struct Qdisc
static int ceetm_cls_dump_stats(struct Qdisc *sch, unsigned long arg,
struct gnet_dump *d)
{
- unsigned int i;
struct ceetm_class *cl = (struct ceetm_class *)arg;
struct gnet_stats_basic_packed tmp_bstats;
struct ceetm_class_stats *cstats = NULL;
struct qm_ceetm_cq *cq = NULL;
struct tc_ceetm_xstats xstats;
+ unsigned int i;
memset(&xstats, 0, sizeof(xstats));
memset(&tmp_bstats, 0, sizeof(tmp_bstats));
@@ -1872,9 +1876,11 @@ static int ceetm_cls_dump_stats(struct Q
static struct tcf_block *ceetm_tcf_block(struct Qdisc *sch, unsigned long arg,
struct netlink_ext_ack *extack)
{
- struct ceetm_qdisc *priv = qdisc_priv(sch);
struct ceetm_class *cl = (struct ceetm_class *)arg;
- struct tcf_block *block = cl ? cl->block : priv->block;
+ struct ceetm_qdisc *priv = qdisc_priv(sch);
+ struct tcf_block *block;
+
+ block = cl ? cl->block : priv->block;
pr_debug(KBUILD_BASENAME " : %s : class %X under qdisc %X\n", __func__,
cl ? cl->common.classid : 0, sch->handle);
@@ -1945,6 +1951,7 @@ static struct ceetm_class *ceetm_classif
case TC_ACT_STOLEN:
case TC_ACT_TRAP:
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
+ /* fall through */
case TC_ACT_SHOT:
/* No valid class found due to action */
*act_drop = true;
|