net/mlx5: Add controller number to SF and VF phys_port_name
Subsystems (4)
Tariq Toukan
maintainercover net/mlx5: Add controller number to SF and VF phys_port_name
Hi,
This series by Chris adds the controller number to the phys_port_name of SF and VF representors on the non-master PCI link of a BlueField-4 Socket-Direct topology.
Today the controller number is omitted from phys_port_name when it is 0. In a BlueField-4 Socket-Direct topology there are two PCI links under a single eswitch, and they have duplicate function numbers (pf num) and SF/VF numbers. As a result, SFs/VFs on the two links end up with the same phys_port_name, for example pf0sf0 on both, and cannot be told apart.
Patch 1 is a preparation patch. It passes a pfnum parameter through the SF hardware-table allocation and free call chain, and stores it on struct mlx5_sf. This is plumbing only: pfnum is not used for hwc selection yet, and the controller/pfnum validation is unchanged.
Patch 2 gives the non-master PCI link its own controller number, read from the MLX5_PCI_PF_TYPE_QUERY_PF entry of QUERY_ESW_FUNCTIONS as host_number + 1, so that its SFs/VFs display the controller prefix. Since the self PF and a satellite PF share the same controller number, pfnum is used to locate the right hwc table. With this, the SF on the second link is named c4pf0sf0 instead of pf0sf0. A user can create an SF with the device controller number either specified or omitted, and any other controller number is rejected.
Regards,
Tariq
Chris Mi (2):
net/mlx5: SF, Pass pfnum through the SF hardware-table allocation path net/mlx5: Add controller number for SF and ECVF phys_port_name
.../mellanox/mlx5/core/esw/devlink_port.c | 24 ++-- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 117 ++++++++++++++++-- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 22 +++- .../mellanox/mlx5/core/eswitch_offloads.c | 16 ++- .../mellanox/mlx5/core/lag/shared_fdb.c | 58 +++++++++ .../ethernet/mellanox/mlx5/core/sf/devlink.c | 58 +++++++-- .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 49 +++++--- .../net/ethernet/mellanox/mlx5/core/sf/priv.h | 12 +- 8 files changed, 295 insertions(+), 61 deletions(-)
base-commit: 612848d37e68b858e15815175f1c5e609e09d719
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 1/2 net/mlx5: SF, Pass pfnum through the SF hardware-table allocation path
From: Chris Mi <[email protected]>
Add a pfnum parameter to the SF allocation/free call chain and store it on struct mlx5_sf as pf_num, set alongside controller in mlx5_sf_alloc(), so free/dealloc can resolve the same hwc table that was used at allocation time.
This is plumbing only. pfnum isn't used for hwc selection yet, and controller/pfnum validation is unchanged. It prepares the SF hw-table code to distinguish SFs created on the self PF from SFs created on a satellite PF sharing the same controller number, implemented in "net/mlx5: Add controller number for SF and ECVF phys_port_name" later in this series.
--- .../mellanox/mlx5/core/esw/devlink_port.c | 20 ++++++---- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 6 ++- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 14 ++++--- .../mellanox/mlx5/core/eswitch_offloads.c | 9 +++-- .../ethernet/mellanox/mlx5/core/sf/devlink.c | 31 ++++++++++----- .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 39 +++++++++++-------- .../net/ethernet/mellanox/mlx5/core/sf/priv.h | 12 ++++-- 7 files changed, 82 insertions(+), 49 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +12 -8
@@ -148,16 +148,16 @@ static const struct devlink_port_ops mlx5_esw_pf_vf_dl_port_ops = { .port_fn_max_io_eqs_set = mlx5_devlink_port_fn_max_io_eqs_set, }; -static void mlx5_esw_offloads_sf_devlink_port_attrs_set (struct mlx5_eswitch *esw, -struct devlink_port *dl_port, -u32 controller,u32 sfnum) +static void +mlx5_esw_offloads_sf_devlink_port_attrs_set (struct mlx5_eswitch *esw, +struct devlink_port *dl_port, +u32 controller,u32 pfnum, +u32 sfnum) {struct mlx5_core_dev *dev = esw->dev;struct netdev_phys_item_id ppid = {};u32 hpf_ctrl; -u16 pfnum; - pfnum =mlx5_esw_sf_controller_to_pfnum (dev, controller); hpf_ctrl =mlx5_esw_get_hpf_host_number (dev) +1 ;mlx5_esw_get_port_parent_id (dev, &ppid);memcpy (dl_port->attrs.switch_id.id, &ppid.id[0 ], ppid.id_len);
@@ -166,11 +166,15 @@ static void mlx5_esw_offloads_sf_devlink_port_attrs_set(struct mlx5_eswitch *esw controller == hpf_ctrl); } -int mlx5_esw_offloads_sf_devlink_port_init (struct mlx5_eswitch *esw,struct mlx5_vport *vport, +int mlx5_esw_offloads_sf_devlink_port_init (struct mlx5_eswitch *esw, +struct mlx5_vport *vport,struct mlx5_devlink_port *dl_port, -u32 controller,u32 sfnum) +u32 controller,u32 pfnum, +u32 sfnum) { -mlx5_esw_offloads_sf_devlink_port_attrs_set (esw, &dl_port->dl_port, controller, sfnum); +mlx5_esw_offloads_sf_devlink_port_attrs_set (esw, &dl_port->dl_port, + controller, pfnum, + sfnum); vport->dl_port = dl_port;mlx5_devlink_port_init (dl_port, vport);
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +4 -2
@@ -1370,7 +1370,8 @@ static void mlx5_eswitch_unload_pf_vf_vport(struct mlx5_eswitch *esw, u16 vport_int mlx5_eswitch_load_sf_vport (struct mlx5_eswitch *esw,u16 vport_num,enum mlx5_eswitch_vport_event enabled_events, -struct mlx5_devlink_port *dl_port,u32 controller,u32 sfnum) +struct mlx5_devlink_port *dl_port, +u32 controller,u32 pfnum,u32 sfnum) {struct mlx5_vport *vport;int err;
@@ -1379,7 +1380,8 @@ int mlx5_eswitch_load_sf_vport(struct mlx5_eswitch *esw, u16 vport_num,if (IS_ERR (vport))return PTR_ERR (vport); - err =mlx5_esw_offloads_init_sf_rep (esw, vport, dl_port, controller, sfnum); + err =mlx5_esw_offloads_init_sf_rep (esw, vport, dl_port, controller, + pfnum, sfnum);if (err)return err;
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +9 -5
@@ -872,9 +872,10 @@ void mlx5_esw_set_spec_source_port(struct mlx5_eswitch *esw,int mlx5_esw_offloads_init_pf_vf_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport);void mlx5_esw_offloads_cleanup_pf_vf_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport); -int mlx5_esw_offloads_init_sf_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport, +int mlx5_esw_offloads_init_sf_rep (struct mlx5_eswitch *esw, +struct mlx5_vport *vport,struct mlx5_devlink_port *dl_port, -u32 controller,u32 sfnum); +u32 controller,u32 pfnum,u32 sfnum);void mlx5_esw_offloads_cleanup_sf_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport);int mlx5_esw_offloads_load_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport);
@@ -882,7 +883,8 @@ void mlx5_esw_offloads_unload_rep(struct mlx5_eswitch *esw, struct mlx5_vport *vint mlx5_eswitch_load_sf_vport (struct mlx5_eswitch *esw,u16 vport_num,enum mlx5_eswitch_vport_event enabled_events, -struct mlx5_devlink_port *dl_port,u32 controller,u32 sfnum); +struct mlx5_devlink_port *dl_port, +u32 controller,u32 pfnum,u32 sfnum);void mlx5_eswitch_unload_sf_vport (struct mlx5_eswitch *esw,u16 vport_num); int mlx5_eswitch_load_vf_vports(struct mlx5_eswitch *esw, u16 num_vfs,
@@ -894,9 +896,11 @@ int mlx5_esw_offloads_pf_vf_devlink_port_init(struct mlx5_eswitch *esw,void mlx5_esw_offloads_pf_vf_devlink_port_cleanup (struct mlx5_eswitch *esw,struct mlx5_vport *vport); -int mlx5_esw_offloads_sf_devlink_port_init (struct mlx5_eswitch *esw,struct mlx5_vport *vport, +int mlx5_esw_offloads_sf_devlink_port_init (struct mlx5_eswitch *esw, +struct mlx5_vport *vport,struct mlx5_devlink_port *dl_port, -u32 controller,u32 sfnum); +u32 controller,u32 pfnum, +u32 sfnum);void mlx5_esw_offloads_sf_devlink_port_cleanup (struct mlx5_eswitch *esw,struct mlx5_vport *vport);int mlx5_esw_offloads_devlink_port_register (struct mlx5_eswitch *esw,struct mlx5_vport *vport);
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +6 -3
@@ -2915,11 +2915,14 @@ void mlx5_esw_offloads_cleanup_pf_vf_rep(struct mlx5_eswitch *esw, struct mlx5_vmlx5_esw_offloads_pf_vf_devlink_port_cleanup (esw, vport); } -int mlx5_esw_offloads_init_sf_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport, +int mlx5_esw_offloads_init_sf_rep (struct mlx5_eswitch *esw, +struct mlx5_vport *vport,struct mlx5_devlink_port *dl_port, -u32 controller,u32 sfnum) +u32 controller,u32 pfnum,u32 sfnum) { -return mlx5_esw_offloads_sf_devlink_port_init (esw, vport, dl_port, controller, sfnum); +return mlx5_esw_offloads_sf_devlink_port_init (esw, vport, dl_port, + controller, pfnum, + sfnum); }void mlx5_esw_offloads_cleanup_sf_rep (struct mlx5_eswitch *esw,struct mlx5_vport *vport)
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +21 -10
@@ -15,6 +15,7 @@ struct mlx5_sf {struct mlx5_devlink_port dl_port;unsigned int port_index;u32 controller; +u32 pf_num;u16 id;u16 hw_fn_id;u16 hw_state;
@@ -51,7 +52,8 @@ static void mlx5_sf_function_id_erase(struct mlx5_sf_table *table, struct mlx5_sstatic struct mlx5_sf *mlx5_sf_alloc (struct mlx5_sf_table *table,struct mlx5_eswitch *esw, -u32 controller,u32 sfnum,struct netlink_ext_ack *extack) +u32 controller,u32 pfnum,u32 sfnum, +struct netlink_ext_ack *extack) {unsigned int dl_port_index;struct mlx5_sf *sf;
@@ -64,7 +66,8 @@ mlx5_sf_alloc(struct mlx5_sf_table *table, struct mlx5_eswitch *esw,return ERR_PTR (-EINVAL ); } - id_err =mlx5_sf_hw_table_sf_alloc (table->dev, controller, sfnum); + id_err =mlx5_sf_hw_table_sf_alloc (table->dev, controller, pfnum, + sfnum);if (id_err <0 ) { err = id_err; goto id_err;
@@ -76,12 +79,13 @@ mlx5_sf_alloc(struct mlx5_sf_table *table, struct mlx5_eswitch *esw, goto alloc_err; } sf->id = id_err; - hw_fn_id =mlx5_sf_sw_to_hw_id (table->dev, controller, sf->id); + hw_fn_id =mlx5_sf_sw_to_hw_id (table->dev, controller, pfnum, sf->id); dl_port_index =mlx5_esw_vport_to_devlink_port_index (table->dev, hw_fn_id); sf->port_index = dl_port_index; sf->hw_fn_id = hw_fn_id; sf->hw_state =MLX5_VHCA_STATE_ALLOCATED ; sf->controller = controller; + sf->pf_num = pfnum; err =mlx5_sf_function_id_insert (table, sf);if (err)
@@ -92,7 +96,7 @@ mlx5_sf_alloc(struct mlx5_sf_table *table, struct mlx5_eswitch *esw, insert_err:kfree (sf); alloc_err: -mlx5_sf_hw_table_sf_free (table->dev, controller, id_err); +mlx5_sf_hw_table_sf_free (table->dev, controller, pfnum, id_err); id_err:if (err == -EEXIST )NL_SET_ERR_MSG_MOD (extack,"SF already exist. Choose different sfnum" );
@@ -101,7 +105,8 @@ mlx5_sf_alloc(struct mlx5_sf_table *table, struct mlx5_eswitch *esw,static void mlx5_sf_free (struct mlx5_sf_table *table,struct mlx5_sf *sf) { -mlx5_sf_hw_table_sf_free (table->dev, sf->controller, sf->id); +mlx5_sf_hw_table_sf_free (table->dev, sf->controller, sf->pf_num, + sf->id);trace_mlx5_sf_free (table->dev, sf->port_index, sf->controller, sf->hw_fn_id);kfree (sf); }
@@ -241,13 +246,17 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table,struct mlx5_sf *sf;int err; - sf =mlx5_sf_alloc (table, esw, new_attr->controller, new_attr->sfnum, extack); + sf =mlx5_sf_alloc (table, esw, new_attr->controller, new_attr->pfnum, + new_attr->sfnum, extack);if (IS_ERR (sf))return PTR_ERR (sf);mlx5_esw_reps_block (esw); - err =mlx5_eswitch_load_sf_vport (esw, sf->hw_fn_id,MLX5_VPORT_UC_ADDR_CHANGE , - &sf->dl_port, new_attr->controller, new_attr->sfnum); + err =mlx5_eswitch_load_sf_vport (esw, sf->hw_fn_id, +MLX5_VPORT_UC_ADDR_CHANGE , + &sf->dl_port, new_attr->controller, + new_attr->pfnum, + new_attr->sfnum);mlx5_esw_reps_unblock (esw);if (err) goto esw_err;
@@ -347,10 +356,12 @@ static void mlx5_sf_dealloc(struct mlx5_sf_table *table, struct mlx5_sf *sf)* firmware gives confirmation that it is detached by the driver. */ mlx5_cmd_sf_disable_hca (table->dev, sf->hw_fn_id); -mlx5_sf_hw_table_sf_deferred_free (table->dev, sf->controller, sf->id); +mlx5_sf_hw_table_sf_deferred_free (table->dev, sf->controller, + sf->pf_num, sf->id);kfree (sf); }else { -mlx5_sf_hw_table_sf_deferred_free (table->dev, sf->controller, sf->id); +mlx5_sf_hw_table_sf_deferred_free (table->dev, sf->controller, + sf->pf_num, sf->id);kfree (sf); }
drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +22 -17
@@ -37,7 +37,7 @@ struct mlx5_sf_hw_table { };static struct mlx5_sf_hwc_table * -mlx5_sf_controller_to_hwc (struct mlx5_core_dev *dev,u32 controller) +mlx5_sf_controller_to_hwc (struct mlx5_core_dev *dev,u32 controller,u32 pfnum) {struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table;int i;
@@ -50,11 +50,12 @@ mlx5_sf_controller_to_hwc(struct mlx5_core_dev *dev, u32 controller)return &table->hwc[!!controller]; } -u16 mlx5_sf_sw_to_hw_id (struct mlx5_core_dev *dev,u32 controller,u16 sw_id) +u16 mlx5_sf_sw_to_hw_id (struct mlx5_core_dev *dev,u32 controller,u32 pfnum, +u16 sw_id) {struct mlx5_sf_hwc_table *hwc; - hwc =mlx5_sf_controller_to_hwc (dev, controller); + hwc =mlx5_sf_controller_to_hwc (dev, controller, pfnum);return hwc->start_fn_id + sw_id; }
@@ -79,14 +80,14 @@ mlx5_sf_table_fn_to_hwc(struct mlx5_sf_hw_table *table, u16 fn_id)static int mlx5_sf_hw_table_id_alloc (struct mlx5_core_dev *dev,struct mlx5_sf_hw_table *table, -u32 controller, +u32 controller,u32 pfnum,u32 usr_sfnum) {struct mlx5_sf_hwc_table *hwc;int free_idx =-1 ;int i; - hwc =mlx5_sf_controller_to_hwc (dev, controller); + hwc =mlx5_sf_controller_to_hwc (dev, controller, pfnum);if (!hwc->sfs)return -ENOSPC ;
@@ -110,16 +111,17 @@ static int mlx5_sf_hw_table_id_alloc(struct mlx5_core_dev *dev,static void mlx5_sf_hw_table_id_free (struct mlx5_core_dev *dev,struct mlx5_sf_hw_table *table, -u32 controller,int id) +u32 controller,u32 pfnum,int id) {struct mlx5_sf_hwc_table *hwc; - hwc =mlx5_sf_controller_to_hwc (dev, controller); + hwc =mlx5_sf_controller_to_hwc (dev, controller, pfnum); hwc->sfs[id].allocated = false; hwc->sfs[id].pending_delete = false; } -int mlx5_sf_hw_table_sf_alloc (struct mlx5_core_dev *dev,u32 controller,u32 usr_sfnum) +int mlx5_sf_hw_table_sf_alloc (struct mlx5_core_dev *dev,u32 controller, +u32 pfnum,u32 usr_sfnum) {struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table;u16 hw_fn_id;
@@ -130,13 +132,14 @@ int mlx5_sf_hw_table_sf_alloc(struct mlx5_core_dev *dev, u32 controller, u32 usrreturn -EOPNOTSUPP ;mutex_lock (&table->table_lock); - sw_id =mlx5_sf_hw_table_id_alloc (dev, table, controller, usr_sfnum); + sw_id =mlx5_sf_hw_table_id_alloc (dev, table, controller, pfnum, + usr_sfnum);if (sw_id <0 ) { err = sw_id; goto exist_err; } - hw_fn_id =mlx5_sf_sw_to_hw_id (dev, controller, sw_id); + hw_fn_id =mlx5_sf_sw_to_hw_id (dev, controller, pfnum, sw_id); err =mlx5_cmd_alloc_sf (dev, hw_fn_id);if (err) goto err;
@@ -161,21 +164,22 @@ int mlx5_sf_hw_table_sf_alloc(struct mlx5_core_dev *dev, u32 controller, u32 usr vhca_err:mlx5_cmd_dealloc_sf (dev, hw_fn_id); err: -mlx5_sf_hw_table_id_free (dev, table, controller, sw_id); +mlx5_sf_hw_table_id_free (dev, table, controller, pfnum, sw_id); exist_err:mutex_unlock (&table->table_lock);return err; } -void mlx5_sf_hw_table_sf_free (struct mlx5_core_dev *dev,u32 controller,u16 id) +void mlx5_sf_hw_table_sf_free (struct mlx5_core_dev *dev,u32 controller, +u32 pfnum,u16 id) {struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table;u16 hw_fn_id;mutex_lock (&table->table_lock); - hw_fn_id =mlx5_sf_sw_to_hw_id (dev, controller, id); + hw_fn_id =mlx5_sf_sw_to_hw_id (dev, controller, pfnum, id);mlx5_cmd_dealloc_sf (dev, hw_fn_id); -mlx5_sf_hw_table_id_free (dev, table, controller, id); +mlx5_sf_hw_table_id_free (dev, table, controller, pfnum, id);mutex_unlock (&table->table_lock); }
@@ -188,7 +192,8 @@ static void mlx5_sf_hw_table_hwc_sf_free(struct mlx5_core_dev *dev,trace_mlx5_sf_hwc_free (dev, hwc->start_fn_id + idx); } -void mlx5_sf_hw_table_sf_deferred_free (struct mlx5_core_dev *dev,u32 controller,u16 id) +void mlx5_sf_hw_table_sf_deferred_free (struct mlx5_core_dev *dev, +u32 controller,u32 pfnum,u16 id) {struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table;u32 out[MLX5_ST_SZ_DW (query_vhca_state_out)] = {};
@@ -197,8 +202,8 @@ void mlx5_sf_hw_table_sf_deferred_free(struct mlx5_core_dev *dev, u32 controlleru8 state;int err; - hw_fn_id =mlx5_sf_sw_to_hw_id (dev, controller, id); - hwc =mlx5_sf_controller_to_hwc (dev, controller); + hw_fn_id =mlx5_sf_sw_to_hw_id (dev, controller, pfnum, id); + hwc =mlx5_sf_controller_to_hwc (dev, controller, pfnum);mutex_lock (&table->table_lock); err =mlx5_cmd_query_vhca_state (dev, hw_fn_id, out,sizeof (out));if (err)
drivers/net/ethernet/mellanox/mlx5/core/sf/priv.h +8 -4
@@ -12,11 +12,15 @@ int mlx5_cmd_dealloc_sf(struct mlx5_core_dev *dev, u16 function_id);int mlx5_cmd_sf_enable_hca (struct mlx5_core_dev *dev,u16 func_id);int mlx5_cmd_sf_disable_hca (struct mlx5_core_dev *dev,u16 func_id); -u16 mlx5_sf_sw_to_hw_id (struct mlx5_core_dev *dev,u32 controller,u16 sw_id); +u16 mlx5_sf_sw_to_hw_id (struct mlx5_core_dev *dev,u32 controller,u32 pfnum, +u16 sw_id); -int mlx5_sf_hw_table_sf_alloc (struct mlx5_core_dev *dev,u32 controller,u32 usr_sfnum); -void mlx5_sf_hw_table_sf_free (struct mlx5_core_dev *dev,u32 controller,u16 id); -void mlx5_sf_hw_table_sf_deferred_free (struct mlx5_core_dev *dev,u32 controller,u16 id); +int mlx5_sf_hw_table_sf_alloc (struct mlx5_core_dev *dev,u32 controller, +u32 pfnum,u32 usr_sfnum); +void mlx5_sf_hw_table_sf_free (struct mlx5_core_dev *dev,u32 controller, +u32 pfnum,u16 id); +void mlx5_sf_hw_table_sf_deferred_free (struct mlx5_core_dev *dev, +u32 controller,u32 pfnum,u16 id);bool mlx5_sf_hw_table_supported (const struct mlx5_core_dev *dev);#endif
Signature · 1 line
2.44.0
Tariq Toukan
maintainerPATCH 2/2 net/mlx5: Add controller number for SF and ECVF phys_port_name
In reply to Tariq ToukanFrom: Chris Mi <[email protected]>
phys_port_name for the SF/VF representors is derived from the devlink port attributes such as controller number, function number (pf num) and the SF/VF number itself. However, if SF/VF controller number is 0, the controller number is not added to the phys_port_name.
In a BlueField-4 Socket-Direct topology [1], there are two PCI links. Under single eswitch, there are duplicate function number (pf num) and SF/VF number. The result is they share the same phys_port_name [2]. Hence, annotate the non-master PCI link with its own controller number so its SFs/VFs can be uniquely identified. This streamlines the design so that all PCI links which are not on the eswitch PF get their own unique controller number.
Use the MLX5_PCI_PF_TYPE_QUERY_PF entry from QUERY_ESW_FUNCTIONS to read the host_number for each PCI link. Controller number is host_number + 1. The non-master PCI link devices get a non-zero phys_port_cnum so their SFs/VFs display the controller prefix.
Since self PF and satellite PF share the same controller number, use pfnum to locate the right hwc table.
For example, if the device controller number is 4, user can create an SF like this:
$ devlink port add pci/0006:01:00.0 flavour pcisf pfnum 0 sfnum 0
or
$ devlink port add pci/0006:01:00.0 flavour pcisf pfnum 0 sfnum 0 controller 4
But if user specifies other controller number, command fails.
[1]
PCI NET 0002:01:00.0 net-B21c1pf0,net-p0,net-B21pf0sf0 0006:01:00.0 net-B61c1pf1,net-p1,net-B61pf0sf0 0002:01:00.1 net-B21c2pf0 0006:01:00.1 net-B61c2pf1
[2]
Before this enhancement:
$ cat /sys/class/net/B21pf0sf0/phys_port_name pf0sf0 $ cat /sys/class/net/B61pf0sf0/phys_port_name pf0sf0
[3]
After this enhancement:
$ cat /sys/class/net/B21pf0sf0/phys_port_name pf0sf0 $ cat /sys/class/net/B61c4pf0sf0/phys_port_name c4pf0sf0
$ devlink port show
pci/0002:01:00.0/360450: type eth netdev B21pf0sf0 flavour pcisf
controller 0 pfnum 0 sfnum 0 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detachedpci/0006:01:00.0/491520: type eth netdev B61c4pf0sf0 flavour pcisf
controller 4 pfnum 0 sfnum 0 external false splittable false
function:
hw_addr 00:00:00:00:00:00 state inactive opstate detached
--- .../mellanox/mlx5/core/esw/devlink_port.c | 4 +- .../net/ethernet/mellanox/mlx5/core/eswitch.c | 111 ++++++++++++++++-- .../net/ethernet/mellanox/mlx5/core/eswitch.h | 8 +- .../mellanox/mlx5/core/eswitch_offloads.c | 7 +- .../mellanox/mlx5/core/lag/shared_fdb.c | 58 +++++++++ .../ethernet/mellanox/mlx5/core/sf/devlink.c | 31 ++++- .../ethernet/mellanox/mlx5/core/sf/hw_table.c | 10 ++ 7 files changed, 215 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c +3 -1
@@ -83,7 +83,9 @@ static void mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(struct mlx5_eswitch *memcpy (dl_port->attrs.switch_id.id, ppid.id, ppid.id_len); dl_port->attrs.switch_id.id_len = ppid.id_len; -devlink_port_attrs_pci_vf_set (dl_port,0 , pfnum, + controller_num =mlx5_esw_get_self_pf_ctrl_num (esw); + pfnum =mlx5_esw_get_self_pf_pfnum (esw); +devlink_port_attrs_pci_vf_set (dl_port, controller_num, pfnum, vport_num - base_vport, false); }else if (mlx5_esw_is_spf_vport (esw, vport_num)) {int spf_idx =mlx5_esw_spf_vport_to_idx (esw, vport_num);
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +104 -7
143 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +7 -1
@@ -370,6 +370,9 @@ struct mlx5_esw_functions {bool has_spf_sfs;struct mlx5_esw_spf *spfs;int num_spfs; +u32 controller_num; +u32 phys_port_cnum; +u32 self_pf_pfnum; };enum {
@@ -916,7 +919,10 @@ int mlx5_esw_spf_get_host_number(struct mlx5_core_dev *dev, int spf_idx, u16 *host_number);u16 mlx5_esw_get_hpf_host_number (struct mlx5_core_dev *dev);u16 mlx5_esw_get_hpf_pf_num (struct mlx5_core_dev *dev); -u16 mlx5_esw_sf_controller_to_pfnum (struct mlx5_core_dev *dev,u32 controller); +u32 mlx5_esw_get_self_pf_ctrl_num (struct mlx5_eswitch *esw); +u16 mlx5_esw_get_self_pf_pfnum (struct mlx5_eswitch *esw); +bool mlx5_esw_sf_controller_to_pfnum_valid (struct mlx5_core_dev *dev, +u32 controller,u32 pfnum);bool mlx5_esw_has_spf_sfs (struct mlx5_core_dev *dev); int mlx5_esw_vport_vhca_id_map(struct mlx5_eswitch *esw,
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +6 -1
@@ -4141,6 +4141,12 @@ bool mlx5_esw_offloads_controller_valid(const struct mlx5_eswitch *esw, u32 contconst struct mlx5_esw_functions *esw_funcs;int i; +/* User specifies correct non-zero self PF controller number */ + esw_funcs = &esw->esw_funcs; +if (esw_funcs->phys_port_cnum && + controller == esw_funcs->phys_port_cnum) +return true; +/* Local controller is always valid */ if (controller ==0 )return true;
@@ -4152,7 +4158,6 @@ bool mlx5_esw_offloads_controller_valid(const struct mlx5_eswitch *esw, u32 contif (controller ==mlx5_esw_get_hpf_host_number (esw->dev) +1 )return true; - esw_funcs = &esw->esw_funcs;for (i =0 ; i < esw_funcs->num_spfs; i++) {if (controller == esw_funcs->spfs[i].host_number +1 )return true;
drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c +58 -0
82 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +27 -4
@@ -237,6 +237,18 @@ int mlx5_devlink_sf_port_fn_state_set(struct devlink_port *dl_port,return mlx5_sf_state_set (dev, table, sf, state, extack); } +static u32 +mlx5_sf_get_self_controller (struct mlx5_eswitch *esw, +const struct devlink_port_new_attrs *new_attr) +{ +struct mlx5_esw_functions *esw_funcs = &esw->esw_funcs; + +if (!new_attr->controller_valid && esw_funcs->phys_port_cnum) +return esw_funcs->phys_port_cnum; + +return new_attr->controller; +} + static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, const struct devlink_port_new_attrs *new_attr, struct netlink_ext_ack *extack,
@@ -244,9 +256,11 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, {struct mlx5_eswitch *esw = dev->priv.eswitch;struct mlx5_sf *sf; +u32 controller;int err; - sf =mlx5_sf_alloc (table, esw, new_attr->controller, new_attr->pfnum, + controller =mlx5_sf_get_self_controller (esw, new_attr); + sf =mlx5_sf_alloc (table, esw, controller, new_attr->pfnum, new_attr->sfnum, extack);if (IS_ERR (sf))return PTR_ERR (sf);
@@ -254,7 +268,7 @@ static int mlx5_sf_add(struct mlx5_core_dev *dev, struct mlx5_sf_table *table,mlx5_esw_reps_block (esw); err =mlx5_eswitch_load_sf_vport (esw, sf->hw_fn_id,MLX5_VPORT_UC_ADDR_CHANGE , - &sf->dl_port, new_attr->controller, + &sf->dl_port, controller, new_attr->pfnum, new_attr->sfnum);mlx5_esw_reps_unblock (esw);
@@ -274,6 +288,8 @@ static int mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_attrs *new_attr, struct netlink_ext_ack *extack) { + struct mlx5_esw_functions *esw_funcs; +struct mlx5_eswitch *esw;u32 controller;if (new_attr->flavour !=DEVLINK_PORT_FLAVOUR_PCI_SF ) {
@@ -295,9 +311,16 @@ mlx5_sf_new_check_attr(struct mlx5_core_dev *dev, const struct devlink_port_new_NL_SET_ERR_MSG_MOD (extack,"External controller is unsupported" );return -EOPNOTSUPP ; } + esw = dev->priv.eswitch; + esw_funcs = &esw->esw_funcs; +if (new_attr->controller_valid && !new_attr->controller && + esw_funcs->phys_port_cnum) { +NL_SET_ERR_MSG_MOD (extack,"Invalid controller supplied" ); +return -EOPNOTSUPP ; + } controller = new_attr->controller_valid ? new_attr->controller :0 ; -if (new_attr->pfnum != -mlx5_esw_sf_controller_to_pfnum (dev, controller)) { +if (!mlx5_esw_sf_controller_to_pfnum_valid (dev, controller, + new_attr->pfnum)) {NL_SET_ERR_MSG_MOD (extack,"Invalid pfnum supplied" );return -EOPNOTSUPP ; }
drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +10 -0
@@ -40,8 +40,18 @@ static struct mlx5_sf_hwc_table * mlx5_sf_controller_to_hwc(struct mlx5_core_dev *dev, u32 controller, u32 pfnum) { struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table; +struct mlx5_eswitch *esw = dev->priv.eswitch; +struct mlx5_esw_functions *esw_funcs;int i; +/* If shared fdb is destroyed, phys_port_cnum is reset to 0. +* So use controller_num directly which is read from firmware. +*/ + esw_funcs = &esw->esw_funcs; +if (controller == esw_funcs->controller_num && + pfnum ==mlx5_esw_get_self_pf_pfnum (esw)) +return &table->hwc[MLX5_SF_HWC_LOCAL ]; +for (i =MLX5_SF_HWC_FIRST_SPF ; i < table->num_hwc; i++) {if (table->hwc[i].controller == controller)return &table->hwc[i];
Signature · 1 line
2.44.0