spectrum.c (13dfb3fa494361ea9a5950f27c9cd8b06d28c04f) spectrum.c (da382875c616856b234790206fc80d51f66b3bc7)
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>

--- 51 unchanged lines hidden (view full) ---

60
61#define MLXSW_SP1_FW_FILENAME \
62 "mellanox/mlxsw_spectrum-" __stringify(MLXSW_SP1_FWREV_MAJOR) \
63 "." __stringify(MLXSW_SP1_FWREV_MINOR) \
64 "." __stringify(MLXSW_SP1_FWREV_SUBMINOR) ".mfa2"
65
66static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum";
67static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2";
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>

--- 51 unchanged lines hidden (view full) ---

60
61#define MLXSW_SP1_FW_FILENAME \
62 "mellanox/mlxsw_spectrum-" __stringify(MLXSW_SP1_FWREV_MAJOR) \
63 "." __stringify(MLXSW_SP1_FWREV_MINOR) \
64 "." __stringify(MLXSW_SP1_FWREV_SUBMINOR) ".mfa2"
65
66static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum";
67static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2";
68static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3";
68static const char mlxsw_sp_driver_version[] = "1.0";
69
70static const unsigned char mlxsw_sp1_mac_mask[ETH_ALEN] = {
71 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00
72};
73static const unsigned char mlxsw_sp2_mac_mask[ETH_ALEN] = {
74 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00
75};

--- 5209 unchanged lines hidden (view full) ---

5285 .params_register = mlxsw_sp2_params_register,
5286 .params_unregister = mlxsw_sp2_params_unregister,
5287 .ptp_transmitted = mlxsw_sp_ptp_transmitted,
5288 .txhdr_len = MLXSW_TXHDR_LEN,
5289 .profile = &mlxsw_sp2_config_profile,
5290 .res_query_enabled = true,
5291};
5292
69static const char mlxsw_sp_driver_version[] = "1.0";
70
71static const unsigned char mlxsw_sp1_mac_mask[ETH_ALEN] = {
72 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00
73};
74static const unsigned char mlxsw_sp2_mac_mask[ETH_ALEN] = {
75 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00
76};

--- 5209 unchanged lines hidden (view full) ---

