[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220425165321.1856ebb7@kernel.org>
Date: Mon, 25 Apr 2022 16:53:21 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Simon Horman <simon.horman@...igine.com>
Cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
oss-drivers@...igine.com, Bin Chen <bin.chen@...igine.com>
Subject: Re: [PATCH net-next] nfp: VF rate limit support
On Fri, 22 Apr 2022 15:19:45 +0200 Simon Horman wrote:
> + if (max_tx_rate > 0 || min_tx_rate > 0) {
> + if (max_tx_rate > 0 && max_tx_rate < min_tx_rate) {
> + nfp_warn(app->cpp, "min-tx-rate exceeds max_tx_rate.\n");
> + return -EINVAL;
> + }
This check should be moved to the core, I reckon.
> + if (max_tx_rate > NFP_NET_VF_RATE_MAX || min_tx_rate > NFP_NET_VF_RATE_MAX) {
Please wrap the lines at 80 chars, it's actually going to be easier
to read here.
> + nfp_warn(app->cpp, "tx-rate exceeds 0x%x.\n", NFP_NET_VF_RATE_MAX);
Does it really make sense to print the rate as hex?
> + return -EINVAL;
> + }
> @@ -261,5 +294,18 @@ int nfp_app_get_vf_config(struct net_device *netdev, int vf,
> ivi->trusted = FIELD_GET(NFP_NET_VF_CFG_CTRL_TRUST, flags);
> ivi->linkstate = FIELD_GET(NFP_NET_VF_CFG_CTRL_LINK_STATE, flags);
>
> + err = nfp_net_sriov_check(app, vf, NFP_NET_VF_CFG_MB_CAP_RATE, "rate");
> + if (!err) {
> + rate = readl(app->pf->vfcfg_tbl2 + vf_offset + NFP_NET_VF_CFG_RATE);
> +
> + ivi->max_tx_rate = FIELD_GET(NFP_NET_VF_CFG_MAX_RATE, rate);
> + ivi->min_tx_rate = FIELD_GET(NFP_NET_VF_CFG_MIN_RATE, rate);
> +
> + if (ivi->max_tx_rate == NFP_NET_VF_RATE_MAX)
> + ivi->max_tx_rate = 0;
If rate == NFP_NET_VF_RATE_MAX means unset then the check on set should
disallow it, IOW:
if (max_tx_rate >= NFP_NET_VF_RATE_MAX ||
min_tx_rate >= NFP_NET_VF_RATE_MAX) {
nfp_war(...
no?
> + if (ivi->min_tx_rate == NFP_NET_VF_RATE_MAX)
> + ivi->max_tx_rate = 0;
*squint* you check min and clear max, is this intentional?
Powered by blists - more mailing lists