Skip to content

Commit c051857

Browse files
committed
Merge branch 'mlxsw-lag-table-allocation'
Petr Machata says: ==================== mlxsw: Move allocation of LAG table to the driver PGT is an in-HW table that maps addresses to sets of ports. Then when some HW process needs a set of ports as an argument, instead of embedding the actual set in the dynamic configuration, what gets configured is the address referencing the set. The HW then works with the appropriate PGT entry. Within the PGT is placed a LAG table. That is a contiguous block of PGT memory where each entry describes which ports are members of the corresponding LAG port. The PGT is split to two parts: one managed by the FW, and one managed by the driver. Historically, the FW part included also the LAG table, referred to as FW LAG mode. Giving the responsibility for placement of the LAG table to the driver, referred to as SW LAG mode, makes the whole system more flexible. The FW currently supports both FW and SW LAG modes. To shed complexity, the FW should in the future only support SW LAG mode. Hence this patchset, where support for placement of LAG is added to mlxsw. There are FW versions out there that do not support SW LAG mode, and on Spectrum-1 in particular, there is no plan to support it at all. mlxsw will therefore have to support both modes of operation. Another aspect is that at least on Spectrum-1, there are FW versions out there that claim to support driver-placed LAG table, but then reject or ignore configurations enabling the same. The driver thus has to have a say in whether an attempt to configure SW LAG mode should even be done. The feature is therefore expressed in terms of "does the driver prefer SW LAG mode?", and "what LAG mode the PCI module managed to configure the FW with". This is unlike current flood mode configuration, where the driver can give a strict value, and that's what gets configured. But it gives a chance to the driver to determine whether LAG mode should be enabled at all. The "does the driver prefer SW LAG mode?" bit is expressed as a boolean lag_mode_prefer_sw. The reason for this is largely another feature that will be introduced in a follow-up patchset: support for CFF flood mode. The driver currently requires that the FW be configured with what is called controlled flood mode. But on capable systems, CFF would be preferred. So there are two values in flight: the preferred flood mode, and the fallback. This could be expressed with an array of flood modes ordered by preference, but that looks like an overkill in comparison. This flag/value model is then reused for LAG mode as well, except the fallback value is absent and implied to be FW, because there are no other values to choose from. The patchset progresses as follows: - Patches #1 to #5 adjust reg.h and cmd.h with new register fields, constants and remarks. - Patches #6 and #7 add the ability to request SW LAG mode and to query the LAG mode that was actually negotiated. This is where the abovementioned lag_mode_prefer_sw flag is added. - Patches #7 to #9 generalize PGT allocations to make it possible to allocate the LAG table, which is done in patch #10. - In patch #11, toggle lag_mode_prefer_sw on Spectrum-2 and above, which makes the newly-added code live. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents fd533a7 + b46c1f3 commit c051857

File tree

9 files changed

+202
-81
lines changed

9 files changed

+202
-81
lines changed

drivers/net/ethernet/mellanox/mlxsw/cmd.h

+35-8
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ MLXSW_ITEM32(cmd_mbox, query_fw, fw_month, 0x14, 8, 8);
276276
*/
277277
MLXSW_ITEM32(cmd_mbox, query_fw, fw_day, 0x14, 0, 8);
278278

279+
/* cmd_mbox_query_fw_lag_mode_support
280+
* 0: CONFIG_PROFILE.lag_mode is not supported by FW
281+
* 1: CONFIG_PROFILE.lag_mode is supported by FW
282+
*/
283+
MLXSW_ITEM32(cmd_mbox, query_fw, lag_mode_support, 0x18, 1, 1);
284+
279285
/* cmd_mbox_query_fw_clr_int_base_offset
280286
* Clear Interrupt register's offset from clr_int_bar register
281287
* in PCI address space.
@@ -659,42 +665,48 @@ MLXSW_ITEM32(cmd_mbox, config_profile,
659665
*/
660666
MLXSW_ITEM32(cmd_mbox, config_profile, set_ar_sec, 0x0C, 15, 1);
661667

662-
/* cmd_mbox_config_set_ubridge
668+
/* cmd_mbox_config_profile_set_ubridge
663669
* Capability bit. Setting a bit to 1 configures the profile
664670
* according to the mailbox contents.
665671
*/
666672
MLXSW_ITEM32(cmd_mbox, config_profile, set_ubridge, 0x0C, 22, 1);
667673

668-
/* cmd_mbox_config_set_kvd_linear_size
674+
/* cmd_mbox_config_profile_set_kvd_linear_size
669675
* Capability bit. Setting a bit to 1 configures the profile
670676
* according to the mailbox contents.
671677
*/
672678
MLXSW_ITEM32(cmd_mbox, config_profile, set_kvd_linear_size, 0x0C, 24, 1);
673679

674-
/* cmd_mbox_config_set_kvd_hash_single_size
680+
/* cmd_mbox_config_profile_set_kvd_hash_single_size
675681
* Capability bit. Setting a bit to 1 configures the profile
676682
* according to the mailbox contents.
677683
*/
678684
MLXSW_ITEM32(cmd_mbox, config_profile, set_kvd_hash_single_size, 0x0C, 25, 1);
679685

680-
/* cmd_mbox_config_set_kvd_hash_double_size
686+
/* cmd_mbox_config_profile_set_kvd_hash_double_size
681687
* Capability bit. Setting a bit to 1 configures the profile
682688
* according to the mailbox contents.
683689
*/
684690
MLXSW_ITEM32(cmd_mbox, config_profile, set_kvd_hash_double_size, 0x0C, 26, 1);
685691

686-
/* cmd_mbox_config_set_cqe_version
692+
/* cmd_mbox_config_profile_set_cqe_version
687693
* Capability bit. Setting a bit to 1 configures the profile
688694
* according to the mailbox contents.
689695
*/
690696
MLXSW_ITEM32(cmd_mbox, config_profile, set_cqe_version, 0x08, 0, 1);
691697

692-
/* cmd_mbox_config_set_cqe_time_stamp_type
698+
/* cmd_mbox_config_profile_set_cqe_time_stamp_type
693699
* Capability bit. Setting a bit to 1 configures the profile
694700
* according to the mailbox contents.
695701
*/
696702
MLXSW_ITEM32(cmd_mbox, config_profile, set_cqe_time_stamp_type, 0x08, 2, 1);
697703

704+
/* cmd_mbox_config_profile_set_lag_mode
705+
* Capability bit. Setting a bit to 1 configures the lag_mode
706+
* according to the mailbox contents.
707+
*/
708+
MLXSW_ITEM32(cmd_mbox, config_profile, set_lag_mode, 0x08, 7, 1);
709+
698710
/* cmd_mbox_config_profile_max_vepa_channels
699711
* Maximum number of VEPA channels per port (0 through 16)
700712
* 0 - multi-channel VEPA is disabled
@@ -840,14 +852,29 @@ MLXSW_ITEM32(cmd_mbox, config_profile, arn, 0x50, 31, 1);
840852
*/
841853
MLXSW_ITEM32(cmd_mbox, config_profile, ubridge, 0x50, 4, 1);
842854

855+
enum mlxsw_cmd_mbox_config_profile_lag_mode {
856+
/* FW manages PGT LAG table */
857+
MLXSW_CMD_MBOX_CONFIG_PROFILE_LAG_MODE_FW,
858+
/* SW manages PGT LAG table */
859+
MLXSW_CMD_MBOX_CONFIG_PROFILE_LAG_MODE_SW,
860+
};
861+
862+
/* cmd_mbox_config_profile_lag_mode
863+
* LAG mode
864+
* Configured if set_lag_mode is set
865+
* Supported from Spectrum-2 and above.
866+
* Supported only when ubridge = 1
867+
*/
868+
MLXSW_ITEM32(cmd_mbox, config_profile, lag_mode, 0x50, 3, 1);
869+
843870
/* cmd_mbox_config_kvd_linear_size
844871
* KVD Linear Size
845872
* Valid for Spectrum only
846873
* Allowed values are 128*N where N=0 or higher
847874
*/
848875
MLXSW_ITEM32(cmd_mbox, config_profile, kvd_linear_size, 0x54, 0, 24);
849876

