netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Olivier Dautricourt <olivier.dautricourt@orolia.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"David S . Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 3/3] net: stmmac: Support coarse mode through ioctl
Date: Tue, 26 May 2020 20:55:09 -0700	[thread overview]
Message-ID: <20200527035509.GA18483@localhost> (raw)
In-Reply-To: <20200514102808.31163-4-olivier.dautricourt@orolia.com>

On Thu, May 14, 2020 at 12:28:08PM +0200, Olivier Dautricourt wrote:
> The required time adjustment is written in the Timestamp Update registers
> while the Sub-second increment register is programmed with the period
> of the clock, which is the precision of our correction.

I don't see in this patch where the "required time adjustment is
written in the Timestamp Update registers".

What am I missing?

Thanks,
Richard


> 
> The fine adjutment mode is always the default behavior of the driver.
> One should use the HWTSAMP_FLAG_ADJ_COARSE flag while calling
> SIOCGHWTSTAMP ioctl to enable coarse mode for stmmac driver.
> 
> Signed-off-by: Olivier Dautricourt <olivier.dautricourt@orolia.com>
> ---
>  .../net/ethernet/stmicro/stmmac/stmmac_main.c   | 17 +++++++++++++----
>  .../net/ethernet/stmicro/stmmac/stmmac_ptp.c    |  3 +++
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index c39fafe69b12..f46503b086f4 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -541,9 +541,12 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
>  	netdev_dbg(priv->dev, "%s config flags:0x%x, tx_type:0x%x, rx_filter:0x%x\n",
>  		   __func__, config.flags, config.tx_type, config.rx_filter);
>  
> -	/* reserved for future extensions */
> -	if (config.flags)
> -		return -EINVAL;
> +	if (config.flags != HWTSTAMP_FLAGS_ADJ_COARSE) {
> +		/* Defaulting to fine adjustment for compatibility */
> +		netdev_dbg(priv->dev, "%s defaulting to fine adjustment mode\n",
> +			   __func__);
> +		config.flags = HWTSTAMP_FLAGS_ADJ_FINE;
> +	}
>  
>  	if (config.tx_type != HWTSTAMP_TX_OFF &&
>  	    config.tx_type != HWTSTAMP_TX_ON)
> @@ -689,10 +692,16 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
>  		stmmac_set_hw_tstamping(priv, priv->ptpaddr, 0);
>  	else {
>  		stmmac_get_hw_tstamping(priv, priv->ptpaddr, &value);
> -		value |= (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | PTP_TCR_TSCTRLSSR |
> +		value |= (PTP_TCR_TSENA |  PTP_TCR_TSCTRLSSR |
>  			 tstamp_all | ptp_v2 | ptp_over_ethernet |
>  			 ptp_over_ipv6_udp | ptp_over_ipv4_udp | ts_event_en |
>  			 ts_master_en | snap_type_sel);
> +
> +		if (config.flags == HWTSTAMP_FLAGS_ADJ_FINE)
> +			value |= PTP_TCR_TSCFUPDT;
> +		else
> +			value &= ~PTP_TCR_TSCFUPDT;
> +
>  		stmmac_set_hw_tstamping(priv, priv->ptpaddr, value);
>  
>  		/* program Sub Second Increment reg */
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
> index 920f0f3ebbca..7fb318441015 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
> @@ -27,6 +27,9 @@ static int stmmac_adjust_freq(struct ptp_clock_info *ptp, s32 ppb)
>  	int neg_adj = 0;
>  	u64 adj;
>  
> +	if (priv->tstamp_config.flags != HWTSTAMP_FLAGS_ADJ_FINE)
> +		return -EPERM;
> +
>  	if (ppb < 0) {
>  		neg_adj = 1;
>  		ppb = -ppb;
> -- 
> 2.17.1
> 

  reply	other threads:[~2020-05-27  3:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 10:28 [PATCH 0/3] Patch series for a PTP Grandmaster use case using stmmac/gmac3 ptp clock Olivier Dautricourt
2020-05-14 10:28 ` [PATCH 1/3] net: stmmac: gmac3: add auxiliary snapshot support Olivier Dautricourt
2020-05-14 10:28 ` [PATCH 2/3] net: uapi: Add HWTSTAMP_FLAGS_ADJ_FINE/ADJ_COARSE Olivier Dautricourt
2020-05-14 13:38   ` Richard Cochran
2020-05-14 15:20     ` Olivier Dautricourt
2020-05-15  0:29       ` Richard Cochran
2020-05-14 10:28 ` [PATCH 3/3] net: stmmac: Support coarse mode through ioctl Olivier Dautricourt
2020-05-27  3:55   ` Richard Cochran [this message]
2020-06-03 16:12     ` Olivier Dautricourt
2020-05-14 13:53 ` [PATCH 0/3] Patch series for a PTP Grandmaster use case using stmmac/gmac3 ptp clock Richard Cochran
2020-05-14 15:09   ` Olivier Dautricourt
2020-05-15  0:37     ` Richard Cochran
2020-05-15 13:26       ` Julien Beraud
2020-05-15 23:30         ` Richard Cochran
2020-05-25 10:00           ` Olivier Dautricourt
2020-05-27  4:05         ` Richard Cochran
2020-06-03 15:17           ` Olivier Dautricourt

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=20200527035509.GA18483@localhost \
    --to=richardcochran@gmail.com \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=joabreu@synopsys.com \
    --cc=netdev@vger.kernel.org \
    --cc=olivier.dautricourt@orolia.com \
    --cc=peppe.cavallaro@st.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).