diff mbox series

[net-next,2/2] ice: ptp: add control over HW timestamp latch point

Message ID 20241021141955.1466979-3-arkadiusz.kubalewski@intel.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series ptp: add control over HW timestamp latch point | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: andrew+netdev@lunn.ch
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 126 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc fail Errors and warnings before: 102 this patch: 103
netdev/source_inline success Was 0 now: 0

Commit Message

Kubalewski, Arkadiusz Oct. 21, 2024, 2:19 p.m. UTC
Allow user to control the latch point of ptp HW timestamps in E825
devices.

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp.c    | 46 +++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 57 +++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  2 +
 3 files changed, 105 insertions(+)

Comments

Paul Menzel Oct. 21, 2024, 3:34 p.m. UTC | #1
Dear Arkadiusz,


Thank you for the patch.

Am 21.10.24 um 16:19 schrieb Arkadiusz Kubalewski:
> Allow user to control the latch point of ptp HW timestamps in E825
> devices.

Please give an example how to configure it.

> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
> ---
>   drivers/net/ethernet/intel/ice/ice_ptp.c    | 46 +++++++++++++++++
>   drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 57 +++++++++++++++++++++
>   drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  2 +
>   3 files changed, 105 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index a999fface272..47444412ed9a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -2509,6 +2509,50 @@ static int ice_ptp_parse_sdp_entries(struct ice_pf *pf, __le16 *entries,
>   	return 0;
>   }
>   
> +/**
> + * ice_get_ts_point - get the tx timestamp latch point
> + * @info: the driver's PTP info structure
> + * @point: return the configured tx timestamp latch point
> + *
> + * Return: 0 on success, negative on failure.
> + */
> +static int
> +ice_get_ts_point(struct ptp_clock_info *info, enum ptp_ts_point *point)
> +{
> +	struct ice_pf *pf = ptp_info_to_pf(info);
> +	struct ice_hw *hw = &pf->hw;
> +	bool sfd_ena;
> +	int ret;
> +
> +	ice_ptp_lock(hw);
> +	ret = ice_ptp_hw_ts_point_get(hw, &sfd_ena);
> +	ice_ptp_unlock(hw);
> +	if (!ret)
> +		*point = sfd_ena ? PTP_TS_POINT_SFD : PTP_TS_POINT_POST_SFD;
> +
> +	return ret;
> +}
> +
> +/**
> + * ice_set_ts_point - set the tx timestamp latch point
> + * @info: the driver's PTP info structure
> + * @point: requested tx timestamp latch point
> + */
> +static int
> +ice_set_ts_point(struct ptp_clock_info *info, enum ptp_ts_point point)
> +{
> +	bool sfd_ena = point == PTP_TS_POINT_SFD ? true : false;
> +	struct ice_pf *pf = ptp_info_to_pf(info);
> +	struct ice_hw *hw = &pf->hw;
> +	int ret;
> +
> +	ice_ptp_lock(hw);
> +	ret = ice_ptp_hw_ts_point_set(hw, sfd_ena);
> +	ice_ptp_unlock(hw);
> +
> +	return ret;
> +}
> +
>   /**
>    * ice_ptp_set_funcs_e82x - Set specialized functions for E82X support
>    * @pf: Board private structure
> @@ -2529,6 +2573,8 @@ static void ice_ptp_set_funcs_e82x(struct ice_pf *pf)
>   	if (ice_is_e825c(&pf->hw)) {
>   		pf->ptp.ice_pin_desc = ice_pin_desc_e825c;
>   		pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e825c);
> +		pf->ptp.info.set_ts_point = ice_set_ts_point;
> +		pf->ptp.info.get_ts_point = ice_get_ts_point;
>   	} else {
>   		pf->ptp.ice_pin_desc = ice_pin_desc_e82x;
>   		pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e82x);
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> index da88c6ccfaeb..d81525bc8a16 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
> @@ -6303,3 +6303,60 @@ int ice_cgu_get_output_pin_state_caps(struct ice_hw *hw, u8 pin_id,
>   
>   	return 0;
>   }
> +
> +/**
> + * ice_ptp_hw_ts_point_get - check if tx timestamping is latched on/post SFD
> + * @hw: pointer to the HW struct
> + * @sfd_ena: on success true if tx timestamping latched at beginning of SFD,
> + *	false if post sfd
> + *
> + * Verify if HW timestamping point is configured to measure at the beginning or
> + * post of SFD (Start of Frame Delimiter)
> + *
> + * Return: 0 on success, negative on error
> + */
> +int ice_ptp_hw_ts_point_get(struct ice_hw *hw, bool *sfd_ena)
> +{
> +	u8 port = hw->port_info->lport;
> +	u32 val;
> +	int err;
> +
> +	err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val);
> +	if (err)
> +		return err;
> +	if (val | PHY_MAC_XIF_TS_SFD_ENA_M)
> +		*sfd_ena = true;
> +	else
> +		*sfd_ena = false;

