[Intel-wired-lan] [PATCH iwl-next 10/10] ixgbevf: allow changing MTU when XDP program is attached

Larysa Zaremba
2026-02-23T10:23:12Z

xskxceiver attempts to change MTU after attaching XDP program,
ixgbevf rejects the request leading to test being failed.

Support MTU change operation even when XDP program is already attached,
perform the same frame size check as when attaching a program.

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
.../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 24 +++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 606c6123d7eb..ccefb44c524e 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -4078,6 +4078,18 @@ static int ixgbevf_set_mac(struct net_device *netdev, void *p)
return 0;
}

+static bool ixgbevf_xdp_mtu_ok(const struct ixgbevf_adapter *adapter,
+ const struct bpf_prog *prog, unsigned int mtu)
+{
+ u32 frame_size = mtu + LIBETH_RX_LL_LEN;
+ bool requires_mbuf;
+
+ requires_mbuf = frame_size > IXGBEVF_RX_PAGE_LEN(LIBETH_XDP_HEADROOM) ||
+ adapter->flags & IXGBEVF_FLAG_HSPLIT;
+
+ return prog->aux->xdp_has_frags || !requires_mbuf;
+}
+
/**
* ixgbevf_change_mtu - Change the Maximum Transfer Unit
* @netdev: network interface device structure
@@ -4093,8 +4105,10 @@ static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu)
int ret;

/* prevent MTU being changed to a size unsupported by XDP */
- if (adapter->xdp_prog) {
- dev_warn(&adapter->pdev->dev, "MTU cannot be changed while XDP program is loaded\n");
+ if (adapter->xdp_prog &&
+ !ixgbevf_xdp_mtu_ok(adapter, adapter->xdp_prog, new_mtu)) {
+ netdev_warn(netdev,
+ "MTU value provided cannot be set while current XDP program is attached\n");
return -EPERM;
}

@@ -4257,14 +4271,10 @@ ixgbevf_features_check(struct sk_buff *skb, struct net_device *dev,
static int ixgbevf_xdp_setup(struct net_device *dev, struct bpf_prog *prog,
struct netlink_ext_ack *extack)
{
- u32 frame_size = READ_ONCE(dev->mtu) + LIBETH_RX_LL_LEN;
struct ixgbevf_adapter *adapter = netdev_priv(dev);
struct bpf_prog *old_prog;
- bool requires_mbuf;

- requires_mbuf = frame_size > IXGBEVF_RX_PAGE_LEN(LIBETH_XDP_HEADROOM) ||
- adapter->flags & IXGBEVF_FLAG_HSPLIT;
- if (prog && !prog->aux->xdp_has_frags && requires_mbuf) {
+ if (prog && !ixgbevf_xdp_mtu_ok(adapter, prog, READ_ONCE(dev->mtu))) {
NL_SET_ERR_MSG_MOD(extack,
"Configured MTU or HW limitations require non-linear frames and XDP prog does not support frags");
return -EOPNOTSUPP;
--
2.52.0