aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/files/drivers/net/phy/rtk/rtl8367s_dbg.c
blob: 039d73d876baabbef1f316f14ebc9430c8b1a970 (plain)
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
#include <linux/uaccess.h>
#include <linux/trace_seq.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <linux/u64_stats_sync.h>

#include  "./rtl8367c/include/rtk_switch.h"
#include  "./rtl8367c/include/port.h"
#include  "./rtl8367c/include/vlan.h"
#include  "./rtl8367c/include/rtl8367c_asicdrv_port.h"
#include  "./rtl8367c/include/stat.h"
#include  "./rtl8367c/include/l2.h"
#include  "./rtl8367c/include/smi.h"
#include  "./rtl8367c/include/mirror.h"
#include  "./rtl8367c/include/igmp.h"
#include  "./rtl8367c/include/leaky.h"

static struct proc_dir_entry *proc_reg_dir;
static struct proc_dir_entry *proc_esw_cnt;
static struct proc_dir_entry *proc_vlan_cnt;
static struct proc_dir_entry *proc_mac_tbl;
static struct proc_dir_entry *proc_reg;
static struct proc_dir_entry *proc_phyreg;
static struct proc_dir_entry *proc_mirror;
static struct proc_dir_entry *proc_igmp;

#define PROCREG_ESW_CNT         "esw_cnt"
#define PROCREG_VLAN            "vlan"
#define PROCREG_MAC_TBL            "mac_tbl"
#define PROCREG_REG            "reg"
#define PROCREG_PHYREG            "phyreg"
#define PROCREG_MIRROR            "mirror"
#define PROCREG_IGMP            "igmp"
#define PROCREG_DIR             "rtk_gsw"

#define RTK_SW_VID_RANGE        16

static void rtk_dump_mib_type(rtk_stat_port_type_t cntr_idx)
{
	rtk_port_t port;
	rtk_stat_counter_t Cntr;

	for (port = UTP_PORT0; port < (UTP_PORT0 + 5); port++) {
		rtk_stat_port_get(port, cntr_idx, &Cntr);
		printk("%8llu", Cntr);
	}

	for (port = EXT_PORT0; port < (EXT_PORT0 + 2); port++) {
		rtk_stat_port_get(port, cntr_idx, &Cntr);
		printk("%8llu", Cntr);
	}
	
	printk("\n");
}
static void rtk_hal_dump_mib(void)
{

	printk("==================%8s%8s%8s%8s%8s%8s%8s\n", "Port0", "Port1",
	       "Port2", "Port3", "Port4", "Port16", "Port17");
	/* Get TX Unicast Pkts */
	printk("TX Unicast Pkts  :");
	rtk_dump_mib_type(STAT_IfOutUcastPkts);
	/* Get TX Multicast Pkts */
	printk("TX Multicast Pkts:");
	rtk_dump_mib_type(STAT_IfOutMulticastPkts);
	/* Get TX BroadCast Pkts */
	printk("TX BroadCast Pkts:");
	rtk_dump_mib_type(STAT_IfOutBroadcastPkts);
	/* Get TX Collisions */
	/* Get TX Puase Frames */
	printk("TX Pause Frames  :");
	rtk_dump_mib_type(STAT_Dot3OutPauseFrames);
	/* Get TX Drop Events */
	/* Get RX Unicast Pkts */
	printk("RX Unicast Pkts  :");
	rtk_dump_mib_type(STAT_IfInUcastPkts);
	/* Get RX Multicast Pkts */
	printk("RX Multicast Pkts:");
	rtk_dump_mib_type(STAT_IfInMulticastPkts);
	/* Get RX Broadcast Pkts */
	printk("RX Broadcast Pkts:");
	rtk_dump_mib_type(STAT_IfInBroadcastPkts);
	/* Get RX FCS Erros */
	printk("RX FCS Errors    :");
	rtk_dump_mib_type(STAT_Dot3StatsFCSErrors);
	/* Get RX Undersize Pkts */
	printk("RX Undersize Pkts:");
	rtk_dump_mib_type(STAT_EtherStatsUnderSizePkts);
	/* Get RX Discard Pkts */
	printk("RX Discard Pkts  :");
	rtk_dump_mib_type(STAT_Dot1dTpPortInDiscards);
	/* Get RX Fragments */
	printk("RX Fragments     :");
	rtk_dump_mib_type(STAT_EtherStatsFragments);
	/* Get RX Oversize Pkts */
	printk("RX Oversize Pkts :");
	rtk_dump_mib_type(STAT_EtherOversizeStats);
	/* Get RX Jabbers */
	printk("RX Jabbers       :");
	rtk_dump_mib_type(STAT_EtherStatsJabbers);
	/* Get RX Pause Frames */
	printk("RX Pause Frames  :");
	rtk_dump_mib_type(STAT_Dot3InPauseFrames);
	/* clear MIB */
	rtk_stat_global_reset();
	
}

