Netdev List
 help / color / mirror / Atom feed
From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>,
	Jian Shen <shenjian15@huawei.com>,
	Jijie Shao <shaojijie@huawei.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Zhangfei Gao <zhangfei.gao@linaro.org>,
	Dongpo Li <lidongpo@hisilicon.com>
Subject: [PATCH net v2 2/4] net: hix5hd2_gmac: linearize skb if too many frags
Date: Sun,  6 Dec 2026 19:00:30 +0800	[thread overview]
Message-ID: <20261206110034.4094717-3-mmyangfl@gmail.com> (raw)
In-Reply-To: <20261206110034.4094717-1-mmyangfl@gmail.com>

Hardware supports at most SG_MAX_SKB_FRAGS fragments. Ask the core to
linearize it if there are too many fragments.

Fixes: e5222b1c3f21 ("net: hix5hd2_gmac: add tx scatter-gather feature")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index 46386a0954a2..4aa5cb559d38 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -907,12 +907,25 @@ static void hix5hd2_net_timeout(struct net_device *dev, unsigned int txqueue)
 	schedule_work(&priv->tx_timeout_task);
 }
 
+static netdev_features_t
+hix5hd2_net_features_check(struct sk_buff *skb, struct net_device *dev,
+			   netdev_features_t features)
+{
+#if (MAX_SKB_FRAGS > SG_MAX_SKB_FRAGS)
+	if (skb_shinfo(skb)->nr_frags > SG_MAX_SKB_FRAGS)
+		features &= ~NETIF_F_SG;
+#endif
+
+	return features;
+}
+
 static const struct net_device_ops hix5hd2_netdev_ops = {
 	.ndo_open		= hix5hd2_net_open,
 	.ndo_stop		= hix5hd2_net_close,
 	.ndo_start_xmit		= hix5hd2_net_xmit,
 	.ndo_tx_timeout		= hix5hd2_net_timeout,
 	.ndo_set_mac_address	= hix5hd2_net_set_mac_address,
+	.ndo_features_check	= hix5hd2_net_features_check,
 };
 
 static const struct ethtool_ops hix5hd2_ethtools_ops = {
-- 
2.53.0


  parent reply	other threads:[~2026-12-06 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06 11:00 [PATCH net v2 0/4] net: hix5hd2_gmac: fix memory corruption across interface reopen David Yang
2026-12-06 11:00 ` [PATCH net v2 1/4] net: hix5hd2_gmac: unmap input TX buffers, not returned ones David Yang
2026-12-06 11:00 ` David Yang [this message]
2026-12-06 11:00 ` [PATCH net v2 3/4] net: hix5hd2_gmac: release TX SG buffers if using SG David Yang
2026-12-06 11:00 ` [PATCH net v2 4/4] net: hix5hd2_gmac: keep TX/RX queues alive across a close David Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206110034.4094717-3-mmyangfl@gmail.com \
    --to=mmyangfl@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lidongpo@hisilicon.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shaojijie@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=zhangfei.gao@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox