DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/11] net/hns3: add some bugfixes for hns3
@ 2023-05-29 13:09 Dongdong Liu
  2023-05-29 13:09 ` [PATCH 01/11] net/hns3: fix uninitialized RTC time Dongdong Liu
                   ` (12 more replies)
  0 siblings, 13 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

This patchset contains some bugfixes for hns3 pmd.

Chengwen Feng (3):
  net/hns3: fix mbuf leak when start rxq in resetting
  net/hns3: fix mbuf leak when start rxq after resetting
  net/hns3: fix no errcode returned when failed to init queue

Dengdui Huang (3):
  net/hns3: make code more clean
  net/hns3: fix inaccurate log
  net/hns3: remove log redundant line break

Huisong Li (4):
  net/hns3: fix uninitialized RTC time
  net/hns3: fix unenabled RTC time after reset
  net/hns3: add the uninitialization process of PTP
  net/hns3: extract a PTP header file

Jie Hai (1):
  net/hns3: fix uninitialized variable

 drivers/net/hns3/hns3_ethdev.c    | 23 ++++++-----
 drivers/net/hns3/hns3_ethdev.h    | 16 --------
 drivers/net/hns3/hns3_ethdev_vf.c |  4 +-
 drivers/net/hns3/hns3_flow.c      |  5 ++-
 drivers/net/hns3/hns3_ptp.c       | 63 +++++++++++++++++++++----------
 drivers/net/hns3/hns3_ptp.h       | 48 +++++++++++++++++++++++
 drivers/net/hns3/hns3_regs.c      |  3 +-
 drivers/net/hns3/hns3_regs.h      | 23 -----------
 drivers/net/hns3/hns3_rxtx.c      | 47 ++++++++++++++++++-----
 9 files changed, 151 insertions(+), 81 deletions(-)
 create mode 100644 drivers/net/hns3/hns3_ptp.h

--
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/11] net/hns3: fix uninitialized RTC time
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
@ 2023-05-29 13:09 ` Dongdong Liu
  2023-06-02  9:00   ` Ferruh Yigit
  2023-05-29 13:09 ` [PATCH 02/11] net/hns3: fix unenabled RTC time after reset Dongdong Liu
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Huisong Li <lihuisong@huawei.com>

Driver doesn't initialize RTC time during probe phase, which
lead to an inaccurate time.

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_ptp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index db3c007b12..fb834bb180 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -59,6 +59,8 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en)
 int
 hns3_ptp_init(struct hns3_hw *hw)
 {
+	struct timespec sys_time;
+	struct rte_eth_dev *dev;
 	int ret;
 
 	if (!hns3_dev_get_support(hw, PTP))
@@ -71,6 +73,11 @@ hns3_ptp_init(struct hns3_hw *hw)
 	/* Start PTP timer */
 	hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1);
 
+	/* Initializing the RTC. */
+	dev = &rte_eth_devices[hw->data->port_id];
+	clock_gettime(CLOCK_REALTIME, &sys_time);
+	(void)hns3_timesync_write_time(dev, &sys_time);
+
 	return 0;
 }
 
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 02/11] net/hns3: fix unenabled RTC time after reset
  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-05-29 13:09 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 03/11] net/hns3: add the uninitialization process of PTP Dongdong Liu
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Huisong Li <lihuisong@huawei.com>

The enabled status of RTC time will be cleared after global
or IMP reset, which cause the local RTC time doesn't work.
So this patch fix it.

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 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 07d907d6a1..39bbee1d7b 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4412,6 +4412,12 @@ hns3_init_hardware(struct hns3_adapter *hns)
 		goto err_mac_init;
 	}
 
+	ret = hns3_ptp_init(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init PTP, ret = %d", ret);
+		goto err_mac_init;
+	}
+
 	return 0;
 
 err_mac_init:
@@ -4573,10 +4579,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
 		goto err_intr_callback_register;
 	}
 
-	ret = hns3_ptp_init(hw);
-	if (ret)
-		goto err_get_config;
-
 	/* Enable interrupt */
 	rte_intr_enable(pci_dev->intr_handle);
 	hns3_pf_enable_irq0(hw);
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 03/11] net/hns3: add the uninitialization process of PTP
  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-05-29 13:09 ` [PATCH 02/11] net/hns3: fix unenabled RTC time after reset Dongdong Liu
@ 2023-05-29 13:09 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 04/11] net/hns3: extract a PTP header file Dongdong Liu
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Huisong Li <lihuisong@huawei.com>

This patch adds the uninitialization process of PTP in case
of having an impact on PF driver in kernel.

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 |  2 +
 drivers/net/hns3/hns3_ethdev.h |  1 +
 drivers/net/hns3/hns3_ptp.c    | 68 +++++++++++++++++++++-------------
 3 files changed, 46 insertions(+), 25 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 39bbee1d7b..b62058a0a9 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4633,6 +4633,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
 	hns3_fdir_filter_uninit(hns);
 err_fdir:
 	hns3_uninit_umv_space(hw);
+	hns3_ptp_uninit(hw);
 err_init_hw:
 	hns3_stats_uninit(hw);
 err_get_config:
@@ -4668,6 +4669,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)
 	hns3_flow_uninit(eth_dev);
 	hns3_fdir_filter_uninit(hns);
 	hns3_uninit_umv_space(hw);
+	hns3_ptp_uninit(hw);
 	hns3_stats_uninit(hw);
 	hns3_config_mac_tnl_int(hw, false);
 	hns3_pf_disable_irq0(hw);
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 88146f5054..a03dc9fa89 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1043,6 +1043,7 @@ 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,
diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index fb834bb180..44cba29854 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -56,31 +56,6 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en)
 	return ret;
 }
 
-int
-hns3_ptp_init(struct hns3_hw *hw)
-{
-	struct timespec sys_time;
-	struct rte_eth_dev *dev;
-	int ret;
-
-	if (!hns3_dev_get_support(hw, PTP))
-		return 0;
-
-	ret = hns3_ptp_int_en(hw, true);
-	if (ret)
-		return ret;
-
-	/* Start PTP timer */
-	hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1);
-
-	/* Initializing the RTC. */
-	dev = &rte_eth_devices[hw->data->port_id];
-	clock_gettime(CLOCK_REALTIME, &sys_time);
-	(void)hns3_timesync_write_time(dev, &sys_time);
-
-	return 0;
-}
-
 static int
 hns3_timesync_configure(struct hns3_adapter *hns, bool en)
 {
@@ -301,3 +276,46 @@ hns3_restore_ptp(struct hns3_adapter *hns)
 
 	return ret;
 }