Use ternary operator?

> +
> +	return err;

As the function returns `int`, use integers (macros) instead of boolean?

> +}
> +
> +/**
> + * ice_ptp_hw_ts_point_set - configure timestamping on/post SFD
> + * @hw: pointer to the HW struct
> + * @sfd_ena: true to enable timestamping at beginning of SFD, false post sfd
> + *
> + * Configure timestamping to measure at the beginning/post SFD (Start of Frame
> + * Delimiter)
> + *
> + * Return: 0 on success, negative on error
> + */
> +int ice_ptp_hw_ts_point_set(struct ice_hw *hw, bool sfd_ena)
> +{
> +	u8 port = hw->port_info->lport;
> +	int err, val;
> +
> +	err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val);
> +	if (err)
> +		return err;
> +	if ((val | PHY_MAC_XIF_TS_SFD_ENA_M && sfd_ena) ||
> +	    (!(val | PHY_MAC_XIF_TS_SFD_ENA_M) && !sfd_ena))
> +		return -EINVAL;
> +	if (sfd_ena)
> +		val |= PHY_MAC_XIF_TS_SFD_ENA_M;
> +	else
> +		val &= ~PHY_MAC_XIF_TS_SFD_ENA_M;
> +
> +	return ice_write_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, val);
> +}
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
> index 656daff3447e..cefedd01479a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
> @@ -348,6 +348,8 @@ void ice_ptp_init_hw(struct ice_hw *hw);
>   int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready);
>   int ice_ptp_one_port_cmd(struct ice_hw *hw, u8 configured_port,
>   			 enum ice_ptp_tmr_cmd configured_cmd);
> +int ice_ptp_hw_ts_point_get(struct ice_hw *hw, bool *sfd_ena);
> +int ice_ptp_hw_ts_point_set(struct ice_hw *hw, bool sfd_ena);
>   
>   /* E822 family functions */
>   int ice_read_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32 *val);


Kind regards,

Paul
Kubalewski, Arkadiusz Oct. 22, 2024, 1:24 p.m. UTC | #2
>From: Paul Menzel <pmenzel@molgen.mpg.de>
>Sent: Monday, October 21, 2024 5:34 PM
>
>Dear Arkadiusz,
>
>
>Thank you for the patch.

Thank you for the review!

>
>Am 21.10.24 um 16:19 schrieb Arkadiusz Kubalewski:
>> Allow user to control the latch point of ptp HW timestamps in E825
>> devices.
>
>Please give an example how to configure it.

Sure will do.

