Thread (181 messages) 181 messages, 6 authors, 2022-01-27

[RFCv2 net-next 022/167] ethtool: convert the prototype of ethtool_get_feature_mask

flat view

From: Jian Shen <shenjian15@huawei.com>
Date: 2021-09-29 15:58:42
Subsystem: networking [ethtool], networking [general], the rest · Maintainers: Andrew Lunn, Jakub Kicinski, "David S. Miller", Eric Dumazet, Paolo Abeni, Linus Torvalds

For the origin type for netdev_features_t would be changed to
be unsigned long * from u64, so changes the prototype of
ethtool_get_feature_mask for adaption.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 net/ethtool/ioctl.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index bf6e8c2f9bf7..661b75dee9fd 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -195,30 +195,35 @@ static void __ethtool_get_strings(struct net_device *dev,
 		ops->get_strings(dev, stringset, data);
 }
 
-static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
+static void ethtool_get_feature_mask(u32 eth_cmd, netdev_features_t *mask)
 {
 	/* feature masks of legacy discrete ethtool ops */
 
 	switch (eth_cmd) {
 	case ETHTOOL_GTXCSUM:
 	case ETHTOOL_STXCSUM:
-		return NETIF_F_CSUM_MASK | NETIF_F_FCOE_CRC |
-		       NETIF_F_SCTP_CRC;
+		*mask = NETIF_F_CSUM_MASK | NETIF_F_FCOE_CRC | NETIF_F_SCTP_CRC;
+		break;
 	case ETHTOOL_GRXCSUM:
 	case ETHTOOL_SRXCSUM:
-		return NETIF_F_RXCSUM;
+		*mask = NETIF_F_RXCSUM;
+		break;
 	case ETHTOOL_GSG:
 	case ETHTOOL_SSG:
-		return NETIF_F_SG | NETIF_F_FRAGLIST;
+		*mask = NETIF_F_SG | NETIF_F_FRAGLIST;
+		break;
 	case ETHTOOL_GTSO:
 	case ETHTOOL_STSO:
-		return NETIF_F_ALL_TSO;
+		*mask = NETIF_F_ALL_TSO;
+		break;
 	case ETHTOOL_GGSO:
 	case ETHTOOL_SGSO:
-		return NETIF_F_GSO;
+		*mask = NETIF_F_GSO;
+		break;
 	case ETHTOOL_GGRO:
 	case ETHTOOL_SGRO:
-		return NETIF_F_GRO;
+		*mask = NETIF_F_GRO;
+		break;
 	default:
 		BUG();
 	}
@@ -227,11 +232,12 @@ static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
 static int ethtool_get_one_feature(struct net_device *dev,
 	char __user *useraddr, u32 ethcmd)
 {
-	netdev_features_t mask = ethtool_get_feature_mask(ethcmd);
-	struct ethtool_value edata = {
-		.cmd = ethcmd,
-		.data = !!(dev->features & mask),
-	};
+	struct ethtool_value edata;
+	netdev_features_t mask;
+
+	ethtool_get_feature_mask(ethcmd, &mask);
+	edata.cmd = ethcmd;
+	edata.data = !!(dev->features & mask);
 
 	if (copy_to_user(useraddr, &edata, sizeof(edata)))
 		return -EFAULT;
@@ -247,7 +253,7 @@ static int ethtool_set_one_feature(struct net_device *dev,
 	if (copy_from_user(&edata, useraddr, sizeof(edata)))
 		return -EFAULT;
 
-	mask = ethtool_get_feature_mask(ethcmd);
+	ethtool_get_feature_mask(ethcmd, &mask);
 	mask &= dev->hw_features;
 	if (!mask)
 		return -EOPNOTSUPP;
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help