Skip to content

Commit 2a644c5

Browse files
committed
net: ethtool: remove the duplicated handling from rxfh and rxnfc
Now that the handles have been separated - remove the RX Flow Hash handling from rxnfc functions and vice versa. Reviewed-by: Joe Damato <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f4f1265 commit 2a644c5

File tree

1 file changed

+5
-52
lines changed

1 file changed

+5
-52
lines changed

net/ethtool/ioctl.c

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,19 +1075,7 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
10751075
if (rc)
10761076
return rc;
10771077

1078-
if (cmd == ETHTOOL_SRXCLSRLINS && info.fs.flow_type & FLOW_RSS) {
1079-
/* Nonzero ring with RSS only makes sense
1080-
* if NIC adds them together
1081-
*/
1082-
if (!ops->cap_rss_rxnfc_adds &&
1083-
ethtool_get_flow_spec_ring(info.fs.ring_cookie))
1084-
return -EINVAL;
1085-
1086-
if (!xa_load(&dev->ethtool->rss_ctx, info.rss_context))
1087-
return -EINVAL;
1088-
}
1089-
1090-
if (cmd == ETHTOOL_SRXFH && ops->get_rxfh) {
1078+
if (ops->get_rxfh) {
10911079
struct ethtool_rxfh_param rxfh = {};
10921080

10931081
rc = ops->get_rxfh(dev, &rxfh);
@@ -1099,15 +1087,7 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
10991087
return rc;
11001088
}
11011089

1102-
rc = ops->set_rxnfc(dev, &info);
1103-
if (rc)
1104-
return rc;
1105-
1106-
if (cmd == ETHTOOL_SRXCLSRLINS &&
1107-
ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL))
1108-
return -EFAULT;
1109-
1110-
return 0;
1090+
return ops->set_rxnfc(dev, &info);
11111091
}
11121092

11131093
static noinline_for_stack int
@@ -1117,7 +1097,6 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
11171097
size_t info_size = sizeof(info);
11181098
const struct ethtool_ops *ops = dev->ethtool_ops;
11191099
int ret;
1120-
void *rule_buf = NULL;
11211100

11221101
if (!ops->get_rxnfc)
11231102
return -EOPNOTSUPP;
@@ -1126,25 +1105,11 @@ ethtool_get_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
11261105
if (ret)
11271106
return ret;
11281107

1129-
if (info.cmd == ETHTOOL_GRXCLSRLALL) {
1130-
if (info.rule_cnt > 0) {
1131-
if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
1132-
rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
1133-
GFP_USER);
1134-
if (!rule_buf)
1135-
return -ENOMEM;
1136-
}
1137-
}
1138-
1139-
ret = ops->get_rxnfc(dev, &info, rule_buf);
1108+
ret = ops->get_rxnfc(dev, &info, NULL);
11401109
if (ret < 0)
1141-
goto err_out;
1142-
1143-
ret = ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, rule_buf);
1144-
err_out:
1145-
kfree(rule_buf);
1110+
return ret;
11461111

1147-
return ret;
1112+
return ethtool_rxnfc_copy_to_user(useraddr, &info, info_size, NULL);
11481113
}
11491114

11501115
static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
@@ -1175,18 +1140,6 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
11751140
return -EINVAL;
11761141
}
11771142

1178-
if (cmd == ETHTOOL_SRXFH && ops->get_rxfh) {
1179-
struct ethtool_rxfh_param rxfh = {};
1180-
1181-
rc = ops->get_rxfh(dev, &rxfh);
1182-
if (rc)
1183-
return rc;
1184-
1185-
rc = ethtool_check_xfrm_rxfh(rxfh.input_xfrm, info.data);
1186-
if (rc)
1187-
return rc;
1188-
}
1189-
11901143
rc = ops->set_rxnfc(dev, &info);
11911144
if (rc)
11921145
return rc;

0 commit comments

Comments
 (0)