linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Arun.Ramadoss@microchip.com>
To: <olteanv@gmail.com>, <ceggers@arri.de>
Cc: <andrew@lunn.ch>, <linux-kernel@vger.kernel.org>,
	<UNGLinuxDriver@microchip.com>, <vivien.didelot@gmail.com>,
	<linux@armlinux.org.uk>, <Tristram.Ha@microchip.com>,
	<f.fainelli@gmail.com>, <kuba@kernel.org>, <edumazet@google.com>,
	<pabeni@redhat.com>, <richardcochran@gmail.com>,
	<netdev@vger.kernel.org>, <Woojung.Huh@microchip.com>,
	<davem@davemloft.net>, <b.hutchman@gmail.com>
Subject: Re: [RFC Patch net-next 0/6] net: dsa: microchip: add gPTP support for LAN937x switch
Date: Thu, 27 Oct 2022 15:51:54 +0000	[thread overview]
Message-ID: <cd9bed118823c23bb0080f904fab9371e4eb9a25.camel@microchip.com> (raw)
In-Reply-To: <20221026214455.3n5f7eqp3duuie22@skbuf>

Hi Christian,
On Thu, 2022-10-27 at 00:44 +0300, Vladimir Oltean wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> On Wed, Oct 26, 2022 at 06:47:53PM +0200, Christian Eggers wrote:
> > Hi Arun, hi Vladimir,
> > 
> > On Tuesday, 18 October 2022, 15:42:41 CEST, 
> > Arun.Ramadoss@microchip.com wrote:
> > > ...
> > > Thanks Vladimir. I will wait for Christian feedback.
> > > 
> > > Hi Christian,
> > > To test this patch on KSZ9563, we need to increase the number of
> > > interrupts port_nirqs in KSZ9893 from 2 to 3. Since the chip id
> > > of
> > > KSZ9893 and KSZ9563 are same, I had reused the ksz_chip_data same
> > > for
> > > both chips. But this chip differ with number of port interrupts.
> > > So we
> > > need to update it. We are generating a new patch for adding the
> > > new
> > > element in the ksz_chip_data for KSZ9563.
> > > For now, you can update the code as below for testing the patch
> > 
> > today I hard first success with your patch series on KSZ9563! ptp4l
> > reported
> > delay measurements between switch port 1 and the connected Meinberg
> > clock:

I tried to bring up the KSZ9563 setup following are my observation
- With this patch series, I am getting the Null pointer exception.
- After applying the patch provided by you, switch probe is successful.

Usually I test the gPTP using the following command
# ptp4l -f ~/ptp4l/gPTP.cfg -i lan1

How did you test this PTP in your setup, so that I can also get the
same result as below.

