Skip to contentSkip to conversation

net: hinic3: Fix netif_queue_set_napi input parameters and code styles

PATCH In review Fan Gong 2 participants 9 messages Jan 20 – Jan 21

Subsystems (4)
lore
Share & tools
lore

Fan Gong

author maintainer
#0 lore raw

cover net: hinic3: Fix netif_queue_set_napi input parameters and code styles

This patchset provides netif_queue_set_napi bug fix and serveral code styles fixes to :

Fix netif_queue_set_napi queue_index parameter passing error. Remove empty lines between error handling.
Remove redundant defensive code.
Use array_size instead of multiplying.
Sq use SQ_CTXT_PREF_CI_HI to improve readability.

Thanks,
Fan gong

Fan Gong (5):
hinic3: Fix netif_queue_set_napi queue_index parameter passing error
hinic3: Fix code Style(remove empty lines between error handling)
hinic3: Remove redundant defensive code
hinic3: Use array_size instead of multiplying
hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI

 .../net/ethernet/huawei/hinic3/hinic3_cmdq.c  |  3 ---
 .../net/ethernet/huawei/hinic3/hinic3_eqs.c   |  1 -
 .../net/ethernet/huawei/hinic3/hinic3_irq.c   | 23 +++++++++++--------
 .../net/ethernet/huawei/hinic3/hinic3_lld.c   |  5 ----
 .../net/ethernet/huawei/hinic3/hinic3_main.c  |  4 ----
 .../net/ethernet/huawei/hinic3/hinic3_mbox.c  |  2 --
 .../ethernet/huawei/hinic3/hinic3_nic_cfg.c   |  6 +++--
 .../ethernet/huawei/hinic3/hinic3_nic_io.c    |  6 ++++-
 .../net/ethernet/huawei/hinic3/hinic3_tx.c    |  7 ------
 9 files changed, 23 insertions(+), 34 deletions(-)

base-commit: 4515ec4ad58a37e70a9e1256c0b993958c9b7497

Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 1/5 hinic3: Fix netif_queue_set_napi queue_index parameter passing error

Incorrectly transmitted interrupt number instead of queue number when using netif_queue_set_napi. Besides, move this to appropriate code location.
Remove redundant netif_stop_subqueue beacuase it is not part of the hinic3_send_one_skb process.

---
 .../net/ethernet/huawei/hinic3/hinic3_irq.c   | 23 +++++++++++--------
 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_irq.c +14 -9
index 6950ee4d037b..ef3bc88e0a65 100644
@@ -63,21 +63,12 @@ static void qp_add_napi(struct hinic3_irq_cfg *irq_cfg)
 	struct hinic3_nic_dev *nic_dev = netdev_priv(irq_cfg->netdev);
 
 	netif_napi_add(nic_dev->netdev, &irq_cfg->napi, hinic3_poll);
-	netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
-			     NETDEV_QUEUE_TYPE_RX, &irq_cfg->napi);
-	netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
-			     NETDEV_QUEUE_TYPE_TX, &irq_cfg->napi);
 	napi_enable(&irq_cfg->napi);
 }
 
 static void qp_del_napi(struct hinic3_irq_cfg *irq_cfg)
 {
 	napi_disable(&irq_cfg->napi);
-	netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
-			     NETDEV_QUEUE_TYPE_RX, NULL);
-	netif_queue_set_napi(irq_cfg->netdev, irq_cfg->irq_id,
-			     NETDEV_QUEUE_TYPE_TX, NULL);
-	netif_stop_subqueue(irq_cfg->netdev, irq_cfg->irq_id);
 	netif_napi_del(&irq_cfg->napi);
 }
 
@@ -240,6 +231,11 @@ int hinic3_qps_irq_init(struct net_device *netdev)
 		INIT_WORK(&irq_cfg->rxq->dim.work, hinic3_rx_dim_work);
 		irq_cfg->rxq->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_CQE;
 
+		netif_queue_set_napi(irq_cfg->netdev, q_id,
+				     NETDEV_QUEUE_TYPE_RX, &irq_cfg->napi);
+		netif_queue_set_napi(irq_cfg->netdev, q_id,
+				     NETDEV_QUEUE_TYPE_TX, &irq_cfg->napi);
+
 		hinic3_set_msix_auto_mask_state(nic_dev->hwdev,
 						irq_cfg->msix_entry_idx,
 						HINIC3_SET_MSIX_AUTO_MASK);
