lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Fri, 29 Apr 2022 08:54:53 +0000 From: Bin Chen <bin.chen@...igine.com> To: Jakub Kicinski <kuba@...nel.org>, Simon Horman <simon.horman@...igine.com> CC: David Miller <davem@...emloft.net>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>, oss-drivers <oss-drivers@...igine.com> Subject: RE: [PATCH net-next] nfp: VF rate limit support On Tue, 26 Apr 2022 7:53 AM, Jakub wrote: > 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. > We agree with your suggestion, thanks. We plan to do this in two steps: 1.The firmware that currently support this feature will reject the nonzero min_tx_rate configuration, so the check here will not step in. We will remove the check from driver site and upstream the patch. 2.We will do more investigation jobs and add an appropriate check in the core. What do you think? > > + 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. Accepted. Thank you. > > > + 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; > > + } > Accepted. I will use "%d" instead. > > @@ -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? > Yes, there is a bugļ¼thank you for catching it. I will enhance the check on set as your suggestion. > > + 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? It is not intentional to do, it must be an accident. I will fix it. Thank you. > -----Original Message----- > From: Jakub Kicinski <kuba@...nel.org> > Sent: 2022.4.6 7:53 > To: Simon Horman <simon.horman@...igine.com> > Cc: David Miller <davem@...emloft.net>; netdev@...r.kernel.org; oss- > drivers <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