Skip to content

Commit ac9cc4e

Browse files
jpirkodavem330
authored andcommitted
mlxsw: spectrum: Push code getting port speed into a helper
Currently PTP code queries directly PTYS register for port speed from work scheduled upon PUDE event. Since the speed needs to be used for SPAN buffer size computation as well, push the code into a separate helper. Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 794eee2 commit ac9cc4e

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,27 @@ mlxsw_sp_port_speed_by_width_set(struct mlxsw_sp_port *mlxsw_sp_port)
35353535
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
35363536
}
35373537

3538+
int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed)
3539+
{
3540+
const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
3541+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
3542+
char ptys_pl[MLXSW_REG_PTYS_LEN];
3543+
u32 eth_proto_oper;
3544+
int err;
3545+
3546+
port_type_speed_ops = mlxsw_sp->port_type_speed_ops;
3547+
port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl,
3548+
mlxsw_sp_port->local_port, 0,
3549+
false);
3550+
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
3551+
if (err)
3552+
return err;
3553+
port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL,
3554+
&eth_proto_oper);
3555+
*speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper);
3556+
return 0;
3557+
}
3558+
35383559
int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
35393560
enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
35403561
bool dwrr, u8 dwrr_weight)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ extern struct notifier_block mlxsw_sp_switchdev_notifier;
471471
/* spectrum.c */
472472
void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
473473
u8 local_port, void *priv);
474+
int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
474475
int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
475476
enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
476477
bool dwrr, u8 dwrr_weight);

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,27 +1016,17 @@ mlxsw_sp1_ptp_port_shaper_set(struct mlxsw_sp_port *mlxsw_sp_port, bool enable)
10161016

10171017
static int mlxsw_sp1_ptp_port_shaper_check(struct mlxsw_sp_port *mlxsw_sp_port)
10181018
{
1019-
const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
1020-
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
1021-
char ptys_pl[MLXSW_REG_PTYS_LEN];
1022-
u32 eth_proto_oper, speed;
10231019
bool ptps = false;
10241020
int err, i;
1021+
u32 speed;
10251022

10261023
if (!mlxsw_sp1_ptp_hwtstamp_enabled(mlxsw_sp_port))
10271024
return mlxsw_sp1_ptp_port_shaper_set(mlxsw_sp_port, false);
10281025

1029-
port_type_speed_ops = mlxsw_sp->port_type_speed_ops;
1030-
port_type_speed_ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl,
1031-
mlxsw_sp_port->local_port, 0,
1032-
false);
1033-
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
1026+
err = mlxsw_sp_port_speed_get(mlxsw_sp_port, &speed);
10341027
if (err)
10351028
return err;
1036-
port_type_speed_ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, NULL, NULL,
1037-
&eth_proto_oper);
10381029

1039-
speed = port_type_speed_ops->from_ptys_speed(mlxsw_sp, eth_proto_oper);
10401030
for (i = 0; i < MLXSW_SP1_PTP_SHAPER_PARAMS_LEN; i++) {
10411031
if (mlxsw_sp1_ptp_shaper_params[i].ethtool_speed == speed) {
10421032
ptps = true;

0 commit comments

Comments
 (0)