static int rtk_hal_dump_vlan(void)
{
	rtk_vlan_cfg_t vlan;
	int i;

	printk("vid    portmap\n");
	for (i = 0; i < RTK_SW_VID_RANGE; i++) {
		rtk_vlan_get(i, &vlan);
		printk("%3d    ", i);
		printk("%c",
		       RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                UTP_PORT0) ? '1' : '-');
		printk("%c",
	       	RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                UTP_PORT1) ? '1' : '-');
		printk("%c",
		       RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                UTP_PORT2) ? '1' : '-');
		printk("%c",
		       RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                UTP_PORT3) ? '1' : '-');
		printk("%c",
	       	RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                UTP_PORT4) ? '1' : '-');
		printk("%c",
		       RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                EXT_PORT0) ? '1' : '-');
		printk("%c",
		       RTK_PORTMASK_IS_PORT_SET(vlan.mbr,
	                                EXT_PORT1) ? '1' : '-');
		printk("\n");
	}
	
	return 0;
}

static void rtk_hal_dump_table(void)
{
	rtk_uint32 i;
	rtk_uint32 address = 0;
	rtk_l2_ucastAddr_t l2_data;
	rtk_l2_ipMcastAddr_t ipMcastAddr;
	rtk_l2_age_time_t age_timout;

	rtk_l2_aging_get(&age_timout);
	printk("Mac table age timeout =%d\n",(unsigned int)age_timout);

	printk("hash  port(0:17)   fid   vid  mac-address\n");
	while (1) {
		if (rtk_l2_addr_next_get(READMETHOD_NEXT_L2UC, UTP_PORT0, &address, &l2_data) != RT_ERR_OK) {
			break;
		} else {
			printk("%03x   ", l2_data.address);
			for (i = 0; i < 5; i++)
				if ( l2_data.port == i)
					printk("1");
				else
					printk("-");
			for (i = 16; i < 18; i++)
				if ( l2_data.port == i)
					printk("1");
				else
					printk("-");

			printk("      %2d", l2_data.fid);
			printk("  %4d", l2_data.cvid);
			printk("  %02x%02x%02x%02x%02x%02x\n", l2_data.mac.octet[0],
			l2_data.mac.octet[1], l2_data.mac.octet[2], l2_data.mac.octet[3],
			l2_data.mac.octet[4], l2_data.mac.octet[5]);
			address ++;
			}
	}

	address = 0;
	while (1) {
        if (rtk_l2_ipMcastAddr_next_get(&address, &ipMcastAddr) != RT_ERR_OK) {
            break;
        } else {
            printk("%03x   ", ipMcastAddr.address);
            for (i = 0; i < 5; i++)
                printk("%c", RTK_PORTMASK_IS_PORT_SET(ipMcastAddr.portmask, i) ? '1' : '-');
            for (i = 16; i < 18; i++)
                printk("%c", RTK_PORTMASK_IS_PORT_SET(ipMcastAddr.portmask, i) ? '1' : '-');
			printk("                ");
			printk("01005E%06x\n", (ipMcastAddr.dip & 0xefffff));
            address ++;
            }
    }
}

static void rtk_hal_clear_table(void)
{
        rtk_api_ret_t ret;

        ret = rtk_l2_table_clear();
        if (ret != RT_ERR_OK)
                printk("rtk_l2_table_clear failed\n");
}

