Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cca316f3 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'bpf-tracepoints'



Daniel Borkmann says:

====================
BPF tracepoints

This set adds tracepoints to BPF for better introspection and
debugging. The first two patches are prerequisite for the actual
third patch that adds the tracepoints. I think the first two are
small and straight forward enough that they could ideally go via
net-next, but I'm also open to other suggestions on how to route
them in case that's not applicable (it would reduce potential
merge conflicts on BPF side, though). For details, please see
individual patches.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 60b1af33 a67edbf4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@

#include <net/busy_poll.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>
#include <linux/mlx4/cq.h>
#include <linux/slab.h>
#include <linux/mlx4/qp.h>
@@ -926,10 +927,12 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
							length, cq->ring,
							&doorbell_pending)))
					goto consumed;
				trace_xdp_exception(dev, xdp_prog, act);
				goto xdp_drop_no_cnt; /* Drop on xmit failure */
			default:
				bpf_warn_invalid_xdp_action(act);
			case XDP_ABORTED:
				trace_xdp_exception(dev, xdp_prog, act);
			case XDP_DROP:
				ring->xdp_drop++;
xdp_drop_no_cnt:
+8 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/tcp.h>
#include <linux/bpf_trace.h>
#include <net/busy_poll.h>
#include "en.h"
#include "en_tc.h"
@@ -640,7 +641,7 @@ static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_sq *sq)
	mlx5e_tx_notify_hw(sq, &wqe->ctrl, 0);
}