> > 
> > > ptp4l[75.590]: port 2: new foreign master ec4670.fffe.0a9dcc-1
> > > ptp4l[79.590]: selected best master clock ec4670.fffe.0a9dcc
> > > ptp4l[79.590]: updating UTC offset to 37
> > > ptp4l[79.591]: port 2: LISTENING to UNCALIBRATED on RS_SLAVE
> > > ptp4l[81.114]: port 2: delay timeout
> > > ptp4l[81.117]: delay   filtered        338   raw        338
> > > ptp4l[81.118]: port 2: minimum delay request interval 2^1
> > > ptp4l[81.434]: port 1: announce timeout
> > > ptp4l[81.434]: config item lan0.udp_ttl is 1
> > > ptp4l[81.436]: config item (null).dscp_event is 0
> > > ptp4l[81.437]: config item (null).dscp_general is 0
> > > ptp4l[81.437]: selected best master clock ec4670.fffe.0a9dcc
> > > ptp4l[81.438]: updating UTC offset to 37
> > > ptp4l[81.843]: master offset         33 s0 freq   +6937 path
> > > delay       338
> > > ptp4l[82.844]: master offset         26 s2 freq   +6930 path
> > > delay       338
> > > ptp4l[82.844]: port 2: UNCALIBRATED to SLAVE on
> > > MASTER_CLOCK_SELECTED
> > > ptp4l[83.844]: master offset         32 s2 freq   +6962 path
> > > delay       338
> > > ptp4l[84.844]: master offset          3 s2 freq   +6943 path
> > > delay       338
> > > ptp4l[85.844]: master offset        -14 s2 freq   +6927 path
> > > delay       338
> > > ptp4l[86.042]: port 2: delay timeout
> > > ptp4l[86.045]: delay   filtered        336   raw        335
> > > ptp4l[86.211]: port 2: delay timeout
> > > ptp4l[86.213]: delay   filtered        335   raw        331
> > > ptp4l[86.844]: master offset          3 s2 freq   +6939 path
> > > delay       335
> > > ptp4l[87.847]: master offset         -7 s2 freq   +6930 path
> > > delay       335
> > 
> > As a next step I'll try to configure the external output for 1PPS.
> > Is this
> > already implemented in your patches? The file
> > /sys/class/ptp/ptp2/n_periodic_outputs
> > shows '0' on my system.
> 
> Arun didn't share the PPS output patch publicly, so I don't know why
> we're discussing this here. Anyway, in it, Arun (incorrectly)
> implemented support for PTP_CLK_REQ_PPS rather than
> PTP_CLK_REQ_PEROUT,
> so there will not be any n_periodic_outputs visible in sysfs. For
> now,
> try via pps_available and pps_enable.
> 
> > 
> > BTW: Which is the preferred delay measurement which I shall test
> > (E2E/P2P)?
> 
> As this time around there is somebody from Microchip finally on the
> line, I will not interfere in this part. I tried once, and failed to
> understand the KSZ PTP philosophy. I hope you get some answers from
> Arun. Just one question below.
> 
> > I started with E2E is this was configured in the hardware and needs
> > no 1-step
> > time stamping, but I had to add PTP_MSGTYPE_DELAY_REQ in
> > ksz_port_txtstamp().
> 
> Hm? So if E2E "doesn't need" 1-step TX timestamping and KSZ9563
> doesn't
> support 2-step TX timestamping, then what kind of TX timestamping is
> used here for Delay_Req messages?
> 
> Perhaps you mean that E2E doesn't need moving the RX timestamp of the
> Pdelay_Req (t2) into the KSZ TX timestamp trailer of the Pdelay_Resp
> (t3)?
> 
> > > May be this is due to kconfig of config_ksz_ptp  defined bool
> > > instead
> > > of tristate. Do I need to change the config_ksz_ptp to tristate
> > > in
> > > order to compile as modules?
> > 
> > I'm not an expert for kbuild and cannot tell whether it's allowed
> > to use
> > bool options which depend on tristate options. At least ksz_ptp.c
> > is compiled
> > by kbuild if tristate is used. But I needed to add additional
> > EXPORT_SYMBOL()
> > statements for all non-static functions (see below) for successful
> > linking.
> 
> If ksz_ptp.o gets linked into ksz_ptp.ko, then yes. But this probably
> doesn't make sense, as you point out. So EXPORT_SYMBOL() should not
> be
> needed.
> 
> > I'm unsure whether it makes sense to build ksz_ptp as a separate
> > module.
> > Perhaps it should be (conditionally) added to ksz_switch.ko.
> > 
> > On Tuesday, 18 October 2022, 08:44:04 CEST, 
> > Arun.Ramadoss@microchip.com wrote:
> > > I had developed this patch set to add gPTP support for LAN937x
> > > based on
> > > the Christian eggers patch for KSZ9563.
> > 
> > Maybe this could be mentioned somewhere (e.g. extra line in file
> > header of
> > ksz_ptp.c). 

Sure, I will add it in the File Header in the next version.

> >  It took a lot of effort (for me) to get this initially running
> > (e.g. due to limited documentation / support by Microchip).  But
> > I'm quite happy
> > that this is continued now as it is likely that I'll need PTP
> > support for the
> > KSZ9563 soon.
> > 
> > For KSZ9563, we will need support for 1-step time stamping as two-
> > step
> > is not possible.
> > 
> > I've stashed all my local changes into an additional patch (see
> > below).
> > Please feel free to integrate this into your series.  As soon I get
> > 1PPS
> > running, I'll continue testing. 

I thought 1PPS and periodic output are same, So I sent the 1PPS patch.
I need to look into periodic output.

> >  Note that I'll be unavailable between Friday
> > and next Tuesday.

If you can elaborate the test need to be done in KSZ9563, I can try to
do during your Vacation.

