Skip to contentSkip to conversation

Patchset for gianfar ptp driver

PATCH Superseded Yangbo Lu 3 participants 15 messages Feb 22, 2016 – Feb 24, 2016

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

cover Patchset for gianfar ptp driver

This patchset is to enable ptp support for ls1021a platform. The endianness issue in gianfar driver and gianfar ptp driver must be fixed, and a 1588 timer node must be added into dts.

Yangbo Lu (3):
ARM: dts: ls1021a: add 1588 timer node
gianfar_ptp: fix endianness in get_of_u32()
gianfar: fix endianness for hardware timestamp

 arch/arm/boot/dts/ls1021a.dtsi               | 12 ++++++++++++
 drivers/net/ethernet/freescale/gianfar.c     |  2 ++
 drivers/net/ethernet/freescale/gianfar_ptp.c |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.1.0.27.g96db324
author
#1 lore raw

PATCH 1/3 ARM: dts: ls1021a: add 1588 timer node

---
 arch/arm/boot/dts/ls1021a.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/boot/dts/ls1021a.dtsi +12 -0
index 2c84ca2..ecf12dc 100644
@@ -457,6 +457,18 @@
 			reg = <0x0 0x2d24000 0x0 0x4000>;
 		};
 
+		ptp_clock@2d10e00 {
+			compatible = "fsl,etsec-ptp";
+			reg = <0x0 0x2d10e00 0x0 0xb0>;
+			interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
+			fsl,tclk-period = <5>;
+			fsl,tmr-prsc    = <2>;
+			fsl,tmr-add     = <0xaaaaaaab>;
+			fsl,tmr-fiper1  = <999999990>;
+			fsl,tmr-fiper2  = <99990>;
+			fsl,max-adj     = <499999999>;
+		};
+
 		enet0: ethernet@2d10000 {
 			compatible = "fsl,etsec2";
 			device_type = "network";
Signature · 1 line
2.1.0.27.g96db324
author
#3 lore raw

RE: [PATCH 1/3] ARM: dts: ls1021a: add 1588 timer node

Quoted 11 lines

-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Monday, February 22, 2016 4:50 PM
To: Yangbo Lu
Cc: [email protected]; Claudiu Manoil
Subject: Re: [PATCH 1/3] ARM: dts: ls1021a: add 1588 timer node

Quoted 1 line · Yangbo Lu

Commit message is missing.

[Lu Yangbo-B47093] I will add commit messages for each patch. Thanks a lot, Richard.

Quoted 3 lines

Thanks,
Richard

author
#4 lore raw

PATCH 2/3 gianfar_ptp: fix endianness in get_of_u32()

In reply to Yangbo Lu
---
 drivers/net/ethernet/freescale/gianfar_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/gianfar_ptp.c +1 -1
index b40fba9..a86145c 100644
@@ -431,7 +431,7 @@ static int get_of_u32(struct device_node *node, char *str, u32 *val)
 
 	if (!prop || plen != sizeof(*prop))
 		return -1;
-	*val = *prop;
+	*val = be32_to_cpu(*prop);
 	return 0;
 }
 
Signature · 1 line
2.1.0.27.g96db324
#5 lore raw

Re: [PATCH 2/3] gianfar_ptp: fix endianness in get_of_u32()

drivers/net/ethernet/freescale/gianfar_ptp.c static int get_of_u32(struct device_node *node, char *str, u32 *val) · line 436

Quoted 8 lines · Yangbo Lu
drivers/net/ethernet/freescale/gianfar_ptp.c +1 -1
@@ -431,7 +431,7 @@ static int get_of_u32(struct device_node *node, char *str, u32 *val)
 
 	if (!prop || plen != sizeof(*prop))
 		return -1;
-	*val = *prop;
+	*val = be32_to_cpu(*prop);
 	return 0;
 }

Why not simply replace get_of_u32 with the standard helper function, of_property_read_u32?

Thanks,
Richard

author
#6 lore raw

RE: [PATCH 2/3] gianfar_ptp: fix endianness in get_of_u32()

Quoted 11 lines

-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Monday, February 22, 2016 4:36 PM
To: Yangbo Lu
Cc: [email protected]; Claudiu Manoil
Subject: Re: [PATCH 2/3] gianfar_ptp: fix endianness in get_of_u32()

Quoted 3 lines · Yangbo Lu
(quoted diff) +0 -0
@@ -431,7 +431,7 @@ static int get_of_u32(struct device_node *node,
 char *str, u32 *val)
 
Quoted 9 lines

drivers/net/ethernet/freescale/gianfar_ptp.c static int get_of_u32(struct device_node *node, char *str, u32 *val) · line 436

