Skip to content

Commit 7b3bbe2

Browse files
committed
util/xdp_sample: Print PPS values in summary line instead of totals
The Summary line output was printing the total values instead of the PPS values, which led to wrong values being printed now that we account the total values correctly. Fix the output to print the PPS values instead of the totals. Add a new err_pps variable to stats_output.totals to record accumulated errors from the various count sources. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
1 parent a40ae7a commit 7b3bbe2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/util/xdp_sample.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct sample_output {
123123
uint64_t drop;
124124
uint64_t drop_xmit;
125125
uint64_t err;
126+
uint64_t err_pps;
126127
uint64_t xmit;
127128
} totals;
128129
struct {
@@ -669,13 +670,16 @@ static void stats_get_rx_cnt(struct stats_record *stats_rec,
669670
}
670671

671672
if (out) {
673+
err = calc_errs_pps(&rec->total, &prev->total, t);
674+
672675
out->rx_cnt.pps = calc_pps(&rec->total, &prev->total, t);
673676
out->rx_cnt.drop = calc_drop_pps(&rec->total, &prev->total, t);
674-
out->rx_cnt.err = calc_errs_pps(&rec->total, &prev->total, t);
677+
out->rx_cnt.err = err;
675678

676679
out->totals.rx += calc_pkts(&rec->total, &prev->total, t);
677680
out->totals.drop += calc_drop_pkts(&rec->total, &prev->total, t);
678681
out->totals.err += calc_errs_pkts(&rec->total, &prev->total, t);
682+
out->totals.err_pps += err;
679683
}
680684
}
681685

@@ -918,6 +922,7 @@ static void stats_get_redirect_err_cnt(struct stats_record *stats_rec,
918922
if (out) {
919923
out->redir_cnt.err = sum_pps;
920924
out->totals.err += sum_pkts;
925+
out->totals.err_pps += sum_pps;
921926
}
922927
}
923928

@@ -964,6 +969,7 @@ static void stats_get_exception_cnt(struct stats_record *stats_rec,
964969
if (out) {
965970
out->except_cnt.hits = sum_pps;
966971
out->totals.err += sum_pkts;
972+
out->totals.err_pps += sum_pps;
967973
}
968974
}
969975

@@ -1004,18 +1010,20 @@ static void stats_get_devmap_xmit(struct stats_record *stats_rec,
10041010
if (out) {
10051011
pps = calc_pps(&rec->total, &prev->total, t);
10061012
drop = calc_drop_pps(&rec->total, &prev->total, t);
1013+
err = calc_errs_pps(&rec->total, &prev->total, t);
10071014

10081015
info = calc_info_pps(&rec->total, &prev->total, t);
10091016
if (info > 0)
10101017
out->xmit_cnt.bavg = (pps + drop) / info; /* calc avg bulk */
10111018

10121019
out->xmit_cnt.pps = pps;
10131020
out->xmit_cnt.drop = drop;
1014-
out->xmit_cnt.err = calc_errs_pps(&rec->total, &prev->total, t);
1021+
out->xmit_cnt.err = err;
10151022

10161023
out->totals.xmit += calc_pkts(&rec->total, &prev->total, t);
10171024
out->totals.drop_xmit += calc_drop_pkts(&rec->total, &prev->total, t);;
10181025
out->totals.err += calc_errs_pkts(&rec->total, &prev->total, t);;
1026+
out->totals.err_pps += err;
10191027
}
10201028
}
10211029

@@ -1069,6 +1077,7 @@ static void stats_get_devmap_xmit_multi(struct stats_record *stats_rec,
10691077
out->totals.xmit += calc_pkts(&r->total, &p->total, t);
10701078
out->totals.drop_xmit += calc_drop_pkts(&r->total, &p->total, t);
10711079
out->totals.err += calc_errs_pkts(&r->total, &p->total, t);
1080+
out->totals.err_pps += calc_errs_pps(&r->total, &p->total, t);
10721081
continue;
10731082
}
10741083

@@ -1129,15 +1138,15 @@ static void stats_print(const char *prefix, int mask, struct stats_record *r,
11291138

11301139
print_always("%-23s", prefix ?: "Summary");
11311140
if (mask & SAMPLE_RX_CNT)
1132-
print_always(FMT_COLUMNl, RX(out->totals.rx));
1141+
print_always(FMT_COLUMNl, RX(out->rx_cnt.pps));
11331142
if (mask & SAMPLE_REDIRECT_CNT)
1134-
print_always(FMT_COLUMNl, REDIR(out->totals.redir));
1143+
print_always(FMT_COLUMNl, REDIR(out->redir_cnt.suc));
11351144
printf(FMT_COLUMNl,
1136-
out->totals.err + ((out->totals.drop_xmit + out->totals.drop) * !(mask & SAMPLE_DROP_OK)),
1145+
out->totals.err_pps + ((out->rx_cnt.drop + out->xmit_cnt.drop) * !(mask & SAMPLE_DROP_OK)),
11371146
(mask & SAMPLE_DROP_OK) ? "err/s" : "err,drop/s");
11381147
if (mask & SAMPLE_DEVMAP_XMIT_CNT ||
11391148
mask & SAMPLE_DEVMAP_XMIT_CNT_MULTI)
1140-
printf(FMT_COLUMNl, XMIT(out->totals.xmit));
1149+
printf(FMT_COLUMNl, XMIT(out->xmit_cnt.pps));
11411150
printf("\n");
11421151

11431152
if (mask & SAMPLE_RX_CNT) {

0 commit comments

Comments
 (0)