dpll: add all inputs phase offset monitor
Subsystems (6)
Arkadiusz Kubalewski
maintainerv5 cover dpll: add all inputs phase offset monitor
Add dpll device level feature: phase offset monitor.
Phase offset measurement is typically performed against the current active source. However, some DPLL (Digital Phase-Locked Loop) devices may offer the capability to monitor phase offsets across all available inputs. The attribute and current feature state shall be included in the response message of the ``DPLL_CMD_DEVICE_GET`` command for supported DPLL devices. In such cases, users can also control the feature using the ``DPLL_CMD_DEVICE_SET`` command by setting the ``enum dpll_feature_state`` values for the attribute.
Once enabled the phase offset measurements for the input shall be returned in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute.
Implement feature support in ice driver for dpll-enabled devices.
Verify capability:
$ ./tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/dpll.yaml \
--dump device-get
[{'clock-id': 4658613174691613800,
'id': 0,
'lock-status': 'locked-ho-acq',
'mode': 'automatic',
'mode-supported': ['automatic'],
'module-name': 'ice',
'type': 'eec'},
{'clock-id': 4658613174691613800,
'id': 1,
'lock-status': 'locked-ho-acq',
'mode': 'automatic',
'mode-supported': ['automatic'],
'module-name': 'ice',
'phase-offset-monitor': 'disable',
'type': 'pps'}]Enable the feature:
$ ./tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/dpll.yaml \
--do device-set --json '{"id":1, "phase-offset-monitor":"enable"}'Verify feature is enabled:
$ ./tools/net/ynl/pyynl/cli.py \
--spec Documentation/netlink/specs/dpll.yaml \
--dump device-get
[
[...]
{'capabilities': {'all-inputs-phase-offset-monitor'},
'clock-id': 4658613174691613800,
'id': 1,
[...]
'phase-offset-monitor': 'enable',
[...]]Arkadiusz Kubalewski (3):
dpll: add phase-offset-monitor feature to netlink spec
dpll: add phase_offset_monitor_get/set callback ops
ice: add phase offset monitor for all PPS dpll inputs
Documentation/driver-api/dpll.rst | 18 ++ Documentation/netlink/specs/dpll.yaml | 24 +++ drivers/dpll/dpll_netlink.c | 69 ++++++- drivers/dpll/dpll_nl.c | 5 +- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 20 ++ drivers/net/ethernet/intel/ice/ice_common.c | 26 +++ drivers/net/ethernet/intel/ice/ice_common.h | 3 + drivers/net/ethernet/intel/ice/ice_dpll.c | 194 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_dpll.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 4 + include/linux/dpll.h | 8 + include/uapi/linux/dpll.h | 12 ++ 12 files changed, 385 insertions(+), 6 deletions(-)
base-commit: 2c7e4a2663a1ab5a740c59c31991579b6b865a26
Signature · 1 line
2.38.1
Arkadiusz Kubalewski
maintainerPATCH v5 1/3 dpll: add phase-offset-monitor feature to netlink spec
Add enum dpll_feature_state for control over features.
Add dpll device level attribute:DPLL_A_PHASE_OFFSET_MONITOR - to allow control over a phase offset monitor feature. Attribute is present and shall return current state of a feature (enum dpll_feature_state), if the device driver provides such capability, otherwie attribute shall not be present.
---
v5:
- specify in docs which attribute holds measured phase offset value,
- rebase.
--- Documentation/driver-api/dpll.rst | 18 ++++++++++++++++++ Documentation/netlink/specs/dpll.yaml | 24 ++++++++++++++++++++++++ drivers/dpll/dpll_nl.c | 5 +++-- include/uapi/linux/dpll.h | 12 ++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-)
Documentation/driver-api/dpll.rst +18 -0
@@ -214,6 +214,24 @@ offset values are fractional with 3-digit decimal places and shell be divided with ``DPLL_PIN_PHASE_OFFSET_DIVIDER`` to get integer part and modulo divided to get fractional part. +Phase offset monitor +==================== + +Phase offset measurement is typically performed against the current active +source. However, some DPLL (Digital Phase-Locked Loop) devices may offer +the capability to monitor phase offsets across all available inputs. +The attribute and current feature state shall be included in the response +message of the ``DPLL_CMD_DEVICE_GET`` command for supported DPLL devices. +In such cases, users can also control the feature using the +``DPLL_CMD_DEVICE_SET`` command by setting the ``enum dpll_feature_state`` +values for the attribute. +Once enabled the phase offset measurements for the input shall be returned +in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute. + + =============================== ======================== + ``DPLL_A_PHASE_OFFSET_MONITOR`` attr state of a feature + =============================== ======================== + Embedded SYNC =============
Documentation/netlink/specs/dpll.yaml +24 -0
@@ -240,6 +240,20 @@ definitions: integer part of a measured phase offset value. Value of (DPLL_A_PHASE_OFFSET % DPLL_PHASE_OFFSET_DIVIDER) is a fractional part of a measured phase offset value. + - + type: enum + name: feature-state + doc: | + Allow control (enable/disable) and status checking over features. + entries: + - + name: disable + doc: | + feature shall be disabled + - + name: enable + doc: | + feature shall be enabled attribute-sets: -
@@ -293,6 +307,14 @@ attribute-sets: be put to message multiple times to indicate possible parallel quality levels (e.g. one specified by ITU option 1 and another one specified by option 2). + - + name: phase-offset-monitor + type: u32 + enum: feature-state + doc: Receive or request state of phase offset monitor feature. + If enabled, dpll device shall monitor and notify all currently + available inputs for changes of their phase offset against the + dpll device. - name: pin enum-name: dpll_a_pin
@@ -483,6 +505,7 @@ operations: - temp - clock-id - type + - phase-offset-monitor dump: reply: *dev-attrs
@@ -499,6 +522,7 @@ operations: request: attributes: - id + - phase-offset-monitor - name: device-create-ntf doc: Notification about device appearing
drivers/dpll/dpll_nl.c +3 -2
@@ -37,8 +37,9 @@ static const struct nla_policy dpll_device_get_nl_policy[DPLL_A_ID + 1] = { };/* DPLL_CMD_DEVICE_SET - do */ -static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_ID +1 ] = { +static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_PHASE_OFFSET_MONITOR +1 ] = { [DPLL_A_ID ] = { .type =NLA_U32 , }, + [DPLL_A_PHASE_OFFSET_MONITOR ] =NLA_POLICY_MAX (NLA_U32 ,1 ), };/* DPLL_CMD_PIN_ID_GET - do */
@@ -105,7 +106,7 @@ static const struct genl_split_ops dpll_nl_ops[] = { .doit = dpll_nl_device_set_doit, .post_doit = dpll_post_doit, .policy = dpll_device_set_nl_policy, - .maxattr = DPLL_A_ID, + .maxattr = DPLL_A_PHASE_OFFSET_MONITOR, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, {
include/uapi/linux/dpll.h +12 -0
@@ -192,6 +192,17 @@ enum dpll_pin_capabilities {#define DPLL_PHASE_OFFSET_DIVIDER 1000 +/** +* enum dpll_feature_state - Allow control (enable/disable) and status checking +* over features. +* @DPLL_FEATURE_STATE_DISABLE: feature shall be disabled +* @DPLL_FEATURE_STATE_ENABLE: feature shall be enabled +*/ +enum dpll_feature_state { +DPLL_FEATURE_STATE_DISABLE , +DPLL_FEATURE_STATE_ENABLE , +}; +enum dpll_a {DPLL_A_ID =1 ,DPLL_A_MODULE_NAME ,
@@ -204,6 +215,7 @@ enum dpll_a {DPLL_A_TYPE ,DPLL_A_LOCK_STATUS_ERROR ,DPLL_A_CLOCK_QUALITY_LEVEL , +DPLL_A_PHASE_OFFSET_MONITOR , __DPLL_A_MAX,DPLL_A_MAX = (__DPLL_A_MAX -1 )
Signature · 1 line
2.38.1
Arkadiusz Kubalewski
maintainerPATCH v5 2/3 dpll: add phase_offset_monitor_get/set callback ops
In reply to Arkadiusz KubalewskiAdd new callback operations for a dpll device:
- phase_offset_monitor_get(..) - to obtain current state of phase offset monitor feature from dpll device,
- phase_offset_monitor_set(..) - to allow feature configuration.
Obtain the feature state value using the get callback and provide it to the user if the device driver implements callbacks.
Execute the set callback upon user requests.
---
v5:
- rebase.
--- drivers/dpll/dpll_netlink.c | 69 +++++++++++++++++++++++++++++++++++-- include/linux/dpll.h | 8 +++++ 2 files changed, 75 insertions(+), 2 deletions(-)
drivers/dpll/dpll_netlink.c +67 -2
@@ -126,6 +126,26 @@ dpll_msg_add_mode_supported(struct sk_buff *msg, struct dpll_device *dpll,return 0 ; } +static int +dpll_msg_add_phase_offset_monitor (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_feature_state state; +int ret; + +if (ops->phase_offset_monitor_set && ops->phase_offset_monitor_get) { + ret = ops->phase_offset_monitor_get (dpll,dpll_priv (dpll), + &state, extack); +if (ret) +return ret; +if (nla_put_u32 (msg,DPLL_A_PHASE_OFFSET_MONITOR , state)) +return -EMSGSIZE ; + } + +return 0 ; +} +static int dpll_msg_add_lock_status (struct sk_buff *msg,struct dpll_device *dpll,struct netlink_ext_ack *extack)
@@ -591,6 +611,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,return ret;if (nla_put_u32 (msg,DPLL_A_TYPE , dpll->type))return -EMSGSIZE ; + ret =dpll_msg_add_phase_offset_monitor (msg, dpll, extack); +if (ret) +return ret;return 0 ; }
@@ -746,6 +769,31 @@ int dpll_pin_change_ntf(struct dpll_pin *pin) }EXPORT_SYMBOL_GPL (dpll_pin_change_ntf); +static int +dpll_phase_offset_monitor_set (struct dpll_device *dpll,struct nlattr *a, +struct netlink_ext_ack *extack) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); +enum dpll_feature_state state =nla_get_u32 (a), old_state; +int ret; + +if (!(ops->phase_offset_monitor_set && ops->phase_offset_monitor_get)) { +NL_SET_ERR_MSG_ATTR (extack, a,"dpll device not capable of phase offset monitor" ); +return -EOPNOTSUPP ; + } + ret = ops->phase_offset_monitor_get (dpll,dpll_priv (dpll), &old_state, + extack); +if (ret) { +NL_SET_ERR_MSG (extack,"unable to get current state of phase offset monitor" ); +return ret; + } +if (state == old_state) +return 0 ; + +return ops->phase_offset_monitor_set (dpll,dpll_priv (dpll), state, + extack); +} +static int dpll_pin_freq_set (struct dpll_pin *pin,struct nlattr *a,struct netlink_ext_ack *extack)
@@ -1533,10 +1581,27 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, struct genl_info *info)return genlmsg_reply (msg, info); } +static int +dpll_set_from_nlattr (struct dpll_device *dpll,struct genl_info *info) +{ +int ret; + +if (info->attrs[DPLL_A_PHASE_OFFSET_MONITOR ]) { +struct nlattr *a = info->attrs[DPLL_A_PHASE_OFFSET_MONITOR ]; + + ret =dpll_phase_offset_monitor_set (dpll, a, info->extack); +if (ret) +return ret; + } + +return 0 ; +} +int dpll_nl_device_set_doit (struct sk_buff *skb,struct genl_info *info) { -/* placeholder for set command */ -return 0 ; +struct dpll_device *dpll = info->user_ptr[0 ]; + +return dpll_set_from_nlattr (dpll, info); }int dpll_nl_device_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb)
include/linux/dpll.h +8 -0
@@ -30,6 +30,14 @@ struct dpll_device_ops {void *dpll_priv, unsigned long *qls, struct netlink_ext_ack *extack); +int (*phase_offset_monitor_set)(const struct dpll_device *dpll, +void *dpll_priv, +enum dpll_feature_state state, +struct netlink_ext_ack *extack); +int (*phase_offset_monitor_get)(const struct dpll_device *dpll, +void *dpll_priv, +enum dpll_feature_state *state, +struct netlink_ext_ack *extack); };struct dpll_pin_ops {
Signature · 1 line
2.38.1
Arkadiusz Kubalewski
maintainerPATCH v5 3/3 ice: add phase offset monitor for all PPS dpll inputs
In reply to Arkadiusz KubalewskiImplement a new admin command and helper function to handle and obtain CGU measurements for input pins.
Add new callback operations to control the dpll device-level feature "phase offset monitor," allowing it to be enabled or disabled. If the feature is enabled, provide users with measured phase offsets and notifications.
Initialize PPS DPLL with new callback operations if the feature is supported by the firmware.
---
v5:
- fix dpll_device_unregister(..) issue by holding and using registsred ops.
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 20 ++ drivers/net/ethernet/intel/ice/ice_common.c | 26 +++ drivers/net/ethernet/intel/ice/ice_common.h | 3 + drivers/net/ethernet/intel/ice/ice_dpll.c | 194 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_dpll.h | 8 + drivers/net/ethernet/intel/ice/ice_main.c | 4 + 6 files changed, 253 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +20 -0
@@ -2272,6 +2272,22 @@ struct ice_aqc_get_pkg_info_resp {struct ice_aqc_get_pkg_info pkg_info[]; }; +#define ICE_CGU_INPUT_PHASE_OFFSET_BYTES 6 + +struct ice_cgu_input_measure { +u8 phase_offset[ICE_CGU_INPUT_PHASE_OFFSET_BYTES ]; +__le32 freq; +} __packed__aligned(sizeof(__le16)) ; + +#define ICE_AQC_GET_CGU_IN_MEAS_DPLL_IDX_M ICE_M(0xf, 0) + +/* Get CGU input measure command response data structure (indirect 0x0C59) */ +struct ice_aqc_get_cgu_input_measure { +u8 dpll_idx_opt; +u8 length; +u8 rsvd[6 ]; +}; +#define ICE_AQC_GET_CGU_MAX_PHASE_ADJ GENMASK(30, 0)/* Get CGU abilities command response data structure (indirect 0x0C61) */
@@ -2721,6 +2737,7 @@ struct ice_aq_desc {struct ice_aqc_add_get_update_free_vsi vsi_cmd;struct ice_aqc_add_update_free_vsi_resp add_update_free_vsi_res;struct ice_aqc_download_pkg download_pkg; +struct ice_aqc_get_cgu_input_measure get_cgu_input_measure;struct ice_aqc_set_cgu_input_config set_cgu_input_config;struct ice_aqc_get_cgu_input_config get_cgu_input_config;struct ice_aqc_set_cgu_output_config set_cgu_output_config;
@@ -2772,6 +2789,8 @@ enum ice_aq_err {ICE_AQ_RC_OK =0 ,/* Success */ ICE_AQ_RC_EPERM =1 ,/* Operation not permitted */ ICE_AQ_RC_ENOENT =2 ,/* No such element */ +ICE_AQ_RC_ESRCH =3 ,/* Bad opcode */ +ICE_AQ_RC_EAGAIN =8 ,/* Try again */ ICE_AQ_RC_ENOMEM =9 ,/* Out of memory */ ICE_AQ_RC_EBUSY =12 ,/* Device or resource busy */ ICE_AQ_RC_EEXIST = 13, /* Object already exists */
@@ -2927,6 +2946,7 @@ enum ice_adminq_opc { ice_aqc_opc_get_pkg_info_list =0x0C43 ,/* 1588/SyncE commands/events */ + ice_aqc_opc_get_cgu_input_measure =0x0C59 , ice_aqc_opc_get_cgu_abilities =0x0C61 , ice_aqc_opc_set_cgu_input_config =0x0C62 , ice_aqc_opc_get_cgu_input_config = 0x0C63,
drivers/net/ethernet/intel/ice/ice_common.c +26 -0
@@ -4970,6 +4970,32 @@ ice_dis_vsi_rdma_qset(struct ice_port_info *pi, u16 count, u32 *qset_teid,return status; } +/** +* ice_aq_get_cgu_input_pin_measure - get input pin signal measurements +* @hw: pointer to the HW struct +* @dpll_idx: index of dpll to be measured +* @meas: array to be filled with results +* @meas_num: max number of results array can hold +* +* Get CGU measurements (0x0C59) of phase and frequency offsets for input +* pins on given dpll. +* +* Return: 0 on success or negative value on failure. +*/ +int ice_aq_get_cgu_input_pin_measure (struct ice_hw *hw,u8 dpll_idx, +struct ice_cgu_input_measure *meas, +u16 meas_num) +{ +struct ice_aqc_get_cgu_input_measure *cmd; +struct ice_aq_desc desc; + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_get_cgu_input_measure); + cmd = &desc.params.get_cgu_input_measure; + cmd->dpll_idx_opt = dpll_idx &ICE_AQC_GET_CGU_IN_MEAS_DPLL_IDX_M ; + +return ice_aq_send_cmd (hw, &desc, meas, meas_num *sizeof (*meas),NULL ); +} +/** * ice_aq_get_cgu_abilities - get cgu abilities * @hw: pointer to the HW struct
drivers/net/ethernet/intel/ice/ice_common.h +3 -0
@@ -229,6 +229,9 @@ void ice_replay_post(struct ice_hw *hw);struct ice_q_ctx *ice_get_lan_q_ctx (struct ice_hw *hw,u16 vsi_handle,u8 tc,u16 q_handle);int ice_sbq_rw_reg (struct ice_hw *hw,struct ice_sbq_msg_input *in,u16 flag); +int ice_aq_get_cgu_input_pin_measure (struct ice_hw *hw,u8 dpll_idx, +struct ice_cgu_input_measure *meas, +u16 meas_num);int ice_aq_get_cgu_abilities (struct ice_hw *hw,struct ice_aqc_get_cgu_abilities *abilities);
drivers/net/ethernet/intel/ice/ice_dpll.c +192 -2
267 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_dpll.h +8 -0
@@ -19,6 +19,7 @@* @prop: pin properties * @freq: current frequency of a pin * @phase_adjust: current phase adjust value +* @phase_offset: monitored phase offset value */ struct ice_dpll_pin {struct dpll_pin *pin;
@@ -31,6 +32,7 @@ struct ice_dpll_pin {struct dpll_pin_properties prop;u32 freq;s32 phase_adjust; +s64 phase_offset;u8 status; };
@@ -47,8 +49,10 @@ struct ice_dpll_pin {* @input_prio: priorities of each input * @dpll_state: current dpll sync state * @prev_dpll_state: last dpll sync state +* @phase_offset_monitor_period: period for phase offset monitor read frequency * @active_input: pointer to active input pin * @prev_input: pointer to previous active input pin +* @ops: holds the registered ops */ struct ice_dpll {struct dpll_device *dpll;
@@ -64,8 +68,10 @@ struct ice_dpll {enum dpll_lock_status dpll_state;enum dpll_lock_status prev_dpll_state;enum dpll_mode mode; +u32 phase_offset_monitor_period;struct dpll_pin *active_input;struct dpll_pin *prev_input; +const struct dpll_device_ops *ops; };/** ice_dplls - store info required for CCU (clock controlling unit)
@@ -80,6 +86,7 @@ struct ice_dpll {* @num_inputs: number of input pins available on dpll * @num_outputs: number of output pins available on dpll * @cgu_state_acq_err_num: number of errors returned during periodic work +* @periodic_counter: counter of periodic work executions * @base_rclk_idx: idx of first pin used for clock revocery pins * @clock_id: clock_id of dplls * @input_phase_adj_max: max phase adjust value for an input pins
@@ -97,6 +104,7 @@ struct ice_dplls {u8 num_inputs;u8 num_outputs;int cgu_state_acq_err_num; +u32 periodic_counter;u8 base_rclk_idx;u64 clock_id;s32 input_phase_adj_max;
drivers/net/ethernet/intel/ice/ice_main.c +4 -0
@@ -7933,6 +7933,10 @@ const char *ice_aq_str(enum ice_aq_err aq_err)return "ICE_AQ_RC_EPERM" ;case ICE_AQ_RC_ENOENT :return "ICE_AQ_RC_ENOENT" ; +case ICE_AQ_RC_ESRCH : +return "ICE_AQ_RC_ESRCH" ; +case ICE_AQ_RC_EAGAIN : +return "ICE_AQ_RC_EAGAIN" ;case ICE_AQ_RC_ENOMEM :return "ICE_AQ_RC_ENOMEM" ;case ICE_AQ_RC_EBUSY :
Signature · 1 line
2.38.1
Jakub Kicinski
maintainerQuoted 1 line · On Tue, 10 Jun 2025 07:53:35 +0200 Arkadiusz Kubalewski wrote:
Add dpll device level feature: phase offset monitor.
Same story here
Signature · 1 line
pw-bot: cr