From: <Arun.Ramadoss@microchip.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<pabeni@redhat.com>
Cc: <olteanv@gmail.com>, <UNGLinuxDriver@microchip.com>,
<vivien.didelot@gmail.com>, <andrew@lunn.ch>,
<linux@armlinux.org.uk>, <ceggers@arri.de>,
<Tristram.Ha@microchip.com>, <f.fainelli@gmail.com>,
<kuba@kernel.org>, <edumazet@google.com>,
<richardcochran@gmail.com>, <Woojung.Huh@microchip.com>,
<davem@davemloft.net>
Subject: Re: [Patch net-next v7 06/13] net: ptp: add helper for one-step P2P clocks
Date: Thu, 5 Jan 2023 15:48:55 +0000 [thread overview]
Message-ID: <4a168b600a77447915855f3cc10b00dfe7da3835.camel@microchip.com> (raw)
In-Reply-To: <bab8cb9e4916ed9f55c720883183812f4e1f717f.camel@redhat.com>
Hi Paolo,
Thanks for the review comment.
On Thu, 2023-01-05 at 11:49 +0100, Paolo Abeni wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
>
> > > +/**
> > > + * ptp_header_update_correction - Update PTP header's correction
> > > field
> > > + * @skb: packet buffer
> > > + * @type: type of the packet (see ptp_classify_raw())
> > > + * @hdr: ptp header
> > > + * @correction: new correction value
> > > + *
> > > + * This updates the correction field of a PTP header and updates
> > > the UDP
> > > + * checksum (if UDP is used as transport). It is needed for
> > > hardware capable of
> > > + * one-step P2P that does not already modify the correction
> > > field of Pdelay_Req
> > > + * event messages on ingress.
> > > + */
> > > +static inline
> > > +void ptp_header_update_correction(struct sk_buff *skb, unsigned
> > > int type,
> > > + struct ptp_header *hdr, s64
> > > correction)
> > > +{
> > > + __be64 correction_old;
> > > + struct udphdr *uhdr;
> > > +
> > > + /* previous correction value is required for checksum update.
> > > */
> > > + memcpy(&correction_old, &hdr->correction,
> > > sizeof(correction_old));
> > > +
> > > + /* write new correction value */
> > > + put_unaligned_be64((u64)correction, &hdr->correction);
> > > +
> > > + switch (type & PTP_CLASS_PMASK) {
> > > + case PTP_CLASS_IPV4:
> > > + case PTP_CLASS_IPV6:
> > > + /* locate udp header */
> > > + uhdr = (struct udphdr *)((char *)hdr - sizeof(struct
> > > udphdr));
> > > + break;
> > > + default:
> > > + return;
> > > + }
> > > +
> > > + /* update checksum */
> > > + uhdr->check = csum_fold(ptp_check_diff8(correction_old,
> > > + hdr->correction,
> > > + ~csum_unfold(uhdr-
> > > >check)));
> > > + if (!uhdr->check)
> > > + uhdr->check = CSUM_MANGLED_0;
> >
> > AFAICS the above works under the assumption that skb->ip_summed !=
> > CHECKSUM_COMPLETE, and such assumption is true for the existing DSA
> > devices.
> >
> > Still the new helper is a generic one, so perhaps it should take
> > care
> > of CHECKSUM_COMPLETE, too? Or at least add a big fat warning in the
> > helper documentation and/or a warn_on_once(CHECKSUM_COMPLETE).
>
> I see this helper is used later even in the tx path, so even packet
> with ip_summed == CHECKSUM_PARTIAL could reach here and should be
> accomodated accordingly.
Do I need to update the checksum only if ip_sum is not equal to
CHECKSUM_COMPLETE or CHECKSUM_PARTIAL.
if ( skb->ip_summed == CHECKSUM_COMPLETE ||
skb->ip_summed == CHECKSUM_PARTIAL) {
warn_on_once(1);
return;
}
Kindly suggest.
>
> Thanks,
>
> Paolo
>
>
next prev parent reply other threads:[~2023-01-05 15:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 8:43 [Patch net-next v7 00/13] net: dsa: microchip: add PTP support for KSZ9563/KSZ8563 and LAN937x Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 01/13] net: dsa: microchip: ptp: add the posix clock support Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 02/13] net: dsa: microchip: ptp: Initial hardware time stamping support Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 03/13] net: dsa: microchip: ptp: add 4 bytes in tail tag when ptp enabled Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 04/13] net: dsa: microchip: ptp: manipulating absolute time using ptp hw clock Arun Ramadoss
2023-01-04 14:08 ` Vladimir Oltean
2023-01-04 8:43 ` [Patch net-next v7 05/13] net: dsa: microchip: ptp: enable interrupt for timestamping Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 06/13] net: ptp: add helper for one-step P2P clocks Arun Ramadoss
2023-01-05 10:09 ` Paolo Abeni
2023-01-05 10:49 ` Paolo Abeni
2023-01-05 15:48 ` Arun.Ramadoss [this message]
2023-01-05 11:27 ` Eric Dumazet
2023-01-09 4:12 ` Arun.Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 07/13] net: dsa: microchip: ptp: add packet reception timestamping Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 08/13] net: dsa: microchip: ptp: add packet transmission timestamping Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 09/13] net: dsa: microchip: ptp: move pdelay_rsp correction field to tail tag Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 10/13] net: dsa: microchip: ptp: add periodic output signal Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 11/13] net: dsa: microchip: ptp: add support for perout programmable pins Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 12/13] net: dsa: microchip: ptp: lan937x: add 2 step timestamping Arun Ramadoss
2023-01-04 8:43 ` [Patch net-next v7 13/13] net: dsa: microchip: ptp: lan937x: Enable periodic output in LED pins Arun Ramadoss
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=4a168b600a77447915855f3cc10b00dfe7da3835.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=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).