All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] bugfix for hns3 PMD
@ 2022-05-19 12:29 Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 01/12] net/hns3: fix spelling errors Min Hu (Connor)
                   ` (13 more replies)
  0 siblings, 14 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

This patch set contains 12 bugfix for hns3 PMD.

Chengwen Feng (1):
  net/hns3: fix TM capability incorrectly defined

Huisong Li (10):
  net/hns3: fix spelling errors
  net/hns3: add check for deferred start queue when rollback
  net/hns3: remove redundant parentheses
  net/hns3: adjust the data type of some variables
  net/hns3: fix an unreasonable memset
  net/hns3: remove duplicate definition
  net/hns3: fix return value for unsupported tuple
  net/hns3: modify a function name
  net/hns3: unify the code wrap style
  net/hns3: fix a segfault from secondary process

Min Hu (Connor) (1):
  net/hns3: fix coverity codecheck

 drivers/net/hns3/hns3_cmd.c       |  6 +--
 drivers/net/hns3/hns3_cmd.h       |  2 +-
 drivers/net/hns3/hns3_common.c    | 14 +++----
 drivers/net/hns3/hns3_dcb.c       |  7 ++--
 drivers/net/hns3/hns3_ethdev.c    | 20 +++++-----
 drivers/net/hns3/hns3_ethdev_vf.c | 23 ++++++------
 drivers/net/hns3/hns3_fdir.c      | 30 +++++++--------
 drivers/net/hns3/hns3_fdir.h      |  2 +-
 drivers/net/hns3/hns3_flow.c      | 25 ++++---------
 drivers/net/hns3/hns3_ptp.c       |  2 +-
 drivers/net/hns3/hns3_regs.c      |  2 +-
 drivers/net/hns3/hns3_rss.c       |  8 ++--
 drivers/net/hns3/hns3_rss.h       |  2 +
 drivers/net/hns3/hns3_rxtx.c      | 62 ++++++++++++++++---------------
 drivers/net/hns3/hns3_rxtx_vec.h  |  4 +-
 drivers/net/hns3/hns3_stats.c     | 28 +++++++-------
 16 files changed, 113 insertions(+), 124 deletions(-)

-- 
2.33.0


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

* [PATCH 01/12] net/hns3: fix spelling errors
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 02/12] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

This patch fix spelling errors.

Fixes: 70791213242e ("net/hns3: support masking device capability")
Fixes: 2192c428f9a6 ("net/hns3: fix firmware compatibility configuration")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c
index 96f8f38cbb..5dc874fd7a 100644
--- a/drivers/net/hns3/hns3_cmd.c
+++ b/drivers/net/hns3/hns3_cmd.c
@@ -462,7 +462,7 @@ hns3_mask_capability(struct hns3_hw *hw,
 	for (i = 0; i < MAX_CAPS_BIT; i++) {
 		if (!(caps_masked & BIT_ULL(i)))
 			continue;
-		hns3_info(hw, "mask capabiliy: id-%u, name-%s.",
+		hns3_info(hw, "mask capability: id-%u, name-%s.",
 			  i, hns3_get_caps_name(i));
 	}
 }
@@ -732,7 +732,7 @@ hns3_cmd_init(struct hns3_hw *hw)
 		return 0;
 
 	/*
-	 * Requiring firmware to enable some features, firber port can still
+	 * Requiring firmware to enable some features, fiber port can still
 	 * work without it, but copper port can't work because the firmware
 	 * fails to take over the PHY.
 	 */
-- 
2.33.0


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

* [PATCH 02/12] net/hns3: add check for deferred start queue when rollback
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 01/12] net/hns3: fix spelling errors Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 03/12] net/hns3: remove redundant parentheses Min Hu (Connor)
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

Driver doesn't allocate mbufs for the deferred start queues, so no need to
free it when rollback.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index d3fa4889d2..a9b997d32e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1202,6 +1202,9 @@ hns3_init_rx_queues(struct hns3_adapter *hns)
 out:
 	for (j = 0; j < i; j++) {
 		rxq = (struct hns3_rx_queue *)hw->data->rx_queues[j];
+		if (rxq->rx_deferred_start)
+			continue;
+
 		hns3_rx_queue_release_mbufs(rxq);
 	}
 
-- 
2.33.0


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

* [PATCH 03/12] net/hns3: remove redundant parentheses
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 01/12] net/hns3: fix spelling errors Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 02/12] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 04/12] net/hns3: adjust the data type of some variables Min Hu (Connor)
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

Remove redundant parentheses.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@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 a9b997d32e..ee0aaaf7fc 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -170,7 +170,7 @@ hns3_fake_rx_queue_release(struct hns3_rx_queue *queue)
 	}
 
 	/* free fake rx queue arrays */
-	if (idx == (hw->fkq_data.nb_fake_rx_queues - 1)) {
+	if (idx == hw->fkq_data.nb_fake_rx_queues - 1) {
 		hw->fkq_data.nb_fake_rx_queues = 0;
 		rte_free(hw->fkq_data.rx_queues);
 		hw->fkq_data.rx_queues = NULL;
@@ -197,7 +197,7 @@ hns3_fake_tx_queue_release(struct hns3_tx_queue *queue)
 	}
 
 	/* free fake tx queue arrays */
-	if (idx == (hw->fkq_data.nb_fake_tx_queues - 1)) {
+	if (idx == hw->fkq_data.nb_fake_tx_queues - 1) {
 		hw->fkq_data.nb_fake_tx_queues = 0;
 		rte_free(hw->fkq_data.tx_queues);
 		hw->fkq_data.tx_queues = NULL;
-- 
2.33.0


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

* [PATCH 04/12] net/hns3: adjust the data type of some variables
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (2 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 03/12] net/hns3: remove redundant parentheses Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 05/12] net/hns3: fix an unreasonable memset Min Hu (Connor)
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

Using the 'int' type and 'uint16_t' type to compare is insecure. This patch
makes them consistent.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_common.c   |  4 ++--
 drivers/net/hns3/hns3_dcb.c      |  2 +-
 drivers/net/hns3/hns3_ethdev.c   |  2 +-
 drivers/net/hns3/hns3_regs.c     |  2 +-
 drivers/net/hns3/hns3_rss.c      |  2 +-
 drivers/net/hns3/hns3_rxtx.c     | 23 ++++++++++++-----------
 drivers/net/hns3/hns3_rxtx_vec.h |  4 ++--
 7 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
index 9c86c00a04..edd16d8076 100644
--- a/drivers/net/hns3/hns3_common.c
+++ b/drivers/net/hns3/hns3_common.c
@@ -475,7 +475,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del)
 	struct rte_ether_addr *addr;
 	uint16_t mac_addrs_capa;
 	int ret = 0;
-	int i;
+	uint16_t i;
 
 	mac_addrs_capa =
 		hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM;
@@ -645,8 +645,8 @@ int
 hns3_init_ring_with_vector(struct hns3_hw *hw)
 {
 	uint16_t vec;
+	uint16_t i;
 	int ret;
-	int i;
 
 	/*
 	 * In hns3 network engine, vector 0 is always the misc interrupt of this
diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 136ada626b..d88757611c 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -628,7 +628,7 @@ hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q)
 	struct hns3_rss_conf *rss_cfg = &hw->rss_info;
 	uint16_t rx_qnum_per_tc;
 	uint16_t used_rx_queues;
-	int i;
+	uint16_t i;
 
 	rx_qnum_per_tc = nb_rx_q / hw->num_tc;
 	if (rx_qnum_per_tc > hw->rss_size_max) {
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 29c9f96c05..97cf27d2a1 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2929,8 +2929,8 @@ hns3_map_tqps_to_func(struct hns3_hw *hw, uint16_t func_id, uint16_t tqp_pid,
 static int
 hns3_map_tqp(struct hns3_hw *hw)
 {
+	uint16_t i;
 	int ret;
-	int i;
 
 	/*
 	 * In current version, VF is not supported when PF is driven by DPDK
diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 86a4cf74d5..6778e4cfc2 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -294,8 +294,8 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data)
 	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
 	uint32_t *origin_data_ptr = data;
 	uint32_t reg_offset;
+	uint16_t i, j;
 	int reg_num;
-	int i, j;
 
 	/* fetching per-PF registers values from PF PCIe register space */
 	reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t);
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index d376486a1d..4c546c9363 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -631,7 +631,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw)
 {
 	struct hns3_rss_conf *rss_cfg = &hw->rss_info;
 	uint16_t queue_num = hw->alloc_rss_size;
-	int i;
+	uint16_t i;
 
 	/* Default hash algorithm */
 	rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index ee0aaaf7fc..510802be05 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -390,7 +390,7 @@ hns3_enable_all_queues(struct hns3_hw *hw, bool en)
 	struct hns3_tx_queue *txq;
 	uint32_t rcb_reg;
 	void *tqp_base;
-	int i;
+	uint16_t i;
 
 	for (i = 0; i < hw->cfg_max_queues; i++) {
 		if (hns3_dev_get_support(hw, INDEP_TXRX)) {
@@ -736,8 +736,8 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw)
 #define HNS3_RESET_RCB_NOT_SUPPORT	0U
 #define HNS3_RESET_ALL_TQP_SUCCESS	1U
 	uint8_t reset_status;
+	uint16_t i;
 	int ret;
-	int i;
 
 	ret = hns3_reset_rcb_cmd(hw, &reset_status);
 	if (ret)
@@ -774,7 +774,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
 	uint8_t reset_status;
 	uint8_t msg_data[2];
 	int ret;
-	int i;
+	uint16_t i;
 
 	memset(msg_data, 0, sizeof(uint16_t));
 	ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
@@ -806,7 +806,8 @@ int
 hns3_reset_all_tqps(struct hns3_adapter *hns)
 {
 	struct hns3_hw *hw = &hns->hw;
-	int ret, i;
+	uint16_t i;
+	int ret;
 
 	/* Disable all queues before reset all queues */
 	for (i = 0; i < hw->cfg_max_queues; i++) {
@@ -1037,7 +1038,7 @@ hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
 	uint16_t nb_rx_q = hw->data->nb_rx_queues;
-	int i;
+	uint16_t i;
 
 	if (dev->data->dev_conf.intr_conf.rxq == 0)
 		return;
@@ -1121,7 +1122,7 @@ static void
 hns3_init_txq(struct hns3_tx_queue *txq)
 {
 	struct hns3_desc *desc;
-	int i;
+	uint16_t i;
 
 	/* Clear tx bd */
 	desc = txq->tx_ring;
@@ -1145,7 +1146,7 @@ hns3_init_tx_ring_tc(struct hns3_adapter *hns)
 
 	for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
 		struct hns3_tc_queue_info *tc_queue = &hw->tc_queue[i];
-		int j;
+		uint16_t j;
 
 		if (!tc_queue->enable)
 			continue;
@@ -1442,7 +1443,7 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev,
 	struct hns3_tx_queue *txq;
 	struct hns3_desc *desc;
 	unsigned int tx_desc;
-	int i;
+	uint16_t i;
 
 	txq = rte_zmalloc_socket(q_info->type, sizeof(struct hns3_tx_queue),
 				 RTE_CACHE_LINE_SIZE, q_info->socket_id);
@@ -1679,7 +1680,7 @@ hns3_dev_release_mbufs(struct hns3_adapter *hns)
 	struct rte_eth_dev_data *dev_data = hns->hw.data;
 	struct hns3_rx_queue *rxq;
 	struct hns3_tx_queue *txq;
-	int i;
+	uint16_t i;
 
 	if (dev_data->rx_queues)
 		for (i = 0; i < dev_data->nb_rx_queues; i++) {
@@ -3086,7 +3087,7 @@ hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq)
 	uint16_t tx_next_use = txq->next_to_use;
 	struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean];
 	struct hns3_desc *desc = &txq->tx_ring[tx_next_clean];
-	int i;
+	uint16_t i;
 
 	if (tx_next_use >= tx_next_clean &&
 	    tx_next_use < tx_next_clean + txq->tx_rs_thresh)
@@ -3984,7 +3985,7 @@ hns3_tx_free_buffer_simple(struct hns3_tx_queue *txq)
 	struct hns3_entry *tx_entry;
 	struct hns3_desc *desc;
 	uint16_t tx_next_clean;
-	int i;
+	uint16_t i;
 
 	while (1) {
 		if (HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) < txq->tx_rs_thresh)
diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h
index 4985a7cae8..d13f18627d 100644
--- a/drivers/net/hns3/hns3_rxtx_vec.h
+++ b/drivers/net/hns3/hns3_rxtx_vec.h
@@ -15,7 +15,7 @@ hns3_tx_bulk_free_buffers(struct hns3_tx_queue *txq)
 	struct hns3_entry *tx_entry;
 	struct rte_mbuf *m;
 	int nb_free = 0;
-	int i;
+	uint16_t i;
 
 	tx_entry = &txq->sw_ring[txq->next_to_clean];
 	if (txq->mbuf_fast_free_en) {
@@ -56,7 +56,7 @@ static inline void
 hns3_tx_free_buffers(struct hns3_tx_queue *txq)
 {
 	struct hns3_desc *tx_desc;
-	int i;
+	uint16_t i;
 
 	/*
 	 * All mbufs can be released only when the VLD bits of all
-- 
2.33.0


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

* [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (3 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 04/12] net/hns3: adjust the data type of some variables Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-20  7:58   ` Andrew Rybchenko
  2022-05-19 12:29 ` [PATCH 06/12] net/hns3: remove duplicate definition Min Hu (Connor)
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

This patch fixes an unreasonable memset.

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

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 510802be05..5a2cfe5a54 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
 	int ret;
 	uint16_t i;
 
-	memset(msg_data, 0, sizeof(uint16_t));
+	memset(msg_data, 0, sizeof(msg_data));
 	ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
 				sizeof(msg_data), true, &reset_status,
 				sizeof(reset_status));
-- 
2.33.0


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

* [PATCH 06/12] net/hns3: remove duplicate definition
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (4 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 05/12] net/hns3: fix an unreasonable memset Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 07/12] net/hns3: fix coverity codecheck Min Hu (Connor)
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

The default hash key array is defined twice. Let's remove the extra one.

Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 9 ---------
 drivers/net/hns3/hns3_rss.c  | 6 ++----
 drivers/net/hns3/hns3_rss.h  | 2 ++
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 12afc24910..e994cac314 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -10,15 +10,6 @@
 #include "hns3_logs.h"
 #include "hns3_flow.h"
 
-/* Default default keys */
-static uint8_t hns3_hash_key[] = {
-	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
-	0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
-	0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
-	0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
-	0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA
-};
-
 static const uint8_t full_mask[VNI_OR_TNI_LEN] = { 0xFF, 0xFF, 0xFF };
 static const uint8_t zero_mask[VNI_OR_TNI_LEN] = { 0x00, 0x00, 0x00 };
 
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 4c546c9363..1003daf03e 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -9,10 +9,8 @@
 #include "hns3_ethdev.h"
 #include "hns3_logs.h"
 
-/*
- * The hash key used for rss initialization.
- */
-static const uint8_t hns3_hash_key[] = {
+/* Default hash keys */
+const uint8_t hns3_hash_key[] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
 	0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
 	0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 7789f02a08..5b90d3a628 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -88,6 +88,8 @@ static inline uint32_t roundup_pow_of_two(uint32_t x)
 	return 1UL << fls(x - 1);
 }
 
+extern const uint8_t hns3_hash_key[];
+
 struct hns3_adapter;
 
 int hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
-- 
2.33.0


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

* [PATCH 07/12] net/hns3: fix coverity codecheck
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (5 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 06/12] net/hns3: remove duplicate definition Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 08/12] net/hns3: fix return value for unsupported tuple Min Hu (Connor)
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

In bitwise operation, "val" should be an unsigned type. This patch
fixed it.

Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index 1442241a4e..0b0061bba5 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -81,7 +81,7 @@ hns3_timesync_configure(struct hns3_adapter *hns, bool en)
 	struct hns3_hw *hw = &hns->hw;
 	struct hns3_pf *pf = &hns->pf;
 	struct hns3_cmd_desc desc;
-	int val;
+	uint32_t val;
 	int ret;
 
 	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false);
-- 
2.33.0


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

* [PATCH 08/12] net/hns3: fix return value for unsupported tuple
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (6 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 07/12] net/hns3: fix coverity codecheck Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 09/12] net/hns3: modify a function name Min Hu (Connor)
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

Driver should return false for unsupported tuple. This patch fixes it.

Fixes: 18a4b4c3fa80 ("net/hns3: add default to switch when parsing fd tuple")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 2a7978ac07..a0d6598e57 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -631,7 +631,7 @@ static bool hns3_fd_convert_tuple(struct hns3_hw *hw,
 		break;
 	default:
 		hns3_warn(hw, "not support tuple of (%u)", tuple);
-		break;
+		return false;
 	}
 	return true;
 }
-- 
2.33.0


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

* [PATCH 09/12] net/hns3: modify a function name
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (7 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 08/12] net/hns3: fix return value for unsupported tuple Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 10/12] net/hns3: unify the code wrap style Min Hu (Connor)
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

The meaning of the "hns3_get_count" function is not precise enough. This
patch changes from "hns3_get_count" to "hns3_fd_get_count".

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_fdir.c | 2 +-
 drivers/net/hns3/hns3_fdir.h | 2 +-
 drivers/net/hns3/hns3_flow.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index a0d6598e57..762b89a51e 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -1099,7 +1099,7 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns)
 	return 0;
 }
 
-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value)
+int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value)
 {
 	struct hns3_fd_get_cnt_cmd *req;
 	struct hns3_cmd_desc desc;
diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h
index 3376c40c8e..4d18759160 100644
--- a/drivers/net/hns3/hns3_fdir.h
+++ b/drivers/net/hns3/hns3_fdir.h
@@ -184,7 +184,7 @@ void hns3_fdir_filter_uninit(struct hns3_adapter *hns);
 int hns3_fdir_filter_program(struct hns3_adapter *hns,
 			     struct hns3_fdir_rule *rule, bool del);
 int hns3_clear_all_fdir_filter(struct hns3_adapter *hns);
-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
+int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
 int hns3_restore_all_fdir_filter(struct hns3_adapter *hns);
 
 #endif /* _HNS3_FDIR_H_ */
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index e994cac314..b60ad596dc 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -164,13 +164,13 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t indirect, uint32_t id,
 				"Counter id is used, indirect flag not match");
 		/* Clear the indirect counter on first use. */
 		if (cnt->indirect && cnt->ref_cnt == 1)
-			(void)hns3_get_count(hw, id, &value);
+			(void)hns3_fd_get_count(hw, id, &value);
 		cnt->ref_cnt++;
 		return 0;
 	}
 
 	/* Clear the counter by read ops because the counter is read-clear */
-	ret = hns3_get_count(hw, id, &value);
+	ret = hns3_fd_get_count(hw, id, &value);
 	if (ret)
 		return rte_flow_error_set(error, EIO,
 					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -210,7 +210,7 @@ hns3_counter_query(struct rte_eth_dev *dev, struct rte_flow *flow,
 					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 					  "Can't find counter id");
 
-	ret = hns3_get_count(&hns->hw, flow->counter_id, &value);
+	ret = hns3_fd_get_count(&hns->hw, flow->counter_id, &value);
 	if (ret) {
 		rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE,
 				   NULL, "Read counter fail.");
-- 
2.33.0


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

* [PATCH 10/12] net/hns3: unify the code wrap style
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (8 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 09/12] net/hns3: modify a function name Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 11/12] net/hns3: fix a segfault from secondary process Min Hu (Connor)
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

This patch unifies the code wrap style.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_cmd.c       |  2 +-
 drivers/net/hns3/hns3_common.c    | 10 +++++-----
 drivers/net/hns3/hns3_dcb.c       |  5 ++---
 drivers/net/hns3/hns3_ethdev.c    | 18 ++++++++----------
 drivers/net/hns3/hns3_ethdev_vf.c | 23 +++++++++++------------
 drivers/net/hns3/hns3_fdir.c      | 26 +++++++++++++-------------
 drivers/net/hns3/hns3_flow.c      | 10 ++++------
 drivers/net/hns3/hns3_rxtx.c      | 28 +++++++++++++---------------
 drivers/net/hns3/hns3_stats.c     | 28 ++++++++++++++--------------
 9 files changed, 71 insertions(+), 79 deletions(-)

diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c
index 5dc874fd7a..eadc15093f 100644
--- a/drivers/net/hns3/hns3_cmd.c
+++ b/drivers/net/hns3/hns3_cmd.c
@@ -108,7 +108,7 @@ hns3_alloc_cmd_queue(struct hns3_hw *hw, int ring_type)
 	ret = hns3_alloc_cmd_desc(hw, ring);
 	if (ret)
 		hns3_err(hw, "descriptor %s alloc error %d",
-			    (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret);
+			 (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret);
 
 	return ret;
 }
diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
index edd16d8076..7a65db907e 100644
--- a/drivers/net/hns3/hns3_common.c
+++ b/drivers/net/hns3/hns3_common.c
@@ -604,7 +604,7 @@ hns3_init_mac_addrs(struct rte_eth_dev *dev)
 				0);
 	if (dev->data->mac_addrs == NULL) {
 		hns3_err(hw, "failed to allocate %zx bytes needed to store MAC addresses",
-			     sizeof(struct rte_ether_addr) * mac_addrs_capa);
+			 sizeof(struct rte_ether_addr) * mac_addrs_capa);
 		return -ENOMEM;
 	}
 
@@ -680,16 +680,16 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)
 		ret = hw->ops.bind_ring_with_vector(hw, vec, false,
 						    HNS3_RING_TYPE_TX, i);
 		if (ret) {
-			PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with "
-					  "vector: %u, ret=%d", i, vec, ret);
+			PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d",
+				     i, vec, ret);
 			return ret;
 		}
 
 		ret = hw->ops.bind_ring_with_vector(hw, vec, false,
 						    HNS3_RING_TYPE_RX, i);
 		if (ret) {
-			PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with "
-					  "vector: %u, ret=%d", i, vec, ret);
+			PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with vector: %u, ret=%d",
+				     i, vec, ret);
 			return ret;
 		}
 	}
diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index d88757611c..b22f618e0a 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -876,9 +876,8 @@ hns3_dcb_pri_tc_base_dwrr_cfg(struct hns3_hw *hw)
 
 		ret = hns3_dcb_pri_weight_cfg(hw, i, dwrr);
 		if (ret) {
-			hns3_err(hw,
-			       "fail to send priority weight cmd: %d, ret = %d",
-			       i, ret);
+			hns3_err(hw, "fail to send priority weight cmd: %d, ret = %d",
+				 i, ret);
 			return ret;
 		}
 
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 97cf27d2a1..8a8f3f1950 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -1627,7 +1627,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	ret = hw->ops.del_uc_mac_addr(hw, oaddr);
 	if (ret) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      oaddr);
+				       oaddr);
 		hns3_warn(hw, "Remove old uc mac address(%s) fail: %d",
 			  mac_str, ret);
 
@@ -1659,7 +1659,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	ret_val = hw->ops.del_uc_mac_addr(hw, mac_addr);
 	if (ret_val) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_warn(hw,
 			  "Failed to roll back to del setted mac addr(%s): %d",
 			  mac_str, ret_val);
@@ -1670,7 +1670,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	if (ret_val) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr);
 		hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d",
-				  mac_str, ret_val);
+			  mac_str, ret_val);
 	}
 	rte_spinlock_unlock(&hw->lock);
 
@@ -1747,7 +1747,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 		if (ret == -ENOSPC)
 			hns3_err(hw, "mc mac vlan table is full");
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret);
 	}
 
@@ -2676,9 +2676,8 @@ hns3_check_dev_specifications(struct hns3_hw *hw)
 {
 	if (hw->rss_ind_tbl_size == 0 ||
 	    hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) {
-		hns3_err(hw, "the size of hash lookup table configured (%u)"
-			      " exceeds the maximum(%u)", hw->rss_ind_tbl_size,
-			      HNS3_RSS_IND_TBL_SIZE_MAX);
+		hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)",
+			 hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX);
 		return -EINVAL;
 	}
 
@@ -3916,7 +3915,7 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev)
 		ret = hns3_enable_vlan_filter(hns, false);
 		if (ret) {
 			hns3_err(hw, "failed to enable promiscuous mode due to "
-				     "failure to disable vlan filter, ret = %d",
+				 "failure to disable vlan filter, ret = %d",
 				 ret);
 			err = hns3_set_promisc_mode(hw, false, allmulti);
 			if (err)
@@ -5993,8 +5992,7 @@ hns3_reset_service(void *param)
 		timersub(&tv, &tv_start, &tv_delta);
 		msec = hns3_clock_calctime_ms(&tv_delta);
 		if (msec > HNS3_RESET_PROCESS_MS)
-			hns3_err(hw, "%d handle long time delta %" PRIu64
-				     " ms time=%ld.%.6ld",
+			hns3_err(hw, "%d handle long time delta %" PRIu64 " ms time=%ld.%.6ld",
 				 hw->reset.level, msec,
 				 tv.tv_sec, tv.tv_usec);
 		if (ret == -EAGAIN)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 0c170797f4..7da6e21b0f 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -142,7 +142,7 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op)
 	pos = hns3vf_find_pci_capability(device, PCI_CAP_ID_MSIX);
 	if (pos) {
 		ret = rte_pci_read_config(device, &control, sizeof(control),
-				    (pos + PCI_MSIX_FLAGS));
+					  (pos + PCI_MSIX_FLAGS));
 		if (ret < 0) {
 			PMD_INIT_LOG(ERR, "Failed to read PCI offset 0x%x",
 				     (pos + PCI_MSIX_FLAGS));
@@ -154,10 +154,10 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op)
 		else
 			control &= ~PCI_MSIX_FLAGS_ENABLE;
 		ret = rte_pci_write_config(device, &control, sizeof(control),
-					  (pos + PCI_MSIX_FLAGS));
+					   (pos + PCI_MSIX_FLAGS));
 		if (ret < 0) {
 			PMD_INIT_LOG(ERR, "failed to write PCI offset 0x%x",
-				    (pos + PCI_MSIX_FLAGS));
+				     (pos + PCI_MSIX_FLAGS));
 			return -ENXIO;
 		}
 
@@ -199,7 +199,7 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 				false, NULL, 0);
 	if (ret) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_err(hw, "failed to add uc mac addr(%s), ret = %d",
 			 mac_str, ret);
 	}
@@ -241,12 +241,12 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,
 		 */
 		if (ret == -EPERM) {
 			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-					      old_addr);
+					       old_addr);
 			hns3_warn(hw, "Has permanet mac addr(%s) for vf",
 				  mac_str);
 		} else {
 			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-					      mac_addr);
+					       mac_addr);
 			hns3_err(hw, "Failed to set mac addr(%s) for vf: %d",
 				 mac_str, ret);
 		}
@@ -293,7 +293,7 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,
 				NULL, 0);
 	if (ret) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
 	}
@@ -715,9 +715,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw)
 {
 	if (hw->rss_ind_tbl_size == 0 ||
 	    hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) {
-		hns3_warn(hw, "the size of hash lookup table configured (%u)"
-			      " exceeds the maximum(%u)", hw->rss_ind_tbl_size,
-			      HNS3_RSS_IND_TBL_SIZE_MAX);
+		hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)",
+			  hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX);
 		return -EINVAL;
 	}
 
@@ -1168,8 +1167,8 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	int ret = 0;
 
 	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
-		hns3_err(hw, "vf set vlan offload failed during resetting, "
-			     "mask = 0x%x", mask);
+		hns3_err(hw, "vf set vlan offload failed during resetting, mask = 0x%x",
+			 mask);
 		return -EIO;
 	}
 
diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 762b89a51e..30e5e66772 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -321,7 +321,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 		break;
 	default:
 		hns3_err(hw, "Unsupported flow director mode %u",
-			    pf->fdir.fd_cfg.fd_mode);
+			 pf->fdir.fd_cfg.fd_mode);
 		return -EOPNOTSUPP;
 	}
 
@@ -337,7 +337,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 	    BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) |
 	    BIT(INNER_SRC_PORT) | BIT(INNER_DST_PORT);
 	hns3_dbg(hw, "fdir tuple: inner<vlan_tag1 eth_type ip_src ip_dst "
-		  "ip_proto ip_tos l4_src_port l4_dst_port>");
+		 "ip_proto ip_tos l4_src_port l4_dst_port>");
 
 	/* If use max 400bit key, we can support tuples for ether type */
 	if (pf->fdir.fd_cfg.max_key_length == MAX_KEY_LENGTH) {
@@ -348,8 +348,8 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 		    BIT(OUTER_TUN_VNI) | BIT(OUTER_TUN_FLOW_ID) |
 		    BIT(OUTER_ETH_TYPE) | BIT(OUTER_IP_PROTO);
 		hns3_dbg(hw, "fdir tuple more: inner<dst_mac src_mac "
-			  "vlan_tag2 sctp_tag> outer<eth_type ip_proto "
-			  "l4_src_port l4_dst_port tun_vni tun_flow_id>");
+			 "vlan_tag2 sctp_tag> outer<eth_type ip_proto "
+			 "l4_src_port l4_dst_port tun_vni tun_flow_id>");
 	}
 
 	/* roce_type is used to filter roce frames
@@ -367,12 +367,11 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 	if (ret)
 		return ret;
 
-	hns3_dbg(hw, "fdir: stage1<rules-%u counters-%u> stage2<rules-%u "
-		  "counters=%u>",
-		  pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1],
-		  pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1],
-		  pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2],
-		  pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]);
+	hns3_dbg(hw, "fdir: stage1<rules-%u counters-%u> stage2<rules-%u counters=%u>",
+		 pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1],
+		 pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1],
+		 pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2],
+		 pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]);
 
 	return hns3_set_fd_key_config(hns);
 }
@@ -420,7 +419,7 @@ static int hns3_fd_tcam_config(struct hns3_hw *hw, bool sel_x, int loc,
 	ret = hns3_cmd_send(hw, desc, FD_TCAM_CMD_NUM);
 	if (ret)
 		hns3_err(hw, "Config tcam key fail, ret=%d loc=%d add=%d",
-			    ret, loc, is_add);
+			 ret, loc, is_add);
 	return ret;
 }
 
@@ -673,6 +672,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg,
 		} else if (i == VLAN_NUMBER) {
 			uint32_t vlan_tag;
 			uint8_t vlan_num;
+
 			if (rule->key_conf.spec.tunnel_type == 0)
 				vlan_num = rule->key_conf.vlan_num;
 			else
@@ -758,14 +758,14 @@ static int hns3_config_key(struct hns3_adapter *hns,
 	ret = hns3_fd_tcam_config(hw, false, rule->location, key_y, true);
 	if (ret) {
 		hns3_err(hw, "Config fd key_y fail, loc=%u, ret=%d",
-			    rule->queue_id, ret);
+			 rule->queue_id, ret);
 		return ret;
 	}
 
 	ret = hns3_fd_tcam_config(hw, true, rule->location, key_x, true);
 	if (ret)
 		hns3_err(hw, "Config fd key_x fail, loc=%u, ret=%d",
-			    rule->queue_id, ret);
+			 rule->queue_id, ret);
 	return ret;
 }
 
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index b60ad596dc..5e0a9bc93f 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -285,9 +285,8 @@ hns3_handle_action_queue(struct rte_eth_dev *dev,
 
 	queue = (const struct rte_flow_action_queue *)action->conf;
 	if (queue->index >= hw->data->nb_rx_queues) {
-		hns3_err(hw, "queue ID(%u) is greater than number of "
-			  "available queue (%u) in driver.",
-			  queue->index, hw->data->nb_rx_queues);
+		hns3_err(hw, "queue ID(%u) is greater than number of available queue (%u) in driver.",
+			 queue->index, hw->data->nb_rx_queues);
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  action, "Invalid queue ID in PF");
@@ -1656,9 +1655,8 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
 	}
 
 	if (rss_rule_fail_cnt) {
-		hns3_err(hw, "fail to delete all RSS filters, success num = %d "
-			     "fail num = %d", rss_rule_succ_cnt,
-			     rss_rule_fail_cnt);
+		hns3_err(hw, "fail to delete all RSS filters, success num = %d fail num = %d",
+			 rss_rule_succ_cnt, rss_rule_fail_cnt);
 		ret = -EIO;
 	}
 
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 5a2cfe5a54..3f576fbf4b 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -606,8 +606,8 @@ hns3_send_reset_tqp_cmd(struct hns3_hw *hw, uint16_t queue_id, bool enable)
 	hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0);
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret)
-		hns3_err(hw, "send tqp reset cmd error, queue_id = %u, "
-			     "ret = %d", queue_id, ret);
+		hns3_err(hw, "send tqp reset cmd error, queue_id = %u, ret = %d",
+			 queue_id, ret);
 
 	return ret;
 }
@@ -627,8 +627,8 @@ hns3_get_tqp_reset_status(struct hns3_hw *hw, uint16_t queue_id,
 
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret) {
-		hns3_err(hw, "get tqp reset status error, queue_id = %u, "
-			     "ret = %d.", queue_id, ret);
+		hns3_err(hw, "get tqp reset status error, queue_id = %u, ret = %d.",
+			 queue_id, ret);
 		return ret;
 	}
 	*reset_status = hns3_get_bit(req->ready_to_reset, HNS3_TQP_RESET_B);
@@ -669,7 +669,7 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id)
 	if (!reset_status) {
 		ret = -ETIMEDOUT;
 		hns3_err(hw, "reset tqp timeout, queue_id = %u, ret = %d",
-			     queue_id, ret);
+			 queue_id, ret);
 		goto tqp_reset_fail;
 	}
 
@@ -752,15 +752,14 @@ 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.",
-				  i, ret);
+				hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.",
+					 i, ret);
 				return ret;
 			}
 		}
 	} else if (reset_status != HNS3_RESET_ALL_TQP_SUCCESS) {
 		hns3_err(hw, "fail to reset all tqps, reset_status = %u.",
-				reset_status);
+			 reset_status);
 		return -EIO;
 	}
 
@@ -813,9 +812,8 @@ hns3_reset_all_tqps(struct hns3_adapter *hns)
 	for (i = 0; i < hw->cfg_max_queues; i++) {
 		ret = hns3_tqp_enable(hw, i, false);
 		if (ret) {
-			hns3_err(hw,
-			    "fail to disable tqps before tqps reset, ret = %d.",
-			    ret);
+			hns3_err(hw, "fail to disable tqps before tqps reset, ret = %d.",
+				 ret);
 			return ret;
 		}
 	}
@@ -922,9 +920,9 @@ hns3_reset_queue(struct hns3_hw *hw, uint16_t queue_id,
 	}
 
 	if (!reset_status) {
-		hns3_err(hw, "reset queue timeout, queue_id = %u, "
-			     "queue_type = %s", queue_id,
-			     queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx");
+		hns3_err(hw, "reset queue timeout, queue_id = %u, queue_type = %s",
+			 queue_id,
+			 queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx");
 		ret = -ETIMEDOUT;
 		goto queue_reset_fail;
 	}
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 9b7ad067aa..83725ecf20 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -507,8 +507,8 @@ hns3_update_port_rx_ssu_drop_stats(struct hns3_hw *hw)
 
 	req = (struct hns3_query_ssu_cmd *)desc[0].data;
 	cnt = rte_le_to_cpu_32(req->oq_drop_cnt) +
-		rte_le_to_cpu_32(req->full_drop_cnt) +
-		rte_le_to_cpu_32(req->part_drop_cnt);
+	      rte_le_to_cpu_32(req->full_drop_cnt) +
+	      rte_le_to_cpu_32(req->part_drop_cnt);
 
 	stats->ssu_rx_drop_cnt += cnt;
 
@@ -532,8 +532,8 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw)
 
 	req = (struct hns3_query_ssu_cmd *)desc[0].data;
 	cnt = rte_le_to_cpu_32(req->oq_drop_cnt) +
-		rte_le_to_cpu_32(req->full_drop_cnt) +
-		rte_le_to_cpu_32(req->part_drop_cnt);
+	      rte_le_to_cpu_32(req->full_drop_cnt) +
+	      rte_le_to_cpu_32(req->part_drop_cnt);
 
 	hw->oerror_stats += cnt;
 
@@ -1336,8 +1336,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 	len = cnt_stats * sizeof(struct rte_eth_xstat);
 	values_copy = rte_zmalloc("hns3_xstats_values", len, 0);
 	if (values_copy == NULL) {
-		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed "
-			     "to store statistics values", len);
+		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics values",
+			 len);
 		return -ENOMEM;
 	}
 
@@ -1358,8 +1358,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 
 	for (i = 0; i < size; i++) {
 		if (ids[i] >= cnt_stats) {
-			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, "
-				     "should < %u", i, ids[i], cnt_stats);
+			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u",
+				 i, ids[i], cnt_stats);
 			rte_free(values_copy);
 			return -EINVAL;
 		}
@@ -1418,8 +1418,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 	len = cnt_stats * sizeof(struct rte_eth_xstat_name);
 	names_copy = rte_zmalloc("hns3_xstats_names", len, 0);
 	if (names_copy == NULL) {
-		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed "
-			     "to store statistics names", len);
+		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics names",
+			 len);
 		return -ENOMEM;
 	}
 
@@ -1427,8 +1427,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 
 	for (i = 0; i < size; i++) {
 		if (ids[i] >= cnt_stats) {
-			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, "
-				     "should < %u", i, ids[i], cnt_stats);
+			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u",
+				 i, ids[i], cnt_stats);
 			rte_free(names_copy);
 			return -EINVAL;
 		}
@@ -1500,14 +1500,14 @@ hns3_tqp_stats_init(struct hns3_hw *hw)
 	struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
 
 	tqp_stats->rcb_rx_ring_pktnum = rte_zmalloc("hns3_rx_ring_pkt_num",
-					 sizeof(uint64_t) * hw->tqps_num, 0);
+					sizeof(uint64_t) * hw->tqps_num, 0);
 	if (tqp_stats->rcb_rx_ring_pktnum == NULL) {
 		hns3_err(hw, "failed to allocate rx_ring pkt_num.");
 		return -ENOMEM;
 	}
 
 	tqp_stats->rcb_tx_ring_pktnum = rte_zmalloc("hns3_tx_ring_pkt_num",
-					 sizeof(uint64_t) * hw->tqps_num, 0);
+					sizeof(uint64_t) * hw->tqps_num, 0);
 	if (tqp_stats->rcb_tx_ring_pktnum == NULL) {
 		hns3_err(hw, "failed to allocate tx_ring pkt_num.");
 		rte_free(tqp_stats->rcb_rx_ring_pktnum);
-- 
2.33.0


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

* [PATCH 11/12] net/hns3: fix a segfault from secondary process
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (9 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 10/12] net/hns3: unify the code wrap style Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-19 12:29 ` [PATCH 12/12] net/hns3: fix TM capability incorrectly defined Min Hu (Connor)
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Huisong Li <lihuisong@huawei.com>

If a hns3 device in the secondary process is attached to do probing
operation, 'rx_queues' and 'tx_queues' in dev->data are null in
eth_dev_fp_ops_setup when calling rte_eth_dev_probing_finish. The primary
process calls dev_start to re-setup their fp_ops. But the secondary process
can't call dev_start and has no chance to do it. If the application sends
and receives packets at this time, a segfault will occur. So this patch
uses the MP communication of the PMD to update the fp_ops of the device in
the secondary process.

Fixes: 9e311d8f93b9 ("net/hns3: fix Rx/Tx when fast path operation introduced")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 3f576fbf4b..0dc1d8cb60 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4420,6 +4420,8 @@ hns3_eth_dev_fp_ops_config(const struct rte_eth_dev *dev)
 	fpo[port_id].tx_pkt_prepare = dev->tx_pkt_prepare;
 	fpo[port_id].rx_descriptor_status = dev->rx_descriptor_status;
 	fpo[port_id].tx_descriptor_status = dev->tx_descriptor_status;
+	fpo[port_id].rxq.data = dev->data->rx_queues;
+	fpo[port_id].txq.data = dev->data->tx_queues;
 }
 
 void
-- 
2.33.0


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

* [PATCH 12/12] net/hns3: fix TM capability incorrectly defined
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (10 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 11/12] net/hns3: fix a segfault from secondary process Min Hu (Connor)
@ 2022-05-19 12:29 ` Min Hu (Connor)
  2022-05-31 14:55 ` [PATCH 00/12] bugfix for hns3 PMD Andrew Rybchenko
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
  13 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-19 12:29 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, thomas

