GNU Linux-libre 4.19.286-gnu1
[releases.git] / drivers / net / ethernet / marvell / mvpp2 / mvpp2_debugfs.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Driver for Marvell PPv2 network controller for Armada 375 SoC.
4  *
5  * Copyright (C) 2018 Marvell
6  */
7
8 #include <linux/kernel.h>
9 #include <linux/slab.h>
10 #include <linux/debugfs.h>
11
12 #include "mvpp2.h"
13 #include "mvpp2_prs.h"
14 #include "mvpp2_cls.h"
15
16 struct mvpp2_dbgfs_prs_entry {
17         int tid;
18         struct mvpp2 *priv;
19 };
20
21 struct mvpp2_dbgfs_flow_entry {
22         int flow;
23         struct mvpp2 *priv;
24 };
25
26 struct mvpp2_dbgfs_port_flow_entry {
27         struct mvpp2_port *port;
28         struct mvpp2_dbgfs_flow_entry *dbg_fe;
29 };
30
31 static int mvpp2_dbgfs_flow_flt_hits_show(struct seq_file *s, void *unused)
32 {
33         struct mvpp2_dbgfs_flow_entry *entry = s->private;
34         int id = MVPP2_FLOW_C2_ENTRY(entry->flow);
35
36         u32 hits = mvpp2_cls_flow_hits(entry->priv, id);
37
38         seq_printf(s, "%u\n", hits);
39
40         return 0;
41 }
42
43 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_flow_flt_hits);
44
45 static int mvpp2_dbgfs_flow_dec_hits_show(struct seq_file *s, void *unused)
46 {
47         struct mvpp2_dbgfs_flow_entry *entry = s->private;
48
49         u32 hits = mvpp2_cls_lookup_hits(entry->priv, entry->flow);
50
51         seq_printf(s, "%u\n", hits);
52
53         return 0;
54 }
55
56 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_flow_dec_hits);
57
58 static int mvpp2_dbgfs_flow_type_show(struct seq_file *s, void *unused)
59 {
60         struct mvpp2_dbgfs_flow_entry *entry = s->private;
61         struct mvpp2_cls_flow *f;
62         const char *flow_name;
63
64         f = mvpp2_cls_flow_get(entry->flow);
65         if (!f)
66                 return -EINVAL;
67
68         switch (f->flow_type) {
69         case IPV4_FLOW:
70                 flow_name = "ipv4";
71                 break;
72         case IPV6_FLOW:
73                 flow_name = "ipv6";
74                 break;
75         case TCP_V4_FLOW:
76                 flow_name = "tcp4";
77                 break;
78         case TCP_V6_FLOW:
79                 flow_name = "tcp6";
80                 break;
81         case UDP_V4_FLOW:
82                 flow_name = "udp4";
83                 break;
84         case UDP_V6_FLOW:
85                 flow_name = "udp6";
86                 break;
87         default:
88                 flow_name = "other";
89         }
90
91         seq_printf(s, "%s\n", flow_name);
92
93         return 0;
94 }
95
96 static int mvpp2_dbgfs_flow_type_open(struct inode *inode, struct file *file)
97 {
98         return single_open(file, mvpp2_dbgfs_flow_type_show, inode->i_private);
99 }
100
101 static int mvpp2_dbgfs_flow_type_release(struct inode *inode, struct file *file)
102 {
103         struct seq_file *seq = file->private_data;
104         struct mvpp2_dbgfs_flow_entry *flow_entry = seq->private;
105
106         kfree(flow_entry);
107         return single_release(inode, file);
108 }
109
110 static const struct file_operations mvpp2_dbgfs_flow_type_fops = {
111         .open = mvpp2_dbgfs_flow_type_open,
112         .read = seq_read,
113         .release = mvpp2_dbgfs_flow_type_release,
114 };
115
116 static int mvpp2_dbgfs_flow_id_show(struct seq_file *s, void *unused)
117 {
118         struct mvpp2_dbgfs_flow_entry *entry = s->private;
119         struct mvpp2_cls_flow *f;
120
121         f = mvpp2_cls_flow_get(entry->flow);
122         if (!f)
123                 return -EINVAL;
124
125         seq_printf(s, "%d\n", f->flow_id);
126
127         return 0;
128 }
129
130 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_flow_id);
131
132 static int mvpp2_dbgfs_port_flow_hash_opt_show(struct seq_file *s, void *unused)
133 {
134         struct mvpp2_dbgfs_port_flow_entry *entry = s->private;
135         struct mvpp2_port *port = entry->port;
136         struct mvpp2_cls_flow_entry fe;
137         struct mvpp2_cls_flow *f;
138         int flow_index;
139         u16 hash_opts;
140
141         f = mvpp2_cls_flow_get(entry->dbg_fe->flow);
142         if (!f)
143                 return -EINVAL;
144
145         flow_index = MVPP2_PORT_FLOW_HASH_ENTRY(entry->port->id, f->flow_id);
146
147         mvpp2_cls_flow_read(port->priv, flow_index, &fe);
148
149         hash_opts = mvpp2_flow_get_hek_fields(&fe);
150
151         seq_printf(s, "0x%04x\n", hash_opts);
152
153         return 0;
154 }
155
156 static int mvpp2_dbgfs_port_flow_hash_opt_open(struct inode *inode,
157                                                struct file *file)
158 {
159         return single_open(file, mvpp2_dbgfs_port_flow_hash_opt_show,
160                            inode->i_private);
161 }
162
163 static int mvpp2_dbgfs_port_flow_hash_opt_release(struct inode *inode,
164                                                   struct file *file)
165 {
166         struct seq_file *seq = file->private_data;
167         struct mvpp2_dbgfs_port_flow_entry *flow_entry = seq->private;
168
169         kfree(flow_entry);
170         return single_release(inode, file);
171 }
172
173 static const struct file_operations mvpp2_dbgfs_port_flow_hash_opt_fops = {
174         .open = mvpp2_dbgfs_port_flow_hash_opt_open,
175         .read = seq_read,
176         .release = mvpp2_dbgfs_port_flow_hash_opt_release,
177 };
178
179 static int mvpp2_dbgfs_port_flow_engine_show(struct seq_file *s, void *unused)
180 {
181         struct mvpp2_dbgfs_port_flow_entry *entry = s->private;
182         struct mvpp2_port *port = entry->port;
183         struct mvpp2_cls_flow_entry fe;
184         struct mvpp2_cls_flow *f;
185         int flow_index, engine;
186
187         f = mvpp2_cls_flow_get(entry->dbg_fe->flow);
188         if (!f)
189                 return -EINVAL;
190
191         flow_index = MVPP2_PORT_FLOW_HASH_ENTRY(entry->port->id, f->flow_id);
192
193         mvpp2_cls_flow_read(port->priv, flow_index, &fe);
194
195         engine = mvpp2_cls_flow_eng_get(&fe);
196
197         seq_printf(s, "%d\n", engine);
198
199         return 0;
200 }
201
202 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_port_flow_engine);
203
204 static int mvpp2_dbgfs_flow_c2_hits_show(struct seq_file *s, void *unused)
205 {
206         struct mvpp2_port *port = s->private;
207         u32 hits;
208
209         hits = mvpp2_cls_c2_hit_count(port->priv,
210                                       MVPP22_CLS_C2_RSS_ENTRY(port->id));
211
212         seq_printf(s, "%u\n", hits);
213
214         return 0;
215 }
216
217 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_flow_c2_hits);
218
219 static int mvpp2_dbgfs_flow_c2_rxq_show(struct seq_file *s, void *unused)
220 {
221         struct mvpp2_port *port = s->private;
222         struct mvpp2_cls_c2_entry c2;
223         u8 qh, ql;
224
225         mvpp2_cls_c2_read(port->priv, MVPP22_CLS_C2_RSS_ENTRY(port->id), &c2);
226
227         qh = (c2.attr[0] >> MVPP22_CLS_C2_ATTR0_QHIGH_OFFS) &
228              MVPP22_CLS_C2_ATTR0_QHIGH_MASK;
229
230         ql = (c2.attr[0] >> MVPP22_CLS_C2_ATTR0_QLOW_OFFS) &
231              MVPP22_CLS_C2_ATTR0_QLOW_MASK;
232
233         seq_printf(s, "%d\n", (qh << 3 | ql));
234
235         return 0;
236 }
237
238 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_flow_c2_rxq);
239
240 static int mvpp2_dbgfs_flow_c2_enable_show(struct seq_file *s, void *unused)
241 {
242         struct mvpp2_port *port = s->private;
243         struct mvpp2_cls_c2_entry c2;
244         int enabled;
245
246         mvpp2_cls_c2_read(port->priv, MVPP22_CLS_C2_RSS_ENTRY(port->id), &c2);
247
248         enabled = !!(c2.attr[2] & MVPP22_CLS_C2_ATTR2_RSS_EN);
249
250         seq_printf(s, "%d\n", enabled);
251
252         return 0;
253 }
254
255 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_flow_c2_enable);
256
257 static int mvpp2_dbgfs_port_vid_show(struct seq_file *s, void *unused)
258 {
259         struct mvpp2_port *port = s->private;
260         unsigned char byte[2], enable[2];
261         struct mvpp2 *priv = port->priv;
262         struct mvpp2_prs_entry pe;
263         unsigned long pmap;
264         u16 rvid;
265         int tid;
266
267         for (tid = MVPP2_PRS_VID_PORT_FIRST(port->id);
268              tid <= MVPP2_PRS_VID_PORT_LAST(port->id); tid++) {
269                 mvpp2_prs_init_from_hw(priv, &pe, tid);
270
271                 pmap = mvpp2_prs_tcam_port_map_get(&pe);
272
273                 if (!priv->prs_shadow[tid].valid)
274                         continue;
275
276                 if (!test_bit(port->id, &pmap))
277                         continue;
278
279                 mvpp2_prs_tcam_data_byte_get(&pe, 2, &byte[0], &enable[0]);
280                 mvpp2_prs_tcam_data_byte_get(&pe, 3, &byte[1], &enable[1]);
281
282                 rvid = ((byte[0] & 0xf) << 8) + byte[1];
283
284                 seq_printf(s, "%u\n", rvid);
285         }
286
287         return 0;
288 }
289
290 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_port_vid);
291
292 static int mvpp2_dbgfs_port_parser_show(struct seq_file *s, void *unused)
293 {
294         struct mvpp2_port *port = s->private;
295         struct mvpp2 *priv = port->priv;
296         struct mvpp2_prs_entry pe;
297         unsigned long pmap;
298         int i;
299
300         for (i = 0; i < MVPP2_PRS_TCAM_SRAM_SIZE; i++) {
301                 mvpp2_prs_init_from_hw(port->priv, &pe, i);
302
303                 pmap = mvpp2_prs_tcam_port_map_get(&pe);
304                 if (priv->prs_shadow[i].valid && test_bit(port->id, &pmap))
305                         seq_printf(s, "%03d\n", i);
306         }
307
308         return 0;
309 }
310
311 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_port_parser);
312
313 static int mvpp2_dbgfs_filter_show(struct seq_file *s, void *unused)
314 {
315         struct mvpp2_port *port = s->private;
316         struct mvpp2 *priv = port->priv;
317         struct mvpp2_prs_entry pe;
318         unsigned long pmap;
319         int index, tid;
320
321         for (tid = MVPP2_PE_MAC_RANGE_START;
322              tid <= MVPP2_PE_MAC_RANGE_END; tid++) {
323                 unsigned char da[ETH_ALEN], da_mask[ETH_ALEN];
324
325                 if (!priv->prs_shadow[tid].valid ||
326                     priv->prs_shadow[tid].lu != MVPP2_PRS_LU_MAC ||
327                     priv->prs_shadow[tid].udf != MVPP2_PRS_UDF_MAC_DEF)
328                         continue;
329
330                 mvpp2_prs_init_from_hw(priv, &pe, tid);
331
332                 pmap = mvpp2_prs_tcam_port_map_get(&pe);
333
334                 /* We only want entries active on this port */
335                 if (!test_bit(port->id, &pmap))
336                         continue;
337
338                 /* Read mac addr from entry */
339                 for (index = 0; index < ETH_ALEN; index++)
340                         mvpp2_prs_tcam_data_byte_get(&pe, index, &da[index],
341                                                      &da_mask[index]);
342
343                 seq_printf(s, "%pM\n", da);
344         }
345
346         return 0;
347 }
348
349 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_filter);
350
351 static int mvpp2_dbgfs_prs_lu_show(struct seq_file *s, void *unused)
352 {
353         struct mvpp2_dbgfs_prs_entry *entry = s->private;
354         struct mvpp2 *priv = entry->priv;
355
356         seq_printf(s, "%x\n", priv->prs_shadow[entry->tid].lu);
357
358         return 0;
359 }
360
361 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_lu);
362
363 static int mvpp2_dbgfs_prs_pmap_show(struct seq_file *s, void *unused)
364 {
365         struct mvpp2_dbgfs_prs_entry *entry = s->private;
366         struct mvpp2_prs_entry pe;
367         unsigned int pmap;
368
369         mvpp2_prs_init_from_hw(entry->priv, &pe, entry->tid);
370
371         pmap = mvpp2_prs_tcam_port_map_get(&pe);
372         pmap &= MVPP2_PRS_PORT_MASK;
373
374         seq_printf(s, "%02x\n", pmap);
375
376         return 0;
377 }
378
379 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_pmap);
380
381 static int mvpp2_dbgfs_prs_ai_show(struct seq_file *s, void *unused)
382 {
383         struct mvpp2_dbgfs_prs_entry *entry = s->private;
384         struct mvpp2_prs_entry pe;
385         unsigned char ai, ai_mask;
386
387         mvpp2_prs_init_from_hw(entry->priv, &pe, entry->tid);
388
389         ai = pe.tcam[MVPP2_PRS_TCAM_AI_WORD] & MVPP2_PRS_AI_MASK;
390         ai_mask = (pe.tcam[MVPP2_PRS_TCAM_AI_WORD] >> 16) & MVPP2_PRS_AI_MASK;
391
392         seq_printf(s, "%02x %02x\n", ai, ai_mask);
393
394         return 0;
395 }
396
397 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_ai);
398
399 static int mvpp2_dbgfs_prs_hdata_show(struct seq_file *s, void *unused)
400 {
401         struct mvpp2_dbgfs_prs_entry *entry = s->private;
402         struct mvpp2_prs_entry pe;
403         unsigned char data[8], mask[8];
404         int i;
405
406         mvpp2_prs_init_from_hw(entry->priv, &pe, entry->tid);
407
408         for (i = 0; i < 8; i++)
409                 mvpp2_prs_tcam_data_byte_get(&pe, i, &data[i], &mask[i]);
410
411         seq_printf(s, "%*phN %*phN\n", 8, data, 8, mask);
412
413         return 0;
414 }
415
416 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_hdata);
417
418 static int mvpp2_dbgfs_prs_sram_show(struct seq_file *s, void *unused)
419 {
420         struct mvpp2_dbgfs_prs_entry *entry = s->private;
421         struct mvpp2_prs_entry pe;
422
423         mvpp2_prs_init_from_hw(entry->priv, &pe, entry->tid);
424
425         seq_printf(s, "%*phN\n", 14, pe.sram);
426
427         return 0;
428 }
429
430 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_sram);
431
432 static int mvpp2_dbgfs_prs_hits_show(struct seq_file *s, void *unused)
433 {
434         struct mvpp2_dbgfs_prs_entry *entry = s->private;
435         int val;
436
437         val = mvpp2_prs_hits(entry->priv, entry->tid);
438         if (val < 0)
439                 return val;
440
441         seq_printf(s, "%d\n", val);
442
443         return 0;
444 }
445
446 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_hits);
447
448 static int mvpp2_dbgfs_prs_valid_show(struct seq_file *s, void *unused)
449 {
450         struct mvpp2_dbgfs_prs_entry *entry = s->private;
451         struct mvpp2 *priv = entry->priv;
452         int tid = entry->tid;
453
454         seq_printf(s, "%d\n", priv->prs_shadow[tid].valid ? 1 : 0);
455
456         return 0;
457 }
458
459 static int mvpp2_dbgfs_prs_valid_open(struct inode *inode, struct file *file)
460 {
461         return single_open(file, mvpp2_dbgfs_prs_valid_show, inode->i_private);
462 }
463
464 static int mvpp2_dbgfs_prs_valid_release(struct inode *inode, struct file *file)
465 {
466         struct seq_file *seq = file->private_data;
467         struct mvpp2_dbgfs_prs_entry *entry = seq->private;
468
469         kfree(entry);
470         return single_release(inode, file);
471 }
472
473 static const struct file_operations mvpp2_dbgfs_prs_valid_fops = {
474         .open = mvpp2_dbgfs_prs_valid_open,
475         .read = seq_read,
476         .release = mvpp2_dbgfs_prs_valid_release,
477 };
478
479 static int mvpp2_dbgfs_flow_port_init(struct dentry *parent,
480                                       struct mvpp2_port *port,
481                                       struct mvpp2_dbgfs_flow_entry *entry)
482 {
483         struct mvpp2_dbgfs_port_flow_entry *port_entry;
484         struct dentry *port_dir;
485
486         port_dir = debugfs_create_dir(port->dev->name, parent);
487
488         /* This will be freed by 'hash_opts' release op */
489         port_entry = kmalloc(sizeof(*port_entry), GFP_KERNEL);
490         if (!port_entry)
491                 return -ENOMEM;
492
493         port_entry->port = port;
494         port_entry->dbg_fe = entry;
495
496         debugfs_create_file("hash_opts", 0444, port_dir, port_entry,
497                             &mvpp2_dbgfs_port_flow_hash_opt_fops);
498
499         debugfs_create_file("engine", 0444, port_dir, port_entry,
500                             &mvpp2_dbgfs_port_flow_engine_fops);
501
502         return 0;
503 }
504
505 static int mvpp2_dbgfs_flow_entry_init(struct dentry *parent,
506                                        struct mvpp2 *priv, int flow)
507 {
508         struct mvpp2_dbgfs_flow_entry *entry;
509         struct dentry *flow_entry_dir;
510         char flow_entry_name[10];
511         int i, ret;
512
513         sprintf(flow_entry_name, "%02d", flow);
514
515         flow_entry_dir = debugfs_create_dir(flow_entry_name, parent);
516
517         /* This will be freed by 'type' release op */
518         entry = kmalloc(sizeof(*entry), GFP_KERNEL);
519         if (!entry)
520                 return -ENOMEM;
521
522         entry->flow = flow;
523         entry->priv = priv;
524
525         debugfs_create_file("flow_hits", 0444, flow_entry_dir, entry,
526                             &mvpp2_dbgfs_flow_flt_hits_fops);
527
528         debugfs_create_file("dec_hits", 0444, flow_entry_dir, entry,
529                             &mvpp2_dbgfs_flow_dec_hits_fops);
530
531         debugfs_create_file("type", 0444, flow_entry_dir, entry,
532                             &mvpp2_dbgfs_flow_type_fops);
533
534         debugfs_create_file("id", 0444, flow_entry_dir, entry,
535                             &mvpp2_dbgfs_flow_id_fops);
536
537         /* Create entry for each port */
538         for (i = 0; i < priv->port_count; i++) {
539                 ret = mvpp2_dbgfs_flow_port_init(flow_entry_dir,
540                                                  priv->port_list[i], entry);
541                 if (ret)
542                         return ret;
543         }
544         return 0;
545 }
546
547 static int mvpp2_dbgfs_flow_init(struct dentry *parent, struct mvpp2 *priv)
548 {
549         struct dentry *flow_dir;
550         int i, ret;
551
552         flow_dir = debugfs_create_dir("flows", parent);
553
554         for (i = 0; i < MVPP2_N_FLOWS; i++) {
555                 ret = mvpp2_dbgfs_flow_entry_init(flow_dir, priv, i);
556                 if (ret)
557                         return ret;
558         }
559
560         return 0;
561 }
562
563 static int mvpp2_dbgfs_prs_entry_init(struct dentry *parent,
564                                       struct mvpp2 *priv, int tid)
565 {
566         struct mvpp2_dbgfs_prs_entry *entry;
567         struct dentry *prs_entry_dir;
568         char prs_entry_name[10];
569
570         if (tid >= MVPP2_PRS_TCAM_SRAM_SIZE)
571                 return -EINVAL;
572
573         sprintf(prs_entry_name, "%03d", tid);
574
575         prs_entry_dir = debugfs_create_dir(prs_entry_name, parent);
576
577         /* The 'valid' entry's ops will free that */
578         entry = kmalloc(sizeof(*entry), GFP_KERNEL);
579         if (!entry)
580                 return -ENOMEM;
581
582         entry->tid = tid;
583         entry->priv = priv;
584
585         /* Create each attr */
586         debugfs_create_file("sram", 0444, prs_entry_dir, entry,
587                             &mvpp2_dbgfs_prs_sram_fops);
588
589         debugfs_create_file("valid", 0644, prs_entry_dir, entry,
590                             &mvpp2_dbgfs_prs_valid_fops);
591
592         debugfs_create_file("lookup_id", 0644, prs_entry_dir, entry,
593                             &mvpp2_dbgfs_prs_lu_fops);
594
595         debugfs_create_file("ai", 0644, prs_entry_dir, entry,
596                             &mvpp2_dbgfs_prs_ai_fops);
597
598         debugfs_create_file("header_data", 0644, prs_entry_dir, entry,
599                             &mvpp2_dbgfs_prs_hdata_fops);
600
601         debugfs_create_file("hits", 0444, prs_entry_dir, entry,
602                             &mvpp2_dbgfs_prs_hits_fops);
603
604         return 0;
605 }
606
607 static int mvpp2_dbgfs_prs_init(struct dentry *parent, struct mvpp2 *priv)
608 {
609         struct dentry *prs_dir;
610         int i, ret;
611
612         prs_dir = debugfs_create_dir("parser", parent);
613
614         for (i = 0; i < MVPP2_PRS_TCAM_SRAM_SIZE; i++) {
615                 ret = mvpp2_dbgfs_prs_entry_init(prs_dir, priv, i);
616                 if (ret)
617                         return ret;
618         }
619
620         return 0;
621 }
622
623 static int mvpp2_dbgfs_port_init(struct dentry *parent,
624                                  struct mvpp2_port *port)
625 {
626         struct dentry *port_dir;
627
628         port_dir = debugfs_create_dir(port->dev->name, parent);
629
630         debugfs_create_file("parser_entries", 0444, port_dir, port,
631                             &mvpp2_dbgfs_port_parser_fops);
632
633         debugfs_create_file("mac_filter", 0444, port_dir, port,
634                             &mvpp2_dbgfs_filter_fops);
635
636         debugfs_create_file("vid_filter", 0444, port_dir, port,
637                             &mvpp2_dbgfs_port_vid_fops);
638
639         debugfs_create_file("c2_hits", 0444, port_dir, port,
640                             &mvpp2_dbgfs_flow_c2_hits_fops);
641
642         debugfs_create_file("default_rxq", 0444, port_dir, port,
643                             &mvpp2_dbgfs_flow_c2_rxq_fops);
644
645         debugfs_create_file("rss_enable", 0444, port_dir, port,
646                             &mvpp2_dbgfs_flow_c2_enable_fops);
647
648         return 0;
649 }
650
651 static struct dentry *mvpp2_root;
652
653 void mvpp2_dbgfs_exit(void)
654 {
655         debugfs_remove(mvpp2_root);
656 }
657
658 void mvpp2_dbgfs_cleanup(struct mvpp2 *priv)
659 {
660         debugfs_remove_recursive(priv->dbgfs_dir);
661 }
662
663 void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name)
664 {
665         struct dentry *mvpp2_dir;
666         int ret, i;
667
668         if (!mvpp2_root)
669                 mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL);
670
671         mvpp2_dir = debugfs_create_dir(name, mvpp2_root);
672
673         priv->dbgfs_dir = mvpp2_dir;
674
675         ret = mvpp2_dbgfs_prs_init(mvpp2_dir, priv);
676         if (ret)
677                 goto err;
678
679         for (i = 0; i < priv->port_count; i++) {
680                 ret = mvpp2_dbgfs_port_init(mvpp2_dir, priv->port_list[i]);
681                 if (ret)
682                         goto err;
683         }
684
685         ret = mvpp2_dbgfs_flow_init(mvpp2_dir, priv);
686         if (ret)
687                 goto err;
688
689         return;
690 err:
691         mvpp2_dbgfs_cleanup(priv);
692 }