Commit 4cd28b21 authored by Sameeh Jubran's avatar Sameeh Jubran Committed by David S. Miller

net: ena: xdp: add queue counters for xdp actions

When using XDP every ingress packet is passed to an eBPF (xdp) program
which returns an action for this packet.

This patch adds counters for the number of times each such action was
received. It also counts all the invalid actions received from the eBPF
program.
Signed-off-by: default avatarShay Agroskin <shayagr@amazon.com>
Signed-off-by: default avatarSameeh Jubran <sameehj@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0201bda1
......@@ -116,6 +116,11 @@ static const struct ena_stats ena_stats_rx_strings[] = {
ENA_STAT_RX_ENTRY(bad_req_id),
ENA_STAT_RX_ENTRY(empty_rx_ring),
ENA_STAT_RX_ENTRY(csum_unchecked),
ENA_STAT_RX_ENTRY(xdp_aborted),
ENA_STAT_RX_ENTRY(xdp_drop),
ENA_STAT_RX_ENTRY(xdp_pass),
ENA_STAT_RX_ENTRY(xdp_tx),
ENA_STAT_RX_ENTRY(xdp_invalid),
};
static const struct ena_stats ena_stats_ena_com_strings[] = {
......
......@@ -365,6 +365,7 @@ static int ena_xdp_execute(struct ena_ring *rx_ring,
{
struct bpf_prog *xdp_prog;
u32 verdict = XDP_PASS;
u64 *xdp_stat;
rcu_read_lock();
xdp_prog = READ_ONCE(rx_ring->xdp_bpf_prog);
......@@ -374,17 +375,31 @@ static int ena_xdp_execute(struct ena_ring *rx_ring,
verdict = bpf_prog_run_xdp(xdp_prog, xdp);
if (verdict == XDP_TX)
if (verdict == XDP_TX) {
ena_xdp_xmit_buff(rx_ring->netdev,
xdp,
rx_ring->qid + rx_ring->adapter->num_io_queues,
rx_info);
else if (unlikely(verdict == XDP_ABORTED))
xdp_stat = &rx_ring->rx_stats.xdp_tx;
} else if (unlikely(verdict == XDP_ABORTED)) {
trace_xdp_exception(rx_ring->netdev, xdp_prog, verdict);
else if (unlikely(verdict > XDP_TX))
xdp_stat = &rx_ring->rx_stats.xdp_aborted;
} else if (unlikely(verdict == XDP_DROP)) {
xdp_stat = &rx_ring->rx_stats.xdp_drop;
} else if (unlikely(verdict == XDP_PASS)) {
xdp_stat = &rx_ring->rx_stats.xdp_pass;
} else {
bpf_warn_invalid_xdp_action(verdict);
xdp_stat = &rx_ring->rx_stats.xdp_invalid;
}
u64_stats_update_begin(&rx_ring->syncp);
(*xdp_stat)++;
u64_stats_update_end(&rx_ring->syncp);
out:
rcu_read_unlock();
return verdict;
}
......
......@@ -261,6 +261,11 @@ struct ena_stats_rx {
u64 bad_req_id;
u64 empty_rx_ring;
u64 csum_unchecked;
u64 xdp_aborted;
u64 xdp_drop;
u64 xdp_pass;
u64 xdp_tx;
u64 xdp_invalid;
};
struct ena_ring {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment