lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221209150634.gb3mdxphq3dt3kfi@skbuf>
Date:   Fri, 9 Dec 2022 17:06:34 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Arun Ramadoss <arun.ramadoss@...rochip.com>
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        woojung.huh@...rochip.com, UNGLinuxDriver@...rochip.com,
        andrew@...n.ch, vivien.didelot@...il.com, f.fainelli@...il.com,
        davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, linux@...linux.org.uk,
        Tristram.Ha@...rochip.com, richardcochran@...il.com,
        ceggers@...i.de
Subject: Re: [Patch net-next v3 07/13] net: dsa: microchip: ptp: add packet
 reception timestamping

On Fri, Dec 09, 2022 at 12:54:31PM +0530, Arun Ramadoss wrote:
> From: Christian Eggers <ceggers@...i.de>
> 
> Rx Timestamping is done through 4 additional bytes in tail tag.
> Whenever the ptp packet is received, the 4 byte hardware time stamped
> value is added before 1 byte tail tag. Also, bit 7 in tail tag indicates
> it as PTP frame. This 4 byte value is extracted from the tail tag and
> reconstructed to absolute time and assigned to skb hwtstamp.
> If the packet received in PDelay_Resp, then partial ingress timestamp
> is subtracted from the correction field. Since user space tools expects
> to be done in hardware.
> 
> Signed-off-by: Christian Eggers <ceggers@...i.de>
> Co-developed-by: Arun Ramadoss <arun.ramadoss@...rochip.com>
> Signed-off-by: Arun Ramadoss <arun.ramadoss@...rochip.com>
> 
> ---

Reviewed-by: Vladimir Oltean <olteanv@...il.com>

> +bool ksz_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,
> +		       unsigned int type)
> +{
> +	struct skb_shared_hwtstamps *hwtstamps = skb_hwtstamps(skb);
> +	struct ksz_device *dev = ds->priv;
> +	struct ptp_header *ptp_hdr;
> +	u8 ptp_msg_type;
> +	ktime_t tstamp;
> +	s64 correction;
> +
> +	tstamp = KSZ_SKB_CB(skb)->tstamp;
> +	memset(hwtstamps, 0, sizeof(*hwtstamps));
> +	hwtstamps->hwtstamp = ksz_tstamp_reconstruct(dev, tstamp);
> +
> +	ptp_hdr = ptp_parse_header(skb, type);
> +	if (!ptp_hdr)
> +		goto out;
> +
> +	ptp_msg_type = ptp_get_msgtype(ptp_hdr, type);
> +	if (ptp_msg_type != PTP_MSGTYPE_PDELAY_REQ)
> +		goto out;
> +
> +	/* Only subtract the partial time stamp from the correction field.  When
> +	 * the hardware adds the egress time stamp to the correction field of
> +	 * the PDelay_Resp message on tx, also only the partial time stamp will
> +	 * be added.
> +	 */
> +	correction = (s64)get_unaligned_be64(&ptp_hdr->correction);
> +	correction -= ktime_to_ns(tstamp) << 16;
> +
> +	ptp_header_update_correction(skb, type, ptp_hdr, correction);
> +
> +out:
> +	return 0;

Nitpick: port_rxtstamp() returns "bool" as in "should reception of this
packet be deferred until the full RX timestamp is available?". The
answer of 0 is coincidentally correct, but should have been "false".

> +}
> +
>  static int _ksz_ptp_gettime(struct ksz_device *dev, struct timespec64 *ts)
>  {
>  	u32 nanoseconds;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