+
+int
+hns3_ptp_init(struct hns3_hw *hw)
+{
+	struct timespec sys_time;
+	struct rte_eth_dev *dev;
+	int ret;
+
+	if (!hns3_dev_get_support(hw, PTP))
+		return 0;
+
+	ret = hns3_ptp_int_en(hw, true);
+	if (ret != 0)
+		return ret;
+
+	/* Start PTP timer */
+	hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1);
+
+	/* Initializing the RTC. */
+	dev = &rte_eth_devices[hw->data->port_id];
+	clock_gettime(CLOCK_REALTIME, &sys_time);
+	(void)hns3_timesync_write_time(dev, &sys_time);
+
+	return 0;
+}
+
+void
+hns3_ptp_uninit(struct hns3_hw *hw)
+{
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+	int ret;
+
+	if (!hns3_dev_get_support(hw, PTP))
+		return;
+
+	ret = hns3_ptp_int_en(hw, false);
+	if (ret != 0)
+		hns3_err(hw, "disable PTP interrupt failed, ret = %d.", ret);
+
+	ret = hns3_timesync_configure(hns, false);
+	if (ret != 0)
+		hns3_err(hw, "disable timesync failed, ret = %d.", ret);
+}
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 04/11] net/hns3: extract a PTP header file
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (2 preceding siblings ...)
  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
  2023-05-29 13:09 ` [PATCH 05/11] net/hns3: fix mbuf leak when start rxq in resetting Dongdong Liu
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

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


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 05/11] net/hns3: fix mbuf leak when start rxq in resetting
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (3 preceding siblings ...)
  2023-05-29 13:09 ` [PATCH 04/11] net/hns3: extract a PTP header file Dongdong Liu
@ 2023-05-29 13:09 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 06/11] net/hns3: fix mbuf leak when start rxq after resetting Dongdong Liu
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Chengwen Feng <fengchengwen@huawei.com>

In the reset restore-conf phase, the reset process will allocate for
the Rx ring mbufs unconditionlly.

And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring
mbufs unconditionlly.

So if the rte_eth_dev_rx_queue_start() is invoked before restore-conf
phase, then the mbufs allocated by rte_eth_dev_rx_queue_start() will
leak.

Because the hw->reset.resetting was always true during the phases from
stop-service to restore-conf, so fix it by returning an error if the
hw->reset.resetting is set.

This patch adds the above logic in both rx_queue_start/rx_queue_stop/
tx_queue_start/tx_queue_stop ops.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 6468da903e..2bfc5507e3 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4523,6 +4523,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to start Rx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	ret = hns3_reset_queue(hw, rx_queue_id, HNS3_RING_TYPE_RX);
 	if (ret) {
 		hns3_err(hw, "fail to reset Rx queue %u, ret = %d.",
@@ -4569,6 +4576,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to stop Rx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	hns3_enable_rxq(rxq, false);
 
 	hns3_rx_queue_release_mbufs(rxq);
@@ -4591,6 +4605,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to start Tx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	ret = hns3_reset_queue(hw, tx_queue_id, HNS3_RING_TYPE_TX);
 	if (ret) {
 		hns3_err(hw, "fail to reset Tx queue %u, ret = %d.",
@@ -4617,6 +4638,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to stop Tx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	hns3_enable_txq(txq, false);
 	hns3_tx_queue_release_mbufs(txq);
 	/*
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 06/11] net/hns3: fix mbuf leak when start rxq after resetting
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (4 preceding siblings ...)
  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 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 07/11] net/hns3: fix no errcode returned when failed to init queue Dongdong Liu
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Chengwen Feng <fengchengwen@huawei.com>

In the reset restore-conf phase, the reset process will allocate for
the Rx ring mbufs unconditionlly.

And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring
mbufs unconditionlly.

So if the rte_eth_dev_rx_queue_start() is invoked after restore-conf
phase, then the mbufs allocated in restore-conf phase will leak.

So fix it by conditional release Rx ring mbufs in
rte_eth_dev_rx_queue_start(): if the Rx ring mbufs were allocated then
release them first.

This patch also set all sw-ring[]'s mbuf is NULL when release Rx ring
mbufs so that we can determine whether the Rx ring mbufs were allocated
based only on the first sw-ring[0]'s mbuf.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 2bfc5507e3..2493748683 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -50,6 +50,8 @@ hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq)
 				rxq->sw_ring[i].mbuf = NULL;
 			}
 		}
+		for (i = 0; i < rxq->rx_rearm_nb; i++)
+			rxq->sw_ring[rxq->rx_rearm_start + i].mbuf = NULL;
 	}
 
 	for (i = 0; i < rxq->bulk_mbuf_num; i++)
@@ -4538,6 +4540,9 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return ret;
 	}
 
+	if (rxq->sw_ring[0].mbuf != NULL)
+		hns3_rx_queue_release_mbufs(rxq);
+
 	ret = hns3_init_rxq(hns, rx_queue_id);
 	if (ret) {
 		hns3_err(hw, "fail to init Rx queue %u, ret = %d.",
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 07/11] net/hns3: fix no errcode returned when failed to init queue
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (5 preceding siblings ...)
  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 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 08/11] net/hns3: fix uninitialized variable Dongdong Liu
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Chengwen Feng <fengchengwen@huawei.com>

If hns3_init_queues() return failed, the hns3vf_do_start() should
return errcode. This patch fixes it.

Fixes: 43d8adf3891c ("net/hns3: fix RSS flow rule restore")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev_vf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index d051a1357b..5aac62a41f 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1674,8 +1674,10 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
 	hns3_enable_rxd_adv_layout(hw);
 
 	ret = hns3_init_queues(hns, reset_queue);
-	if (ret)
+	if (ret) {
 		hns3_err(hw, "failed to init queues, ret = %d.", ret);
+		return ret;
+	}
 
 	return hns3_restore_filter(hns);
 }
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 08/11] net/hns3: fix uninitialized variable
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (6 preceding siblings ...)
  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 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 09/11] net/hns3: make code more clean Dongdong Liu
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Jie Hai <haijie1@huawei.com>

This patch fixes possible use of uninitialized variable
"old_tuple_fields".

Fixes: e3069658da9f ("net/hns3: reimplement hash flow function")
Cc: stable@dpdk.org

Signed-off-by: Jie Hai <haijie1@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index e132d88fa1..a5a7e452d8 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1944,8 +1944,9 @@ hns3_flow_set_rss_ptype_tuple(struct hns3_hw *hw,
 	if (ret != 0)
 		return ret;
 
-	hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64,
-		  old_tuple_fields, new_tuple_fields);
+	if (!cfg_global_tuple)
+		hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64,
+			  old_tuple_fields, new_tuple_fields);
 
 	return 0;
 }
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 09/11] net/hns3: make code more clean
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (7 preceding siblings ...)
  2023-05-29 13:09 ` [PATCH 08/11] net/hns3: fix uninitialized variable Dongdong Liu
@ 2023-05-29 13:09 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 10/11] net/hns3: fix inaccurate log Dongdong Liu
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

This patch modify the code that violates the coding standards.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_regs.c |  3 +--
 drivers/net/hns3/hns3_rxtx.c | 10 +++-------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 5d6f92e4bb..be1be6a89c 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -385,10 +385,9 @@ hns3_dfx_reg_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc,
 	hns3_cmd_setup_basic_desc(&desc[i], opcode, true);
 
 	ret = hns3_cmd_send(hw, desc, bd_num);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "fail to query dfx registers, opcode = 0x%04X, "
 			 "ret = %d.\n", opcode, ret);
-	}
 
 	return ret;
 }
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 2493748683..cf04dc857e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -751,7 +751,7 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw)
 		for (i = 0; i < hw->cfg_max_queues; i++) {
 			ret = hns3pf_reset_tqp(hw, i);
 			if (ret) {
-				hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.",
+				hns3_err(hw, "fail to reset tqp, queue_id = %u, ret = %d.",
 					 i, ret);
 				return ret;
 			}
@@ -829,15 +829,13 @@ hns3_send_reset_queue_cmd(struct hns3_hw *hw, uint16_t queue_id,
 {
 	struct hns3_reset_tqp_queue_cmd *req;
 	struct hns3_cmd_desc desc;
-	int queue_direction;
 	int ret;
 
 	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RESET_TQP_QUEUE_INDEP, false);
 
 	req = (struct hns3_reset_tqp_queue_cmd *)desc.data;
 	req->tqp_id = rte_cpu_to_le_16(queue_id);
-	queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
-	req->queue_direction = rte_cpu_to_le_16(queue_direction);
+	req->queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
 	hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0);
 
 	ret = hns3_cmd_send(hw, &desc, 1);
@@ -855,15 +853,13 @@ hns3_get_queue_reset_status(struct hns3_hw *hw, uint16_t queue_id,
 {
 	struct hns3_reset_tqp_queue_cmd *req;
 	struct hns3_cmd_desc desc;
-	int queue_direction;
 	int ret;
 
 	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RESET_TQP_QUEUE_INDEP, true);
 
 	req = (struct hns3_reset_tqp_queue_cmd *)desc.data;
 	req->tqp_id = rte_cpu_to_le_16(queue_id);
-	queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
-	req->queue_direction = rte_cpu_to_le_16(queue_direction);
+	req->queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
 
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret) {
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 10/11] net/hns3: fix inaccurate log
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (8 preceding siblings ...)
  2023-05-29 13:09 ` [PATCH 09/11] net/hns3: make code more clean Dongdong Liu
@ 2023-05-29 13:09 ` Dongdong Liu
  2023-05-29 13:09 ` [PATCH 11/11] net/hns3: remove log redundant line break Dongdong Liu
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

This patch fix inaccurate log

Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
Fixes: a951c1ed3ab5 ("net/hns3: support different numbers of Rx and Tx queues")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index cf04dc857e..f3c3b38c55 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -586,7 +586,7 @@ hns3_tqp_enable(struct hns3_hw *hw, uint16_t queue_id, bool enable)
 
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret)
-		hns3_err(hw, "TQP enable fail, ret = %d", ret);
+		hns3_err(hw, "TQP %s fail, ret = %d", enable ? "enable" : "disable", ret);
 
 	return ret;
 }
@@ -1635,7 +1635,7 @@ hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q,
 
 	ret = hns3_fake_tx_queue_config(hw, tx_need_add_nb_q);
 	if (ret) {
-		hns3_err(hw, "Fail to configure fake rx queues: %d", ret);
+		hns3_err(hw, "Fail to configure fake tx queues: %d", ret);
 		goto cfg_fake_tx_q_fail;
 	}
 
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 11/11] net/hns3: remove log redundant line break
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (9 preceding siblings ...)
  2023-05-29 13:09 ` [PATCH 10/11] net/hns3: fix inaccurate log Dongdong Liu
@ 2023-05-29 13:09 ` 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
  12 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-05-29 13:09 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

This patch remove log redundant line break

Fixes: d51867db65c1 ("net/hns3: add initialization")
Fixes: c6332c3cf9f0 ("net/hns3: support module EEPROM dump")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index aa37e7d450..3155542c31 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -3629,7 +3629,7 @@ hns3_get_mac_ethertype_cmd_status(uint16_t cmdq_resp, uint8_t resp_code)
 
 	if (cmdq_resp) {
 		PMD_INIT_LOG(ERR,
-			     "cmdq execute failed for get_mac_ethertype_cmd_status, status=%u.\n",
+			     "cmdq execute failed for get_mac_ethertype_cmd_status, status=%u.",
 			     cmdq_resp);
 		return -EIO;
 	}
@@ -6245,7 +6245,7 @@ hns3_optical_module_existed(struct hns3_hw *hw)
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret) {
 		hns3_err(hw,
-			 "fail to get optical module exist state, ret = %d.\n",
+			 "fail to get optical module exist state, ret = %d.",
 			 ret);
 		return false;
 	}
@@ -6283,7 +6283,7 @@ hns3_get_module_eeprom_data(struct hns3_hw *hw, uint32_t offset,
 
 	ret = hns3_cmd_send(hw, desc, HNS3_SFP_INFO_CMD_NUM);
 	if (ret) {
-		hns3_err(hw, "fail to get module EEPROM info, ret = %d.\n",
+		hns3_err(hw, "fail to get module EEPROM info, ret = %d.",
 				ret);
 		return ret;
 	}
@@ -6320,7 +6320,7 @@ hns3_get_module_eeprom(struct rte_eth_dev *dev,
 		return -ENOTSUP;
 
 	if (!hns3_optical_module_existed(hw)) {
-		hns3_err(hw, "fail to read module EEPROM: no module is connected.\n");
+		hns3_err(hw, "fail to read module EEPROM: no module is connected.");
 		return -EIO;
 	}
 
@@ -6383,7 +6383,7 @@ hns3_get_module_info(struct rte_eth_dev *dev,
 		modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8636_MAX_LEN;
 		break;
 	default:
-		hns3_err(hw, "unknown module, type = %u, extra_type = %u.\n",
+		hns3_err(hw, "unknown module, type = %u, extra_type = %u.",
 			 sfp_type.type, sfp_type.ext_type);
 		return -EINVAL;
 	}
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/11] net/hns3: fix uninitialized RTC time
  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
  0 siblings, 1 reply; 28+ messages in thread
From: Ferruh Yigit @ 2023-06-02  9:00 UTC (permalink / raw)
  To: Dongdong Liu, dev, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, yisen.zhuang, huangdengdui

On 5/29/2023 2:09 PM, Dongdong Liu wrote:
> From: Huisong Li <lihuisong@huawei.com>
> 
> Driver doesn't initialize RTC time during probe phase, which
> lead to an inaccurate time.
> 
> 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_ptp.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
> index db3c007b12..fb834bb180 100644
> --- a/drivers/net/hns3/hns3_ptp.c
> +++ b/drivers/net/hns3/hns3_ptp.c
> @@ -59,6 +59,8 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en)
>  int
>  hns3_ptp_init(struct hns3_hw *hw)
>  {
> +	struct timespec sys_time;
> +	struct rte_eth_dev *dev;
>  	int ret;
>  
>  	if (!hns3_dev_get_support(hw, PTP))
> @@ -71,6 +73,11 @@ hns3_ptp_init(struct hns3_hw *hw)
>  	/* Start PTP timer */
>  	hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1);
>  
> +	/* Initializing the RTC. */
> +	dev = &rte_eth_devices[hw->data->port_id];


Better to not access 'rte_eth_devices[]' global array directly from the
driver, driver should keep reference to the eth_dev internally.

'hns3_timesync_write_time()' already gets 'hw' from 'eth_dev' and uses
it. Perhaps 'hns3_timesync_write_time()' should get 'hw' as paramter.

Since 'hns3_timesync_write_time()' used for dev_ops, it is possible to
get internal version of it, like:

```
hns3_timesync_write_time_(struct hns3_hw *hw, timespec *ts) {
}

hns3_timesync_write_time(struct rte_eth_dev *dev, timespec *ts) {
	struct hns3_hw *hw = <dev to hw>;

	hns3_timesync_write_time_(hw, ts);
}
```

And this function can directly use internal version.
	

> +	clock_gettime(CLOCK_REALTIME, &sys_time);
> +	(void)hns3_timesync_write_time(dev, &sys_time);
> +
>  	return 0;
>  }
>  


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 00/11] net/hns3: add some bugfixes for hns3
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (10 preceding siblings ...)
  2023-05-29 13:09 ` [PATCH 11/11] net/hns3: remove log redundant line break Dongdong Liu
@ 2023-06-02 10:52 ` Ferruh Yigit
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
  12 siblings, 0 replies; 28+ messages in thread
From: Ferruh Yigit @ 2023-06-02 10:52 UTC (permalink / raw)
  To: Dongdong Liu, dev, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, yisen.zhuang, huangdengdui

On 5/29/2023 2:09 PM, Dongdong Liu wrote:
> This patchset contains some bugfixes for hns3 pmd.
> 
> Chengwen Feng (3):
>   net/hns3: fix mbuf leak when start rxq in resetting
>   net/hns3: fix mbuf leak when start rxq after resetting
>   net/hns3: fix no errcode returned when failed to init queue
> 
> Dengdui Huang (3):
>   net/hns3: make code more clean
>   net/hns3: fix inaccurate log
>   net/hns3: remove log redundant line break
> 
> Huisong Li (4):
>   net/hns3: fix uninitialized RTC time
>   net/hns3: fix unenabled RTC time after reset
>   net/hns3: add the uninitialization process of PTP
>   net/hns3: extract a PTP header file
> 
> Jie Hai (1):
>   net/hns3: fix uninitialized variable
>

Except from comment on first patch, rest looks good to me, waiting for
new version.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/11] net/hns3: fix uninitialized RTC time
  2023-06-02  9:00   ` Ferruh Yigit
@ 2023-06-02 10:55     ` Dongdong Liu
  0 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 10:55 UTC (permalink / raw)
  To: Ferruh Yigit, dev, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, yisen.zhuang, huangdengdui

Hi Ferruh

Many thanks for your review.

On 2023/6/2 17:00, Ferruh Yigit wrote:
> On 5/29/2023 2:09 PM, Dongdong Liu wrote:
>> From: Huisong Li <lihuisong@huawei.com>
>>
>> Driver doesn't initialize RTC time during probe phase, which
>> lead to an inaccurate time.
>>
>> 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_ptp.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
>> index db3c007b12..fb834bb180 100644
>> --- a/drivers/net/hns3/hns3_ptp.c
>> +++ b/drivers/net/hns3/hns3_ptp.c
>> @@ -59,6 +59,8 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en)
>>  int
>>  hns3_ptp_init(struct hns3_hw *hw)
>>  {
>> +	struct timespec sys_time;
>> +	struct rte_eth_dev *dev;
>>  	int ret;
>>
>>  	if (!hns3_dev_get_support(hw, PTP))
>> @@ -71,6 +73,11 @@ hns3_ptp_init(struct hns3_hw *hw)
>>  	/* Start PTP timer */
>>  	hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1);
>>
>> +	/* Initializing the RTC. */
>> +	dev = &rte_eth_devices[hw->data->port_id];
>
>
> Better to not access 'rte_eth_devices[]' global array directly from the
> driver, driver should keep reference to the eth_dev internally.
>
> 'hns3_timesync_write_time()' already gets 'hw' from 'eth_dev' and uses
> it. Perhaps 'hns3_timesync_write_time()' should get 'hw' as paramter.
>
> Since 'hns3_timesync_write_time()' used for dev_ops, it is possible to
> get internal version of it, like:
>
> ```
> hns3_timesync_write_time_(struct hns3_hw *hw, timespec *ts) {
> }
>
> hns3_timesync_write_time(struct rte_eth_dev *dev, timespec *ts) {
> 	struct hns3_hw *hw = <dev to hw>;
>
> 	hns3_timesync_write_time_(hw, ts);
> }
> ```
>
> And this function can directly use internal version.
Good point.
Will fix in v2.