From: Chengwen Feng <fengchengwen@huawei.com>

The TM capability should be bit-19 according to the user manual of
firmware. This patch fixes it.

Fixes: fc18d1b4b85f ("net/hns3: fix traffic management")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index f9addc6069..82c999061d 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -323,7 +323,7 @@ enum HNS3_CAPS_BITS {
 	HNS3_CAPS_UDP_TUNNEL_CSUM_B,
 	HNS3_CAPS_RAS_IMP_B,
 	HNS3_CAPS_RXD_ADV_LAYOUT_B = 15,
-	HNS3_CAPS_TM_B = 17,
+	HNS3_CAPS_TM_B = 19,
 };
 
 /* Capabilities of VF dependent on the PF */
-- 
2.33.0


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

* Re: [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-19 12:29 ` [PATCH 05/12] net/hns3: fix an unreasonable memset Min Hu (Connor)
@ 2022-05-20  7:58   ` Andrew Rybchenko
  2022-05-20  8:37     ` Min Hu (Connor)
  0 siblings, 1 reply; 38+ messages in thread
From: Andrew Rybchenko @ 2022-05-20  7:58 UTC (permalink / raw)
  To: Min Hu (Connor), dev; +Cc: ferruh.yigit, thomas

On 5/19/22 15:29, Min Hu (Connor) wrote:
> From: Huisong Li <lihuisong@huawei.com>
> 
> This patch fixes an unreasonable memset.
> 
> Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>   drivers/net/hns3/hns3_rxtx.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
> index 510802be05..5a2cfe5a54 100644
> --- a/drivers/net/hns3/hns3_rxtx.c
> +++ b/drivers/net/hns3/hns3_rxtx.c
> @@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
>   	int ret;
>   	uint16_t i;
>   
> -	memset(msg_data, 0, sizeof(uint16_t));
> +	memset(msg_data, 0, sizeof(msg_data));

It looks a bit suspicious. May be it is better to do:
     memset(&msg_data, 0, sizeof(msg_data));
It is pretty common mistake to do:
     memset(p, 0, sizeof(p));
instead of
     memset(p, 0, sizeof(*p));
when p is a pointer.
I realize that msg_data is an array in this case, but
I think it is better to avoid bad pattern in the code.

>   	ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
>   				sizeof(msg_data), true, &reset_status,
>   				sizeof(reset_status));


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

* Re: [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-20  7:58   ` Andrew Rybchenko
@ 2022-05-20  8:37     ` Min Hu (Connor)
  2022-05-20  8:59       ` Andrew Rybchenko
  0 siblings, 1 reply; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-20  8:37 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: ferruh.yigit, thomas

Hi, Andrew ,

在 2022/5/20 15:58, Andrew Rybchenko 写道:
> On 5/19/22 15:29, Min Hu (Connor) wrote:
>> From: Huisong Li <lihuisong@huawei.com>
>>
>> This patch fixes an unreasonable memset.
>>
>> Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   drivers/net/hns3/hns3_rxtx.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
>> index 510802be05..5a2cfe5a54 100644
>> --- a/drivers/net/hns3/hns3_rxtx.c
>> +++ b/drivers/net/hns3/hns3_rxtx.c
>> @@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
>>       int ret;
>>       uint16_t i;
>> -    memset(msg_data, 0, sizeof(uint16_t));
>> +    memset(msg_data, 0, sizeof(msg_data));
> 
> It looks a bit suspicious. May be it is better to do:
>      memset(&msg_data, 0, sizeof(msg_data));
I think this is too hard to understand for &msg_data is **p.
maybe it confuse others when use memset to operate level-2 pointer.


> It is pretty common mistake to do:
>      memset(p, 0, sizeof(p));
> instead of
>      memset(p, 0, sizeof(*p));
> when p is a pointer.
> I realize that msg_data is an array in this case, but
> I think it is better to avoid bad pattern in the code.
> 
>>       ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
>>                   sizeof(msg_data), true, &reset_status,
>>                   sizeof(reset_status));
> 
> .

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