5286 .params_register = mlxsw_sp2_params_register,
5287 .params_unregister = mlxsw_sp2_params_unregister,
5288 .ptp_transmitted = mlxsw_sp_ptp_transmitted,
5289 .txhdr_len = MLXSW_TXHDR_LEN,
5290 .profile = &mlxsw_sp2_config_profile,
5291 .res_query_enabled = true,
5292};
5293
5294static struct mlxsw_driver mlxsw_sp3_driver = {
5295 .kind = mlxsw_sp3_driver_name,
5296 .priv_size = sizeof(struct mlxsw_sp),
5297 .init = mlxsw_sp2_init,
5298 .fini = mlxsw_sp_fini,
5299 .basic_trap_groups_set = mlxsw_sp_basic_trap_groups_set,
5300 .port_split = mlxsw_sp_port_split,
5301 .port_unsplit = mlxsw_sp_port_unsplit,
5302 .sb_pool_get = mlxsw_sp_sb_pool_get,
5303 .sb_pool_set = mlxsw_sp_sb_pool_set,
5304 .sb_port_pool_get = mlxsw_sp_sb_port_pool_get,
5305 .sb_port_pool_set = mlxsw_sp_sb_port_pool_set,
5306 .sb_tc_pool_bind_get = mlxsw_sp_sb_tc_pool_bind_get,
5307 .sb_tc_pool_bind_set = mlxsw_sp_sb_tc_pool_bind_set,
5308 .sb_occ_snapshot = mlxsw_sp_sb_occ_snapshot,
5309 .sb_occ_max_clear = mlxsw_sp_sb_occ_max_clear,
5310 .sb_occ_port_pool_get = mlxsw_sp_sb_occ_port_pool_get,
5311 .sb_occ_tc_port_bind_get = mlxsw_sp_sb_occ_tc_port_bind_get,
5312 .flash_update = mlxsw_sp_flash_update,
5313 .txhdr_construct = mlxsw_sp_txhdr_construct,
5314 .resources_register = mlxsw_sp2_resources_register,
5315 .params_register = mlxsw_sp2_params_register,
5316 .params_unregister = mlxsw_sp2_params_unregister,
5317 .ptp_transmitted = mlxsw_sp_ptp_transmitted,
5318 .txhdr_len = MLXSW_TXHDR_LEN,
5319 .profile = &mlxsw_sp2_config_profile,
5320 .res_query_enabled = true,
5321};
5322
5293bool mlxsw_sp_port_dev_check(const struct net_device *dev)
5294{
5295 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops;
5296}
5297
5298static int mlxsw_sp_lower_dev_walk(struct net_device *lower_dev, void *data)
5299{
5300 struct mlxsw_sp_port **p_mlxsw_sp_port = data;

--- 1018 unchanged lines hidden (view full) ---

6319 {0, },
6320};
6321
6322static struct pci_driver mlxsw_sp2_pci_driver = {
6323 .name = mlxsw_sp2_driver_name,
6324 .id_table = mlxsw_sp2_pci_id_table,
6325};
6326
5323bool mlxsw_sp_port_dev_check(const struct net_device *dev)
5324{
5325 return dev->netdev_ops == &mlxsw_sp_port_netdev_ops;
5326}
5327
5328static int mlxsw_sp_lower_dev_walk(struct net_device *lower_dev, void *data)
5329{
5330 struct mlxsw_sp_port **p_mlxsw_sp_port = data;

--- 1018 unchanged lines hidden (view full) ---

6349 {0, },
6350};
6351
6352static struct pci_driver mlxsw_sp2_pci_driver = {
6353 .name = mlxsw_sp2_driver_name,
6354 .id_table = mlxsw_sp2_pci_id_table,
6355};
6356
6357static const struct pci_device_id mlxsw_sp3_pci_id_table[] = {
6358 {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM3), 0},
6359 {0, },
6360};
6361
6362static struct pci_driver mlxsw_sp3_pci_driver = {
6363 .name = mlxsw_sp3_driver_name,
6364 .id_table = mlxsw_sp3_pci_id_table,
6365};
6366
6327static int __init mlxsw_sp_module_init(void)
6328{
6329 int err;
6330
6331 register_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
6332 register_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
6333
6334 err = mlxsw_core_driver_register(&mlxsw_sp1_driver);
6335 if (err)
6336 goto err_sp1_core_driver_register;
6337
6338 err = mlxsw_core_driver_register(&mlxsw_sp2_driver);
6339 if (err)
6340 goto err_sp2_core_driver_register;
6341
6367static int __init mlxsw_sp_module_init(void)
6368{
6369 int err;
6370
6371 register_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
6372 register_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
6373
6374 err = mlxsw_core_driver_register(&mlxsw_sp1_driver);
6375 if (err)
6376 goto err_sp1_core_driver_register;
6377
6378 err = mlxsw_core_driver_register(&mlxsw_sp2_driver);
6379 if (err)
6380 goto err_sp2_core_driver_register;
6381
6382 err = mlxsw_core_driver_register(&mlxsw_sp3_driver);
6383 if (err)
6384 goto err_sp3_core_driver_register;
6385
6342 err = mlxsw_pci_driver_register(&mlxsw_sp1_pci_driver);
6343 if (err)
6344 goto err_sp1_pci_driver_register;
6345
6346 err = mlxsw_pci_driver_register(&mlxsw_sp2_pci_driver);
6347 if (err)
6348 goto err_sp2_pci_driver_register;
6349
6386 err = mlxsw_pci_driver_register(&mlxsw_sp1_pci_driver);
6387 if (err)
6388 goto err_sp1_pci_driver_register;
6389
6390 err = mlxsw_pci_driver_register(&mlxsw_sp2_pci_driver);
6391 if (err)
6392 goto err_sp2_pci_driver_register;
6393
6394 err = mlxsw_pci_driver_register(&mlxsw_sp3_pci_driver);
6395 if (err)
6396 goto err_sp3_pci_driver_register;
6397
6350 return 0;
6351
6398 return 0;
6399
6400err_sp3_pci_driver_register:
6401 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver);
6352err_sp2_pci_driver_register:
6353 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver);
6354err_sp1_pci_driver_register:
6402err_sp2_pci_driver_register:
6403 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver);
6404err_sp1_pci_driver_register:
6405 mlxsw_core_driver_unregister(&mlxsw_sp3_driver);
6406err_sp3_core_driver_register:
6355 mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
6356err_sp2_core_driver_register:
6357 mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
6358err_sp1_core_driver_register:
6359 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
6360 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
6361 return err;
6362}
6363
6364static void __exit mlxsw_sp_module_exit(void)
6365{
6407 mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
6408err_sp2_core_driver_register:
6409 mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
6410err_sp1_core_driver_register:
6411 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
6412 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
6413 return err;
6414}
6415
6416static void __exit mlxsw_sp_module_exit(void)
6417{
6418 mlxsw_pci_driver_unregister(&mlxsw_sp3_pci_driver);
6366 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver);
6367 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver);
6419 mlxsw_pci_driver_unregister(&mlxsw_sp2_pci_driver);
6420 mlxsw_pci_driver_unregister(&mlxsw_sp1_pci_driver);
6421 mlxsw_core_driver_unregister(&mlxsw_sp3_driver);
6368 mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
6369 mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
6370 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
6371 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
6372}
6373
6374module_init(mlxsw_sp_module_init);
6375module_exit(mlxsw_sp_module_exit);
6376
6377MODULE_LICENSE("Dual BSD/GPL");
6378MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>");
6379MODULE_DESCRIPTION("Mellanox Spectrum driver");
6380MODULE_DEVICE_TABLE(pci, mlxsw_sp1_pci_id_table);
6381MODULE_DEVICE_TABLE(pci, mlxsw_sp2_pci_id_table);
6422 mlxsw_core_driver_unregister(&mlxsw_sp2_driver);
6423 mlxsw_core_driver_unregister(&mlxsw_sp1_driver);
6424 unregister_inet6addr_validator_notifier(&mlxsw_sp_inet6addr_valid_nb);
6425 unregister_inetaddr_validator_notifier(&mlxsw_sp_inetaddr_valid_nb);
6426}
6427
6428module_init(mlxsw_sp_module_init);
6429module_exit(mlxsw_sp_module_exit);
6430
6431MODULE_LICENSE("Dual BSD/GPL");
6432MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>");
6433MODULE_DESCRIPTION("Mellanox Spectrum driver");
6434MODULE_DEVICE_TABLE(pci, mlxsw_sp1_pci_id_table);
6435MODULE_DEVICE_TABLE(pci, mlxsw_sp2_pci_id_table);
6436MODULE_DEVICE_TABLE(pci, mlxsw_sp3_pci_id_table);
6382MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME);
6437MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME);