@@ -91,7 +91,8 @@ static const struct mlxsw_fw_rev mlxsw_sp1_fw_rev = {
91
91
"." __stringify(MLXSW_SP1_FWREV_MINOR) \
92
92
"." __stringify(MLXSW_SP1_FWREV_SUBMINOR) ".mfa2"
93
93
94
- static const char mlxsw_sp_driver_name [] = "mlxsw_spectrum" ;
94
+ static const char mlxsw_sp1_driver_name [] = "mlxsw_spectrum" ;
95
+ static const char mlxsw_sp2_driver_name [] = "mlxsw_spectrum2" ;
95
96
static const char mlxsw_sp_driver_version [] = "1.0" ;
96
97
97
98
/* tx_hdr_version
@@ -1727,7 +1728,8 @@ static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,
1727
1728
struct mlxsw_sp_port * mlxsw_sp_port = netdev_priv (dev );
1728
1729
struct mlxsw_sp * mlxsw_sp = mlxsw_sp_port -> mlxsw_sp ;
1729
1730
1730
- strlcpy (drvinfo -> driver , mlxsw_sp_driver_name , sizeof (drvinfo -> driver ));
1731
+ strlcpy (drvinfo -> driver , mlxsw_sp -> bus_info -> device_kind ,
1732
+ sizeof (drvinfo -> driver ));
1731
1733
strlcpy (drvinfo -> version , mlxsw_sp_driver_version ,
1732
1734
sizeof (drvinfo -> version ));
1733
1735
snprintf (drvinfo -> fw_version , sizeof (drvinfo -> fw_version ),
@@ -3696,14 +3698,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
3696
3698
struct mlxsw_sp * mlxsw_sp = mlxsw_core_driver_priv (mlxsw_core );
3697
3699
int err ;
3698
3700
3699
- mlxsw_sp -> req_rev = & mlxsw_sp1_fw_rev ;
3700
- mlxsw_sp -> fw_filename = MLXSW_SP1_FW_FILENAME ;
3701
- mlxsw_sp -> kvdl_ops = & mlxsw_sp1_kvdl_ops ;
3702
- mlxsw_sp -> afa_ops = & mlxsw_sp1_act_afa_ops ;
3703
- mlxsw_sp -> afk_ops = & mlxsw_sp1_afk_ops ;
3704
- mlxsw_sp -> mr_tcam_ops = & mlxsw_sp1_mr_tcam_ops ;
3705
- mlxsw_sp -> acl_tcam_ops = & mlxsw_sp1_acl_tcam_ops ;
3706
-
3707
3701
mlxsw_sp -> core = mlxsw_core ;
3708
3702
mlxsw_sp -> bus_info = mlxsw_bus_info ;
3709
3703
@@ -3842,6 +3836,36 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
3842
3836
return err ;
3843
3837
}
3844
3838
3839
+ static int mlxsw_sp1_init (struct mlxsw_core * mlxsw_core ,
3840
+ const struct mlxsw_bus_info * mlxsw_bus_info )
3841
+ {
3842
+ struct mlxsw_sp * mlxsw_sp = mlxsw_core_driver_priv (mlxsw_core );
3843
+
3844
+ mlxsw_sp -> req_rev = & mlxsw_sp1_fw_rev ;
3845
+ mlxsw_sp -> fw_filename = MLXSW_SP1_FW_FILENAME ;
3846
+ mlxsw_sp -> kvdl_ops = & mlxsw_sp1_kvdl_ops ;
3847
+ mlxsw_sp -> afa_ops = & mlxsw_sp1_act_afa_ops ;
3848
+ mlxsw_sp -> afk_ops = & mlxsw_sp1_afk_ops ;
3849
+ mlxsw_sp -> mr_tcam_ops = & mlxsw_sp1_mr_tcam_ops ;
3850
+ mlxsw_sp -> acl_tcam_ops = & mlxsw_sp1_acl_tcam_ops ;
3851
+
3852
+ return mlxsw_sp_init (mlxsw_core , mlxsw_bus_info );
3853
+ }
3854
+
3855
+ static int mlxsw_sp2_init (struct mlxsw_core * mlxsw_core ,
3856
+ const struct mlxsw_bus_info * mlxsw_bus_info )
3857
+ {
3858
+ struct mlxsw_sp * mlxsw_sp = mlxsw_core_driver_priv (mlxsw_core );
3859
+
3860
+ mlxsw_sp -> kvdl_ops = & mlxsw_sp2_kvdl_ops ;
3861
+ mlxsw_sp -> afa_ops = & mlxsw_sp2_act_afa_ops ;
3862
+ mlxsw_sp -> afk_ops = & mlxsw_sp2_afk_ops ;
3863
+ mlxsw_sp -> mr_tcam_ops = & mlxsw_sp2_mr_tcam_ops ;
3864
+ mlxsw_sp -> acl_tcam_ops = & mlxsw_sp2_acl_tcam_ops ;
3865
+
3866
+ return mlxsw_sp_init (mlxsw_core , mlxsw_bus_info );
3867
+ }
3868
+
3845
3869
static void mlxsw_sp_fini (struct mlxsw_core * mlxsw_core )
3846
3870
{
3847
3871
struct mlxsw_sp * mlxsw_sp = mlxsw_core_driver_priv (mlxsw_core );
@@ -3862,7 +3886,7 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
3862
3886
mlxsw_sp_kvdl_fini (mlxsw_sp );
3863
3887
}
3864
3888
3865
- static const struct mlxsw_config_profile mlxsw_sp_config_profile = {
3889
+ static const struct mlxsw_config_profile mlxsw_sp1_config_profile = {
3866
3890
.used_max_mid = 1 ,
3867
3891
.max_mid = MLXSW_SP_MID_MAX ,
3868
3892
.used_flood_tables = 1 ,
@@ -3888,6 +3912,28 @@ static const struct mlxsw_config_profile mlxsw_sp_config_profile = {
3888
3912
},
3889
3913
};
3890
3914
3915
+ static const struct mlxsw_config_profile mlxsw_sp2_config_profile = {
3916
+ .used_max_mid = 1 ,
3917
+ .max_mid = MLXSW_SP_MID_MAX ,
3918
+ .used_flood_tables = 1 ,
3919
+ .used_flood_mode = 1 ,
3920
+ .flood_mode = 3 ,
3921
+ .max_fid_offset_flood_tables = 3 ,
3922
+ .fid_offset_flood_table_size = VLAN_N_VID - 1 ,
3923
+ .max_fid_flood_tables = 3 ,
3924
+ .fid_flood_table_size = MLXSW_SP_FID_8021D_MAX ,
3925
+ .used_max_ib_mc = 1 ,
3926
+ .max_ib_mc = 0 ,
3927
+ .used_max_pkey = 1 ,
3928
+ .max_pkey = 0 ,
3929
+ .swid_config = {
3930
+ {
3931
+ .used_type = 1 ,
3932
+ .type = MLXSW_PORT_SWID_TYPE_ETH ,
3933
+ }
3934
+ },
3935
+ };
3936
+
3891
3937
static void
3892
3938
mlxsw_sp_resource_size_params_prepare (struct mlxsw_core * mlxsw_core ,
3893
3939
struct devlink_resource_size_params * kvd_size_params ,
@@ -3924,7 +3970,7 @@ mlxsw_sp_resource_size_params_prepare(struct mlxsw_core *mlxsw_core,
3924
3970
DEVLINK_RESOURCE_UNIT_ENTRY );
3925
3971
}
3926
3972
3927
- static int mlxsw_sp_resources_register (struct mlxsw_core * mlxsw_core )
3973
+ static int mlxsw_sp1_resources_kvd_register (struct mlxsw_core * mlxsw_core )
3928
3974
{
3929
3975
struct devlink * devlink = priv_to_devlink (mlxsw_core );
3930
3976
struct devlink_resource_size_params hash_single_size_params ;
@@ -3935,7 +3981,7 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
3935
3981
const struct mlxsw_config_profile * profile ;
3936
3982
int err ;
3937
3983
3938
- profile = & mlxsw_sp_config_profile ;
3984
+ profile = & mlxsw_sp1_config_profile ;
3939
3985
if (!MLXSW_CORE_RES_VALID (mlxsw_core , KVD_SIZE ))
3940
3986
return - EIO ;
3941
3987
@@ -3990,6 +4036,16 @@ static int mlxsw_sp_resources_register(struct mlxsw_core *mlxsw_core)
3990
4036
return 0 ;
3991
4037
}
3992
4038
4039
+ static int mlxsw_sp1_resources_register (struct mlxsw_core * mlxsw_core )
4040
+ {
4041
+ return mlxsw_sp1_resources_kvd_register (mlxsw_core );
4042
+ }
4043
+
4044
+ static int mlxsw_sp2_resources_register (struct mlxsw_core * mlxsw_core )
4045
+ {
4046
+ return 0 ;
4047
+ }
4048
+
3993
4049
static int mlxsw_sp_kvd_sizes_get (struct mlxsw_core * mlxsw_core ,
3994
4050
const struct mlxsw_config_profile * profile ,
3995
4051
u64 * p_single_size , u64 * p_double_size ,
@@ -4045,10 +4101,10 @@ static int mlxsw_sp_kvd_sizes_get(struct mlxsw_core *mlxsw_core,
4045
4101
return 0 ;
4046
4102
}
4047
4103
4048
- static struct mlxsw_driver mlxsw_sp_driver = {
4049
- .kind = mlxsw_sp_driver_name ,
4104
+ static struct mlxsw_driver mlxsw_sp1_driver = {
4105
+ .kind = mlxsw_sp1_driver_name ,
4050
4106
.priv_size = sizeof (struct mlxsw_sp ),
4051
- .init = mlxsw_sp_init ,
4107
+ .init = mlxsw_sp1_init ,
4052
4108
.fini = mlxsw_sp_fini ,
4053
4109
.basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set ,
4054
4110
.port_split = mlxsw_sp_port_split ,
@@ -4064,10 +4120,35 @@ static struct mlxsw_driver mlxsw_sp_driver = {
4064
4120
.sb_occ_port_pool_get = mlxsw_sp_sb_occ_port_pool_get ,
4065
4121
.sb_occ_tc_port_bind_get = mlxsw_sp_sb_occ_tc_port_bind_get ,
4066
4122
.txhdr_construct = mlxsw_sp_txhdr_construct ,
4067
- .resources_register = mlxsw_sp_resources_register ,
4123
+ .resources_register = mlxsw_sp1_resources_register ,
4068
4124
.kvd_sizes_get = mlxsw_sp_kvd_sizes_get ,
4069
4125
.txhdr_len = MLXSW_TXHDR_LEN ,
4070
- .profile = & mlxsw_sp_config_profile ,
4126
+ .profile = & mlxsw_sp1_config_profile ,
4127
+ .res_query_enabled = true,
4128
+ };
4129
+
4130
+ static struct mlxsw_driver mlxsw_sp2_driver = {
4131
+ .kind = mlxsw_sp2_driver_name ,
4132
+ .priv_size = sizeof (struct mlxsw_sp ),
4133
+ .init = mlxsw_sp2_init ,
4134
+ .fini = mlxsw_sp_fini ,
4135
+ .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set ,
4136
+ .port_split = mlxsw_sp_port_split ,
4137
+ .port_unsplit = mlxsw_sp_port_unsplit ,
4138
+ .sb_pool_get = mlxsw_sp_sb_pool_get ,
4139
+ .sb_pool_set = mlxsw_sp_sb_pool_set ,
4140
+ .sb_port_pool_get = mlxsw_sp_sb_port_pool_get ,
4141
+ .sb_port_pool_set = mlxsw_sp_sb_port_pool_set ,
4142
+ .sb_tc_pool_bind_get = mlxsw_sp_sb_tc_pool_bind_get ,
4143
+ .sb_tc_pool_bind_set = mlxsw_sp_sb_tc_pool_bind_set ,
4144
+ .sb_occ_snapshot = mlxsw_sp_sb_occ_snapshot ,
4145
+ .sb_occ_max_clear = mlxsw_sp_sb_occ_max_clear ,
4146
+ .sb_occ_port_pool_get = mlxsw_sp_sb_occ_port_pool_get ,
4147
+ .sb_occ_tc_port_bind_get = mlxsw_sp_sb_occ_tc_port_bind_get ,
4148
+ .txhdr_construct = mlxsw_sp_txhdr_construct ,
4149
+ .resources_register = mlxsw_sp2_resources_register ,
4150
+ .txhdr_len = MLXSW_TXHDR_LEN ,
4151
+ .profile = & mlxsw_sp2_config_profile ,
4071
4152
.res_query_enabled = true,
4072
4153
};
4073
4154
@@ -4846,14 +4927,24 @@ static struct notifier_block mlxsw_sp_inet6addr_nb __read_mostly = {
4846
4927
.notifier_call = mlxsw_sp_inet6addr_event ,
4847
4928
};
4848
4929
4849
- static const struct pci_device_id mlxsw_sp_pci_id_table [] = {
4930
+ static const struct pci_device_id mlxsw_sp1_pci_id_table [] = {
4850
4931
{PCI_VDEVICE (MELLANOX , PCI_DEVICE_ID_MELLANOX_SPECTRUM ), 0 },
4851
4932
{0 , },
4852
4933
};
4853
4934
4854
- static struct pci_driver mlxsw_sp_pci_driver = {
4855
- .name = mlxsw_sp_driver_name ,
4856
- .id_table = mlxsw_sp_pci_id_table ,
4935
+ static struct pci_driver mlxsw_sp1_pci_driver = {
4936
+ .name = mlxsw_sp1_driver_name ,
4937
+ .id_table = mlxsw_sp1_pci_id_table ,
4938
+ };
4939
+
4940
+ static const struct pci_device_id mlxsw_sp2_pci_id_table [] = {
4941
+ {PCI_VDEVICE (MELLANOX , PCI_DEVICE_ID_MELLANOX_SPECTRUM2 ), 0 },
4942
+ {0 , },
4943
+ };
4944
+
4945
+ static struct pci_driver mlxsw_sp2_pci_driver = {
4946
+ .name = mlxsw_sp2_driver_name ,
4947
+ .id_table = mlxsw_sp2_pci_id_table ,
4857
4948
};
4858
4949
4859
4950
static int __init mlxsw_sp_module_init (void )
@@ -4865,19 +4956,31 @@ static int __init mlxsw_sp_module_init(void)
4865
4956
register_inet6addr_validator_notifier (& mlxsw_sp_inet6addr_valid_nb );
4866
4957
register_inet6addr_notifier (& mlxsw_sp_inet6addr_nb );
4867
4958
4868
- err = mlxsw_core_driver_register (& mlxsw_sp_driver );
4959
+ err = mlxsw_core_driver_register (& mlxsw_sp1_driver );
4960
+ if (err )
4961
+ goto err_sp1_core_driver_register ;
4962
+
4963
+ err = mlxsw_core_driver_register (& mlxsw_sp2_driver );
4964
+ if (err )
4965
+ goto err_sp2_core_driver_register ;
4966
+
4967
+ err = mlxsw_pci_driver_register (& mlxsw_sp1_pci_driver );
4869
4968
if (err )
4870
- goto err_core_driver_register ;
4969
+ goto err_sp1_pci_driver_register ;
4871
4970
4872
- err = mlxsw_pci_driver_register (& mlxsw_sp_pci_driver );
4971
+ err = mlxsw_pci_driver_register (& mlxsw_sp2_pci_driver );
4873
4972
if (err )
4874
- goto err_pci_driver_register ;
4973
+ goto err_sp2_pci_driver_register ;
4875
4974
4876
4975
return 0 ;
4877
4976
4878
- err_pci_driver_register :
4879
- mlxsw_core_driver_unregister (& mlxsw_sp_driver );
4880
- err_core_driver_register :
4977
+ err_sp2_pci_driver_register :
4978
+ mlxsw_pci_driver_unregister (& mlxsw_sp2_pci_driver );
4979
+ err_sp1_pci_driver_register :
4980
+ mlxsw_core_driver_unregister (& mlxsw_sp2_driver );
4981
+ err_sp2_core_driver_register :
4982
+ mlxsw_core_driver_unregister (& mlxsw_sp1_driver );
4983
+ err_sp1_core_driver_register :
4881
4984
unregister_inet6addr_notifier (& mlxsw_sp_inet6addr_nb );
4882
4985
unregister_inet6addr_validator_notifier (& mlxsw_sp_inet6addr_valid_nb );
4883
4986
unregister_inetaddr_notifier (& mlxsw_sp_inetaddr_nb );
@@ -4887,8 +4990,10 @@ static int __init mlxsw_sp_module_init(void)
4887
4990
4888
4991
static void __exit mlxsw_sp_module_exit (void )
4889
4992
{
4890
- mlxsw_pci_driver_unregister (& mlxsw_sp_pci_driver );
4891
- mlxsw_core_driver_unregister (& mlxsw_sp_driver );
4993
+ mlxsw_pci_driver_unregister (& mlxsw_sp2_pci_driver );
4994
+ mlxsw_pci_driver_unregister (& mlxsw_sp1_pci_driver );
4995
+ mlxsw_core_driver_unregister (& mlxsw_sp2_driver );
4996
+ mlxsw_core_driver_unregister (& mlxsw_sp1_driver );
4892
4997
unregister_inet6addr_notifier (& mlxsw_sp_inet6addr_nb );
4893
4998
unregister_inet6addr_validator_notifier (& mlxsw_sp_inet6addr_valid_nb );
4894
4999
unregister_inetaddr_notifier (& mlxsw_sp_inetaddr_nb );
@@ -4901,5 +5006,6 @@ module_exit(mlxsw_sp_module_exit);
4901
5006
MODULE_LICENSE ("Dual BSD/GPL" );
4902
5007
MODULE_AUTHOR (
"Jiri Pirko <[email protected] >" );
4903
5008
MODULE_DESCRIPTION ("Mellanox Spectrum driver" );
4904
- MODULE_DEVICE_TABLE (pci , mlxsw_sp_pci_id_table );
5009
+ MODULE_DEVICE_TABLE (pci , mlxsw_sp1_pci_id_table );
5010
+ MODULE_DEVICE_TABLE (pci , mlxsw_sp2_pci_id_table );
4905
5011
MODULE_FIRMWARE (MLXSW_SP1_FW_FILENAME );
0 commit comments