Skip to content

Commit 4735402

Browse files
Amit Cohenkuba-moo
authored andcommitted
mlxsw: spectrum: Extend to support Spectrum-4 ASIC
Extend existing driver for Spectrum, Spectrum-2 and Spectrum-3 ASICs to support Spectrum-4 ASIC as well. Currently there is no released firmware version for Spectrum-4, so the driver is not enforcing a minimum version. Signed-off-by: Amit Cohen <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 852ee41 commit 4735402

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ config MLXSW_SPECTRUM
6666
default m
6767
help
6868
This driver supports Mellanox Technologies
69-
Spectrum/Spectrum-2/Spectrum-3 Ethernet Switch ASICs.
69+
Spectrum/Spectrum-2/Spectrum-3/Spectrum-4 Ethernet Switch ASICs.
7070

7171
To compile this driver as a module, choose M here: the
7272
module will be called mlxsw_spectrum.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define PCI_DEVICE_ID_MELLANOX_SPECTRUM 0xcb84
1010
#define PCI_DEVICE_ID_MELLANOX_SPECTRUM2 0xcf6c
1111
#define PCI_DEVICE_ID_MELLANOX_SPECTRUM3 0xcf70
12+
#define PCI_DEVICE_ID_MELLANOX_SPECTRUM4 0xcf80
1213

1314
#if IS_ENABLED(CONFIG_MLXSW_PCI)
1415

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3914,6 +3914,7 @@ MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
39143914
#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
39153915
#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
39163916
#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11
3917+
#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4 11
39173918

39183919
static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
39193920
enum mlxsw_reg_qeec_hr hr, u8 index,

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

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static const struct mlxsw_fw_rev mlxsw_sp3_fw_rev = {
9595
static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum";
9696
static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2";
9797
static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3";
98+
static const char mlxsw_sp4_driver_name[] = "mlxsw_spectrum4";
9899

99100
static const unsigned char mlxsw_sp1_mac_mask[ETH_ALEN] = {
100101
0xff, 0xff, 0xff, 0xff, 0xfc, 0x00
@@ -3202,6 +3203,36 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core,
32023203
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack);
32033204
}
32043205

