Commit a8551c9b authored by Joshua Roys's avatar Joshua Roys Committed by David S. Miller

net: mlx4: Add support for XDP_REDIRECT

Signed-off-by: default avatarJoshua Roys <roysjosh@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e93c1e03
...@@ -669,6 +669,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud ...@@ -669,6 +669,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
struct bpf_prog *xdp_prog; struct bpf_prog *xdp_prog;
int cq_ring = cq->ring; int cq_ring = cq->ring;
bool doorbell_pending; bool doorbell_pending;
bool xdp_redir_flush;
struct mlx4_cqe *cqe; struct mlx4_cqe *cqe;
struct xdp_buff xdp; struct xdp_buff xdp;
int polled = 0; int polled = 0;
...@@ -682,6 +683,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud ...@@ -682,6 +683,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
xdp_prog = rcu_dereference_bh(ring->xdp_prog); xdp_prog = rcu_dereference_bh(ring->xdp_prog);
xdp_init_buff(&xdp, priv->frag_info[0].frag_stride, &ring->xdp_rxq); xdp_init_buff(&xdp, priv->frag_info[0].frag_stride, &ring->xdp_rxq);
doorbell_pending = false; doorbell_pending = false;
xdp_redir_flush = false;
/* We assume a 1:1 mapping between CQEs and Rx descriptors, so Rx /* We assume a 1:1 mapping between CQEs and Rx descriptors, so Rx
* descriptor offset can be deduced from the CQE index instead of * descriptor offset can be deduced from the CQE index instead of
...@@ -790,6 +792,14 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud ...@@ -790,6 +792,14 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
switch (act) { switch (act) {
case XDP_PASS: case XDP_PASS:
break; break;
case XDP_REDIRECT:
if (xdp_do_redirect(dev, &xdp, xdp_prog) >= 0) {
xdp_redir_flush = true;
frags[0].page = NULL;
goto next;
}
trace_xdp_exception(dev, xdp_prog, act);
goto xdp_drop_no_cnt;
case XDP_TX: case XDP_TX:
if (likely(!mlx4_en_xmit_frame(ring, frags, priv, if (likely(!mlx4_en_xmit_frame(ring, frags, priv,
length, cq_ring, length, cq_ring,
...@@ -897,6 +907,9 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud ...@@ -897,6 +907,9 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
break; break;
} }
if (xdp_redir_flush)
xdp_do_flush();
if (likely(polled)) { if (likely(polled)) {
if (doorbell_pending) { if (doorbell_pending) {
priv->tx_cq[TX_XDP][cq_ring]->xdp_busy = true; priv->tx_cq[TX_XDP][cq_ring]->xdp_busy = true;
......
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