>
>> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
>> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
>> ---
>>   drivers/net/ethernet/intel/ice/ice_ptp.c    | 46 +++++++++++++++++
>>   drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 57 +++++++++++++++++++++
>>   drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  2 +
>>   3 files changed, 105 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> index a999fface272..47444412ed9a 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> @@ -2509,6 +2509,50 @@ static int ice_ptp_parse_sdp_entries(struct ice_pf
>> *pf, __le16 *entries,
>>   	return 0;
>>   }
>>
>> +/**
>> + * ice_get_ts_point - get the tx timestamp latch point
>> + * @info: the driver's PTP info structure
>> + * @point: return the configured tx timestamp latch point
>> + *
>> + * Return: 0 on success, negative on failure.
>> + */
>> +static int
>> +ice_get_ts_point(struct ptp_clock_info *info, enum ptp_ts_point *point)
>> +{
>> +	struct ice_pf *pf = ptp_info_to_pf(info);
>> +	struct ice_hw *hw = &pf->hw;
>> +	bool sfd_ena;
>> +	int ret;
>> +
>> +	ice_ptp_lock(hw);
>> +	ret = ice_ptp_hw_ts_point_get(hw, &sfd_ena);
>> +	ice_ptp_unlock(hw);
>> +	if (!ret)
>> +		*point = sfd_ena ? PTP_TS_POINT_SFD : PTP_TS_POINT_POST_SFD;
>> +
>> +	return ret;
>> +}
>> +
>> +/**
>> + * ice_set_ts_point - set the tx timestamp latch point
>> + * @info: the driver's PTP info structure
>> + * @point: requested tx timestamp latch point
>> + */
>> +static int
>> +ice_set_ts_point(struct ptp_clock_info *info, enum ptp_ts_point point)
>> +{
>> +	bool sfd_ena = point == PTP_TS_POINT_SFD ? true : false;
>> +	struct ice_pf *pf = ptp_info_to_pf(info);
>> +	struct ice_hw *hw = &pf->hw;
>> +	int ret;
>> +
>> +	ice_ptp_lock(hw);
>> +	ret = ice_ptp_hw_ts_point_set(hw, sfd_ena);
>> +	ice_ptp_unlock(hw);
>> +
>> +	return ret;
>> +}
>> +
>>   /**
>>    * ice_ptp_set_funcs_e82x - Set specialized functions for E82X support
>>    * @pf: Board private structure
>> @@ -2529,6 +2573,8 @@ static void ice_ptp_set_funcs_e82x(struct ice_pf
>> *pf)
>>   	if (ice_is_e825c(&pf->hw)) {
>>   		pf->ptp.ice_pin_desc = ice_pin_desc_e825c;
>>   		pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e825c);
>> +		pf->ptp.info.set_ts_point = ice_set_ts_point;
>> +		pf->ptp.info.get_ts_point = ice_get_ts_point;
>>   	} else {
>>   		pf->ptp.ice_pin_desc = ice_pin_desc_e82x;
>>   		pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e82x);
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
>> b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
>> index da88c6ccfaeb..d81525bc8a16 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
>> @@ -6303,3 +6303,60 @@ int ice_cgu_get_output_pin_state_caps(struct
>> ice_hw *hw, u8 pin_id,
>>
>>   	return 0;
>>   }
>> +
>> +/**
>> + * ice_ptp_hw_ts_point_get - check if tx timestamping is latched on/post
>> SFD
>> + * @hw: pointer to the HW struct
>> + * @sfd_ena: on success true if tx timestamping latched at beginning of
>> SFD,
>> + *	false if post sfd
>> + *
>> + * Verify if HW timestamping point is configured to measure at the
>> beginning or
>> + * post of SFD (Start of Frame Delimiter)
>> + *
>> + * Return: 0 on success, negative on error
>> + */
>> +int ice_ptp_hw_ts_point_get(struct ice_hw *hw, bool *sfd_ena)
>> +{
>> +	u8 port = hw->port_info->lport;
>> +	u32 val;
>> +	int err;
>> +
>> +	err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val);
>> +	if (err)
>> +		return err;
>> +	if (val | PHY_MAC_XIF_TS_SFD_ENA_M)
>> +		*sfd_ena = true;
>> +	else
>> +		*sfd_ena = false;
>
>Use ternary operator?
>

Ok, will do.

>> +
>> +	return err;
>
>As the function returns `int`, use integers (macros) instead of boolean?
>

Sure, will fix in next version.