static void rtk_hal_read_reg(unsigned int reg_addr)
{
        ret_t retVal;
	 unsigned int reg_val;

        retVal = smi_read(reg_addr, &reg_val);

        if(retVal != RT_ERR_OK)
                printk("switch reg read failed\n");
        else
                printk("reg0x%x = 0x%x\n", reg_addr, reg_val);
}

static void rtk_hal_write_reg(unsigned int reg_addr , unsigned int reg_val)
{
        ret_t retVal;

    retVal = smi_write(reg_addr, reg_val);

    if(retVal != RT_ERR_OK)
        printk("switch reg write failed\n");
    else
        printk("write switch reg0x%x 0x%x success\n", reg_addr, reg_val);
}

static void rtk_hal_get_phy_reg(unsigned int port ,unsigned int reg_addr )
{
        ret_t retVal;
        rtk_port_phy_data_t Data;

        retVal = rtk_port_phyReg_get(port, reg_addr, &Data);
        if (retVal == RT_ERR_OK)
                printk("Get: phy[%d].reg[%d] = 0x%04x\n", port, reg_addr, Data);
        else
                printk("read phy reg failed\n");
}

static void rtk_hal_set_phy_reg(unsigned int port ,unsigned int reg_addr,unsigned int reg_val)
{
        ret_t retVal;

        retVal = rtk_port_phyReg_set(port, reg_addr, reg_val);
        if (retVal == RT_ERR_OK)
                printk("Set: phy[%d].reg[%d] = 0x%04x\n", port, reg_addr, reg_val);
        else
                printk("write phy reg failed\n");
}

static void rtk_hal_set_port_mirror(unsigned int port ,unsigned int rx_port_map,unsigned int tx_port_map)
{
        rtk_portmask_t rx_portmask;
        rtk_portmask_t tx_portmask;
        rtk_api_ret_t ret;
        int i;

        rtk_mirror_portIso_set(ENABLED);
        RTK_PORTMASK_CLEAR(rx_portmask);
        RTK_PORTMASK_CLEAR(tx_portmask);

	for (i = 0; i < 5; i++)
                if (rx_port_map & (1 << i))
                        RTK_PORTMASK_PORT_SET(rx_portmask, i);

        for (i = 0; i < 2; i++)
                if (rx_port_map & (1 << (i + 5)))
                        RTK_PORTMASK_PORT_SET(rx_portmask, (i + EXT_PORT0));

        RTK_PORTMASK_CLEAR(tx_portmask);

	for (i = 0; i < 5; i++)
		if (tx_port_map & (1 << i))
		           RTK_PORTMASK_PORT_SET(tx_portmask, i);

	for (i = 0; i < 2; i++)
		if (tx_port_map & (1 << (i + 5)))
			RTK_PORTMASK_PORT_SET(tx_portmask, (i + EXT_PORT0));

	ret = rtk_mirror_portBased_set(port, &rx_portmask, &tx_portmask);

        if (!ret)
                printk("rtk_mirror_portBased_set success\n");

}

