Commit a218a319 authored by Joshua Washington's avatar Joshua Washington Committed by Wentao Guan
Browse files

gve: set xdp redirect target only when it is available

stable inclusion
from stable-v6.6.81
commit 9921e266029cfeb34e7ee7e1bf7311b58754375b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBYZED

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9921e266029cfeb34e7ee7e1bf7311b58754375b



--------------------------------

commit 415cadd505464d9a11ff5e0f6e0329c127849da5 upstream.

Before this patch the NETDEV_XDP_ACT_NDO_XMIT XDP feature flag is set by
default as part of driver initialization, and is never cleared. However,
this flag differs from others in that it is used as an indicator for
whether the driver is ready to perform the ndo_xdp_xmit operation as
part of an XDP_REDIRECT. Kernel helpers
xdp_features_(set|clear)_redirect_target exist to convey this meaning.

This patch ensures that the netdev is only reported as a redirect target
when XDP queues exist to forward traffic.

Fixes: 39a7f4aa ("gve: Add XDP REDIRECT support for GQI-QPL format")
Cc: stable@vger.kernel.org
Reviewed-by: default avatarPraveen Kaligineedi <pkaligineedi@google.com>
Reviewed-by: default avatarJeroen de Borst <jeroendb@google.com>
Signed-off-by: default avatarJoshua Washington <joshwash@google.com>
Link: https://patch.msgid.link/20250214224417.1237818-1-joshwash@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarJoshua Washington <joshwash@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 9921e266029cfeb34e7ee7e1bf7311b58754375b)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent 9e7bc3fc
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1030,6 +1030,16 @@ static inline u32 gve_xdp_tx_start_queue_id(struct gve_priv *priv)
	return gve_xdp_tx_queue_id(priv, 0);
}

static inline bool gve_supports_xdp_xmit(struct gve_priv *priv)
{
	switch (priv->queue_format) {
	case GVE_GQI_QPL_FORMAT:
		return true;
	default:
		return false;
	}
}

/* buffers */
int gve_alloc_page(struct gve_priv *priv, struct device *dev,
		   struct page **page, dma_addr_t *dma,
+5 −1
Original line number Diff line number Diff line
@@ -1753,6 +1753,8 @@ static void gve_turndown(struct gve_priv *priv)
	/* Stop tx queues */
	netif_tx_disable(priv->dev);

	xdp_features_clear_redirect_target(priv->dev);

	gve_clear_napi_enabled(priv);
	gve_clear_report_stats(priv);

@@ -1793,6 +1795,9 @@ static void gve_turnup(struct gve_priv *priv)
		}
	}

	if (priv->num_xdp_queues && gve_supports_xdp_xmit(priv))
		xdp_features_set_redirect_target(priv->dev, false);

	gve_set_napi_enabled(priv);
}

@@ -2014,7 +2019,6 @@ static void gve_set_netdev_xdp_features(struct gve_priv *priv)
	if (priv->queue_format == GVE_GQI_QPL_FORMAT) {
		xdp_features = NETDEV_XDP_ACT_BASIC;
		xdp_features |= NETDEV_XDP_ACT_REDIRECT;
		xdp_features |= NETDEV_XDP_ACT_NDO_XMIT;
		xdp_features |= NETDEV_XDP_ACT_XSK_ZEROCOPY;
	} else {
		xdp_features = 0;