Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mlxsw: Add struct mlxsw_sp_switchdev_ops per ASIC

A subsequent patch will need to implement different set of operations
when a port joins / leaves an 802.1ad bridge, based on the ASIC type.

Prepare for this change by allowing to initialize the bridge module
based on the ASIC type via 'struct mlxsw_sp_switchdev_ops'.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Amit Cohen and committed by
David S. Miller
0f74fa56 114a465d

+31
+3
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
··· 2925 2925 { 2926 2926 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); 2927 2927 2928 + mlxsw_sp->switchdev_ops = &mlxsw_sp1_switchdev_ops; 2928 2929 mlxsw_sp->kvdl_ops = &mlxsw_sp1_kvdl_ops; 2929 2930 mlxsw_sp->afa_ops = &mlxsw_sp1_act_afa_ops; 2930 2931 mlxsw_sp->afk_ops = &mlxsw_sp1_afk_ops; ··· 2956 2955 { 2957 2956 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); 2958 2957 2958 + mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; 2959 2959 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; 2960 2960 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; 2961 2961 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops; ··· 2985 2983 { 2986 2984 struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core); 2987 2985 2986 + mlxsw_sp->switchdev_ops = &mlxsw_sp2_switchdev_ops; 2988 2987 mlxsw_sp->kvdl_ops = &mlxsw_sp2_kvdl_ops; 2989 2988 mlxsw_sp->afa_ops = &mlxsw_sp2_act_afa_ops; 2990 2989 mlxsw_sp->afk_ops = &mlxsw_sp2_afk_ops;
+6
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
··· 92 92 extern const struct mlxsw_sp_rif_ops *mlxsw_sp1_rif_ops_arr[]; 93 93 extern const struct mlxsw_sp_rif_ops *mlxsw_sp2_rif_ops_arr[]; 94 94 95 + struct mlxsw_sp_switchdev_ops; 96 + 97 + extern const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops; 98 + extern const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops; 99 + 95 100 enum mlxsw_sp_fid_type { 96 101 MLXSW_SP_FID_TYPE_8021Q, 97 102 MLXSW_SP_FID_TYPE_8021D, ··· 172 167 struct mlxsw_sp_counter_pool *counter_pool; 173 168 struct mlxsw_sp_span *span; 174 169 struct mlxsw_sp_trap *trap; 170 + const struct mlxsw_sp_switchdev_ops *switchdev_ops; 175 171 const struct mlxsw_sp_kvdl_ops *kvdl_ops; 176 172 const struct mlxsw_afa_ops *afa_ops; 177 173 const struct mlxsw_afk_ops *afk_ops;
+22
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
··· 98 98 const struct mlxsw_sp_fid *fid); 99 99 }; 100 100 101 + struct mlxsw_sp_switchdev_ops { 102 + void (*init)(struct mlxsw_sp *mlxsw_sp); 103 + }; 104 + 101 105 static int 102 106 mlxsw_sp_bridge_port_fdb_flush(struct mlxsw_sp *mlxsw_sp, 103 107 struct mlxsw_sp_bridge_port *bridge_port, ··· 3539 3535 unregister_switchdev_notifier(&mlxsw_sp_switchdev_notifier); 3540 3536 } 3541 3537 3538 + static void mlxsw_sp1_switchdev_init(struct mlxsw_sp *mlxsw_sp) 3539 + { 3540 + } 3541 + 3542 + const struct mlxsw_sp_switchdev_ops mlxsw_sp1_switchdev_ops = { 3543 + .init = mlxsw_sp1_switchdev_init, 3544 + }; 3545 + 3546 + static void mlxsw_sp2_switchdev_init(struct mlxsw_sp *mlxsw_sp) 3547 + { 3548 + } 3549 + 3550 + const struct mlxsw_sp_switchdev_ops mlxsw_sp2_switchdev_ops = { 3551 + .init = mlxsw_sp2_switchdev_init, 3552 + }; 3553 + 3542 3554 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp) 3543 3555 { 3544 3556 struct mlxsw_sp_bridge *bridge; ··· 3570 3550 bridge->bridge_8021q_ops = &mlxsw_sp_bridge_8021q_ops; 3571 3551 bridge->bridge_8021d_ops = &mlxsw_sp_bridge_8021d_ops; 3572 3552 bridge->bridge_8021ad_ops = &mlxsw_sp_bridge_8021ad_ops; 3553 + 3554 + mlxsw_sp->switchdev_ops->init(mlxsw_sp); 3573 3555 3574 3556 return mlxsw_sp_fdb_init(mlxsw_sp); 3575 3557 }