* [PATCH v1 0/2] ptp: Add generic header parsing function
@ 2020-07-23 7:49 Kurt Kanzenbach
2020-07-23 7:49 ` [PATCH v1 1/2] ptp: Add generic ptp v2 " Kurt Kanzenbach
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-23 7:49 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Richard Cochran
Cc: David S. Miller, Jakub Kicinski, netdev, Kurt Kanzenbach
Hi,
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].
@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.
Thanks,
Kurt
[1] - https://lkml.kernel.org/netdev/20200713140112.GB27934@hoboy/
[2] - https://lkml.kernel.org/netdev/20200720142146.GB16001@hoboy/
Kurt Kanzenbach (2):
ptp: Add generic ptp v2 header parsing function
net: dsa: mv88e6xxx: Use generic ptp header parsing function
drivers/net/dsa/mv88e6xxx/Kconfig | 1 +
drivers/net/dsa/mv88e6xxx/hwtstamp.c | 59 ++++++----------------------
include/linux/ptp_classify.h | 38 ++++++++++++++++++
net/core/ptp_classifier.c | 30 ++++++++++++++
4 files changed, 82 insertions(+), 46 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v1 1/2] ptp: Add generic ptp v2 header parsing function
2020-07-23 7:49 [PATCH v1 0/2] ptp: Add generic header parsing function Kurt Kanzenbach
@ 2020-07-23 7:49 ` 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:08 ` [PATCH v1 0/2] ptp: Add generic " Richard Cochran
2 siblings, 1 reply; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-23 7:49 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Richard Cochran
Cc: David S. Miller, Jakub Kicinski, netdev, Kurt Kanzenbach
Reason: A lot of the ptp drivers - which implement hardware time stamping - need
specific fields such as the sequence id from the ptp v2 header. Currently all
drivers implement that themselves.
Introduce a generic function to retrieve a pointer to the start of the ptp v2
header.
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
include/linux/ptp_classify.h | 38 ++++++++++++++++++++++++++++++++++++
net/core/ptp_classifier.c | 30 ++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h
index dd00fa41f7e7..3370f402a503 100644
--- a/include/linux/ptp_classify.h
+++ b/include/linux/ptp_classify.h
@@ -44,6 +44,30 @@
#define OFF_IHL 14
#define IPV4_HLEN(data) (((struct iphdr *)(data + OFF_IHL))->ihl << 2)
+struct clock_identity {
+ u8 id[8];
+} __packed;
+
+struct port_identity {
+ struct clock_identity clock_identity;
+ __be16 port_number;
+} __packed;
+
+struct ptp_header {
+ u8 tsmt; /* transportSpecific | messageType */
+ u8 ver; /* reserved | versionPTP */
+ __be16 message_length;
+ u8 domain_number;
+ u8 reserved1;
+ u8 flag_field[2];
+ __be64 correction;
+ __be32 reserved2;
+ struct port_identity source_port_identity;
+ __be16 sequence_id;
+ u8 control;
+ u8 log_message_interval;
+} __packed;
+
#if defined(CONFIG_NET_PTP_CLASSIFY)
/**
* ptp_classify_raw - classify a PTP packet
@@ -57,6 +81,15 @@
*/
unsigned int ptp_classify_raw(const struct sk_buff *skb);
+/**
+ * ptp_parse_header - Get pointer to the PTP v2 header
+ * @skb: packet buffer
+ * @type: type of the packet (see ptp_classify_raw())
+ *
+ * Return: Pointer to the ptp v2 header or NULL if not found
+ */
+struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type);
+
void __init ptp_classifier_init(void);
#else
static inline void ptp_classifier_init(void)
@@ -66,5 +99,10 @@ static inline unsigned int ptp_classify_raw(struct sk_buff *skb)
{
return PTP_CLASS_NONE;
}
+static struct ptp_header *ptp_parse_header(struct sk_buff *skb,
+ unsigned int type)
+{
+ return NULL;
+}
#endif
#endif /* _PTP_CLASSIFY_H_ */
diff --git a/net/core/ptp_classifier.c b/net/core/ptp_classifier.c
index d964a5147f22..dc12338bf3cd 100644
--- a/net/core/ptp_classifier.c
+++ b/net/core/ptp_classifier.c
@@ -107,6 +107,36 @@ unsigned int ptp_classify_raw(const struct sk_buff *skb)
}
EXPORT_SYMBOL_GPL(ptp_classify_raw);
+struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type)
+{
+ u8 *data = skb_mac_header(skb);
+ unsigned int offset = 0;
+
+ if (type & PTP_CLASS_VLAN)
+ offset += VLAN_HLEN;
+
+ switch (type & PTP_CLASS_PMASK) {
+ case PTP_CLASS_IPV4:
+ offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
+ break;
+ case PTP_CLASS_IPV6:
+ offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
+ break;
+ case PTP_CLASS_L2:
+ offset += ETH_HLEN;
+ break;
+ default:
+ return NULL;
+ }
+
+ /* Ensure that the entire header is present in this packet. */
+ if (skb->len + ETH_HLEN < offset + sizeof(struct ptp_header))
+ return NULL;
+
+ return (struct ptp_header *)(data + offset);
+}
+EXPORT_SYMBOL_GPL(ptp_parse_header);
+
void __init ptp_classifier_init(void)
{
static struct sock_filter ptp_filter[] __initdata = {
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v1 2/2] net: dsa: mv88e6xxx: Use generic ptp header parsing function
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 7:49 ` Kurt Kanzenbach
2020-07-23 17:11 ` Richard Cochran
2020-07-23 17:08 ` [PATCH v1 0/2] ptp: Add generic " Richard Cochran
2 siblings, 1 reply; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-23 7:49 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Richard Cochran
Cc: David S. Miller, Jakub Kicinski, netdev, Kurt Kanzenbach
That function is now available within ptp classify. So use it.
Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
---
drivers/net/dsa/mv88e6xxx/Kconfig | 1 +
drivers/net/dsa/mv88e6xxx/hwtstamp.c | 59 ++++++----------------------
2 files changed, 14 insertions(+), 46 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/Kconfig b/drivers/net/dsa/mv88e6xxx/Kconfig
index 51185e4d7d15..349621fe71cf 100644
--- a/drivers/net/dsa/mv88e6xxx/Kconfig
+++ b/drivers/net/dsa/mv88e6xxx/Kconfig
@@ -26,6 +26,7 @@ config NET_DSA_MV88E6XXX_PTP
depends on NET_DSA_MV88E6XXX_GLOBAL2
depends on PTP_1588_CLOCK
imply NETWORK_PHY_TIMESTAMPING
+ select NET_PTP_CLASSIFY
help
Say Y to enable PTP hardware timestamping on Marvell 88E6xxx switch
chips that support it.
diff --git a/drivers/net/dsa/mv88e6xxx/hwtstamp.c b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
index a4c488b12e8f..094d17a1d037 100644
--- a/drivers/net/dsa/mv88e6xxx/hwtstamp.c
+++ b/drivers/net/dsa/mv88e6xxx/hwtstamp.c
@@ -211,49 +211,20 @@ int mv88e6xxx_port_hwtstamp_get(struct dsa_switch *ds, int port,
-EFAULT : 0;
}
-/* Get the start of the PTP header in this skb */
-static u8 *parse_ptp_header(struct sk_buff *skb, unsigned int type)
-{
- u8 *data = skb_mac_header(skb);
- unsigned int offset = 0;
-
- if (type & PTP_CLASS_VLAN)
- offset += VLAN_HLEN;
-
- switch (type & PTP_CLASS_PMASK) {
- case PTP_CLASS_IPV4:
- offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
- break;
- case PTP_CLASS_IPV6:
- offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
- break;
- case PTP_CLASS_L2:
- offset += ETH_HLEN;
- break;
- default:
- return NULL;
- }
-
- /* Ensure that the entire header is present in this packet. */
- if (skb->len + ETH_HLEN < offset + 34)
- return NULL;
-
- return data + offset;
-}
-
/* Returns a pointer to the PTP header if the caller should time stamp,
* or NULL if the caller should not.
*/
-static u8 *mv88e6xxx_should_tstamp(struct mv88e6xxx_chip *chip, int port,
- struct sk_buff *skb, unsigned int type)
+static struct ptp_header *mv88e6xxx_should_tstamp(struct mv88e6xxx_chip *chip,
+ int port, struct sk_buff *skb,
+ unsigned int type)
{
struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
- u8 *hdr;
+ struct ptp_header *hdr;
if (!chip->info->ptp_support)
return NULL;
- hdr = parse_ptp_header(skb, type);
+ hdr = ptp_parse_header(skb, type);
if (!hdr)
return NULL;
@@ -275,12 +246,11 @@ static int mv88e6xxx_ts_valid(u16 status)
static int seq_match(struct sk_buff *skb, u16 ts_seqid)
{
unsigned int type = SKB_PTP_TYPE(skb);
- u8 *hdr = parse_ptp_header(skb, type);
- __be16 *seqid;
+ struct ptp_header *hdr;
- seqid = (__be16 *)(hdr + OFF_PTP_SEQUENCE_ID);
+ hdr = ptp_parse_header(skb, type);
- return ts_seqid == ntohs(*seqid);
+ return ts_seqid == ntohs(hdr->sequence_id);
}
static void mv88e6xxx_get_rxts(struct mv88e6xxx_chip *chip,
@@ -357,9 +327,9 @@ static void mv88e6xxx_rxtstamp_work(struct mv88e6xxx_chip *chip,
&ps->rx_queue2);
}
-static int is_pdelay_resp(u8 *msgtype)
+static int is_pdelay_resp(const struct ptp_header *hdr)
{
- return (*msgtype & 0xf) == 3;
+ return (hdr->tsmt & 0xf) == 3;
}
bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
@@ -367,7 +337,7 @@ bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
{
struct mv88e6xxx_port_hwtstamp *ps;
struct mv88e6xxx_chip *chip;
- u8 *hdr;
+ struct ptp_header *hdr;
chip = ds->priv;
ps = &chip->port_hwtstamp[port];
@@ -503,8 +473,7 @@ bool mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,
{
struct mv88e6xxx_chip *chip = ds->priv;
struct mv88e6xxx_port_hwtstamp *ps = &chip->port_hwtstamp[port];
- __be16 *seq_ptr;
- u8 *hdr;
+ struct ptp_header *hdr;
if (!(skb_shinfo(clone)->tx_flags & SKBTX_HW_TSTAMP))
return false;
@@ -513,15 +482,13 @@ bool mv88e6xxx_port_txtstamp(struct dsa_switch *ds, int port,
if (!hdr)
return false;
- seq_ptr = (__be16 *)(hdr + OFF_PTP_SEQUENCE_ID);
-
if (test_and_set_bit_lock(MV88E6XXX_HWTSTAMP_TX_IN_PROGRESS,
&ps->state))
return false;
ps->tx_skb = clone;
ps->tx_tstamp_start = jiffies;
- ps->tx_seq_id = be16_to_cpup(seq_ptr);
+ ps->tx_seq_id = be16_to_cpu(hdr->sequence_id);
ptp_schedule_worker(chip->ptp_clock, 0);
return true;
--
2.20.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v1 1/2] ptp: Add generic ptp v2 header parsing function
2020-07-23 7:49 ` [PATCH v1 1/2] ptp: Add generic ptp v2 " Kurt Kanzenbach
@ 2020-07-23 10:54 ` Kurt Kanzenbach
0 siblings, 0 replies; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-23 10:54 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Richard Cochran
Cc: David S. Miller, Jakub Kicinski, netdev
[-- Attachment #1: Type: text/plain, Size: 226 bytes --]
On Thu Jul 23 2020, Kurt Kanzenbach wrote:
> +static struct ptp_header *ptp_parse_header(struct sk_buff *skb,
> + unsigned int type)
> +{
> + return NULL;
> +}
> #endif
That should be static inline ofc.
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 0/2] ptp: Add generic header parsing function
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 7:49 ` [PATCH v1 2/2] net: dsa: mv88e6xxx: Use generic ptp " Kurt Kanzenbach
@ 2020-07-23 17:08 ` Richard Cochran
2020-07-24 6:25 ` Kurt Kanzenbach
2 siblings, 1 reply; 10+ messages in thread
From: Richard Cochran @ 2020-07-23 17:08 UTC (permalink / raw)
To: Kurt Kanzenbach
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
Jakub Kicinski, netdev
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) {
*** drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c:
mlxsw_sp_ptp_parse[335] switch (ptp_class & PTP_CLASS_PMASK) {
*** 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) {
*** drivers/ptp/ptp_ines.c:
ines_match[457] switch (ptp_class & PTP_CLASS_PMASK) {
is_sync_pdelay_resp[703] switch (type & PTP_CLASS_PMASK) {
> @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...
Thanks,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/2] net: dsa: mv88e6xxx: Use generic ptp header parsing function
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
0 siblings, 1 reply; 10+ messages in thread
From: Richard Cochran @ 2020-07-23 17:11 UTC (permalink / raw)
To: Kurt Kanzenbach
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
Jakub Kicinski, netdev
On Thu, Jul 23, 2020 at 09:49:46AM +0200, Kurt Kanzenbach wrote:
> @@ -26,6 +26,7 @@ config NET_DSA_MV88E6XXX_PTP
> depends on NET_DSA_MV88E6XXX_GLOBAL2
> depends on PTP_1588_CLOCK
> imply NETWORK_PHY_TIMESTAMPING
> + select NET_PTP_CLASSIFY
Hm, PTP_1588_CLOCK already selects NET_PTP_CLASSIFY,
config PTP_1588_CLOCK
tristate "PTP clock support"
depends on NET && POSIX_TIMERS
select PPS
select NET_PTP_CLASSIFY
and so I expect that the 'select' in NET_DSA_MV88E6XXX_PTP isn't
needed. What am I missing?
Thanks,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/2] net: dsa: mv88e6xxx: Use generic ptp header parsing function
2020-07-23 17:11 ` Richard Cochran
@ 2020-07-24 6:07 ` Kurt Kanzenbach
0 siblings, 0 replies; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-24 6:07 UTC (permalink / raw)
To: Richard Cochran
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
Jakub Kicinski, netdev
[-- Attachment #1: Type: text/plain, Size: 629 bytes --]
On Thu Jul 23 2020, Richard Cochran wrote:
> On Thu, Jul 23, 2020 at 09:49:46AM +0200, Kurt Kanzenbach wrote:
>> @@ -26,6 +26,7 @@ config NET_DSA_MV88E6XXX_PTP
>> depends on NET_DSA_MV88E6XXX_GLOBAL2
>> depends on PTP_1588_CLOCK
>> imply NETWORK_PHY_TIMESTAMPING
>> + select NET_PTP_CLASSIFY
>
> Hm, PTP_1588_CLOCK already selects NET_PTP_CLASSIFY,
>
> config PTP_1588_CLOCK
> tristate "PTP clock support"
> depends on NET && POSIX_TIMERS
> select PPS
> select NET_PTP_CLASSIFY
>
> and so I expect that the 'select' in NET_DSA_MV88E6XXX_PTP isn't
> needed. What am I missing?
OK, didn't noticed that.
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 0/2] ptp: Add generic header parsing function
2020-07-23 17:08 ` [PATCH v1 0/2] ptp: Add generic " Richard Cochran
@ 2020-07-24 6:25 ` Kurt Kanzenbach
2020-07-24 16:03 ` Richard Cochran
0 siblings, 1 reply; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-24 6:25 UTC (permalink / raw)
To: Richard Cochran
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
Jakub Kicinski, netdev
[-- 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 --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 0/2] ptp: Add generic header parsing function
2020-07-24 6:25 ` Kurt Kanzenbach
@ 2020-07-24 16:03 ` Richard Cochran
2020-07-25 7:04 ` Kurt Kanzenbach
0 siblings, 1 reply; 10+ messages in thread
From: Richard Cochran @ 2020-07-24 16:03 UTC (permalink / raw)
To: Kurt Kanzenbach
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
Jakub Kicinski, netdev
On Fri, Jul 24, 2020 at 08:25:59AM +0200, Kurt Kanzenbach wrote:
> 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?
Yes, please.
> |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?
Looks good.
I can also test the dp83640. Maybe you could test the cpts on a bbb?
Thanks,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 0/2] ptp: Add generic header parsing function
2020-07-24 16:03 ` Richard Cochran
@ 2020-07-25 7:04 ` Kurt Kanzenbach
0 siblings, 0 replies; 10+ messages in thread
From: Kurt Kanzenbach @ 2020-07-25 7:04 UTC (permalink / raw)
To: Richard Cochran
Cc: Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
Jakub Kicinski, netdev
[-- Attachment #1: Type: text/plain, Size: 649 bytes --]
On Fri Jul 24 2020, Richard Cochran wrote:
> On Fri, Jul 24, 2020 at 08:25:59AM +0200, Kurt Kanzenbach wrote:
>> |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?
>
> Looks good.
OK, I'll add it.
>
> I can also test the dp83640. Maybe you could test the cpts on a bbb?
Most likely, yes.
Thanks,
Kurt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-07-25 7:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2020-07-24 16:03 ` Richard Cochran
2020-07-25 7:04 ` Kurt Kanzenbach
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).