spectrum.c (58723d2f77717373d44721a2c65f8af5917102b7) | spectrum.c (4735402173e6eed18d7e04cfc4bc358d8b2965db) |
---|---|
1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 2/* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 3 4#include <linux/kernel.h> 5#include <linux/module.h> 6#include <linux/types.h> 7#include <linux/pci.h> 8#include <linux/netdevice.h> --- 81 unchanged lines hidden (view full) --- 90#define MLXSW_SP3_FW_FILENAME \ 91 "mellanox/mlxsw_spectrum3-" __stringify(MLXSW_SP3_FWREV_MAJOR) \ 92 "." __stringify(MLXSW_SP3_FWREV_MINOR) \ 93 "." __stringify(MLXSW_SP3_FWREV_SUBMINOR) ".mfa2" 94 95static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum"; 96static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2"; 97static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3"; | 1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 2/* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */ 3 4#include <linux/kernel.h> 5#include <linux/module.h> 6#include <linux/types.h> 7#include <linux/pci.h> 8#include <linux/netdevice.h> --- 81 unchanged lines hidden (view full) --- 90#define MLXSW_SP3_FW_FILENAME \ 91 "mellanox/mlxsw_spectrum3-" __stringify(MLXSW_SP3_FWREV_MAJOR) \ 92 "." __stringify(MLXSW_SP3_FWREV_MINOR) \ 93 "." __stringify(MLXSW_SP3_FWREV_SUBMINOR) ".mfa2" 94 95static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum"; 96static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2"; 97static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3"; |
98static const char mlxsw_sp4_driver_name[] = "mlxsw_spectrum4"; |
|
98 99static const unsigned char mlxsw_sp1_mac_mask[ETH_ALEN] = { 100 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00 101}; 102static const unsigned char mlxsw_sp2_mac_mask[ETH_ALEN] = { 103 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00 104}; 105 --- 3091 unchanged lines hidden (view full) --- 3197 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; 3198 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; 3199 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; 3200 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3; 3201 3202 return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack); 3203} 3204 | 99 100static const unsigned char mlxsw_sp1_mac_mask[ETH_ALEN] = { 101 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00 102}; 103static const unsigned char mlxsw_sp2_mac_mask[ETH_ALEN] = { 104 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00 105}; 106 --- 3091 unchanged lines hidden (view full) --- 3198 mlxsw_sp->trap_ops = &mlxsw_sp2_trap_ops; 3199 mlxsw_sp->mall_ops = &mlxsw_sp2_mall_ops; 3200 mlxsw_sp->router_ops = &mlxsw_sp2_router_ops; 3201 mlxsw_sp->lowest_shaper_bs = MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3; 3202 3203 return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info, extack); 3204} 3205 |
3206static 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 |
|
3205static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) 3206{ 3207 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); 3208 3209 mlxsw_sp_ports_remove(mlxsw_sp); 3210 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); 3211 mlxsw_sp_port_module_info_fini(mlxsw_sp); 3212 mlxsw_sp_dpipe_fini(mlxsw_sp); --- 543 unchanged lines hidden (view full) --- 3756 .ptp_transmitted = mlxsw_sp_ptp_transmitted, 3757 .txhdr_len = MLXSW_TXHDR_LEN, 3758 .profile = &mlxsw_sp2_config_profile, 3759 .res_query_enabled = true, 3760 .fw_fatal_enabled = true, 3761 .temp_warn_enabled = true, 3762}; 3763 | 3236static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) 3237{ 3238 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); 3239 3240 mlxsw_sp_ports_remove(mlxsw_sp); 3241 rhashtable_destroy(&mlxsw_sp->sample_trigger_ht); 3242 mlxsw_sp_port_module_info_fini(mlxsw_sp); 3243 mlxsw_sp_dpipe_fini(mlxsw_sp); --- 543 unchanged lines hidden (view full) --- 3787 .ptp_transmitted = mlxsw_sp_ptp_transmitted, 3788 .txhdr_len = MLXSW_TXHDR_LEN, 3789 .profile = &mlxsw_sp2_config_profile, 3790 .res_query_enabled = true, 3791 .fw_fatal_enabled = true, 3792 .temp_warn_enabled = true, 3793}; 3794 |
3795static 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 |
|
3764bool mlxsw_sp_port_dev_check(const struct net_device *dev) 3765{ 3766 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops; 3767} 3768 3769static int mlxsw_sp_lower_dev_walk(struct net_device *lower_dev, 3770 struct netdev_nested_priv *priv) 3771{ --- 1151 unchanged lines hidden (view full) --- 4923 {0, }, 4924}; 4925 4926static struct pci_driver mlxsw_sp3_pci_driver = { 4927 .name = mlxsw_sp3_driver_name, 4928 .id_table = mlxsw_sp3_pci_id_table, 4929}; 4930 | 3834bool mlxsw_sp_port_dev_check(const struct net_device *dev) 3835{ 3836 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops; 3837} 3838 3839static int mlxsw_sp_lower_dev_walk(struct net_device *lower_dev, 3840 struct netdev_nested_priv *priv) 3841{ --- 1151 unchanged lines hidden (view full) --- 4993 {0, }, 4994}; 4995 4996static struct pci_driver mlxsw_sp3_pci_driver = { 4997 .name = mlxsw_sp3_driver_name, 4998 .id_table = mlxsw_sp3_pci_id_table, 4999}; 5000 |
5001static const struct pci_device_id mlxsw_sp4_pci_id_table[] = { 5002 {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM4), 0}, 5003 {0, }, 5004}; 5005 5006static struct pci_driver mlxsw_sp4_pci_driver = { 5007 .name = mlxsw_sp4_driver_name, 5008 .id_table = mlxsw_sp4_pci_id_table, 5009}; 5010 |
|
4931static int __init mlxsw_sp_module_init(void) 4932{ 4933 int err; 4934 4935 register_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb); 4936 register_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb); 4937 4938 err = mlxsw_core_driver_register(&mlxsw_sp1_driver); 4939 if (err) 4940 goto err_sp1_core_driver_register; 4941 4942 err = mlxsw_core_driver_register(&mlxsw_sp2_driver); 4943 if (err) 4944 goto err_sp2_core_driver_register; 4945 4946 err = mlxsw_core_driver_register(&mlxsw_sp3_driver); 4947 if (err) 4948 goto err_sp3_core_driver_register; 4949 | 5011static int __init mlxsw_sp_module_init(void) 5012{ 5013 int err; 5014 5015 register_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb); 5016 register_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb); 5017 5018 err = mlxsw_core_driver_register(&mlxsw_sp1_driver); 5019 if (err) 5020 goto err_sp1_core_driver_register; 5021 5022 err = mlxsw_core_driver_register(&mlxsw_sp2_driver); 5023 if (err) 5024 goto err_sp2_core_driver_register; 5025 5026 err = mlxsw_core_driver_register(&mlxsw_sp3_driver); 5027 if (err) 5028 goto err_sp3_core_driver_register; 5029 |
5030 err = mlxsw_core_driver_register(&mlxsw_sp4_driver); 5031 if (err) 5032 goto err_sp4_core_driver_register; 5033 |
|
4950 err = mlxsw_pci_driver_register(&mlxsw_sp1_pci_driver); 4951 if (err) 4952 goto err_sp1_pci_driver_register; 4953 4954 err = mlxsw_pci_driver_register(&mlxsw_sp2_pci_driver); 4955 if (err) 4956 goto err_sp2_pci_driver_register; 4957 4958 err = mlxsw_pci_driver_register(&mlxsw_sp3_pci_driver); 4959 if (err) 4960 goto err_sp3_pci_driver_register; 4961 | 5034 err = mlxsw_pci_driver_register(&mlxsw_sp1_pci_driver); 5035 if (err) 5036 goto err_sp1_pci_driver_register; 5037 5038 err = mlxsw_pci_driver_register(&mlxsw_sp2_pci_driver); 5039 if (err) 5040 goto err_sp2_pci_driver_register; 5041 5042 err = mlxsw_pci_driver_register(&mlxsw_sp3_pci_driver); 5043 if (err) 5044 goto err_sp3_pci_driver_register; 5045 |
5046 err = mlxsw_pci_driver_register(&mlxsw_sp4_pci_driver); 5047 if (err) 5048 goto err_sp4_pci_driver_register; 5049 |
|
4962 return 0; 4963 | 5050 return 0; 5051 |
5052err_sp4_pci_driver_register: 5053 mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver); |
|
4964err_sp3_pci_driver_register: 4965 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver); 4966err_sp2_pci_driver_register: 4967 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver); 4968err_sp1_pci_driver_register: | 5054err_sp3_pci_driver_register: 5055 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver); 5056err_sp2_pci_driver_register: 5057 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver); 5058err_sp1_pci_driver_register: |
5059 mlxsw_core_driver_unregister(&mlxsw_sp4_driver); 5060err_sp4_core_driver_register: |
|
4969 mlxsw_core_driver_unregister(&mlxsw_sp3_driver); 4970err_sp3_core_driver_register: 4971 mlxsw_core_driver_unregister(&mlxsw_sp2_driver); 4972err_sp2_core_driver_register: 4973 mlxsw_core_driver_unregister(&mlxsw_sp1_driver); 4974err_sp1_core_driver_register: 4975 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb); 4976 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb); 4977 return err; 4978} 4979 4980static void __exit mlxsw_sp_module_exit(void) 4981{ | 5061 mlxsw_core_driver_unregister(&mlxsw_sp3_driver); 5062err_sp3_core_driver_register: 5063 mlxsw_core_driver_unregister(&mlxsw_sp2_driver); 5064err_sp2_core_driver_register: 5065 mlxsw_core_driver_unregister(&mlxsw_sp1_driver); 5066err_sp1_core_driver_register: 5067 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb); 5068 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb); 5069 return err; 5070} 5071 5072static void __exit mlxsw_sp_module_exit(void) 5073{ |
5074 mlxsw_pci_driver_unregister(&mlxsw_sp4_pci_driver); |
|
4982 mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver); 4983 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver); 4984 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver); | 5075 mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver); 5076 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver); 5077 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver); |
5078 mlxsw_core_driver_unregister(&mlxsw_sp4_driver); |
|
4985 mlxsw_core_driver_unregister(&mlxsw_sp3_driver); 4986 mlxsw_core_driver_unregister(&mlxsw_sp2_driver); 4987 mlxsw_core_driver_unregister(&mlxsw_sp1_driver); 4988 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb); 4989 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb); 4990} 4991 4992module_init(mlxsw_sp_module_init); 4993module_exit(mlxsw_sp_module_exit); 4994 4995MODULE_LICENSE("Dual BSD/GPL"); 4996MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>"); 4997MODULE_DESCRIPTION("Mellanox Spectrum driver"); 4998MODULE_DEVICE_TABLE(pci, mlxsw_sp1_pci_id_table); 4999MODULE_DEVICE_TABLE(pci, mlxsw_sp2_pci_id_table); 5000MODULE_DEVICE_TABLE(pci, mlxsw_sp3_pci_id_table); | 5079 mlxsw_core_driver_unregister(&mlxsw_sp3_driver); 5080 mlxsw_core_driver_unregister(&mlxsw_sp2_driver); 5081 mlxsw_core_driver_unregister(&mlxsw_sp1_driver); 5082 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb); 5083 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb); 5084} 5085 5086module_init(mlxsw_sp_module_init); 5087module_exit(mlxsw_sp_module_exit); 5088 5089MODULE_LICENSE("Dual BSD/GPL"); 5090MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>"); 5091MODULE_DESCRIPTION("Mellanox Spectrum driver"); 5092MODULE_DEVICE_TABLE(pci, mlxsw_sp1_pci_id_table); 5093MODULE_DEVICE_TABLE(pci, mlxsw_sp2_pci_id_table); 5094MODULE_DEVICE_TABLE(pci, mlxsw_sp3_pci_id_table); |
5095MODULE_DEVICE_TABLE(pci, mlxsw_sp4_pci_id_table); |
|
5001MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME); 5002MODULE_FIRMWARE(MLXSW_SP2_FW_FILENAME); 5003MODULE_FIRMWARE(MLXSW_SP3_FW_FILENAME); | 5096MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME); 5097MODULE_FIRMWARE(MLXSW_SP2_FW_FILENAME); 5098MODULE_FIRMWARE(MLXSW_SP3_FW_FILENAME); |