>> +}
>> +
>> +/**
>> + * ice_ptp_hw_ts_point_set - configure timestamping on/post SFD
>> + * @hw: pointer to the HW struct
>> + * @sfd_ena: true to enable timestamping at beginning of SFD, false post
>> sfd
>> + *
>> + * Configure timestamping to measure at the beginning/post SFD (Start of
>> Frame
>> + * Delimiter)
>> + *
>> + * Return: 0 on success, negative on error
>> + */
>> +int ice_ptp_hw_ts_point_set(struct ice_hw *hw, bool sfd_ena)
>> +{
>> +	u8 port = hw->port_info->lport;
>> +	int err, val;
>> +
>> +	err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val);
>> +	if (err)
>> +		return err;
>> +	if ((val | PHY_MAC_XIF_TS_SFD_ENA_M && sfd_ena) ||
>> +	    (!(val | PHY_MAC_XIF_TS_SFD_ENA_M) && !sfd_ena))
>> +		return -EINVAL;
>> +	if (sfd_ena)
>> +		val |= PHY_MAC_XIF_TS_SFD_ENA_M;
>> +	else
>> +		val &= ~PHY_MAC_XIF_TS_SFD_ENA_M;
>> +
>> +	return ice_write_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, val);
>> +}
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
>> b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
>> index 656daff3447e..cefedd01479a 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
>> @@ -348,6 +348,8 @@ void ice_ptp_init_hw(struct ice_hw *hw);
>>   int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64
>> *tstamp_ready);
>>   int ice_ptp_one_port_cmd(struct ice_hw *hw, u8 configured_port,
>>   			 enum ice_ptp_tmr_cmd configured_cmd);
>> +int ice_ptp_hw_ts_point_get(struct ice_hw *hw, bool *sfd_ena);
>> +int ice_ptp_hw_ts_point_set(struct ice_hw *hw, bool sfd_ena);
>>
>>   /* E822 family functions */
>>   int ice_read_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32
>> *val);
>
>
>Kind regards,
>
>Paul

