mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
net: ethtool: add support for ETHTOOL_GRXRINGS ioctl
This patch adds handling for the ETHTOOL_GRXRINGS ioctl command in the ethtool ioctl dispatcher. It introduces a new helper function ethtool_get_rxrings() that calls the driver's get_rxnfc() callback with appropriate parameters to retrieve the number of RX rings supported by the device. By explicitly handling ETHTOOL_GRXRINGS, userspace queries through ethtool can now obtain RX ring information in a structured manner. In this patch, ethtool_get_rxrings() is a simply copy of ethtool_get_rxnfc(). Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20250917-gxrings-v4-2-dae520e2e1cb@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
3efaede2e1
commit
06fad5a4ae
@@ -1208,6 +1208,44 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static noinline_for_stack int ethtool_get_rxrings(struct net_device *dev,
|
||||
u32 cmd,
|
||||
void __user *useraddr)
|
||||
{
|
||||
struct ethtool_rxnfc info;
|
||||
size_t info_size = sizeof(info);
|
||||
const struct ethtool_ops *ops = dev->ethtool_ops;
|
||||
int ret;
|
||||
void *rule_buf = NULL;
|
||||
|
||||
if (!ops->get_rxnfc)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ret = ethtool_rxnfc_copy_struct(cmd, &info, &info_size, useraddr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (info.cmd == ETHTOOL_GRXCLSRLALL) {
|
||||
if (info.rule_cnt > 0) {
|
||||
if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
|
||||
rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
|
||||
GFP_USER);
|
||||
if (!rule_buf)
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
ret = ops->get_rxnfc(dev, &info, rule_buf);
|
||||
if (ret < 0)
|
||||
goto err_out;
|
||||
|
||||
ret = ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, rule_buf);
|
||||
err_out:
|
||||
kfree(rule_buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
|
||||
u32 cmd, void __user *useraddr)
|
||||
{
|
||||
@@ -3377,6 +3415,8 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
|
||||
rc = ethtool_set_rxfh_fields(dev, ethcmd, useraddr);
|
||||
break;
|
||||
case ETHTOOL_GRXRINGS:
|
||||
rc = ethtool_get_rxrings(dev, ethcmd, useraddr);
|
||||
break;
|
||||
case ETHTOOL_GRXCLSRLCNT:
|
||||
case ETHTOOL_GRXCLSRULE:
|
||||
case ETHTOOL_GRXCLSRLALL:
|
||||
|
||||
Reference in New Issue
Block a user