dpll: expose lock status error value to user
Subsystems (9)
Jiri Pirko
maintainerv2 cover dpll: expose lock status error value to user
From: Jiri Pirko <[email protected]>
Allow to expose lock status errort value over new DPLL generic netlink attribute. Extend the lock_status_get() op by new argument to get the value from the driver. Implement this new argument fill-up in mlx5 driver.
Jiri Pirko (3):
dpll: extend uapi by lock status error attribute
dpll: extend lock_status_get() op by status error and expose to user net/mlx5: DPLL, Implement lock status error value
Documentation/netlink/specs/dpll.yaml | 39 +++++++++++++++++++ drivers/dpll/dpll_netlink.c | 9 ++++- drivers/net/ethernet/intel/ice/ice_dpll.c | 2 + .../net/ethernet/mellanox/mlx5/core/dpll.c | 32 +++++++++++++-- drivers/ptp/ptp_ocp.c | 9 +++-- include/linux/dpll.h | 1 + include/linux/mlx5/mlx5_ifc.h | 8 ++++ include/uapi/linux/dpll.h | 30 ++++++++++++++ 8 files changed, 121 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0
Jiri Pirko
maintainerPATCH v2 1/3 dpll: extend uapi by lock status error attribute
From: Jiri Pirko <[email protected]>
If the dpll devices goes to state "unlocked" or "holdover", it may be caused by an error. In that case, allow user to see what the error was. Introduce a new attribute and values it can carry.
--- Documentation/netlink/specs/dpll.yaml | 39 +++++++++++++++++++++++++++ include/uapi/linux/dpll.h | 30 +++++++++++++++++++++ 2 files changed, 69 insertions(+)
Documentation/netlink/specs/dpll.yaml +39 -0
@@ -51,6 +51,40 @@ definitions: if dpll lock-state was not DPLL_LOCK_STATUS_LOCKED_HO_ACQ, the dpll's lock-state shall remain DPLL_LOCK_STATUS_UNLOCKED) render-max: true + - + type: enum + name: lock-status-error + doc: | + if previous status change was done due to a failure, this provides + information of dpll device lock status error. + Valid values for DPLL_A_LOCK_STATUS_ERROR attribute + entries: + - + name: none + doc: | + dpll device lock status was changed without any error + value: 1 + - + name: undefined + doc: | + dpll device lock status was changed due to undefined error. + Driver fills this value up in case it is not able + to obtain suitable exact error type. + - + name: media-down + doc: | + dpll device lock status was changed because of associated + media got down. + This may happen for example if dpll device was previously + locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT. + - + name: fractional-frequency-offset-too-high + doc: | + the FFO (Fractional Frequency Offset) between the RX and TX + symbol rate on the media got too high. + This may happen for example if dpll device was previously + locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT. + render-max: true - type: const name: temp-divider
@@ -214,6 +248,10 @@ attribute-sets: name: type type: u32 enum: type + - + name: lock-status-error + type: u32 + enum: lock-status-error - name: pin enum-name: dpll_a_pin
@@ -379,6 +417,7 @@ operations: - mode - mode-supported - lock-status + - lock-status-error - temp - clock-id - type
include/uapi/linux/dpll.h +30 -0
@@ -50,6 +50,35 @@ enum dpll_lock_status { DPLL_LOCK_STATUS_MAX = (__DPLL_LOCK_STATUS_MAX - 1) }; +/** +* enum dpll_lock_status_error - if previous status change was done due to a +* failure, this provides information of dpll device lock status error. Valid +* values for DPLL_A_LOCK_STATUS_ERROR attribute +* @DPLL_LOCK_STATUS_ERROR_NONE: dpll device lock status was changed without +* any error +* @DPLL_LOCK_STATUS_ERROR_UNDEFINED: dpll device lock status was changed due +* to undefined error. Driver fills this value up in case it is not able to +* obtain suitable exact error type. +* @DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN: dpll device lock status was changed +* because of associated media got down. This may happen for example if dpll +* device was previously locked on an input pin of type +* PIN_TYPE_SYNCE_ETH_PORT. +* @DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH: the FFO +* (Fractional Frequency Offset) between the RX and TX symbol rate on the +* media got too high. This may happen for example if dpll device was +* previously locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT. +*/ +enum dpll_lock_status_error { +DPLL_LOCK_STATUS_ERROR_NONE =1 , +DPLL_LOCK_STATUS_ERROR_UNDEFINED , +DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN , +DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH , + +/* private: */ + __DPLL_LOCK_STATUS_ERROR_MAX, +DPLL_LOCK_STATUS_ERROR_MAX = (__DPLL_LOCK_STATUS_ERROR_MAX -1 ) +}; +#define DPLL_TEMP_DIVIDER 1000/**
@@ -150,6 +179,7 @@ enum dpll_a {DPLL_A_LOCK_STATUS ,DPLL_A_TEMP ,DPLL_A_TYPE , +DPLL_A_LOCK_STATUS_ERROR , __DPLL_A_MAX,DPLL_A_MAX = (__DPLL_A_MAX -1 )
Signature · 1 line
2.43.0
Re: [patch net-next v2 1/3] dpll: extend uapi by lock status error attribute
Quoted 8 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
If the dpll devices goes to state "unlocked" or "holdover", it may be caused by an error. In that case, allow user to see what the error was. Introduce a new attribute and values it can carry.
Signed-off-by Jiri Pirko <[email protected]>Acked-by Vadim Fedorenko <[email protected]>
The nit below notwithstanding, this looks good to me.
...
Quoted 21 lines
include/uapi/linux/dpll.h +13
-0@@ -50,6 +50,35 @@ enum dpll_lock_status { DPLL_LOCK_STATUS_MAX = (__DPLL_LOCK_STATUS_MAX - 1) }; +/** +* enum dpll_lock_status_error - if previous status change was done due to a +* failure, this provides information of dpll device lock status error. Valid +* values for DPLL_A_LOCK_STATUS_ERROR attribute +* @DPLL_LOCK_STATUS_ERROR_NONE: dpll device lock status was changed without +* any error +* @DPLL_LOCK_STATUS_ERROR_UNDEFINED: dpll device lock status was changed due +* to undefined error. Driver fills this value up in case it is not able to +* obtain suitable exact error type. +* @DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN: dpll device lock status was changed +* because of associated media got down. This may happen for example if dpll +* device was previously locked on an input pin of type +* PIN_TYPE_SYNCE_ETH_PORT.
include/uapi/linux/dpll.h enum dpll_lock_status { · line 75
Quoted 10 lines
include/uapi/linux/dpll.h +10
-0+* @DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH: the FFO +* (Fractional Frequency Offset) between the RX and TX symbol rate on the +* media got too high. This may happen for example if dpll device was +* previously locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT. +*/ +enum dpll_lock_status_error { +DPLL_LOCK_STATUS_ERROR_NONE =1 , +DPLL_LOCK_STATUS_ERROR_UNDEFINED , +DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN , +DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH ,
nit: I'm all for descriptive names,
but this one is rather long to say the least.
Quoted 21 lines
include/uapi/linux/dpll.h +7
-0+ +/* private: */ + __DPLL_LOCK_STATUS_ERROR_MAX, + DPLL_LOCK_STATUS_ERROR_MAX = (__DPLL_LOCK_STATUS_ERROR_MAX - 1) +}; +#define DPLL_TEMP_DIVIDER 1000/** @@ -150,6 +179,7 @@ enum dpll_a {DPLL_A_LOCK_STATUS ,DPLL_A_TEMP ,DPLL_A_TYPE , +DPLL_A_LOCK_STATUS_ERROR , __DPLL_A_MAX,DPLL_A_MAX = (__DPLL_A_MAX -1 )Signature · 1 line
2.43.0
Jakub Kicinski
maintainerRe: [patch net-next v2 1/3] dpll: extend uapi by lock status error attribute
Quoted 4 lines · On Thu, 1 Feb 2024 14:53:11 +0100 Simon Horman wrote:
include/uapi/linux/dpll.h enum dpll_lock_status { · line 75
Quoted 1 line
include/uapi/linux/dpll.h +1
-0+ DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH,nit: I'm all for descriptive names,
but this one is rather long to say the least.
OMG :(
Jiri Pirko
maintainerPATCH v2 2/3 dpll: extend lock_status_get() op by status error and expose to user
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Pass additional argunent status_error over lock_status_get() so drivers can fill it up. In case they do, expose the value over previously introduced attribute to user. Do it only in case the current lock_status is either "unlocked" or "holdover".
---v1->v2:
- fixed warning caused by a missed arg description in comment of a static function in ice driver :O
--- drivers/dpll/dpll_netlink.c | 9 ++++++++- drivers/net/ethernet/intel/ice/ice_dpll.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/dpll.c | 9 +++++---- drivers/ptp/ptp_ocp.c | 9 +++++---- include/linux/dpll.h | 1 + 5 files changed, 21 insertions(+), 9 deletions(-)
drivers/dpll/dpll_netlink.c +8 -1
@@ -121,14 +121,21 @@ dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll, struct netlink_ext_ack *extack) {const struct dpll_device_ops *ops =dpll_device_ops (dpll); +enum dpll_lock_status_error status_error =0 ;enum dpll_lock_status status;int ret; - ret = ops->lock_status_get (dpll,dpll_priv (dpll), &status, extack); + ret = ops->lock_status_get (dpll,dpll_priv (dpll), &status, + &status_error, extack);if (ret)return ret;if (nla_put_u32 (msg,DPLL_A_LOCK_STATUS , status))return -EMSGSIZE ; +if (status_error && + (status ==DPLL_LOCK_STATUS_UNLOCKED || + status ==DPLL_LOCK_STATUS_HOLDOVER ) && +nla_put_u32 (msg,DPLL_A_LOCK_STATUS_ERROR , status_error)) +return -EMSGSIZE ;return 0 ; }
drivers/net/ethernet/intel/ice/ice_dpll.c +2 -0
@@ -488,6 +488,7 @@ ice_dpll_hw_input_prio_set(struct ice_pf *pf, struct ice_dpll *dpll,* @dpll: registered dpll pointer * @dpll_priv: private data pointer passed on dpll registration * @status: on success holds dpll's lock status +* @status_error: status error value * @extack: error reporting * * Dpll subsystem callback, provides dpll's lock status.
@@ -500,6 +501,7 @@ ice_dpll_hw_input_prio_set(struct ice_pf *pf, struct ice_dpll *dpll,static int ice_dpll_lock_status_get (const struct dpll_device *dpll,void *dpll_priv,enum dpll_lock_status *status, +enum dpll_lock_status_error *status_error,struct netlink_ext_ack *extack) {struct ice_dpll *d = dpll_priv;
drivers/net/ethernet/mellanox/mlx5/core/dpll.c +5 -4
@@ -118,10 +118,11 @@ mlx5_dpll_pin_ffo_get(struct mlx5_dpll_synce_status *synce_status,return 0 ; } -static int mlx5_dpll_device_lock_status_get (const struct dpll_device *dpll, -void *priv, -enum dpll_lock_status *status, -struct netlink_ext_ack *extack) +static int +mlx5_dpll_device_lock_status_get (const struct dpll_device *dpll,void *priv, +enum dpll_lock_status *status, +enum dpll_lock_status_error *status_error, +struct netlink_ext_ack *extack) {struct mlx5_dpll_synce_status synce_status;struct mlx5_dpll *mdpll = priv;
drivers/ptp/ptp_ocp.c +5 -4
@@ -4209,10 +4209,11 @@ ptp_ocp_detach(struct ptp_ocp *bp)device_unregister (&bp->dev); } -static int ptp_ocp_dpll_lock_status_get (const struct dpll_device *dpll, -void *priv, -enum dpll_lock_status *status, -struct netlink_ext_ack *extack) +static int +ptp_ocp_dpll_lock_status_get (const struct dpll_device *dpll,void *priv, +enum dpll_lock_status *status, +enum dpll_lock_status_error *status_error, +struct netlink_ext_ack *extack) {struct ptp_ocp *bp = priv;
include/linux/dpll.h +1 -0
@@ -19,6 +19,7 @@ struct dpll_device_ops { enum dpll_mode *mode, struct netlink_ext_ack *extack);int (*lock_status_get)(const struct dpll_device *dpll,void *dpll_priv,enum dpll_lock_status *status, +enum dpll_lock_status_error *status_error,struct netlink_ext_ack *extack);int (*temp_get)(const struct dpll_device *dpll,void *dpll_priv,s32 *temp,struct netlink_ext_ack *extack);
Signature · 1 line
2.43.0
Re: [patch net-next v2 2/3] dpll: extend lock_status_get() op by status error and expose to user
Quoted 9 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Pass additional argunent
status_erroroverlock_status_get()so drivers can fill it up. In case they do, expose the value over previously introduced attribute to user. Do it only in case the currentlock_statusis either "unlocked" or "holdover".Signed-off-by Jiri Pirko <[email protected]>Acked-by Vadim Fedorenko <[email protected]>
Jiri Pirko
maintainerPATCH v2 3/3 net/mlx5: DPLL, Implement lock status error value
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Fill-up the lock status error value properly.
--- .../net/ethernet/mellanox/mlx5/core/dpll.c | 23 +++++++++++++++++++ include/linux/mlx5/mlx5_ifc.h | 8 +++++++ 2 files changed, 31 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/dpll.c +23 -0
@@ -41,6 +41,7 @@ struct mlx5_dpll_synce_status {enum mlx5_msees_oper_status oper_status;bool ho_acq;bool oper_freq_measure; +enum mlx5_msees_failure_reason failure_reason;s32 frequency_diff; };
@@ -60,6 +61,7 @@ mlx5_dpll_synce_status_get(struct mlx5_core_dev *mdev, synce_status->oper_status =MLX5_GET (msees_reg, out, oper_status); synce_status->ho_acq =MLX5_GET (msees_reg, out, ho_acq); synce_status->oper_freq_measure =MLX5_GET (msees_reg, out, oper_freq_measure); + synce_status->failure_reason =MLX5_GET (msees_reg, out, failure_reason); synce_status->frequency_diff =MLX5_GET (msees_reg, out, frequency_diff);return 0 ; }
@@ -99,6 +101,26 @@ mlx5_dpll_lock_status_get(struct mlx5_dpll_synce_status *synce_status) } } +static enum dpll_lock_status_error +mlx5_dpll_lock_status_error_get (struct mlx5_dpll_synce_status *synce_status) +{ +switch (synce_status->oper_status) { +case MLX5_MSEES_OPER_STATUS_FAIL_HOLDOVER : + fallthrough; +case MLX5_MSEES_OPER_STATUS_FAIL_FREE_RUNNING : +switch (synce_status->failure_reason) { +case MLX5_MSEES_FAILURE_REASON_PORT_DOWN : +return DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN ; +case MLX5_MSEES_FAILURE_REASON_TOO_HIGH_FREQUENCY_DIFF : +return DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH ; +default : +return DPLL_LOCK_STATUS_ERROR_UNDEFINED ; + } +default : +return DPLL_LOCK_STATUS_ERROR_NONE ; + } +} +static enum dpll_pin_state mlx5_dpll_pin_state_get (struct mlx5_dpll_synce_status *synce_status) {
@@ -132,6 +154,7 @@ mlx5_dpll_device_lock_status_get(const struct dpll_device *dpll, void *priv,if (err)return err; *status =mlx5_dpll_lock_status_get (&synce_status); + *status_error =mlx5_dpll_lock_status_error_get (&synce_status);return 0 ; }
include/linux/mlx5/mlx5_ifc.h +8 -0
@@ -12705,6 +12705,14 @@ enum mlx5_msees_oper_status { MLX5_MSEES_OPER_STATUS_FAIL_FREE_RUNNING = 0x5, }; +enum mlx5_msees_failure_reason { +MLX5_MSEES_FAILURE_REASON_UNDEFINED_ERROR =0x0 , +MLX5_MSEES_FAILURE_REASON_PORT_DOWN =0x1 , +MLX5_MSEES_FAILURE_REASON_TOO_HIGH_FREQUENCY_DIFF =0x2 , +MLX5_MSEES_FAILURE_REASON_NET_SYNCHRONIZER_DEVICE_ERROR =0x3 , +MLX5_MSEES_FAILURE_REASON_LACK_OF_RESOURCES =0x4 , +}; +struct mlx5_ifc_msees_reg_bits {u8 reserved_at_0[0x8 ];u8 local_port[0x8 ];
Signature · 1 line
2.43.0
Re: [patch net-next v2 3/3] net/mlx5: DPLL, Implement lock status error value
Quoted 6 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Fill-up the lock status error value properly.
Signed-off-by Jiri Pirko <[email protected]>Acked-by Vadim Fedorenko <[email protected]>
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Tue, 30 Jan 2024 13:08:28 +0100 you wrote:
From: Jiri Pirko <[email protected]>
Allow to expose lock status errort value over new DPLL generic netlink attribute. Extend the
lock_status_get()op by new argument to get the value from the driver. Implement this new argument fill-up in mlx5 driver.[...]
Here is the summary with links:
- [net-next,v2,1/3] dpll: extend uapi by lock status error attribute
https://git.kernel.org/netdev/net-next/c/cf4f0f1e1c46 - [net-next,v2,2/3] dpll: extend lock_status_get() op by status error and expose to user https://git.kernel.org/netdev/net-next/c/e2ca9e75849e - [net-next,v2,3/3] net/mlx5: DPLL, Implement lock status error value https://git.kernel.org/netdev/net-next/c/2c54a4d71246
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html