850-
/* cmd_mbox_config_kvd_hash_single_size
877+
/* cmd_mbox_config_profile_kvd_hash_single_size
851878
* KVD Hash single-entries size
852879
* Valid for Spectrum only
853880
* Allowed values are 128*N where N=0 or higher
@@ -856,7 +883,7 @@ MLXSW_ITEM32(cmd_mbox, config_profile, kvd_linear_size, 0x54, 0, 24);
856883
*/
857884
MLXSW_ITEM32(cmd_mbox, config_profile, kvd_hash_single_size, 0x58, 0, 24);
858885

859-
/* cmd_mbox_config_kvd_hash_double_size
886+
/* cmd_mbox_config_profile_kvd_hash_double_size
860887
* KVD Hash double-entries size (units of single-size entries)
861888
* Valid for Spectrum only
862889
* Allowed values are 128*N where N=0 or higher

drivers/net/ethernet/mellanox/mlxsw/core.c

+7
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ int mlxsw_core_max_lag(struct mlxsw_core *mlxsw_core, u16 *p_max_lag)
204204
}
205205
EXPORT_SYMBOL(mlxsw_core_max_lag);
206206

207+
enum mlxsw_cmd_mbox_config_profile_lag_mode
208+
mlxsw_core_lag_mode(struct mlxsw_core *mlxsw_core)
209+
{
210+
return mlxsw_core->bus->lag_mode(mlxsw_core->bus_priv);
211+
}
212+
EXPORT_SYMBOL(mlxsw_core_lag_mode);
213+
207214
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
208215
{
209216
return mlxsw_core->driver_priv;

drivers/net/ethernet/mellanox/mlxsw/core.h

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct mlxsw_fw_rev;
3636
unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
3737

3838
int mlxsw_core_max_lag(struct mlxsw_core *mlxsw_core, u16 *p_max_lag);
39+
enum mlxsw_cmd_mbox_config_profile_lag_mode
40+
mlxsw_core_lag_mode(struct mlxsw_core *mlxsw_core);
3941

4042
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
4143

@@ -335,6 +337,7 @@ struct mlxsw_config_profile {
335337
u8 kvd_hash_single_parts;
336338
u8 kvd_hash_double_parts;
337339
u8 cqe_time_stamp_type;
340+
bool lag_mode_prefer_sw;
338341
struct mlxsw_swid_config swid_config[MLXSW_CONFIG_PROFILE_SWID_COUNT];
339342
};
340343

@@ -485,6 +488,7 @@ struct mlxsw_bus {
485488
u32 (*read_frc_l)(void *bus_priv);
486489
u32 (*read_utc_sec)(void *bus_priv);
487490
u32 (*read_utc_nsec)(void *bus_priv);
491+
enum mlxsw_cmd_mbox_config_profile_lag_mode (*lag_mode)(void *bus_priv);
488492
u8 features;
489493
};
490494

drivers/net/ethernet/mellanox/mlxsw/pci.c

+25-3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ struct mlxsw_pci {
105105
u64 free_running_clock_offset;
106106
u64 utc_sec_offset;
107107
u64 utc_nsec_offset;
108+
bool lag_mode_support;
109+
enum mlxsw_cmd_mbox_config_profile_lag_mode lag_mode;
108110
struct mlxsw_pci_queue_type_group queues[MLXSW_PCI_QUEUE_TYPE_COUNT];
109111
u32 doorbell_offset;
110112
struct mlxsw_core *core;
@@ -1312,6 +1314,16 @@ static int mlxsw_pci_config_profile(struct mlxsw_pci *mlxsw_pci, char *mbox,
13121314
profile->cqe_time_stamp_type);
13131315
}
13141316

1317+
if (profile->lag_mode_prefer_sw && mlxsw_pci->lag_mode_support) {
1318+
enum mlxsw_cmd_mbox_config_profile_lag_mode lag_mode =
1319+
MLXSW_CMD_MBOX_CONFIG_PROFILE_LAG_MODE_SW;
1320+
1321+
mlxsw_cmd_mbox_config_profile_set_lag_mode_set(mbox, 1);
1322+
mlxsw_cmd_mbox_config_profile_lag_mode_set(mbox, lag_mode);
1323+
mlxsw_pci->lag_mode = lag_mode;
1324+
} else {
1325+
mlxsw_pci->lag_mode = MLXSW_CMD_MBOX_CONFIG_PROFILE_LAG_MODE_FW;
1326+
}
13151327
return mlxsw_cmd_config_profile_set(mlxsw_pci->core, mbox);
13161328
}
13171329

@@ -1587,6 +1599,8 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
15871599
mlxsw_pci->utc_nsec_offset =
15881600
mlxsw_cmd_mbox_query_fw_utc_nsec_offset_get(mbox);
15891601

1602+
mlxsw_pci->lag_mode_support =
1603+
mlxsw_cmd_mbox_query_fw_lag_mode_support_get(mbox);
15901604
num_pages = mlxsw_cmd_mbox_query_fw_fw_pages_get(mbox);
15911605
err = mlxsw_pci_fw_area_init(mlxsw_pci, mbox, num_pages);
15921606
if (err)
@@ -1619,9 +1633,8 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
16191633
if (err)
16201634
goto err_config_profile;
16211635

1622-
/* Some resources depend on unified bridge model, which is configured
1623-
* as part of config_profile. Query the resources again to get correct
1624-
* values.
1636+
/* Some resources depend on details of config_profile, such as unified
1637+
* bridge model. Query the resources again to get correct values.
16251638
*/
16261639
err = mlxsw_core_resources_query(mlxsw_core, mbox, res);
16271640
if (err)
@@ -1896,6 +1909,14 @@ static u32 mlxsw_pci_read_utc_nsec(void *bus_priv)
18961909
return mlxsw_pci_read32_off(mlxsw_pci, mlxsw_pci->utc_nsec_offset);
18971910
}
18981911

1912+
static enum mlxsw_cmd_mbox_config_profile_lag_mode
1913+
mlxsw_pci_lag_mode(void *bus_priv)
1914+
{
1915+
struct mlxsw_pci *mlxsw_pci = bus_priv;
1916+
1917+
return mlxsw_pci->lag_mode;
1918+
}
1919+
18991920
static const struct mlxsw_bus mlxsw_pci_bus = {
19001921
.kind = "pci",
19011922
.init = mlxsw_pci_init,
@@ -1907,6 +1928,7 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
19071928
.read_frc_l = mlxsw_pci_read_frc_l,
19081929
.read_utc_sec = mlxsw_pci_read_utc_sec,
19091930
.read_utc_nsec = mlxsw_pci_read_utc_nsec,
1931+
.lag_mode = mlxsw_pci_lag_mode,
19101932
.features = MLXSW_BUS_F_TXRX | MLXSW_BUS_F_RESET,
19111933
};
19121934

drivers/net/ethernet/mellanox/mlxsw/reg.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
3838

3939
MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
4040

41-
/* reg_sgcr_llb
42-
* Link Local Broadcast (Default=0)
43-
* When set, all Link Local packets (224.0.0.X) will be treated as broadcast
44-
* packets and ignore the IGMP snooping entries.
41+
/* reg_sgcr_lag_lookup_pgt_base
42+
* Base address used for lookup in PGT table
43+
* Supported when CONFIG_PROFILE.lag_mode = 1
44+
* Note: when IGCR.ddd_lag_mode=0, the address shall be aligned to 8 entries.
4545
* Access: RW
4646
*/
47-
MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
47+
MLXSW_ITEM32(reg, sgcr, lag_lookup_pgt_base, 0x0C, 0, 16);
4848

49-
static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
49+
static inline void mlxsw_reg_sgcr_pack(char *payload, u16 lag_lookup_pgt_base)
5050
{
5151
MLXSW_REG_ZERO(sgcr, payload);
52-
mlxsw_reg_sgcr_llb_set(payload, !!llb);
52+
mlxsw_reg_sgcr_lag_lookup_pgt_base_set(payload, lag_lookup_pgt_base);
5353
}
5454

5555
/* SPAD - Switch Physical Address Register

0 commit comments

Comments
 (0)