40
40
#include <linux/export.h>
41
41
#include <linux/err.h>
42
42
#include <linux/if_link.h>
43
- #include <linux/debugfs.h>
44
- #include <linux/seq_file.h>
45
- #include <linux/u64_stats_sync.h>
46
43
#include <linux/netdevice.h>
47
44
#include <linux/completion.h>
48
45
#include <linux/skbuff.h>
@@ -74,23 +71,9 @@ static DEFINE_SPINLOCK(mlxsw_core_driver_list_lock);
74
71
75
72
static const char mlxsw_core_driver_name [] = "mlxsw_core" ;
76
73
77
- static struct dentry * mlxsw_core_dbg_root ;
78
-
79
74
static struct workqueue_struct * mlxsw_wq ;
80
75
static struct workqueue_struct * mlxsw_owq ;
81
76
82
- struct mlxsw_core_pcpu_stats {
83
- u64 trap_rx_packets [MLXSW_TRAP_ID_MAX ];
84
- u64 trap_rx_bytes [MLXSW_TRAP_ID_MAX ];
85
- u64 port_rx_packets [MLXSW_PORT_MAX_PORTS ];
86
- u64 port_rx_bytes [MLXSW_PORT_MAX_PORTS ];
87
- struct u64_stats_sync syncp ;
88
- u32 trap_rx_dropped [MLXSW_TRAP_ID_MAX ];
89
- u32 port_rx_dropped [MLXSW_PORT_MAX_PORTS ];
90
- u32 trap_rx_invalid ;
91
- u32 port_rx_invalid ;
92
- };
93
-
94
77
struct mlxsw_core_port {
95
78
struct devlink_port devlink_port ;
96
79
void * port_driver_priv ;
@@ -121,12 +104,6 @@ struct mlxsw_core {
121
104
spinlock_t trans_list_lock ; /* protects trans_list writes */
122
105
bool use_emad ;
123
106
} emad ;
124
- struct mlxsw_core_pcpu_stats __percpu * pcpu_stats ;
125
- struct dentry * dbg_dir ;
126
- struct {
127
- struct debugfs_blob_wrapper vsd_blob ;
128
- struct debugfs_blob_wrapper psid_blob ;
129
- } dbg ;
130
107
struct {
131
108
u8 * mapping ; /* lag_id+port_index to local_port mapping */
132
109
} lag ;
@@ -703,91 +680,6 @@ static int mlxsw_emad_reg_access(struct mlxsw_core *mlxsw_core,
703
680
* Core functions
704
681
*****************/
705
682
706
- static int mlxsw_core_rx_stats_dbg_read (struct seq_file * file , void * data )
707
- {
708
- struct mlxsw_core * mlxsw_core = file -> private ;
709
- struct mlxsw_core_pcpu_stats * p ;
710
- u64 rx_packets , rx_bytes ;
711
- u64 tmp_rx_packets , tmp_rx_bytes ;
712
- u32 rx_dropped , rx_invalid ;
713
- unsigned int start ;
714
- int i ;
715
- int j ;
716
- static const char hdr [] =
717
- " NUM RX_PACKETS RX_BYTES RX_DROPPED\n" ;
718
-
719
- seq_printf (file , hdr );
720
- for (i = 0 ; i < MLXSW_TRAP_ID_MAX ; i ++ ) {
721
- rx_packets = 0 ;
722
- rx_bytes = 0 ;
723
- rx_dropped = 0 ;
724
- for_each_possible_cpu (j ) {
725
- p = per_cpu_ptr (mlxsw_core -> pcpu_stats , j );
726
- do {
727
- start = u64_stats_fetch_begin (& p -> syncp );
728
- tmp_rx_packets = p -> trap_rx_packets [i ];
729
- tmp_rx_bytes = p -> trap_rx_bytes [i ];
730
- } while (u64_stats_fetch_retry (& p -> syncp , start ));
731
-
732
- rx_packets += tmp_rx_packets ;
733
- rx_bytes += tmp_rx_bytes ;
734
- rx_dropped += p -> trap_rx_dropped [i ];
735
- }
736
- seq_printf (file , "trap %3d %12llu %12llu %10u\n" ,
737
- i , rx_packets , rx_bytes , rx_dropped );
738
- }
739
- rx_invalid = 0 ;
740
- for_each_possible_cpu (j ) {
741
- p = per_cpu_ptr (mlxsw_core -> pcpu_stats , j );
742
- rx_invalid += p -> trap_rx_invalid ;
743
- }
744
- seq_printf (file , "trap INV %10u\n" ,
745
- rx_invalid );
746
-
747
- for (i = 0 ; i < MLXSW_PORT_MAX_PORTS ; i ++ ) {
748
- rx_packets = 0 ;
749
- rx_bytes = 0 ;
750
- rx_dropped = 0 ;
751
- for_each_possible_cpu (j ) {
752
- p = per_cpu_ptr (mlxsw_core -> pcpu_stats , j );
753
- do {
754
- start = u64_stats_fetch_begin (& p -> syncp );
755
- tmp_rx_packets = p -> port_rx_packets [i ];
756
- tmp_rx_bytes = p -> port_rx_bytes [i ];
757
- } while (u64_stats_fetch_retry (& p -> syncp , start ));
758
-
759
- rx_packets += tmp_rx_packets ;
760
- rx_bytes += tmp_rx_bytes ;
761
- rx_dropped += p -> port_rx_dropped [i ];
762
- }
763
- seq_printf (file , "port %3d %12llu %12llu %10u\n" ,
764
- i , rx_packets , rx_bytes , rx_dropped );
765
- }
766
- rx_invalid = 0 ;
767
- for_each_possible_cpu (j ) {
768
- p = per_cpu_ptr (mlxsw_core -> pcpu_stats , j );
769
- rx_invalid += p -> port_rx_invalid ;
770
- }
771
- seq_printf (file , "port INV %10u\n" ,
772
- rx_invalid );
773
- return 0 ;
774
- }
775
-
776
- static int mlxsw_core_rx_stats_dbg_open (struct inode * inode , struct file * f )
777
- {
778
- struct mlxsw_core * mlxsw_core = inode -> i_private ;
779
-
780
- return single_open (f , mlxsw_core_rx_stats_dbg_read , mlxsw_core );
781
- }
782
-
783
- static const struct file_operations mlxsw_core_rx_stats_dbg_ops = {
784
- .owner = THIS_MODULE ,
785
- .open = mlxsw_core_rx_stats_dbg_open ,
786
- .release = single_release ,
787
- .read = seq_read ,
788
- .llseek = seq_lseek
789
- };
790
-
791
683
int mlxsw_core_driver_register (struct mlxsw_driver * mlxsw_driver )
792
684
{
793
685
spin_lock (& mlxsw_core_driver_list_lock );
@@ -835,32 +727,6 @@ static void mlxsw_core_driver_put(const char *kind)
835
727
spin_unlock (& mlxsw_core_driver_list_lock );
836
728
}
837
729
838
- static int mlxsw_core_debugfs_init (struct mlxsw_core * mlxsw_core )
839
- {
840
- const struct mlxsw_bus_info * bus_info = mlxsw_core -> bus_info ;
841
-
842
- mlxsw_core -> dbg_dir = debugfs_create_dir (bus_info -> device_name ,
843
- mlxsw_core_dbg_root );
844
- if (!mlxsw_core -> dbg_dir )
845
- return - ENOMEM ;
846
- debugfs_create_file ("rx_stats" , S_IRUGO , mlxsw_core -> dbg_dir ,
847
- mlxsw_core , & mlxsw_core_rx_stats_dbg_ops );
848
- mlxsw_core -> dbg .vsd_blob .data = (void * ) & bus_info -> vsd ;
849
- mlxsw_core -> dbg .vsd_blob .size = sizeof (bus_info -> vsd );
850
- debugfs_create_blob ("vsd" , S_IRUGO , mlxsw_core -> dbg_dir ,
851
- & mlxsw_core -> dbg .vsd_blob );
852
- mlxsw_core -> dbg .psid_blob .data = (void * ) & bus_info -> psid ;
853
- mlxsw_core -> dbg .psid_blob .size = sizeof (bus_info -> psid );
854
- debugfs_create_blob ("psid" , S_IRUGO , mlxsw_core -> dbg_dir ,
855
- & mlxsw_core -> dbg .psid_blob );
856
- return 0 ;
857
- }
858
-
859
- static void mlxsw_core_debugfs_fini (struct mlxsw_core * mlxsw_core )
860
- {
861
- debugfs_remove_recursive (mlxsw_core -> dbg_dir );
862
- }
863
-
864
730
static int mlxsw_devlink_port_split (struct devlink * devlink ,
865
731
unsigned int port_index ,
866
732
unsigned int count )
@@ -1101,13 +967,6 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
1101
967
mlxsw_core -> bus_priv = bus_priv ;
1102
968
mlxsw_core -> bus_info = mlxsw_bus_info ;
1103
969
1104
- mlxsw_core -> pcpu_stats =
1105
- netdev_alloc_pcpu_stats (struct mlxsw_core_pcpu_stats );
1106
- if (!mlxsw_core -> pcpu_stats ) {
1107
- err = - ENOMEM ;
1108
- goto err_alloc_stats ;
1109
- }
1110
-
1111
970
err = mlxsw_bus -> init (bus_priv , mlxsw_core , mlxsw_driver -> profile ,
1112
971
& mlxsw_core -> res );
1113
972
if (err )
@@ -1148,15 +1007,8 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
1148
1007
goto err_driver_init ;
1149
1008
}
1150
1009
1151
- err = mlxsw_core_debugfs_init (mlxsw_core );
1152
- if (err )
1153
- goto err_debugfs_init ;
1154
-
1155
1010
return 0 ;
1156
1011
1157
- err_debugfs_init :
1158
- if (mlxsw_core -> driver -> fini )
1159
- mlxsw_core -> driver -> fini (mlxsw_core );
1160
1012
err_driver_init :
1161
1013
mlxsw_thermal_fini (mlxsw_core -> thermal );
1162
1014
err_thermal_init :
@@ -1169,8 +1021,6 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
1169
1021
err_alloc_lag_mapping :
1170
1022
mlxsw_bus -> fini (bus_priv );
1171
1023
err_bus_init :
1172
- free_percpu (mlxsw_core -> pcpu_stats );
1173
- err_alloc_stats :
1174
1024
devlink_free (devlink );
1175
1025
err_devlink_alloc :
1176
1026
mlxsw_core_driver_put (device_kind );
@@ -1183,15 +1033,13 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core)
1183
1033
const char * device_kind = mlxsw_core -> bus_info -> device_kind ;
1184
1034
struct devlink * devlink = priv_to_devlink (mlxsw_core );
1185
1035
1186
- mlxsw_core_debugfs_fini (mlxsw_core );
1187
1036
if (mlxsw_core -> driver -> fini )
1188
1037
mlxsw_core -> driver -> fini (mlxsw_core );
1189
1038
mlxsw_thermal_fini (mlxsw_core -> thermal );
1190
1039
devlink_unregister (devlink );
1191
1040
mlxsw_emad_fini (mlxsw_core );
1192
1041
kfree (mlxsw_core -> lag .mapping );
1193
1042
mlxsw_core -> bus -> fini (mlxsw_core -> bus_priv );
1194
- free_percpu (mlxsw_core -> pcpu_stats );
1195
1043
devlink_free (devlink );
1196
1044
mlxsw_core_driver_put (device_kind );
1197
1045
}
@@ -1639,7 +1487,6 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
1639
1487
{
1640
1488
struct mlxsw_rx_listener_item * rxl_item ;
1641
1489
const struct mlxsw_rx_listener * rxl ;
1642
- struct mlxsw_core_pcpu_stats * pcpu_stats ;
1643
1490
u8 local_port ;
1644
1491
bool found = false;
1645
1492
@@ -1678,26 +1525,10 @@ void mlxsw_core_skb_receive(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
1678
1525
if (!found )
1679
1526
goto drop ;
1680
1527
1681
- pcpu_stats = this_cpu_ptr (mlxsw_core -> pcpu_stats );
1682
- u64_stats_update_begin (& pcpu_stats -> syncp );
1683
- pcpu_stats -> port_rx_packets [local_port ]++ ;
1684
- pcpu_stats -> port_rx_bytes [local_port ] += skb -> len ;
1685
- pcpu_stats -> trap_rx_packets [rx_info -> trap_id ]++ ;
1686
- pcpu_stats -> trap_rx_bytes [rx_info -> trap_id ] += skb -> len ;
1687
- u64_stats_update_end (& pcpu_stats -> syncp );
1688
-
1689
1528
rxl -> func (skb , local_port , rxl_item -> priv );
1690
1529
return ;
1691
1530
1692
1531
drop :
1693
- if (rx_info -> trap_id >= MLXSW_TRAP_ID_MAX )
1694
- this_cpu_inc (mlxsw_core -> pcpu_stats -> trap_rx_invalid );
1695
- else
1696
- this_cpu_inc (mlxsw_core -> pcpu_stats -> trap_rx_dropped [rx_info -> trap_id ]);
1697
- if (local_port >= MLXSW_PORT_MAX_PORTS )
1698
- this_cpu_inc (mlxsw_core -> pcpu_stats -> port_rx_invalid );
1699
- else
1700
- this_cpu_inc (mlxsw_core -> pcpu_stats -> port_rx_dropped [local_port ]);
1701
1532
dev_kfree_skb (skb );
1702
1533
}
1703
1534
EXPORT_SYMBOL (mlxsw_core_skb_receive );
@@ -1926,23 +1757,15 @@ static int __init mlxsw_core_module_init(void)
1926
1757
err = - ENOMEM ;
1927
1758
goto err_alloc_ordered_workqueue ;
1928
1759
}
1929
- mlxsw_core_dbg_root = debugfs_create_dir (mlxsw_core_driver_name , NULL );
1930
- if (!mlxsw_core_dbg_root ) {
1931
- err = - ENOMEM ;
1932
- goto err_debugfs_create_dir ;
1933
- }
1934
1760
return 0 ;
1935
1761
1936
- err_debugfs_create_dir :
1937
- destroy_workqueue (mlxsw_owq );
1938
1762
err_alloc_ordered_workqueue :
1939
1763
destroy_workqueue (mlxsw_wq );
1940
1764
return err ;
1941
1765
}
1942
1766
1943
1767
static void __exit mlxsw_core_module_exit (void )
1944
1768
{
1945
- debugfs_remove_recursive (mlxsw_core_dbg_root );
1946
1769
destroy_workqueue (mlxsw_owq );
1947
1770
destroy_workqueue (mlxsw_wq );
1948
1771
}
0 commit comments