@@ -117,6 +117,7 @@ struct datarec {
117
117
__u64 processed ;
118
118
__u64 dropped ;
119
119
__u64 info ;
120
+ __u64 err ;
120
121
};
121
122
#define MAX_CPUS 64
122
123
@@ -152,6 +153,7 @@ static bool map_collect_record(int fd, __u32 key, struct record *rec)
152
153
__u64 sum_processed = 0 ;
153
154
__u64 sum_dropped = 0 ;
154
155
__u64 sum_info = 0 ;
156
+ __u64 sum_err = 0 ;
155
157
int i ;
156
158
157
159
if ((bpf_map_lookup_elem (fd , & key , values )) != 0 ) {
@@ -170,10 +172,13 @@ static bool map_collect_record(int fd, __u32 key, struct record *rec)
170
172
sum_dropped += values [i ].dropped ;
171
173
rec -> cpu [i ].info = values [i ].info ;
172
174
sum_info += values [i ].info ;
175
+ rec -> cpu [i ].err = values [i ].err ;
176
+ sum_err += values [i ].err ;
173
177
}
174
178
rec -> total .processed = sum_processed ;
175
179
rec -> total .dropped = sum_dropped ;
176
180
rec -> total .info = sum_info ;
181
+ rec -> total .err = sum_err ;
177
182
return true;
178
183
}
179
184
@@ -274,6 +279,18 @@ static double calc_info(struct datarec *r, struct datarec *p, double period)
274
279
return pps ;
275
280
}
276
281
282
+ static double calc_err (struct datarec * r , struct datarec * p , double period )
283
+ {
284
+ __u64 packets = 0 ;
285
+ double pps = 0 ;
286
+
287
+ if (period > 0 ) {
288
+ packets = r -> err - p -> err ;
289
+ pps = packets / period ;
290
+ }
291
+ return pps ;
292
+ }
293
+
277
294
static void stats_print (struct stats_record * stats_rec ,
278
295
struct stats_record * stats_prev ,
279
296
bool err_only )
@@ -412,11 +429,12 @@ static void stats_print(struct stats_record *stats_rec,
412
429
413
430
/* devmap ndo_xdp_xmit stats */
414
431
{
415
- char * fmt1 = "%-15s %-7d %'-12.0f %'-12.0f %'-10.2f %s\n" ;
416
- char * fmt2 = "%-15s %-7s %'-12.0f %'-12.0f %'-10.2f %s\n" ;
432
+ char * fmt1 = "%-15s %-7d %'-12.0f %'-12.0f %'-10.2f %s %s \n" ;
433
+ char * fmt2 = "%-15s %-7s %'-12.0f %'-12.0f %'-10.2f %s %s \n" ;
417
434
struct record * rec , * prev ;
418
- double drop , info ;
435
+ double drop , info , err ;
419
436
char * i_str = "" ;
437
+ char * err_str = "" ;
420
438
421
439
rec = & stats_rec -> xdp_devmap_xmit ;
422
440
prev = & stats_prev -> xdp_devmap_xmit ;
@@ -428,22 +446,29 @@ static void stats_print(struct stats_record *stats_rec,
428
446
pps = calc_pps (r , p , t );
429
447
drop = calc_drop (r , p , t );
430
448
info = calc_info (r , p , t );
449
+ err = calc_err (r , p , t );
431
450
if (info > 0 ) {
432
451
i_str = "bulk-average" ;
433
452
info = (pps + drop ) / info ; /* calc avg bulk */
434
453
}
454
+ if (err > 0 )
455
+ err_str = "drv-err" ;
435
456
if (pps > 0 || drop > 0 )
436
457
printf (fmt1 , "devmap-xmit" ,
437
- i , pps , drop , info , i_str );
458
+ i , pps , drop , info , i_str , err_str );
438
459
}
439
460
pps = calc_pps (& rec -> total , & prev -> total , t );
440
461
drop = calc_drop (& rec -> total , & prev -> total , t );
441
462
info = calc_info (& rec -> total , & prev -> total , t );
463
+ err = calc_err (& rec -> total , & prev -> total , t );
442
464
if (info > 0 ) {
443
465
i_str = "bulk-average" ;
444
466
info = (pps + drop ) / info ; /* calc avg bulk */
445
467
}
446
- printf (fmt2 , "devmap-xmit" , "total" , pps , drop , info , i_str );
468
+ if (err > 0 )
469
+ err_str = "drv-err" ;
470
+ printf (fmt2 , "devmap-xmit" , "total" , pps , drop ,
471
+ info , i_str , err_str );
447
472
}
448
473
449
474
printf ("\n" );
0 commit comments