netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v5 0/3] Macb PTP minor updates
@ 2023-04-11 12:37 Harini Katakam
  2023-04-11 12:37 ` [PATCH net-next v5 1/3] net: macb: Update gem PTP support check Harini Katakam
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Harini Katakam @ 2023-04-11 12:37 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea,
	andrei.pistirica, kuba, edumazet, pabeni
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

- Enable PTP unicast
- Optimize HW timestamp reading

v5:
Remove unnecessary braces and !! in gem_has_ptp

v4:
Fix kernel test robot error; use static check for
CONFIG_MACB_USE_HWTSTAMP where necessary

v3:
Add patch to move CONFIG_MACB_USE_HWTSTAMP check into gem_has_ptp

v2:
- Handle unicast setting with one register R/W operation
- Update HW timestamp logic to remove sec_rollover variable
- Removed Richard Cochran's ACK as patch 2/2 changed

Harini Katakam (3):
  net: macb: Update gem PTP support check
  net: macb: Enable PTP unicast
  net: macb: Optimize reading HW timestamp

 drivers/net/ethernet/cadence/macb.h      |  6 +++++-
 drivers/net/ethernet/cadence/macb_main.c | 17 +++++++++++++----
 drivers/net/ethernet/cadence/macb_ptp.c  |  4 ++--
 3 files changed, 20 insertions(+), 7 deletions(-)

-- 
2.17.1


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

* [PATCH net-next v5 1/3] net: macb: Update gem PTP support check
  2023-04-11 12:37 [PATCH net-next v5 0/3] Macb PTP minor updates Harini Katakam
@ 2023-04-11 12:37 ` Harini Katakam
  2023-04-11 12:37 ` [PATCH net-next v5 2/3] net: macb: Enable PTP unicast Harini Katakam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Harini Katakam @ 2023-04-11 12:37 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea,
	andrei.pistirica, kuba, edumazet, pabeni
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

There are currently two checks for PTP functionality - one on GEM
capability and another on the kernel config option. Combine them
into a single function as there's no use case where gem_has_ptp is
TRUE and MACB_USE_HWSTAMP is false.

Signed-off-by: Harini Katakam <harini.katakam@amd.com>
---
v5:
Remove unnecessary braces and !!
v4:
Fixed error introduced in 1/3 in v3:
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202303280600.LarprmhI-lkp@intel.com/
v3:
New patch

 drivers/net/ethernet/cadence/macb.h      | 2 +-
 drivers/net/ethernet/cadence/macb_main.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index c1fc91c97cee..07560803aa26 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -1363,7 +1363,7 @@ static inline bool macb_is_gem(struct macb *bp)
 
 static inline bool gem_has_ptp(struct macb *bp)
 {
-	return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
+	return IS_ENABLED(CONFIG_MACB_USE_HWSTAMP) && (bp->caps & MACB_CAPS_GEM_HAS_PTP);
 }
 
 /**
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index f77bd1223c8f..eab2d41fa571 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3889,17 +3889,17 @@ static void macb_configure_caps(struct macb *bp,
 		dcfg = gem_readl(bp, DCFG2);
 		if ((dcfg & (GEM_BIT(RX_PKT_BUFF) | GEM_BIT(TX_PKT_BUFF))) == 0)
 			bp->caps |= MACB_CAPS_FIFO_MODE;
-#ifdef CONFIG_MACB_USE_HWSTAMP
 		if (gem_has_ptp(bp)) {
 			if (!GEM_BFEXT(TSU, gem_readl(bp, DCFG5)))
 				dev_err(&bp->pdev->dev,
 					"GEM doesn't support hardware ptp.\n");
 			else {
+#ifdef CONFIG_MACB_USE_HWSTAMP
 				bp->hw_dma_cap |= HW_DMA_CAP_PTP;
 				bp->ptp_info = &gem_ptp_info;
+#endif
 			}
 		}
-#endif
 	}
 
 	dev_dbg(&bp->pdev->dev, "Cadence caps 0x%08x\n", bp->caps);
-- 
2.17.1


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

* [PATCH net-next v5 2/3] net: macb: Enable PTP unicast
  2023-04-11 12:37 [PATCH net-next v5 0/3] Macb PTP minor updates Harini Katakam
  2023-04-11 12:37 ` [PATCH net-next v5 1/3] net: macb: Update gem PTP support check Harini Katakam