static void rtk_hal_enable_igmpsnoop(int hw_on)
{
        rtk_api_ret_t ret;
        rtk_portmask_t pmask;

        ret = rtk_igmp_init();
        if (hw_on == 1) {
                RTK_PORTMASK_CLEAR(pmask);
                RTK_PORTMASK_PORT_SET(pmask, EXT_PORT0);
                ret |= rtk_igmp_static_router_port_set(&pmask);
                ret |= rtk_igmp_protocol_set(UTP_PORT4, PROTOCOL_IGMPv1, IGMP_ACTION_FORWARD);
                ret |= rtk_igmp_protocol_set(UTP_PORT4, PROTOCOL_IGMPv2, IGMP_ACTION_FORWARD);
                ret |= rtk_igmp_protocol_set(UTP_PORT4, PROTOCOL_MLDv1, IGMP_ACTION_FORWARD);
                ret |= rtk_igmp_protocol_set(EXT_PORT1, PROTOCOL_IGMPv1, IGMP_ACTION_FORWARD);
                ret |= rtk_igmp_protocol_set(EXT_PORT1, PROTOCOL_IGMPv2, IGMP_ACTION_FORWARD);
                ret |= rtk_igmp_protocol_set(EXT_PORT1, PROTOCOL_MLDv1, IGMP_ACTION_FORWARD);
                ret |= rtk_igmp_protocol_set(UTP_PORT0, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(UTP_PORT1, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(UTP_PORT2, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(UTP_PORT3, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(EXT_PORT0, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);

                ret |= rtk_leaky_vlan_set(LEAKY_IPMULTICAST, ENABLED);
                ret |= rtk_l2_ipMcastForwardRouterPort_set(DISABLED);
                /* drop unknown multicast packets*/
                /* ret |= rtk_trap_unknownMcastPktAction_set(UTP_PORT4, MCAST_IPV4, MCAST_ACTION_DROP);*/
        } else {
		RTK_PORTMASK_CLEAR(pmask);
		RTK_PORTMASK_PORT_SET(pmask, EXT_PORT0);
		RTK_PORTMASK_PORT_SET(pmask, EXT_PORT1);
                ret |= rtk_igmp_protocol_set(UTP_PORT0, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(UTP_PORT1, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(UTP_PORT2, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(UTP_PORT3, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);
                ret |= rtk_igmp_protocol_set(EXT_PORT0, PROTOCOL_IGMPv3, IGMP_ACTION_ASIC);

                ret |= rtk_igmp_static_router_port_set(&pmask);
        }

        if(ret != RT_ERR_OK)
                printk("enable switch igmpsnoop failed\n");

}

static void rtk_hal_disable_igmpsnoop(void)
{
        if (rtk_igmp_state_set(DISABLED) != RT_ERR_OK)
                printk("Disable IGMP SNOOPING failed\n");
}

static ssize_t mac_tbl_write(struct file *file,
                            const char __user *buffer, size_t count,
                            loff_t *data)
{
	rtk_hal_clear_table();

        return count;
}


static ssize_t phyreg_ops(struct file *file,
                            const char __user *buffer, size_t count,
                            loff_t *data)
{
        char buf[64];
	 unsigned int port;
        unsigned int offset;
        unsigned int val;

        memset(buf, 0, 64);

        if (copy_from_user(buf, buffer, count))
                return -EFAULT;


        if(buf[0] == 'w') {

                if(sscanf(buf, "w %d %x %x", &port,&offset,&val) == -1)
                        return -EFAULT;
                else
                        rtk_hal_set_phy_reg(port,offset,val);

        } else {

		if(sscanf(buf, "r %d %x",&port, &offset) == -1)
                        return -EFAULT;
                else
                        rtk_hal_get_phy_reg(port,offset);
        }

        return count;
}

static ssize_t reg_ops(struct file *file,
                            const char __user *buffer, size_t count,
                            loff_t *data)
{
        char buf[64];
        unsigned int offset;
        unsigned int val;

        memset(buf, 0, 64);

        if (copy_from_user(buf, buffer, count))
                return -EFAULT;


        if(buf[0] == 'w') {

                if(sscanf(buf, "w %x %x", &offset,&val) == -1)
                        return -EFAULT;
                else
                        rtk_hal_write_reg(offset,val);

        } else {

                if(sscanf(buf, "r %x", &offset) == -1)
                        return -EFAULT;
                else
                        rtk_hal_read_reg(offset);
        }

        return count;
}

static ssize_t mirror_ops(struct file *file,
                            const char __user *buffer, size_t count,
                            loff_t *data)
{
        char buf[64];
	 unsigned int port;
        unsigned int tx_map,rx_map;

        memset(buf, 0, 64);

        if (copy_from_user(buf, buffer, count))
                return -EFAULT;

	if(sscanf(buf, "%d %x %x", &port,&rx_map,&tx_map) == -1)
		return -EFAULT;
	else
		rtk_hal_set_port_mirror(port,rx_map,tx_map);

        return count;
}


static ssize_t igmp_ops(struct file *file,
                            const char __user *buffer, size_t count,
                            loff_t *data)
{
        char buf[8];
        unsigned int ops;

        if (copy_from_user(buf, buffer, count))
                return -EFAULT;

	if(sscanf(buf, "%d", &ops) == -1)
		return -EFAULT;

        if(ops == 0)
                rtk_hal_disable_igmpsnoop();
	else if (ops == 1)
		rtk_hal_enable_igmpsnoop(0);
	else //hw igmp
		rtk_hal_enable_igmpsnoop(1);

        return count;
}


static int esw_cnt_read(struct seq_file *seq, void *v)
{
	rtk_hal_dump_mib();
	return 0;
}

static int vlan_read(struct seq_file *seq, void *v)
{
	rtk_hal_dump_vlan();
	return 0;
}

static int mac_tbl_read(struct seq_file *seq, void *v)
{
	rtk_hal_dump_table();
	return 0;
}

static int reg_show(struct seq_file *seq, void *v)
{
	return 0;
}

static int phyreg_show(struct seq_file *seq, void *v)
{
	return 0;
}

static int mirror_show(struct seq_file *seq, void *v)
{
	return 0;
}

static int igmp_show(struct seq_file *seq, void *v)
{
	return 0;
}

static int switch_count_open(struct inode *inode, struct file *file)
{
	return single_open(file, esw_cnt_read, 0);
}

static int switch_vlan_open(struct inode *inode, struct file *file)
{
	return single_open(file, vlan_read, 0);
}

static int mac_tbl_open(struct inode *inode, struct file *file)
{
	return single_open(file, mac_tbl_read, 0);
}

static int reg_open(struct inode *inode, struct file *file)
{
	return single_open(file, reg_show, 0);
}

static int phyreg_open(struct inode *inode, struct file *file)
{
	return single_open(file, phyreg_show, 0);
}

static int mirror_open(struct inode *inode, struct file *file)
{
	return single_open(file, mirror_show, 0);
}

static int igmp_open(struct inode *inode, struct file *file)
{
	return single_open(file, igmp_show, 0);
}


static const struct proc_ops switch_count_fops = {
	.proc_open = switch_count_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_release = single_release
};

static const struct proc_ops switch_vlan_fops = {
	.proc_open = switch_vlan_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_release = single_release
};

static const struct proc_ops mac_tbl_fops = {
	.proc_open = mac_tbl_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_write = mac_tbl_write,
	.proc_release = single_release
};

static const struct proc_ops reg_fops = {
	.proc_open = reg_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_write = reg_ops,
	.proc_release = single_release
};

static const struct proc_ops phyreg_fops = {
	.proc_open = phyreg_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_write = phyreg_ops,
	.proc_release = single_release
};

static const struct proc_ops mirror_fops = {
	.proc_open = mirror_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_write = mirror_ops,
	.proc_release = single_release
};

static const struct proc_ops igmp_fops = {
	.proc_open = igmp_open,
	.proc_read = seq_read,
	.proc_lseek = seq_lseek,
	.proc_write = igmp_ops,
	.proc_release = single_release
};

int gsw_debug_proc_init(void)
{

	if (!proc_reg_dir)
		proc_reg_dir = proc_mkdir(PROCREG_DIR, NULL);

	proc_esw_cnt =
	proc_create(PROCREG_ESW_CNT, 0, proc_reg_dir, &switch_count_fops);

	if (!proc_esw_cnt)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_ESW_CNT);

	proc_vlan_cnt =
	proc_create(PROCREG_VLAN, 0, proc_reg_dir, &switch_vlan_fops);

	if (!proc_vlan_cnt)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_VLAN);

	proc_mac_tbl =
	proc_create(PROCREG_MAC_TBL, 0, proc_reg_dir, &mac_tbl_fops);

	if (!proc_mac_tbl)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_MAC_TBL);

	proc_reg =
	proc_create(PROCREG_REG, 0, proc_reg_dir, &reg_fops);

	if (!proc_reg)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_REG);

	proc_phyreg =
	proc_create(PROCREG_PHYREG, 0, proc_reg_dir, &phyreg_fops);

	if (!proc_phyreg)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_PHYREG);

	proc_mirror =
	proc_create(PROCREG_MIRROR, 0, proc_reg_dir, &mirror_fops);

	if (!proc_mirror)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_MIRROR);

	proc_igmp =
	proc_create(PROCREG_IGMP, 0, proc_reg_dir, &igmp_fops);

	if (!proc_igmp)
		pr_err("!! FAIL to create %s PROC !!\n", PROCREG_IGMP);

	return 0;
}

void gsw_debug_proc_exit(void)
{
	if (proc_esw_cnt)
		remove_proc_entry(PROCREG_ESW_CNT, proc_reg_dir);
}