@@ -117,24 +117,71 @@ static const struct counter_desc vport_rep_stats_desc[] = {
117
117
#define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
118
118
#define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
119
119
120
- static void mlx5e_rep_get_strings (struct net_device * dev ,
121
- u32 stringset , uint8_t * data )
120
+ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS (sw_rep )
122
121
{
123
- int i , j ;
122
+ return NUM_VPORT_REP_SW_COUNTERS ;
123
+ }
124
124
125
- switch (stringset ) {
126
- case ETH_SS_STATS :
127
- for (i = 0 ; i < NUM_VPORT_REP_SW_COUNTERS ; i ++ )
128
- strcpy (data + (i * ETH_GSTRING_LEN ),
129
- sw_rep_stats_desc [i ].format );
130
- for (j = 0 ; j < NUM_VPORT_REP_HW_COUNTERS ; j ++ , i ++ )
131
- strcpy (data + (i * ETH_GSTRING_LEN ),
132
- vport_rep_stats_desc [j ].format );
133
- break ;
134
- }
125
+ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS (sw_rep )
126
+ {
127
+ int i ;
128
+
129
+ for (i = 0 ; i < NUM_VPORT_REP_SW_COUNTERS ; i ++ )
130
+ strcpy (data + (idx ++ ) * ETH_GSTRING_LEN ,
131
+ sw_rep_stats_desc [i ].format );
132
+ return idx ;
133
+ }
134
+
135
+ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS (sw_rep )
136
+ {
137
+ int i ;
138
+
139
+ for (i = 0 ; i < NUM_VPORT_REP_SW_COUNTERS ; i ++ )
140
+ data [idx ++ ] = MLX5E_READ_CTR64_CPU (& priv -> stats .sw ,
141
+ sw_rep_stats_desc , i );
142
+ return idx ;
143
+ }
144
+
145
+ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS (sw_rep )
146
+ {
147
+ struct mlx5e_sw_stats * s = & priv -> stats .sw ;
148
+ struct rtnl_link_stats64 stats64 = {};
149
+
150
+ memset (s , 0 , sizeof (* s ));
151
+ mlx5e_fold_sw_stats64 (priv , & stats64 );
152
+
153
+ s -> rx_packets = stats64 .rx_packets ;
154
+ s -> rx_bytes = stats64 .rx_bytes ;
155
+ s -> tx_packets = stats64 .tx_packets ;
156
+ s -> tx_bytes = stats64 .tx_bytes ;
157
+ s -> tx_queue_dropped = stats64 .tx_dropped ;
158
+ }
159
+
160
+ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS (vport_rep )
161
+ {
162
+ return NUM_VPORT_REP_HW_COUNTERS ;
163
+ }
164
+
165
+ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS (vport_rep )
166
+ {
167
+ int i ;
168
+
169
+ for (i = 0 ; i < NUM_VPORT_REP_HW_COUNTERS ; i ++ )
170
+ strcpy (data + (idx ++ ) * ETH_GSTRING_LEN , vport_rep_stats_desc [i ].format );
171
+ return idx ;
172
+ }
173
+
174
+ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS (vport_rep )
175
+ {
176
+ int i ;
177
+
178
+ for (i = 0 ; i < NUM_VPORT_REP_HW_COUNTERS ; i ++ )
179
+ data [idx ++ ] = MLX5E_READ_CTR64_CPU (& priv -> stats .vf_vport ,
180
+ vport_rep_stats_desc , i );
181
+ return idx ;
135
182
}
136
183
137
- static void mlx5e_rep_update_hw_counters (struct mlx5e_priv * priv )
184
+ static void mlx5e_vf_rep_update_hw_counters (struct mlx5e_priv * priv )
138
185
{
139
186
struct mlx5_eswitch * esw = priv -> mdev -> priv .eswitch ;
140
187
struct mlx5e_rep_priv * rpriv = priv -> ppriv ;
@@ -172,49 +219,44 @@ static void mlx5e_uplink_rep_update_hw_counters(struct mlx5e_priv *priv)
172
219
vport_stats -> tx_bytes = PPORT_802_3_GET (pstats , a_octets_transmitted_ok );
173
220
}
174
221
175
- static void mlx5e_rep_update_sw_counters ( struct mlx5e_priv * priv )
222
+ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS ( vport_rep )
176
223
{
177
- struct mlx5e_sw_stats * s = & priv -> stats . sw ;
178
- struct rtnl_link_stats64 stats64 = {} ;
224
+ struct mlx5e_rep_priv * rpriv = priv -> ppriv ;
225
+ struct mlx5_eswitch_rep * rep = rpriv -> rep ;
179
226
180
- memset (s , 0 , sizeof (* s ));
181
- mlx5e_fold_sw_stats64 (priv , & stats64 );
227
+ if (rep -> vport == MLX5_VPORT_UPLINK )
228
+ mlx5e_uplink_rep_update_hw_counters (priv );
229
+ else
230
+ mlx5e_vf_rep_update_hw_counters (priv );
231
+ }
182
232
183
- s -> rx_packets = stats64 .rx_packets ;
184
- s -> rx_bytes = stats64 .rx_bytes ;
185
- s -> tx_packets = stats64 .tx_packets ;
186
- s -> tx_bytes = stats64 .tx_bytes ;
187
- s -> tx_queue_dropped = stats64 .tx_dropped ;
233
+ static void mlx5e_rep_get_strings (struct net_device * dev ,
234
+ u32 stringset , uint8_t * data )
235
+ {
236
+ struct mlx5e_priv * priv = netdev_priv (dev );
237
+
238
+ switch (stringset ) {
239
+ case ETH_SS_STATS :
240
+ mlx5e_stats_fill_strings (priv , data );
241
+ break ;
242
+ }
188
243
}
189
244
190
245
static void mlx5e_rep_get_ethtool_stats (struct net_device * dev ,
191
246
struct ethtool_stats * stats , u64 * data )
192
247
{
193
248
struct mlx5e_priv * priv = netdev_priv (dev );
194
- int i , j ;
195
-
196
- if (!data )
197
- return ;
198
-
199
- mutex_lock (& priv -> state_lock );
200
- mlx5e_rep_update_sw_counters (priv );
201
- priv -> profile -> update_stats (priv );
202
- mutex_unlock (& priv -> state_lock );
203
249
204
- for (i = 0 ; i < NUM_VPORT_REP_SW_COUNTERS ; i ++ )
205
- data [i ] = MLX5E_READ_CTR64_CPU (& priv -> stats .sw ,
206
- sw_rep_stats_desc , i );
207
-
208
- for (j = 0 ; j < NUM_VPORT_REP_HW_COUNTERS ; j ++ , i ++ )
209
- data [i ] = MLX5E_READ_CTR64_CPU (& priv -> stats .vf_vport ,
210
- vport_rep_stats_desc , j );
250
+ mlx5e_ethtool_get_ethtool_stats (priv , stats , data );
211
251
}
212
252
213
253
static int mlx5e_rep_get_sset_count (struct net_device * dev , int sset )
214
254
{
255
+ struct mlx5e_priv * priv = netdev_priv (dev );
256
+
215
257
switch (sset ) {
216
258
case ETH_SS_STATS :
217
- return NUM_VPORT_REP_SW_COUNTERS + NUM_VPORT_REP_HW_COUNTERS ;
259
+ return mlx5e_stats_total_num ( priv ) ;
218
260
default :
219
261
return - EOPNOTSUPP ;
220
262
}
@@ -1833,6 +1875,31 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
1833
1875
mlx5_lag_remove (mdev );
1834
1876
}
1835
1877
1878
+ static MLX5E_DEFINE_STATS_GRP (sw_rep , 0 ) ;
1879
+ static MLX5E_DEFINE_STATS_GRP (vport_rep , MLX5E_NDO_UPDATE_STATS ) ;
1880
+
1881
+ /* The stats groups order is opposite to the update_stats() order calls */
1882
+ static mlx5e_stats_grp_t mlx5e_rep_stats_grps [] = {
1883
+ & MLX5E_STATS_GRP (sw_rep ),
1884
+ & MLX5E_STATS_GRP (vport_rep ),
1885
+ };
1886
+
1887
+ static unsigned int mlx5e_rep_stats_grps_num (struct mlx5e_priv * priv )
1888
+ {
1889
+ return ARRAY_SIZE (mlx5e_rep_stats_grps );
1890
+ }
1891
+
1892
+ /* The stats groups order is opposite to the update_stats() order calls */
1893
+ static mlx5e_stats_grp_t mlx5e_ul_rep_stats_grps [] = {
1894
+ & MLX5E_STATS_GRP (sw_rep ),
1895
+ & MLX5E_STATS_GRP (vport_rep ),
1896
+ };
1897
+
1898
+ static unsigned int mlx5e_ul_rep_stats_grps_num (struct mlx5e_priv * priv )
1899
+ {
1900
+ return ARRAY_SIZE (mlx5e_ul_rep_stats_grps );
1901
+ }
1902
+
1836
1903
static const struct mlx5e_profile mlx5e_rep_profile = {
1837
1904
.init = mlx5e_init_rep ,
1838
1905
.cleanup = mlx5e_cleanup_rep ,
@@ -1842,11 +1909,13 @@ static const struct mlx5e_profile mlx5e_rep_profile = {
1842
1909
.cleanup_tx = mlx5e_cleanup_rep_tx ,
1843
1910
.enable = mlx5e_rep_enable ,
1844
1911
.update_rx = mlx5e_update_rep_rx ,
1845
- .update_stats = mlx5e_rep_update_hw_counters ,
1912
+ .update_stats = mlx5e_update_ndo_stats ,
1846
1913
.rx_handlers .handle_rx_cqe = mlx5e_handle_rx_cqe_rep ,
1847
1914
.rx_handlers .handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq ,
1848
1915
.max_tc = 1 ,
1849
1916
.rq_groups = MLX5E_NUM_RQ_GROUPS (REGULAR ),
1917
+ .stats_grps = mlx5e_rep_stats_grps ,
1918
+ .stats_grps_num = mlx5e_rep_stats_grps_num ,
1850
1919
};
1851
1920
1852
1921
static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
@@ -1859,12 +1928,14 @@ static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
1859
1928
.enable = mlx5e_uplink_rep_enable ,
1860
1929
.disable = mlx5e_uplink_rep_disable ,
1861
1930
.update_rx = mlx5e_update_rep_rx ,
1862
- .update_stats = mlx5e_uplink_rep_update_hw_counters ,
1931
+ .update_stats = mlx5e_update_ndo_stats ,
1863
1932
.update_carrier = mlx5e_update_carrier ,
1864
1933
.rx_handlers .handle_rx_cqe = mlx5e_handle_rx_cqe_rep ,
1865
1934
.rx_handlers .handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq ,
1866
1935
.max_tc = MLX5E_MAX_NUM_TC ,
1867
1936
.rq_groups = MLX5E_NUM_RQ_GROUPS (REGULAR ),
1937
+ .stats_grps = mlx5e_ul_rep_stats_grps ,
1938
+ .stats_grps_num = mlx5e_ul_rep_stats_grps_num ,
1868
1939
};
1869
1940
1870
1941
static bool
0 commit comments