Skip to content

Commit 0959159

Browse files
pmachatakuba-moo
authored andcommitted
mlxsw: core, pci: Add plumbing related to CFF mode
CFF mode, for Compressed FID Flooding, is a way of organizing flood vectors in the PGT table. The bus module determines whether CFF is supported, can configure flood mode to CFF if it is, and knows what flood mode has been configured. Therefore add a bus callback to determine the configured flood mode. Also add to core an API to query it. Since after this patch, we rely on mlxsw_pci->flood_mode being set, it becomes a coding error if a driver invokes this function with a set of fields that misses the initialization. Warn and bail out in that case. The CFF mode is not used as of this patch. The code to actually use it will be added later. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/889d58759dd40f5037f2206b9fc4a78a9240da80.1700503644.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6b10371 commit 0959159

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ mlxsw_core_lag_mode(struct mlxsw_core *mlxsw_core)
211211
}
212212
EXPORT_SYMBOL(mlxsw_core_lag_mode);
213213

214+
enum mlxsw_cmd_mbox_config_profile_flood_mode
215+
mlxsw_core_flood_mode(struct mlxsw_core *mlxsw_core)
216+
{
217+
return mlxsw_core->bus->flood_mode(mlxsw_core->bus_priv);
218+
}
219+
EXPORT_SYMBOL(mlxsw_core_flood_mode);
220+
214221
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core)
215222
{
216223
return mlxsw_core->driver_priv;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
3838
int mlxsw_core_max_lag(struct mlxsw_core *mlxsw_core, u16 *p_max_lag);
3939
enum mlxsw_cmd_mbox_config_profile_lag_mode
4040
mlxsw_core_lag_mode(struct mlxsw_core *mlxsw_core);
41+
enum mlxsw_cmd_mbox_config_profile_flood_mode
42+
mlxsw_core_flood_mode(struct mlxsw_core *mlxsw_core);
4143

4244
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
4345

@@ -489,6 +491,7 @@ struct mlxsw_bus {
489491
u32 (*read_utc_sec)(void *bus_priv);
490492
u32 (*read_utc_nsec)(void *bus_priv);
491493
enum mlxsw_cmd_mbox_config_profile_lag_mode (*lag_mode)(void *bus_priv);
494+
enum mlxsw_cmd_mbox_config_profile_flood_mode (*flood_mode)(void *priv);
492495
u8 features;
493496
};
494497

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ struct mlxsw_pci {
106106
u64 utc_sec_offset;
107107
u64 utc_nsec_offset;
108108
bool lag_mode_support;
109+
bool cff_support;
109110
enum mlxsw_cmd_mbox_config_profile_lag_mode lag_mode;
111+
enum mlxsw_cmd_mbox_config_profile_flood_mode flood_mode;
110112
struct mlxsw_pci_queue_type_group queues[MLXSW_PCI_QUEUE_TYPE_COUNT];
111113
u32 doorbell_offset;
112114
struct mlxsw_core *core;
@@ -1251,6 +1253,10 @@ static int mlxsw_pci_config_profile(struct mlxsw_pci *mlxsw_pci, char *mbox,
12511253
mbox, 1);
12521254
mlxsw_cmd_mbox_config_profile_flood_mode_set(
12531255
mbox, profile->flood_mode);
1256+
mlxsw_pci->flood_mode = profile->flood_mode;
1257+
} else {
1258+
WARN_ON(1);
1259+
return -EINVAL;
12541260
}
12551261
if (profile->used_max_ib_mc) {
12561262
mlxsw_cmd_mbox_config_profile_set_max_ib_mc_set(
@@ -1654,6 +1660,9 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
16541660

16551661
mlxsw_pci->lag_mode_support =
16561662
mlxsw_cmd_mbox_query_fw_lag_mode_support_get(mbox);
1663+
mlxsw_pci->cff_support =
1664+
mlxsw_cmd_mbox_query_fw_cff_support_get(mbox);
1665+
16571666
num_pages = mlxsw_cmd_mbox_query_fw_fw_pages_get(mbox);
16581667
err = mlxsw_pci_fw_area_init(mlxsw_pci, mbox, num_pages);
16591668
if (err)
@@ -1970,6 +1979,14 @@ mlxsw_pci_lag_mode(void *bus_priv)
19701979
return mlxsw_pci->lag_mode;
19711980
}
19721981

1982+
static enum mlxsw_cmd_mbox_config_profile_flood_mode
1983+
mlxsw_pci_flood_mode(void *bus_priv)
1984+
{
1985+
struct mlxsw_pci *mlxsw_pci = bus_priv;
1986+
1987+
return mlxsw_pci->flood_mode;
1988+
}
1989+
19731990
static const struct mlxsw_bus mlxsw_pci_bus = {
19741991
.kind = "pci",
19751992
.init = mlxsw_pci_init,
@@ -1982,6 +1999,7 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
19821999
.read_utc_sec = mlxsw_pci_read_utc_sec,
19832000
.read_utc_nsec = mlxsw_pci_read_utc_nsec,
19842001
.lag_mode = mlxsw_pci_lag_mode,
2002+
.flood_mode = mlxsw_pci_flood_mode,
19852003
.features = MLXSW_BUS_F_TXRX | MLXSW_BUS_F_RESET,
19862004
};
19872005

0 commit comments

Comments
 (0)