From: Harini Katakam <harini.katakam@xilinx.com>
To: <nicolas.ferre@microchip.com>, <davem@davemloft.net>,
<richardcochran@gmail.com>, <claudiu.beznea@microchip.com>,
<kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<michal.simek@xilinx.com>, <harinikatakamlinux@gmail.com>,
<harini.katakam@xilinx.com>, <radhey.shyam.pandey@xilinx.com>
Subject: [PATCH 3/3] net: macb: Optimize reading HW timestamp
Date: Tue, 17 May 2022 13:02:59 +0530 [thread overview]
Message-ID: <20220517073259.23476-4-harini.katakam@xilinx.com> (raw)
In-Reply-To: <20220517073259.23476-1-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 +/- operations every
single time. Check for seconds rollover at BIT 5 and subtract the
overhead only in that case.
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>
---
drivers/net/ethernet/cadence/macb_ptp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 9559c16078f9..c853518c0406 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -247,6 +247,7 @@ static int gem_hw_timestamp(struct macb *bp, u32 dma_desc_ts_1,
u32 dma_desc_ts_2, struct timespec64 *ts)
{
struct timespec64 tsu;
+ bool sec_rollover = false;
ts->tv_sec = (GEM_BFEXT(DMA_SECH, dma_desc_ts_2) << GEM_DMA_SECL_SIZE) |
GEM_BFEXT(DMA_SECL, dma_desc_ts_1);
@@ -264,9 +265,12 @@ static int gem_hw_timestamp(struct macb *bp, u32 dma_desc_ts_1,
*/
if ((ts->tv_sec & (GEM_DMA_SEC_TOP >> 1)) &&
!(tsu.tv_sec & (GEM_DMA_SEC_TOP >> 1)))
- ts->tv_sec -= GEM_DMA_SEC_TOP;
+ sec_rollover = true;
+
+ ts->tv_sec |= ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
- ts->tv_sec += ((~GEM_DMA_SEC_MASK) & tsu.tv_sec);
+ if (sec_rollover)
+ ts->tv_sec -= GEM_DMA_SEC_TOP;
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2022-05-17 7:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-17 7:32 [PATCH 0/3] Macb PTP updates Harini Katakam
2022-05-17 7:32 ` [PATCH 1/3] net: macb: Fix PTP one step sync support Harini Katakam
2022-05-18 2:42 ` Jakub Kicinski
2022-05-18 4:23 ` Harini Katakam
2022-05-18 5:06 ` Jakub Kicinski
2022-05-18 10:31 ` Harini Katakam
2022-05-17 7:32 ` [PATCH 2/3] net: macb: Enable PTP unicast Harini Katakam
2022-05-19 8:54 ` Claudiu.Beznea
2022-05-17 7:32 ` Harini Katakam [this message]
2022-05-17 13:55 ` [PATCH 0/3] Macb PTP updates Richard Cochran
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=20220517073259.23476-4-harini.katakam@xilinx.com \
--to=harini.katakam@xilinx.com \
--cc=claudiu.beznea@microchip.com \
--cc=davem@davemloft.net \
--cc=harinikatakamlinux@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=radhey.shyam.pandey@xilinx.com \
--cc=richardcochran@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).