Thanks,
Dongdong
> 	
>
>> +	clock_gettime(CLOCK_REALTIME, &sys_time);
>> +	(void)hns3_timesync_write_time(dev, &sys_time);
>> +
>>  	return 0;
>>  }
>>
>
> .
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 00/11] net/hns3: add some bugfixes for hns3
  2023-05-29 13:09 [PATCH 00/11] net/hns3: add some bugfixes for hns3 Dongdong Liu
                   ` (11 preceding siblings ...)
  2023-06-02 10:52 ` [PATCH 00/11] net/hns3: add some bugfixes for hns3 Ferruh Yigit
@ 2023-06-02 11:41 ` Dongdong Liu
  2023-06-02 11:41   ` [PATCH v2 01/11] net/hns3: fix uninitialized RTC time Dongdong Liu
                     ` (11 more replies)
  12 siblings, 12 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:41 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

This patchset contains some bugfixes for hns3 pmd.

v1->v2:
- Fix the comments for [PATCH 01/11] suggested by Ferruh.

Chengwen Feng (3):
  net/hns3: fix mbuf leak when start rxq in resetting
  net/hns3: fix mbuf leak when start rxq after resetting
  net/hns3: fix no errcode returned when failed to init queue

Dengdui Huang (3):
  net/hns3: make code more clean
  net/hns3: fix inaccurate log
  net/hns3: remove log redundant line break

Huisong Li (4):
  net/hns3: fix uninitialized RTC time
  net/hns3: fix unenabled RTC time after reset
  net/hns3: add the uninitialization process of PTP
  net/hns3: extract a PTP header file

Jie Hai (1):
  net/hns3: fix uninitialized variable

 drivers/net/hns3/hns3_ethdev.c    | 23 +++++++++------
 drivers/net/hns3/hns3_ethdev.h    | 16 -----------
 drivers/net/hns3/hns3_ethdev_vf.c |  4 ++-
 drivers/net/hns3/hns3_flow.c      |  5 ++--
 drivers/net/hns3/hns3_ptp.c       | 46 +++++++++++++++++++++++------
 drivers/net/hns3/hns3_ptp.h       | 48 +++++++++++++++++++++++++++++++
 drivers/net/hns3/hns3_regs.c      |  3 +-
 drivers/net/hns3/hns3_regs.h      | 23 ---------------
 drivers/net/hns3/hns3_rxtx.c      | 47 ++++++++++++++++++++++++------
 9 files changed, 145 insertions(+), 70 deletions(-)
 create mode 100644 drivers/net/hns3/hns3_ptp.h

--
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 01/11] net/hns3: fix uninitialized RTC time
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
@ 2023-06-02 11:41   ` Dongdong Liu
  2023-06-02 11:41   ` [PATCH v2 02/11] net/hns3: fix unenabled RTC time after reset Dongdong Liu
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:41 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Huisong Li <lihuisong@huawei.com>

Driver doesn't initialize RTC time during probe phase, which
lead to an inaccurate time.

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_ptp.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index db3c007b12..1e27e4aeca 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -56,9 +56,23 @@ hns3_ptp_int_en(struct hns3_hw *hw, bool en)
 	return ret;
 }
 
+static void
+hns3_ptp_timesync_write_time(struct hns3_hw *hw, const struct timespec *ts)
+{
+	uint64_t sec = ts->tv_sec;
+	uint64_t ns = ts->tv_nsec;
+
+	/* Set the timecounters to a new value. */
+	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_H, upper_32_bits(sec));
+	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_M, lower_32_bits(sec));
+	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_L, lower_32_bits(ns));
+	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_RDY, 1);
+}
+
 int
 hns3_ptp_init(struct hns3_hw *hw)
 {
+	struct timespec sys_time;
 	int ret;
 
 	if (!hns3_dev_get_support(hw, PTP))
@@ -71,6 +85,10 @@ hns3_ptp_init(struct hns3_hw *hw)
 	/* Start PTP timer */
 	hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1);
 
+	/* Initializing the RTC. */
+	clock_gettime(CLOCK_REALTIME, &sys_time);
+	hns3_ptp_timesync_write_time(hw, &sys_time);
+
 	return 0;
 }
 
@@ -241,17 +259,11 @@ int
 hns3_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
 {
 	struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint64_t sec = ts->tv_sec;
-	uint64_t ns = ts->tv_nsec;
 
 	if (!hns3_dev_get_support(hw, PTP))
 		return -ENOTSUP;
 
-	/* Set the timecounters to a new value. */
-	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_H, upper_32_bits(sec));
-	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_M, lower_32_bits(sec));
-	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_L, lower_32_bits(ns));
-	hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_RDY, 1);
+	hns3_ptp_timesync_write_time(hw, ts);
 
 	return 0;
 }
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 02/11] net/hns3: fix unenabled RTC time after reset
  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   ` Dongdong Liu
  2023-06-02 11:41   ` [PATCH v2 03/11] net/hns3: add the uninitialization process of PTP Dongdong Liu
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:41 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Huisong Li <lihuisong@huawei.com>

The enabled status of RTC time will be cleared after global
or IMP reset, which cause the local RTC time doesn't work.
So this patch fix it.

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 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 600accea93..9ed54ae384 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4416,6 +4416,12 @@ hns3_init_hardware(struct hns3_adapter *hns)
 		goto err_mac_init;
 	}
 
+	ret = hns3_ptp_init(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "Failed to init PTP, ret = %d", ret);
+		goto err_mac_init;
+	}
+
 	return 0;
 
 err_mac_init:
@@ -4577,10 +4583,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
 		goto err_intr_callback_register;
 	}
 
-	ret = hns3_ptp_init(hw);
-	if (ret)
-		goto err_get_config;
-
 	/* Enable interrupt */
 	rte_intr_enable(pci_dev->intr_handle);
 	hns3_pf_enable_irq0(hw);
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 03/11] net/hns3: add the uninitialization process of PTP
  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   ` Dongdong Liu
  2023-06-02 11:41   ` [PATCH v2 04/11] net/hns3: extract a PTP header file Dongdong Liu
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:41 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Huisong Li <lihuisong@huawei.com>

This patch adds the uninitialization process of PTP in case
of having an impact on PF driver in kernel.

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 |  2 ++
 drivers/net/hns3/hns3_ethdev.h |  1 +
 drivers/net/hns3/hns3_ptp.c    | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 9ed54ae384..70463fe177 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -4637,6 +4637,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev)
 	hns3_fdir_filter_uninit(hns);
 err_fdir:
 	hns3_uninit_umv_space(hw);
+	hns3_ptp_uninit(hw);
 err_init_hw:
 	hns3_stats_uninit(hw);
 err_get_config:
@@ -4672,6 +4673,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev)
 	hns3_flow_uninit(eth_dev);
 	hns3_fdir_filter_uninit(hns);
 	hns3_uninit_umv_space(hw);
+	hns3_ptp_uninit(hw);
 	hns3_stats_uninit(hw);
 	hns3_config_mac_tnl_int(hw, false);
 	hns3_pf_disable_irq0(hw);
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index c04edf622f..9456204422 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1045,6 +1045,7 @@ 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,
diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index 1e27e4aeca..0e17a17034 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -306,3 +306,21 @@ hns3_restore_ptp(struct hns3_adapter *hns)
 
 	return ret;
 }
+
+void
+hns3_ptp_uninit(struct hns3_hw *hw)
+{
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+	int ret;
+
+	if (!hns3_dev_get_support(hw, PTP))
+		return;
+
+	ret = hns3_ptp_int_en(hw, false);
+	if (ret != 0)
+		hns3_err(hw, "disable PTP interrupt failed, ret = %d.", ret);
+
+	ret = hns3_timesync_configure(hns, false);
+	if (ret != 0)
+		hns3_err(hw, "disable timesync failed, ret = %d.", ret);
+}
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 04/11] net/hns3: extract a PTP header file
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (2 preceding siblings ...)
  2023-06-02 11:41   ` [PATCH v2 03/11] net/hns3: add the uninitialization process of PTP Dongdong Liu
@ 2023-06-02 11:41   ` Dongdong Liu
  2023-06-02 11:41   ` [PATCH v2 05/11] net/hns3: fix mbuf leak when start rxq in resetting Dongdong Liu
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:41 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

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 70463fe177..64028778d0 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 9456204422..c58094d87b 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1041,23 +1041,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 0e17a17034..894ac6dd71 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


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 05/11] net/hns3: fix mbuf leak when start rxq in resetting
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (3 preceding siblings ...)
  2023-06-02 11:41   ` [PATCH v2 04/11] net/hns3: extract a PTP header file Dongdong Liu
@ 2023-06-02 11:41   ` Dongdong Liu
  2023-06-02 11:42   ` [PATCH v2 06/11] net/hns3: fix mbuf leak when start rxq after resetting Dongdong Liu
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:41 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Chengwen Feng <fengchengwen@huawei.com>

In the reset restore-conf phase, the reset process will allocate for
the Rx ring mbufs unconditionlly.

And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring
mbufs unconditionlly.

So if the rte_eth_dev_rx_queue_start() is invoked before restore-conf
phase, then the mbufs allocated by rte_eth_dev_rx_queue_start() will
leak.

Because the hw->reset.resetting was always true during the phases from
stop-service to restore-conf, so fix it by returning an error if the
hw->reset.resetting is set.

This patch adds the above logic in both rx_queue_start/rx_queue_stop/
tx_queue_start/tx_queue_stop ops.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 6468da903e..2bfc5507e3 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4523,6 +4523,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to start Rx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	ret = hns3_reset_queue(hw, rx_queue_id, HNS3_RING_TYPE_RX);
 	if (ret) {
 		hns3_err(hw, "fail to reset Rx queue %u, ret = %d.",
@@ -4569,6 +4576,13 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to stop Rx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	hns3_enable_rxq(rxq, false);
 
 	hns3_rx_queue_release_mbufs(rxq);
@@ -4591,6 +4605,13 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to start Tx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	ret = hns3_reset_queue(hw, tx_queue_id, HNS3_RING_TYPE_TX);
 	if (ret) {
 		hns3_err(hw, "fail to reset Tx queue %u, ret = %d.",
@@ -4617,6 +4638,13 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 		return -ENOTSUP;
 
 	rte_spinlock_lock(&hw->lock);
+
+	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
+		hns3_err(hw, "fail to stop Tx queue during resetting.");
+		rte_spinlock_unlock(&hw->lock);
+		return -EIO;
+	}
+
 	hns3_enable_txq(txq, false);
 	hns3_tx_queue_release_mbufs(txq);
 	/*
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 06/11] net/hns3: fix mbuf leak when start rxq after resetting
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (4 preceding siblings ...)
  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   ` Dongdong Liu
  2023-06-02 11:42   ` [PATCH v2 07/11] net/hns3: fix no errcode returned when failed to init queue Dongdong Liu
                     ` (5 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:42 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Chengwen Feng <fengchengwen@huawei.com>

In the reset restore-conf phase, the reset process will allocate for
the Rx ring mbufs unconditionlly.

And the rte_eth_dev_rx_queue_start() will also allocate for the Rx ring
mbufs unconditionlly.

So if the rte_eth_dev_rx_queue_start() is invoked after restore-conf
phase, then the mbufs allocated in restore-conf phase will leak.

So fix it by conditional release Rx ring mbufs in
rte_eth_dev_rx_queue_start(): if the Rx ring mbufs were allocated then
release them first.

This patch also set all sw-ring[]'s mbuf is NULL when release Rx ring
mbufs so that we can determine whether the Rx ring mbufs were allocated
based only on the first sw-ring[0]'s mbuf.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 2bfc5507e3..2493748683 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -50,6 +50,8 @@ hns3_rx_queue_release_mbufs(struct hns3_rx_queue *rxq)
 				rxq->sw_ring[i].mbuf = NULL;
 			}
 		}
