@@ -140,6 +140,19 @@ static int bnxt_set_coalesce(struct net_device *dev,
140
140
#define BNXT_RX_STATS_EXT_ENTRY (counter ) \
141
141
{ BNXT_RX_STATS_EXT_OFFSET(counter), __stringify(counter) }
142
142
143
+ enum {
144
+ RX_TOTAL_DISCARDS ,
145
+ TX_TOTAL_DISCARDS ,
146
+ };
147
+
148
+ static struct {
149
+ u64 counter ;
150
+ char string [ETH_GSTRING_LEN ];
151
+ } bnxt_sw_func_stats [] = {
152
+ {0 , "rx_total_discard_pkts" },
153
+ {0 , "tx_total_discard_pkts" },
154
+ };
155
+
143
156
static const struct {
144
157
long offset ;
145
158
char string [ETH_GSTRING_LEN ];
@@ -237,13 +250,16 @@ static const struct {
237
250
BNXT_RX_STATS_EXT_ENTRY (resume_roce_pause_events ),
238
251
};
239
252
253
+ #define BNXT_NUM_SW_FUNC_STATS ARRAY_SIZE(bnxt_sw_func_stats)
240
254
#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr)
241
255
#define BNXT_NUM_PORT_STATS_EXT ARRAY_SIZE(bnxt_port_stats_ext_arr)
242
256
243
257
static int bnxt_get_num_stats (struct bnxt * bp )
244
258
{
245
259
int num_stats = BNXT_NUM_STATS * bp -> cp_nr_rings ;
246
260
261
+ num_stats += BNXT_NUM_SW_FUNC_STATS ;
262
+
247
263
if (bp -> flags & BNXT_FLAG_PORT_STATS )
248
264
num_stats += BNXT_NUM_PORT_STATS ;
249
265
@@ -279,6 +295,9 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
279
295
if (!bp -> bnapi )
280
296
return ;
281
297
298
+ for (i = 0 ; i < BNXT_NUM_SW_FUNC_STATS ; i ++ )
299
+ bnxt_sw_func_stats [i ].counter = 0 ;
300
+
282
301
for (i = 0 ; i < bp -> cp_nr_rings ; i ++ ) {
283
302
struct bnxt_napi * bnapi = bp -> bnapi [i ];
284
303
struct bnxt_cp_ring_info * cpr = & bnapi -> cp_ring ;
@@ -288,7 +307,16 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
288
307
for (k = 0 ; k < stat_fields ; j ++ , k ++ )
289
308
buf [j ] = le64_to_cpu (hw_stats [k ]);
290
309
buf [j ++ ] = cpr -> rx_l4_csum_errors ;
310
+
311
+ bnxt_sw_func_stats [RX_TOTAL_DISCARDS ].counter +=
312
+ le64_to_cpu (cpr -> hw_stats -> rx_discard_pkts );
313
+ bnxt_sw_func_stats [TX_TOTAL_DISCARDS ].counter +=
314
+ le64_to_cpu (cpr -> hw_stats -> tx_discard_pkts );
291
315
}
316
+
317
+ for (i = 0 ; i < BNXT_NUM_SW_FUNC_STATS ; i ++ , j ++ )
318
+ buf [j ] = bnxt_sw_func_stats [i ].counter ;
319
+
292
320
if (bp -> flags & BNXT_FLAG_PORT_STATS ) {
293
321
__le64 * port_stats = (__le64 * )bp -> hw_rx_port_stats ;
294
322
@@ -359,6 +387,11 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
359
387
sprintf (buf , "[%d]: rx_l4_csum_errors" , i );
360
388
buf += ETH_GSTRING_LEN ;
361
389
}
390
+ for (i = 0 ; i < BNXT_NUM_SW_FUNC_STATS ; i ++ ) {
391
+ strcpy (buf , bnxt_sw_func_stats [i ].string );
392
+ buf += ETH_GSTRING_LEN ;
393
+ }
394
+
362
395
if (bp -> flags & BNXT_FLAG_PORT_STATS ) {
363
396
for (i = 0 ; i < BNXT_NUM_PORT_STATS ; i ++ ) {
364
397
strcpy (buf , bnxt_port_stats_arr [i ].string );
0 commit comments