static inline void mlx5e_xmit_xdp_frame(struct mlx5e_rq *rq,
static inline bool mlx5e_xmit_xdp_frame(struct mlx5e_rq *rq,
					struct mlx5e_dma_info *di,
					const struct xdp_buff *xdp)
{
@@ -662,7 +663,7 @@ static inline void mlx5e_xmit_xdp_frame(struct mlx5e_rq *rq,
		     MLX5E_SW2HW_MTU(rq->netdev->mtu) < dma_len)) {
		rq->stats.xdp_drop++;
		mlx5e_page_release(rq, di, true);
		return;
		return false;
	}

	if (unlikely(!mlx5e_sq_has_room_for(sq, MLX5E_XDP_TX_WQEBBS))) {
@@ -673,7 +674,7 @@ static inline void mlx5e_xmit_xdp_frame(struct mlx5e_rq *rq,
		}
		rq->stats.xdp_tx_full++;
		mlx5e_page_release(rq, di, true);
		return;
		return false;
	}

	dma_len -= MLX5E_XDP_MIN_INLINE;
@@ -703,6 +704,7 @@ static inline void mlx5e_xmit_xdp_frame(struct mlx5e_rq *rq,

	sq->db.xdp.doorbell = true;
	rq->stats.xdp_tx++;
	return true;
}

/* returns true if packet was consumed by xdp */
@@ -728,11 +730,13 @@ static inline int mlx5e_xdp_handle(struct mlx5e_rq *rq,
		*len = xdp.data_end - xdp.data;
		return false;
	case XDP_TX:
		mlx5e_xmit_xdp_frame(rq, di, &xdp);
		if (unlikely(!mlx5e_xmit_xdp_frame(rq, di, &xdp)))
			trace_xdp_exception(rq->netdev, prog, act);
		return true;
	default:
		bpf_warn_invalid_xdp_action(act);
	case XDP_ABORTED:
		trace_xdp_exception(rq->netdev, prog, act);
	case XDP_DROP:
		rq->stats.xdp_drop++;
		mlx5e_page_release(rq, di, true);
+10 −5
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
 */

#include <linux/bpf.h>
#include <linux/bpf_trace.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -1459,7 +1460,7 @@ nfp_net_rx_drop(struct nfp_net_r_vector *r_vec, struct nfp_net_rx_ring *rx_ring,
		dev_kfree_skb_any(skb);
}

static void
static bool
nfp_net_tx_xdp_buf(struct nfp_net *nn, struct nfp_net_rx_ring *rx_ring,
		   struct nfp_net_tx_ring *tx_ring,
		   struct nfp_net_rx_buf *rxbuf, unsigned int pkt_off,
@@ -1473,13 +1474,13 @@ nfp_net_tx_xdp_buf(struct nfp_net *nn, struct nfp_net_rx_ring *rx_ring,

	if (unlikely(nfp_net_tx_full(tx_ring, 1))) {
		nfp_net_rx_drop(rx_ring->r_vec, rx_ring, rxbuf, NULL);
		return;
		return false;
	}

	new_frag = nfp_net_napi_alloc_one(nn, DMA_BIDIRECTIONAL, &new_dma_addr);
	if (unlikely(!new_frag)) {
		nfp_net_rx_drop(rx_ring->r_vec, rx_ring, rxbuf, NULL);
		return;
		return false;
	}
	nfp_net_rx_give_one(rx_ring, new_frag, new_dma_addr);

@@ -1509,6 +1510,7 @@ nfp_net_tx_xdp_buf(struct nfp_net *nn, struct nfp_net_rx_ring *rx_ring,

	tx_ring->wr_p++;
	tx_ring->wr_ptr_add++;
	return true;
}

static int nfp_net_run_xdp(struct bpf_prog *prog, void *data, unsigned int len)
@@ -1613,12 +1615,15 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
			case XDP_PASS:
				break;
			case XDP_TX:
				nfp_net_tx_xdp_buf(nn, rx_ring, tx_ring, rxbuf,
						   pkt_off, pkt_len);
				if (unlikely(!nfp_net_tx_xdp_buf(nn, rx_ring,
								 tx_ring, rxbuf,
								 pkt_off, pkt_len)))
					trace_xdp_exception(nn->netdev, xdp_prog, act);
				continue;
			default:
				bpf_warn_invalid_xdp_action(act);
			case XDP_ABORTED:
				trace_xdp_exception(nn->netdev, xdp_prog, act);
			case XDP_DROP:
				nfp_net_rx_give_one(rx_ring, rxbuf->frag,
						    rxbuf->dma_addr);
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/bpf_trace.h>
#include <net/udp_tunnel.h>
#include <linux/ip.h>
#include <net/ipv6.h>
@@ -1016,6 +1017,7 @@ static bool qede_rx_xdp(struct qede_dev *edev,
		/* We need the replacement buffer before transmit. */
		if (qede_alloc_rx_buffer(rxq, true)) {
			qede_recycle_rx_bd_ring(rxq, 1);
			trace_xdp_exception(edev->ndev, prog, act);
			return false;
		}

@@ -1026,6 +1028,7 @@ static bool qede_rx_xdp(struct qede_dev *edev,
			dma_unmap_page(rxq->dev, bd->mapping,
				       PAGE_SIZE, DMA_BIDIRECTIONAL);
			__free_page(bd->data);
			trace_xdp_exception(edev->ndev, prog, act);
		}

		/* Regardless, we've consumed an Rx BD */
@@ -1035,6 +1038,7 @@ static bool qede_rx_xdp(struct qede_dev *edev,
	default:
		bpf_warn_invalid_xdp_action(act);
	case XDP_ABORTED:
		trace_xdp_exception(edev->ndev, prog, act);
	case XDP_DROP:
		qede_recycle_rx_bd_ring(rxq, cqe->bd_num);
	}
+9 −3
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <linux/virtio.h>
#include <linux/virtio_net.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>
#include <linux/scatterlist.h>
#include <linux/if_vlan.h>
#include <linux/slab.h>
@@ -330,7 +331,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
	return skb;
}

static void virtnet_xdp_xmit(struct virtnet_info *vi,
static bool virtnet_xdp_xmit(struct virtnet_info *vi,
			     struct receive_queue *rq,
			     struct send_queue *sq,
			     struct xdp_buff *xdp,
@@ -382,10 +383,12 @@ static void virtnet_xdp_xmit(struct virtnet_info *vi,
			put_page(page);
		} else /* small buffer */
			kfree_skb(data);
		return; // On error abort to avoid unnecessary kick
		/* On error abort to avoid unnecessary kick */
		return false;
	}

	virtqueue_kick(sq->vq);
	return true;
}

static u32 do_xdp_prog(struct virtnet_info *vi,
@@ -421,11 +424,14 @@ static u32 do_xdp_prog(struct virtnet_info *vi,
			vi->xdp_queue_pairs +
			smp_processor_id();
		xdp.data = buf;
		virtnet_xdp_xmit(vi, rq, &vi->sq[qp], &xdp, data);
		if (unlikely(!virtnet_xdp_xmit(vi, rq, &vi->sq[qp], &xdp,
					       data)))
			trace_xdp_exception(vi->dev, xdp_prog, act);
		return XDP_TX;
	default:
		bpf_warn_invalid_xdp_action(act);
	case XDP_ABORTED:
		trace_xdp_exception(vi->dev, xdp_prog, act);
	case XDP_DROP:
		return XDP_DROP;
	}
Loading