[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1714442379.4695537-1-hengqi@linux.alibaba.com>
Date: Tue, 30 Apr 2024 09:59:39 +0800
From: Heng Qi <hengqi@...ux.alibaba.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org,
virtualization@...ts.linux.dev,
"David S . Miller" <davem@...emloft.net>,
Paolo Abeni <pabeni@...hat.com>,
Eric Dumazet <edumazet@...gle.com>,
Jason Wang <jasowang@...hat.com>,
"Michael S . Tsirkin" <mst@...hat.com>,
Brett Creeley <bcreeley@....com>,
Ratheesh Kannoth <rkannoth@...vell.com>,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Tal Gilboa <talgi@...dia.com>,
Jonathan Corbet <corbet@....net>,
linux-doc@...r.kernel.org,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Jiri Pirko <jiri@...nulli.us>,
Paul Greenwalt <paul.greenwalt@...el.com>,
Ahmed Zaki <ahmed.zaki@...el.com>,
Vladimir Oltean <vladimir.oltean@....com>,
Kory Maincent <kory.maincent@...tlin.com>,
Andrew Lunn <andrew@...n.ch>,
"justinstitt @ google . com" <justinstitt@...gle.com>
Subject: Re: [PATCH net-next v10 2/4] ethtool: provide customized dim profile management
On Mon, 29 Apr 2024 10:47:41 -0700, Jakub Kicinski <kuba@...nel.org> wrote:
> On Sun, 28 Apr 2024 22:49:09 +0800 Heng Qi wrote:
> > >> + nla_for_each_nested_type(nest, ETHTOOL_A_PROFILE_IRQ_MODERATION, nests, rem) {
> > >> + ret = nla_parse_nested(moder,
> > >> + ARRAY_SIZE(coalesce_irq_moderation_policy) - 1,
> > >> + nest, coalesce_irq_moderation_policy,
> > >> + extack);
> > >> + if (ret)
> > >> + return ret;
> > >> +
> > >> + if (!NL_REQ_ATTR_CHECK(extack, nest, moder, ETHTOOL_A_IRQ_MODERATION_USEC)) {
> > >> + if (irq_moder->coal_flags & DIM_COALESCE_USEC)
> > > There are 3 options here, not 2:
> > >
> > > if (irq_moder->coal_flags & flag) {
> > > if (NL_REQ_ATTR_CHECK())
> > > val = nla_get_u32(...);
> > > else
> > > return -EINVAL;
> > > } else {
> > > if (moder[attr_type)) {
> > > BAD_ATTR()
> > > return -EOPNOTSUPP;
> > > }
> > > }
> >
> > Maybe we missed something.
> >
> > As shown in the commit log, the user is allowed to modify only
> > a certain fields in irq-moderation. It is assumed that the driver
> > supports modification of usec and pkts, but the user may only
> > modify usec and only fill in the usec attr.
> >
> > Therefore, the kernel only gets usec attr here. Of course, the user
> > may have passed in 5 groups of "n, n, n", which means that nothing
> > is modified, and rx_profile and irq_moderation attrs are all empty.
>
> What you describe sounds good, but it's not what the code seems to be
> doing. NL_REQ_ATTR_CHECK() will set an error attribute if the attr is
> not present.
So here we can use:
+ if (moder[ETHTOOL_A_IRQ_MODERATION_USEC]) {
+ if (irq_moder->coal_flags & DIM_COALESCE_USEC)
+ new_profile[i].usec =
+ nla_get_u32(moder[ETHTOOL_A_IRQ_MODERATION_USEC]);
+ else
+ return -EOPNOTSUPP;
+ }
instead of:
+ if (!NL_REQ_ATTR_CHECK(extack, nest, moder, ETHTOOL_A_IRQ_MODERATION_USEC)) {
+ if (irq_moder->coal_flags & DIM_COALESCE_USEC)
+ new_profile[i].usec =
+ nla_get_u32(moder[ETHTOOL_A_IRQ_MODERATION_USEC]);
+ else
+ return -EOPNOTSUPP;
+ }
to avoid missing information set in extack?
Thanks.
Powered by blists - more mailing lists