netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kurt Kanzenbach <kurt@linutronix.de>
To: Richard Cochran <richardcochran@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org
Subject: Re: [PATCH v1 0/2] ptp: Add generic header parsing function
Date: Fri, 24 Jul 2020 08:25:59 +0200	[thread overview]
Message-ID: <87r1t12zuw.fsf@kurt> (raw)
In-Reply-To: <20200723170842.GB2975@hoboy>

[-- Attachment #1: Type: text/plain, Size: 2419 bytes --]

On Thu Jul 23 2020, Richard Cochran wrote:
> Kurt,
>
> On Thu, Jul 23, 2020 at 09:49:44AM +0200, Kurt Kanzenbach wrote:
>> in order to reduce code duplication in the ptp code of DSA drivers, move the
>> header parsing function to ptp_classify. This way the Marvell and the hellcreek
>> drivers can share the same implementation. And probably more drivers can benefit
>> from it. Implemented as discussed [1] [2].
>
> This looks good.  I made a list of drivers that can possibily use this helper.
>
> Finding symbol: PTP_CLASS_PMASK
>
> *** drivers/net/dsa/mv88e6xxx/hwtstamp.c:
> parse_ptp_header[223]          switch (type & PTP_CLASS_PMASK) {

Sure, done already (see patch 2).

>
> *** drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c:
> mlxsw_sp_ptp_parse[335]        switch (ptp_class & PTP_CLASS_PMASK) {

Works ootb.

>
> *** drivers/net/ethernet/ti/am65-cpts.c:
> am65_skb_get_mtype_seqid[761]  switch (ptp_class & PTP_CLASS_PMASK) {
>
> *** drivers/net/ethernet/ti/cpts.c:
> cpts_skb_get_mtype_seqid[459]  switch (ptp_class & PTP_CLASS_PMASK) {
>
> *** drivers/net/phy/dp83640.c:
> match[815]                     switch (type & PTP_CLASS_PMASK) {
> is_sync[990]                   switch (type & PTP_CLASS_PMASK) {

These three drivers also deal with ptp v1 and they need access to the
message type. However, the message type is located at a different offset
depending on the ptp version. They all do:

|if (unlikely(ptp_class & PTP_CLASS_V1))
|	msgtype = data + offset + OFF_PTP_CONTROL;
|else
|	msgtype = data + offset;

Maybe we can put that in a helper function, too?

|static inline u8 ptp_get_msgtype(const struct ptp_header *hdr, unsigned int type)
|{
|	u8 msg;
|
|	if (unlikely(type & PTP_CLASS_V1))
|		/* msg type is located @ offset 20 for ptp v1 */ 
|		msg = hdr->source_port_identity.clock_identity.id[0];
|	else
|		msg = hdr->tsmt & 0x0f;
|
|	return msg;
|}

What do you think about it?

>
> *** drivers/ptp/ptp_ines.c:
> ines_match[457]                switch (ptp_class & PTP_CLASS_PMASK) {
> is_sync_pdelay_resp[703]       switch (type & PTP_CLASS_PMASK) {

Works ootb.

>
>> @DSA maintainers: Please, have a look the Marvell code. I don't have hardware to
>> test it. I've tested this series only on the Hirschmann switch.
>
> I'll test the marvell switch with your change and let you know...

Great.

Thanks,
Kurt

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2020-07-24  6:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23  7:49 [PATCH v1 0/2] ptp: Add generic header parsing function Kurt Kanzenbach
2020-07-23  7:49 ` [PATCH v1 1/2] ptp: Add generic ptp v2 " Kurt Kanzenbach
2020-07-23 10:54   ` Kurt Kanzenbach
2020-07-23  7:49 ` [PATCH v1 2/2] net: dsa: mv88e6xxx: Use generic ptp " Kurt Kanzenbach
2020-07-23 17:11   ` Richard Cochran
2020-07-24  6:07     ` Kurt Kanzenbach
2020-07-23 17:08 ` [PATCH v1 0/2] ptp: Add generic " Richard Cochran
2020-07-24  6:25   ` Kurt Kanzenbach [this message]
2020-07-24 16:03     ` Richard Cochran
2020-07-25  7:04       ` Kurt Kanzenbach

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=87r1t12zuw.fsf@kurt \
    --to=kurt@linutronix.de \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --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).