+		for (i = 0; i < rxq->rx_rearm_nb; i++)
+			rxq->sw_ring[rxq->rx_rearm_start + i].mbuf = NULL;
 	}
 
 	for (i = 0; i < rxq->bulk_mbuf_num; i++)
@@ -4538,6 +4540,9 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return ret;
 	}
 
+	if (rxq->sw_ring[0].mbuf != NULL)
+		hns3_rx_queue_release_mbufs(rxq);
+
 	ret = hns3_init_rxq(hns, rx_queue_id);
 	if (ret) {
 		hns3_err(hw, "fail to init Rx queue %u, ret = %d.",
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 07/11] net/hns3: fix no errcode returned when failed to init queue
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (5 preceding siblings ...)
  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   ` Dongdong Liu
  2023-06-02 11:42   ` [PATCH v2 08/11] net/hns3: fix uninitialized variable Dongdong Liu
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:42 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Chengwen Feng <fengchengwen@huawei.com>

If hns3_init_queues() return failed, the hns3vf_do_start() should
return errcode. This patch fixes it.

Fixes: 43d8adf3891c ("net/hns3: fix RSS flow rule restore")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev_vf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index d051a1357b..5aac62a41f 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -1674,8 +1674,10 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
 	hns3_enable_rxd_adv_layout(hw);
 
 	ret = hns3_init_queues(hns, reset_queue);
-	if (ret)
+	if (ret) {
 		hns3_err(hw, "failed to init queues, ret = %d.", ret);
+		return ret;
+	}
 
 	return hns3_restore_filter(hns);
 }
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 08/11] net/hns3: fix uninitialized variable
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (6 preceding siblings ...)
  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   ` Dongdong Liu
  2023-06-02 11:42   ` [PATCH v2 09/11] net/hns3: make code more clean Dongdong Liu
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:42 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Jie Hai <haijie1@huawei.com>

This patch fixes possible use of uninitialized variable
"old_tuple_fields".

Fixes: e3069658da9f ("net/hns3: reimplement hash flow function")
Cc: stable@dpdk.org

Signed-off-by: Jie Hai <haijie1@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index e132d88fa1..a5a7e452d8 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -1944,8 +1944,9 @@ hns3_flow_set_rss_ptype_tuple(struct hns3_hw *hw,
 	if (ret != 0)
 		return ret;
 
-	hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64,
-		  old_tuple_fields, new_tuple_fields);
+	if (!cfg_global_tuple)
+		hns3_info(hw, "RSS tuple fields changed from 0x%" PRIx64 " to 0x%" PRIx64,
+			  old_tuple_fields, new_tuple_fields);
 
 	return 0;
 }
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 09/11] net/hns3: make code more clean
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (7 preceding siblings ...)
  2023-06-02 11:42   ` [PATCH v2 08/11] net/hns3: fix uninitialized variable Dongdong Liu
@ 2023-06-02 11:42   ` Dongdong Liu
  2023-06-02 11:42   ` [PATCH v2 10/11] net/hns3: fix inaccurate log Dongdong Liu
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:42 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

This patch modify the code that violates the coding standards.

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_regs.c |  3 +--
 drivers/net/hns3/hns3_rxtx.c | 10 +++-------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 5d6f92e4bb..be1be6a89c 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -385,10 +385,9 @@ hns3_dfx_reg_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc,
 	hns3_cmd_setup_basic_desc(&desc[i], opcode, true);
 
 	ret = hns3_cmd_send(hw, desc, bd_num);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "fail to query dfx registers, opcode = 0x%04X, "
 			 "ret = %d.\n", opcode, ret);
-	}
 
 	return ret;
 }
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 2493748683..cf04dc857e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -751,7 +751,7 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw)
 		for (i = 0; i < hw->cfg_max_queues; i++) {
 			ret = hns3pf_reset_tqp(hw, i);
 			if (ret) {
-				hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.",
+				hns3_err(hw, "fail to reset tqp, queue_id = %u, ret = %d.",
 					 i, ret);
 				return ret;
 			}
@@ -829,15 +829,13 @@ hns3_send_reset_queue_cmd(struct hns3_hw *hw, uint16_t queue_id,
 {
 	struct hns3_reset_tqp_queue_cmd *req;
 	struct hns3_cmd_desc desc;
-	int queue_direction;
 	int ret;
 
 	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RESET_TQP_QUEUE_INDEP, false);
 
 	req = (struct hns3_reset_tqp_queue_cmd *)desc.data;
 	req->tqp_id = rte_cpu_to_le_16(queue_id);
-	queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
-	req->queue_direction = rte_cpu_to_le_16(queue_direction);
+	req->queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
 	hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0);
 
 	ret = hns3_cmd_send(hw, &desc, 1);
@@ -855,15 +853,13 @@ hns3_get_queue_reset_status(struct hns3_hw *hw, uint16_t queue_id,
 {
 	struct hns3_reset_tqp_queue_cmd *req;
 	struct hns3_cmd_desc desc;
-	int queue_direction;
 	int ret;
 
 	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RESET_TQP_QUEUE_INDEP, true);
 
 	req = (struct hns3_reset_tqp_queue_cmd *)desc.data;
 	req->tqp_id = rte_cpu_to_le_16(queue_id);
-	queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
-	req->queue_direction = rte_cpu_to_le_16(queue_direction);
+	req->queue_direction = queue_type == HNS3_RING_TYPE_TX ? 0 : 1;
 
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret) {
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 10/11] net/hns3: fix inaccurate log
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (8 preceding siblings ...)
  2023-06-02 11:42   ` [PATCH v2 09/11] net/hns3: make code more clean Dongdong Liu
