Skip to content

Commit

Permalink
util/xdp_sample: Print PPS values in summary line instead of totals
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tohojo committed Feb 11, 2025
1 parent a40ae7a commit 7b3bbe2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/util/xdp_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ struct sample_output {
uint64_t drop;
uint64_t drop_xmit;
uint64_t err;
uint64_t err_pps;
uint64_t xmit;
} totals;
struct {
Expand Down Expand Up @@ -669,13 +670,16 @@ static void stats_get_rx_cnt(struct stats_record *stats_rec,
}

if (out) {
err = calc_errs_pps(&rec->total, &prev->total, t);

out->rx_cnt.pps = calc_pps(&rec->total, &prev->total, t);
out->rx_cnt.drop = calc_drop_pps(&rec->total, &prev->total, t);
out->rx_cnt.err = calc_errs_pps(&rec->total, &prev->total, t);
out->rx_cnt.err = err;

out->totals.rx += calc_pkts(&rec->total, &prev->total, t);
out->totals.drop += calc_drop_pkts(&rec->total, &prev->total, t);
out->totals.err += calc_errs_pkts(&rec->total, &prev->total, t);
out->totals.err_pps += err;
}
}

Expand Down Expand Up @@ -918,6 +922,7 @@ static void stats_get_redirect_err_cnt(struct stats_record *stats_rec,
if (out) {
out->redir_cnt.err = sum_pps;
out->totals.err += sum_pkts;
out->totals.err_pps += sum_pps;
}
}

Expand Down Expand Up @@ -964,6 +969,7 @@ static void stats_get_exception_cnt(struct stats_record *stats_rec,
if (out) {
out->except_cnt.hits = sum_pps;
out->totals.err += sum_pkts;
out->totals.err_pps += sum_pps;
}
}

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

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

out->xmit_cnt.pps = pps;
out->xmit_cnt.drop = drop;
out->xmit_cnt.err = calc_errs_pps(&rec->total, &prev->total, t);
out->xmit_cnt.err = err;

out->totals.xmit += calc_pkts(&rec->total, &prev->total, t);
out->totals.drop_xmit += calc_drop_pkts(&rec->total, &prev->total, t);;
out->totals.err += calc_errs_pkts(&rec->total, &prev->total, t);;
out->totals.err_pps += err;
}
}

Expand Down Expand Up @@ -1069,6 +1077,7 @@ static void stats_get_devmap_xmit_multi(struct stats_record *stats_rec,
out->totals.xmit += calc_pkts(&r->total, &p->total, t);
out->totals.drop_xmit += calc_drop_pkts(&r->total, &p->total, t);
out->totals.err += calc_errs_pkts(&r->total, &p->total, t);
out->totals.err_pps += calc_errs_pps(&r->total, &p->total, t);
continue;
}

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

print_always("%-23s", prefix ?: "Summary");
if (mask & SAMPLE_RX_CNT)
print_always(FMT_COLUMNl, RX(out->totals.rx));
print_always(FMT_COLUMNl, RX(out->rx_cnt.pps));
if (mask & SAMPLE_REDIRECT_CNT)
print_always(FMT_COLUMNl, REDIR(out->totals.redir));
print_always(FMT_COLUMNl, REDIR(out->redir_cnt.suc));
printf(FMT_COLUMNl,
out->totals.err + ((out->totals.drop_xmit + out->totals.drop) * !(mask & SAMPLE_DROP_OK)),
out->totals.err_pps + ((out->rx_cnt.drop + out->xmit_cnt.drop) * !(mask & SAMPLE_DROP_OK)),
(mask & SAMPLE_DROP_OK) ? "err/s" : "err,drop/s");
if (mask & SAMPLE_DEVMAP_XMIT_CNT ||
mask & SAMPLE_DEVMAP_XMIT_CNT_MULTI)
printf(FMT_COLUMNl, XMIT(out->totals.xmit));
printf(FMT_COLUMNl, XMIT(out->xmit_cnt.pps));
printf("\n");

if (mask & SAMPLE_RX_CNT) {
Expand Down

0 comments on commit 7b3bbe2

Please sign in to comment.