From: Dongdong Liu <liudongdong3@huawei.com>
To: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <thomas@monjalon.net>,
<andrew.rybchenko@oktetlabs.ru>, <fengchengwen@huawei.com>
Cc: <stable@dpdk.org>, <lihuisong@huawei.com>,
<liudongdong3@huawei.com>, <yisen.zhuang@huawei.com>,
<huangdengdui@huawei.com>
Subject: [PATCH 04/11] net/hns3: extract a PTP header file
Date: Mon, 29 May 2023 21:09:33 +0800 [thread overview]
Message-ID: <20230529130940.1501-5-liudongdong3@huawei.com> (raw)
In-Reply-To: <20230529130940.1501-1-liudongdong3@huawei.com>
From: Huisong Li <lihuisong@huawei.com>
This patch extracts a PTP header file to contain PTP registers
and external API in order to make PTP code structure more clear.
Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
Cc: stable@dpdk.org
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 1 +
drivers/net/hns3/hns3_ethdev.h | 17 ------------
drivers/net/hns3/hns3_ptp.c | 2 +-
drivers/net/hns3/hns3_ptp.h | 48 ++++++++++++++++++++++++++++++++++
drivers/net/hns3/hns3_regs.h | 23 ----------------
5 files changed, 50 insertions(+), 41 deletions(-)
create mode 100644 drivers/net/hns3/hns3_ptp.h
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index b62058a0a9..aa37e7d450 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -15,6 +15,7 @@
#include "hns3_dcb.h"
#include "hns3_mp.h"
#include "hns3_flow.h"
+#include "hns3_ptp.h"
#include "hns3_ethdev.h"
#define HNS3_SERVICE_INTERVAL 1000000 /* us */
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index a03dc9fa89..3a2d687440 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1039,23 +1039,6 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status,
uint32_t link_speed, uint8_t link_duplex);
void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported);
-int hns3_restore_ptp(struct hns3_adapter *hns);
-int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev,
- struct rte_eth_conf *conf);
-int hns3_ptp_init(struct hns3_hw *hw);
-void hns3_ptp_uninit(struct hns3_hw *hw);
-int hns3_timesync_enable(struct rte_eth_dev *dev);
-int hns3_timesync_disable(struct rte_eth_dev *dev);
-int hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
- struct timespec *timestamp,
- uint32_t flags __rte_unused);
-int hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
- struct timespec *timestamp);
-int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts);
-int hns3_timesync_write_time(struct rte_eth_dev *dev,
- const struct timespec *ts);
-int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
-
const char *hns3_get_media_type_name(uint8_t media_type);
static inline bool
diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index 44cba29854..5d8cfc1b29 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -7,7 +7,7 @@
#include <rte_time.h>
#include "hns3_ethdev.h"
-#include "hns3_regs.h"
+#include "hns3_ptp.h"
#include "hns3_logs.h"
uint64_t hns3_timestamp_rx_dynflag;
diff --git a/drivers/net/hns3/hns3_ptp.h b/drivers/net/hns3/hns3_ptp.h
new file mode 100644
index 0000000000..2b8717fa3c
--- /dev/null
+++ b/drivers/net/hns3/hns3_ptp.h
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 HiSilicon Limited.
+ */
+
+#ifndef HNS3_PTP_H
+#define HNS3_PTP_H
+
+/* Register bit for 1588 event */
+#define HNS3_VECTOR0_1588_INT_B 0
+
+#define HNS3_PTP_BASE_ADDRESS 0x29000
+
+#define HNS3_TX_1588_SEQID_BACK (HNS3_PTP_BASE_ADDRESS + 0x0)
+#define HNS3_TX_1588_TSP_BACK_0 (HNS3_PTP_BASE_ADDRESS + 0x4)
+#define HNS3_TX_1588_TSP_BACK_1 (HNS3_PTP_BASE_ADDRESS + 0x8)
+#define HNS3_TX_1588_TSP_BACK_2 (HNS3_PTP_BASE_ADDRESS + 0xc)
+
+#define HNS3_TX_1588_BACK_TSP_CNT (HNS3_PTP_BASE_ADDRESS + 0x30)
+
+#define HNS3_CFG_TIME_SYNC_H (HNS3_PTP_BASE_ADDRESS + 0x50)
+#define HNS3_CFG_TIME_SYNC_M (HNS3_PTP_BASE_ADDRESS + 0x54)
+#define HNS3_CFG_TIME_SYNC_L (HNS3_PTP_BASE_ADDRESS + 0x58)
+#define HNS3_CFG_TIME_SYNC_RDY (HNS3_PTP_BASE_ADDRESS + 0x5c)
+
+#define HNS3_CFG_TIME_CYC_EN (HNS3_PTP_BASE_ADDRESS + 0x70)
+
+#define HNS3_CURR_TIME_OUT_H (HNS3_PTP_BASE_ADDRESS + 0x74)
+#define HNS3_CURR_TIME_OUT_L (HNS3_PTP_BASE_ADDRESS + 0x78)
+#define HNS3_CURR_TIME_OUT_NS (HNS3_PTP_BASE_ADDRESS + 0x7c)
+
+int hns3_restore_ptp(struct hns3_adapter *hns);
+int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev,
+ struct rte_eth_conf *conf);
+int hns3_ptp_init(struct hns3_hw *hw);
+void hns3_ptp_uninit(struct hns3_hw *hw);
+int hns3_timesync_enable(struct rte_eth_dev *dev);
+int hns3_timesync_disable(struct rte_eth_dev *dev);
+int hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
+ struct timespec *timestamp,
+ uint32_t flags __rte_unused);
+int hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
+ struct timespec *timestamp);
+int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts);
+int hns3_timesync_write_time(struct rte_eth_dev *dev,
+ const struct timespec *ts);
+int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
+
+#endif /* HNS3_PTP_H */
diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h
index 459bbaf773..6b037f81c1 100644
--- a/drivers/net/hns3/hns3_regs.h
+++ b/drivers/net/hns3/hns3_regs.h
@@ -124,29 +124,6 @@
#define HNS3_TQP_INTR_RL_DEFAULT 0
#define HNS3_TQP_INTR_QL_DEFAULT 0
-/* Register bit for 1588 event */
-#define HNS3_VECTOR0_1588_INT_B 0
-
-#define HNS3_PTP_BASE_ADDRESS 0x29000
-
-#define HNS3_TX_1588_SEQID_BACK (HNS3_PTP_BASE_ADDRESS + 0x0)
-#define HNS3_TX_1588_TSP_BACK_0 (HNS3_PTP_BASE_ADDRESS + 0x4)
-#define HNS3_TX_1588_TSP_BACK_1 (HNS3_PTP_BASE_ADDRESS + 0x8)
-#define HNS3_TX_1588_TSP_BACK_2 (HNS3_PTP_BASE_ADDRESS + 0xc)
-
-#define HNS3_TX_1588_BACK_TSP_CNT (HNS3_PTP_BASE_ADDRESS + 0x30)
-
-#define HNS3_CFG_TIME_SYNC_H (HNS3_PTP_BASE_ADDRESS + 0x50)
-#define HNS3_CFG_TIME_SYNC_M (HNS3_PTP_BASE_ADDRESS + 0x54)
-#define HNS3_CFG_TIME_SYNC_L (HNS3_PTP_BASE_ADDRESS + 0x58)
-#define HNS3_CFG_TIME_SYNC_RDY (HNS3_PTP_BASE_ADDRESS + 0x5c)
-
-#define HNS3_CFG_TIME_CYC_EN (HNS3_PTP_BASE_ADDRESS + 0x70)
-
-#define HNS3_CURR_TIME_OUT_H (HNS3_PTP_BASE_ADDRESS + 0x74)
-#define HNS3_CURR_TIME_OUT_L (HNS3_PTP_BASE_ADDRESS + 0x78)
-#define HNS3_CURR_TIME_OUT_NS (HNS3_PTP_BASE_ADDRESS + 0x7c)
-
/* gl_usec convert to hardware count, as writing each 1 represents 2us */
#define HNS3_GL_USEC_TO_REG(gl_usec) ((gl_usec) >> 1)
/* rl_usec convert to hardware count, as writing each 1 represents 4us */
--
2.22.0
next prev parent reply other threads:[~2023-05-29 13:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
2023-05-29 13:09 ` [PATCH 01/11] net/hns3: fix uninitialized RTC time Dongdong Liu
2023-06-02 9:00 ` Ferruh Yigit
2023-06-02 10:55 ` Dongdong Liu
2023-05-29 13:09 ` [PATCH 02/11] net/hns3: fix unenabled RTC time after reset Dongdong Liu
2023-05-29 13:09 ` [PATCH 03/11] net/hns3: add the uninitialization process of PTP Dongdong Liu
2023-05-29 13:09 ` Dongdong Liu [this message]
2023-05-29 13:09 ` [PATCH 05/11] net/hns3: fix mbuf leak when start rxq in resetting Dongdong Liu
2023-05-29 13:09 ` [PATCH 06/11] net/hns3: fix mbuf leak when start rxq after resetting Dongdong Liu
2023-05-29 13:09 ` [PATCH 07/11] net/hns3: fix no errcode returned when failed to init queue Dongdong Liu
2023-05-29 13:09 ` [PATCH 08/11] net/hns3: fix uninitialized variable Dongdong Liu
2023-05-29 13:09 ` [PATCH 09/11] net/hns3: make code more clean Dongdong Liu
2023-05-29 13:09 ` [PATCH 10/11] net/hns3: fix inaccurate log Dongdong Liu
2023-05-29 13:09 ` [PATCH 11/11] net/hns3: remove log redundant line break Dongdong Liu
2023-06-02 10:52 ` [PATCH 00/11] net/hns3: add some bugfixes for hns3 Ferruh Yigit
2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
2023-06-02 11:41 ` [PATCH v2 01/11] net/hns3: fix uninitialized RTC time Dongdong Liu
2023-06-02 11:41 ` [PATCH v2 02/11] net/hns3: fix unenabled RTC time after reset Dongdong Liu
2023-06-02 11:41 ` [PATCH v2 03/11] net/hns3: add the uninitialization process of PTP Dongdong Liu
2023-06-02 11:41 ` [PATCH v2 04/11] net/hns3: extract a PTP header file Dongdong Liu
2023-06-02 11:41 ` [PATCH v2 05/11] net/hns3: fix mbuf leak when start rxq in resetting Dongdong Liu
2023-06-02 11:42 ` [PATCH v2 06/11] net/hns3: fix mbuf leak when start rxq after resetting Dongdong Liu
2023-06-02 11:42 ` [PATCH v2 07/11] net/hns3: fix no errcode returned when failed to init queue Dongdong Liu
2023-06-02 11:42 ` [PATCH v2 08/11] net/hns3: fix uninitialized variable Dongdong Liu
2023-06-02 11:42 ` [PATCH v2 09/11] net/hns3: make code more clean Dongdong Liu
2023-06-02 11:42 ` [PATCH v2 10/11] net/hns3: fix inaccurate log Dongdong Liu
2023-06-02 11:42 ` [PATCH v2 11/11] net/hns3: remove log redundant line break Dongdong Liu
2023-06-02 13:51 ` [PATCH v2 00/11] net/hns3: add some bugfixes for hns3 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=20230529130940.1501-5-liudongdong3@huawei.com \
--to=liudongdong3@huawei.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=ferruh.yigit@amd.com \
--cc=huangdengdui@huawei.com \
--cc=lihuisong@huawei.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
--cc=yisen.zhuang@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 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).