> > 
> > regards,
> > Christian
> >  static int ksz_set_hwtstamp_config(struct ksz_device *dev, int
> > port,
> >                                  struct hwtstamp_config *config)
> > @@ -106,7 +108,7 @@ static int ksz_set_hwtstamp_config(struct
> > ksz_device *dev, int port,
> >       case HWTSTAMP_TX_OFF:
> >               prt->hwts_tx_en = false;
> >               break;
> > -     case HWTSTAMP_TX_ON:
> > +     case HWTSTAMP_TX_ONESTEP_P2P:
> 
> One shouldn't replace the other; this implementation is simplistic,
> of course.
> 
> Also, why did you choose HWTSTAMP_TX_ONESTEP_P2P and not
> HWTSTAMP_TX_ONESTEP_SYNC?
> 
> >               prt->hwts_tx_en = true;
> >               break;
> >       default:
> > @@ -162,6 +164,7 @@ int ksz_hwtstamp_set(struct dsa_switch *ds, int
> > port, struct ifreq *ifr)
> >       mutex_unlock(&ptp_data->lock);
> >       return ret;
> >  }
> > +EXPORT_SYMBOL(ksz_hwtstamp_set);
> > diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
> > index 582add3398d3..e7680718b478 100644
> > --- a/net/dsa/tag_ksz.c
> > +++ b/net/dsa/tag_ksz.c
> > @@ -251,17 +251,69 @@
> > MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9477);
> >  #define KSZ9893_TAIL_TAG_OVERRIDE    BIT(5)
> >  #define KSZ9893_TAIL_TAG_LOOKUP              BIT(6)
> > 
> > +/* Time stamp tag is only inserted if PTP is enabled in hardware.
> > */
> > +static void ksz9893_xmit_timestamp(struct sk_buff *skb)
> > +{
> > +//   struct sk_buff *clone = KSZ9477_SKB_CB(skb)->clone;
> > +//   struct ptp_header *ptp_hdr;
> > +//   unsigned int ptp_type;
> > +     u32 tstamp_raw = 0;
> > +     put_unaligned_be32(tstamp_raw, skb_put(skb,
> > KSZ9477_PTP_TAG_LEN));
> > +}
> 
> This is needed for one-step TX timestamping, ok.
> 
> > +
> > +/* Defer transmit if waiting for egress time stamp is
> > required.  */
> > +static struct sk_buff *ksz9893_defer_xmit(struct dsa_port *dp,
> > +                                       struct sk_buff *skb)
> 
> No need to duplicate, can rename lan937x_defer_xmit() and call that.
> 
> Although I'm not exactly clear *which* packets will need deferred
> transmission on ksz9xxx. To my knowledge, such a procedure is only
> necessary for 2-step TX timestamping, when the TX timestamp must be
> propagated back to the socket error queue via
> skb_complete_tx_timestamp().
> For one-step, AFAIK*, this isn't needed.
> 
> This is not used, right? Because the function call is shortcircuited
> by
> the "if (test_bit(KSZ_HWTS_EN, &priv->state))" test earlier.
> 
> *Or is this intended to be used for the "Software Two-Step Simulation
> Mode in hardware 1-Step Mode" that was suggested in the errata sheet,
> where one-step Sync messages still get their TX timestamp reported to
> user space as if they were two-step?
> 
http://ww1.microchip.com/downloads/en/DeviceDoc/KSZ9563R-Errata-80000786B.pdf

  reply	other threads:[~2022-10-27 15:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 15:28 [RFC Patch net-next 0/6] net: dsa: microchip: add gPTP support for LAN937x switch Arun Ramadoss
2022-10-14 15:28 ` [RFC Patch net-next 1/6] net: dsa: microchip: adding the posix clock support Arun Ramadoss
2022-10-14 15:28 ` [RFC Patch net-next 2/6] net: dsa: microchip: Initial hardware time stamping support Arun Ramadoss
2022-10-14 15:28 ` [RFC Patch net-next 3/6] net: dsa: microchip: Manipulating absolute time using ptp hw clock Arun Ramadoss
2022-10-14 15:28 ` [RFC Patch net-next 4/6] net: dsa: microchip: enable the ptp interrupt for timestamping Arun Ramadoss
2022-10-14 15:28 ` [RFC Patch net-next 5/6] net: dsa: microchip: Adding the ptp packet reception logic Arun Ramadoss
2022-10-25  6:17   ` Christian Eggers
2022-10-26 20:13     ` Vladimir Oltean
2022-10-14 15:28 ` [RFC Patch net-next 6/6] net: dsa: microchip: add the transmission tstamp logic Arun Ramadoss
2022-10-17 17:19 ` [RFC Patch net-next 0/6] net: dsa: microchip: add gPTP support for LAN937x switch Vladimir Oltean
2022-10-18  6:44   ` Arun.Ramadoss
2022-10-18 10:29     ` Vladimir Oltean
2022-10-18 13:42       ` Arun.Ramadoss
2022-10-23 20:15         ` Christian Eggers
2022-10-25  3:41           ` Arun.Ramadoss
2022-10-26 20:07             ` Vladimir Oltean
2022-10-26 16:47         ` Christian Eggers
2022-10-26 21:44           ` Vladimir Oltean
2022-10-27 15:51             ` Arun.Ramadoss [this message]
2022-11-02 13:12               ` Christian Eggers
2022-11-02 13:11             ` Christian Eggers
2022-11-04 10:36               ` Arun.Ramadoss
2022-10-17 18:46 ` Vladimir Oltean
2022-10-18  6:29   ` Arun.Ramadoss
2022-10-18  9:55     ` Vladimir Oltean

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=cd9bed118823c23bb0080f904fab9371e4eb9a25.camel@microchip.com \
    --to=arun.ramadoss@microchip.com \
    --cc=Tristram.Ha@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=Woojung.Huh@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=b.hutchman@gmail.com \
    --cc=ceggers@arri.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vivien.didelot@gmail.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).