@@ -254,6 +250,10 @@ int hinic3_qps_irq_init(struct net_device *netdev)
 		q_id--;
 		irq_cfg = &nic_dev->q_params.irq_cfg[q_id];
 		qp_del_napi(irq_cfg);
+		netif_queue_set_napi(irq_cfg->netdev, q_id,
+				     NETDEV_QUEUE_TYPE_RX, NULL);
+		netif_queue_set_napi(irq_cfg->netdev, q_id,
+				     NETDEV_QUEUE_TYPE_TX, NULL);
 
 		hinic3_set_msix_state(nic_dev->hwdev, irq_cfg->msix_entry_idx,
 				      HINIC3_MSIX_DISABLE);
@@ -276,6 +276,11 @@ void hinic3_qps_irq_uninit(struct net_device *netdev)
 	for (q_id = 0; q_id < nic_dev->q_params.num_qps; q_id++) {
 		irq_cfg = &nic_dev->q_params.irq_cfg[q_id];
 		qp_del_napi(irq_cfg);
+		netif_queue_set_napi(irq_cfg->netdev, q_id,
+				     NETDEV_QUEUE_TYPE_RX, NULL);
+		netif_queue_set_napi(irq_cfg->netdev, q_id,
+				     NETDEV_QUEUE_TYPE_TX, NULL);
+
 		hinic3_set_msix_state(nic_dev->hwdev, irq_cfg->msix_entry_idx,
 				      HINIC3_MSIX_DISABLE);
 		hinic3_set_msix_auto_mask_state(nic_dev->hwdev,
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH 2/5 hinic3: Fix code Style(remove empty lines between error handling)

In reply to Fan Gong

Fix code style of removing empty lines between the actions on the error handling path.

---
 drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c | 3 ---
 drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c  | 1 -
 drivers/net/ethernet/huawei/hinic3/hinic3_lld.c  | 5 -----
 drivers/net/ethernet/huawei/hinic3/hinic3_main.c | 4 ----
 drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 2 --
 drivers/net/ethernet/huawei/hinic3/hinic3_tx.c   | 1 -
 6 files changed, 16 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c +0 -3
index ef539d1b69a3..86720bb119e9 100644
@@ -878,14 +878,11 @@ int hinic3_cmdqs_init(struct hinic3_hwdev *hwdev)
 	}
 
 	hinic3_free_db_addr(hwdev, cmdqs->cmdqs_db_base);
-
 err_destroy_cmdq_wq:
 	destroy_cmdq_wq(hwdev, cmdqs);
-
 err_free_cmdqs:
 	dma_pool_destroy(cmdqs->cmd_buf_pool);
 	kfree(cmdqs);
-
 err_out:
 	return err;
 }
drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c +0 -1
index 1ecc2aca1e35..a2c3962116d5 100644
@@ -686,7 +686,6 @@ int hinic3_aeqs_init(struct hinic3_hwdev *hwdev, u16 num_aeqs,
 	}
 
 	destroy_workqueue(aeqs->workq);
-
 err_free_aeqs:
 	kfree(aeqs);
 