@ 2023-06-02 11:42   ` 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
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:42 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

This patch fix inaccurate log

Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
Fixes: a951c1ed3ab5 ("net/hns3: support different numbers of Rx and Tx queues")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index cf04dc857e..f3c3b38c55 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -586,7 +586,7 @@ hns3_tqp_enable(struct hns3_hw *hw, uint16_t queue_id, bool enable)
 
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret)
-		hns3_err(hw, "TQP enable fail, ret = %d", ret);
+		hns3_err(hw, "TQP %s fail, ret = %d", enable ? "enable" : "disable", ret);
 
 	return ret;
 }
@@ -1635,7 +1635,7 @@ hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q,
 
 	ret = hns3_fake_tx_queue_config(hw, tx_need_add_nb_q);
 	if (ret) {
-		hns3_err(hw, "Fail to configure fake rx queues: %d", ret);
+		hns3_err(hw, "Fail to configure fake tx queues: %d", ret);
 		goto cfg_fake_tx_q_fail;
 	}
 
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2 11/11] net/hns3: remove log redundant line break
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (9 preceding siblings ...)
  2023-06-02 11:42   ` [PATCH v2 10/11] net/hns3: fix inaccurate log Dongdong Liu
@ 2023-06-02 11:42   ` Dongdong Liu
  2023-06-02 13:51   ` [PATCH v2 00/11] net/hns3: add some bugfixes for hns3 Ferruh Yigit
  11 siblings, 0 replies; 28+ messages in thread
From: Dongdong Liu @ 2023-06-02 11:42 UTC (permalink / raw)
  To: dev, ferruh.yigit, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, liudongdong3, yisen.zhuang, huangdengdui

From: Dengdui Huang <huangdengdui@huawei.com>

This patch remove log redundant line break

Fixes: d51867db65c1 ("net/hns3: add initialization")
Fixes: c6332c3cf9f0 ("net/hns3: support module EEPROM dump")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 64028778d0..dccd1d416f 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -3631,7 +3631,7 @@ hns3_get_mac_ethertype_cmd_status(uint16_t cmdq_resp, uint8_t resp_code)
 
 	if (cmdq_resp) {
 		PMD_INIT_LOG(ERR,
-			     "cmdq execute failed for get_mac_ethertype_cmd_status, status=%u.\n",
+			     "cmdq execute failed for get_mac_ethertype_cmd_status, status=%u.",
 			     cmdq_resp);
 		return -EIO;
 	}
@@ -6235,7 +6235,7 @@ hns3_optical_module_existed(struct hns3_hw *hw)
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret) {
 		hns3_err(hw,
-			 "fail to get optical module exist state, ret = %d.\n",
+			 "fail to get optical module exist state, ret = %d.",
 			 ret);
 		return false;
 	}
@@ -6273,7 +6273,7 @@ hns3_get_module_eeprom_data(struct hns3_hw *hw, uint32_t offset,
 
 	ret = hns3_cmd_send(hw, desc, HNS3_SFP_INFO_CMD_NUM);
 	if (ret) {
-		hns3_err(hw, "fail to get module EEPROM info, ret = %d.\n",
+		hns3_err(hw, "fail to get module EEPROM info, ret = %d.",
 				ret);
 		return ret;
 	}
@@ -6310,7 +6310,7 @@ hns3_get_module_eeprom(struct rte_eth_dev *dev,
 		return -ENOTSUP;
 
 	if (!hns3_optical_module_existed(hw)) {
-		hns3_err(hw, "fail to read module EEPROM: no module is connected.\n");
+		hns3_err(hw, "fail to read module EEPROM: no module is connected.");
 		return -EIO;
 	}
 
@@ -6373,7 +6373,7 @@ hns3_get_module_info(struct rte_eth_dev *dev,
 		modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8636_MAX_LEN;
 		break;
 	default:
-		hns3_err(hw, "unknown module, type = %u, extra_type = %u.\n",
+		hns3_err(hw, "unknown module, type = %u, extra_type = %u.",
 			 sfp_type.type, sfp_type.ext_type);
 		return -EINVAL;
 	}
-- 
2.22.0


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2 00/11] net/hns3: add some bugfixes for hns3
  2023-06-02 11:41 ` [PATCH v2 " Dongdong Liu
                     ` (10 preceding siblings ...)
  2023-06-02 11:42   ` [PATCH v2 11/11] net/hns3: remove log redundant line break Dongdong Liu
@ 2023-06-02 13:51   ` Ferruh Yigit
  11 siblings, 0 replies; 28+ messages in thread
From: Ferruh Yigit @ 2023-06-02 13:51 UTC (permalink / raw)
  To: Dongdong Liu, dev, thomas, andrew.rybchenko, fengchengwen
  Cc: stable, lihuisong, yisen.zhuang, huangdengdui

On 6/2/2023 12:41 PM, Dongdong Liu wrote:
> This patchset contains some bugfixes for hns3 pmd.
> 
> v1->v2:
> - Fix the comments for [PATCH 01/11] suggested by Ferruh.
> 
> Chengwen Feng (3):
>   net/hns3: fix mbuf leak when start rxq in resetting
>   net/hns3: fix mbuf leak when start rxq after resetting
>   net/hns3: fix no errcode returned when failed to init queue
> 
> Dengdui Huang (3):
>   net/hns3: make code more clean
>   net/hns3: fix inaccurate log
>   net/hns3: remove log redundant line break
> 
> Huisong Li (4):
>   net/hns3: fix uninitialized RTC time
>   net/hns3: fix unenabled RTC time after reset
>   net/hns3: add the uninitialization process of PTP
>   net/hns3: extract a PTP header file
> 
> Jie Hai (1):
>   net/hns3: fix uninitialized variable
>

Series applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2023-06-02 13:51 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 04/11] net/hns3: extract a PTP header file Dongdong Liu
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

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).