@ 2023-04-11 12:37 ` Harini Katakam
  2023-04-11 12:37 ` [PATCH net-next v5 3/3] net: macb: Optimize reading HW timestamp Harini Katakam
  2023-04-14  5:20 ` [PATCH net-next v5 0/3] Macb PTP minor updates patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Harini Katakam @ 2023-04-11 12:37 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea,
	andrei.pistirica, kuba, edumazet, pabeni
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

From: Harini Katakam <harini.katakam@xilinx.com>

Enable transmission and reception of PTP unicast packets by
updating PTP unicast config bit and setting current HW mac
address as allowed address in PTP unicast filter registers.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
v5 and v4:
No change
v3:
Remove config check as it is handled in gem_has_ptp
v2:
Handle operation using a single write as suggested by Cladiu

 drivers/net/ethernet/cadence/macb.h      |  4 ++++
 drivers/net/ethernet/cadence/macb_main.c | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 07560803aa26..cfbdd0022764 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -95,6 +95,8 @@
 #define GEM_SA4B		0x00A0 /* Specific4 Bottom */
 #define GEM_SA4T		0x00A4 /* Specific4 Top */
 #define GEM_WOL			0x00b8 /* Wake on LAN */
+#define GEM_RXPTPUNI		0x00D4 /* PTP RX Unicast address */
+#define GEM_TXPTPUNI		0x00D8 /* PTP TX Unicast address */
 #define GEM_EFTSH		0x00e8 /* PTP Event Frame Transmitted Seconds Register 47:32 */
 #define GEM_EFRSH		0x00ec /* PTP Event Frame Received Seconds Register 47:32 */
 #define GEM_PEFTSH		0x00f0 /* PTP Peer Event Frame Transmitted Seconds Register 47:32 */
@@ -245,6 +247,8 @@
 #define MACB_TZQ_OFFSET		12 /* Transmit zero quantum pause frame */
 #define MACB_TZQ_SIZE		1
 #define MACB_SRTSM_OFFSET	15 /* Store Receive Timestamp to Memory */
+#define MACB_PTPUNI_OFFSET	20 /* PTP Unicast packet enable */
+#define MACB_PTPUNI_SIZE	1
 #define MACB_OSSMODE_OFFSET	24 /* Enable One Step Synchro Mode */
 #define MACB_OSSMODE_SIZE	1
 #define MACB_MIIONRGMII_OFFSET	28 /* MII Usage on RGMII Interface */
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index eab2d41fa571..e941ea365db1 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -287,6 +287,11 @@ static void macb_set_hwaddr(struct macb *bp)
 	top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
 	macb_or_gem_writel(bp, SA1T, top);
 
+	if (gem_has_ptp(bp)) {
+		gem_writel(bp, RXPTPUNI, bottom);
+		gem_writel(bp, TXPTPUNI, bottom);
+	}
+
 	/* Clear unused address register sets */
 	macb_or_gem_writel(bp, SA2B, 0);
 	macb_or_gem_writel(bp, SA2T, 0);
@@ -773,8 +778,12 @@ static void macb_mac_link_up(struct phylink_config *config,
 
 	spin_unlock_irqrestore(&bp->lock, flags);
 
-	/* Enable Rx and Tx */
-	macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE) | MACB_BIT(TE));
+	/* Enable Rx and Tx; Enable PTP unicast */
+	ctrl = macb_readl(bp, NCR);
+	if (gem_has_ptp(bp))
+		ctrl |= MACB_BIT(PTPUNI);
+
+	macb_writel(bp, NCR, ctrl | MACB_BIT(RE) | MACB_BIT(TE));
 
 	netif_tx_wake_all_queues(ndev);
 }
-- 
2.17.1


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

* [PATCH net-next v5 3/3] net: macb: Optimize reading HW timestamp
  2023-04-11 12:37 [PATCH net-next v5 0/3] Macb PTP minor updates Harini Katakam
  2023-04-11 12:37 ` [PATCH net-next v5 1/3] net: macb: Update gem PTP support check Harini Katakam
  2023-04-11 12:37 ` [PATCH net-next v5 2/3] net: macb: Enable PTP unicast Harini Katakam
@ 2023-04-11 12:37 ` Harini Katakam
  2023-04-14  5:20 ` [PATCH net-next v5 0/3] Macb PTP minor updates patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Harini Katakam @ 2023-04-11 12:37 UTC (permalink / raw)
  To: nicolas.ferre, davem, richardcochran, claudiu.beznea,
	andrei.pistirica, kuba, edumazet, pabeni
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

From: Harini Katakam <harini.katakam@xilinx.com>

The seconds input from BD (6 bits) just needs to be ORed with the
upper bits from timer in this function. Avoid addition operation
every single time. Seconds rollover handling is left untouched.

Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
v5 and v4:
No change
v3:
No change
v2:
- Update HW timestamp logic to remove sec_rollover variable as per
Cladiu's comment
- Remove Richard Cochran's ACK on original patch as the patch changed

 drivers/net/ethernet/cadence/macb_ptp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index f962a95068a0..51d26fa190d7 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -258,6 +258,8 @@ static int gem_hw_timestamp(struct macb *bp, u32 dma_desc_ts_1,
 	 */
 	gem_tsu_get_time(&bp->ptp_clock_info, &tsu, NULL);
 
+	ts->tv_sec |= ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
+
 	/* If the top bit is set in the timestamp,
 	 * but not in 1588 timer, it has rolled over,
 	 * so subtract max size
@@ -266,8 +268,6 @@ static int gem_hw_timestamp(struct macb *bp, u32 dma_desc_ts_1,
 	    !(tsu.tv_sec & (GEM_DMA_SEC_TOP >> 1)))
 		ts->tv_sec -= GEM_DMA_SEC_TOP;
 
-	ts->tv_sec += ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
-
 	return 0;
 }
 
-- 
2.17.1


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

* Re: [PATCH net-next v5 0/3] Macb PTP minor updates
  2023-04-11 12:37 [PATCH net-next v5 0/3] Macb PTP minor updates Harini Katakam
                   ` (2 preceding siblings ...)
  2023-04-11 12:37 ` [PATCH net-next v5 3/3] net: macb: Optimize reading HW timestamp Harini Katakam
@ 2023-04-14  5:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-14  5:20 UTC (permalink / raw)
  To: Harini Katakam
  Cc: nicolas.ferre, davem, richardcochran, claudiu.beznea,
	andrei.pistirica, kuba, edumazet, pabeni, netdev, linux-kernel,
	michal.simek, harinikatakamlinux

Hello:

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

On Tue, 11 Apr 2023 18:07:09 +0530 you wrote:
> - Enable PTP unicast
> - Optimize HW timestamp reading
> 
> v5:
> Remove unnecessary braces and !! in gem_has_ptp
> 
> v4:
> Fix kernel test robot error; use static check for
> CONFIG_MACB_USE_HWTSTAMP where necessary
> 
> [...]

Here is the summary with links:
  - [net-next,v5,1/3] net: macb: Update gem PTP support check
    https://git.kernel.org/netdev/net-next/c/adee474a3b43
  - [net-next,v5,2/3] net: macb: Enable PTP unicast
    https://git.kernel.org/netdev/net-next/c/ee4e92c26c60
  - [net-next,v5,3/3] net: macb: Optimize reading HW timestamp
    https://git.kernel.org/netdev/net-next/c/8c0d0fe04449

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] 5+ messages in thread

end of thread, other threads:[~2023-04-14  5:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-11 12:37 [PATCH net-next v5 0/3] Macb PTP minor updates Harini Katakam
2023-04-11 12:37 ` [PATCH net-next v5 1/3] net: macb: Update gem PTP support check Harini Katakam
2023-04-11 12:37 ` [PATCH net-next v5 2/3] net: macb: Enable PTP unicast Harini Katakam
2023-04-11 12:37 ` [PATCH net-next v5 3/3] net: macb: Optimize reading HW timestamp Harini Katakam
2023-04-14  5:20 ` [PATCH net-next v5 0/3] Macb PTP minor updates 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;
as well as URLs for NNTP newsgroup(s).