[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLi=eTekiVDLzaJ4dYJ5EG-wRS7-sJdYF=aDCW2jONVCXCw@mail.gmail.com>
Date: Tue, 12 Nov 2024 10:05:50 -0800
From: Michael Chan <michael.chan@...adcom.com>
To: Vadim Fedorenko <vadfed@...a.com>
Cc: Vadim Fedorenko <vadim.fedorenko@...ux.dev>, Pavan Chebbi <pavan.chebbi@...adcom.com>,
Andrew Lunn <andrew+netdev@...n.ch>, Paolo Abeni <pabeni@...hat.com>,
Jakub Kicinski <kuba@...nel.org>, Richard Cochran <richardcochran@...il.com>, netdev@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Simon Horman <horms@...nel.org>
Subject: Re: [PATCH net-next] bnxt_en: optimize gettimex64
On Tue, Nov 12, 2024 at 3:06 AM Vadim Fedorenko <vadfed@...a.com> wrote:
>
> Current implementation of gettimex64() makes at least 3 PCIe reads to
> get current PHC time. It takes at least 2.2us to get this value back to
> userspace. At the same time there is cached value of upper bits of PHC
> available for packet timestamps already. This patch reuses cached value
> to speed up reading of PHC time.
>
> Signed-off-by: Vadim Fedorenko <vadfed@...a.com>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> index 91e7e08fabb1..8764ce412f7b 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
> @@ -162,13 +184,19 @@ static int bnxt_ptp_gettimex(struct ptp_clock_info *ptp_info,
> {
> struct bnxt_ptp_cfg *ptp = container_of(ptp_info, struct bnxt_ptp_cfg,
> ptp_info);
> - u64 ns, cycles;
> + u64 ns, cycles, time;
> + u32 low;
> int rc;
>
> - rc = bnxt_refclk_read(ptp->bp, sts, &cycles);
> + rc = bnxt_refclk_read_low(ptp->bp, sts, &low);
> if (rc)
> return rc;
>
> + time = (u64)READ_ONCE(ptp->old_time) << BNXT_HI_TIMER_SHIFT;
> + cycles = (time & BNXT_HI_TIMER_MASK) | low;
> + if (low < (time & BNXT_LO_TIMER_MASK))
> + cycles += BNXT_LO_TIMER_MASK + 1;
> +
Looks good to me. I think this logic here to get the upper bits and
check for overflow is identical to the RX timestamp logic. It may be
worthwhile to have a common helper function to do this. Other than
that,
Reviewed-by: Michael Chan <michael.chan@...adocm.com>
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)
Powered by blists - more mailing lists