@@ -360,6 +360,229 @@ static const struct file_operations l2_table_fops = {
360360 .release = single_release ,
361361};
362362
363+ static int rtldsa_pmsks_table_raw_show (struct seq_file * m , void * v )
364+ {
365+ struct rtl838x_switch_priv * priv = m -> private ;
366+ u64 all_ports ;
367+
368+ mutex_lock (& priv -> reg_mutex );
369+
370+ for (int i = 0 ; i < MAX_MC_PMASKS ; i += 4 ) {
371+ seq_printf (m , "%04i: " , i );
372+ for (int j = 0 ; j < 4 ; j ++ ) {
373+ bool is_set = test_bit (i + j , priv -> mc_group_bm );
374+ seq_printf (m , " %c0x%016llx%c" , is_set ? ' ' : '(' ,
375+ priv -> r -> read_mcast_pmask (i + j ),
376+ is_set ? ' ' : ')' );
377+ }
378+ seq_printf (m , "\n" );
379+ }
380+
381+ all_ports = priv -> r -> read_mcast_pmask (MC_PMASK_ALL_PORTS_IDX );
382+ seq_printf (m , "MC_PMASK_ALL_PORTS (%i): 0x%016llx\n" ,
383+ MC_PMASK_ALL_PORTS_IDX , all_ports );
384+
385+ mutex_unlock (& priv -> reg_mutex );
386+
387+ return 0 ;
388+ }
389+
390+ static int rtldsa_pmsks_table_raw_open (struct inode * inode , struct file * filp )
391+ {
392+ return single_open (filp , rtldsa_pmsks_table_raw_show , inode -> i_private );
393+ }
394+
395+ static const struct file_operations rtldsa_pmsks_table_raw_fops = {
396+ .owner = THIS_MODULE ,
397+ .open = rtldsa_pmsks_table_raw_open ,
398+ .read = seq_read ,
399+ .llseek = seq_lseek ,
400+ .release = single_release ,
401+ };
402+
403+ static int rtldsa_pmsks_table_show (struct seq_file * m , void * v )
404+ {
405+ struct rtl838x_switch_priv * priv = m -> private ;
406+ u64 ports ;
407+
408+ mutex_lock (& priv -> reg_mutex );
409+
410+ for (int i = 0 ; i < MC_PMASK_ALL_PORTS_IDX ; i ++ ) {
411+ if (!test_bit (i , priv -> mc_group_bm ))
412+ continue ;
413+
414+ ports = priv -> r -> read_mcast_pmask (i );
415+ seq_printf (m , "%04i:" , i );
416+ for (int j = 0 ; j < sizeof (ports )* 8 ; j ++ )
417+ if (ports & BIT_ULL (j ))
418+ seq_printf (m , " %i" , j );
419+ seq_printf (m , "\n" );
420+ }
421+
422+ ports = priv -> r -> read_mcast_pmask (MC_PMASK_ALL_PORTS_IDX );
423+ seq_printf (m , "MC_PMASK_ALL_PORTS (%i):" , MC_PMASK_ALL_PORTS_IDX );
424+ for (int i = 0 ; i < sizeof (ports )* 8 ; i ++ )
425+ if (ports & BIT_ULL (i ))
426+ seq_printf (m , " %i" , i );
427+ seq_printf (m , "\n" );
428+
429+ mutex_unlock (& priv -> reg_mutex );
430+
431+ return 0 ;
432+ }
433+
434+ static int rtldsa_pmsks_table_open (struct inode * inode , struct file * filp )
435+ {
436+ return single_open (filp , rtldsa_pmsks_table_show , inode -> i_private );
437+ }
438+
439+ static const struct file_operations rtldsa_pmsks_table_fops = {
440+ .owner = THIS_MODULE ,
441+ .open = rtldsa_pmsks_table_open ,
442+ .read = seq_read ,
443+ .llseek = seq_lseek ,
444+ .release = single_release ,
445+ };
446+
447+ static int rtldsa_vlan_profiles_show (struct seq_file * m , void * v )
448+ {
449+ struct rtl838x_switch_priv * priv = m -> private ;
450+ struct rtldsa_vlan_profile profile ;
451+ int ret , profiles_max ;
452+
453+ if (!priv -> r -> vlan_profile_get )
454+ return - ENOTSUPP ;
455+
456+ profiles_max = max (RTL838X_VLAN_PROFILE_MAX , RTL839X_VLAN_PROFILE_MAX );
457+ profiles_max = max (profiles_max , RTL930X_VLAN_PROFILE_MAX );
458+ profiles_max = max (profiles_max , RTL931X_VLAN_PROFILE_MAX );
459+
460+ mutex_lock (& priv -> reg_mutex );
461+
462+ seq_printf (m ,
463+ "prof-idx: L2 learn | UNKN L2MC FLD PMSK (IDX) | UNKN IPMC FLD PMSK (IDX) | UNKN IPv6MC FLD PMSK (IDX)\n" );
464+ for (int i = 0 ; i <= profiles_max ; i ++ ) {
465+ ret = priv -> r -> vlan_profile_get (i , & profile );
466+ if (ret < 0 )
467+ break ;
468+
469+ if (profile .pmsk_is_idx )
470+ seq_printf (m , "%i: %i %03i %03i %03i\n" , i ,
471+ profile .l2_learn ,
472+ profile .unkn_mc_fld .pmsks_idx .l2 ,
473+ profile .unkn_mc_fld .pmsks_idx .ip ,
474+ profile .unkn_mc_fld .pmsks_idx .ip6 );
475+ else
476+ seq_printf (m , "%i: %i 0x%016llx 0x%016llx 0x%016llx\n" , i ,
477+ profile .l2_learn ,
478+ profile .unkn_mc_fld .pmsks .l2 ,
479+ profile .unkn_mc_fld .pmsks .ip ,
480+ profile .unkn_mc_fld .pmsks .ip6 );
481+ }
482+
483+ mutex_unlock (& priv -> reg_mutex );
484+
485+ return 0 ;
486+ }
487+
488+ static int rtldsa_vlan_profiles_open (struct inode * inode , struct file * filp )
489+ {
490+ return single_open (filp , rtldsa_vlan_profiles_show , inode -> i_private );
491+ }
492+
493+ static const struct file_operations rtldsa_vlan_profiles_fops = {
494+ .owner = THIS_MODULE ,
495+ .open = rtldsa_vlan_profiles_open ,
496+ .read = seq_read ,
497+ .llseek = seq_lseek ,
498+ .release = single_release ,
499+ };
500+
501+ static int rtldsa_vlan_table_raw_show (struct seq_file * m , void * v )
502+ {
503+ struct rtl838x_switch_priv * priv = m -> private ;
504+ struct rtl838x_vlan_info info ;
505+
506+ if (!priv -> r -> vlan_tables_read )
507+ return - ENOTSUPP ;
508+
509+ mutex_lock (& priv -> reg_mutex );
510+
511+ seq_printf (m , "VID: profile-index untagged-ports member-ports\n" );
512+
513+ for (int i = 0 ; i < MAX_VLANS ; i ++ ) {
514+ priv -> r -> vlan_tables_read (i , & info );
515+
516+ if (!info .member_ports )
517+ continue ;
518+
519+ seq_printf (m , "%i: %2i 0x%016llx 0x%016llx\n" , i ,
520+ info .profile_id ,
521+ info .untagged_ports ,
522+ info .member_ports );
523+ }
524+
525+ mutex_unlock (& priv -> reg_mutex );
526+
527+ return 0 ;
528+ }
529+
530+ static int rtldsa_vlan_table_raw_open (struct inode * inode , struct file * filp )
531+ {
532+ return single_open (filp , rtldsa_vlan_table_raw_show , inode -> i_private );
533+ }
534+
535+ static const struct file_operations rtldsa_vlan_table_raw_fops = {
536+ .owner = THIS_MODULE ,
537+ .open = rtldsa_vlan_table_raw_open ,
538+ .read = seq_read ,
539+ .llseek = seq_lseek ,
540+ .release = single_release ,
541+ };
542+
543+
544+ static int rtldsa_vlan_table_show (struct seq_file * m , void * v )
545+ {
546+ struct rtl838x_switch_priv * priv = m -> private ;
547+ struct rtl838x_vlan_info info ;
548+
549+ if (!priv -> r -> vlan_tables_read )
550+ return - ENOTSUPP ;
551+
552+ mutex_lock (& priv -> reg_mutex );
553+
554+ for (int i = 0 ; i < MAX_VLANS ; i ++ ) {
555+ priv -> r -> vlan_tables_read (i , & info );
556+
557+ if (!info .member_ports )
558+ continue ;
559+
560+ seq_printf (m , "%i: %i |" , i , info .profile_id );
561+ for (int j = 0 ; j < sizeof (info .member_ports )* 8 ; j ++ )
562+ if (info .member_ports & BIT_ULL (j ))
563+ seq_printf (m , " %i%s" , j ,
564+ (info .untagged_ports & BIT_ULL (j )) ? "" : "t" );
565+ seq_printf (m , "\n" );
566+ }
567+
568+ mutex_unlock (& priv -> reg_mutex );
569+
570+ return 0 ;
571+ }
572+
573+ static int rtldsa_vlan_table_open (struct inode * inode , struct file * filp )
574+ {
575+ return single_open (filp , rtldsa_vlan_table_show , inode -> i_private );
576+ }
577+
578+ static const struct file_operations rtldsa_vlan_table_fops = {
579+ .owner = THIS_MODULE ,
580+ .open = rtldsa_vlan_table_open ,
581+ .read = seq_read ,
582+ .llseek = seq_lseek ,
583+ .release = single_release ,
584+ };
585+
363586static ssize_t age_out_read (struct file * filp , char __user * buffer , size_t count ,
364587 loff_t * ppos )
365588{
@@ -695,6 +918,21 @@ void rtl838x_dbgfs_init(struct rtl838x_switch_priv *priv)
695918
696919 debugfs_create_file ("l2_table" , 0400 , rtl838x_dir , priv , & l2_table_fops );
697920
921+ debugfs_create_file ("port_masks_table_raw" , 0400 , rtl838x_dir , priv ,
922+ & rtldsa_pmsks_table_raw_fops );
923+
924+ debugfs_create_file ("port_masks_table" , 0400 , rtl838x_dir , priv ,
925+ & rtldsa_pmsks_table_fops );
926+
927+ debugfs_create_file ("vlan_profiles" , 0400 , rtl838x_dir , priv ,
928+ & rtldsa_vlan_profiles_fops );
929+
930+ debugfs_create_file ("vlan_table_raw" , 0400 , rtl838x_dir , priv ,
931+ & rtldsa_vlan_table_raw_fops );
932+
933+ debugfs_create_file ("vlan_table" , 0400 , rtl838x_dir , priv ,
934+ & rtldsa_vlan_table_fops );
935+
698936 return ;
699937err :
700938 rtl838x_dbgfs_cleanup (priv );
@@ -714,4 +952,19 @@ void rtl930x_dbgfs_init(struct rtl838x_switch_priv *priv)
714952 debugfs_create_file ("drop_counters" , 0400 , dbg_dir , priv , & drop_counter_fops );
715953
716954 debugfs_create_file ("l2_table" , 0400 , dbg_dir , priv , & l2_table_fops );
955+
956+ debugfs_create_file ("port_masks_table_raw" , 0400 , dbg_dir , priv ,
957+ & rtldsa_pmsks_table_raw_fops );
958+
959+ debugfs_create_file ("port_masks_table" , 0400 , dbg_dir , priv ,
960+ & rtldsa_pmsks_table_fops );
961+
962+ debugfs_create_file ("vlan_profiles" , 0400 , dbg_dir , priv ,
963+ & rtldsa_vlan_profiles_fops );
964+
965+ debugfs_create_file ("vlan_table_raw" , 0400 , dbg_dir , priv ,
966+ & rtldsa_vlan_table_raw_fops );
967+
968+ debugfs_create_file ("vlan_table" , 0400 , dbg_dir , priv ,
969+ & rtldsa_vlan_table_fops );
717970}
0 commit comments