All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keller, Jacob E <jacob.e.keller@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [net-next PATCH 9/9] ice: support crosstimestamping on E822 devices if supported
Date: Tue, 12 Oct 2021 00:58:08 +0000	[thread overview]
Message-ID: <CO1PR11MB5089AC81D4843D4F7D50A00FD6B69@CO1PR11MB5089.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87mtnfhz21.fsf@linux.intel.com>



> -----Original Message-----
> From: Gomes, Vinicius <vinicius.gomes@intel.com>
> Sent: Monday, October 11, 2021 5:23 PM
> To: Keller, Jacob E <jacob.e.keller@intel.com>; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>; Intel Wired LAN <intel-wired-
> lan at lists.osuosl.org>
> Subject: Re: [Intel-wired-lan] [net-next PATCH 9/9] ice: support
> crosstimestamping on E822 devices if supported
> 
> Jacob Keller <jacob.e.keller@intel.com> writes:
> 
> > E822 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: Jacob Keller <jacob.e.keller@intel.com>
> > ---
> >  .../net/ethernet/intel/ice/ice_hw_autogen.h   |   8 ++
> >  drivers/net/ethernet/intel/ice/ice_ptp.c      | 113 ++++++++++++++++++
> >  2 files changed, 121 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> > index 7bff0450b76c..d16738a3d3a7 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> > +++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> > @@ -441,6 +441,10 @@
> >  #define GLV_UPRCL(_i)				(0x003B2000 + ((_i) * 8))
> >  #define GLV_UPTCL(_i)				(0x0030A000 + ((_i) * 8))
> >  #define PRTRPB_RDPC				0x000AC260
> > +#define GLHH_ART_CTL				0x000A41D4
> > +#define GLHH_ART_CTL_ACTIVE_M			BIT(0)
> > +#define GLHH_ART_TIME_H				0x000A41D8
> > +#define GLHH_ART_TIME_L				0x000A41DC
> >  #define GLTSYN_AUX_IN_0(_i)			(0x000889D8 + ((_i) * 4))
> >  #define GLTSYN_AUX_IN_0_INT_ENA_M		BIT(4)
> >  #define GLTSYN_AUX_OUT_0(_i)			(0x00088998 + ((_i) * 4))
> > @@ -453,6 +457,8 @@
> >  #define GLTSYN_ENA_TSYN_ENA_M			BIT(0)
> >  #define GLTSYN_EVNT_H_0(_i)			(0x00088970 + ((_i) * 4))
> >  #define GLTSYN_EVNT_L_0(_i)			(0x00088968 + ((_i) * 4))
> > +#define GLTSYN_HHTIME_H(_i)			(0x00088900 + ((_i) * 4))
> > +#define GLTSYN_HHTIME_L(_i)			(0x000888F8 + ((_i) * 4))
> >  #define GLTSYN_INCVAL_H(_i)			(0x00088920 + ((_i) * 4))
> >  #define GLTSYN_INCVAL_L(_i)			(0x00088918 + ((_i) * 4))
> >  #define GLTSYN_SHADJ_H(_i)			(0x00088910 + ((_i) * 4))
> > @@ -469,6 +475,8 @@
> >  #define GLTSYN_TGT_L_0(_i)			(0x00088928 + ((_i) * 4))
> >  #define GLTSYN_TIME_H(_i)			(0x000888D8 + ((_i) * 4))
> >  #define GLTSYN_TIME_L(_i)			(0x000888D0 + ((_i) * 4))
> > +#define PFHH_SEM				0x000A4200 /* Reset Source: PFR
> */
> > +#define PFHH_SEM_BUSY_M				BIT(0)
> >  #define PFTSYN_SEM				0x00088880
> >  #define PFTSYN_SEM_BUSY_M			BIT(0)
> >  #define VSIQF_FD_CNT(_VSI)			(0x00464000 + ((_VSI) * 4))
> > diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c
> b/drivers/net/ethernet/intel/ice/ice_ptp.c
> > index 047914111389..ea853a744376 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> > @@ -1598,6 +1598,99 @@ static int ice_ptp_adjtime(struct ptp_clock_info
> *info, s64 delta)
> >  	return 0;
> >  }
> >
> > +/**
> > + * ice_ptp_get_syncdevicetime - Get the cross time stamp info
> > + * @device: Current device time
> > + * @system: System counter value read synchronously with device time
> > + * @ctx: Context provided by timekeeping code
> > + *
> > + * Read device and system (ART) clock simultaneously and return the
> corrected
> > + * clock values in ns.
> > + */
> > +static int
> > +ice_ptp_get_syncdevicetime(ktime_t *device,
> > +			   struct system_counterval_t *system,
> > +			   void *ctx)
> > +{
> > +	struct ice_pf *pf = (struct ice_pf *)ctx;
> > +	struct ice_hw *hw = &pf->hw;
> > +	u32 hh_lock, hh_art_ctl;
> > +	int i;
> > +
> > +	/* Get the HW lock */
> > +	hh_lock = rd32(hw, PFHH_SEM + (PFTSYN_SEM_BYTES * hw->pf_id));
> > +	if (hh_lock & PFHH_SEM_BUSY_M) {
> > +		dev_err(ice_pf_to_dev(pf), "PTP failed to get hh lock\n");
> > +		return -EFAULT;
> > +	}
> > +
> > +	/* Start the ART and device clock sync sequence */
> > +	hh_art_ctl = rd32(hw, GLHH_ART_CTL);
> > +	hh_art_ctl = hh_art_ctl | GLHH_ART_CTL_ACTIVE_M;
> > +	wr32(hw, GLHH_ART_CTL, hh_art_ctl);
> > +
> > +#define MAX_HH_LOCK_TRIES 100
> > +
> > +	for (i = 0; i < MAX_HH_LOCK_TRIES; i++) {
> > +		/* Wait for sync to complete */
> > +		hh_art_ctl = rd32(hw, GLHH_ART_CTL);
> > +		if (hh_art_ctl & GLHH_ART_CTL_ACTIVE_M) {
> > +			udelay(1);
> > +			continue;
> > +		} else {
> > +			u32 hh_ts_lo, hh_ts_hi, tmr_idx;
> > +			u64 hh_ts;
> > +
> > +			tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
> > +			/* Read ART time */
> > +			hh_ts_lo = rd32(hw, GLHH_ART_TIME_L);
> > +			hh_ts_hi = rd32(hw, GLHH_ART_TIME_H);
> > +			hh_ts = ((u64)hh_ts_hi << 32) | hh_ts_lo;
> > +			*system = convert_art_ns_to_tsc(hh_ts);
> 
> Note that convert_art_ns_to_tsc() is only defined for x86, will not
> compile for others.
> 
> For igc, I wrote a very simple wrapper, if you have better suggestions I
> also would like to hear :-)
> 

I must have accidentally grabbed an out-of-date version of the series. This should have included the ICE_HWTS config option which disables this support except for X86

I'll resend with the fixed patch and double check all of the other fixes from previous versions made it in as well..

Thanks,
Jake



      reply	other threads:[~2021-10-12  0:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 21:54 [Intel-wired-lan] [net-next PATCH 0/9] implement support for PTP on E822 hardware Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 1/9] ice: introduce ice_base_incval function Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 2/9] ice: PTP: move setting of tstamp_config Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 3/9] ice: use 'int err' instead of 'int status' in ice_ptp_hw.c Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 4/9] ice: introduce ice_ptp_init_phc function Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 5/9] ice: convert clk_freq capability into time_ref Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 6/9] ice: implement basic E822 PTP support Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 7/9] ice: ensure the hardware Clock Generation Unit is configured Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 8/9] ice: exit bypass mode once hardware finishes timestamp calibration Jacob Keller
2021-10-11 21:54 ` [Intel-wired-lan] [net-next PATCH 9/9] ice: support crosstimestamping on E822 devices if supported Jacob Keller
2021-10-12  0:22   ` Vinicius Costa Gomes
2021-10-12  0:58     ` Keller, Jacob E [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB5089AC81D4843D4F7D50A00FD6B69@CO1PR11MB5089.namprd11.prod.outlook.com \
    --to=jacob.e.keller@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.