From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8DDCC54EBE for ; Fri, 13 Jan 2023 06:49:36 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 135EB410EF; Fri, 13 Jan 2023 07:49:36 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 42432410D4 for ; Fri, 13 Jan 2023 07:49:34 +0100 (CET) Received: from kwepemi500017.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NtX6z69MqzJrQG; Fri, 13 Jan 2023 14:48:11 +0800 (CST) Received: from [10.67.103.235] (10.67.103.235) by kwepemi500017.china.huawei.com (7.221.188.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 13 Jan 2023 14:49:31 +0800 Subject: Re: [PATCH] net/hns3: fix inaccurate RTC time to read To: Huisong Li , References: <20230109082344.17253-1-lihuisong@huawei.com> CC: , , From: Dongdong Liu Message-ID: Date: Fri, 13 Jan 2023 14:49:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20230109082344.17253-1-lihuisong@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.235] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500017.china.huawei.com (7.221.188.110) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Acked-by: Dongdong Liu 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); > >