public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data
@ 2026-02-01 18:37 Niklas Söderlund
  2026-02-01 18:37 ` [net-next 1/4] net: ethernet: renesas: rcar_gen4_ptp: Move address assignment Niklas Söderlund
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Niklas Söderlund @ 2026-02-01 18:37 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven, Magnus Damm,
	Richard Cochran, netdev, linux-renesas-soc
  Cc: Niklas Söderlund

Hello,

The R-Car Gen4 PTP module started out as an exclusive feature of a 
single driver, but have since been extended to cover both R-Car Switch 
and TSN driver implementations on Gen4.

The feature have already been extended to be built as its own module 
with an interface exposed thru a local header file. The header file 
however also exposes the modules private data structure. The two 
existing users have already started to poke at members of the struct.  

The exposed private data being manipulated by users makes refactoring 
and future rework hard as the interface for the module becomes to 
chaotic. This small series aims to create two helpers to hide the 
private data.

This is done as a small preparation before a third, new, users of the 
Gen4 PTP will be added in a follow up series.

Niklas Söderlund (4):
  net: ethernet: renesas: rcar_gen4_ptp: Move address assignment
  net: ethernet: renesas: rcar_gen4_ptp: Add helper to get clock index
  net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time
  net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users

 drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 34 +++++++++++++++++++-
 drivers/net/ethernet/renesas/rcar_gen4_ptp.h | 18 ++++-------
 drivers/net/ethernet/renesas/rswitch_main.c  | 11 +++----
 drivers/net/ethernet/renesas/rtsn.c          | 30 +++++++----------
 4 files changed, 57 insertions(+), 36 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [net-next 1/4] net: ethernet: renesas: rcar_gen4_ptp: Move address assignment
  2026-02-01 18:37 [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data Niklas Söderlund
@ 2026-02-01 18:37 ` Niklas Söderlund
  2026-02-01 18:37 ` [net-next 2/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to get clock index Niklas Söderlund
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Niklas Söderlund @ 2026-02-01 18:37 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven, Magnus Damm,
	Richard Cochran, netdev, linux-renesas-soc
  Cc: Niklas Söderlund

Instead of accessing the Gen4 PTP specific structure directly in drivers
move the device address assignment into the preparation call. This is
done in preparation to completely hide the Gen4 PTP specific structure
from users.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/net/ethernet/renesas/rcar_gen4_ptp.c |  5 ++++-
 drivers/net/ethernet/renesas/rcar_gen4_ptp.h |  3 ++-
 drivers/net/ethernet/renesas/rswitch_main.c  |  9 ++++-----
 drivers/net/ethernet/renesas/rtsn.c          | 19 ++++++++++---------
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
index d0979abd36de..3fd835128cc8 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
@@ -168,7 +168,8 @@ int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv)
 }
 EXPORT_SYMBOL_GPL(rcar_gen4_ptp_unregister);
 
-struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev)
+struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
+						  void __iomem *addr)
 {
 	struct rcar_gen4_ptp_private *ptp;
 
@@ -178,6 +179,8 @@ struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev)
 
 	ptp->info = rcar_gen4_ptp_info;
 
+	ptp->addr = addr;
+
 	return ptp;
 }
 EXPORT_SYMBOL_GPL(rcar_gen4_ptp_alloc);
diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
index 9a9c232c854e..b71aba873795 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
@@ -20,6 +20,7 @@ struct rcar_gen4_ptp_private {
 
 int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, u32 rate);
 int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv);
-struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev);
+struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
+						  void __iomem *addr);
 
 #endif	/* #ifndef __RCAR_GEN4_PTP_H__ */
diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
index e14b21148f27..ab0b40d4f4fb 100644
--- a/drivers/net/ethernet/renesas/rswitch_main.c
+++ b/drivers/net/ethernet/renesas/rswitch_main.c
@@ -2150,17 +2150,16 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
 	if (attr)
 		priv->etha_no_runtime_change = true;
 
-	priv->ptp_priv = rcar_gen4_ptp_alloc(pdev);
-	if (!priv->ptp_priv)
-		return -ENOMEM;
-
 	platform_set_drvdata(pdev, priv);
 	priv->pdev = pdev;
 	priv->addr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(priv->addr))
 		return PTR_ERR(priv->addr);
 
-	priv->ptp_priv->addr = priv->addr + RSWITCH_GPTP_OFFSET_S4;
+	priv->ptp_priv =
+		rcar_gen4_ptp_alloc(pdev, priv->addr + RSWITCH_GPTP_OFFSET_S4);
+	if (!priv->ptp_priv)
+		return -ENOMEM;
 
 	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
 	if (ret < 0) {
diff --git a/drivers/net/ethernet/renesas/rtsn.c b/drivers/net/ethernet/renesas/rtsn.c
index fdb1e7b7fb06..d4b955c87f1b 100644
--- a/drivers/net/ethernet/renesas/rtsn.c
+++ b/drivers/net/ethernet/renesas/rtsn.c
@@ -1227,6 +1227,7 @@ static int rtsn_probe(struct platform_device *pdev)
 {
 	struct rtsn_private *priv;
 	struct net_device *ndev;
+	void __iomem *ptpaddr;
 	struct resource *res;
 	int ret;
 
@@ -1239,12 +1240,6 @@ static int rtsn_probe(struct platform_device *pdev)
 	priv->pdev = pdev;
 	priv->ndev = ndev;
 
-	priv->ptp_priv = rcar_gen4_ptp_alloc(pdev);
-	if (!priv->ptp_priv) {
-		ret = -ENOMEM;
-		goto error_free;
-	}
-
 	spin_lock_init(&priv->lock);
 	platform_set_drvdata(pdev, priv);
 
@@ -1288,9 +1283,15 @@ static int rtsn_probe(struct platform_device *pdev)
 		goto error_free;
 	}
 
-	priv->ptp_priv->addr = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(priv->ptp_priv->addr)) {
-		ret = PTR_ERR(priv->ptp_priv->addr);
+	ptpaddr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ptpaddr)) {
+		ret = PTR_ERR(ptpaddr);
+		goto error_free;
+	}
+
+	priv->ptp_priv = rcar_gen4_ptp_alloc(pdev, ptpaddr);
+	if (!priv->ptp_priv) {
+		ret = -ENOMEM;
 		goto error_free;
 	}
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net-next 2/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to get clock index
  2026-02-01 18:37 [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data Niklas Söderlund
  2026-02-01 18:37 ` [net-next 1/4] net: ethernet: renesas: rcar_gen4_ptp: Move address assignment Niklas Söderlund
