All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, jiri@mellanox.com,
	andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com,
	roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
	mlxsw@mellanox.com, Ido Schimmel <idosch@mellanox.com>
Subject: Re: [PATCH net-next 05/15] devlink: Allow setting of packet trap group parameters
Date: Tue, 24 Mar 2020 20:53:14 -0700	[thread overview]
Message-ID: <20200324205314.2d2ba2fd@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200324193250.1322038-6-idosch@idosch.org>

On Tue, 24 Mar 2020 21:32:40 +0200 Ido Schimmel wrote:
> From: Ido Schimmel <idosch@mellanox.com>
> 
> The previous patch allowed device drivers to publish their default
> binding between packet trap policers and packet trap groups. However,
> some users might not be content with this binding and would like to
> change it.
> 
> In case user space passed a packet trap policer identifier when setting
> a packet trap group, invoke the appropriate device driver callback and
> pass the new policer identifier.
> 
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Reviewed-by: Jiri Pirko <jiri@mellanox.com>
> ---
>  include/net/devlink.h |  9 +++++++++
>  net/core/devlink.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/include/net/devlink.h b/include/net/devlink.h
> index 84c28e0f2d90..dea3c3fd9634 100644
> --- a/include/net/devlink.h
> +++ b/include/net/devlink.h
> @@ -847,6 +847,15 @@ struct devlink_ops {
>  	 */
>  	int (*trap_group_init)(struct devlink *devlink,
>  			       const struct devlink_trap_group *group);
> +	/**
> +	 * @trap_group_set: Trap group parameters set function.
> +	 *
> +	 * Note: @policer can be NULL when a policer is being unbound from
> +	 * @group.
> +	 */
> +	int (*trap_group_set)(struct devlink *devlink,
> +			      const struct devlink_trap_group *group,
> +			      const struct devlink_trap_policer *policer);
>  	/**
>  	 * @trap_policer_init: Trap policer initialization function.
>  	 *
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index 4ec7c7578709..e3042e131c1f 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -6039,6 +6039,45 @@ devlink_trap_group_action_set(struct devlink *devlink,
>  	return 0;
>  }
>  
> +static int devlink_trap_group_set(struct devlink *devlink,
> +				  struct devlink_trap_group_item *group_item,
> +				  struct genl_info *info)
> +{
> +	struct devlink_trap_policer_item *policer_item;
> +	struct netlink_ext_ack *extack = info->extack;
> +	const struct devlink_trap_policer *policer;
> +	struct nlattr **attrs = info->attrs;
> +	int err;
> +

Why not:

	if (!attrs[DEVLINK_ATTR_TRAP_POLICER_ID])
		return 0?

> +	if (!devlink->ops->trap_group_set) {
> +		if (attrs[DEVLINK_ATTR_TRAP_POLICER_ID])
> +			return -EOPNOTSUPP;
> +		return 0;
> +	}
> +
> +	policer_item = group_item->policer_item;
> +	if (attrs[DEVLINK_ATTR_TRAP_POLICER_ID]) {
> +		u32 policer_id;
> +
> +		policer_id = nla_get_u32(attrs[DEVLINK_ATTR_TRAP_POLICER_ID]);
> +		policer_item = devlink_trap_policer_item_lookup(devlink,
> +								policer_id);
> +		if (policer_id && !policer_item) {
> +			NL_SET_ERR_MSG_MOD(extack, "Device did not register this trap policer");

nit: is KBUILD_MODNAME still set if devlink can only be built-in now?

> +			return -ENOENT;
> +		}
> +	}
> +	policer = policer_item ? policer_item->policer : NULL;
> +
> +	err = devlink->ops->trap_group_set(devlink, group_item->group, policer);
> +	if (err)
> +		return err;
> +
> +	group_item->policer_item = policer_item;
> +
> +	return 0;
> +}
> +
>  static int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
>  					      struct genl_info *info)
>  {
> @@ -6060,6 +6099,10 @@ static int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
>  	if (err)
>  		return err;
>  
> +	err = devlink_trap_group_set(devlink, group_item, info);
> +	if (err)
> +		return err;

Should this unwind the action changes? Are the changes supposed to be
atomic? :S 

Also could it potentially be a problem if trap is being enabled and
policer applied - if we enable first the CPU may get overloaded and it
may be hard to apply the policer? Making sure the ordering is right
requires some careful checking, so IDK if its worth it..

>  	return 0;
>  }
>  


  reply	other threads:[~2020-03-25  3:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 19:32 [PATCH net-next 00/15] Add packet trap policers support Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 01/15] devlink: " Ido Schimmel
2020-03-25  3:31   ` Jakub Kicinski
2020-03-25  9:41     ` Ido Schimmel
2020-03-25 10:41       ` Jiri Pirko
2020-03-25 16:43       ` Jakub Kicinski
2020-03-25  3:37   ` Jakub Kicinski
2020-03-25  9:46     ` Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 02/15] Documentation: Add description of packet trap policers Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 03/15] netdevsim: Add devlink-trap policer support Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 04/15] devlink: Add packet trap group parameters support Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 05/15] devlink: Allow setting of packet trap group parameters Ido Schimmel
2020-03-25  3:53   ` Jakub Kicinski [this message]
2020-03-25 10:37     ` Ido Schimmel
2020-03-25 16:45       ` Jakub Kicinski
2020-03-24 19:32 ` [PATCH net-next 06/15] netdevsim: Add support for " Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 07/15] selftests: netdevsim: Add test cases for devlink-trap policers Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 08/15] mlxsw: reg: Extend QPCR register Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 09/15] mlxsw: spectrum: Track used packet trap policer IDs Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 10/15] mlxsw: spectrum_trap: Prepare policers for registration with devlink Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 11/15] mlxsw: spectrum_trap: Add devlink-trap policer support Ido Schimmel
2020-03-25  3:33   ` Jakub Kicinski
2020-03-25 10:51     ` Ido Schimmel
2020-03-25 16:45       ` Jakub Kicinski
2020-03-24 19:32 ` [PATCH net-next 12/15] mlxsw: spectrum_trap: Do not initialize dedicated discard policer Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 13/15] mlxsw: spectrum_trap: Switch to use correct packet trap group Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 14/15] mlxsw: spectrum_trap: Add support for setting of packet trap group parameters Ido Schimmel
2020-03-24 19:32 ` [PATCH net-next 15/15] selftests: mlxsw: Add test cases for devlink-trap policers Ido Schimmel

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=20200324205314.2d2ba2fd@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@idosch.org \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=vivien.didelot@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.