3206+
static int mlxsw_sp4_init(struct mlxsw_core *mlxsw_core,
3207+
const struct mlxsw_bus_info *mlxsw_bus_info,
3208+
struct netlink_ext_ack *extack)
3209+
{
3210+
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
3211+
3212+
mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops;
3213+
mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops;
3214+
mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops;
3215+
mlxsw_sp->afk_ops = &mlxsw_sp4_afk_ops;
3216+
mlxsw_sp->mr_tcam_ops = &mlxsw_sp2_mr_tcam_ops;
3217+
mlxsw_sp->acl_rulei_ops = &mlxsw_sp2_acl_rulei_ops;
3218+
mlxsw_sp->acl_tcam_ops = &mlxsw_sp2_acl_tcam_ops;
3219+
mlxsw_sp->acl_bf_ops = &mlxsw_sp4_acl_bf_ops;
3220+
mlxsw_sp->nve_ops_arr = mlxsw_sp2_nve_ops_arr;
3221+
mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask;
3222+
mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals;
3223+
mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops;
3224+
mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops;
3225+
mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops;
3226+
mlxsw_sp->span_ops = &mlxsw_sp3_span_ops;
3227+
mlxsw_sp->policer_core_ops = &mlxsw_sp2_policer_core_ops;
3228+
mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops;
3229+
mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops;
3230+
mlxsw_sp->router_ops = &mlxsw_sp2_router_ops;
3231+
mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4;
3232+
3233+
return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack);
3234+
}
3235+
32053236
static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
32063237
{
32073238
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
@@ -3761,6 +3792,45 @@ static struct mlxsw_driver mlxsw_sp3_driver = {
37613792
.temp_warn_enabled = true,
37623793
};
37633794

3795+
static struct mlxsw_driver mlxsw_sp4_driver = {
3796+
.kind = mlxsw_sp4_driver_name,
3797+
.priv_size = sizeof(struct mlxsw_sp),
3798+
.init = mlxsw_sp4_init,
3799+
.fini = mlxsw_sp_fini,
3800+
.basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set,
3801+
.port_split = mlxsw_sp_port_split,
3802+
.port_unsplit = mlxsw_sp_port_unsplit,
3803+
.sb_pool_get = mlxsw_sp_sb_pool_get,
3804+
.sb_pool_set = mlxsw_sp_sb_pool_set,
3805+
.sb_port_pool_get = mlxsw_sp_sb_port_pool_get,
3806+
.sb_port_pool_set = mlxsw_sp_sb_port_pool_set,
3807+
.sb_tc_pool_bind_get = mlxsw_sp_sb_tc_pool_bind_get,
3808+
.sb_tc_pool_bind_set = mlxsw_sp_sb_tc_pool_bind_set,
3809+
.sb_occ_snapshot = mlxsw_sp_sb_occ_snapshot,
3810+
.sb_occ_max_clear = mlxsw_sp_sb_occ_max_clear,
3811+
.sb_occ_port_pool_get = mlxsw_sp_sb_occ_port_pool_get,
3812+
.sb_occ_tc_port_bind_get = mlxsw_sp_sb_occ_tc_port_bind_get,
3813+
.trap_init = mlxsw_sp_trap_init,
3814+
.trap_fini = mlxsw_sp_trap_fini,
3815+
.trap_action_set = mlxsw_sp_trap_action_set,
3816+
.trap_group_init = mlxsw_sp_trap_group_init,
3817+
.trap_group_set = mlxsw_sp_trap_group_set,
3818+
.trap_policer_init = mlxsw_sp_trap_policer_init,
3819+
.trap_policer_fini = mlxsw_sp_trap_policer_fini,
3820+
.trap_policer_set = mlxsw_sp_trap_policer_set,
3821+
.trap_policer_counter_get = mlxsw_sp_trap_policer_counter_get,
3822+
.txhdr_construct = mlxsw_sp_txhdr_construct,
3823+
.resources_register = mlxsw_sp2_resources_register,
3824+
.params_register = mlxsw_sp2_params_register,
3825+
.params_unregister = mlxsw_sp2_params_unregister,
3826+
.ptp_transmitted = mlxsw_sp_ptp_transmitted,
3827+
.txhdr_len = MLXSW_TXHDR_LEN,
3828+
.profile = &mlxsw_sp2_config_profile,
3829+
.res_query_enabled = true,
3830+
.fw_fatal_enabled = true,
3831+
.temp_warn_enabled = true,
3832+
};
3833+
37643834
bool mlxsw_sp_port_dev_check(const struct net_device *dev)
37653835
{
37663836
return dev->netdev_ops == &mlxsw_sp_port_netdev_ops;
@@ -4928,6 +4998,16 @@ static struct pci_driver mlxsw_sp3_pci_driver = {
49284998
.id_table = mlxsw_sp3_pci_id_table,
49294999
};
49305000

5001+
static const struct pci_device_id mlxsw_sp4_pci_id_table[] = {
5002+
{PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM4), 0},
5003+
{0, },
5004+
};
5005+
5006+
static struct pci_driver mlxsw_sp4_pci_driver = {
5007+
.name = mlxsw_sp4_driver_name,
5008+
.id_table = mlxsw_sp4_pci_id_table,
5009+
};
5010+
49315011
static int __init mlxsw_sp_module_init(void)
49325012
{
49335013
int err;
@@ -4947,6 +5027,10 @@ static int __init mlxsw_sp_module_init(void)
49475027
if (err)
49485028
goto err_sp3_core_driver_register;
49495029

5030+
err = mlxsw_core_driver_register(&mlxsw_sp4_driver);
5031+
if (err)
5032+
goto err_sp4_core_driver_register;
5033+
49505034
err = mlxsw_pci_driver_register(&mlxsw_sp1_pci_driver);
49515035
if (err)
49525036
goto err_sp1_pci_driver_register;
@@ -4959,13 +5043,21 @@ static int __init mlxsw_sp_module_init(void)
49595043
if (err)
49605044
goto err_sp3_pci_driver_register;
49615045

5046+
err = mlxsw_pci_driver_register(&mlxsw_sp4_pci_driver);
5047+
if (err)
5048+
goto err_sp4_pci_driver_register;
5049+
49625050
return 0;
49635051

5052+
err_sp4_pci_driver_register:
5053+
mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver);
49645054
err_sp3_pci_driver_register:
49655055
mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver);
49665056
err_sp2_pci_driver_register:
49675057
mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver);
49685058
err_sp1_pci_driver_register:
5059+
mlxsw_core_driver_unregister(&mlxsw_sp4_driver);
5060+
err_sp4_core_driver_register:
49695061
mlxsw_core_driver_unregister(&mlxsw_sp3_driver);
49705062
err_sp3_core_driver_register:
49715063
mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
@@ -4979,9 +5071,11 @@ static int __init mlxsw_sp_module_init(void)
49795071

49805072
static void __exit mlxsw_sp_module_exit(void)
49815073
{
5074+
mlxsw_pci_driver_unregister(&mlxsw_sp4_pci_driver);
49825075
mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver);
49835076
mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver);
49845077
mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver);
5078+
mlxsw_core_driver_unregister(&mlxsw_sp4_driver);
49855079
mlxsw_core_driver_unregister(&mlxsw_sp3_driver);
49865080
mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
49875081
mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
@@ -4998,6 +5092,7 @@ MODULE_DESCRIPTION("Mellanox Spectrum driver");
49985092
MODULE_DEVICE_TABLE(pci, mlxsw_sp1_pci_id_table);
49995093
MODULE_DEVICE_TABLE(pci, mlxsw_sp2_pci_id_table);
50005094
MODULE_DEVICE_TABLE(pci, mlxsw_sp3_pci_id_table);
5095+
MODULE_DEVICE_TABLE(pci, mlxsw_sp4_pci_id_table);
50015096
MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME);
50025097
MODULE_FIRMWARE(MLXSW_SP2_FW_FILENAME);
50035098
MODULE_FIRMWARE(MLXSW_SP3_FW_FILENAME);

0 commit comments

Comments
 (0)