From: Dongdong Liu <liudongdong3@huawei.com>
To: Huisong Li <lihuisong@huawei.com>, <dev@dpdk.org>
Cc: <andrew.rybchenko@oktetlabs.ru>, <ferruh.yigit@amd.com>,
<huangdaode@huawei.com>
Subject: Re: [PATCH] net/hns3: fix inaccurate RTC time to read
Date: Fri, 13 Jan 2023 14:49:30 +0800 [thread overview]
Message-ID: <ab625ee4-4da2-6015-a9a0-91aaf1ef3df4@huawei.com> (raw)
In-Reply-To: <20230109082344.17253-1-lihuisong@huawei.com>
Hi Huisong
On 2023/1/9 16:23, Huisong Li wrote:
> The sequence of reading current RTC time register doesn't meet
> the hardware requirements, which causes this time obtained is
> the one before modifying RTC time.
>
> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
> Cc: stable@dpdk.org
>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Dongdong Liu <liudongdong3@huawei.com>
Thanks,
Dongdong
> ---
> drivers/net/hns3/hns3_ptp.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
> index 6bbd85ba23..db3c007b12 100644
> --- a/drivers/net/hns3/hns3_ptp.c
> +++ b/drivers/net/hns3/hns3_ptp.c
> @@ -216,17 +216,21 @@ hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
> int
> hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
> {
> +#define HNS3_PTP_SEC_H_OFFSET 32
> +#define HNS3_PTP_SEC_H_MASK 0xFFFF
> +
> struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + uint32_t sec_hi, sec_lo;
> uint64_t ns, sec;
>
> if (!hns3_dev_get_support(hw, PTP))
> return -ENOTSUP;
>
> - sec = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L);
> - sec |= (uint64_t)(hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & 0xFFFF)
> - << 32;
> -
> ns = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_NS);
> + sec_hi = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & HNS3_PTP_SEC_H_MASK;
> + sec_lo = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L);
> + sec = ((uint64_t)sec_hi << HNS3_PTP_SEC_H_OFFSET) | sec_lo;
> +
> ns += sec * NSEC_PER_SEC;
> *ts = rte_ns_to_timespec(ns);
>
>
next prev parent reply other threads:[~2023-01-13 6:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 8:23 [PATCH] net/hns3: fix inaccurate RTC time to read Huisong Li
2023-01-13 6:49 ` Dongdong Liu [this message]
2023-01-13 11:05 ` Ferruh Yigit
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=ab625ee4-4da2-6015-a9a0-91aaf1ef3df4@huawei.com \
--to=liudongdong3@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=huangdaode@huawei.com \
--cc=lihuisong@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.