search for: bpf_prog_run_xdp

Displaying 20 results from an estimated 39 matches for "bpf_prog_run_xdp".

2023 Apr 03
1
[PATCH net-next 3/8] virtio_net: introduce virtnet_xdp_handler() to seprate the logic of run xdp
...; + struct net_device *dev, > + unsigned int *xdp_xmit, > + struct virtnet_rq_stats *stats) > +{ > + struct xdp_frame *xdpf; > + int err; > + u32 act; > + > + act = bpf_prog_run_xdp(xdp_prog, xdp); > + stats->xdp_packets++; > + > + switch (act) { > + case XDP_PASS: > + return VIRTNET_XDP_RES_PASS; > + > + case XDP_TX: > + stats->xdp_tx++; > + xdpf = xdp_convert_buff_to_frame(xdp)...
2017 Dec 31
1
[bpf-next V3 PATCH 11/14] virtio_net: setup xdp_rxq_info
...; struct virtnet_info { @@ -559,6 +562,7 @@ static struct sk_buff *receive_small(struct net_device *dev, xdp.data = xdp.data_hard_start + xdp_headroom; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + len; + xdp.rxq = &rq->xdp_rxq; orig_data = xdp.data; act = bpf_prog_run_xdp(xdp_prog, &xdp); @@ -692,6 +696,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, xdp.data = data + vi->hdr_len; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + (len - vi->hdr_len); + xdp.rxq = &rq->xdp_rxq; + act = bpf_prog_run_xdp...
2018 Sep 06
2
[PATCH net-next 06/11] tuntap: split out XDP logic
...(struct tun_struct *tun, struct tun_file *tfile, > return true; > } > > +static u32 tun_do_xdp(struct tun_struct *tun, > + struct tun_file *tfile, > + struct bpf_prog *xdp_prog, > + struct xdp_buff *xdp, > + int *err) > +{ > + u32 act = bpf_prog_run_xdp(xdp_prog, xdp); > + > + switch (act) { > + case XDP_REDIRECT: > + *err = xdp_do_redirect(tun->dev, xdp, xdp_prog); > + xdp_do_flush_map(); > + if (*err) > + break; > + goto out; > + case XDP_TX: > + *err = tun_xdp_tx(tun->dev, xdp); > + if (*err < 0...
2018 Sep 06
2
[PATCH net-next 06/11] tuntap: split out XDP logic
...(struct tun_struct *tun, struct tun_file *tfile, > return true; > } > > +static u32 tun_do_xdp(struct tun_struct *tun, > + struct tun_file *tfile, > + struct bpf_prog *xdp_prog, > + struct xdp_buff *xdp, > + int *err) > +{ > + u32 act = bpf_prog_run_xdp(xdp_prog, xdp); > + > + switch (act) { > + case XDP_REDIRECT: > + *err = xdp_do_redirect(tun->dev, xdp, xdp_prog); > + xdp_do_flush_map(); > + if (*err) > + break; > + goto out; > + case XDP_TX: > + *err = tun_xdp_tx(tun->dev, xdp); > + if (*err < 0...
2023 Apr 04
1
[PATCH net-next 3/8] virtio_net: introduce virtnet_xdp_handler() to seprate the logic of run xdp
...*xdp_xmit, > > > > + struct virtnet_rq_stats *stats) > > > > +{ > > > > + struct xdp_frame *xdpf; > > > > + int err; > > > > + u32 act; > > > > + > > > > + act = bpf_prog_run_xdp(xdp_prog, xdp); > > > > + stats->xdp_packets++; > > > > + > > > > + switch (act) { > > > > + case XDP_PASS: > > > > + return VIRTNET_XDP_RES_PASS; > > > > + > > > > + case XD...
2023 Apr 04
1
[PATCH net-next 3/8] virtio_net: introduce virtnet_xdp_handler() to seprate the logic of run xdp
...; + struct virtnet_rq_stats *stats) > > > > > +{ > > > > > + struct xdp_frame *xdpf; > > > > > + int err; > > > > > + u32 act; > > > > > + > > > > > + act = bpf_prog_run_xdp(xdp_prog, xdp); > > > > > + stats->xdp_packets++; > > > > > + > > > > > + switch (act) { > > > > > + case XDP_PASS: > > > > > + return VIRTNET_XDP_RES_PASS; > > > > > + >...
2023 Apr 04
1
[PATCH net-next 3/8] virtio_net: introduce virtnet_xdp_handler() to seprate the logic of run xdp
...ats) > > > > > > > +{ > > > > > > > + struct xdp_frame *xdpf; > > > > > > > + int err; > > > > > > > + u32 act; > > > > > > > + > > > > > > > + act = bpf_prog_run_xdp(xdp_prog, xdp); > > > > > > > + stats->xdp_packets++; > > > > > > > + > > > > > > > + switch (act) { > > > > > > > + case XDP_PASS: > > > > > > > + return VIRT...
2018 Jan 03
0
[bpf-next V4 PATCH 11/14] virtio_net: setup xdp_rxq_info
...; struct virtnet_info { @@ -559,6 +562,7 @@ static struct sk_buff *receive_small(struct net_device *dev, xdp.data = xdp.data_hard_start + xdp_headroom; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + len; + xdp.rxq = &rq->xdp_rxq; orig_data = xdp.data; act = bpf_prog_run_xdp(xdp_prog, &xdp); @@ -692,6 +696,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, xdp.data = data + vi->hdr_len; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + (len - vi->hdr_len); + xdp.rxq = &rq->xdp_rxq; + act = bpf_prog_run_xdp...
2018 Sep 06
0
[PATCH net-next 06/11] tuntap: split out XDP logic
...-1635,6 +1635,44 @@ static bool tun_can_build_skb(struct tun_struct *tun, struct tun_file *tfile, return true; } +static u32 tun_do_xdp(struct tun_struct *tun, + struct tun_file *tfile, + struct bpf_prog *xdp_prog, + struct xdp_buff *xdp, + int *err) +{ + u32 act = bpf_prog_run_xdp(xdp_prog, xdp); + + switch (act) { + case XDP_REDIRECT: + *err = xdp_do_redirect(tun->dev, xdp, xdp_prog); + xdp_do_flush_map(); + if (*err) + break; + goto out; + case XDP_TX: + *err = tun_xdp_tx(tun->dev, xdp); + if (*err < 0) + break; + *err = 0; + goto out; + case XDP_PASS:...
2018 Sep 07
0
[PATCH net-next 06/11] tuntap: split out XDP logic
...file, >> return true; >> } >> >> +static u32 tun_do_xdp(struct tun_struct *tun, >> + struct tun_file *tfile, >> + struct bpf_prog *xdp_prog, >> + struct xdp_buff *xdp, >> + int *err) >> +{ >> + u32 act = bpf_prog_run_xdp(xdp_prog, xdp); >> + >> + switch (act) { >> + case XDP_REDIRECT: >> + *err = xdp_do_redirect(tun->dev, xdp, xdp_prog); >> + xdp_do_flush_map(); >> + if (*err) >> + break; >> + goto out; >> + case XDP_TX: >> + *err = tun_xdp_tx(tu...
2018 Jul 31
0
[PATCH net-next 2/2] virtio-net: get rid of unnecessary container of rq stats
...len -= vi->hdr_len; - stats->rx.bytes += len; + stats->bytes += len; rcu_read_lock(); xdp_prog = rcu_dereference(rq->xdp_prog); @@ -674,7 +666,7 @@ static struct sk_buff *receive_small(struct net_device *dev, xdp.rxq = &rq->xdp_rxq; orig_data = xdp.data; act = bpf_prog_run_xdp(xdp_prog, &xdp); - stats->rx.xdp_packets++; + stats->xdp_packets++; switch (act) { case XDP_PASS: @@ -683,7 +675,7 @@ static struct sk_buff *receive_small(struct net_device *dev, len = xdp.data_end - xdp.data; break; case XDP_TX: - stats->rx.xdp_tx++; + stats-&...
2018 Jul 31
8
[PATCH net-next 1/2] virtio-net: correctly update XDP_TX counters
Commit 5b8f3c8d30a6 ("virtio_net: Add XDP related stats") tries to count TX XDP stats in virtnet_receive(). This will cause several issues: - virtnet_xdp_sq() was called without checking whether or not XDP is set. This may cause out of bound access when there's no enough txq for XDP. - Stats were updated even if there's no XDP/XDP_TX. Fixing this by reusing
2018 Jul 31
8
[PATCH net-next 1/2] virtio-net: correctly update XDP_TX counters
Commit 5b8f3c8d30a6 ("virtio_net: Add XDP related stats") tries to count TX XDP stats in virtnet_receive(). This will cause several issues: - virtnet_xdp_sq() was called without checking whether or not XDP is set. This may cause out of bound access when there's no enough txq for XDP. - Stats were updated even if there's no XDP/XDP_TX. Fixing this by reusing
2017 Sep 19
0
[PATCH net-next 2/3] virtio-net: add packet len average only when needed during XDP
...--git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index a0ef4b0..db5924c 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -656,6 +656,9 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, xdp.data_end = xdp.data + (len - vi->hdr_len); act = bpf_prog_run_xdp(xdp_prog, &xdp); + if (act != XDP_PASS) + ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len); + switch (act) { case XDP_PASS: /* recalculate offset to account for any header @@ -671,14 +674,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, put_page(page)...
2017 Dec 13
0
[bpf-next V1-RFC PATCH 11/14] virtio_net: setup xdp_rxq_info
...; struct virtnet_info { @@ -556,6 +559,7 @@ static struct sk_buff *receive_small(struct net_device *dev, xdp.data = xdp.data_hard_start + xdp_headroom; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + len; + xdp.rxq = &rq->xdp_rxq; orig_data = xdp.data; act = bpf_prog_run_xdp(xdp_prog, &xdp); @@ -1229,6 +1233,13 @@ static int virtnet_open(struct net_device *dev) /* Make sure we have some buffers: if oom use wq. */ if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL)) schedule_delayed_work(&vi->refill, 0); + + /* XDP RX queue info */ + xdp_rx...
2019 Feb 08
0
[PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames
...stics on their own, > we should move the responsibility to upper layer. > > Idea: since we already have rxq_info structure per XDP ring (no false > sharing) and available per xdp_buff we can do: > > +++ b/include/linux/filter.h > @@ -651,7 +651,9 @@ static __always_inline u32 bpf_prog_run_xdp(const > struct bpf_prog *prog, > * already takes rcu_read_lock() when fetching the program, so > * it's not necessary here anymore. > */ > - return BPF_PROG_RUN(prog, xdp); > + u32 ret = BPF_PROG_RUN(prog, xdp); > + xdp->xdp_r...
2017 Dec 13
0
[bpf-next V1-RFC PATCH 11/14] virtio_net: setup xdp_rxq_info
...; struct virtnet_info { @@ -556,6 +559,7 @@ static struct sk_buff *receive_small(struct net_device *dev, xdp.data = xdp.data_hard_start + xdp_headroom; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + len; + xdp.rxq = &rq->xdp_rxq; orig_data = xdp.data; act = bpf_prog_run_xdp(xdp_prog, &xdp); @@ -1229,6 +1233,13 @@ static int virtnet_open(struct net_device *dev) /* Make sure we have some buffers: if oom use wq. */ if (!try_fill_recv(vi, &vi->rq[i], GFP_KERNEL)) schedule_delayed_work(&vi->refill, 0); + + /* XDP RX queue info */ + xdp_rx...
2017 Dec 22
1
[bpf-next V2 PATCH 11/14] virtio_net: setup xdp_rxq_info
...; struct virtnet_info { @@ -559,6 +562,7 @@ static struct sk_buff *receive_small(struct net_device *dev, xdp.data = xdp.data_hard_start + xdp_headroom; xdp_set_data_meta_invalid(&xdp); xdp.data_end = xdp.data + len; + xdp.rxq = &rq->xdp_rxq; orig_data = xdp.data; act = bpf_prog_run_xdp(xdp_prog, &xdp); @@ -1225,13 +1229,18 @@ static int virtnet_poll(struct napi_struct *napi, int budget) static int virtnet_open(struct net_device *dev) { struct virtnet_info *vi = netdev_priv(dev); - int i; + int i, err; for (i = 0; i < vi->max_queue_pairs; i++) { if (i < v...
2018 Mar 02
6
[PATCH net V2] virtio-net: re enable XDP_REDIRECT for mergeable buffer
...first several packets, so we don't + * care much about its performance. + */ if (unlikely(num_buf > 1 || headroom < virtnet_get_headroom(vi))) { /* linearize data for XDP */ @@ -736,9 +743,6 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, act = bpf_prog_run_xdp(xdp_prog, &xdp); - if (act != XDP_PASS) - ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len); - switch (act) { case XDP_PASS: /* recalculate offset to account for any header @@ -770,6 +774,18 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, goto err_xdp;...
2018 Mar 02
6
[PATCH net V2] virtio-net: re enable XDP_REDIRECT for mergeable buffer
...first several packets, so we don't + * care much about its performance. + */ if (unlikely(num_buf > 1 || headroom < virtnet_get_headroom(vi))) { /* linearize data for XDP */ @@ -736,9 +743,6 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, act = bpf_prog_run_xdp(xdp_prog, &xdp); - if (act != XDP_PASS) - ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len); - switch (act) { case XDP_PASS: /* recalculate offset to account for any header @@ -770,6 +774,18 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, goto err_xdp;...