Skip to content

Commit

Permalink
net: ena: xdp: add queue counters for xdp actions
Browse files Browse the repository at this point in the history
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: Shay Agroskin <shayagr@amazon.com>
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sameeh Jubran authored and David S. Miller committed Sep 10, 2020
1 parent 0201bda commit 4cd28b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/amazon/ena/ena_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
21 changes: 18 additions & 3 deletions drivers/net/ethernet/amazon/ena/ena_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/net/ethernet/amazon/ena/ena_netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4cd28b2

Please sign in to comment.