Commit e6d86938 authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

net/mlx5: DPLL, Use struct to get values from mlx5_dpll_synce_status_get()

Instead of passing separate args, introduce
struct mlx5_dpll_synce_status to hold the values obtained by
mlx5_dpll_synce_status_get().
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Acked-by: default avatarVadim Fedorenko <vadim.fedorenko@linux.dev>
Acked-by: default avatarArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Link: https://lore.kernel.org/r/20240103132838.1501801-3-jiri@resnulli.usSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8a6286c1
...@@ -36,11 +36,15 @@ static int mlx5_dpll_clock_id_get(struct mlx5_core_dev *mdev, u64 *clock_id) ...@@ -36,11 +36,15 @@ static int mlx5_dpll_clock_id_get(struct mlx5_core_dev *mdev, u64 *clock_id)
return 0; return 0;
} }
struct mlx5_dpll_synce_status {
enum mlx5_msees_admin_status admin_status;
enum mlx5_msees_oper_status oper_status;
bool ho_acq;
};
static int static int
mlx5_dpll_synce_status_get(struct mlx5_core_dev *mdev, mlx5_dpll_synce_status_get(struct mlx5_core_dev *mdev,
enum mlx5_msees_admin_status *admin_status, struct mlx5_dpll_synce_status *synce_status)
enum mlx5_msees_oper_status *oper_status,
bool *ho_acq)
{ {
u32 out[MLX5_ST_SZ_DW(msees_reg)] = {}; u32 out[MLX5_ST_SZ_DW(msees_reg)] = {};
u32 in[MLX5_ST_SZ_DW(msees_reg)] = {}; u32 in[MLX5_ST_SZ_DW(msees_reg)] = {};
...@@ -50,11 +54,9 @@ mlx5_dpll_synce_status_get(struct mlx5_core_dev *mdev, ...@@ -50,11 +54,9 @@ mlx5_dpll_synce_status_get(struct mlx5_core_dev *mdev,
MLX5_REG_MSEES, 0, 0); MLX5_REG_MSEES, 0, 0);
if (err) if (err)
return err; return err;
if (admin_status) synce_status->admin_status = MLX5_GET(msees_reg, out, admin_status);
*admin_status = MLX5_GET(msees_reg, out, admin_status); synce_status->oper_status = MLX5_GET(msees_reg, out, oper_status);
*oper_status = MLX5_GET(msees_reg, out, oper_status); synce_status->ho_acq = MLX5_GET(msees_reg, out, ho_acq);
if (ho_acq)
*ho_acq = MLX5_GET(msees_reg, out, ho_acq);
return 0; return 0;
} }
...@@ -74,13 +76,13 @@ mlx5_dpll_synce_status_set(struct mlx5_core_dev *mdev, ...@@ -74,13 +76,13 @@ mlx5_dpll_synce_status_set(struct mlx5_core_dev *mdev,
} }
static enum dpll_lock_status static enum dpll_lock_status
mlx5_dpll_lock_status_get(enum mlx5_msees_oper_status oper_status, bool ho_acq) mlx5_dpll_lock_status_get(struct mlx5_dpll_synce_status *synce_status)
{ {
switch (oper_status) { switch (synce_status->oper_status) {
case MLX5_MSEES_OPER_STATUS_SELF_TRACK: case MLX5_MSEES_OPER_STATUS_SELF_TRACK:
fallthrough; fallthrough;
case MLX5_MSEES_OPER_STATUS_OTHER_TRACK: case MLX5_MSEES_OPER_STATUS_OTHER_TRACK:
return ho_acq ? DPLL_LOCK_STATUS_LOCKED_HO_ACQ : return synce_status->ho_acq ? DPLL_LOCK_STATUS_LOCKED_HO_ACQ :
DPLL_LOCK_STATUS_LOCKED; DPLL_LOCK_STATUS_LOCKED;
case MLX5_MSEES_OPER_STATUS_HOLDOVER: case MLX5_MSEES_OPER_STATUS_HOLDOVER:
fallthrough; fallthrough;
...@@ -92,12 +94,11 @@ mlx5_dpll_lock_status_get(enum mlx5_msees_oper_status oper_status, bool ho_acq) ...@@ -92,12 +94,11 @@ mlx5_dpll_lock_status_get(enum mlx5_msees_oper_status oper_status, bool ho_acq)
} }
static enum dpll_pin_state static enum dpll_pin_state
mlx5_dpll_pin_state_get(enum mlx5_msees_admin_status admin_status, mlx5_dpll_pin_state_get(struct mlx5_dpll_synce_status *synce_status)
enum mlx5_msees_oper_status oper_status)
{ {
return (admin_status == MLX5_MSEES_ADMIN_STATUS_TRACK && return (synce_status->admin_status == MLX5_MSEES_ADMIN_STATUS_TRACK &&
(oper_status == MLX5_MSEES_OPER_STATUS_SELF_TRACK || (synce_status->oper_status == MLX5_MSEES_OPER_STATUS_SELF_TRACK ||
oper_status == MLX5_MSEES_OPER_STATUS_OTHER_TRACK)) ? synce_status->oper_status == MLX5_MSEES_OPER_STATUS_OTHER_TRACK)) ?
DPLL_PIN_STATE_CONNECTED : DPLL_PIN_STATE_DISCONNECTED; DPLL_PIN_STATE_CONNECTED : DPLL_PIN_STATE_DISCONNECTED;
} }
...@@ -106,17 +107,14 @@ static int mlx5_dpll_device_lock_status_get(const struct dpll_device *dpll, ...@@ -106,17 +107,14 @@ static int mlx5_dpll_device_lock_status_get(const struct dpll_device *dpll,
enum dpll_lock_status *status, enum dpll_lock_status *status,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
enum mlx5_msees_oper_status oper_status; struct mlx5_dpll_synce_status synce_status;
struct mlx5_dpll *mdpll = priv; struct mlx5_dpll *mdpll = priv;
bool ho_acq;
int err; int err;
err = mlx5_dpll_synce_status_get(mdpll->mdev, NULL, err = mlx5_dpll_synce_status_get(mdpll->mdev, &synce_status);
&oper_status, &ho_acq);
if (err) if (err)
return err; return err;
*status = mlx5_dpll_lock_status_get(&synce_status);
*status = mlx5_dpll_lock_status_get(oper_status, ho_acq);
return 0; return 0;
} }
...@@ -151,16 +149,14 @@ static int mlx5_dpll_state_on_dpll_get(const struct dpll_pin *pin, ...@@ -151,16 +149,14 @@ static int mlx5_dpll_state_on_dpll_get(const struct dpll_pin *pin,
enum dpll_pin_state *state, enum dpll_pin_state *state,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
enum mlx5_msees_admin_status admin_status; struct mlx5_dpll_synce_status synce_status;
enum mlx5_msees_oper_status oper_status;
struct mlx5_dpll *mdpll = pin_priv; struct mlx5_dpll *mdpll = pin_priv;
int err; int err;
err = mlx5_dpll_synce_status_get(mdpll->mdev, &admin_status, err = mlx5_dpll_synce_status_get(mdpll->mdev, &synce_status);
&oper_status, NULL);
if (err) if (err)
return err; return err;
*state = mlx5_dpll_pin_state_get(admin_status, oper_status); *state = mlx5_dpll_pin_state_get(&synce_status);
return 0; return 0;
} }
...@@ -202,19 +198,16 @@ static void mlx5_dpll_periodic_work(struct work_struct *work) ...@@ -202,19 +198,16 @@ static void mlx5_dpll_periodic_work(struct work_struct *work)
{ {
struct mlx5_dpll *mdpll = container_of(work, struct mlx5_dpll, struct mlx5_dpll *mdpll = container_of(work, struct mlx5_dpll,
work.work); work.work);
enum mlx5_msees_admin_status admin_status; struct mlx5_dpll_synce_status synce_status;
enum mlx5_msees_oper_status oper_status;
enum dpll_lock_status lock_status; enum dpll_lock_status lock_status;
enum dpll_pin_state pin_state; enum dpll_pin_state pin_state;
bool ho_acq;
int err; int err;
err = mlx5_dpll_synce_status_get(mdpll->mdev, &admin_status, err = mlx5_dpll_synce_status_get(mdpll->mdev, &synce_status);
&oper_status, &ho_acq);
if (err) if (err)
goto err_out; goto err_out;
lock_status = mlx5_dpll_lock_status_get(oper_status, ho_acq); lock_status = mlx5_dpll_lock_status_get(&synce_status);
pin_state = mlx5_dpll_pin_state_get(admin_status, oper_status); pin_state = mlx5_dpll_pin_state_get(&synce_status);
if (!mdpll->last.valid) if (!mdpll->last.valid)
goto invalid_out; goto invalid_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment