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


Alexei Starovoitov says:

====================
pull-request: bpf-next 2021-03-24

The following pull-request contains BPF updates for your *net-next* tree.

We've added 37 non-merge commits during the last 15 day(s) which contain
a total of 65 files changed, 3200 insertions(+), 738 deletions(-).

The main changes are:

1) Static linking of multiple BPF ELF files, from Andrii.

2) Move drop error path to devmap for XDP_REDIRECT, from Lorenzo.

3) Spelling fixes from various folks.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents efd13b71 e2c69f3a
Loading
Loading
Loading
Loading
+55 −9
Original line number Original line Diff line number Diff line
@@ -1209,21 +1209,67 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
	 */
	 */
	case BPF_STX | BPF_ATOMIC | BPF_DW:
	case BPF_STX | BPF_ATOMIC | BPF_DW:
	case BPF_STX | BPF_ATOMIC | BPF_W:
	case BPF_STX | BPF_ATOMIC | BPF_W:
		if (insn->imm != BPF_ADD) {
	{
		bool is32 = BPF_SIZE(insn->code) == BPF_W;

		switch (insn->imm) {
/* {op32|op64} {%w0|%src},%src,off(%dst) */
#define EMIT_ATOMIC(op32, op64) do {					\
	EMIT6_DISP_LH(0xeb000000, is32 ? (op32) : (op64),		\
		      (insn->imm & BPF_FETCH) ? src_reg : REG_W0,	\
		      src_reg, dst_reg, off);				\
	if (is32 && (insn->imm & BPF_FETCH))				\
		EMIT_ZERO(src_reg);					\
} while (0)
		case BPF_ADD:
		case BPF_ADD | BPF_FETCH:
			/* {laal|laalg} */
			EMIT_ATOMIC(0x00fa, 0x00ea);
			break;
		case BPF_AND:
		case BPF_AND | BPF_FETCH:
			/* {lan|lang} */
			EMIT_ATOMIC(0x00f4, 0x00e4);
			break;
		case BPF_OR:
		case BPF_OR | BPF_FETCH:
			/* {lao|laog} */
			EMIT_ATOMIC(0x00f6, 0x00e6);
			break;
		case BPF_XOR:
		case BPF_XOR | BPF_FETCH:
			/* {lax|laxg} */
			EMIT_ATOMIC(0x00f7, 0x00e7);
			break;
#undef EMIT_ATOMIC
		case BPF_XCHG:
			/* {ly|lg} %w0,off(%dst) */
			EMIT6_DISP_LH(0xe3000000,
				      is32 ? 0x0058 : 0x0004, REG_W0, REG_0,
				      dst_reg, off);
			/* 0: {csy|csg} %w0,%src,off(%dst) */
			EMIT6_DISP_LH(0xeb000000, is32 ? 0x0014 : 0x0030,
				      REG_W0, src_reg, dst_reg, off);
			/* brc 4,0b */
			EMIT4_PCREL_RIC(0xa7040000, 4, jit->prg - 6);
			/* {llgfr|lgr} %src,%w0 */
			EMIT4(is32 ? 0xb9160000 : 0xb9040000, src_reg, REG_W0);
			if (is32 && insn_is_zext(&insn[1]))
				insn_count = 2;
			break;
		case BPF_CMPXCHG:
			/* 0: {csy|csg} %b0,%src,off(%dst) */
			EMIT6_DISP_LH(0xeb000000, is32 ? 0x0014 : 0x0030,
				      BPF_REG_0, src_reg, dst_reg, off);
			break;
		default:
			pr_err("Unknown atomic operation %02x\n", insn->imm);
			pr_err("Unknown atomic operation %02x\n", insn->imm);
			return -1;
			return -1;
		}
		}


		/* *(u32/u64 *)(dst + off) += src
		 *
		 * BFW_W:  laal  %w0,%src,off(%dst)
		 * BPF_DW: laalg %w0,%src,off(%dst)
		 */
		EMIT6_DISP_LH(0xeb000000,
			      BPF_SIZE(insn->code) == BPF_W ? 0x00fa : 0x00ea,
			      REG_W0, src_reg, dst_reg, off);
		jit->seen |= SEEN_MEM;
		jit->seen |= SEEN_MEM;
		break;
		break;
	}
	/*
	/*
	 * BPF_LDX
	 * BPF_LDX
	 */
	 */
+9 −12
Original line number Original line Diff line number Diff line
@@ -300,7 +300,7 @@ static int ena_xdp_xmit_frame(struct ena_ring *xdp_ring,


	rc = ena_xdp_tx_map_frame(xdp_ring, tx_info, xdpf, &push_hdr, &push_len);
	rc = ena_xdp_tx_map_frame(xdp_ring, tx_info, xdpf, &push_hdr, &push_len);
	if (unlikely(rc))
	if (unlikely(rc))
		goto error_drop_packet;
		return rc;


	ena_tx_ctx.ena_bufs = tx_info->bufs;
	ena_tx_ctx.ena_bufs = tx_info->bufs;
	ena_tx_ctx.push_header = push_hdr;
	ena_tx_ctx.push_header = push_hdr;
@@ -330,8 +330,6 @@ static int ena_xdp_xmit_frame(struct ena_ring *xdp_ring,
error_unmap_dma:
error_unmap_dma:
	ena_unmap_tx_buff(xdp_ring, tx_info);
	ena_unmap_tx_buff(xdp_ring, tx_info);
	tx_info->xdpf = NULL;
	tx_info->xdpf = NULL;
error_drop_packet:
	xdp_return_frame(xdpf);
	return rc;
	return rc;
}
}


@@ -339,8 +337,8 @@ static int ena_xdp_xmit(struct net_device *dev, int n,
			struct xdp_frame **frames, u32 flags)
			struct xdp_frame **frames, u32 flags)
{
{
	struct ena_adapter *adapter = netdev_priv(dev);
	struct ena_adapter *adapter = netdev_priv(dev);
	int qid, i, err, drops = 0;
	struct ena_ring *xdp_ring;
	struct ena_ring *xdp_ring;
	int qid, i, nxmit = 0;


	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
		return -EINVAL;
		return -EINVAL;
@@ -360,12 +358,9 @@ static int ena_xdp_xmit(struct net_device *dev, int n,
	spin_lock(&xdp_ring->xdp_tx_lock);
	spin_lock(&xdp_ring->xdp_tx_lock);


	for (i = 0; i < n; i++) {
	for (i = 0; i < n; i++) {
		err = ena_xdp_xmit_frame(xdp_ring, dev, frames[i], 0);
		if (ena_xdp_xmit_frame(xdp_ring, dev, frames[i], 0))
		/* The descriptor is freed by ena_xdp_xmit_frame in case
			break;
		 * of an error.
		nxmit++;
		 */
		if (err)
			drops++;
	}
	}


	/* Ring doorbell to make device aware of the packets */
	/* Ring doorbell to make device aware of the packets */
@@ -378,7 +373,7 @@ static int ena_xdp_xmit(struct net_device *dev, int n,
	spin_unlock(&xdp_ring->xdp_tx_lock);
	spin_unlock(&xdp_ring->xdp_tx_lock);


	/* Return number of packets sent */
	/* Return number of packets sent */
	return n - drops;
	return nxmit;
}
}


static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
@@ -415,7 +410,9 @@ static int ena_xdp_execute(struct ena_ring *rx_ring, struct xdp_buff *xdp)
		/* The XDP queues are shared between XDP_TX and XDP_REDIRECT */
		/* The XDP queues are shared between XDP_TX and XDP_REDIRECT */
		spin_lock(&xdp_ring->xdp_tx_lock);
		spin_lock(&xdp_ring->xdp_tx_lock);


		ena_xdp_xmit_frame(xdp_ring, rx_ring->netdev, xdpf, XDP_XMIT_FLUSH);
		if (ena_xdp_xmit_frame(xdp_ring, rx_ring->netdev, xdpf,
				       XDP_XMIT_FLUSH))
			xdp_return_frame(xdpf);


		spin_unlock(&xdp_ring->xdp_tx_lock);
		spin_unlock(&xdp_ring->xdp_tx_lock);
		xdp_stat = &rx_ring->rx_stats.xdp_tx;
		xdp_stat = &rx_ring->rx_stats.xdp_tx;
+8 −12
Original line number Original line Diff line number Diff line
@@ -217,7 +217,7 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,
	struct pci_dev *pdev = bp->pdev;
	struct pci_dev *pdev = bp->pdev;
	struct bnxt_tx_ring_info *txr;
	struct bnxt_tx_ring_info *txr;
	dma_addr_t mapping;
	dma_addr_t mapping;
	int drops = 0;
	int nxmit = 0;
	int ring;
	int ring;
	int i;
	int i;


@@ -233,21 +233,17 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,
		struct xdp_frame *xdp = frames[i];
		struct xdp_frame *xdp = frames[i];


		if (!txr || !bnxt_tx_avail(bp, txr) ||
		if (!txr || !bnxt_tx_avail(bp, txr) ||
		    !(bp->bnapi[ring]->flags & BNXT_NAPI_FLAG_XDP)) {
		    !(bp->bnapi[ring]->flags & BNXT_NAPI_FLAG_XDP))
			xdp_return_frame_rx_napi(xdp);
			break;
			drops++;
			continue;
		}


		mapping = dma_map_single(&pdev->dev, xdp->data, xdp->len,
		mapping = dma_map_single(&pdev->dev, xdp->data, xdp->len,
					 DMA_TO_DEVICE);
					 DMA_TO_DEVICE);


		if (dma_mapping_error(&pdev->dev, mapping)) {
		if (dma_mapping_error(&pdev->dev, mapping))
			xdp_return_frame_rx_napi(xdp);
			break;
			drops++;

			continue;
		}
		__bnxt_xmit_xdp_redirect(bp, txr, mapping, xdp->len, xdp);
		__bnxt_xmit_xdp_redirect(bp, txr, mapping, xdp->len, xdp);
		nxmit++;
	}
	}


	if (flags & XDP_XMIT_FLUSH) {
	if (flags & XDP_XMIT_FLUSH) {
@@ -256,7 +252,7 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,
		bnxt_db_write(bp, &txr->tx_db, txr->tx_prod);
		bnxt_db_write(bp, &txr->tx_db, txr->tx_prod);
	}
	}


	return num_frames - drops;
	return nxmit;
}
}


/* Under rtnl_lock */
/* Under rtnl_lock */
+5 −7
Original line number Original line Diff line number Diff line
@@ -3081,7 +3081,7 @@ static int dpaa_xdp_xmit(struct net_device *net_dev, int n,
			 struct xdp_frame **frames, u32 flags)
			 struct xdp_frame **frames, u32 flags)
{
{
	struct xdp_frame *xdpf;
	struct xdp_frame *xdpf;
	int i, err, drops = 0;
	int i, nxmit = 0;


	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
		return -EINVAL;
		return -EINVAL;
@@ -3091,14 +3091,12 @@ static int dpaa_xdp_xmit(struct net_device *net_dev, int n,


	for (i = 0; i < n; i++) {
	for (i = 0; i < n; i++) {
		xdpf = frames[i];
		xdpf = frames[i];
		err = dpaa_xdp_xmit_frame(net_dev, xdpf);
		if (dpaa_xdp_xmit_frame(net_dev, xdpf))
		if (err) {
			break;
			xdp_return_frame_rx_napi(xdpf);
		nxmit++;
			drops++;
		}
	}
	}


	return n - drops;
	return nxmit;
}
}


static int dpaa_ts_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
static int dpaa_ts_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+0 −2
Original line number Original line Diff line number Diff line
@@ -2431,8 +2431,6 @@ static int dpaa2_eth_xdp_xmit(struct net_device *net_dev, int n,
	percpu_stats->tx_packets += enqueued;
	percpu_stats->tx_packets += enqueued;
	for (i = 0; i < enqueued; i++)
	for (i = 0; i < enqueued; i++)
		percpu_stats->tx_bytes += dpaa2_fd_get_len(&fds[i]);
		percpu_stats->tx_bytes += dpaa2_fd_get_len(&fds[i]);
	for (i = enqueued; i < n; i++)
		xdp_return_frame_rx_napi(frames[i]);


	return enqueued;
	return enqueued;
}
}
Loading