From: Mengyuan Lou <mengyuanlou@net-swift.com>
To: netdev@vger.kernel.org
Cc: jiawenwu@trustnetic.com, duanqiangwen@net-swift.com,
linglingzhang@net-swift.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, jacob.e.keller@intel.com,
przemyslaw.kitszel@intel.com, u.kleine-koenig@baylibre.com,
Mengyuan Lou <mengyuanlou@net-swift.com>
Subject: [PATCH net-next] net: libwx: Add ethtool -L support for VF drivers
Date: Tue, 15 Sep 2026 17:37:14 +0800 [thread overview]
Message-ID: <20260915093714.18815-1-mengyuanlou@net-swift.com> (raw)
Implement get_channels and set_channels ethtool operations for Wangxun
VF net_device instances in libwx.
This allows users to query and dynamically reconfigure the number of RX/TX
channels on VF interfaces via `ethtool -l/ -L`.
Specifically:
- Add wx_get_channels_vf() and wx_set_channels_vf() to report and update
channel limits and combined queue counts.
- Re-evaluate RSS limits in txgbevf_set_num_queues() based on user settings
stored in wx->ring_feature[RING_F_RSS].limit.
- Adjust VF MRQC RSS hash mask logic in wx_setup_vfmrqc_vf() to correctly
match queue configuration thresholds.
Signed-off-by: Mengyuan Lou <mengyuanlou@net-swift.com>
---
.../net/ethernet/wangxun/libwx/wx_ethtool.c | 64 +++++++++++++++++++
.../net/ethernet/wangxun/libwx/wx_vf_lib.c | 2 +-
.../ethernet/wangxun/txgbevf/txgbevf_main.c | 3 +
3 files changed, 68 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
index 940d2e59876c..d24370790941 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
@@ -564,6 +564,68 @@ int wx_set_channels(struct net_device *dev,
}
EXPORT_SYMBOL(wx_set_channels);
+static void wx_get_channels_vf(struct net_device *dev,
+ struct ethtool_channels *ch)
+{
+ struct wx *wx = netdev_priv(dev);
+
+ /* report maximum channels */
+ ch->max_combined = wx->mac.max_rx_queues;
+
+ ch->max_other = 1;
+ ch->other_count = 1;
+
+ /* record current channels */
+ ch->combined_count = wx->num_rx_queues;
+}
+
+static int wx_set_channels_vf(struct net_device *dev,
+ struct ethtool_channels *ch)
+{
+ struct wx *wx = netdev_priv(dev);
+ u16 rss_limit;
+ int ret;
+
+ rss_limit = wx->ring_feature[RING_F_RSS].limit;
+
+ /* verify other_count has not changed */
+ if (ch->other_count != 1)
+ return -EINVAL;
+
+ /* verify the number of channels does not exceed hardware limits */
+ if (ch->combined_count > wx->mac.max_rx_queues)
+ return -EINVAL;
+
+ /* if device is resetting, do nothing */
+ if (test_bit(WX_STATE_RESETTING, wx->state))
+ return -EBUSY;
+
+ wx->ring_feature[RING_F_RSS].limit = ch->combined_count;
+
+ if (netif_running(dev))
+ wxvf_close(dev);
+
+ wx_clear_interrupt_scheme(wx);
+
+ ret = wx_init_interrupt_scheme(wx);
+ if (ret)
+ goto err_out;
+
+ if (netif_running(dev)) {
+ ret = wxvf_open(dev);
+ if (ret)
+ goto err_close;
+ }
+
+ return 0;
+
+err_close:
+ wx_clear_interrupt_scheme(wx);
+err_out:
+ wx->ring_feature[RING_F_RSS].limit = rss_limit;
+ return ret;
+}
+
u32 wx_rss_indir_size(struct net_device *netdev)
{
struct wx *wx = netdev_priv(netdev);
@@ -852,6 +914,8 @@ static const struct ethtool_ops wx_ethtool_ops_vf = {
.set_coalesce = wx_set_coalesce,
.get_ts_info = ethtool_op_get_ts_info,
.get_link_ksettings = wx_get_link_ksettings_vf,
+ .get_channels = wx_get_channels_vf,
+ .set_channels = wx_set_channels_vf,
};
void wx_set_ethtool_ops_vf(struct net_device *netdev)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c
index 7325b475ee10..6fec3ab5e4e4 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_vf_lib.c
@@ -237,7 +237,7 @@ void wx_setup_vfmrqc_vf(struct wx *wx)
vfmrqc |= WX_VXMRQC_RSS_EN;
- if (wx->num_rx_queues > 3)
+ if (wx->num_rx_queues >= 3)
vfmrqc |= WX_VXMRQC_RSS_HASH(2);
else if (wx->num_rx_queues > 1)
vfmrqc |= WX_VXMRQC_RSS_HASH(1);
diff --git a/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c b/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
index 8b16b900820a..6e8659082051 100644
--- a/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
+++ b/drivers/net/ethernet/wangxun/txgbevf/txgbevf_main.c
@@ -72,6 +72,9 @@ static void txgbevf_set_num_queues(struct wx *wx)
queue = min_t(u16, wx->mac.max_rx_queues, wx->mac.max_tx_queues);
rss = min_t(u16, queue, rss);
+ if (wx->ring_feature[RING_F_RSS].limit)
+ rss = min_t(u16, rss, wx->ring_feature[RING_F_RSS].limit);
+
if (wx->vfinfo->vf_api >= wx_mbox_api_13) {
wx->num_rx_queues = rss;
wx->num_tx_queues = rss;
--
2.30.1
next reply other threads:[~2026-09-15 9:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 9:37 Mengyuan Lou [this message]
2026-09-15 19:19 ` [PATCH net-next] net: libwx: Add ethtool -L support for VF drivers Harshitha Ramamurthy
2026-09-17 6:43 ` mengyuanlou
2026-09-19 1:51 ` netdev-bot+sashiko
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=20260915093714.18815-1-mengyuanlou@net-swift.com \
--to=mengyuanlou@net-swift.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=duanqiangwen@net-swift.com \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=jiawenwu@trustnetic.com \
--cc=kuba@kernel.org \
--cc=linglingzhang@net-swift.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=u.kleine-koenig@baylibre.com \
/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