Skip to content

Commit a41b962

Browse files
pmachatadavem330
authored andcommitted
mlxsw: spectrum_buffers: Introduce shared buffer ops
The size of the internal buffer is currently calculated in the SPAN module. Logically it belongs to the spectrum_buffers module, where it should be moved. However, that being a chip-specific operation, it needs dynamic dispatch. There currently is a chip-specific structure for description of shared buffer values, struct mlxsw_sp_sb_vals. However placing ops into this structure would be confusing. Therefore introduce a new per-chip structure, currently empty, and initialize the ops pointer as appropriate. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0cda1a9 commit a41b962

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,6 +2697,7 @@ static int mlxsw_sp1_init(struct mlxsw_core *mlxsw_core,
26972697
mlxsw_sp->mac_mask = mlxsw_sp1_mac_mask;
26982698
mlxsw_sp->rif_ops_arr = mlxsw_sp1_rif_ops_arr;
26992699
mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals;
2700+
mlxsw_sp->sb_ops = &mlxsw_sp1_sb_ops;
27002701
mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops;
27012702
mlxsw_sp->ptp_ops = &mlxsw_sp1_ptp_ops;
27022703
mlxsw_sp->span_ops = &mlxsw_sp1_span_ops;
@@ -2725,6 +2726,7 @@ static int mlxsw_sp2_init(struct mlxsw_core *mlxsw_core,
27252726
mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask;
27262727
mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr;
27272728
mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals;
2729+
mlxsw_sp->sb_ops = &mlxsw_sp2_sb_ops;
27282730
mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops;
27292731
mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops;
27302732
mlxsw_sp->span_ops = &mlxsw_sp2_span_ops;
@@ -2751,6 +2753,7 @@ static int mlxsw_sp3_init(struct mlxsw_core *mlxsw_core,
27512753
mlxsw_sp->mac_mask = mlxsw_sp2_mac_mask;
27522754
mlxsw_sp->rif_ops_arr = mlxsw_sp2_rif_ops_arr;
27532755
mlxsw_sp->sb_vals = &mlxsw_sp2_sb_vals;
2756+
mlxsw_sp->sb_ops = &mlxsw_sp3_sb_ops;
27542757
mlxsw_sp->port_type_speed_ops = &mlxsw_sp2_port_type_speed_ops;
27552758
mlxsw_sp->ptp_ops = &mlxsw_sp2_ptp_ops;
27562759
mlxsw_sp->span_ops = &mlxsw_sp3_span_ops;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct mlxsw_sp_mr_tcam_ops;
125125
struct mlxsw_sp_acl_rulei_ops;
126126
struct mlxsw_sp_acl_tcam_ops;
127127
struct mlxsw_sp_nve_ops;
128+
struct mlxsw_sp_sb_ops;
128129
struct mlxsw_sp_sb_vals;
129130
struct mlxsw_sp_port_type_speed_ops;
130131
struct mlxsw_sp_ptp_state;
@@ -171,6 +172,7 @@ struct mlxsw_sp {
171172
const struct mlxsw_sp_nve_ops **nve_ops_arr;
172173
const struct mlxsw_sp_rif_ops **rif_ops_arr;
173174
const struct mlxsw_sp_sb_vals *sb_vals;
175+
const struct mlxsw_sp_sb_ops *sb_ops;
174176
const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
175177
const struct mlxsw_sp_ptp_ops *ptp_ops;
176178
const struct mlxsw_sp_span_ops *span_ops;
@@ -514,6 +516,10 @@ int mlxsw_sp_hdroom_configure(struct mlxsw_sp_port *mlxsw_sp_port,
514516
extern const struct mlxsw_sp_sb_vals mlxsw_sp1_sb_vals;
515517
extern const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals;
516518

519+
extern const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops;
520+
extern const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops;
521+
extern const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops;
522+
517523
/* spectrum_switchdev.c */
518524
int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
519525
void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ struct mlxsw_sp_sb_vals {
121121
unsigned int cms_cpu_count;
122122
};
123123

124+
struct mlxsw_sp_sb_ops {
125+
};
126+
124127
u32 mlxsw_sp_cells_bytes(const struct mlxsw_sp *mlxsw_sp, u32 cells)
125128
{
126129
return mlxsw_sp->sb->cell_size * cells;
@@ -1101,6 +1104,15 @@ const struct mlxsw_sp_sb_vals mlxsw_sp2_sb_vals = {
11011104
.cms_cpu_count = ARRAY_SIZE(mlxsw_sp_cpu_port_sb_cms),
11021105
};
11031106

1107+
const struct mlxsw_sp_sb_ops mlxsw_sp1_sb_ops = {
1108+
};
1109+
1110+
const struct mlxsw_sp_sb_ops mlxsw_sp2_sb_ops = {
1111+
};
1112+
1113+
const struct mlxsw_sp_sb_ops mlxsw_sp3_sb_ops = {
1114+
};
1115+
11041116
int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp)
11051117
{
11061118
u32 max_headroom_size;

0 commit comments

Comments
 (0)