public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, pabeni@redhat.com, davem@davemloft.net,
	edumazet@google.com, leon@kernel.org, saeedm@nvidia.com,
	moshe@nvidia.com, jesse.brandeburg@intel.com,
	anthony.l.nguyen@intel.com, tariqt@nvidia.com, idosch@nvidia.com,
	petrm@nvidia.com, simon.horman@corigine.com,
	ecree.xilinx@gmail.com, habetsm.xilinx@gmail.com,
	michal.wilczynski@intel.com, jacob.e.keller@intel.com
Subject: Re: [patch net-next v2 14/15] devlink: move port_del() to devlink_port_ops
Date: Tue, 30 May 2023 08:58:47 +0200	[thread overview]
Message-ID: <ZHWep0dU9gCGJW0d@nanopsycho> (raw)
In-Reply-To: <20230529184119.414d62f3@kernel.org>

Tue, May 30, 2023 at 03:41:19AM CEST, kuba@kernel.org wrote:
>On Mon, 29 May 2023 10:31:14 +0200 Jiri Pirko wrote:
>> >One could argue logically removing a port is also an operation of 
>> >the parent (i.e. the devlink instance). The fact that the port gets
>> >destroyed in the process is secondary. Ergo maybe we should skip 
>> >this patch?  
>> 
>> Well, the port_del() could differ for different port flavours. The
>> embedding structure of struct devlink_port is also different.
>> 
>> Makes sense to me to skip the flavour switch and have one port_del() for
>> each port.
>
>The asymmetry bothers me. It's hard to comment on what the best

Yeah, I had the same problem with that, but after a lots of thinking,
it is a best I could think of. Please see below for the reasoning.


>approach is given this series shows no benefit of moving port_del().
>Maybe even a loss, as mlx5 now has an ifdef in two places:
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>> index e39fd85ea2f9..63635cc44479 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/devlink.c
>> @@ -320,7 +320,6 @@ static const struct devlink_ops mlx5_devlink_ops = {
>>  #endif
>>  #ifdef CONFIG_MLX5_SF_MANAGER
>>  	.port_new = mlx5_devlink_sf_port_new,
>> -	.port_del = mlx5_devlink_sf_port_del,
>>  #endif
>>  	.flash_update = mlx5_devlink_flash_update,
>>  	.info_get = mlx5_devlink_info_get,
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
>> index 76c5d6e9d47f..f370f67d9e33 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
>> @@ -145,6 +145,9 @@ struct devlink_port *mlx5_esw_offloads_devlink_port(struct mlx5_eswitch *esw, u1
>>  }
>>  
>>  static const struct devlink_port_ops mlx5_esw_dl_sf_port_ops = {
>> +#ifdef CONFIG_MLX5_SF_MANAGER
>> +	.port_del = mlx5_devlink_sf_port_del,
>> +#endif

Btw, this ifdef is going to go away in a follow-up patchset.


>>  	.port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get,
>>  	.port_fn_hw_addr_set = mlx5_devlink_port_fn_hw_addr_set,
>>  	.port_fn_roce_get = mlx5_devlink_port_fn_roce_get,
>
>Is it okay if we deferred the port_del() patch until there's some
>clear benefit?

Well actually, there is a clear benefit even in this patchset:

We have 2 flavours of ports each with different ops in mlx5:
VF:
static const struct devlink_port_ops mlx5_esw_dl_port_ops = {
        .port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get,
        .port_fn_hw_addr_set = mlx5_devlink_port_fn_hw_addr_set,
        .port_fn_roce_get = mlx5_devlink_port_fn_roce_get,
        .port_fn_roce_set = mlx5_devlink_port_fn_roce_set,
        .port_fn_migratable_get = mlx5_devlink_port_fn_migratable_get,
        .port_fn_migratable_set = mlx5_devlink_port_fn_migratable_set,
};

SF:
static const struct devlink_port_ops mlx5_esw_dl_sf_port_ops = {
        .port_del = mlx5_devlink_sf_port_del,
        .port_fn_hw_addr_get = mlx5_devlink_port_fn_hw_addr_get,
        .port_fn_hw_addr_set = mlx5_devlink_port_fn_hw_addr_set,
        .port_fn_roce_get = mlx5_devlink_port_fn_roce_get,
        .port_fn_roce_set = mlx5_devlink_port_fn_roce_set,
        .port_fn_state_get = mlx5_devlink_sf_port_fn_state_get,
        .port_fn_state_set = mlx5_devlink_sf_port_fn_state_set,
};

You can see that the port_del() op is supported only on the SF flavour.
VF does not support it and therefore port_del() is not defined on it.

Without this patch, I would have to have a helper
mlx5_devlink_port_del() that would check if the port is SF and call
mlx5_devlink_sf_port_del() in that case. This patch reduces the
boilerplate.


Btw if you look at the cmd line api, it also aligns:
$ devlink port add pci/0000:08:00.0 flavour pcisf pfnum 0 sfnum 101
pci/0000:08:00.0/32768: type eth netdev eth4 flavour pcisf controller 0 pfnum 0 sfnum 101 splittable false
  function:
    hw_addr 00:00:00:00:00:00 state inactive opstate detached
$ devlink port del pci/0000:08:00.0/32768

You use pci/0000:08:00.0/32768 as a delete handle.

port_del() is basically an object destructor. Would it perhaps help to
rename is to .port_destructor()? That would somehow ease the asymmetry
:) IDK. I would leave the name as it is a and move to port_ops.

  parent reply	other threads:[~2023-05-30  6:58 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 10:28 [patch net-next v2 00/15] devlink: move port ops into separate structure Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 01/15] devlink: introduce port ops placeholder Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 02/15] ice: register devlink port for PF with ops Jiri Pirko
2023-05-26 10:52   ` Wilczynski, Michal
2023-05-26 11:35     ` Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 03/15] mlxsw_core: register devlink port " Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 04/15] nfp: devlink: " Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 05/15] devlink: move port_split/unsplit() ops into devlink_port_ops Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 06/15] mlx4: register devlink port with ops Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 07/15] devlink: move port_type_set() op into devlink_port_ops Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 08/15] sfc: register devlink port with ops Jiri Pirko
2023-05-30  8:02   ` Martin Habets
2023-05-26 10:28 ` [patch net-next v2 09/15] mlx5: register devlink ports " Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 10/15] devlink: move port_fn_hw_addr_get/set() to devlink_port_ops Jiri Pirko
2023-05-30  8:03   ` Martin Habets
2023-05-26 10:28 ` [patch net-next v2 11/15] devlink: move port_fn_roce_get/set() " Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 12/15] devlink: move port_fn_migratable_get/set() " Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 13/15] devlink: move port_fn_state_get/set() " Jiri Pirko
2023-05-26 10:28 ` [patch net-next v2 14/15] devlink: move port_del() " Jiri Pirko
2023-05-27  4:10   ` Jakub Kicinski
2023-05-27  7:42     ` Jiri Pirko
2023-05-29  6:33       ` Jakub Kicinski
2023-05-29  8:31         ` Jiri Pirko
2023-05-30  1:41           ` Jakub Kicinski
2023-05-30  6:33             ` Jiri Pirko
2023-05-30  6:58             ` Jiri Pirko [this message]
2023-05-30 17:34               ` Jakub Kicinski
2023-05-31  6:33                 ` Jiri Pirko
2023-06-01 22:16                   ` Jacob Keller
2023-05-26 10:28 ` [patch net-next v2 15/15] devlink: save devlink_port_ops into a variable in devlink_port_function_validate() Jiri Pirko
2023-05-30 18:00 ` [patch net-next v2 00/15] devlink: move port ops into separate structure patchwork-bot+netdevbpf

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=ZHWep0dU9gCGJW0d@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=habetsm.xilinx@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=michal.wilczynski@intel.com \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=simon.horman@corigine.com \
    --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