Quoted 6 lines
drivers/net/ethernet/freescale/gianfar_ptp.c +1 -1
 	if (!prop || plen != sizeof(*prop))
 		return -1;
-	*val = *prop;
+	*val = be32_to_cpu(*prop);
 	return 0;
 }

Why not simply replace get_of_u32 with the standard helper function, of_property_read_u32?

[Lu Yangbo-B47093] Thank you for your suggestion. I even didn't know this function. Will use it in v2 patchset.

Quoted 3 lines

Thanks,
Richard

author
#8 lore raw

PATCH 3/3 gianfar: fix endianness for hardware timestamp

In reply to Yangbo Lu
---
 drivers/net/ethernet/freescale/gianfar.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/gianfar.c +2 -0
index 2aa7b40..20e8648 100644
@@ -2708,6 +2708,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
 			struct skb_shared_hwtstamps shhwtstamps;
 			u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
 					  ~0x7UL);
+			*ns = be64_to_cpu(*ns);
 
 			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 			shhwtstamps.hwtstamp = ns_to_ktime(*ns);
@@ -3037,6 +3038,7 @@ static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb)
 	if (priv->hwts_rx_en) {
 		struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
 		u64 *ns = (u64 *) skb->data;
+		*ns = be64_to_cpu(*ns);
 
 		memset(shhwtstamps, 0, sizeof(*shhwtstamps));
 		shhwtstamps->hwtstamp = ns_to_ktime(*ns);
Signature · 1 line
2.1.0.27.g96db324
#9 lore raw

Re: [PATCH 3/3] gianfar: fix endianness for hardware timestamp

drivers/net/ethernet/freescale/gianfar.c static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · line 2714

Quoted 8 lines · Yangbo Lu
drivers/net/ethernet/freescale/gianfar.c +1 -0
@@ -2708,6 +2708,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
 			struct skb_shared_hwtstamps shhwtstamps;
 			u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
 					  ~0x7UL);
+			*ns = be64_to_cpu(*ns);
 
 			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 			shhwtstamps.hwtstamp = ns_to_ktime(*ns);

There is no point in modifying the buffer data in place.

Instead, do this:

			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
			shhwtstamps.hwtstamp = ns_to_ktime(be64_to_cpu(*ns));

or this:

			u64 ns, *ptr = (u64 *)(((uintptr_t)skb->data + 0x10) &
					       ~0x7UL);
			ns = be64_to_cpu(*ptr);

			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
			shhwtstamps.hwtstamp = ns_to_ktime(ns);

drivers/net/ethernet/freescale/gianfar.c static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb) · line 3044

