RE: [Intel-wired-lan] [PATCH net-next v4 1/2] e1000e: add basic XDP support

From: Loktionov, Aleksandr

Date: Wed Apr 01 2026 - 04:58:36 EST




> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf
> Of Matteo Croce
> Sent: Monday, March 23, 2026 7:28 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@xxxxxxxxx>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@xxxxxxxxx>; Andrew Lunn
> <andrew+netdev@xxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>; Eric
> Dumazet <edumazet@xxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo
> Abeni <pabeni@xxxxxxxxxx>; Alexei Starovoitov <ast@xxxxxxxxxx>; Daniel
> Borkmann <daniel@xxxxxxxxxxxxx>; Jesper Dangaard Brouer
> <hawk@xxxxxxxxxx>; John Fastabend <john.fastabend@xxxxxxxxx>; Mohsin
> Bashir <mohsin.bashr@xxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx; bpf@xxxxxxxxxxxxxxx; intel-wired-
> lan@xxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: [Intel-wired-lan] [PATCH net-next v4 1/2] e1000e: add basic
> XDP support
>
> Add XDP support to the e1000e driver covering the actions defined by
> NETDEV_XDP_ACT_BASIC: XDP_DROP, XDP_PASS, XDP_TX and XDP_ABORTED.
>
> Infrastructure:

...

> +/**
> + * e1000_xdp_setup - add/remove an XDP program
> + * @netdev: network interface device structure
> + * @bpf: XDP program setup structure
> + **/
> +static int e1000_xdp_setup(struct net_device *netdev, struct
> netdev_bpf
> +*bpf) {
> + struct e1000_adapter *adapter = netdev_priv(netdev);
> + struct bpf_prog *prog = bpf->prog, *old_prog;
> + bool running = netif_running(netdev);
> + bool need_reset;
> +
> + /* XDP is incompatible with jumbo frames */
> + if (prog && netdev->mtu > ETH_DATA_LEN) {
> + NL_SET_ERR_MSG_MOD(bpf->extack,
> + "XDP is not supported with jumbo
> frames");
> + return -EINVAL;
> + }
> +
> + /* Validate frame fits in a single page with XDP headroom */
> + if (prog && netdev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN +
> + XDP_PACKET_HEADROOM > PAGE_SIZE) {
> + NL_SET_ERR_MSG_MOD(bpf->extack,
> + "Frame size too large for XDP");
> + return -EINVAL;
> + }
> +
> + old_prog = xchg(&adapter->xdp_prog, prog);
> + need_reset = (!!prog != !!old_prog);
> +
> + /* Transition between XDP and non-XDP requires ring
> reconfiguration */
> + if (need_reset && running)
> + e1000e_close(netdev);
> +
> + if (old_prog)
> + bpf_prog_put(old_prog);
> +
> + if (!need_reset)
> + return 0;
> +
> + if (running) {
> + int err = e1000e_open(netdev);
> +
> + if (err) {
> + /* Remove the XDP program since interface is down
> */
> + xchg(&adapter->xdp_prog, NULL);
> + if (prog)
> + bpf_prog_put(prog);
I'm afraid the reference is owned by the BPF infrastructure, and you will drop refcount to 0.

> + return err;
> + }
> + }
> +
> + return 0;
> +}

...

> kfree(adapter->tx_ring);
> kfree(adapter->rx_ring);
>
> --
> 2.53.0