On Sun, 28 Apr 2024 22:49:09 +0800 Heng Qi wrote:
> >> +#if IS_ENABLED(CONFIG_DIMLIB)
> >> +  if (dev->irq_moder) {  
> > This may be NULL  
> 
> 
> Do you mean dev may be null or dev->irq_moder may be null?
> The former has been excluded (see const struct ethtool_ops *ops
> 
> = req_info->dev->ethtool_ops;).
> 
> And we are ruling out the latter using 'if (dev->irq_moder)'.
> 
> Or something else?

Hm, I must have misread something here.

> >> +  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.

Reply via email to