Quoted 8 lines
drivers/net/ethernet/freescale/gianfar.c +1 -0
@@ -3037,6 +3038,7 @@ static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb)
 	if (priv->hwts_rx_en) {
 		struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
 		u64 *ns = (u64 *) skb->data;
+		*ns = be64_to_cpu(*ns);
 
 		memset(shhwtstamps, 0, sizeof(*shhwtstamps));
 		shhwtstamps->hwtstamp = ns_to_ktime(*ns);

Same here.

Thanks,
Richard

author
#10 lore raw

RE: [PATCH 3/3] gianfar: fix endianness for hardware timestamp

Quoted 25 lines

-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Monday, February 22, 2016 4:48 PM
To: Yangbo Lu
Cc: [email protected]; Claudiu Manoil
Subject: Re: [PATCH 3/3] gianfar: fix endianness for hardware timestamp

Review static void gfar_clean_tx_ring(struct

Quoted 1 line · Yangbo Lu
(quoted diff) +0 -0
@@ -2708,6 +2708,7 @@ static void gfar_clean_tx_ring(struct

gfar_priv_tx_q *tx_queue)

drivers/net/ethernet/freescale/gianfar.c static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · line 2714

Quoted 7 lines
drivers/net/ethernet/freescale/gianfar.c +1 -0
 			struct skb_shared_hwtstamps shhwtstamps;
 			u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
 					  ~0x7UL);
+			*ns = be64_to_cpu(*ns);
 
 			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 			shhwtstamps.hwtstamp = ns_to_ktime(*ns);

There is no point in modifying the buffer data in place.

Instead, do this:

			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
			shhwtstamps.hwtstamp = ns_to_ktime(be64_to_cpu(*ns));
Quoted 9 lines

or this:

			u64 ns, *ptr = (u64 *)(((uintptr_t)skb->data + 0x10) &
					       ~0x7UL);
			ns = be64_to_cpu(*ptr);

			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
			shhwtstamps.hwtstamp = ns_to_ktime(ns);

[Lu Yangbo-B47093] I will modify codes according your suggestion. Thank you so much!

Quoted 14 lines

Review static void gfar_process_frame(struct net_device

Quoted 1 line
(quoted diff) +0 -0
@@ -3037,6 +3038,7 @@ static void gfar_process_frame(struct net_device

*ndev, struct sk_buff *skb)

drivers/net/ethernet/freescale/gianfar.c static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb) · line 3044

Quoted 7 lines
drivers/net/ethernet/freescale/gianfar.c +1 -0
 	if (priv->hwts_rx_en) {
 		struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
 		u64 *ns = (u64 *) skb->data;
+		*ns = be64_to_cpu(*ns);
 
 		memset(shhwtstamps, 0, sizeof(*shhwtstamps));
 		shhwtstamps->hwtstamp = ns_to_ktime(*ns);

Same here.

Thanks,
Richard

#11 lore raw

Re: [PATCH 3/3] gianfar: fix endianness for hardware timestamp

Hi,

Quoted 31 lines · Yangbo Lu
Quoted 31 lines

-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Monday, February 22, 2016 4:48 PM
To: Yangbo Lu
Cc: [email protected]; Claudiu Manoil
Subject: Re: [PATCH 3/3] gianfar: fix endianness for hardware timestamp

Review static void gfar_clean_tx_ring(struct

Quoted 1 line · Yangbo Lu
(quoted diff) +0 -0
@@ -2708,6 +2708,7 @@ static void gfar_clean_tx_ring(struct

gfar_priv_tx_q *tx_queue)

drivers/net/ethernet/freescale/gianfar.c static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) · line 2714

Quoted 7 lines
drivers/net/ethernet/freescale/gianfar.c +1 -0
 			struct skb_shared_hwtstamps shhwtstamps;
 			u64 *ns = (u64 *)(((uintptr_t)skb->data + 0x10) &
 					  ~0x7UL);
+			*ns = be64_to_cpu(*ns);
 
 			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 			shhwtstamps.hwtstamp = ns_to_ktime(*ns);

There is no point in modifying the buffer data in place.

Instead, do this:

			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
			shhwtstamps.hwtstamp = ns_to_ktime(be64_to_cpu(*ns));

or this:

			u64 ns, *ptr = (u64 *)(((uintptr_t)skb->data + 0x10) &
					       ~0x7UL);
			ns = be64_to_cpu(*ptr);
Quoted 6 lines
Quoted 3 lines
			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
			shhwtstamps.hwtstamp = ns_to_ktime(ns);

[Lu Yangbo-B47093] I will modify codes according your suggestion. Thank you so much!

You may want to use PTR_ALIGN() and be64_to_cpup() here.

--yoshfuji

Quoted 15 lines
Quoted 15 lines

Review static void gfar_process_frame(struct net_device

Quoted 2 lines
(quoted diff) +0 -0
@@ -3037,6 +3038,7 @@ static void gfar_process_frame(struct net_device

*ndev, struct sk_buff *skb)

drivers/net/ethernet/freescale/gianfar.c static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb) · line 3044

Quoted 7 lines
drivers/net/ethernet/freescale/gianfar.c +1 -0
 	if (priv->hwts_rx_en) {
 		struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
 		u64 *ns = (u64 *) skb->data;
+		*ns = be64_to_cpu(*ns);
 
 		memset(shhwtstamps, 0, sizeof(*shhwtstamps));
 		shhwtstamps->hwtstamp = ns_to_ktime(*ns);

Same here.

Thanks,
Richard

Signature · 2 lines
Hideaki Yoshifuji <[email protected]>
Technical Division, MIRACLE LINUX CORPORATION
#13 lore raw
In reply to Yangbo Lu
Quoted 3 lines · Yangbo Lu

This patchset is to enable ptp support for ls1021a platform. The endianness issue in gianfar driver and gianfar ptp driver must be fixed, and a 1588 timer node must be added into dts.

Why have you excluded both the driver author and the PTP maintainer from CC?

Thanks,
Richard

author
#14 lore raw
Quoted 7 lines

-----Original Message-----
From: Richard Cochran [mailto:[email protected]]
Sent: Monday, February 22, 2016 4:33 PM
To: Yangbo Lu
Cc: [email protected]; Claudiu Manoil
Subject: Re: [PATCH 0/3] Patchset for gianfar ptp driver

Quoted 8 lines
Quoted 3 lines · Yangbo Lu

This patchset is to enable ptp support for ls1021a platform. The endianness issue in gianfar driver and gianfar ptp driver must be fixed, and a 1588 timer node must be added into dts.

Why have you excluded both the driver author and the PTP maintainer from CC?

[Lu Yangbo-B47093] Sorry for missing some reviewers. I will add them in the later v2 patchset. Thanks a lot, Richard.

Quoted 2 lines

Thanks,
Richard