* Re: [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-20  8:37     ` Min Hu (Connor)
@ 2022-05-20  8:59       ` Andrew Rybchenko
  2022-05-20  9:14         ` Min Hu (Connor)
  0 siblings, 1 reply; 38+ messages in thread
From: Andrew Rybchenko @ 2022-05-20  8:59 UTC (permalink / raw)
  To: Min Hu (Connor), dev; +Cc: ferruh.yigit, thomas

On 5/20/22 11:37, Min Hu (Connor) wrote:
> Hi, Andrew ,
> 
> 在 2022/5/20 15:58, Andrew Rybchenko 写道:
>> On 5/19/22 15:29, Min Hu (Connor) wrote:
>>> From: Huisong Li <lihuisong@huawei.com>
>>>
>>> This patch fixes an unreasonable memset.
>>>
>>> Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>> ---
>>>   drivers/net/hns3/hns3_rxtx.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
>>> index 510802be05..5a2cfe5a54 100644
>>> --- a/drivers/net/hns3/hns3_rxtx.c
>>> +++ b/drivers/net/hns3/hns3_rxtx.c
>>> @@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
>>>       int ret;
>>>       uint16_t i;
>>> -    memset(msg_data, 0, sizeof(uint16_t));
>>> +    memset(msg_data, 0, sizeof(msg_data));
>>
>> It looks a bit suspicious. May be it is better to do:
>>      memset(&msg_data, 0, sizeof(msg_data));
> I think this is too hard to understand for &msg_data is **p.
> maybe it confuse others when use memset to operate level-2 pointer.

msg_data == &amsg_data
since it is an array

> 
> 
>> It is pretty common mistake to do:
>>      memset(p, 0, sizeof(p));
>> instead of
>>      memset(p, 0, sizeof(*p));
>> when p is a pointer.
>> I realize that msg_data is an array in this case, but
>> I think it is better to avoid bad pattern in the code.
>>
>>>       ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
>>>                   sizeof(msg_data), true, &reset_status,
>>>                   sizeof(reset_status));
>>
>> .


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

* Re: [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-20  8:59       ` Andrew Rybchenko
@ 2022-05-20  9:14         ` Min Hu (Connor)
  2022-05-20 10:43           ` Ferruh Yigit
  0 siblings, 1 reply; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-20  9:14 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: ferruh.yigit, thomas

Hi,Andrew,

在 2022/5/20 16:59, Andrew Rybchenko 写道:
> On 5/20/22 11:37, Min Hu (Connor) wrote:
>> Hi, Andrew ,
>>
>> 在 2022/5/20 15:58, Andrew Rybchenko 写道:
>>> On 5/19/22 15:29, Min Hu (Connor) wrote:
>>>> From: Huisong Li <lihuisong@huawei.com>
>>>>
>>>> This patch fixes an unreasonable memset.
>>>>
>>>> Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
>>>> Cc: stable@dpdk.org
>>>>
>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>>> ---
>>>>   drivers/net/hns3/hns3_rxtx.c | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/net/hns3/hns3_rxtx.c 
>>>> b/drivers/net/hns3/hns3_rxtx.c
>>>> index 510802be05..5a2cfe5a54 100644
>>>> --- a/drivers/net/hns3/hns3_rxtx.c
>>>> +++ b/drivers/net/hns3/hns3_rxtx.c
>>>> @@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
>>>>       int ret;
>>>>       uint16_t i;
>>>> -    memset(msg_data, 0, sizeof(uint16_t));
>>>> +    memset(msg_data, 0, sizeof(msg_data));
>>>
>>> It looks a bit suspicious. May be it is better to do:
>>>      memset(&msg_data, 0, sizeof(msg_data));
>> I think this is too hard to understand for &msg_data is **p.
>> maybe it confuse others when use memset to operate level-2 pointer.
> 
> msg_data == &amsg_data
> since it is an array
Yes, you are right, the address of 'msg_data ' is the same
as the address of '&amsg_data'.

But I still think this usage is not common.
like the current code in DPDK:
*****
static int
app_parse_flow_conf(const char *conf_str)
{
	int ret;
	uint32_t vals[5];
	struct flow_conf *pconf;
	uint64_t mask;

	memset(vals, 0, sizeof(vals));
...
*****

how about others's opinion? @Ferruh, @Thomas.

> 
>>
>>
>>> It is pretty common mistake to do:
>>>      memset(p, 0, sizeof(p));
>>> instead of
>>>      memset(p, 0, sizeof(*p));
>>> when p is a pointer.
>>> I realize that msg_data is an array in this case, but
>>> I think it is better to avoid bad pattern in the code.
>>>
>>>>       ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
>>>>                   sizeof(msg_data), true, &reset_status,
>>>>                   sizeof(reset_status));
>>>
>>> .
> 
> .

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

* Re: [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-20  9:14         ` Min Hu (Connor)
@ 2022-05-20 10:43           ` Ferruh Yigit
  2022-05-20 11:00             ` Min Hu (Connor)
  0 siblings, 1 reply; 38+ messages in thread
From: Ferruh Yigit @ 2022-05-20 10:43 UTC (permalink / raw)
  To: Min Hu (Connor), Andrew Rybchenko, dev; +Cc: thomas

On 5/20/2022 10:14 AM, Min Hu (Connor) wrote:
> [CAUTION: External Email]
> 
> Hi,Andrew,
> 
> 在 2022/5/20 16:59, Andrew Rybchenko 写道:
>> On 5/20/22 11:37, Min Hu (Connor) wrote:
>>> Hi, Andrew ,
>>>
>>> 在 2022/5/20 15:58, Andrew Rybchenko 写道:
>>>> On 5/19/22 15:29, Min Hu (Connor) wrote:
>>>>> From: Huisong Li <lihuisong@huawei.com>
>>>>>
>>>>> This patch fixes an unreasonable memset.
>>>>>
>>>>> Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations")
>>>>> Cc: stable@dpdk.org
>>>>>
>>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>>>> ---
>>>>>   drivers/net/hns3/hns3_rxtx.c | 2 +-
>>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/net/hns3/hns3_rxtx.c
>>>>> b/drivers/net/hns3/hns3_rxtx.c
>>>>> index 510802be05..5a2cfe5a54 100644
>>>>> --- a/drivers/net/hns3/hns3_rxtx.c
>>>>> +++ b/drivers/net/hns3/hns3_rxtx.c
>>>>> @@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
>>>>>       int ret;
>>>>>       uint16_t i;
>>>>> -    memset(msg_data, 0, sizeof(uint16_t));
>>>>> +    memset(msg_data, 0, sizeof(msg_data));
>>>>
>>>> It looks a bit suspicious. May be it is better to do:
>>>>      memset(&msg_data, 0, sizeof(msg_data));
>>> I think this is too hard to understand for &msg_data is **p.
>>> maybe it confuse others when use memset to operate level-2 pointer.
>>
>> msg_data == &amsg_data
>> since it is an array
> Yes, you are right, the address of 'msg_data ' is the same
> as the address of '&amsg_data'.
> 
> But I still think this usage is not common.
> like the current code in DPDK:
> *****
> static int
> app_parse_flow_conf(const char *conf_str)
> {
>         int ret;
>         uint32_t vals[5];
>         struct flow_conf *pconf;
>         uint64_t mask;
> 
>         memset(vals, 0, sizeof(vals));
> ...
> *****
> 
> how about others's opinion? @Ferruh, @Thomas.
> 

I would use array without address operator, so original patch lgtm.

+1 to main purpose of the patch (to replace 'sizeof(uint16_t)').

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

* Re: [PATCH 05/12] net/hns3: fix an unreasonable memset
  2022-05-20 10:43           ` Ferruh Yigit
@ 2022-05-20 11:00             ` Min Hu (Connor)
  0 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-05-20 11:00 UTC (permalink / raw)
  To: Ferruh Yigit, Andrew Rybchenko, dev; +Cc: thomas

Hi,

在 2022/5/20 18:43, Ferruh Yigit 写道:
> On 5/20/2022 10:14 AM, Min Hu (Connor) wrote:
>> [CAUTION: External Email]
>>
>> Hi,Andrew,
>>
>> 在 2022/5/20 16:59, Andrew Rybchenko 写道:
>>> On 5/20/22 11:37, Min Hu (Connor) wrote:
>>>> Hi, Andrew ,
>>>>
>>>> 在 2022/5/20 15:58, Andrew Rybchenko 写道:
>>>>> On 5/19/22 15:29, Min Hu (Connor) wrote:
>>>>>> From: Huisong Li <lihuisong@huawei.com>
>>>>>>
>>>>>> This patch fixes an unreasonable memset.
>>>>>>
>>>>>> Fixes: bba636698316 ("net/hns3: support Rx/Tx and related 
>>>>>> operations")
>>>>>> Cc: stable@dpdk.org
>>>>>>
>>>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>>>>> ---
>>>>>>   drivers/net/hns3/hns3_rxtx.c | 2 +-
>>>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/net/hns3/hns3_rxtx.c
>>>>>> b/drivers/net/hns3/hns3_rxtx.c
>>>>>> index 510802be05..5a2cfe5a54 100644
>>>>>> --- a/drivers/net/hns3/hns3_rxtx.c
>>>>>> +++ b/drivers/net/hns3/hns3_rxtx.c
>>>>>> @@ -776,7 +776,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
>>>>>>       int ret;
>>>>>>       uint16_t i;
>>>>>> -    memset(msg_data, 0, sizeof(uint16_t));
>>>>>> +    memset(msg_data, 0, sizeof(msg_data));
>>>>>
>>>>> It looks a bit suspicious. May be it is better to do:
>>>>>      memset(&msg_data, 0, sizeof(msg_data));
>>>> I think this is too hard to understand for &msg_data is **p.
>>>> maybe it confuse others when use memset to operate level-2 pointer.
>>>
>>> msg_data == &amsg_data
>>> since it is an array
>> Yes, you are right, the address of 'msg_data ' is the same
>> as the address of '&amsg_data'.
>>
>> But I still think this usage is not common.
>> like the current code in DPDK:
>> *****
>> static int
>> app_parse_flow_conf(const char *conf_str)
>> {
>>         int ret;
>>         uint32_t vals[5];
>>         struct flow_conf *pconf;
>>         uint64_t mask;
>>
>>         memset(vals, 0, sizeof(vals));
>> ...
>> *****
>>
>> how about others's opinion? @Ferruh, @Thomas.
>>
> 
> I would use array without address operator, so original patch lgtm.
thanks Ferruh.
> 
> +1 to main purpose of the patch (to replace 'sizeof(uint16_t)').
> .

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

* Re: [PATCH 00/12] bugfix for hns3 PMD
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (11 preceding siblings ...)
  2022-05-19 12:29 ` [PATCH 12/12] net/hns3: fix TM capability incorrectly defined Min Hu (Connor)
@ 2022-05-31 14:55 ` Andrew Rybchenko
  2022-06-01  3:54   ` Min Hu (Connor)
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
  13 siblings, 1 reply; 38+ messages in thread
From: Andrew Rybchenko @ 2022-05-31 14:55 UTC (permalink / raw)
  To: Min Hu (Connor), dev; +Cc: ferruh.yigit, thomas

On 5/19/22 15:29, Min Hu (Connor) wrote:
> This patch set contains 12 bugfix for hns3 PMD.

The patch series fails to apply to dpdk-next-net/main.
Please, rebase and send v2.

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

* [PATCH v2 00/11] bugfix for hns3 PMD
  2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
                   ` (12 preceding siblings ...)
  2022-05-31 14:55 ` [PATCH 00/12] bugfix for hns3 PMD Andrew Rybchenko
@ 2022-06-01  3:52 ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 01/11] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
                     ` (11 more replies)
  13 siblings, 12 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

This patch set contains 11 bugfix for hns3 PMD.

Chengwen Feng (1):
  net/hns3: fix TM capability incorrectly defined

Huisong Li (9):
  net/hns3: add check for deferred start queue when rollback
  net/hns3: remove redundant parentheses
  net/hns3: adjust the data type of some variables
  net/hns3: fix an unreasonable memset
  net/hns3: remove duplicate definition
  net/hns3: fix return value for unsupported tuple
  net/hns3: modify a function name
  net/hns3: unify the code wrap style
  net/hns3: fix a segfault from secondary process

Min Hu (Connor) (1):
  net/hns3: fix coverity codecheck

 drivers/net/hns3/hns3_cmd.c       |  2 +-
 drivers/net/hns3/hns3_cmd.h       |  2 +-
 drivers/net/hns3/hns3_common.c    | 14 +++----
 drivers/net/hns3/hns3_dcb.c       |  7 ++--
 drivers/net/hns3/hns3_ethdev.c    | 20 +++++-----
 drivers/net/hns3/hns3_ethdev_vf.c | 23 ++++++------
 drivers/net/hns3/hns3_fdir.c      | 30 +++++++--------
 drivers/net/hns3/hns3_fdir.h      |  2 +-
 drivers/net/hns3/hns3_flow.c      | 25 ++++---------
 drivers/net/hns3/hns3_ptp.c       |  2 +-
 drivers/net/hns3/hns3_regs.c      |  2 +-
 drivers/net/hns3/hns3_rss.c       |  8 ++--
 drivers/net/hns3/hns3_rss.h       |  2 +
 drivers/net/hns3/hns3_rxtx.c      | 62 ++++++++++++++++---------------
 drivers/net/hns3/hns3_rxtx_vec.h  |  4 +-
 drivers/net/hns3/hns3_stats.c     | 28 +++++++-------
 16 files changed, 111 insertions(+), 122 deletions(-)
---
v2:
* delete one patch which is fixed by others.
refer to:
https://patches.dpdk.org/project/dpdk/cover/20220112072808.59713-1-jsoref@gmail.com/
-- 
2.33.0


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

* [PATCH v2 01/11] net/hns3: add check for deferred start queue when rollback
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 02/11] net/hns3: remove redundant parentheses Min Hu (Connor)
                     ` (10 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

Driver doesn't allocate mbufs for the deferred start queues, so no need to
free it when rollback.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 0c91e4721e..1c9648bd52 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -1199,6 +1199,9 @@ hns3_init_rx_queues(struct hns3_adapter *hns)
 out:
 	for (j = 0; j < i; j++) {
 		rxq = (struct hns3_rx_queue *)hw->data->rx_queues[j];
+		if (rxq->rx_deferred_start)
+			continue;
+
 		hns3_rx_queue_release_mbufs(rxq);
 	}
 
-- 
2.33.0


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

* [PATCH v2 02/11] net/hns3: remove redundant parentheses
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 01/11] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 03/11] net/hns3: adjust the data type of some variables Min Hu (Connor)
                     ` (9 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

Remove redundant parentheses.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@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 1c9648bd52..4cba4fd13e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -167,7 +167,7 @@ hns3_fake_rx_queue_release(struct hns3_rx_queue *queue)
 	}
 
 	/* free fake rx queue arrays */
-	if (idx == (hw->fkq_data.nb_fake_rx_queues - 1)) {
+	if (idx == hw->fkq_data.nb_fake_rx_queues - 1) {
 		hw->fkq_data.nb_fake_rx_queues = 0;
 		rte_free(hw->fkq_data.rx_queues);
 		hw->fkq_data.rx_queues = NULL;
@@ -194,7 +194,7 @@ hns3_fake_tx_queue_release(struct hns3_tx_queue *queue)
 	}
 
 	/* free fake tx queue arrays */
-	if (idx == (hw->fkq_data.nb_fake_tx_queues - 1)) {
+	if (idx == hw->fkq_data.nb_fake_tx_queues - 1) {
 		hw->fkq_data.nb_fake_tx_queues = 0;
 		rte_free(hw->fkq_data.tx_queues);
 		hw->fkq_data.tx_queues = NULL;
-- 
2.33.0


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

* [PATCH v2 03/11] net/hns3: adjust the data type of some variables
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 01/11] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 02/11] net/hns3: remove redundant parentheses Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 04/11] net/hns3: fix an unreasonable memset Min Hu (Connor)
                     ` (8 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

Using the 'int' type and 'uint16_t' type to compare is insecure. This patch
makes them consistent.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_common.c   |  4 ++--
 drivers/net/hns3/hns3_dcb.c      |  2 +-
 drivers/net/hns3/hns3_ethdev.c   |  2 +-
 drivers/net/hns3/hns3_regs.c     |  2 +-
 drivers/net/hns3/hns3_rss.c      |  2 +-
 drivers/net/hns3/hns3_rxtx.c     | 23 ++++++++++++-----------
 drivers/net/hns3/hns3_rxtx_vec.h |  4 ++--
 7 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
index dcdc609654..221d4ccec3 100644
--- a/drivers/net/hns3/hns3_common.c
+++ b/drivers/net/hns3/hns3_common.c
@@ -475,7 +475,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del)
 	struct rte_ether_addr *addr;
 	uint16_t mac_addrs_capa;
 	int ret = 0;
-	int i;
+	uint16_t i;
 
 	mac_addrs_capa =
 		hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM;
@@ -645,8 +645,8 @@ int
 hns3_init_ring_with_vector(struct hns3_hw *hw)
 {
 	uint16_t vec;
+	uint16_t i;
 	int ret;
-	int i;
 
 	/*
 	 * In hns3 network engine, vector 0 is always the misc interrupt of this
diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 73693786d1..04d7f530ef 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -628,7 +628,7 @@ hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q)
 	struct hns3_rss_conf *rss_cfg = &hw->rss_info;
 	uint16_t rx_qnum_per_tc;
 	uint16_t used_rx_queues;
-	int i;
+	uint16_t i;
 
 	rx_qnum_per_tc = nb_rx_q / hw->num_tc;
 	if (rx_qnum_per_tc > hw->rss_size_max) {
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 0b565a5614..3cffacdd6a 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2928,8 +2928,8 @@ hns3_map_tqps_to_func(struct hns3_hw *hw, uint16_t func_id, uint16_t tqp_pid,
 static int
 hns3_map_tqp(struct hns3_hw *hw)
 {
+	uint16_t i;
 	int ret;
-	int i;
 
 	/*
 	 * In current version, VF is not supported when PF is driven by DPDK
diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index 86a4cf74d5..6778e4cfc2 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -294,8 +294,8 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data)
 	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
 	uint32_t *origin_data_ptr = data;
 	uint32_t reg_offset;
+	uint16_t i, j;
 	int reg_num;
-	int i, j;
 
 	/* fetching per-PF registers values from PF PCIe register space */
 	reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t);
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index d376486a1d..4c546c9363 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -631,7 +631,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw)
 {
 	struct hns3_rss_conf *rss_cfg = &hw->rss_info;
 	uint16_t queue_num = hw->alloc_rss_size;
-	int i;
+	uint16_t i;
 
 	/* Default hash algorithm */
 	rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 4cba4fd13e..be4ab16dcc 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -387,7 +387,7 @@ hns3_enable_all_queues(struct hns3_hw *hw, bool en)
 	struct hns3_tx_queue *txq;
 	uint32_t rcb_reg;
 	void *tqp_base;
-	int i;
+	uint16_t i;
 
 	for (i = 0; i < hw->cfg_max_queues; i++) {
 		if (hns3_dev_get_support(hw, INDEP_TXRX)) {
@@ -733,8 +733,8 @@ hns3pf_reset_all_tqps(struct hns3_hw *hw)
 #define HNS3_RESET_RCB_NOT_SUPPORT	0U
 #define HNS3_RESET_ALL_TQP_SUCCESS	1U
 	uint8_t reset_status;
+	uint16_t i;
 	int ret;
-	int i;
 
 	ret = hns3_reset_rcb_cmd(hw, &reset_status);
 	if (ret)
@@ -771,7 +771,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
 	uint8_t reset_status;
 	uint8_t msg_data[2];
 	int ret;
-	int i;
+	uint16_t i;
 
 	memset(msg_data, 0, sizeof(uint16_t));
 	ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
@@ -803,7 +803,8 @@ int
 hns3_reset_all_tqps(struct hns3_adapter *hns)
 {
 	struct hns3_hw *hw = &hns->hw;
-	int ret, i;
+	uint16_t i;
+	int ret;
 
 	/* Disable all queues before reset all queues */
 	for (i = 0; i < hw->cfg_max_queues; i++) {
@@ -1034,7 +1035,7 @@ hns3_dev_all_rx_queue_intr_enable(struct hns3_hw *hw, bool en)
 {
 	struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id];
 	uint16_t nb_rx_q = hw->data->nb_rx_queues;
-	int i;
+	uint16_t i;
 
 	if (dev->data->dev_conf.intr_conf.rxq == 0)
 		return;
@@ -1118,7 +1119,7 @@ static void
 hns3_init_txq(struct hns3_tx_queue *txq)
 {
 	struct hns3_desc *desc;
-	int i;
+	uint16_t i;
 
 	/* Clear tx bd */
 	desc = txq->tx_ring;
@@ -1142,7 +1143,7 @@ hns3_init_tx_ring_tc(struct hns3_adapter *hns)
 
 	for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
 		struct hns3_tc_queue_info *tc_queue = &hw->tc_queue[i];
-		int j;
+		uint16_t j;
 
 		if (!tc_queue->enable)
 			continue;
@@ -1439,7 +1440,7 @@ hns3_alloc_txq_and_dma_zone(struct rte_eth_dev *dev,
 	struct hns3_tx_queue *txq;
 	struct hns3_desc *desc;
 	unsigned int tx_desc;
-	int i;
+	uint16_t i;
 
 	txq = rte_zmalloc_socket(q_info->type, sizeof(struct hns3_tx_queue),
 				 RTE_CACHE_LINE_SIZE, q_info->socket_id);
@@ -1676,7 +1677,7 @@ hns3_dev_release_mbufs(struct hns3_adapter *hns)
 	struct rte_eth_dev_data *dev_data = hns->hw.data;
 	struct hns3_rx_queue *rxq;
 	struct hns3_tx_queue *txq;
-	int i;
+	uint16_t i;
 
 	if (dev_data->rx_queues)
 		for (i = 0; i < dev_data->nb_rx_queues; i++) {
@@ -3083,7 +3084,7 @@ hns3_tx_free_useless_buffer(struct hns3_tx_queue *txq)
 	uint16_t tx_next_use = txq->next_to_use;
 	struct hns3_entry *tx_entry = &txq->sw_ring[tx_next_clean];
 	struct hns3_desc *desc = &txq->tx_ring[tx_next_clean];
-	int i;
+	uint16_t i;
 
 	if (tx_next_use >= tx_next_clean &&
 	    tx_next_use < tx_next_clean + txq->tx_rs_thresh)
@@ -3981,7 +3982,7 @@ hns3_tx_free_buffer_simple(struct hns3_tx_queue *txq)
 	struct hns3_entry *tx_entry;
 	struct hns3_desc *desc;
 	uint16_t tx_next_clean;
-	int i;
+	uint16_t i;
 
 	while (1) {
 		if (HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) < txq->tx_rs_thresh)
diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h
index 4985a7cae8..d13f18627d 100644
--- a/drivers/net/hns3/hns3_rxtx_vec.h
+++ b/drivers/net/hns3/hns3_rxtx_vec.h
@@ -15,7 +15,7 @@ hns3_tx_bulk_free_buffers(struct hns3_tx_queue *txq)
 	struct hns3_entry *tx_entry;
 	struct rte_mbuf *m;
 	int nb_free = 0;
-	int i;
+	uint16_t i;
 
 	tx_entry = &txq->sw_ring[txq->next_to_clean];
 	if (txq->mbuf_fast_free_en) {
@@ -56,7 +56,7 @@ static inline void
 hns3_tx_free_buffers(struct hns3_tx_queue *txq)
 {
 	struct hns3_desc *tx_desc;
-	int i;
+	uint16_t i;
 
 	/*
 	 * All mbufs can be released only when the VLD bits of all
-- 
2.33.0


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

* [PATCH v2 04/11] net/hns3: fix an unreasonable memset
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (2 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 03/11] net/hns3: adjust the data type of some variables Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 05/11] net/hns3: remove duplicate definition Min Hu (Connor)
                     ` (7 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

This patch fixes an unreasonable memset.

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

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index be4ab16dcc..dcb1cdf168 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -773,7 +773,7 @@ hns3vf_reset_all_tqps(struct hns3_hw *hw)
 	int ret;
 	uint16_t i;
 
-	memset(msg_data, 0, sizeof(uint16_t));
+	memset(msg_data, 0, sizeof(msg_data));
 	ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data,
 				sizeof(msg_data), true, &reset_status,
 				sizeof(reset_status));
-- 
2.33.0


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

* [PATCH v2 05/11] net/hns3: remove duplicate definition
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (3 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 04/11] net/hns3: fix an unreasonable memset Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 06/11] net/hns3: fix coverity codecheck Min Hu (Connor)
                     ` (6 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

The default hash key array is defined twice. Let's remove the extra one.

Fixes: c37ca66f2b27 ("net/hns3: support RSS")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 9 ---------
 drivers/net/hns3/hns3_rss.c  | 6 ++----
 drivers/net/hns3/hns3_rss.h  | 2 ++
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 86ebbf69b6..ca9edc5244 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -10,15 +10,6 @@
 #include "hns3_logs.h"
 #include "hns3_flow.h"
 
-/* Default default keys */
-static uint8_t hns3_hash_key[] = {
-	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
-	0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
-	0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
-	0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
-	0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA
-};
-
 static const uint8_t full_mask[VNI_OR_TNI_LEN] = { 0xFF, 0xFF, 0xFF };
 static const uint8_t zero_mask[VNI_OR_TNI_LEN] = { 0x00, 0x00, 0x00 };
 
diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c
index 4c546c9363..1003daf03e 100644
--- a/drivers/net/hns3/hns3_rss.c
+++ b/drivers/net/hns3/hns3_rss.c
@@ -9,10 +9,8 @@
 #include "hns3_ethdev.h"
 #include "hns3_logs.h"
 
-/*
- * The hash key used for rss initialization.
- */
-static const uint8_t hns3_hash_key[] = {
+/* Default hash keys */
+const uint8_t hns3_hash_key[] = {
 	0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
 	0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
 	0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h
index 55d5718ffc..56627cbd4c 100644
--- a/drivers/net/hns3/hns3_rss.h
+++ b/drivers/net/hns3/hns3_rss.h
@@ -88,6 +88,8 @@ static inline uint32_t roundup_pow_of_two(uint32_t x)
 	return 1UL << fls(x - 1);
 }
 
+extern const uint8_t hns3_hash_key[];
+
 struct hns3_adapter;
 
 int hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
-- 
2.33.0


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

* [PATCH v2 06/11] net/hns3: fix coverity codecheck
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (4 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 05/11] net/hns3: remove duplicate definition Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  8:32     ` Andrew Rybchenko
  2022-06-01  3:52   ` [PATCH v2 07/11] net/hns3: fix return value for unsupported tuple Min Hu (Connor)
                     ` (5 subsequent siblings)
  11 siblings, 1 reply; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

In bitwise operation, "val" should be an unsigned type. This patch
fixed it.

Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
index 1442241a4e..0b0061bba5 100644
--- a/drivers/net/hns3/hns3_ptp.c
+++ b/drivers/net/hns3/hns3_ptp.c
@@ -81,7 +81,7 @@ hns3_timesync_configure(struct hns3_adapter *hns, bool en)
 	struct hns3_hw *hw = &hns->hw;
 	struct hns3_pf *pf = &hns->pf;
 	struct hns3_cmd_desc desc;
-	int val;
+	uint32_t val;
 	int ret;
 
 	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false);
-- 
2.33.0


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

* [PATCH v2 07/11] net/hns3: fix return value for unsupported tuple
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (5 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 06/11] net/hns3: fix coverity codecheck Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 08/11] net/hns3: modify a function name Min Hu (Connor)
                     ` (4 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

Driver should return false for unsupported tuple. This patch fixes it.

Fixes: 18a4b4c3fa80 ("net/hns3: add default to switch when parsing fd tuple")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 2a7978ac07..a0d6598e57 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -631,7 +631,7 @@ static bool hns3_fd_convert_tuple(struct hns3_hw *hw,
 		break;
 	default:
 		hns3_warn(hw, "not support tuple of (%u)", tuple);
-		break;
+		return false;
 	}
 	return true;
 }
-- 
2.33.0


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

* [PATCH v2 08/11] net/hns3: modify a function name
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (6 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 07/11] net/hns3: fix return value for unsupported tuple Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 09/11] net/hns3: unify the code wrap style Min Hu (Connor)
                     ` (3 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

The meaning of the "hns3_get_count" function is not precise enough. This
patch changes from "hns3_get_count" to "hns3_fd_get_count".

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_fdir.c | 2 +-
 drivers/net/hns3/hns3_fdir.h | 2 +-
 drivers/net/hns3/hns3_flow.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index a0d6598e57..762b89a51e 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -1099,7 +1099,7 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns)
 	return 0;
 }
 
-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value)
+int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value)
 {
 	struct hns3_fd_get_cnt_cmd *req;
 	struct hns3_cmd_desc desc;
diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h
index 8d588ffef3..d81f04a3f3 100644
--- a/drivers/net/hns3/hns3_fdir.h
+++ b/drivers/net/hns3/hns3_fdir.h
@@ -184,7 +184,7 @@ void hns3_fdir_filter_uninit(struct hns3_adapter *hns);
 int hns3_fdir_filter_program(struct hns3_adapter *hns,
 			     struct hns3_fdir_rule *rule, bool del);
 int hns3_clear_all_fdir_filter(struct hns3_adapter *hns);
-int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
+int hns3_fd_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
 int hns3_restore_all_fdir_filter(struct hns3_adapter *hns);
 
 #endif /* _HNS3_FDIR_H_ */
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index ca9edc5244..1bd4ac160d 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -164,13 +164,13 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t indirect, uint32_t id,
 				"Counter id is used, indirect flag not match");
 		/* Clear the indirect counter on first use. */
 		if (cnt->indirect && cnt->ref_cnt == 1)
-			(void)hns3_get_count(hw, id, &value);
+			(void)hns3_fd_get_count(hw, id, &value);
 		cnt->ref_cnt++;
 		return 0;
 	}
 
 	/* Clear the counter by read ops because the counter is read-clear */
-	ret = hns3_get_count(hw, id, &value);
+	ret = hns3_fd_get_count(hw, id, &value);
 	if (ret)
 		return rte_flow_error_set(error, EIO,
 					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -210,7 +210,7 @@ hns3_counter_query(struct rte_eth_dev *dev, struct rte_flow *flow,
 					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 					  "Can't find counter id");
 
-	ret = hns3_get_count(&hns->hw, flow->counter_id, &value);
+	ret = hns3_fd_get_count(&hns->hw, flow->counter_id, &value);
 	if (ret) {
 		rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE,
 				   NULL, "Read counter fail.");
-- 
2.33.0


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

* [PATCH v2 09/11] net/hns3: unify the code wrap style
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (7 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 08/11] net/hns3: modify a function name Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 10/11] net/hns3: fix a segfault from secondary process Min Hu (Connor)
                     ` (2 subsequent siblings)
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

This patch unifies the code wrap style.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_cmd.c       |  2 +-
 drivers/net/hns3/hns3_common.c    | 10 +++++-----
 drivers/net/hns3/hns3_dcb.c       |  5 ++---
 drivers/net/hns3/hns3_ethdev.c    | 18 ++++++++----------
 drivers/net/hns3/hns3_ethdev_vf.c | 23 +++++++++++------------
 drivers/net/hns3/hns3_fdir.c      | 26 +++++++++++++-------------
 drivers/net/hns3/hns3_flow.c      | 10 ++++------
 drivers/net/hns3/hns3_rxtx.c      | 28 +++++++++++++---------------
 drivers/net/hns3/hns3_stats.c     | 28 ++++++++++++++--------------
 9 files changed, 71 insertions(+), 79 deletions(-)

diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c
index 5dc874fd7a..eadc15093f 100644
--- a/drivers/net/hns3/hns3_cmd.c
+++ b/drivers/net/hns3/hns3_cmd.c
@@ -108,7 +108,7 @@ hns3_alloc_cmd_queue(struct hns3_hw *hw, int ring_type)
 	ret = hns3_alloc_cmd_desc(hw, ring);
 	if (ret)
 		hns3_err(hw, "descriptor %s alloc error %d",
-			    (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret);
+			 (ring_type == HNS3_TYPE_CSQ) ? "CSQ" : "CRQ", ret);
 
 	return ret;
 }
diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c
index 221d4ccec3..424205356e 100644
--- a/drivers/net/hns3/hns3_common.c
+++ b/drivers/net/hns3/hns3_common.c
@@ -604,7 +604,7 @@ hns3_init_mac_addrs(struct rte_eth_dev *dev)
 				0);
 	if (dev->data->mac_addrs == NULL) {
 		hns3_err(hw, "failed to allocate %zx bytes needed to store MAC addresses",
-			     sizeof(struct rte_ether_addr) * mac_addrs_capa);
+			 sizeof(struct rte_ether_addr) * mac_addrs_capa);
 		return -ENOMEM;
 	}
 
@@ -680,16 +680,16 @@ hns3_init_ring_with_vector(struct hns3_hw *hw)
 		ret = hw->ops.bind_ring_with_vector(hw, vec, false,
 						    HNS3_RING_TYPE_TX, i);
 		if (ret) {
-			PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with "
-					  "vector: %u, ret=%d", i, vec, ret);
+			PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with vector: %u, ret=%d",
+				     i, vec, ret);
 			return ret;
 		}
 
 		ret = hw->ops.bind_ring_with_vector(hw, vec, false,
 						    HNS3_RING_TYPE_RX, i);
 		if (ret) {
-			PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with "
-					  "vector: %u, ret=%d", i, vec, ret);
+			PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with vector: %u, ret=%d",
+				     i, vec, ret);
 			return ret;
 		}
 	}
diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 04d7f530ef..af045b22f7 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -876,9 +876,8 @@ hns3_dcb_pri_tc_base_dwrr_cfg(struct hns3_hw *hw)
 
 		ret = hns3_dcb_pri_weight_cfg(hw, i, dwrr);
 		if (ret) {
-			hns3_err(hw,
-			       "fail to send priority weight cmd: %d, ret = %d",
-			       i, ret);
+			hns3_err(hw, "fail to send priority weight cmd: %d, ret = %d",
+				 i, ret);
 			return ret;
 		}
 
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 3cffacdd6a..6c77c8b964 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -1626,7 +1626,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	ret = hw->ops.del_uc_mac_addr(hw, oaddr);
 	if (ret) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      oaddr);
+				       oaddr);
 		hns3_warn(hw, "Remove old uc mac address(%s) fail: %d",
 			  mac_str, ret);
 
