mlxsw: Unified bridge conversion - part 2/6
Subsystems (3)
Ido Schimmel
maintainercover mlxsw: Unified bridge conversion - part 2/6
This is the second part of the conversion of mlxsw to the unified bridge model. Part 1 was merged in commit 4336487e30c3 ("Merge branch 'mlxsw-unified-bridge-conversion-part-1'") which includes details about the new model and the motivation behind the conversion.
This patchset does not begin the conversion, but rather prepares the code base for it.
Patchset overview:
Patch #1 removes an unnecessary field from one of the FID families.
Patches #2-#7 make various improvements in the layer 2 multicast code, making it more receptive towards upcoming changes.
Patches #8-#10 prepare the CONFIG_PROFILE command for the unified bridge model. This command will be used to enable the new model in the last patchset.
Patches #11-#13 perform small changes in the FID code, preparing it for upcoming changes.
Amit Cohen (13):
mlxsw: Remove lag_vid_valid indication
mlxsw: spectrum_switchdev: Pass 'struct mlxsw_sp' to
mlxsw_sp_bridge_mdb_mc_enable_sync()
mlxsw: spectrum_switchdev: Do not set 'multicast_enabled' twice
mlxsw: spectrum_switchdev: Simplify mlxsw_sp_port_mc_disabled_set()
mlxsw: spectrum_switchdev: Add error path in
mlxsw_sp_port_mc_disabled_set()
mlxsw: spectrum_switchdev: Convert mlxsw_sp_mc_write_mdb_entry() to
return int
mlxsw: spectrum_switchdev: Handle error in
mlxsw_sp_bridge_mdb_mc_enable_sync()
mlxsw: Add enumerator for 'config_profile.flood_mode'
mlxsw: cmd: Increase 'config_profile.flood_mode' length
mlxsw: pci: Query resources before and after issuing 'CONFIG_PROFILE'
command
mlxsw: spectrum_fid: Save 'fid_offset' as part of FID structure
mlxsw: spectrum_fid: Use 'fid->fid_offset' when setting VNI
mlxsw: spectrum_fid: Implement missing operations for rFID and dummy
FID
drivers/net/ethernet/mellanox/mlxsw/cmd.h | 25 ++- drivers/net/ethernet/mellanox/mlxsw/pci.c | 9 + .../net/ethernet/mellanox/mlxsw/spectrum.c | 4 +- .../net/ethernet/mellanox/mlxsw/spectrum.h | 1 - .../ethernet/mellanox/mlxsw/spectrum_fid.c | 120 ++++++++++---- .../mellanox/mlxsw/spectrum_switchdev.c | 155 ++++++++++++++---- 6 files changed, 240 insertions(+), 74 deletions(-)
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 1/13 mlxsw: Remove lag_vid_valid indication
From: Amit Cohen <[email protected]>
Currently 'struct mlxsw_sp_fid_family' has a field which indicates if 'lag_vid' is valid for use in SFD register.
This is a leftover from using .1Q FIDs instead of emulating them using .1D FIDs.
Currently when .1Q FIDs are emulated using .1D FIDs, this field is true for both families, so there is no reason to maintain it.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 - drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c | 8 -------- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 +-- 3 files changed, 1 insertion(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +0 -1
@@ -1237,7 +1237,6 @@ int mlxsw_sp_setup_tc_block_qevent_mark(struct mlxsw_sp_port *mlxsw_sp_port,/* spectrum_fid.c */ bool mlxsw_sp_fid_is_dummy (struct mlxsw_sp *mlxsw_sp,u16 fid_index); -bool mlxsw_sp_fid_lag_vid_valid (const struct mlxsw_sp_fid *fid);struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index (struct mlxsw_sp *mlxsw_sp,u16 fid_index);int mlxsw_sp_fid_nve_ifindex (const struct mlxsw_sp_fid *fid,int *nve_ifindex);
drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c +0 -8
@@ -102,7 +102,6 @@ struct mlxsw_sp_fid_family {enum mlxsw_sp_rif_type rif_type;const struct mlxsw_sp_fid_ops *ops;struct mlxsw_sp *mlxsw_sp; - u8 lag_vid_valid:1; };static const int mlxsw_sp_sfgc_uc_packet_types[MLXSW_REG_SFGC_TYPE_MAX ] = {
@@ -137,11 +136,6 @@ bool mlxsw_sp_fid_is_dummy(struct mlxsw_sp *mlxsw_sp, u16 fid_index)return fid_family->start_index == fid_index; } -bool mlxsw_sp_fid_lag_vid_valid (const struct mlxsw_sp_fid *fid) -{ -return fid->fid_family->lag_vid_valid; -} -struct mlxsw_sp_fid *mlxsw_sp_fid_lookup_by_index (struct mlxsw_sp *mlxsw_sp,u16 fid_index) {
@@ -699,7 +693,6 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021d_family = { .nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables), .rif_type = MLXSW_SP_RIF_TYPE_FID, .ops = &mlxsw_sp_fid_8021d_ops, - .lag_vid_valid = 1, }; static bool
@@ -748,7 +741,6 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021q_emu_family = { .nr_flood_tables = ARRAY_SIZE(mlxsw_sp_fid_8021d_flood_tables), .rif_type = MLXSW_SP_RIF_TYPE_VLAN, .ops = &mlxsw_sp_fid_8021q_emu_ops, - .lag_vid_valid = 1, };static int mlxsw_sp_fid_rfid_configure (struct mlxsw_sp_fid *fid)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +1 -2
@@ -2730,8 +2730,7 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp, bridge_device = bridge_port->bridge_device; vid = bridge_device->vlan_enabled ? mlxsw_sp_port_vlan->vid :0 ; - lag_vid =mlxsw_sp_fid_lag_vid_valid (mlxsw_sp_port_vlan->fid) ? - mlxsw_sp_port_vlan->vid :0 ; + lag_vid = mlxsw_sp_port_vlan->vid; do_fdb_op: err = mlxsw_sp_port_fdb_uc_lag_op(mlxsw_sp, lag_id, mac, fid, lag_vid,
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 2/13 mlxsw: spectrum_switchdev: Pass 'struct mlxsw_sp' to mlxsw_sp_bridge_mdb_mc_enable_sync()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently the above mentioned function gets 'struct mlxsw_sp_port', while the only use of this structure is to get 'mlxsw_sp_port->mlxsw_sp'.
Instead, pass 'struct mlxsw_sp'.
--- .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +4 -7
@@ -112,7 +112,7 @@ mlxsw_sp_bridge_port_mdb_flush(struct mlxsw_sp_port *mlxsw_sp_port, struct mlxsw_sp_bridge_port *bridge_port);static void -mlxsw_sp_bridge_mdb_mc_enable_sync (struct mlxsw_sp_port *mlxsw_sp_port, +mlxsw_sp_bridge_mdb_mc_enable_sync (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_bridge_device *bridge_device);
@@ -856,8 +856,7 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,if (bridge_device->multicast_enabled != !mc_disabled) { bridge_device->multicast_enabled = !mc_disabled; -mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp_port, - bridge_device); +mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device); }list_for_each_entry (bridge_port, &bridge_device->ports_list, list) {
@@ -1841,11 +1840,9 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port, }static void -mlxsw_sp_bridge_mdb_mc_enable_sync (struct mlxsw_sp_port *mlxsw_sp_port, -struct mlxsw_sp_bridge_device - *bridge_device) +mlxsw_sp_bridge_mdb_mc_enable_sync (struct mlxsw_sp *mlxsw_sp, +struct mlxsw_sp_bridge_device *bridge_device) { -struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;struct mlxsw_sp_mid *mid;bool mc_enabled;
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 3/13 mlxsw: spectrum_switchdev: Do not set 'multicast_enabled' twice
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The function mlxsw_sp_port_mc_disabled_set() sets 'bridge_device->multicast_enabled' twice. Remove the unnecessary setting.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0 -2
@@ -870,8 +870,6 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,return err; } - bridge_device->multicast_enabled = !mc_disabled; -return 0 ; }
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 4/13 mlxsw: spectrum_switchdev: Simplify mlxsw_sp_port_mc_disabled_set()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The above mentioned function is called for each port in bridge when the multicast behavior is changed. Currently, it updates all the relevant MID entries only for the first call, but the update of flooding per port is done only for the port that it was called for it.
To simplify this behavior, it is possible to handle flooding for all the ports in the first call, then, the other calls will do nothing. For that, new functions are required to set flooding for all ports, no 'struct mlxsw_sp_port' is required.
This issue was found while extending this function for unified bridge model, the above mentioned change will ease the extending later.
--- .../mellanox/mlxsw/spectrum_switchdev.c | 73 +++++++++++++++++-- 1 file changed, 66 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +66 -7
@@ -642,6 +642,64 @@ mlxsw_sp_bridge_port_flood_table_set(struct mlxsw_sp_port *mlxsw_sp_port,return err; } +static int +mlxsw_sp_bridge_vlans_flood_set (struct mlxsw_sp_bridge_vlan *bridge_vlan, +enum mlxsw_sp_flood_type packet_type, +bool member) +{ +struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan; +int err; + +list_for_each_entry (mlxsw_sp_port_vlan, &bridge_vlan->port_vlan_list, + bridge_vlan_node) { +u16 local_port = mlxsw_sp_port_vlan->mlxsw_sp_port->local_port; + + err =mlxsw_sp_fid_flood_set (mlxsw_sp_port_vlan->fid, + packet_type, local_port, member); +if (err) + goto err_fid_flood_set; + } + +return 0 ; + +err_fid_flood_set: +list_for_each_entry_continue_reverse (mlxsw_sp_port_vlan, + &bridge_vlan->port_vlan_list, + list) { +u16 local_port = mlxsw_sp_port_vlan->mlxsw_sp_port->local_port; + +mlxsw_sp_fid_flood_set (mlxsw_sp_port_vlan->fid, packet_type, + local_port, !member); + } + +return err; +} + +static int +mlxsw_sp_bridge_ports_flood_table_set (struct mlxsw_sp_bridge_port *bridge_port, +enum mlxsw_sp_flood_type packet_type, +bool member) +{ +struct mlxsw_sp_bridge_vlan *bridge_vlan; +int err; + +list_for_each_entry (bridge_vlan, &bridge_port->vlans_list, list) { + err =mlxsw_sp_bridge_vlans_flood_set (bridge_vlan, packet_type, + member); +if (err) + goto err_bridge_vlans_flood_set; + } + +return 0 ; + +err_bridge_vlans_flood_set: +list_for_each_entry_continue_reverse (bridge_vlan, + &bridge_port->vlans_list, list) +mlxsw_sp_bridge_vlans_flood_set (bridge_vlan, packet_type, + !member); +return err; +} + static int mlxsw_sp_port_bridge_vlan_learning_set(struct mlxsw_sp_port *mlxsw_sp_port, struct mlxsw_sp_bridge_vlan *bridge_vlan,
@@ -854,18 +912,19 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,if (!bridge_device)return 0 ; -if (bridge_device->multicast_enabled != !mc_disabled) { - bridge_device->multicast_enabled = !mc_disabled; -mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device); - } +if (bridge_device->multicast_enabled == !mc_disabled) +return 0 ; + + bridge_device->multicast_enabled = !mc_disabled; +mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device);list_for_each_entry (bridge_port, &bridge_device->ports_list, list) {enum mlxsw_sp_flood_type packet_type =MLXSW_SP_FLOOD_TYPE_MC ;bool member =mlxsw_sp_mc_flood (bridge_port); - err =mlxsw_sp_bridge_port_flood_table_set (mlxsw_sp_port, - bridge_port, - packet_type, member); + err =mlxsw_sp_bridge_ports_flood_table_set (bridge_port, + packet_type, + member);if (err)return err; }
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 5/13 mlxsw: spectrum_switchdev: Add error path in mlxsw_sp_port_mc_disabled_set()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The above mentioned function just returns an error in case that mlxsw_sp_bridge_ports_flood_table_set() fails. That means that the previous configurations are not cleaned.
Fix it by adding error path to clean the configurations in case of error.
--- .../mellanox/mlxsw/spectrum_switchdev.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +15 -2
@@ -900,6 +900,7 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port, struct net_device *orig_dev, bool mc_disabled) { +enum mlxsw_sp_flood_type packet_type =MLXSW_SP_FLOOD_TYPE_MC ;struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;struct mlxsw_sp_bridge_device *bridge_device;struct mlxsw_sp_bridge_port *bridge_port;
@@ -919,17 +920,29 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device);list_for_each_entry (bridge_port, &bridge_device->ports_list, list) { -enum mlxsw_sp_flood_type packet_type =MLXSW_SP_FLOOD_TYPE_MC ;bool member =mlxsw_sp_mc_flood (bridge_port); err =mlxsw_sp_bridge_ports_flood_table_set (bridge_port, packet_type, member);if (err) -return err; + goto err_flood_table_set; }return 0 ; + +err_flood_table_set: +list_for_each_entry_continue_reverse (bridge_port, + &bridge_device->ports_list, list) { +bool member =mlxsw_sp_mc_flood (bridge_port); + +mlxsw_sp_bridge_ports_flood_table_set (bridge_port, packet_type, + !member); + } + + bridge_device->multicast_enabled = mc_disabled; +mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device); +return err; } static int mlxsw_sp_smid_router_port_set(struct mlxsw_sp *mlxsw_sp,
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 6/13 mlxsw: spectrum_switchdev: Convert mlxsw_sp_mc_write_mdb_entry() to return int
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The function returns 'false' upon failure and 'true' upon success. Convert it to the usual scheme of returning integer error codes and align the callers.
--- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +9 -7
@@ -1746,7 +1746,7 @@ mlxsw_sp_mc_get_mrouters_bitmap(unsigned long *flood_bitmap, } } -static bool +static int mlxsw_sp_mc_write_mdb_entry (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_mid *mid,struct mlxsw_sp_bridge_device *bridge_device)
@@ -1759,12 +1759,12 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp, mid_idx =find_first_zero_bit (mlxsw_sp->bridge->mids_bitmap,MLXSW_SP_MID_MAX );if (mid_idx ==MLXSW_SP_MID_MAX ) -return false; +return -ENOBUFS ; num_of_ports =mlxsw_core_max_ports (mlxsw_sp->core); flood_bitmap =bitmap_alloc (num_of_ports,GFP_KERNEL );if (!flood_bitmap) -return false; +return -ENOMEM ;bitmap_copy (flood_bitmap, mid->ports_in_mid, num_of_ports);mlxsw_sp_mc_get_mrouters_bitmap (flood_bitmap, bridge_device, mlxsw_sp);
@@ -1774,16 +1774,16 @@ mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp, bridge_device->mrouter);bitmap_free (flood_bitmap);if (err) -return false; +return err; err =mlxsw_sp_port_mdb_op (mlxsw_sp, mid->addr, mid->fid, mid_idx, true);if (err) -return false; +return err;set_bit (mid_idx, mlxsw_sp->bridge->mids_bitmap); mid->in_hw = true; -return true; +return 0 ; } static int mlxsw_sp_mc_remove_mdb_entry(struct mlxsw_sp *mlxsw_sp,
@@ -1805,6 +1805,7 @@ mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp, u16 fid) {struct mlxsw_sp_mid *mid; +int err; mid =kzalloc (sizeof (*mid),GFP_KERNEL );if (!mid)
@@ -1822,7 +1823,8 @@ mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp,if (!bridge_device->multicast_enabled) goto out; -if (!mlxsw_sp_mc_write_mdb_entry (mlxsw_sp, mid, bridge_device)) + err =mlxsw_sp_mc_write_mdb_entry (mlxsw_sp, mid, bridge_device); +if (err) goto err_write_mdb_entry; out:
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 7/13 mlxsw: spectrum_switchdev: Handle error in mlxsw_sp_bridge_mdb_mc_enable_sync()
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The above mentioned function calls two functions which return values, but it ignores them.
Check if the return value is an error, handle it in such case and return an error back to the caller.
--- .../mellanox/mlxsw/spectrum_switchdev.c | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +31 -12
@@ -111,10 +111,10 @@ static void mlxsw_sp_bridge_port_mdb_flush(struct mlxsw_sp_port *mlxsw_sp_port, struct mlxsw_sp_bridge_port *bridge_port); -static void +static int mlxsw_sp_bridge_mdb_mc_enable_sync (struct mlxsw_sp *mlxsw_sp,struct mlxsw_sp_bridge_device - *bridge_device); + *bridge_device,bool mc_enabled); static void mlxsw_sp_port_mrouter_update_mdb(struct mlxsw_sp_port *mlxsw_sp_port,
@@ -917,7 +917,10 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,return 0 ; bridge_device->multicast_enabled = !mc_disabled; -mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device); + err =mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device, + !mc_disabled); +if (err) + goto err_mc_enable_sync;list_for_each_entry (bridge_port, &bridge_device->ports_list, list) {bool member =mlxsw_sp_mc_flood (bridge_port);
@@ -939,9 +942,10 @@ static int mlxsw_sp_port_mc_disabled_set(struct mlxsw_sp_port *mlxsw_sp_port,mlxsw_sp_bridge_ports_flood_table_set (bridge_port, packet_type, !member); } - +mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device, + mc_disabled); +err_mc_enable_sync: bridge_device->multicast_enabled = mc_disabled; -mlxsw_sp_bridge_mdb_mc_enable_sync (mlxsw_sp, bridge_device);return err; }
@@ -1911,22 +1915,37 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port,return err; } -static void +static int mlxsw_sp_bridge_mdb_mc_enable_sync (struct mlxsw_sp *mlxsw_sp, -struct mlxsw_sp_bridge_device *bridge_device) +struct mlxsw_sp_bridge_device *bridge_device, +bool mc_enabled) {struct mlxsw_sp_mid *mid; -bool mc_enabled; - - mc_enabled = bridge_device->multicast_enabled; +int err;list_for_each_entry (mid, &bridge_device->mids_list, list) {if (mc_enabled) -mlxsw_sp_mc_write_mdb_entry (mlxsw_sp, mid, - bridge_device); + err =mlxsw_sp_mc_write_mdb_entry (mlxsw_sp, mid, + bridge_device);else + err =mlxsw_sp_mc_remove_mdb_entry (mlxsw_sp, mid); + +if (err) + goto err_mdb_entry_update; + } + +return 0 ; + +err_mdb_entry_update: +list_for_each_entry_continue_reverse (mid, &bridge_device->mids_list, + list) { +if (mc_enabled)mlxsw_sp_mc_remove_mdb_entry (mlxsw_sp, mid); +else +mlxsw_sp_mc_write_mdb_entry (mlxsw_sp, mid, + bridge_device); } +return err; } static void
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 8/13 mlxsw: Add enumerator for 'config_profile.flood_mode'
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently magic constant is used for setting 'flood_mode' as part of config profile.
As preparation for unified bridge model, which will require different 'flood_mode', add a dedicated enumerator for this field and use it as part of 'struct mlxsw_config_profile'.
Add the relevant value for unified bridge model.
--- drivers/net/ethernet/mellanox/mlxsw/cmd.h | 21 +++++++++++++------ .../net/ethernet/mellanox/mlxsw/spectrum.c | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/cmd.h +15 -6
@@ -713,14 +713,23 @@ MLXSW_ITEM32(cmd_mbox, config_profile, max_flood_tables, 0x30, 16, 4);*/ MLXSW_ITEM32 (cmd_mbox, config_profile, max_vid_flood_tables,0x30 ,8 ,4 ); +enum mlxsw_cmd_mbox_config_profile_flood_mode { +/* Mixed mode, where: +* max_flood_tables indicates the number of single-entry tables. +* max_vid_flood_tables indicates the number of per-VID tables. +* max_fid_offset_flood_tables indicates the number of FID-offset +* tables. max_fid_flood_tables indicates the number of per-FID tables. +* Reserved when unified bridge model is used. +*/ +MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_MIXED =3 , +/* Controlled flood tables. Reserved when legacy bridge model is +* used. +*/ +MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_CONTROLLED =4 , +}; +/* cmd_mbox_config_profile_flood_mode * Flooding mode to use. -* 0-2 - Backward compatible modes for SwitchX devices. -* 3 - Mixed mode, where: -* max_flood_tables indicates the number of single-entry tables. -* max_vid_flood_tables indicates the number of per-VID tables. -* max_fid_offset_flood_tables indicates the number of FID-offset tables. -* max_fid_flood_tables indicates the number of per-FID tables. */ MLXSW_ITEM32 (cmd_mbox, config_profile, flood_mode,0x30 ,0 ,2 );
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +2 -2
@@ -3376,7 +3376,7 @@ static const struct mlxsw_config_profile mlxsw_sp1_config_profile = { .max_mid = MLXSW_SP_MID_MAX, .used_flood_tables = 1, .used_flood_mode = 1, - .flood_mode = 3, + .flood_mode = MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_MIXED, .max_fid_flood_tables = 3, .fid_flood_table_size = MLXSW_SP_FID_FLOOD_TABLE_SIZE, .used_max_ib_mc = 1,
@@ -3400,7 +3400,7 @@ static const struct mlxsw_config_profile mlxsw_sp2_config_profile = { .max_mid = MLXSW_SP_MID_MAX, .used_flood_tables = 1, .used_flood_mode = 1, - .flood_mode = 3, + .flood_mode = MLXSW_CMD_MBOX_CONFIG_PROFILE_FLOOD_MODE_MIXED, .max_fid_flood_tables = 3, .fid_flood_table_size = MLXSW_SP_FID_FLOOD_TABLE_SIZE, .used_max_ib_mc = 1,
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 9/13 mlxsw: cmd: Increase 'config_profile.flood_mode' length
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently, the length of 'config_profile.flood_mode' is defined as 2 bits, while the correct length is 3 bits.
As preparation for unified bridge model, which will use the whole field length, fix it and increase the field to the correct size.
--- drivers/net/ethernet/mellanox/mlxsw/cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/cmd.h +1 -1
@@ -731,7 +731,7 @@ enum mlxsw_cmd_mbox_config_profile_flood_mode {/* cmd_mbox_config_profile_flood_mode * Flooding mode to use. */ -MLXSW_ITEM32 (cmd_mbox, config_profile, flood_mode,0x30 ,0 ,2 ); +MLXSW_ITEM32 (cmd_mbox, config_profile, flood_mode,0x30 ,0 ,3 );/* cmd_mbox_config_profile_max_fid_offset_flood_tables * Maximum number of FID-offset flooding tables.
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 10/13 mlxsw: pci: Query resources before and after issuing 'CONFIG_PROFILE' command
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
Currently, as part of mlxsw_pci_init(), resources are queried from firmware before issuing the 'CONFIG_PROFILE' command.
There are resources whose size depend on the enablement of the unified bridge model that is performed via 'CONFIG_PROFILE' command. As a preparation for unified bridge model, add an additional query after issuing this command. Both queries are required as KVD sizes are read from firmware and then are configured as part of 'CONFIG_PROFILE' command.
--- drivers/net/ethernet/mellanox/mlxsw/pci.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/pci.c +9 -0
@@ -1551,6 +1551,14 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,if (err) goto err_config_profile; +/* Some resources depend on unified bridge model, which is configured +* as part of config_profile. Query the resources again to get correct +* values. +*/ + err =mlxsw_core_resources_query (mlxsw_core, mbox, res); +if (err) + goto err_requery_resources; + err =mlxsw_pci_aqs_init (mlxsw_pci, mbox);if (err) goto err_aqs_init;
@@ -1568,6 +1576,7 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core, err_request_eq_irq:mlxsw_pci_aqs_fini (mlxsw_pci); err_aqs_init: +err_requery_resources: err_config_profile: err_cqe_v_check: err_query_resources:
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 11/13 mlxsw: spectrum_fid: Save 'fid_offset' as part of FID structure
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
SFMR register contains a 'fid_offset' field which is used when flooding tables of type FID offset are used.
Currently, the driver sets this field to zero, as flooding tables of type FID are used.
Using unified bridge model, the driver will use FID offset flooding tables. As preparation, add 'fid_offset' to 'struct mlxsw_sp_fid'. Then, use this field instead of passing zero to the function that configures SFMR.
Set the new field as part of 'ops->setup()', for that, implement this function for dummy FID and rFID.
--- .../ethernet/mellanox/mlxsw/spectrum_fid.c | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c +23 -6
@@ -27,6 +27,7 @@ struct mlxsw_sp_fid {struct mlxsw_sp_rif *rif;refcount_t ref_count;u16 fid_index; +u16 fid_offset;struct mlxsw_sp_fid_family *fid_family;struct rhash_head ht_node;
@@ -399,6 +400,7 @@ static void mlxsw_sp_fid_8021q_setup(struct mlxsw_sp_fid *fid, const void *arg)u16 vid = *(u16 *) arg;mlxsw_sp_fid_8021q_fid (fid)->vid = vid; + fid->fid_offset =0 ; }static enum mlxsw_reg_sfmr_op mlxsw_sp_sfmr_op (bool valid)
@@ -453,20 +455,23 @@ static void mlxsw_sp_fid_8021d_setup(struct mlxsw_sp_fid *fid, const void *arg)int br_ifindex = *(int *) arg;mlxsw_sp_fid_8021d_fid (fid)->br_ifindex = br_ifindex; + fid->fid_offset =0 ; }static int mlxsw_sp_fid_8021d_configure (struct mlxsw_sp_fid *fid) {struct mlxsw_sp_fid_family *fid_family = fid->fid_family; -return mlxsw_sp_fid_op (fid_family->mlxsw_sp, fid->fid_index,0 , true); +return mlxsw_sp_fid_op (fid_family->mlxsw_sp, fid->fid_index, + fid->fid_offset, true); }static void mlxsw_sp_fid_8021d_deconfigure (struct mlxsw_sp_fid *fid) {if (fid->vni_valid)mlxsw_sp_nve_fid_disable (fid->fid_family->mlxsw_sp, fid); -mlxsw_sp_fid_op (fid->fid_family->mlxsw_sp, fid->fid_index,0 , false); +mlxsw_sp_fid_op (fid->fid_family->mlxsw_sp, fid->fid_index, + fid->fid_offset, false); } static int mlxsw_sp_fid_8021d_index_alloc(struct mlxsw_sp_fid *fid,
@@ -743,6 +748,11 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_8021q_emu_family = { .ops = &mlxsw_sp_fid_8021q_emu_ops, }; +static void mlxsw_sp_fid_rfid_setup (struct mlxsw_sp_fid *fid,const void *arg) +{ + fid->fid_offset =0 ; +} +static int mlxsw_sp_fid_rfid_configure (struct mlxsw_sp_fid *fid) {/* rFIDs are allocated by the device during init */
@@ -808,6 +818,7 @@ mlxsw_sp_fid_rfid_port_vid_unmap(struct mlxsw_sp_fid *fid, }static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_rfid_ops = { + .setup = mlxsw_sp_fid_rfid_setup, .configure = mlxsw_sp_fid_rfid_configure, .deconfigure = mlxsw_sp_fid_rfid_deconfigure, .index_alloc = mlxsw_sp_fid_rfid_index_alloc,
@@ -828,16 +839,22 @@ static const struct mlxsw_sp_fid_family mlxsw_sp_fid_rfid_family = { .ops = &mlxsw_sp_fid_rfid_ops, }; +static void mlxsw_sp_fid_dummy_setup (struct mlxsw_sp_fid *fid,const void *arg) +{ + fid->fid_offset =0 ; +} +static int mlxsw_sp_fid_dummy_configure (struct mlxsw_sp_fid *fid) {struct mlxsw_sp *mlxsw_sp = fid->fid_family->mlxsw_sp; -return mlxsw_sp_fid_op (mlxsw_sp, fid->fid_index,0 , true); +return mlxsw_sp_fid_op (mlxsw_sp, fid->fid_index, fid->fid_offset, true); }static void mlxsw_sp_fid_dummy_deconfigure (struct mlxsw_sp_fid *fid) { -mlxsw_sp_fid_op (fid->fid_family->mlxsw_sp, fid->fid_index,0 , false); +mlxsw_sp_fid_op (fid->fid_family->mlxsw_sp, fid->fid_index, + fid->fid_offset, false); } static int mlxsw_sp_fid_dummy_index_alloc(struct mlxsw_sp_fid *fid,
@@ -855,6 +872,7 @@ static bool mlxsw_sp_fid_dummy_compare(const struct mlxsw_sp_fid *fid, }static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_dummy_ops = { + .setup = mlxsw_sp_fid_dummy_setup, .configure = mlxsw_sp_fid_dummy_configure, .deconfigure = mlxsw_sp_fid_dummy_deconfigure, .index_alloc = mlxsw_sp_fid_dummy_index_alloc,
@@ -919,8 +937,7 @@ static struct mlxsw_sp_fid *mlxsw_sp_fid_get(struct mlxsw_sp *mlxsw_sp, fid->fid_index = fid_index;__set_bit (fid_index - fid_family->start_index, fid_family->fids_bitmap); -if (fid->fid_family->ops->setup) - fid->fid_family->ops->setup (fid, arg); + fid->fid_family->ops->setup (fid, arg); err = fid->fid_family->ops->configure (fid);if (err)
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 12/13 mlxsw: spectrum_fid: Use 'fid->fid_offset' when setting VNI
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
The previous patch added 'fid_offset' field to FID structure. Now, this field can be used when VNI is set using SFMR register. Currently 'fid_offset' is set to zero, instead, use the new field which is now set to zero and in the future will be changed.
--- .../ethernet/mellanox/mlxsw/spectrum_fid.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c +14 -11
@@ -420,13 +420,13 @@ static int mlxsw_sp_fid_op(struct mlxsw_sp *mlxsw_sp, u16 fid_index, }static int mlxsw_sp_fid_vni_op (struct mlxsw_sp *mlxsw_sp,u16 fid_index, -__be32 vni,bool vni_valid,u32 nve_flood_index, -bool nve_flood_index_valid) +u16 fid_offset,__be32 vni,bool vni_valid, +u32 nve_flood_index,bool nve_flood_index_valid) {char sfmr_pl[MLXSW_REG_SFMR_LEN ];mlxsw_reg_sfmr_pack (sfmr_pl,MLXSW_REG_SFMR_OP_CREATE_FID , fid_index, -0 ); + fid_offset);mlxsw_reg_sfmr_vv_set (sfmr_pl, vni_valid);mlxsw_reg_sfmr_vni_set (sfmr_pl,be32_to_cpu (vni));mlxsw_reg_sfmr_vtfp_set (sfmr_pl, nve_flood_index_valid);
@@ -613,8 +613,9 @@ static int mlxsw_sp_fid_8021d_vni_set(struct mlxsw_sp_fid *fid, __be32 vni) {struct mlxsw_sp_fid_family *fid_family = fid->fid_family; -return mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index, vni, - true, fid->nve_flood_index, +return mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index, + fid->fid_offset, vni, true, + fid->nve_flood_index, fid->nve_flood_index_valid); }
@@ -622,8 +623,9 @@ static void mlxsw_sp_fid_8021d_vni_clear(struct mlxsw_sp_fid *fid) {struct mlxsw_sp_fid_family *fid_family = fid->fid_family; -mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index,0 , false, - fid->nve_flood_index, fid->nve_flood_index_valid); +mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index, + fid->fid_offset,0 , false, fid->nve_flood_index, + fid->nve_flood_index_valid); } static int mlxsw_sp_fid_8021d_nve_flood_index_set(struct mlxsw_sp_fid *fid,
@@ -632,16 +634,17 @@ static int mlxsw_sp_fid_8021d_nve_flood_index_set(struct mlxsw_sp_fid *fid,struct mlxsw_sp_fid_family *fid_family = fid->fid_family;return mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index, - fid->vni, fid->vni_valid, nve_flood_index, - true); + fid->fid_offset, fid->vni, fid->vni_valid, + nve_flood_index, true); }static void mlxsw_sp_fid_8021d_nve_flood_index_clear (struct mlxsw_sp_fid *fid) {struct mlxsw_sp_fid_family *fid_family = fid->fid_family; -mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index, fid->vni, - fid->vni_valid,0 , false); +mlxsw_sp_fid_vni_op (fid_family->mlxsw_sp, fid->fid_index, + fid->fid_offset, fid->vni, fid->vni_valid,0 , + false); } static void
Signature · 1 line
2.36.1
Ido Schimmel
maintainerPATCH 13/13 mlxsw: spectrum_fid: Implement missing operations for rFID and dummy FID
In reply to Ido SchimmelFrom: Amit Cohen <[email protected]>
rFID and dummy FID do not support FID->VNI mapping. Currently, these families do not implement the vni_{set, clear}() operations. Instead, there is a check if these functions are implemented.
Similarly, 'SFMR.nve_tunnel_flood_ptr' is not relevant for rFID and dummy FID, therefore, these families do not implement nve_flood_index_{set, clear}().
Align the behavior to other unsupported operations, implement the functions and just return an error or warn. Then, checks like '!ops->vni_set' can be removed.
--- .../ethernet/mellanox/mlxsw/spectrum_fid.c | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c +54 -4
@@ -201,7 +201,7 @@ int mlxsw_sp_fid_nve_flood_index_set(struct mlxsw_sp_fid *fid,const struct mlxsw_sp_fid_ops *ops = fid_family->ops;int err; -if (WARN_ON (!ops->nve_flood_index_set || fid->nve_flood_index_valid)) +if (WARN_ON (fid->nve_flood_index_valid))return -EINVAL ; err = ops->nve_flood_index_set (fid, nve_flood_index);
@@ -219,7 +219,7 @@ void mlxsw_sp_fid_nve_flood_index_clear(struct mlxsw_sp_fid *fid)struct mlxsw_sp_fid_family *fid_family = fid->fid_family;const struct mlxsw_sp_fid_ops *ops = fid_family->ops; -if (WARN_ON (!ops->nve_flood_index_clear || !fid->nve_flood_index_valid)) +if (WARN_ON (!fid->nve_flood_index_valid))return ; fid->nve_flood_index_valid = false;
@@ -239,7 +239,7 @@ int mlxsw_sp_fid_vni_set(struct mlxsw_sp_fid *fid, enum mlxsw_sp_nve_type type,struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp;int err; -if (WARN_ON (!ops->vni_set || fid->vni_valid)) +if (WARN_ON (fid->vni_valid))return -EINVAL ; fid->nve_type = type;
@@ -271,7 +271,7 @@ void mlxsw_sp_fid_vni_clear(struct mlxsw_sp_fid *fid)const struct mlxsw_sp_fid_ops *ops = fid_family->ops;struct mlxsw_sp *mlxsw_sp = fid_family->mlxsw_sp; -if (WARN_ON (!ops->vni_clear || !fid->vni_valid)) +if (WARN_ON (!fid->vni_valid))return ; fid->vni_valid = false;
@@ -820,6 +820,27 @@ mlxsw_sp_fid_rfid_port_vid_unmap(struct mlxsw_sp_fid *fid, mlxsw_sp->fid_core->port_fid_mappings[local_port]--; } +static int mlxsw_sp_fid_rfid_vni_set (struct mlxsw_sp_fid *fid,__be32 vni) +{ +return -EOPNOTSUPP ; +} + +static void mlxsw_sp_fid_rfid_vni_clear (struct mlxsw_sp_fid *fid) +{ +WARN_ON_ONCE (1 ); +} + +static int mlxsw_sp_fid_rfid_nve_flood_index_set (struct mlxsw_sp_fid *fid, +u32 nve_flood_index) +{ +return -EOPNOTSUPP ; +} + +static void mlxsw_sp_fid_rfid_nve_flood_index_clear (struct mlxsw_sp_fid *fid) +{ +WARN_ON_ONCE (1 ); +} +static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_rfid_ops = { .setup = mlxsw_sp_fid_rfid_setup, .configure = mlxsw_sp_fid_rfid_configure,
@@ -828,6 +849,10 @@ static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_rfid_ops = { .compare = mlxsw_sp_fid_rfid_compare, .port_vid_map = mlxsw_sp_fid_rfid_port_vid_map, .port_vid_unmap = mlxsw_sp_fid_rfid_port_vid_unmap, + .vni_set = mlxsw_sp_fid_rfid_vni_set, + .vni_clear = mlxsw_sp_fid_rfid_vni_clear, + .nve_flood_index_set = mlxsw_sp_fid_rfid_nve_flood_index_set, + .nve_flood_index_clear = mlxsw_sp_fid_rfid_nve_flood_index_clear, };#define MLXSW_SP_RFID_BASE (15 * 1024)
@@ -874,12 +899,37 @@ static bool mlxsw_sp_fid_dummy_compare(const struct mlxsw_sp_fid *fid,return true; } +static int mlxsw_sp_fid_dummy_vni_set (struct mlxsw_sp_fid *fid,__be32 vni) +{ +return -EOPNOTSUPP ; +} + +static void mlxsw_sp_fid_dummy_vni_clear (struct mlxsw_sp_fid *fid) +{ +WARN_ON_ONCE (1 ); +} + +static int mlxsw_sp_fid_dummy_nve_flood_index_set (struct mlxsw_sp_fid *fid, +u32 nve_flood_index) +{ +return -EOPNOTSUPP ; +} + +static void mlxsw_sp_fid_dummy_nve_flood_index_clear (struct mlxsw_sp_fid *fid) +{ +WARN_ON_ONCE (1 ); +} +static const struct mlxsw_sp_fid_ops mlxsw_sp_fid_dummy_ops = { .setup = mlxsw_sp_fid_dummy_setup, .configure = mlxsw_sp_fid_dummy_configure, .deconfigure = mlxsw_sp_fid_dummy_deconfigure, .index_alloc = mlxsw_sp_fid_dummy_index_alloc, .compare = mlxsw_sp_fid_dummy_compare, + .vni_set = mlxsw_sp_fid_dummy_vni_set, + .vni_clear = mlxsw_sp_fid_dummy_vni_clear, + .nve_flood_index_set = mlxsw_sp_fid_dummy_nve_flood_index_set, + .nve_flood_index_clear = mlxsw_sp_fid_dummy_nve_flood_index_clear, };static const struct mlxsw_sp_fid_family mlxsw_sp_fid_dummy_family = {
Signature · 1 line
2.36.1
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 9 lines · On Tue, 21 Jun 2022 11:33:32 +0300 you wrote:
This is the second part of the conversion of mlxsw to the unified bridge model. Part 1 was merged in commit
4336487e30c3("Merge branch 'mlxsw-unified-bridge-conversion-part-1'") which includes details about the new model and the motivation behind the conversion.This patchset does not begin the conversion, but rather prepares the code base for it.
[...]
Here is the summary with links:
- [net-next,01/13] mlxsw: Remove lag_vid_valid indication
https://git.kernel.org/netdev/net-next/c/22aae52076cd - [net-next,02/13] mlxsw: spectrum_switchdev: Pass 'struct mlxsw_sp' to mlxsw_sp_bridge_mdb_mc_enable_sync() https://git.kernel.org/netdev/net-next/c/21c795f8494a - [net-next,03/13] mlxsw: spectrum_switchdev: Do not set 'multicast_enabled' twice https://git.kernel.org/netdev/net-next/c/6e66d2e4b3a2 - [net-next,04/13] mlxsw: spectrum_switchdev: Simplify mlxsw_sp_port_mc_disabled_set() https://git.kernel.org/netdev/net-next/c/a6f43b1dad80 - [net-next,05/13] mlxsw: spectrum_switchdev: Add error path in mlxsw_sp_port_mc_disabled_set() https://git.kernel.org/netdev/net-next/c/c96a9919c79e - [net-next,06/13] mlxsw: spectrum_switchdev: Convert mlxsw_sp_mc_write_mdb_entry() to return int https://git.kernel.org/netdev/net-next/c/fd66f5184c28 - [net-next,07/13] mlxsw: spectrum_switchdev: Handle error in mlxsw_sp_bridge_mdb_mc_enable_sync() https://git.kernel.org/netdev/net-next/c/0100f840750c - [net-next,08/13] mlxsw: Add enumerator for 'config_profile.flood_mode' https://git.kernel.org/netdev/net-next/c/70b34c77f127 - [net-next,09/13] mlxsw: cmd: Increase 'config_profile.flood_mode' length https://git.kernel.org/netdev/net-next/c/89df3c6261f2 - [net-next,10/13] mlxsw: pci: Query resources before and after issuing 'CONFIG_PROFILE' command https://git.kernel.org/netdev/net-next/c/6131d9630d98 - [net-next,11/13] mlxsw: spectrum_fid: Save 'fid_offset' as part of FID structure https://git.kernel.org/netdev/net-next/c/736bf371d2d4 - [net-next,12/13] mlxsw: spectrum_fid: Use 'fid->fid_offset' when setting VNI https://git.kernel.org/netdev/net-next/c/784763e59225 - [net-next,13/13] mlxsw: spectrum_fid: Implement missing operations for rFID and dummy FID https://git.kernel.org/netdev/net-next/c/048fcbb71a0e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html