drivers/net/ethernet/huawei/hinic3/hinic3_lld.c +0 -5
index 2b77fea1e0b3..87413e192f10 100644
@@ -230,7 +230,6 @@ static int hinic3_mapping_bar(struct pci_dev *pdev,
 		iounmap(pci_adapter->mgmt_reg_base);
 err_unmap_intr_reg_base:
 	iounmap(pci_adapter->intr_reg_base);
-
 err_unmap_cfg_reg_base:
 	iounmap(pci_adapter->cfg_reg_base);
 
@@ -285,10 +284,8 @@ static int hinic3_pci_init(struct pci_dev *pdev)
 err_release_regions:
 	pci_clear_master(pdev);
 	pci_release_regions(pdev);
-
 err_disable_device:
 	pci_disable_device(pdev);
-
 err_free_pci_adapter:
 	pci_set_drvdata(pdev, NULL);
 	mutex_destroy(&pci_adapter->pdev_mutex);
@@ -382,7 +379,6 @@ static int hinic3_probe_func(struct hinic3_pcidev *pci_adapter)
 	hinic3_func_uninit(pdev);
 err_unmap_bar:
 	hinic3_unmapping_bar(pci_adapter);
-
 err_out:
 	dev_err(&pdev->dev, "PCIe device probe function failed\n");
 
@@ -415,7 +411,6 @@ static int hinic3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 err_uninit_pci:
 	hinic3_pci_uninit(pdev);
-
 err_out:
 	dev_err(&pdev->dev, "PCIe device probe failed\n");
 
drivers/net/ethernet/huawei/hinic3/hinic3_main.c +0 -4
index a33f86675954..6275d94dfefd 100644
@@ -104,7 +104,6 @@ static int hinic3_alloc_txrxqs(struct net_device *netdev)
 
 err_free_rxqs:
 	hinic3_free_rxqs(netdev);
-
 err_free_txqs:
 	hinic3_free_txqs(netdev);
 
@@ -475,17 +474,14 @@ static int hinic3_nic_probe(struct auxiliary_device *adev,
 	disable_delayed_work_sync(&nic_dev->periodic_work);
 	hinic3_update_nic_feature(nic_dev, 0);
 	hinic3_set_nic_feature_to_hw(nic_dev);
-
 err_uninit_sw:
 	hinic3_sw_uninit(netdev);
-
 err_free_nic_io:
 	hinic3_free_nic_io(nic_dev);
 err_free_nic_dev:
 	hinic3_free_nic_dev(nic_dev);
 err_free_netdev:
 	free_netdev(netdev);
-
 err_unregister_adev_event:
 	hinic3_adev_event_unregister(adev);
 	dev_err(&pdev->dev, "NIC service probe failed\n");
drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c +0 -2
index 6eb441d6a590..c871fd0fb109 100644
@@ -446,10 +446,8 @@ int hinic3_init_mbox(struct hinic3_hwdev *hwdev)
 		hinic3_uninit_func_mbox_msg_channel(hwdev);
 err_uninit_mgmt_msg_ch:
 	uninit_mgmt_msg_channel(mbox);
-
 err_destroy_workqueue:
 	destroy_workqueue(mbox->workq);
-
 err_free_mbox:
 	kfree(mbox);
 
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +0 -1
index ef32aed7d761..4e361c9bd043 100644
@@ -609,7 +609,6 @@ static netdev_tx_t hinic3_send_one_skb(struct sk_buff *skb,
 
 err_drop_pkt:
 	dev_kfree_skb_any(skb);
-
 err_out:
 	return NETDEV_TX_OK;
 }
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH 3/5 hinic3: Remove redundant defensive code

In reply to Fan Gong

According to comment of patch 03, check codes that were merged and remove redundant defensive codes.

---
 drivers/net/ethernet/huawei/hinic3/hinic3_tx.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_tx.c +0 -6
index 4e361c9bd043..6d3dc930ca97 100644
@@ -44,16 +44,10 @@ static void hinic3_txq_stats_init(struct hinic3_txq *txq)
 int hinic3_alloc_txqs(struct net_device *netdev)
 {
 	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
-	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
 	u16 q_id, num_txqs = nic_dev->max_qps;
 	struct pci_dev *pdev = nic_dev->pdev;
 	struct hinic3_txq *txq;
 
-	if (!num_txqs) {
-		dev_err(hwdev->dev, "Cannot allocate zero size txqs\n");
-		return -EINVAL;
-	}
-
 	nic_dev->txqs = kcalloc(num_txqs, sizeof(*nic_dev->txqs),  GFP_KERNEL);
 	if (!nic_dev->txqs)
 		return -ENOMEM;
Signature · 1 line
2.43.0
author maintainer
#4 lore raw

PATCH 4/5 hinic3: Use array_size instead of multiplying

In reply to Fan Gong

According to comment of patch 03, check codes that were merged and use array_size instead of multiplying.

---
 drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.c +4 -2
index b6cc7bb7bb0c..44abccf9cb29 100644
@@ -23,7 +23,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
 	feature_nego.func_id = hinic3_global_func_id(hwdev);
 	feature_nego.opcode = opcode;
 	if (opcode == MGMT_MSG_CMD_OP_SET)
-		memcpy(feature_nego.s_feature, s_feature, size * sizeof(u64));
+		memcpy(feature_nego.s_feature, s_feature,
+		       array_size(size, sizeof(u64)));
 
 	mgmt_msg_params_init_default(&msg_params, &feature_nego,
 				     sizeof(feature_nego));
@@ -37,7 +38,8 @@ static int hinic3_feature_nego(struct hinic3_hwdev *hwdev, u8 opcode,
 	}
 
 	if (opcode == MGMT_MSG_CMD_OP_GET)
-		memcpy(s_feature, feature_nego.s_feature, size * sizeof(u64));
+		memcpy(s_feature, feature_nego.s_feature,
+		       array_size(size, sizeof(u64)));
 
 	return 0;
 }
Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH 5/5 hinic3: RQ use RQ_CTXT_PREF_CI_HI instead of SQ_CTXT_PREF_CI_HI

In reply to Fan Gong

Separate the CTX_PREF_CI_HI of rq and sq to improve readability.

---
 drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c +5 -1
index d86cd1ba4605..90887d2bb127 100644
@@ -162,6 +162,9 @@ struct hinic3_clean_queue_ctxt {
 #define SQ_CTXT_WQ_BLOCK_SET(val, member)  \
 	FIELD_PREP(SQ_CTXT_WQ_BLOCK_##member##_MASK, val)
 
+/* reuse SQ macro for RQ because the hardware format is identical */
+#define RQ_CTXT_PREF_CI_HI(val)            SQ_CTXT_PREF_CI_HI(val)
+
 #define RQ_CTXT_PI_IDX_MASK                GENMASK(15, 0)
 #define RQ_CTXT_CI_IDX_MASK                GENMASK(31, 16)
 #define RQ_CTXT_CI_PI_SET(val, member)  \
@@ -629,7 +632,8 @@ static void hinic3_rq_prepare_ctxt(struct hinic3_io_queue *rq,
 			    RQ_CTXT_PREF_SET(RQ_WQ_PREFETCH_THRESHOLD, CACHE_THRESHOLD));
 
 	rq_ctxt->pref_ci_owner =
-		cpu_to_le32(RQ_CTXT_PREF_SET(SQ_CTXT_PREF_CI_HI(ci_start), CI_HI) |
+		cpu_to_le32(RQ_CTXT_PREF_SET(RQ_CTXT_PREF_CI_HI(ci_start),
+					     CI_HI) |
 			    RQ_CTXT_PREF_SET(1, OWNER));
 
 	rq_ctxt->pref_wq_pfn_hi_ci =
Signature · 1 line
2.43.0
author maintainer
#6 lore raw
In reply to Fan Gong

Sorry for choosing the wrong branch. We should send to net-next instead of net. We'll send a new patchset to net-next soon.

Thanks,
Fan gong

maintainer
#7 lore raw
In reply to Fan Gong
Quoted 8 lines · On Tue, 20 Jan 2026 20:38:38 +0800 Fan Gong wrote:

This patchset provides netif_queue_set_napi bug fix and serveral code styles fixes to :

Fix netif_queue_set_napi queue_index parameter passing error. Remove empty lines between error handling.
Remove redundant defensive code.
Use array_size instead of multiplying.
Sq use SQ_CTXT_PREF_CI_HI to improve readability.

no reposts within 24h please
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html

Signature · 1 line
pv-bot: 24h
author maintainer
#8 lore raw
Quoted 4 lines · Jakub Kicinski
Quoted 3 lines · On Tue, 20 Jan 2026 20:38:38 +0800 Fan Gong wrote:

This patchset provides netif_queue_set_napi bug fix and serveral code styles fixes to :

Quoted 8 lines
Quoted 5 lines

Fix netif_queue_set_napi queue_index parameter passing error. Remove empty lines between error handling.
Remove redundant defensive code.
Use array_size instead of multiplying.
Sq use SQ_CTXT_PREF_CI_HI to improve readability.

no reposts within 24h please
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html

Sorry for reposting and incorrectly confusing net and net-next. We will send a new patchset tomorrow and add Fixed tag in patchs for fixes.