@@ -1658,7 +1658,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	ret_val = hw->ops.del_uc_mac_addr(hw, mac_addr);
 	if (ret_val) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_warn(hw,
 			  "Failed to roll back to del setted mac addr(%s): %d",
 			  mac_str, ret_val);
@@ -1669,7 +1669,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev,
 	if (ret_val) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr);
 		hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d",
-				  mac_str, ret_val);
+			  mac_str, ret_val);
 	}
 	rte_spinlock_unlock(&hw->lock);
 
@@ -1746,7 +1746,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 		if (ret == -ENOSPC)
 			hns3_err(hw, "mc mac vlan table is full");
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret);
 	}
 
@@ -2675,9 +2675,8 @@ hns3_check_dev_specifications(struct hns3_hw *hw)
 {
 	if (hw->rss_ind_tbl_size == 0 ||
 	    hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) {
-		hns3_err(hw, "the size of hash lookup table configured (%u)"
-			      " exceeds the maximum(%u)", hw->rss_ind_tbl_size,
-			      HNS3_RSS_IND_TBL_SIZE_MAX);
+		hns3_err(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)",
+			 hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX);
 		return -EINVAL;
 	}
 
@@ -3915,7 +3914,7 @@ hns3_dev_promiscuous_enable(struct rte_eth_dev *dev)
 		ret = hns3_enable_vlan_filter(hns, false);
 		if (ret) {
 			hns3_err(hw, "failed to enable promiscuous mode due to "
-				     "failure to disable vlan filter, ret = %d",
+				 "failure to disable vlan filter, ret = %d",
 				 ret);
 			err = hns3_set_promisc_mode(hw, false, allmulti);
 			if (err)
@@ -5992,8 +5991,7 @@ hns3_reset_service(void *param)
 		timersub(&tv, &tv_start, &tv_delta);
 		msec = hns3_clock_calctime_ms(&tv_delta);
 		if (msec > HNS3_RESET_PROCESS_MS)
-			hns3_err(hw, "%d handle long time delta %" PRIu64
-				     " ms time=%ld.%.6ld",
+			hns3_err(hw, "%d handle long time delta %" PRIu64 " ms time=%ld.%.6ld",
 				 hw->reset.level, msec,
 				 tv.tv_sec, tv.tv_usec);
 		if (ret == -EAGAIN)
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 589de0ab3a..bebfaa6417 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -141,7 +141,7 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op)
 	pos = hns3vf_find_pci_capability(device, PCI_CAP_ID_MSIX);
 	if (pos) {
 		ret = rte_pci_read_config(device, &control, sizeof(control),
-				    (pos + PCI_MSIX_FLAGS));
+					  (pos + PCI_MSIX_FLAGS));
 		if (ret < 0) {
 			PMD_INIT_LOG(ERR, "Failed to read PCI offset 0x%x",
 				     (pos + PCI_MSIX_FLAGS));
@@ -153,10 +153,10 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op)
 		else
 			control &= ~PCI_MSIX_FLAGS_ENABLE;
 		ret = rte_pci_write_config(device, &control, sizeof(control),
-					  (pos + PCI_MSIX_FLAGS));
+					   (pos + PCI_MSIX_FLAGS));
 		if (ret < 0) {
 			PMD_INIT_LOG(ERR, "failed to write PCI offset 0x%x",
-				    (pos + PCI_MSIX_FLAGS));
+				     (pos + PCI_MSIX_FLAGS));
 			return -ENXIO;
 		}
 
@@ -198,7 +198,7 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 				false, NULL, 0);
 	if (ret) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_err(hw, "failed to add uc mac addr(%s), ret = %d",
 			 mac_str, ret);
 	}
@@ -240,12 +240,12 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev,
 		 */
 		if (ret == -EPERM) {
 			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-					      old_addr);
