summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2022-05-12 13:03:12 +0200
committerPaolo Abeni <pabeni@redhat.com>2022-05-12 13:03:12 +0200
commitb33177f1d62bea7dd8a7dd6775116958ea71dc6b (patch)
tree65c76bd75ec6eef47ec3437db6aa5c0df3d36f92 /net
parent982c97eede13f3cb98c471c1b8fc5a12686ef85c (diff)
parente0d0e1fdf1ed9dcbca60409af0856fa17f0021cb (diff)
downloadlinux-b33177f1d62bea7dd8a7dd6775116958ea71dc6b.tar.bz2
Merge branch 'nfp-vf-rate-limit-support'
Simon Horman says: ==================== *nfp: VF rate limit support this short series adds VF rate limiting to the NFP driver. The first patch, as suggested by Jakub Kicinski, adds a helper to check that ndo_set_vf_rate() rate parameters are sane. It also provides a place for further parameter checking to live, if needed in future. The second patch adds VF rate limit support to the NFP driver. It addresses several comments made on v1, including removing the parameter check that is now provided by the helper added in the first patch. ==================== Link: https://lore.kernel.org/r/20220511113932.92114-1-simon.horman@corigine.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/core/rtnetlink.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 6aff02df9ba5..bdc891326102 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2306,6 +2306,19 @@ invalid_attr:
return -EINVAL;
}
+static int rtnl_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate,
+ int max_tx_rate)
+{
+ const struct net_device_ops *ops = dev->netdev_ops;
+
+ if (!ops->ndo_set_vf_rate)
+ return -EOPNOTSUPP;
+ if (max_tx_rate && max_tx_rate < min_tx_rate)
+ return -EINVAL;
+
+ return ops->ndo_set_vf_rate(dev, vf, min_tx_rate, max_tx_rate);
+}
+
static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[],
struct netlink_ext_ack *extack)
{
@@ -2443,11 +2456,8 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
if (err < 0)
return err;
- err = -EOPNOTSUPP;
- if (ops->ndo_set_vf_rate)
- err = ops->ndo_set_vf_rate(dev, ivt->vf,
- ivf.min_tx_rate,
- ivt->rate);
+ err = rtnl_set_vf_rate(dev, ivt->vf,
+ ivf.min_tx_rate, ivt->rate);
if (err < 0)
return err;
}
@@ -2457,11 +2467,9 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
if (ivt->vf >= INT_MAX)
return -EINVAL;
- err = -EOPNOTSUPP;
- if (ops->ndo_set_vf_rate)
- err = ops->ndo_set_vf_rate(dev, ivt->vf,
- ivt->min_tx_rate,
- ivt->max_tx_rate);
+
+ err = rtnl_set_vf_rate(dev, ivt->vf,
+ ivt->min_tx_rate, ivt->max_tx_rate);
if (err < 0)
return err;
}