Thank you!
Arkadiusz
Simon Horman Oct. 22, 2024, 1:40 p.m. UTC | #3
On Mon, Oct 21, 2024 at 04:19:55PM +0200, Arkadiusz Kubalewski wrote:
> Allow user to control the latch point of ptp HW timestamps in E825
> devices.
> 
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_ptp.c    | 46 +++++++++++++++++
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 57 +++++++++++++++++++++
>  drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  2 +
>  3 files changed, 105 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index a999fface272..47444412ed9a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -2509,6 +2509,50 @@ static int ice_ptp_parse_sdp_entries(struct ice_pf *pf, __le16 *entries,
>  	return 0;
>  }
>  
> +/**
> + * ice_get_ts_point - get the tx timestamp latch point
> + * @info: the driver's PTP info structure
> + * @point: return the configured tx timestamp latch point
> + *
> + * Return: 0 on success, negative on failure.
> + */
> +static int
> +ice_get_ts_point(struct ptp_clock_info *info, enum ptp_ts_point *point)
> +{
> +	struct ice_pf *pf = ptp_info_to_pf(info);
> +	struct ice_hw *hw = &pf->hw;
> +	bool sfd_ena;
> +	int ret;
> +
> +	ice_ptp_lock(hw);
> +	ret = ice_ptp_hw_ts_point_get(hw, &sfd_ena);
> +	ice_ptp_unlock(hw);
> +	if (!ret)
> +		*point = sfd_ena ? PTP_TS_POINT_SFD : PTP_TS_POINT_POST_SFD;
> +
> +	return ret;
> +}
> +
> +/**
> + * ice_set_ts_point - set the tx timestamp latch point
> + * @info: the driver's PTP info structure
> + * @point: requested tx timestamp latch point

nit: Please include documentation of the return value,
     as was done for ice_get_ts_point.

     Flagged by ./scripts/kernel-doc -none -Warn

> + */
> +static int
> +ice_set_ts_point(struct ptp_clock_info *info, enum ptp_ts_point point)
> +{
> +	bool sfd_ena = point == PTP_TS_POINT_SFD ? true : false;
> +	struct ice_pf *pf = ptp_info_to_pf(info);
> +	struct ice_hw *hw = &pf->hw;
> +	int ret;
> +
> +	ice_ptp_lock(hw);
> +	ret = ice_ptp_hw_ts_point_set(hw, sfd_ena);
> +	ice_ptp_unlock(hw);
> +
> +	return ret;
> +}
> +
>  /**
>   * ice_ptp_set_funcs_e82x - Set specialized functions for E82X support
>   * @pf: Board private structure

...
Kubalewski, Arkadiusz Oct. 22, 2024, 2:52 p.m. UTC | #4
>From: Simon Horman <horms@kernel.org>
>Sent: Tuesday, October 22, 2024 3:40 PM
>
>On Mon, Oct 21, 2024 at 04:19:55PM +0200, Arkadiusz Kubalewski wrote:
>> Allow user to control the latch point of ptp HW timestamps in E825
>> devices.
>>
>> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
>> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
>> ---
>>  drivers/net/ethernet/intel/ice/ice_ptp.c    | 46 +++++++++++++++++
>>  drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 57
>> +++++++++++++++++++++  drivers/net/ethernet/intel/ice/ice_ptp_hw.h |
>> 2 +
>>  3 files changed, 105 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> index a999fface272..47444412ed9a 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> @@ -2509,6 +2509,50 @@ static int ice_ptp_parse_sdp_entries(struct ice_pf
>> *pf, __le16 *entries,
>>  	return 0;
>>  }
>>
>> +/**
>> + * ice_get_ts_point - get the tx timestamp latch point
>> + * @info: the driver's PTP info structure
>> + * @point: return the configured tx timestamp latch point
>> + *
>> + * Return: 0 on success, negative on failure.
>> + */
>> +static int
>> +ice_get_ts_point(struct ptp_clock_info *info, enum ptp_ts_point
>> +*point) {
>> +	struct ice_pf *pf = ptp_info_to_pf(info);
>> +	struct ice_hw *hw = &pf->hw;
>> +	bool sfd_ena;
>> +	int ret;
>> +
>> +	ice_ptp_lock(hw);
>> +	ret = ice_ptp_hw_ts_point_get(hw, &sfd_ena);
>> +	ice_ptp_unlock(hw);
>> +	if (!ret)
>> +		*point = sfd_ena ? PTP_TS_POINT_SFD : PTP_TS_POINT_POST_SFD;
>> +
>> +	return ret;
>> +}
>> +
>> +/**
>> + * ice_set_ts_point - set the tx timestamp latch point
>> + * @info: the driver's PTP info structure
>> + * @point: requested tx timestamp latch point
>
>nit: Please include documentation of the return value,
>     as was done for ice_get_ts_point.
>
>     Flagged by ./scripts/kernel-doc -none -Warn
>

Sure, will do.

Thank you!
Arkadiusz

>> + */
>> +static int
>> +ice_set_ts_point(struct ptp_clock_info *info, enum ptp_ts_point
>> +point) {
>> +	bool sfd_ena = point == PTP_TS_POINT_SFD ? true : false;
>> +	struct ice_pf *pf = ptp_info_to_pf(info);
>> +	struct ice_hw *hw = &pf->hw;
>> +	int ret;
>> +
>> +	ice_ptp_lock(hw);
>> +	ret = ice_ptp_hw_ts_point_set(hw, sfd_ena);
>> +	ice_ptp_unlock(hw);
>> +
>> +	return ret;
>> +}
>> +
>>  /**
>>   * ice_ptp_set_funcs_e82x - Set specialized functions for E82X support
>>   * @pf: Board private structure
>
>...
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
index a999fface272..47444412ed9a 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -2509,6 +2509,50 @@  static int ice_ptp_parse_sdp_entries(struct ice_pf *pf, __le16 *entries,
 	return 0;
 }
 
+/**
+ * ice_get_ts_point - get the tx timestamp latch point
+ * @info: the driver's PTP info structure
+ * @point: return the configured tx timestamp latch point
+ *
+ * Return: 0 on success, negative on failure.
+ */
+static int
+ice_get_ts_point(struct ptp_clock_info *info, enum ptp_ts_point *point)
+{
+	struct ice_pf *pf = ptp_info_to_pf(info);
+	struct ice_hw *hw = &pf->hw;
+	bool sfd_ena;
+	int ret;
+
+	ice_ptp_lock(hw);
+	ret = ice_ptp_hw_ts_point_get(hw, &sfd_ena);
+	ice_ptp_unlock(hw);
+	if (!ret)
+		*point = sfd_ena ? PTP_TS_POINT_SFD : PTP_TS_POINT_POST_SFD;
+
+	return ret;
+}
+
+/**
+ * ice_set_ts_point - set the tx timestamp latch point
+ * @info: the driver's PTP info structure
+ * @point: requested tx timestamp latch point
+ */
+static int
+ice_set_ts_point(struct ptp_clock_info *info, enum ptp_ts_point point)
+{
+	bool sfd_ena = point == PTP_TS_POINT_SFD ? true : false;
+	struct ice_pf *pf = ptp_info_to_pf(info);
+	struct ice_hw *hw = &pf->hw;
+	int ret;
+
+	ice_ptp_lock(hw);
+	ret = ice_ptp_hw_ts_point_set(hw, sfd_ena);
+	ice_ptp_unlock(hw);
+
+	return ret;
+}
+
 /**
  * ice_ptp_set_funcs_e82x - Set specialized functions for E82X support
  * @pf: Board private structure
@@ -2529,6 +2573,8 @@  static void ice_ptp_set_funcs_e82x(struct ice_pf *pf)
 	if (ice_is_e825c(&pf->hw)) {
 		pf->ptp.ice_pin_desc = ice_pin_desc_e825c;
 		pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e825c);
+		pf->ptp.info.set_ts_point = ice_set_ts_point;
+		pf->ptp.info.get_ts_point = ice_get_ts_point;
 	} else {
 		pf->ptp.ice_pin_desc = ice_pin_desc_e82x;
 		pf->ptp.info.n_pins = ICE_PIN_DESC_ARR_LEN(ice_pin_desc_e82x);
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index da88c6ccfaeb..d81525bc8a16 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -6303,3 +6303,60 @@  int ice_cgu_get_output_pin_state_caps(struct ice_hw *hw, u8 pin_id,
 
 	return 0;
 }
+
+/**
+ * ice_ptp_hw_ts_point_get - check if tx timestamping is latched on/post SFD
+ * @hw: pointer to the HW struct
+ * @sfd_ena: on success true if tx timestamping latched at beginning of SFD,
+ *	false if post sfd
+ *
+ * Verify if HW timestamping point is configured to measure at the beginning or
+ * post of SFD (Start of Frame Delimiter)
+ *
+ * Return: 0 on success, negative on error
+ */
+int ice_ptp_hw_ts_point_get(struct ice_hw *hw, bool *sfd_ena)
+{
+	u8 port = hw->port_info->lport;
+	u32 val;
+	int err;
+
+	err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val);
+	if (err)
+		return err;
+	if (val | PHY_MAC_XIF_TS_SFD_ENA_M)
+		*sfd_ena = true;
+	else
+		*sfd_ena = false;
+
+	return err;
+}
+
+/**
+ * ice_ptp_hw_ts_point_set - configure timestamping on/post SFD
+ * @hw: pointer to the HW struct
+ * @sfd_ena: true to enable timestamping at beginning of SFD, false post sfd
+ *
+ * Configure timestamping to measure at the beginning/post SFD (Start of Frame
+ * Delimiter)
+ *
+ * Return: 0 on success, negative on error
+ */
+int ice_ptp_hw_ts_point_set(struct ice_hw *hw, bool sfd_ena)
+{
+	u8 port = hw->port_info->lport;
+	int err, val;
+
+	err = ice_read_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, &val);
+	if (err)
+		return err;
+	if ((val | PHY_MAC_XIF_TS_SFD_ENA_M && sfd_ena) ||
+	    (!(val | PHY_MAC_XIF_TS_SFD_ENA_M) && !sfd_ena))
+		return -EINVAL;
+	if (sfd_ena)
+		val |= PHY_MAC_XIF_TS_SFD_ENA_M;
+	else
+		val &= ~PHY_MAC_XIF_TS_SFD_ENA_M;
+
+	return ice_write_mac_reg_eth56g(hw, port, PHY_MAC_XIF_MODE, val);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
index 656daff3447e..cefedd01479a 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
@@ -348,6 +348,8 @@  void ice_ptp_init_hw(struct ice_hw *hw);
 int ice_get_phy_tx_tstamp_ready(struct ice_hw *hw, u8 block, u64 *tstamp_ready);
 int ice_ptp_one_port_cmd(struct ice_hw *hw, u8 configured_port,
 			 enum ice_ptp_tmr_cmd configured_cmd);
+int ice_ptp_hw_ts_point_get(struct ice_hw *hw, bool *sfd_ena);
+int ice_ptp_hw_ts_point_set(struct ice_hw *hw, bool sfd_ena);
 
 /* E822 family functions */
 int ice_read_quad_reg_e82x(struct ice_hw *hw, u8 quad, u16 offset, u32 *val);