+					       old_addr);
 			hns3_warn(hw, "Has permanent mac addr(%s) for vf",
 				  mac_str);
 		} else {
 			hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-					      mac_addr);
+					       mac_addr);
 			hns3_err(hw, "Failed to set mac addr(%s) for vf: %d",
 				 mac_str, ret);
 		}
@@ -292,7 +292,7 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw,
 				NULL, 0);
 	if (ret) {
 		hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE,
-				      mac_addr);
+				       mac_addr);
 		hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
 	}
@@ -714,9 +714,8 @@ hns3vf_check_dev_specifications(struct hns3_hw *hw)
 {
 	if (hw->rss_ind_tbl_size == 0 ||
 	    hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) {
-		hns3_warn(hw, "the size of hash lookup table configured (%u)"
-			      " exceeds the maximum(%u)", hw->rss_ind_tbl_size,
-			      HNS3_RSS_IND_TBL_SIZE_MAX);
+		hns3_warn(hw, "the size of hash lookup table configured (%u) exceeds the maximum(%u)",
+			  hw->rss_ind_tbl_size, HNS3_RSS_IND_TBL_SIZE_MAX);
 		return -EINVAL;
 	}
 
@@ -1167,8 +1166,8 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 	int ret = 0;
 
 	if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) {
-		hns3_err(hw, "vf set vlan offload failed during resetting, "
-			     "mask = 0x%x", mask);
+		hns3_err(hw, "vf set vlan offload failed during resetting, mask = 0x%x",
+			 mask);
 		return -EIO;
 	}
 
diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 762b89a51e..30e5e66772 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -321,7 +321,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 		break;
 	default:
 		hns3_err(hw, "Unsupported flow director mode %u",
-			    pf->fdir.fd_cfg.fd_mode);
+			 pf->fdir.fd_cfg.fd_mode);
 		return -EOPNOTSUPP;
 	}
 
@@ -337,7 +337,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 	    BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) |
 	    BIT(INNER_SRC_PORT) | BIT(INNER_DST_PORT);
 	hns3_dbg(hw, "fdir tuple: inner<vlan_tag1 eth_type ip_src ip_dst "
-		  "ip_proto ip_tos l4_src_port l4_dst_port>");
+		 "ip_proto ip_tos l4_src_port l4_dst_port>");
 
 	/* If use max 400bit key, we can support tuples for ether type */
 	if (pf->fdir.fd_cfg.max_key_length == MAX_KEY_LENGTH) {
@@ -348,8 +348,8 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 		    BIT(OUTER_TUN_VNI) | BIT(OUTER_TUN_FLOW_ID) |
 		    BIT(OUTER_ETH_TYPE) | BIT(OUTER_IP_PROTO);
 		hns3_dbg(hw, "fdir tuple more: inner<dst_mac src_mac "
-			  "vlan_tag2 sctp_tag> outer<eth_type ip_proto "
-			  "l4_src_port l4_dst_port tun_vni tun_flow_id>");
+			 "vlan_tag2 sctp_tag> outer<eth_type ip_proto "
+			 "l4_src_port l4_dst_port tun_vni tun_flow_id>");
 	}
 
 	/* roce_type is used to filter roce frames
@@ -367,12 +367,11 @@ int hns3_init_fd_config(struct hns3_adapter *hns)
 	if (ret)
 		return ret;
 
-	hns3_dbg(hw, "fdir: stage1<rules-%u counters-%u> stage2<rules-%u "
-		  "counters=%u>",
-		  pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1],
-		  pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1],
-		  pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2],
-		  pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]);
+	hns3_dbg(hw, "fdir: stage1<rules-%u counters-%u> stage2<rules-%u counters=%u>",
+		 pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1],
+		 pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1],
+		 pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2],
+		 pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]);
 
 	return hns3_set_fd_key_config(hns);
 }
@@ -420,7 +419,7 @@ static int hns3_fd_tcam_config(struct hns3_hw *hw, bool sel_x, int loc,
 	ret = hns3_cmd_send(hw, desc, FD_TCAM_CMD_NUM);
 	if (ret)
 		hns3_err(hw, "Config tcam key fail, ret=%d loc=%d add=%d",
-			    ret, loc, is_add);
+			 ret, loc, is_add);
 	return ret;
 }
 
@@ -673,6 +672,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg,
 		} else if (i == VLAN_NUMBER) {
 			uint32_t vlan_tag;
 			uint8_t vlan_num;
+
 			if (rule->key_conf.spec.tunnel_type == 0)
 				vlan_num = rule->key_conf.vlan_num;
 			else
@@ -758,14 +758,14 @@ static int hns3_config_key(struct hns3_adapter *hns,
 	ret = hns3_fd_tcam_config(hw, false, rule->location, key_y, true);
 	if (ret) {
 		hns3_err(hw, "Config fd key_y fail, loc=%u, ret=%d",
-			    rule->queue_id, ret);
+			 rule->queue_id, ret);
 		return ret;
 	}
 
 	ret = hns3_fd_tcam_config(hw, true, rule->location, key_x, true);
 	if (ret)
 		hns3_err(hw, "Config fd key_x fail, loc=%u, ret=%d",
-			    rule->queue_id, ret);
+			 rule->queue_id, ret);
 	return ret;
 }
 
diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 1bd4ac160d..fb9354fe7f 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -285,9 +285,8 @@ hns3_handle_action_queue(struct rte_eth_dev *dev,
 
 	queue = (const struct rte_flow_action_queue *)action->conf;
 	if (queue->index >= hw->data->nb_rx_queues) {
-		hns3_err(hw, "queue ID(%u) is greater than number of "
-			  "available queue (%u) in driver.",
-			  queue->index, hw->data->nb_rx_queues);
+		hns3_err(hw, "queue ID(%u) is greater than number of available queue (%u) in driver.",
+			 queue->index, hw->data->nb_rx_queues);
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 					  action, "Invalid queue ID in PF");
@@ -1656,9 +1655,8 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev)
 	}
 
 	if (rss_rule_fail_cnt) {
-		hns3_err(hw, "fail to delete all RSS filters, success num = %d "
-			     "fail num = %d", rss_rule_succ_cnt,
-			     rss_rule_fail_cnt);
+		hns3_err(hw, "fail to delete all RSS filters, success num = %d fail num = %d",
+			 rss_rule_succ_cnt, rss_rule_fail_cnt);
 		ret = -EIO;
 	}
 
diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index dcb1cdf168..bbf98fc90e 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -603,8 +603,8 @@ hns3_send_reset_tqp_cmd(struct hns3_hw *hw, uint16_t queue_id, bool enable)
 	hns3_set_bit(req->reset_req, HNS3_TQP_RESET_B, enable ? 1 : 0);
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret)
-		hns3_err(hw, "send tqp reset cmd error, queue_id = %u, "
-			     "ret = %d", queue_id, ret);
+		hns3_err(hw, "send tqp reset cmd error, queue_id = %u, ret = %d",
+			 queue_id, ret);
 
 	return ret;
 }
@@ -624,8 +624,8 @@ hns3_get_tqp_reset_status(struct hns3_hw *hw, uint16_t queue_id,
 
 	ret = hns3_cmd_send(hw, &desc, 1);
 	if (ret) {
-		hns3_err(hw, "get tqp reset status error, queue_id = %u, "
-			     "ret = %d.", queue_id, ret);
+		hns3_err(hw, "get tqp reset status error, queue_id = %u, ret = %d.",
+			 queue_id, ret);
 		return ret;
 	}
 	*reset_status = hns3_get_bit(req->ready_to_reset, HNS3_TQP_RESET_B);
@@ -666,7 +666,7 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id)
 	if (!reset_status) {
 		ret = -ETIMEDOUT;
 		hns3_err(hw, "reset tqp timeout, queue_id = %u, ret = %d",
-			     queue_id, ret);
+			 queue_id, ret);
 		goto tqp_reset_fail;
 	}
 
@@ -749,15 +749,14 @@ 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.",
-				  i, ret);
+				hns3_err(hw, "fail to reset tqp, queue_id = %d, ret = %d.",
+					 i, ret);
 				return ret;
 			}
 		}
 	} else if (reset_status != HNS3_RESET_ALL_TQP_SUCCESS) {
 		hns3_err(hw, "fail to reset all tqps, reset_status = %u.",
-				reset_status);
+			 reset_status);
 		return -EIO;
 	}
 
@@ -810,9 +809,8 @@ hns3_reset_all_tqps(struct hns3_adapter *hns)
 	for (i = 0; i < hw->cfg_max_queues; i++) {
 		ret = hns3_tqp_enable(hw, i, false);
 		if (ret) {
-			hns3_err(hw,
-			    "fail to disable tqps before tqps reset, ret = %d.",
-			    ret);
+			hns3_err(hw, "fail to disable tqps before tqps reset, ret = %d.",
+				 ret);
 			return ret;
 		}
 	}
@@ -919,9 +917,9 @@ hns3_reset_queue(struct hns3_hw *hw, uint16_t queue_id,
 	}
 
 	if (!reset_status) {
-		hns3_err(hw, "reset queue timeout, queue_id = %u, "
-			     "queue_type = %s", queue_id,
-			     queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx");
+		hns3_err(hw, "reset queue timeout, queue_id = %u, queue_type = %s",
+			 queue_id,
+			 queue_type == HNS3_RING_TYPE_TX ? "Tx" : "Rx");
 		ret = -ETIMEDOUT;
 		goto queue_reset_fail;
 	}
diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 07fad03485..a71356934a 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -507,8 +507,8 @@ hns3_update_port_rx_ssu_drop_stats(struct hns3_hw *hw)
 
 	req = (struct hns3_query_ssu_cmd *)desc[0].data;
 	cnt = rte_le_to_cpu_32(req->oq_drop_cnt) +
-		rte_le_to_cpu_32(req->full_drop_cnt) +
-		rte_le_to_cpu_32(req->part_drop_cnt);
+	      rte_le_to_cpu_32(req->full_drop_cnt) +
+	      rte_le_to_cpu_32(req->part_drop_cnt);
 
 	stats->ssu_rx_drop_cnt += cnt;
 
@@ -532,8 +532,8 @@ hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw)
 
 	req = (struct hns3_query_ssu_cmd *)desc[0].data;
 	cnt = rte_le_to_cpu_32(req->oq_drop_cnt) +
-		rte_le_to_cpu_32(req->full_drop_cnt) +
-		rte_le_to_cpu_32(req->part_drop_cnt);
+	      rte_le_to_cpu_32(req->full_drop_cnt) +
+	      rte_le_to_cpu_32(req->part_drop_cnt);
 
 	hw->oerror_stats += cnt;
 
@@ -1337,8 +1337,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 	len = cnt_stats * sizeof(struct rte_eth_xstat);
 	values_copy = rte_zmalloc("hns3_xstats_values", len, 0);
 	if (values_copy == NULL) {
-		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed "
-			     "to store statistics values", len);
+		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics values",
+			 len);
 		return -ENOMEM;
 	}
 
@@ -1359,8 +1359,8 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
 
 	for (i = 0; i < size; i++) {
 		if (ids[i] >= cnt_stats) {
-			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, "
-				     "should < %u", i, ids[i], cnt_stats);
+			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u",
+				 i, ids[i], cnt_stats);
 			rte_free(values_copy);
 			return -EINVAL;
 		}
@@ -1419,8 +1419,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 	len = cnt_stats * sizeof(struct rte_eth_xstat_name);
 	names_copy = rte_zmalloc("hns3_xstats_names", len, 0);
 	if (names_copy == NULL) {
-		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed "
-			     "to store statistics names", len);
+		hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed to store statistics names",
+			 len);
 		return -ENOMEM;
 	}
 
@@ -1428,8 +1428,8 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
 
 	for (i = 0; i < size; i++) {
 		if (ids[i] >= cnt_stats) {
-			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, "
-				     "should < %u", i, ids[i], cnt_stats);
+			hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, should < %u",
+				 i, ids[i], cnt_stats);
 			rte_free(names_copy);
 			return -EINVAL;
 		}
@@ -1501,14 +1501,14 @@ hns3_tqp_stats_init(struct hns3_hw *hw)
 	struct hns3_tqp_stats *tqp_stats = &hw->tqp_stats;
 
 	tqp_stats->rcb_rx_ring_pktnum = rte_zmalloc("hns3_rx_ring_pkt_num",
-					 sizeof(uint64_t) * hw->tqps_num, 0);
+					sizeof(uint64_t) * hw->tqps_num, 0);
 	if (tqp_stats->rcb_rx_ring_pktnum == NULL) {
 		hns3_err(hw, "failed to allocate rx_ring pkt_num.");
 		return -ENOMEM;
 	}
 
 	tqp_stats->rcb_tx_ring_pktnum = rte_zmalloc("hns3_tx_ring_pkt_num",
-					 sizeof(uint64_t) * hw->tqps_num, 0);
+					sizeof(uint64_t) * hw->tqps_num, 0);
 	if (tqp_stats->rcb_tx_ring_pktnum == NULL) {
 		hns3_err(hw, "failed to allocate tx_ring pkt_num.");
 		rte_free(tqp_stats->rcb_rx_ring_pktnum);
-- 
2.33.0


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

* [PATCH v2 10/11] net/hns3: fix a segfault from secondary process
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (8 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 09/11] net/hns3: unify the code wrap style Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-01  3:52   ` [PATCH v2 11/11] net/hns3: fix TM capability incorrectly defined Min Hu (Connor)
  2022-06-09 10:57   ` [PATCH v2 00/11] bugfix for hns3 PMD Andrew Rybchenko
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Huisong Li <lihuisong@huawei.com>

If a hns3 device in the secondary process is attached to do probing
operation, 'rx_queues' and 'tx_queues' in dev->data are null in
eth_dev_fp_ops_setup when calling rte_eth_dev_probing_finish. The primary
process calls dev_start to re-setup their fp_ops. But the secondary process
can't call dev_start and has no chance to do it. If the application sends
and receives packets at this time, a segfault will occur. So this patch
uses the MP communication of the PMD to update the fp_ops of the device in
the secondary process.

Fixes: 96c33cfb06cf ("net/hns3: fix Rx/Tx functions update")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index bbf98fc90e..e25a91becf 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4409,6 +4409,8 @@ hns3_eth_dev_fp_ops_config(const struct rte_eth_dev *dev)
 	fpo[port_id].tx_pkt_prepare = dev->tx_pkt_prepare;
 	fpo[port_id].rx_descriptor_status = dev->rx_descriptor_status;
 	fpo[port_id].tx_descriptor_status = dev->tx_descriptor_status;
+	fpo[port_id].rxq.data = dev->data->rx_queues;
+	fpo[port_id].txq.data = dev->data->tx_queues;
 }
 
 void
-- 
2.33.0


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

* [PATCH v2 11/11] net/hns3: fix TM capability incorrectly defined
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (9 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 10/11] net/hns3: fix a segfault from secondary process Min Hu (Connor)
@ 2022-06-01  3:52   ` Min Hu (Connor)
  2022-06-09 10:57   ` [PATCH v2 00/11] bugfix for hns3 PMD Andrew Rybchenko
  11 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:52 UTC (permalink / raw)
  To: dev

From: Chengwen Feng <fengchengwen@huawei.com>

The TM capability should be bit-19 according to the user manual of
firmware. This patch fixes it.

Fixes: fc18d1b4b85f ("net/hns3: fix traffic management")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h
index f9addc6069..82c999061d 100644
--- a/drivers/net/hns3/hns3_cmd.h
+++ b/drivers/net/hns3/hns3_cmd.h
@@ -323,7 +323,7 @@ enum HNS3_CAPS_BITS {
 	HNS3_CAPS_UDP_TUNNEL_CSUM_B,
 	HNS3_CAPS_RAS_IMP_B,
 	HNS3_CAPS_RXD_ADV_LAYOUT_B = 15,
-	HNS3_CAPS_TM_B = 17,
+	HNS3_CAPS_TM_B = 19,
 };
 
 /* Capabilities of VF dependent on the PF */
