diff mbox series

[net-next,2/2] ice: Add crosstimestamping on E823 devices

Message ID 20220916131440.566617-2-karol.kolacinski@intel.com
State Changes Requested
Headers show
Series [net-next,1/2] ice: Add GPIO pin support for E823 products | expand

Commit Message

Karol Kolacinski Sept. 16, 2022, 1:14 p.m. UTC
E823 devices on supported platforms can generate a cross timestamp
between the platform ART and the device time. This process allows for
very precise measurement of the difference between the PTP hardware
clock and the platform time.

This is only supported if we know the TSC frequency relative to ART, so
we do not enable this unless the boot CPU has a known TSC frequency (as
required by convert_art_ns_to_tsc).

Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Tony Nguyen Sept. 16, 2022, 10:07 p.m. UTC | #1
On 9/16/2022 6:14 AM, Karol Kolacinski wrote:
> E823 devices on supported platforms can generate a cross timestamp
> between the platform ART and the device time. This process allows for
> very precise measurement of the difference between the PTP hardware
> clock and the platform time.
> 
> This is only supported if we know the TSC frequency relative to ART, so
> we do not enable this unless the boot CPU has a known TSC frequency (as
> required by convert_art_ns_to_tsc).
> 
> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com>
> ---
>   drivers/net/ethernet/intel/ice/ice_ptp.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 408beddc1210..0b37e3d1ef68 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -2036,7 +2036,7 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
>   }
>   
>   /**
> - * ice_ptp_getcrosststamp_e822 - Capture a device cross timestamp
> + * ice_ptp_getcrosststamp_generic - Capture a device cross timestamp

IMO generic is implied if there is not a specific device put to it. I 
don't think we need to specifically call it generic...

>    * @info: the driver's PTP info structure
>    * @cts: The memory to fill the cross timestamp info
>    *
> @@ -2044,15 +2044,15 @@ ice_ptp_get_syncdevicetime(ktime_t *device,
>    * clock. Fill the cross timestamp information and report it back to the
>    * caller.
>    *
> - * This is only valid for E822 devices which have support for generating the
> - * cross timestamp via PCIe PTM.
> + * This is only valid for E822 and E823 devices which have support for

... however it's still kind of device specific as it's for E822 and 
E823. Seems like E822 functions are used for both E822 and E823 so I 
think leaving the name as is or, perhaps, calling it '_e82x'?

> + * generating the cross timestamp via PCIe PTM.
>    *
>    * In order to correctly correlate the ART timestamp back to the TSC time, the
>    * CPU must have X86_FEATURE_TSC_KNOWN_FREQ.
>    */
>   static int
> -ice_ptp_getcrosststamp_e822(struct ptp_clock_info *info,
> -			    struct system_device_crosststamp *cts)
> +ice_ptp_getcrosststamp_generic(struct ptp_clock_info *info,
> +			       struct system_device_crosststamp *cts)
>   {
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 408beddc1210..0b37e3d1ef68 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
@@ -2036,7 +2036,7 @@  ice_ptp_get_syncdevicetime(ktime_t *device,
 }
 
 /**
- * ice_ptp_getcrosststamp_e822 - Capture a device cross timestamp
+ * ice_ptp_getcrosststamp_generic - Capture a device cross timestamp
  * @info: the driver's PTP info structure
  * @cts: The memory to fill the cross timestamp info
  *
@@ -2044,15 +2044,15 @@  ice_ptp_get_syncdevicetime(ktime_t *device,
  * clock. Fill the cross timestamp information and report it back to the
  * caller.
  *
- * This is only valid for E822 devices which have support for generating the
- * cross timestamp via PCIe PTM.
+ * This is only valid for E822 and E823 devices which have support for
+ * generating the cross timestamp via PCIe PTM.
  *
  * In order to correctly correlate the ART timestamp back to the TSC time, the
  * CPU must have X86_FEATURE_TSC_KNOWN_FREQ.
  */
 static int
-ice_ptp_getcrosststamp_e822(struct ptp_clock_info *info,
-			    struct system_device_crosststamp *cts)
+ice_ptp_getcrosststamp_generic(struct ptp_clock_info *info,
+			       struct system_device_crosststamp *cts)
 {
 	struct ice_pf *pf = ptp_info_to_pf(info);
 
@@ -2300,7 +2300,7 @@  ice_ptp_set_funcs_e822(struct ice_pf *pf, struct ptp_clock_info *info)
 #ifdef CONFIG_ICE_HWTS
 	if (boot_cpu_has(X86_FEATURE_ART) &&
 	    boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ))
-		info->getcrosststamp = ice_ptp_getcrosststamp_e822;
+		info->getcrosststamp = ice_ptp_getcrosststamp_generic;
 #endif /* CONFIG_ICE_HWTS */
 }
 
@@ -2334,6 +2334,12 @@  ice_ptp_set_funcs_e810(struct ice_pf *pf, struct ptp_clock_info *info)
 static void
 ice_ptp_set_funcs_e823(struct ice_pf *pf, struct ptp_clock_info *info)
 {
+#ifdef CONFIG_ICE_HWTS
+	if (boot_cpu_has(X86_FEATURE_ART) &&
+	    boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ))
+		info->getcrosststamp = ice_ptp_getcrosststamp_generic;
+#endif /* CONFIG_ICE_HWTS */
+
 	info->enable = ice_ptp_gpio_enable_e823;
 	ice_ptp_setup_pins_e823(pf, info);
 }