mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Carolina Jubran <cjubran@nvidia.com>
To: Jakub Kicinski <kuba@kernel.org>, Tariq Toukan <tariqt@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>, Jiri Pirko <jiri@nvidia.com>,
	Gal Pressman <gal@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kselftest@vger.kernel.org, Moshe Shemesh <moshe@nvidia.com>,
	Mark Bloch <mbloch@nvidia.com>, Cosmin Ratiu <cratiu@nvidia.com>
Subject: Re: [PATCH net-next V10 1/6] devlink: Extend devlink rate API with traffic classes bandwidth management
Date: Sun, 25 May 2025 17:57:28 +0300	[thread overview]
Message-ID: <3dddb35c-d3cb-453d-8e60-70f241abd018@nvidia.com> (raw)
In-Reply-To: <20250520155301.5217dd81@kernel.org>



On 21/05/2025 1:53, Jakub Kicinski wrote:
> A few quick comments here as the test is failing
> 
> On Tue, 20 May 2025 21:38:02 +0300 Tariq Toukan wrote:
>> +      -
>> +        name: rate-tc-bws
>> +        type: nest
>> +        multi-attr: true
>> +        nested-attributes: dl-rate-tc-bws
>> +      -
>> +        name: rate-tc-index
>> +        type: u8
>> +        checks:
>> +          min: 0
>> +          max: rate-tc-index-max
> 
> no need for min: 0 on an unsigned type ?
> 

Will remove them.

>> +      -
>> +        name: rate-tc-bw
>> +        type: u32
>> +        doc: |
>> +             Specifies the bandwidth allocation for the Traffic Class as a
>> +             percentage.
>> +        checks:
>> +          min: 0
>> +          max: 100
> 
> Why in percentage? I don't think any existing param in devlink rate
> or net shapers is in percentage right? Not according to what i can
> grok about the uAPI.
> 

I thought percentage might fit better here because it lets users clearly 
set the bandwidth share for each traffic class. While this isn’t the 
same as tx_weight in devlink-rate, the idea is related since both use 
relative values. If there isn’t a strong reason against it, I’d like to 
keep using percentages here.

>> +static int devlink_nl_rate_tc_bw_parse(struct nlattr *parent_nest, u32 *tc_bw,
>> +				       unsigned long *bitmap, struct netlink_ext_ack *extack)
>> +{
>> +	struct nlattr *tb[DEVLINK_ATTR_MAX + 1];
>> +	u8 tc_index;
>> +
>> +	nla_parse_nested(tb, DEVLINK_ATTR_MAX, parent_nest, devlink_dl_rate_tc_bws_nl_policy,
> 
> Let's error check this, I get that we already validated via the policy
> but what if we do memory allocations during parsing one day, or some
> other failure-prone operation.. better check the return value.
> 

Ack. will do.
> nit: over 80 chars for no good reason, the line overflows anyway.
> Please use checkpatch --max-line-width=80 for core code,
> at the very least.
> 

I noticed the current code already goes over 80 chars, but I’ll update 
it to follow the 80-char limit. Will fix, thanks.

>> +			 extack);
>> +	if (!tb[DEVLINK_ATTR_RATE_TC_INDEX]) {
>> +		NL_SET_ERR_ATTR_MISS(extack, parent_nest, DEVLINK_ATTR_RATE_TC_INDEX);
>> +		return -EINVAL;
>> +	}
>> +
>> +	tc_index = nla_get_u8(tb[DEVLINK_ATTR_RATE_TC_INDEX]);
>> +
>> +	if (!tb[DEVLINK_ATTR_RATE_TC_BW]) {
>> +		NL_SET_ERR_ATTR_MISS(extack, parent_nest, DEVLINK_ATTR_RATE_TC_BW);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (test_and_set_bit(tc_index, bitmap)) {
>> +		NL_SET_ERR_MSG_FMT(extack, "Duplicate traffic class index specified (%u)",
>> +				   tc_index);
>> +		return -EINVAL;
>> +	}
>> +
>> +	tc_bw[tc_index] = nla_get_u32(tb[DEVLINK_ATTR_RATE_TC_BW]);
>> +
>> +	return 0;
>> +}
>> +
>> +static int devlink_nl_rate_tc_bw_set(struct devlink_rate *devlink_rate,
>> +				     struct genl_info *info)
>> +{
>> +	DECLARE_BITMAP(bitmap, DEVLINK_RATE_TCS_MAX) = {};
>> +	struct devlink *devlink = devlink_rate->devlink;
>> +	const struct devlink_ops *ops = devlink->ops;
>> +	int rem, err = -EOPNOTSUPP, i, total = 0;
>> +	u32 tc_bw[DEVLINK_RATE_TCS_MAX] = {};
>> +	struct nlattr *attr;
>> +
>> +	nla_for_each_attr(attr, genlmsg_data(info->genlhdr),
>> +			  genlmsg_len(info->genlhdr), rem) {
> 
>   nla_for_each_attr_type() ?
>   or better still add a _type() version of nlmsg_for_each_attr() ?
> 
Good point, thanks. I’ll add a _type() version for nlmsg_for_each_attr. 
Do you prefer this to be part of this patch or should I send it as a 
separate patch?

>> +		if (nla_type(attr) == DEVLINK_ATTR_RATE_TC_BWS) {
>> +			err = devlink_nl_rate_tc_bw_parse(attr, tc_bw, bitmap, info->extack);
>> +			if (err)
>> +				return err;
>> +		}
>> +	}


  reply	other threads:[~2025-05-25 14:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20 18:38 [PATCH net-next V10 0/6] Support rate management on traffic classes in devlink and mlx5 Tariq Toukan
2025-05-20 18:38 ` [PATCH net-next V10 1/6] devlink: Extend devlink rate API with traffic classes bandwidth management Tariq Toukan
2025-05-20 22:53   ` Jakub Kicinski
2025-05-25 14:57     ` Carolina Jubran [this message]
2025-05-27 23:28       ` Jakub Kicinski
2025-05-20 18:38 ` [PATCH net-next V10 2/6] selftest: netdevsim: Add devlink rate tc-bw test Tariq Toukan
2025-05-20 22:59   ` Jakub Kicinski
2025-05-21  7:05     ` Tariq Toukan
2025-05-21 14:10       ` Jakub Kicinski
2025-05-25 20:31         ` Gal Pressman
2025-05-21 21:05     ` Carolina Jubran
2025-05-21 22:24       ` Jakub Kicinski
2025-05-20 18:38 ` [PATCH net-next V10 3/6] net/mlx5: Add no-op implementation for setting tc-bw on rate objects Tariq Toukan
2025-05-20 18:38 ` [PATCH net-next V10 4/6] net/mlx5: Add support for setting tc-bw on nodes Tariq Toukan
2025-05-20 18:38 ` [PATCH net-next V10 5/6] net/mlx5: Add traffic class scheduling support for vport QoS Tariq Toukan
2025-05-20 18:38 ` [PATCH net-next V10 6/6] net/mlx5: Manage TC arbiter nodes and implement full support for tc-bw Tariq Toukan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3dddb35c-d3cb-453d-8e60-70f241abd018@nvidia.com \
    --to=cjubran@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=cratiu@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®