-- 
2.33.0


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

* Re: [PATCH 00/12] bugfix for hns3 PMD
  2022-05-31 14:55 ` [PATCH 00/12] bugfix for hns3 PMD Andrew Rybchenko
@ 2022-06-01  3:54   ` Min Hu (Connor)
  0 siblings, 0 replies; 38+ messages in thread
From: Min Hu (Connor) @ 2022-06-01  3:54 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: ferruh.yigit, thomas

Hi, Andrew ,
  v2 has been sent, thanks.

在 2022/5/31 22:55, Andrew Rybchenko 写道:
> On 5/19/22 15:29, Min Hu (Connor) wrote:
>> This patch set contains 12 bugfix for hns3 PMD.
> 
> The patch series fails to apply to dpdk-next-net/main.
> Please, rebase and send v2.
> .

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

* Re: [PATCH v2 06/11] net/hns3: fix coverity codecheck
  2022-06-01  3:52   ` [PATCH v2 06/11] net/hns3: fix coverity codecheck Min Hu (Connor)
@ 2022-06-01  8:32     ` Andrew Rybchenko
  2022-06-06  7:48       ` Dongdong Liu
  0 siblings, 1 reply; 38+ messages in thread
From: Andrew Rybchenko @ 2022-06-01  8:32 UTC (permalink / raw)
  To: Min Hu (Connor), dev

On 6/1/22 06:52, Min Hu (Connor) wrote:
> In bitwise operation, "val" should be an unsigned type. This patch
> fixed it.
> 
> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
> Cc: stable@dpdk.org

Please, let me know coverity ID. No necessity to resend.
I'll add it on applying.

> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>   drivers/net/hns3/hns3_ptp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
> index 1442241a4e..0b0061bba5 100644
> --- a/drivers/net/hns3/hns3_ptp.c
> +++ b/drivers/net/hns3/hns3_ptp.c
> @@ -81,7 +81,7 @@ hns3_timesync_configure(struct hns3_adapter *hns, bool en)
>   	struct hns3_hw *hw = &hns->hw;
>   	struct hns3_pf *pf = &hns->pf;
>   	struct hns3_cmd_desc desc;
> -	int val;
> +	uint32_t val;
>   	int ret;
>   
>   	hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false);


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

* Re: [PATCH v2 06/11] net/hns3: fix coverity codecheck
  2022-06-01  8:32     ` Andrew Rybchenko
@ 2022-06-06  7:48       ` Dongdong Liu
  2022-06-08 11:19         ` Andrew Rybchenko
  0 siblings, 1 reply; 38+ messages in thread
From: Dongdong Liu @ 2022-06-06  7:48 UTC (permalink / raw)
  To: Andrew Rybchenko, Min Hu (Connor), dev

Hi Andrew

Many thanks for your review.

I will take over Hu Min's current work and continue to do the upstream work.

On 2022/6/1 16:32, Andrew Rybchenko wrote:
> On 6/1/22 06:52, Min Hu (Connor) wrote:
>> In bitwise operation, "val" should be an unsigned type. This patch
>> fixed it.
>>
>> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
>> Cc: stable@dpdk.org
>
> Please, let me know coverity ID. No necessity to resend.
> I'll add it on applying.

The code warning is checked by our internal code check tool,
does not have the coverity ID.

Thanks,
Dongdong
>
>>
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>>   drivers/net/hns3/hns3_ptp.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c
>> index 1442241a4e..0b0061bba5 100644
>> --- a/drivers/net/hns3/hns3_ptp.c
>> +++ b/drivers/net/hns3/hns3_ptp.c
>> @@ -81,7 +81,7 @@ hns3_timesync_configure(struct hns3_adapter *hns,
>> bool en)
>>       struct hns3_hw *hw = &hns->hw;
>>       struct hns3_pf *pf = &hns->pf;
>>       struct hns3_cmd_desc desc;
>> -    int val;
>> +    uint32_t val;
>>       int ret;
>>         hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false);
>
> .
>

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

* Re: [PATCH v2 06/11] net/hns3: fix coverity codecheck
  2022-06-06  7:48       ` Dongdong Liu
@ 2022-06-08 11:19         ` Andrew Rybchenko
  2022-06-08 12:04           ` Dongdong Liu
  0 siblings, 1 reply; 38+ messages in thread
From: Andrew Rybchenko @ 2022-06-08 11:19 UTC (permalink / raw)
  To: Dongdong Liu, Min Hu (Connor), dev

Hi Dongdong,

On 6/6/22 10:48, Dongdong Liu wrote:
> Hi Andrew
> 
> Many thanks for your review.
> 
> I will take over Hu Min's current work and continue to do the upstream 
> work.
> 
> On 2022/6/1 16:32, Andrew Rybchenko wrote:
>> On 6/1/22 06:52, Min Hu (Connor) wrote:
>>> In bitwise operation, "val" should be an unsigned type. This patch
>>> fixed it.
>>>
>>> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
>>> Cc: stable@dpdk.org
>>
>> Please, let me know coverity ID. No necessity to resend.
>> I'll add it on applying.
> 
> The code warning is checked by our internal code check tool,
> does not have the coverity ID.

Hm, the summary says coverity. Could you suggest how to rephrase it.

Thanks,
Andrew.


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

* Re: [PATCH v2 06/11] net/hns3: fix coverity codecheck
  2022-06-08 11:19         ` Andrew Rybchenko
@ 2022-06-08 12:04           ` Dongdong Liu
  0 siblings, 0 replies; 38+ messages in thread
From: Dongdong Liu @ 2022-06-08 12:04 UTC (permalink / raw)
  To: Andrew Rybchenko, Min Hu (Connor), dev

Hi Andrew
On 2022/6/8 19:19, Andrew Rybchenko wrote:
> Hi Dongdong,
>
> On 6/6/22 10:48, Dongdong Liu wrote:
>> Hi Andrew
>>
>> Many thanks for your review.
>>
>> I will take over Hu Min's current work and continue to do the upstream
>> work.
>>
>> On 2022/6/1 16:32, Andrew Rybchenko wrote:
>>> On 6/1/22 06:52, Min Hu (Connor) wrote:
>>>> In bitwise operation, "val" should be an unsigned type. This patch
>>>> fixed it.
>>>>
>>>> Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP")
>>>> Cc: stable@dpdk.org
>>>
>>> Please, let me know coverity ID. No necessity to resend.
>>> I'll add it on applying.
>>
>> The code warning is checked by our internal code check tool,
>> does not have the coverity ID.
>
> Hm, the summary says coverity. Could you suggest how to rephrase it.
Aha, the title is inaccurate.
How about change to "net/hns3: fix code check warning".

Thanks,
Dongdong
>
> Thanks,
> Andrew.
>
> .
>

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

* Re: [PATCH v2 00/11] bugfix for hns3 PMD
  2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
                     ` (10 preceding siblings ...)
  2022-06-01  3:52   ` [PATCH v2 11/11] net/hns3: fix TM capability incorrectly defined Min Hu (Connor)
@ 2022-06-09 10:57   ` Andrew Rybchenko
  11 siblings, 0 replies; 38+ messages in thread
From: Andrew Rybchenko @ 2022-06-09 10:57 UTC (permalink / raw)
  To: Min Hu (Connor), dev

On 6/1/22 06:52, Min Hu (Connor) wrote:
> This patch set contains 11 bugfix for hns3 PMD.
> 
> Chengwen Feng (1):
>    net/hns3: fix TM capability incorrectly defined
> 
> Huisong Li (9):
>    net/hns3: add check for deferred start queue when rollback
>    net/hns3: remove redundant parentheses
>    net/hns3: adjust the data type of some variables
>    net/hns3: fix an unreasonable memset
>    net/hns3: remove duplicate definition
>    net/hns3: fix return value for unsupported tuple
>    net/hns3: modify a function name
>    net/hns3: unify the code wrap style
>    net/hns3: fix a segfault from secondary process
> 
> Min Hu (Connor) (1):
>    net/hns3: fix coverity codecheck
> 
>   drivers/net/hns3/hns3_cmd.c       |  2 +-
>   drivers/net/hns3/hns3_cmd.h       |  2 +-
>   drivers/net/hns3/hns3_common.c    | 14 +++----
>   drivers/net/hns3/hns3_dcb.c       |  7 ++--
>   drivers/net/hns3/hns3_ethdev.c    | 20 +++++-----
>   drivers/net/hns3/hns3_ethdev_vf.c | 23 ++++++------
>   drivers/net/hns3/hns3_fdir.c      | 30 +++++++--------
>   drivers/net/hns3/hns3_fdir.h      |  2 +-
>   drivers/net/hns3/hns3_flow.c      | 25 ++++---------
>   drivers/net/hns3/hns3_ptp.c       |  2 +-
>   drivers/net/hns3/hns3_regs.c      |  2 +-
>   drivers/net/hns3/hns3_rss.c       |  8 ++--
>   drivers/net/hns3/hns3_rss.h       |  2 +
>   drivers/net/hns3/hns3_rxtx.c      | 62 ++++++++++++++++---------------
>   drivers/net/hns3/hns3_rxtx_vec.h  |  4 +-
>   drivers/net/hns3/hns3_stats.c     | 28 +++++++-------
>   16 files changed, 111 insertions(+), 122 deletions(-)
> ---
> v2:
> * delete one patch which is fixed by others.
> refer to:
> https://patches.dpdk.org/project/dpdk/cover/20220112072808.59713-1-jsoref@gmail.com/

Applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2022-06-09 10:57 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 12:29 [PATCH 00/12] bugfix for hns3 PMD Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 01/12] net/hns3: fix spelling errors Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 02/12] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 03/12] net/hns3: remove redundant parentheses Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 04/12] net/hns3: adjust the data type of some variables Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 05/12] net/hns3: fix an unreasonable memset Min Hu (Connor)
2022-05-20  7:58   ` Andrew Rybchenko
2022-05-20  8:37     ` Min Hu (Connor)
2022-05-20  8:59       ` Andrew Rybchenko
2022-05-20  9:14         ` Min Hu (Connor)
2022-05-20 10:43           ` Ferruh Yigit
2022-05-20 11:00             ` Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 06/12] net/hns3: remove duplicate definition Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 07/12] net/hns3: fix coverity codecheck Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 08/12] net/hns3: fix return value for unsupported tuple Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 09/12] net/hns3: modify a function name Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 10/12] net/hns3: unify the code wrap style Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 11/12] net/hns3: fix a segfault from secondary process Min Hu (Connor)
2022-05-19 12:29 ` [PATCH 12/12] net/hns3: fix TM capability incorrectly defined Min Hu (Connor)
2022-05-31 14:55 ` [PATCH 00/12] bugfix for hns3 PMD Andrew Rybchenko
2022-06-01  3:54   ` Min Hu (Connor)
2022-06-01  3:52 ` [PATCH v2 00/11] " Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 01/11] net/hns3: add check for deferred start queue when rollback Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 02/11] net/hns3: remove redundant parentheses Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 03/11] net/hns3: adjust the data type of some variables Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 04/11] net/hns3: fix an unreasonable memset Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 05/11] net/hns3: remove duplicate definition Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 06/11] net/hns3: fix coverity codecheck Min Hu (Connor)
2022-06-01  8:32     ` Andrew Rybchenko
2022-06-06  7:48       ` Dongdong Liu
2022-06-08 11:19         ` Andrew Rybchenko
2022-06-08 12:04           ` Dongdong Liu
2022-06-01  3:52   ` [PATCH v2 07/11] net/hns3: fix return value for unsupported tuple Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 08/11] net/hns3: modify a function name Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 09/11] net/hns3: unify the code wrap style Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 10/11] net/hns3: fix a segfault from secondary process Min Hu (Connor)
2022-06-01  3:52   ` [PATCH v2 11/11] net/hns3: fix TM capability incorrectly defined Min Hu (Connor)
2022-06-09 10:57   ` [PATCH v2 00/11] bugfix for hns3 PMD Andrew Rybchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.