@ 2026-02-01 18:37 ` Niklas Söderlund
  2026-02-01 18:37 ` [net-next 3/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time Niklas Söderlund
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Niklas Söderlund @ 2026-02-01 18:37 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven, Magnus Damm,
	Richard Cochran, netdev, linux-renesas-soc
  Cc: Niklas Söderlund

Instead of accessing the Gen4 PTP specific structure directly in drivers
add a helper to read the clock index. This is done in preparation to
completely hide the Gen4 PTP specific structure from users.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 9 +++++++++
 drivers/net/ethernet/renesas/rcar_gen4_ptp.h | 2 ++
 drivers/net/ethernet/renesas/rswitch_main.c  | 2 +-
 drivers/net/ethernet/renesas/rtsn.c          | 2 +-
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
index 3fd835128cc8..75bf7aac089b 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
@@ -185,6 +185,15 @@ struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(rcar_gen4_ptp_alloc);
 
+int rcar_gen4_ptp_clock_index(struct rcar_gen4_ptp_private *priv)
+{
+	if (!priv->initialized)
+		return -1;
+
+	return ptp_clock_index(priv->clock);
+}
+EXPORT_SYMBOL_GPL(rcar_gen4_ptp_clock_index);
+
 MODULE_AUTHOR("Yoshihiro Shimoda");
 MODULE_DESCRIPTION("Renesas R-Car Gen4 gPTP driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
index b71aba873795..c141cd38a40d 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
@@ -23,4 +23,6 @@ int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv);
 struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
 						  void __iomem *addr);
 
+int rcar_gen4_ptp_clock_index(struct rcar_gen4_ptp_private *priv);
+
 #endif	/* #ifndef __RCAR_GEN4_PTP_H__ */
diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
index ab0b40d4f4fb..433eb2b00d10 100644
--- a/drivers/net/ethernet/renesas/rswitch_main.c
+++ b/drivers/net/ethernet/renesas/rswitch_main.c
@@ -1891,7 +1891,7 @@ static int rswitch_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts
 {
 	struct rswitch_device *rdev = netdev_priv(ndev);
 
-	info->phc_index = ptp_clock_index(rdev->priv->ptp_priv->clock);
+	info->phc_index = rcar_gen4_ptp_clock_index(rdev->priv->ptp_priv);
 	info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
 				SOF_TIMESTAMPING_TX_HARDWARE |
 				SOF_TIMESTAMPING_RX_HARDWARE |
diff --git a/drivers/net/ethernet/renesas/rtsn.c b/drivers/net/ethernet/renesas/rtsn.c
index d4b955c87f1b..ce1047743970 100644
--- a/drivers/net/ethernet/renesas/rtsn.c
+++ b/drivers/net/ethernet/renesas/rtsn.c
@@ -1197,7 +1197,7 @@ static int rtsn_get_ts_info(struct net_device *ndev,
 {
 	struct rtsn_private *priv = netdev_priv(ndev);
 
-	info->phc_index = ptp_clock_index(priv->ptp_priv->clock);
+	info->phc_index = rcar_gen4_ptp_clock_index(priv->ptp_priv);
 	info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
 		SOF_TIMESTAMPING_TX_HARDWARE |
 		SOF_TIMESTAMPING_RX_HARDWARE |
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net-next 3/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time
  2026-02-01 18:37 [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data Niklas Söderlund
  2026-02-01 18:37 ` [net-next 1/4] net: ethernet: renesas: rcar_gen4_ptp: Move address assignment Niklas Söderlund
  2026-02-01 18:37 ` [net-next 2/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to get clock index Niklas Söderlund
@ 2026-02-01 18:37 ` Niklas Söderlund
  2026-02-01 18:37 ` [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users Niklas Söderlund
  2026-02-04  3:50 ` [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data patchwork-bot+netdevbpf
  4 siblings, 0 replies; 8+ messages in thread
From: Niklas Söderlund @ 2026-02-01 18:37 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven, Magnus Damm,
	Richard Cochran, netdev, linux-renesas-soc
  Cc: Niklas Söderlund

Instead of accessing the Gen4 PTP specific structure directly in drivers
add a helper to read the time. This is done in preparation to
completely hide the Gen4 PTP specific structure from users.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 10 ++++++++++
 drivers/net/ethernet/renesas/rcar_gen4_ptp.h |  2 ++
 drivers/net/ethernet/renesas/rtsn.c          |  9 +--------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
index 75bf7aac089b..a14a16cf5fe6 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
@@ -194,6 +194,16 @@ int rcar_gen4_ptp_clock_index(struct rcar_gen4_ptp_private *priv)
 }
 EXPORT_SYMBOL_GPL(rcar_gen4_ptp_clock_index);
 
+void rcar_gen4_ptp_gettime64(struct rcar_gen4_ptp_private *priv,
+			     struct timespec64 *ts)
+{
+	if (!priv->initialized)
+		return;
+
+	priv->info.gettime64(&priv->info, ts);
+}
+EXPORT_SYMBOL_GPL(rcar_gen4_ptp_gettime64);
+
 MODULE_AUTHOR("Yoshihiro Shimoda");
 MODULE_DESCRIPTION("Renesas R-Car Gen4 gPTP driver");
 MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
index c141cd38a40d..fffccda401f5 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
@@ -24,5 +24,7 @@ struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
 						  void __iomem *addr);
 
 int rcar_gen4_ptp_clock_index(struct rcar_gen4_ptp_private *priv);
+void rcar_gen4_ptp_gettime64(struct rcar_gen4_ptp_private *priv,
+			     struct timespec64 *ts);
 
 #endif	/* #ifndef __RCAR_GEN4_PTP_H__ */
diff --git a/drivers/net/ethernet/renesas/rtsn.c b/drivers/net/ethernet/renesas/rtsn.c
index ce1047743970..85052b47afb9 100644
--- a/drivers/net/ethernet/renesas/rtsn.c
+++ b/drivers/net/ethernet/renesas/rtsn.c
@@ -104,13 +104,6 @@ static void rtsn_ctrl_data_irq(struct rtsn_private *priv, bool enable)
 	}
 }
 
-static void rtsn_get_timestamp(struct rtsn_private *priv, struct timespec64 *ts)
-{
-	struct rcar_gen4_ptp_private *ptp_priv = priv->ptp_priv;
-
-	ptp_priv->info.gettime64(&ptp_priv->info, ts);
-}
-
 static int rtsn_tx_free(struct net_device *ndev, bool free_txed_only)
 {
 	struct rtsn_private *priv = netdev_priv(ndev);
@@ -133,7 +126,7 @@ static int rtsn_tx_free(struct net_device *ndev, bool free_txed_only)
 				struct skb_shared_hwtstamps shhwtstamps;
 				struct timespec64 ts;
 
-				rtsn_get_timestamp(priv, &ts);
+				rcar_gen4_ptp_gettime64(priv->ptp_priv, &ts);
 				memset(&shhwtstamps, 0, sizeof(shhwtstamps));
 				shhwtstamps.hwtstamp = timespec64_to_ktime(ts);
 				skb_tstamp_tx(skb, &shhwtstamps);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users
  2026-02-01 18:37 [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data Niklas Söderlund
                   ` (2 preceding siblings ...)
  2026-02-01 18:37 ` [net-next 3/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time Niklas Söderlund
@ 2026-02-01 18:37 ` Niklas Söderlund
  2026-02-03  3:11   ` Jakub Kicinski
  2026-02-04  3:50 ` [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data patchwork-bot+netdevbpf
  4 siblings, 1 reply; 8+ messages in thread
From: Niklas Söderlund @ 2026-02-01 18:37 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Geert Uytterhoeven, Magnus Damm,
	Richard Cochran, netdev, linux-renesas-soc
  Cc: Niklas Söderlund

The Gen4 PTP helper module is already used by RTSN and RSWITCH to
support PTP clocks and will be used by RAVB too. Hide the Gen4 PTP
private data structure to make sure none of the users poke at it.

This will be more important for RAVB use-cases as more then one RAVB
device will need to cooperate using one PTP clock source.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/net/ethernet/renesas/rcar_gen4_ptp.c | 10 ++++++++++
 drivers/net/ethernet/renesas/rcar_gen4_ptp.h | 11 +----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
index a14a16cf5fe6..27a6f0492097 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.c
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/ptp_clock_kernel.h>
 #include <linux/slab.h>
 
 #include "rcar_gen4_ptp.h"
@@ -23,6 +24,15 @@
 #define PTPGPTPTM10_REG		0x0054
 #define PTPGPTPTM20_REG		0x0058
 
+struct rcar_gen4_ptp_private {
+	void __iomem *addr;
+	struct ptp_clock *clock;
+	struct ptp_clock_info info;
+	spinlock_t lock;	/* For multiple registers access */
+	s64 default_addend;
+	bool initialized;
+};
+
 #define ptp_to_priv(ptp)	container_of(ptp, struct rcar_gen4_ptp_private, info)
 
 static int rcar_gen4_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
diff --git a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
index fffccda401f5..6abaa7cc6b77 100644
--- a/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
+++ b/drivers/net/ethernet/renesas/rcar_gen4_ptp.h
@@ -7,16 +7,7 @@
 #ifndef __RCAR_GEN4_PTP_H__
 #define __RCAR_GEN4_PTP_H__
 
-#include <linux/ptp_clock_kernel.h>
-
-struct rcar_gen4_ptp_private {
-	void __iomem *addr;
-	struct ptp_clock *clock;
-	struct ptp_clock_info info;
-	spinlock_t lock;	/* For multiple registers access */
-	s64 default_addend;
-	bool initialized;
-};
+struct rcar_gen4_ptp_private;
 
 int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, u32 rate);
 int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users
  2026-02-01 18:37 ` [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users Niklas Söderlund
@ 2026-02-03  3:11   ` Jakub Kicinski
  2026-02-03  6:39     ` Niklas Söderlund
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2026-02-03  3:11 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Geert Uytterhoeven, Magnus Damm, Richard Cochran,
	netdev, linux-renesas-soc

On Sun,  1 Feb 2026 19:37:45 +0100 Niklas Söderlund wrote:
> The Gen4 PTP helper module is already used by RTSN and RSWITCH to
> support PTP clocks and will be used by RAVB too. Hide the Gen4 PTP
> private data structure to make sure none of the users poke at it.
> 
> This will be more important for RAVB use-cases as more then one RAVB
> device will need to cooperate using one PTP clock source.

IMO hiding type definitions in C is an anti-pattern.
Sooner or later you'll need a sizeof or a static inline helper 
and you'll have to bend over backwards to access the type info.

We can take this if you have a strong preference, but please
think again if you really need this or it's a code cleanliness
instinct carried over from objective programming, hence foreign..

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users
  2026-02-03  3:11   ` Jakub Kicinski
@ 2026-02-03  6:39     ` Niklas Söderlund
  0 siblings, 0 replies; 8+ messages in thread
From: Niklas Söderlund @ 2026-02-03  6:39 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Yoshihiro Shimoda, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Geert Uytterhoeven, Magnus Damm, Richard Cochran,
	netdev, linux-renesas-soc

Hello Jakub,

Thanks for your feedback.

On 2026-02-02 19:11:21 -0800, Jakub Kicinski wrote:
> On Sun,  1 Feb 2026 19:37:45 +0100 Niklas Söderlund wrote:
> > The Gen4 PTP helper module is already used by RTSN and RSWITCH to
> > support PTP clocks and will be used by RAVB too. Hide the Gen4 PTP
> > private data structure to make sure none of the users poke at it.
> > 
> > This will be more important for RAVB use-cases as more then one RAVB
> > device will need to cooperate using one PTP clock source.
> 
> IMO hiding type definitions in C is an anti-pattern.
> Sooner or later you'll need a sizeof or a static inline helper 
> and you'll have to bend over backwards to access the type info.
> 
> We can take this if you have a strong preference, but please
> think again if you really need this or it's a code cleanliness
> instinct carried over from objective programming, hence foreign..

On principle I agree with you, hiding type definitions is usually not a 
good idea long term, but here I would still like to do it.

My reason is that the goal is to completely remove the type from the 
header file and only expose the struct ptp_clock to users.

The private data will need to be reworked as the next device where 
support for the Gen4 PTP clock need to support the same PTP clock device 
to be used by multiple network devices. This will make the private data 
more fragile and I don't want to expose that to the users as the helpers 
will then be mandatory to use.

I'm sure there are multiple paths to achieve my goal, but unless you 
strongly object against this intermediate step I would like to move 
forward with it.

-- 
Kind Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data
  2026-02-01 18:37 [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data Niklas Söderlund
                   ` (3 preceding siblings ...)
  2026-02-01 18:37 ` [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users Niklas Söderlund
@ 2026-02-04  3:50 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-04  3:50 UTC (permalink / raw)
  To: =?utf-8?q?Niklas_S=C3=B6derlund_=3Cniklas=2Esoderlund+renesas=40ragnatech=2E?=,
	=?utf-8?q?se=3E?=
  Cc: yoshihiro.shimoda.uh, andrew+netdev, davem, edumazet, kuba,
	pabeni, geert+renesas, magnus.damm, richardcochran, netdev,
	linux-renesas-soc

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sun,  1 Feb 2026 19:37:41 +0100 you wrote:
> Hello,
> 
> The R-Car Gen4 PTP module started out as an exclusive feature of a
> single driver, but have since been extended to cover both R-Car Switch
> and TSN driver implementations on Gen4.
> 
> The feature have already been extended to be built as its own module
> with an interface exposed thru a local header file. The header file
> however also exposes the modules private data structure. The two
> existing users have already started to poke at members of the struct.
> 
> [...]

Here is the summary with links:
  - [net-next,1/4] net: ethernet: renesas: rcar_gen4_ptp: Move address assignment
    https://git.kernel.org/netdev/net-next/c/642377346a4e
  - [net-next,2/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to get clock index
    https://git.kernel.org/netdev/net-next/c/9afe65e7e7d7
  - [net-next,3/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time
    https://git.kernel.org/netdev/net-next/c/5640afa0583d
  - [net-next,4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users
    https://git.kernel.org/netdev/net-next/c/9c2f568eb236

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-02-04  3:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-01 18:37 [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data Niklas Söderlund
2026-02-01 18:37 ` [net-next 1/4] net: ethernet: renesas: rcar_gen4_ptp: Move address assignment Niklas Söderlund
2026-02-01 18:37 ` [net-next 2/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to get clock index Niklas Söderlund
2026-02-01 18:37 ` [net-next 3/4] net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time Niklas Söderlund
2026-02-01 18:37 ` [net-next 4/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data from users Niklas Söderlund
2026-02-03  3:11   ` Jakub Kicinski
2026-02-03  6:39     ` Niklas Söderlund
2026-02-04  3:50 ` [net-next 0/4] net: ethernet: renesas: rcar_gen4_ptp: Hide private data patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox