linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver
@ 2025-06-17  1:02 Jijie Shao
  2025-06-17  1:02 ` [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num" Jijie Shao
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

There are some cleanup for hns3 driver

---
ChangeLog:
v1 -> v2:
  - Change commit message and title, suggested by Michal Swiatkowski.
  v1: https://lore.kernel.org/all/20250612021317.1487943-1-shaojijie@huawei.com/
---

Jian Shen (1):
  net: hns3: set the freed pointers to NULL when lifetime is not end

Jijie Shao (4):
  net: hns3: fix spelling mistake "reg_um" -> "reg_num"
  net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary
    middle layer conversion
  net: hns3: use hns3_get_ops() helper to reduce the unnecessary middle
    layer conversion
  net: hns3: add complete parentheses for some macros

Peiyang Wang (2):
  net: hns3: add \n at the end when print msg
  net: hns3: clear hns alarm: comparison of integer expressions of
    different signedness

Yonglong Liu (1):
  net: hns3: delete redundant address before the array

 .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    | 10 +--
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 38 +++++-----
 .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  4 +-
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 75 ++++++++++---------
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 15 ++--
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 38 +++++-----
 .../hisilicon/hns3/hns3pf/hclge_mbx.c         |  7 +-
 .../hisilicon/hns3/hns3pf/hclge_mdio.c        |  2 +-
 .../hisilicon/hns3/hns3pf/hclge_ptp.h         |  2 +-
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  8 +-
 .../hisilicon/hns3/hns3vf/hclgevf_mbx.c       |  2 +-
 .../hisilicon/hns3/hns3vf/hclgevf_regs.c      | 27 +++----
 13 files changed, 120 insertions(+), 110 deletions(-)

-- 
2.33.0


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

* [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num"
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-18 10:55   ` Simon Horman
  2025-06-17  1:02 ` [PATCH V2 net-next 2/8] net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary middle layer conversion Jijie Shao
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

There are spelling mistakes in hclgevf_get_regs. Fix them.

Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 .../hisilicon/hns3/hns3vf/hclgevf_regs.c      | 27 ++++++++++---------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
index 7d9d9dbc7560..9de01e344e27 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_regs.c
@@ -127,37 +127,38 @@ void hclgevf_get_regs(struct hnae3_handle *handle, u32 *version,
 
 	struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
 	struct hnae3_queue *tqp;
-	int i, j, reg_um;
+	int i, j, reg_num;
 	u32 *reg = data;
 
 	*version = hdev->fw_version;
 	reg += hclgevf_reg_get_header(reg);
 
 	/* fetching per-VF registers values from VF PCIe register space */
-	reg_um = ARRAY_SIZE(cmdq_reg_addr_list);
-	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_CMDQ, reg_um, reg);
-	for (i = 0; i < reg_um; i++)
+	reg_num = ARRAY_SIZE(cmdq_reg_addr_list);
+	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_CMDQ, reg_num, reg);
+	for (i = 0; i < reg_num; i++)
 		*reg++ = hclgevf_read_dev(&hdev->hw, cmdq_reg_addr_list[i]);
 
-	reg_um = ARRAY_SIZE(common_reg_addr_list);
-	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_COMMON, reg_um, reg);
-	for (i = 0; i < reg_um; i++)
+	reg_num = ARRAY_SIZE(common_reg_addr_list);
+	reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_COMMON, reg_num, reg);
+	for (i = 0; i < reg_num; i++)
 		*reg++ = hclgevf_read_dev(&hdev->hw, common_reg_addr_list[i]);
 
-	reg_um = ARRAY_SIZE(ring_reg_addr_list);
+	reg_num = ARRAY_SIZE(ring_reg_addr_list);
 	for (j = 0; j < hdev->num_tqps; j++) {
-		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_RING, reg_um, reg);
+		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_RING, reg_num, reg);
 		tqp = &hdev->htqp[j].q;
-		for (i = 0; i < reg_um; i++)
+		for (i = 0; i < reg_num; i++)
 			*reg++ = readl_relaxed(tqp->io_base -
 					       HCLGEVF_TQP_REG_OFFSET +
 					       ring_reg_addr_list[i]);
 	}
 
-	reg_um = ARRAY_SIZE(tqp_intr_reg_addr_list);
+	reg_num = ARRAY_SIZE(tqp_intr_reg_addr_list);
 	for (j = 0; j < hdev->num_msi_used - 1; j++) {
-		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_TQP_INTR, reg_um, reg);
-		for (i = 0; i < reg_um; i++)
+		reg += hclgevf_reg_get_tlv(HCLGEVF_REG_TAG_TQP_INTR,
+					   reg_num, reg);
+		for (i = 0; i < reg_num; i++)
 			*reg++ = hclgevf_read_dev(&hdev->hw,
 						  tqp_intr_reg_addr_list[i] +
 						  HCLGEVF_RING_INT_REG_OFFSET * j);
-- 
2.33.0


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

* [PATCH V2 net-next 2/8] net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary middle layer conversion
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
  2025-06-17  1:02 ` [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num" Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-17 14:15   ` Michal Swiatkowski
  2025-06-17  1:02 ` [PATCH V2 net-next 3/8] net: hns3: use hns3_get_ops() " Jijie Shao
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

There are too many indirection layers in the HNS3 driver code.
This issue was previously discussed with the maintainer,
who suggested adding a helper function to fix the issue.
In fact, the hns3_get_ae_dev() helper is already defined
and can fix this issue.

This patch uses hns3_get_ae_dev() helper to reduce the unnecessary
middle layer conversion. Apply it to the whole HNS3 driver.
The former discusstion can be checked from the link.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230310081404.947-1-lanhao@huawei.com/
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
ChangeLog:
v1 -> v2:
  - Change commit message and title, suggested by Michal Swiatkowski.
  v1: https://lore.kernel.org/all/20250612021317.1487943-1-shaojijie@huawei.com/
---
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  8 ++---
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 12 +++----
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 36 +++++++++----------
 3 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 4e5d8bc39a1b..4f6ed7c7ee68 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -684,7 +684,7 @@ static int hns3_dbg_rx_queue_info(struct hnae3_handle *h,
 				  char *buf, int len)
 {
 	char data_str[ARRAY_SIZE(rx_queue_info_items)][HNS3_DBG_DATA_STR_LEN];
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	char *result[ARRAY_SIZE(rx_queue_info_items)];
 	struct hns3_nic_priv *priv = h->priv;
 	char content[HNS3_DBG_INFO_LEN];
@@ -789,7 +789,7 @@ static int hns3_dbg_tx_queue_info(struct hnae3_handle *h,
 				  char *buf, int len)
 {
 	char data_str[ARRAY_SIZE(tx_queue_info_items)][HNS3_DBG_DATA_STR_LEN];
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	char *result[ARRAY_SIZE(tx_queue_info_items)];
 	struct hns3_nic_priv *priv = h->priv;
 	char content[HNS3_DBG_INFO_LEN];
@@ -1034,7 +1034,7 @@ static int hns3_dbg_tx_bd_info(struct hns3_dbg_data *d, char *buf, int len)
 static void
 hns3_dbg_dev_caps(struct hnae3_handle *h, char *buf, int len, int *pos)
 {
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	unsigned long *caps = ae_dev->caps;
 	u32 i, state;
 
@@ -1364,7 +1364,7 @@ hns3_dbg_common_file_init(struct hnae3_handle *handle, u32 cmd)
 
 int hns3_dbg_init(struct hnae3_handle *handle)
 {
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const char *name = pci_name(handle->pdev);
 	int ret;
 	u32 i;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 5c8c62ea6ac0..6babc636145b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -547,9 +547,9 @@ void hns3_set_vector_coalesce_rx_ql(struct hns3_enet_tqp_vector *tqp_vector,
 static void hns3_vector_coalesce_init(struct hns3_enet_tqp_vector *tqp_vector,
 				      struct hns3_nic_priv *priv)
 {
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
 	struct hns3_enet_coalesce *tx_coal = &tqp_vector->tx_group.coal;
 	struct hns3_enet_coalesce *rx_coal = &tqp_vector->rx_group.coal;
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
 	struct hns3_enet_coalesce *ptx_coal = &priv->tx_coal;
 	struct hns3_enet_coalesce *prx_coal = &priv->rx_coal;
 
@@ -1304,7 +1304,7 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
 static bool hns3_tunnel_csum_bug(struct sk_buff *skb)
 {
 	struct hns3_nic_priv *priv = netdev_priv(skb->dev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
 	union l4_hdr_info l4;
 
 	/* device version above V3(include V3), the hardware can
@@ -1504,7 +1504,7 @@ static int hns3_handle_vtags(struct hns3_enet_ring *tx_ring,
 	 * VLAN enabled, only one VLAN header is allowed in skb, otherwise it
 	 * will cause RAS error.
 	 */
-	ae_dev = pci_get_drvdata(handle->pdev);
+	ae_dev = hns3_get_ae_dev(handle);
 	if (unlikely(skb_vlan_tagged_multi(skb) &&
 		     ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2 &&
 		     handle->port_base_vlan_state ==
@@ -4747,7 +4747,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
 
 static void hns3_nic_init_coal_cfg(struct hns3_nic_priv *priv)
 {
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
 	struct hns3_enet_coalesce *tx_coal = &priv->tx_coal;
 	struct hns3_enet_coalesce *rx_coal = &priv->rx_coal;
 
@@ -5226,7 +5226,7 @@ static void hns3_info_show(struct hns3_nic_priv *priv)
 static void hns3_set_cq_period_mode(struct hns3_nic_priv *priv,
 				    enum dim_cq_period_mode mode, bool is_tx)
 {
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
 	struct hnae3_handle *handle = priv->ae_handle;
 	int i;
 
@@ -5264,7 +5264,7 @@ void hns3_cq_period_mode_init(struct hns3_nic_priv *priv,
 
 static void hns3_state_init(struct hnae3_handle *handle)
 {
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	struct net_device *netdev = handle->kinfo.netdev;
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 6715222aeb66..ae220f49df64 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -86,7 +86,7 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset);
 static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
 {
 	struct hnae3_handle *h = hns3_get_handle(ndev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	int ret;
 
 	if (!h->ae_algo->ops->set_loopback ||
@@ -171,7 +171,7 @@ static void hns3_lp_setup_skb(struct sk_buff *skb)
 	 * the purpose of mac or serdes selftest.
 	 */
 	handle = hns3_get_handle(ndev);
-	ae_dev = pci_get_drvdata(handle->pdev);
+	ae_dev = hns3_get_ae_dev(handle);
 	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
 		ethh->h_dest[5] += HNS3_NIC_LB_DST_MAC_ADDR;
 	eth_zero_addr(ethh->h_source);
@@ -692,7 +692,7 @@ static void hns3_get_pauseparam(struct net_device *netdev,
 				struct ethtool_pauseparam *param)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 
 	if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps))
 		return;
@@ -706,7 +706,7 @@ static int hns3_set_pauseparam(struct net_device *netdev,
 			       struct ethtool_pauseparam *param)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 
 	if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps))
 		return -EOPNOTSUPP;
@@ -751,7 +751,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 				   struct ethtool_link_ksettings *cmd)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	const struct hnae3_ae_ops *ops;
 	u8 module_type;
 	u8 media_type;
@@ -861,7 +861,7 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
 				   const struct ethtool_link_ksettings *cmd)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 	int ret;
 
@@ -932,7 +932,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev)
 static u32 hns3_get_rss_indir_size(struct net_device *netdev)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 
 	return ae_dev->dev_specs.rss_ind_tbl_size;
 }
@@ -954,7 +954,7 @@ static int hns3_set_rss(struct net_device *netdev,
 			struct netlink_ext_ack *extack)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 
 	if (!h->ae_algo->ops->set_rss)
 		return -EOPNOTSUPP;
@@ -1024,7 +1024,7 @@ static int hns3_set_reset(struct net_device *netdev, u32 *flags)
 {
 	enum hnae3_reset_type rst_type = HNAE3_NONE_RESET;
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	const struct hnae3_ae_ops *ops = h->ae_algo->ops;
 	const struct hns3_reset_type_map *rst_type_map;
 	enum ethtool_reset_flags rst_flags;
@@ -1189,7 +1189,7 @@ static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push)
 {
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
 	u32 old_state = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
 
 	if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps) && tx_push)
@@ -1377,7 +1377,7 @@ static int hns3_check_gl_coalesce_para(struct net_device *netdev,
 				       struct ethtool_coalesce *cmd)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	u32 rx_gl, tx_gl;
 
 	if (cmd->rx_coalesce_usecs > ae_dev->dev_specs.max_int_gl) {
@@ -1449,7 +1449,7 @@ static int hns3_check_ql_coalesce_param(struct net_device *netdev,
 					struct ethtool_coalesce *cmd)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 
 	if ((cmd->tx_max_coalesced_frames || cmd->rx_max_coalesced_frames) &&
 	    !ae_dev->dev_specs.int_ql_max) {
@@ -1473,7 +1473,7 @@ hns3_check_cqe_coalesce_param(struct net_device *netdev,
 			      struct kernel_ethtool_coalesce *kernel_coal)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 
 	if ((kernel_coal->use_cqe_mode_tx || kernel_coal->use_cqe_mode_rx) &&
 	    !hnae3_ae_dev_cq_supported(ae_dev)) {
@@ -1649,7 +1649,7 @@ static void hns3_get_fec_stats(struct net_device *netdev,
 			       struct ethtool_fec_stats *fec_stats)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 
 	if (!hnae3_ae_dev_fec_stats_supported(ae_dev) || !ops->get_fec_stats)
@@ -1700,7 +1700,7 @@ static int hns3_get_fecparam(struct net_device *netdev,
 			     struct ethtool_fecparam *fec)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 	u8 fec_ability;
 	u8 fec_mode;
@@ -1725,7 +1725,7 @@ static int hns3_set_fecparam(struct net_device *netdev,
 			     struct ethtool_fecparam *fec)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 	u32 fec_mode;
 
@@ -1747,7 +1747,7 @@ static int hns3_get_module_info(struct net_device *netdev,
 #define HNS3_SFF_8636_V1_3 0x03
 
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 	struct hns3_sfp_type sfp_type;
 	int ret;
@@ -1797,7 +1797,7 @@ static int hns3_get_module_eeprom(struct net_device *netdev,
 				  struct ethtool_eeprom *ee, u8 *data)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
+	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 
 	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2 ||
-- 
2.33.0


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

* [PATCH V2 net-next 3/8] net: hns3: use hns3_get_ops() helper to reduce the unnecessary middle layer conversion
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
  2025-06-17  1:02 ` [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num" Jijie Shao
  2025-06-17  1:02 ` [PATCH V2 net-next 2/8] net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary middle layer conversion Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-17 14:12   ` Michal Swiatkowski
  2025-06-17  1:02 ` [PATCH V2 net-next 4/8] net: hns3: add \n at the end when print msg Jijie Shao
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

There are too many indirection layers in the HNS3 driver code,
This issue was previously discussed with the maintainer,
who suggested adding a helper function to fix the issue.
In fact, the hns3_get_ops() helper is already defined
and can fix this issue.

This patch uses hns3_get_ops() helper to reduce the unnecessary
middle layer conversion. Apply it to the whole HNS3 driver.
The former discusstion can be checked from the link.

Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230310081404.947-1-lanhao@huawei.com/
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
ChangeLog:
v1 -> v2:
  - Change commit message and title, suggested by Michal Swiatkowski.
  v1: https://lore.kernel.org/all/20250612021317.1487943-1-shaojijie@huawei.com/
---
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   |  2 +-
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 24 +++++++++----------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 4f6ed7c7ee68..35e57eebcf57 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -1239,7 +1239,7 @@ static const struct hns3_dbg_func hns3_dbg_cmd_func[] = {
 static int hns3_dbg_read_cmd(struct hns3_dbg_data *dbg_data,
 			     enum hnae3_dbg_cmd cmd, char *buf, int len)
 {
-	const struct hnae3_ae_ops *ops = dbg_data->handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(dbg_data->handle);
 	const struct hns3_dbg_func *cmd_func;
 	u32 i;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 6babc636145b..208a2dfc07ec 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -960,7 +960,7 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev)
 
 void hns3_request_update_promisc_mode(struct hnae3_handle *handle)
 {
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 
 	if (ops->request_update_promisc_mode)
 		ops->request_update_promisc_mode(handle);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index ae220f49df64..5e01dd55d660 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -489,7 +489,7 @@ static const struct hns3_pflag_desc hns3_priv_flags[HNAE3_PFLAG_MAX] = {
 static int hns3_get_sset_count(struct net_device *netdev, int stringset)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	const struct hnae3_ae_ops *ops = h->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(h);
 
 	if (!ops->get_sset_count)
 		return -EOPNOTSUPP;
@@ -540,7 +540,7 @@ static void hns3_get_strings_tqps(struct hnae3_handle *handle, u8 **data)
 static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
-	const struct hnae3_ae_ops *ops = h->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(h);
 	int i;
 
 	if (!ops->get_strings)
@@ -725,7 +725,7 @@ static int hns3_set_pauseparam(struct net_device *netdev,
 static void hns3_get_ksettings(struct hnae3_handle *h,
 			       struct ethtool_link_ksettings *cmd)
 {
-	const struct hnae3_ae_ops *ops = h->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(h);
 
 	/* 1.auto_neg & speed & duplex from cmd */
 	if (ops->get_ksettings_an_result)
@@ -814,7 +814,7 @@ static int hns3_check_ksettings_param(const struct net_device *netdev,
 				      const struct ethtool_link_ksettings *cmd)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 	u8 module_type = HNAE3_MODULE_TYPE_UNKNOWN;
 	u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
 	u32 lane_num;
@@ -862,7 +862,7 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 	int ret;
 
 	/* Chip don't support this mode. */
@@ -1025,7 +1025,7 @@ static int hns3_set_reset(struct net_device *netdev, u32 *flags)
 	enum hnae3_reset_type rst_type = HNAE3_NONE_RESET;
 	struct hnae3_handle *h = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
-	const struct hnae3_ae_ops *ops = h->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(h);
 	const struct hns3_reset_type_map *rst_type_map;
 	enum ethtool_reset_flags rst_flags;
 	u32 i, size;
@@ -1300,7 +1300,7 @@ static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 static int hns3_nway_reset(struct net_device *netdev)
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 	struct phy_device *phy = netdev->phydev;
 	int autoneg;
 
@@ -1650,7 +1650,7 @@ static void hns3_get_fec_stats(struct net_device *netdev,
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 
 	if (!hnae3_ae_dev_fec_stats_supported(ae_dev) || !ops->get_fec_stats)
 		return;
@@ -1701,7 +1701,7 @@ static int hns3_get_fecparam(struct net_device *netdev,
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 	u8 fec_ability;
 	u8 fec_mode;
 
@@ -1726,7 +1726,7 @@ static int hns3_set_fecparam(struct net_device *netdev,
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 	u32 fec_mode;
 
 	if (!test_bit(HNAE3_DEV_SUPPORT_FEC_B, ae_dev->caps))
@@ -1748,7 +1748,7 @@ static int hns3_get_module_info(struct net_device *netdev,
 
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 	struct hns3_sfp_type sfp_type;
 	int ret;
 
@@ -1798,7 +1798,7 @@ static int hns3_get_module_eeprom(struct net_device *netdev,
 {
 	struct hnae3_handle *handle = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
-	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
+	const struct hnae3_ae_ops *ops = hns3_get_ops(handle);
 
 	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2 ||
 	    !ops->get_module_eeprom)
-- 
2.33.0


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

* [PATCH V2 net-next 4/8] net: hns3: add \n at the end when print msg
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
                   ` (2 preceding siblings ...)
  2025-06-17  1:02 ` [PATCH V2 net-next 3/8] net: hns3: use hns3_get_ops() " Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-18 10:57   ` Simon Horman
  2025-06-17  1:02 ` [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end Jijie Shao
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

From: Peiyang Wang <wangpeiyang1@huawei.com>

To make the print message more clearly, add \n at the and of message if
it is missing currently.

Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c        |  2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c     | 10 +++++-----
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c    |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 208a2dfc07ec..dc1e15926482 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2447,7 +2447,7 @@ static int hns3_nic_set_features(struct net_device *netdev,
 	if ((netdev->features & NETIF_F_HW_TC) > (features & NETIF_F_HW_TC) &&
 	    h->ae_algo->ops->cls_flower_active(h)) {
 		netdev_err(netdev,
-			   "there are offloaded TC filters active, cannot disable HW TC offload");
+			   "there are offloaded TC filters active, cannot disable HW TC offload\n");
 		return -EINVAL;
 	}
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 5e01dd55d660..6a244ba5e051 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -436,7 +436,7 @@ static void hns3_self_test(struct net_device *ndev,
 		data[i] = HNS3_NIC_LB_TEST_UNEXECUTED;
 
 	if (hns3_nic_resetting(ndev)) {
-		netdev_err(ndev, "dev resetting!");
+		netdev_err(ndev, "dev resetting!\n");
 		goto failure;
 	}
 
@@ -794,7 +794,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 		break;
 	default:
 
-		netdev_warn(netdev, "Unknown media type");
+		netdev_warn(netdev, "Unknown media type\n");
 		return 0;
 	}
 
@@ -842,7 +842,7 @@ static int hns3_check_ksettings_param(const struct net_device *netdev,
 	if (cmd->base.duplex == DUPLEX_HALF &&
 	    media_type != HNAE3_MEDIA_TYPE_COPPER) {
 		netdev_err(netdev,
-			   "only copper port supports half duplex!");
+			   "only copper port supports half duplex!\n");
 		return -EINVAL;
 	}
 
@@ -1308,7 +1308,7 @@ static int hns3_nway_reset(struct net_device *netdev)
 		return 0;
 
 	if (hns3_nic_resetting(netdev)) {
-		netdev_err(netdev, "dev resetting!");
+		netdev_err(netdev, "dev resetting!\n");
 		return -EBUSY;
 	}
 
@@ -1924,7 +1924,7 @@ static int hns3_set_tunable(struct net_device *netdev,
 	int i, ret = 0;
 
 	if (hns3_nic_resetting(netdev) || !priv->ring) {
-		netdev_err(netdev, "failed to set tunable value, dev resetting!");
+		netdev_err(netdev, "failed to set tunable value, dev resetting!\n");
 		return -EBUSY;
 	}
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index a5b480d59fbf..e0a2ca21ee46 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -11423,7 +11423,7 @@ static int hclge_pci_init(struct hclge_dev *hdev)
 		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 		if (ret) {
 			dev_err(&pdev->dev,
-				"can't set consistent PCI DMA");
+				"can't set consistent PCI DMA\n");
 			goto err_disable_device;
 		}
 		dev_warn(&pdev->dev, "set DMA mask to 32 bits\n");
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index c4f35e8e2177..e3f86638540b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -2625,7 +2625,7 @@ static int hclgevf_pci_init(struct hclgevf_dev *hdev)
 
 	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
 	if (ret) {
-		dev_err(&pdev->dev, "can't set consistent PCI DMA, exiting");
+		dev_err(&pdev->dev, "can't set consistent PCI DMA, exiting\n");
 		goto err_disable_device;
 	}
 
-- 
2.33.0


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

* [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
                   ` (3 preceding siblings ...)
  2025-06-17  1:02 ` [PATCH V2 net-next 4/8] net: hns3: add \n at the end when print msg Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-18 11:12   ` Simon Horman
  2025-06-17  1:02 ` [PATCH V2 net-next 6/8] net: hns3: delete redundant address before the array Jijie Shao
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

From: Jian Shen <shenjian15@huawei.com>

There are several pointers are freed but not set to NULL,
and their lifetime is not end immediately. To avoid misusing
there wild pointers, set them to NULL.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c        | 1 +
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 4 ++++
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 6a244ba5e051..0d6db46db5ed 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -276,6 +276,7 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
 			good_cnt++;
 		} else {
 			kfree_skb(skb);
+			skb = NULL;
 			netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n",
 				   tx_ret);
 		}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index e0a2ca21ee46..9d7c9523c9e1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -5208,6 +5208,7 @@ static void hclge_fd_free_node(struct hclge_dev *hdev,
 {
 	hlist_del(&rule->rule_node);
 	kfree(rule);
+	rule = NULL;
 	hclge_sync_fd_state(hdev);
 }
 
@@ -5232,6 +5233,7 @@ static void hclge_update_fd_rule_node(struct hclge_dev *hdev,
 		new_rule->rule_node.pprev = old_rule->rule_node.pprev;
 		memcpy(old_rule, new_rule, sizeof(*old_rule));
 		kfree(new_rule);
+		new_rule = NULL;
 		break;
 	case HCLGE_FD_DELETED:
 		hclge_fd_dec_rule_cnt(hdev, old_rule->location);
@@ -8521,6 +8523,7 @@ static void hclge_update_mac_node(struct hclge_mac_node *mac_node,
 		if (mac_node->state == HCLGE_MAC_TO_ADD) {
 			list_del(&mac_node->node);
 			kfree(mac_node);
+			mac_node = NULL;
 		} else {
 			mac_node->state = HCLGE_MAC_TO_DEL;
 		}
@@ -9151,6 +9154,7 @@ static void hclge_uninit_vport_mac_list(struct hclge_vport *vport,
 		case HCLGE_MAC_TO_ADD:
 			list_del(&mac_node->node);
 			kfree(mac_node);
+			mac_node = NULL;
 			break;
 		}
 	}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index e3f86638540b..3ffd47b30ad3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -933,6 +933,7 @@ static void hclgevf_update_mac_node(struct hclgevf_mac_addr_node *mac_node,
 		if (mac_node->state == HCLGEVF_MAC_TO_ADD) {
 			list_del(&mac_node->node);
 			kfree(mac_node);
+			mac_node = NULL;
 		} else {
 			mac_node->state = HCLGEVF_MAC_TO_DEL;
 		}
@@ -2395,6 +2396,7 @@ static int hclgevf_init_msi(struct hclgevf_dev *hdev)
 					sizeof(int), GFP_KERNEL);
 	if (!hdev->vector_irq) {
 		devm_kfree(&pdev->dev, hdev->vector_status);
+		hdev->vector_status = NULL;
 		pci_free_irq_vectors(pdev);
 		return -ENOMEM;
 	}
@@ -2408,6 +2410,8 @@ static void hclgevf_uninit_msi(struct hclgevf_dev *hdev)
 
 	devm_kfree(&pdev->dev, hdev->vector_status);
 	devm_kfree(&pdev->dev, hdev->vector_irq);
+	hdev->vector_status = NULL;
+	hdev->vector_irq = NULL;
 	pci_free_irq_vectors(pdev);
 }
 
-- 
2.33.0


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

* [PATCH V2 net-next 6/8] net: hns3: delete redundant address before the array
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
                   ` (4 preceding siblings ...)
  2025-06-17  1:02 ` [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-18 11:20   ` Simon Horman
  2025-06-17  1:02 ` [PATCH V2 net-next 7/8] net: hns3: add complete parentheses for some macros Jijie Shao
  2025-06-17  1:02 ` [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness Jijie Shao
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

From: Yonglong Liu <liuyonglong@huawei.com>

Address before the array is redundant, this patch delete it.

Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index c46490693594..21deec217668 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -2110,7 +2110,7 @@ static int hclge_dbg_dump_mng_table(struct hclge_dev *hdev, char *buf, int len)
 	for (i = 0; i < HCLGE_DBG_MNG_TBL_MAX; i++) {
 		hclge_cmd_setup_basic_desc(&desc, HCLGE_MAC_ETHERTYPE_IDX_RD,
 					   true);
-		req0 = (struct hclge_mac_ethertype_idx_rd_cmd *)&desc.data;
+		req0 = (struct hclge_mac_ethertype_idx_rd_cmd *)desc.data;
 		req0->index = cpu_to_le16(i);
 
 		ret = hclge_cmd_send(&hdev->hw, &desc, 1);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 9d7c9523c9e1..b76400e67a23 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2358,7 +2358,7 @@ static int hclge_common_thrd_config(struct hclge_dev *hdev,
 	for (i = 0; i < 2; i++) {
 		hclge_cmd_setup_basic_desc(&desc[i],
 					   HCLGE_OPC_RX_COM_THRD_ALLOC, false);
-		req = (struct hclge_rx_com_thrd *)&desc[i].data;
+		req = (struct hclge_rx_com_thrd *)desc[i].data;
 
 		/* The first descriptor set the NEXT bit to 1 */
 		if (i == 0)
-- 
2.33.0


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

* [PATCH V2 net-next 7/8] net: hns3: add complete parentheses for some macros
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
                   ` (5 preceding siblings ...)
  2025-06-17  1:02 ` [PATCH V2 net-next 6/8] net: hns3: delete redundant address before the array Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-18 11:21   ` Simon Horman
  2025-06-17  1:02 ` [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness Jijie Shao
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

Add complete parentheses for some macros to fix static check
warning.

Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index d36c4ed16d8d..dd61ddd8f904 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -692,7 +692,7 @@ static inline unsigned int hns3_page_order(struct hns3_enet_ring *ring)
 
 /* iterator for handling rings in ring group */
 #define hns3_for_each_ring(pos, head) \
-	for (pos = (head).ring; (pos); pos = (pos)->next)
+	for ((pos) = (head).ring; (pos); (pos) = (pos)->next)
 
 #define hns3_get_handle(ndev) \
 	(((struct hns3_nic_priv *)netdev_priv(ndev))->ae_handle)
-- 
2.33.0


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

* [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness
  2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
                   ` (6 preceding siblings ...)
  2025-06-17  1:02 ` [PATCH V2 net-next 7/8] net: hns3: add complete parentheses for some macros Jijie Shao
@ 2025-06-17  1:02 ` Jijie Shao
  2025-06-18 11:29   ` Simon Horman
  7 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-17  1:02 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, andrew+netdev, horms
  Cc: shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski, shaojijie

From: Peiyang Wang <wangpeiyang1@huawei.com>

A static alarm exists in the hns and needs to be cleared.

The alarm is comparison of integer expressions of different
signedness including 's64' and 'long unsigned int',
'int' and 'long unsigned int', 'u32' and 'int',
'int' and 'unsigned int'.

Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
---
 .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 22 +++++++-------
 .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  2 +-
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  4 +--
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 13 ++++----
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 30 +++++++++----------
 .../hisilicon/hns3/hns3pf/hclge_mbx.c         |  7 +++--
 .../hisilicon/hns3/hns3pf/hclge_mdio.c        |  2 +-
 .../hisilicon/hns3/hns3pf/hclge_ptp.h         |  2 +-
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  2 +-
 .../hisilicon/hns3/hns3vf/hclgevf_mbx.c       |  2 +-
 11 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
index 4ad4e8ab2f1f..37396ca4ecfc 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
@@ -348,7 +348,7 @@ static int hclge_comm_cmd_csq_clean(struct hclge_comm_hw *hw)
 static int hclge_comm_cmd_csq_done(struct hclge_comm_hw *hw)
 {
 	u32 head = hclge_comm_read_dev(hw, HCLGE_COMM_NIC_CSQ_HEAD_REG);
-	return head == hw->cmq.csq.next_to_use;
+	return head == (u32)hw->cmq.csq.next_to_use;
 }
 
 static u32 hclge_get_cmdq_tx_timeout(u16 opcode, u32 tx_timeout)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index dc1e15926482..49fcee7a6d0f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1690,8 +1690,8 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, dma_addr_t dma,
 #define HNS3_LIKELY_BD_NUM	1
 
 	struct hns3_desc *desc = &ring->desc[ring->next_to_use];
-	unsigned int frag_buf_num;
-	int k, sizeoflast;
+	unsigned int frag_buf_num, k;
+	int sizeoflast;
 
 	if (likely(size <= HNS3_MAX_BD_SIZE)) {
 		desc->addr = cpu_to_le64(dma);
@@ -1863,7 +1863,7 @@ static bool hns3_skb_need_linearized(struct sk_buff *skb, unsigned int *bd_size,
 				     unsigned int bd_num, u8 max_non_tso_bd_num)
 {
 	unsigned int tot_len = 0;
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < max_non_tso_bd_num - 1U; i++)
 		tot_len += bd_size[i];
@@ -1891,7 +1891,7 @@ static bool hns3_skb_need_linearized(struct sk_buff *skb, unsigned int *bd_size,
 
 void hns3_shinfo_pack(struct skb_shared_info *shinfo, __u32 *size)
 {
-	int i;
+	u32 i;
 
 	for (i = 0; i < MAX_SKB_FRAGS; i++)
 		size[i] = skb_frag_size(&shinfo->frags[i]);
@@ -2207,9 +2207,9 @@ static int hns3_handle_tx_sgl(struct hns3_enet_ring *ring,
 	struct hns3_desc_cb *desc_cb = &ring->desc_cb[ring->next_to_use];
 	u32 nfrag = skb_shinfo(skb)->nr_frags + 1;
 	struct sg_table *sgt;
-	int i, bd_num = 0;
+	int bd_num = 0;
 	dma_addr_t dma;
-	u32 cb_len;
+	u32 cb_len, i;
 	int nents;
 
 	if (skb_has_frag_list(skb))
@@ -2544,7 +2544,7 @@ static void hns3_nic_get_stats64(struct net_device *netdev,
 	struct hnae3_handle *handle = priv->ae_handle;
 	struct rtnl_link_stats64 ring_total_stats;
 	struct hns3_enet_ring *ring;
-	unsigned int idx;
+	int idx;
 
 	if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state))
 		return;
@@ -2770,7 +2770,7 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
 
 static int hns3_get_timeout_queue(struct net_device *ndev)
 {
-	int i;
+	unsigned int i;
 
 	/* Find the stopped queue the same way the stack does */
 	for (i = 0; i < ndev->num_tx_queues; i++) {
@@ -2851,7 +2851,7 @@ static bool hns3_get_tx_timeo_queue_info(struct net_device *ndev)
 	struct hns3_nic_priv *priv = netdev_priv(ndev);
 	struct hnae3_handle *h = hns3_get_handle(ndev);
 	struct hns3_enet_ring *tx_ring;
-	int timeout_queue;
+	u32 timeout_queue;
 
 	timeout_queue = hns3_get_timeout_queue(ndev);
 	if (timeout_queue >= ndev->num_tx_queues) {
@@ -3821,7 +3821,7 @@ static int hns3_gro_complete(struct sk_buff *skb, u32 l234info)
 {
 	__be16 type = skb->protocol;
 	struct tcphdr *th;
-	int depth = 0;
+	u32 depth = 0;
 
 	while (eth_type_vlan(type)) {
 		struct vlan_hdr *vh;
@@ -5934,7 +5934,7 @@ static const struct hns3_hw_error_info hns3_hw_err[] = {
 static void hns3_process_hw_error(struct hnae3_handle *handle,
 				  enum hnae3_hw_error_type type)
 {
-	int i;
+	u32 i;
 
 	for (i = 0; i < ARRAY_SIZE(hns3_hw_err); i++) {
 		if (hns3_hw_err[i].type == type) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index dd61ddd8f904..d3bad5d1b888 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -621,7 +621,7 @@ struct hns3_reset_type_map {
 	enum hnae3_reset_type rst_type;
 };
 
-static inline int ring_space(struct hns3_enet_ring *ring)
+static inline u32 ring_space(struct hns3_enet_ring *ring)
 {
 	/* This smp_load_acquire() pairs with smp_store_release() in
 	 * hns3_nic_reclaim_one_desc called by hns3_clean_tx_ring.
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 0d6db46db5ed..549b0382921d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -542,7 +542,7 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
 	const struct hnae3_ae_ops *ops = hns3_get_ops(h);
-	int i;
+	u32 i;
 
 	if (!ops->get_strings)
 		return;
@@ -570,7 +570,7 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
 	struct hns3_nic_priv *nic_priv = handle->priv;
 	struct hns3_enet_ring *ring;
 	u8 *stat;
-	int i, j;
+	u32 i, j;
 
 	/* get stats for Tx */
 	for (i = 0; i < kinfo->num_tqps; i++) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index 21deec217668..f130020a1227 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -830,10 +830,10 @@ hclge_dbg_dump_reg_tqp(struct hclge_dev *hdev,
 {
 	const struct hclge_dbg_dfx_message *dfx_message = reg_info->dfx_msg;
 	const struct hclge_dbg_reg_common_msg *reg_msg = &reg_info->reg_msg;
+	u32 index, entry, i, cnt, min_num;
 	struct hclge_desc *desc_src;
-	u32 index, entry, i, cnt;
-	int bd_num, min_num, ret;
 	struct hclge_desc *desc;
+	int bd_num, ret;
 
 	ret = hclge_dbg_get_dfx_bd_num(hdev, reg_msg->offset, &bd_num);
 	if (ret)
@@ -885,9 +885,9 @@ hclge_dbg_dump_reg_common(struct hclge_dev *hdev,
 	const struct hclge_dbg_reg_common_msg *reg_msg = &reg_info->reg_msg;
 	const struct hclge_dbg_dfx_message *dfx_message = reg_info->dfx_msg;
 	struct hclge_desc *desc_src;
-	int bd_num, min_num, ret;
+	int bd_num, min_num, ret, i;
 	struct hclge_desc *desc;
-	u32 entry, i;
+	u32 entry;
 
 	ret = hclge_dbg_get_dfx_bd_num(hdev, reg_msg->offset, &bd_num);
 	if (ret)
@@ -1279,7 +1279,7 @@ static int hclge_dbg_dump_reg_cmd(struct hclge_dev *hdev,
 {
 	const struct hclge_dbg_reg_type_info *reg_info;
 	int pos = 0, ret = 0;
-	int i;
+	u32 i;
 
 	for (i = 0; i < ARRAY_SIZE(hclge_dbg_reg_info); i++) {
 		reg_info = &hclge_dbg_reg_info[i];
@@ -2648,9 +2648,8 @@ static void hclge_dbg_dump_mac_list(struct hclge_dev *hdev, char *buf, int len,
 	struct hclge_mac_node *mac_node, *tmp;
 	struct hclge_vport *vport;
 	struct list_head *list;
-	u32 func_id;
+	u32 func_id, i;
 	int pos = 0;
-	int i;
 
 	for (i = 0; i < ARRAY_SIZE(mac_list_items); i++)
 		result[i] = &data_str[i][0];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index b76400e67a23..d886b04ad92c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -582,7 +582,7 @@ static u64 *hclge_comm_get_stats(struct hclge_dev *hdev,
 				 int size, u64 *data)
 {
 	u64 *buf = data;
-	u32 i;
+	int i;
 
 	for (i = 0; i < size; i++) {
 		if (strs[i].stats_num > hdev->ae_dev->dev_specs.mac_stats_num)
@@ -599,7 +599,7 @@ static void hclge_comm_get_strings(struct hclge_dev *hdev, u32 stringset,
 				   const struct hclge_comm_stats_str strs[],
 				   int size, u8 **data)
 {
-	u32 i;
+	int i;
 
 	if (stringset != ETH_SS_STATS)
 		return;
@@ -2624,7 +2624,7 @@ int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex, u8 lan
 	int ret;
 
 	duplex = hclge_check_speed_dup(duplex, speed);
-	if (!mac->support_autoneg && mac->speed == speed &&
+	if (!mac->support_autoneg && mac->speed == (u32)speed &&
 	    mac->duplex == duplex && (mac->lane_num == lane_num || lane_num == 0))
 		return 0;
 
@@ -2652,7 +2652,7 @@ static int hclge_cfg_mac_speed_dup_h(struct hnae3_handle *handle, int speed,
 	if (ret)
 		return ret;
 
-	hdev->hw.mac.req_speed = speed;
+	hdev->hw.mac.req_speed = (u32)speed;
 	hdev->hw.mac.req_duplex = duplex;
 
 	return 0;
@@ -3446,7 +3446,7 @@ static int hclge_tp_port_init(struct hclge_dev *hdev)
 static int hclge_update_port_info(struct hclge_dev *hdev)
 {
 	struct hclge_mac *mac = &hdev->hw.mac;
-	int speed;
+	u32 speed;
 	int ret;
 
 	/* get the port info from SFP cmd if not copper port */
@@ -6991,7 +6991,7 @@ static int hclge_get_all_rules(struct hnae3_handle *handle,
 	struct hclge_dev *hdev = vport->back;
 	struct hclge_fd_rule *rule;
 	struct hlist_node *node2;
-	int cnt = 0;
+	u32 cnt = 0;
 
 	if (!hnae3_ae_dev_fd_supported(hdev->ae_dev))
 		return -EOPNOTSUPP;
@@ -8225,14 +8225,14 @@ static int hclge_update_desc_vfid(struct hclge_desc *desc, int vfid, bool clr)
 		word_num = vfid / 32;
 		bit_num  = vfid % 32;
 		if (clr)
-			desc[1].data[word_num] &= cpu_to_le32(~(1 << bit_num));
+			desc[1].data[word_num] &= cpu_to_le32(~(1U << bit_num));
 		else
 			desc[1].data[word_num] |= cpu_to_le32(1 << bit_num);
 	} else {
 		word_num = (vfid - HCLGE_VF_NUM_IN_FIRST_DESC) / 32;
 		bit_num  = vfid % 32;
 		if (clr)
-			desc[2].data[word_num] &= cpu_to_le32(~(1 << bit_num));
+			desc[2].data[word_num] &= cpu_to_le32(~(1U << bit_num));
 		else
 			desc[2].data[word_num] |= cpu_to_le32(1 << bit_num);
 	}
@@ -9296,7 +9296,7 @@ static int hclge_add_mgr_tbl(struct hclge_dev *hdev,
 static int init_mgr_tbl(struct hclge_dev *hdev)
 {
 	int ret;
-	int i;
+	u32 i;
 
 	for (i = 0; i < ARRAY_SIZE(hclge_mgr_table); i++) {
 		ret = hclge_add_mgr_tbl(hdev, &hclge_mgr_table[i]);
@@ -10717,7 +10717,7 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu)
 	max_frm_size = max(max_frm_size, HCLGE_MAC_DEFAULT_FRAME);
 	mutex_lock(&hdev->vport_lock);
 	/* VF's mps must fit within hdev->mps */
-	if (vport->vport_id && max_frm_size > hdev->mps) {
+	if (vport->vport_id && (u32)max_frm_size > hdev->mps) {
 		mutex_unlock(&hdev->vport_lock);
 		return -EINVAL;
 	} else if (vport->vport_id) {
@@ -10728,7 +10728,7 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu)
 
 	/* PF's mps must be greater then VF's mps */
 	for (i = 1; i < hdev->num_alloc_vport; i++)
-		if (max_frm_size < hdev->vport[i].mps) {
+		if ((u32)max_frm_size < hdev->vport[i].mps) {
 			dev_err(&hdev->pdev->dev,
 				"failed to set pf mtu for less than vport %d, mps = %u.\n",
 				i, hdev->vport[i].mps);
@@ -11218,7 +11218,7 @@ static int hclge_init_nic_client_instance(struct hnae3_ae_dev *ae_dev,
 {
 	struct hnae3_client *client = vport->nic.client;
 	struct hclge_dev *hdev = ae_dev->priv;
-	int rst_cnt = hdev->rst_stats.reset_cnt;
+	u32 rst_cnt = hdev->rst_stats.reset_cnt;
 	int ret;
 
 	ret = client->ops->init_instance(&vport->nic);
@@ -11262,7 +11262,7 @@ static int hclge_init_roce_client_instance(struct hnae3_ae_dev *ae_dev,
 {
 	struct hclge_dev *hdev = ae_dev->priv;
 	struct hnae3_client *client;
-	int rst_cnt;
+	u32 rst_cnt;
 	int ret;
 
 	if (!hnae3_dev_roce_supported(hdev) || !hdev->roce_client ||
@@ -12092,7 +12092,7 @@ static int hclge_vf_rate_param_check(struct hclge_dev *hdev,
 				     int min_tx_rate, int max_tx_rate)
 {
 	if (min_tx_rate != 0 ||
-	    max_tx_rate < 0 || max_tx_rate > hdev->hw.mac.max_speed) {
+	    max_tx_rate < 0 || (u32)max_tx_rate > hdev->hw.mac.max_speed) {
 		dev_err(&hdev->pdev->dev,
 			"min_tx_rate:%d [0], max_tx_rate:%d [0, %u]\n",
 			min_tx_rate, max_tx_rate, hdev->hw.mac.max_speed);
@@ -12117,7 +12117,7 @@ static int hclge_set_vf_rate(struct hnae3_handle *handle, int vf,
 	if (!vport)
 		return -EINVAL;
 
-	if (!force && max_tx_rate == vport->vf_info.max_tx_rate)
+	if (!force && (u32)max_tx_rate == vport->vf_info.max_tx_rate)
 		return 0;
 
 	ret = hclge_tm_qs_shaper_cfg(vport, max_tx_rate);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
index 59c863306657..c7ff12a6c076 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
@@ -749,16 +749,17 @@ static int hclge_get_rss_key(struct hclge_vport *vport,
 #define HCLGE_RSS_MBX_RESP_LEN	8
 	struct hclge_dev *hdev = vport->back;
 	struct hclge_comm_rss_cfg *rss_cfg;
+	int rss_hash_key_size;
 	u8 index;
 
 	index = mbx_req->msg.data[0];
 	rss_cfg = &hdev->rss_cfg;
+	rss_hash_key_size = sizeof(rss_cfg->rss_hash_key);
 
 	/* Check the query index of rss_hash_key from VF, make sure no
 	 * more than the size of rss_hash_key.
 	 */
-	if (((index + 1) * HCLGE_RSS_MBX_RESP_LEN) >
-	      sizeof(rss_cfg->rss_hash_key)) {
+	if (((index + 1) * HCLGE_RSS_MBX_RESP_LEN) > rss_hash_key_size) {
 		dev_warn(&hdev->pdev->dev,
 			 "failed to get the rss hash key, the index(%u) invalid !\n",
 			 index);
@@ -800,7 +801,7 @@ static void hclge_handle_link_change_event(struct hclge_dev *hdev,
 
 static bool hclge_cmd_crq_empty(struct hclge_hw *hw)
 {
-	u32 tail = hclge_read_dev(hw, HCLGE_COMM_NIC_CRQ_TAIL_REG);
+	int tail = hclge_read_dev(hw, HCLGE_COMM_NIC_CRQ_TAIL_REG);
 
 	return tail == hw->hw.cmq.crq.next_to_use;
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
index 9a456ebf9b7c..96553109f44c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
@@ -151,7 +151,7 @@ int hclge_mac_mdio_config(struct hclge_dev *hdev)
 
 	mdio_bus->parent = &hdev->pdev->dev;
 	mdio_bus->priv = hdev;
-	mdio_bus->phy_mask = ~(1 << mac->phy_addr);
+	mdio_bus->phy_mask = ~(1U << mac->phy_addr);
 	ret = mdiobus_register(mdio_bus);
 	if (ret) {
 		dev_err(mdio_bus->parent,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
index 63483636c074..61faddcc3dd0 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.h
@@ -25,7 +25,7 @@ struct ifreq;
 #define HCLGE_PTP_TIME_SEC_H_MASK	GENMASK(15, 0)
 #define HCLGE_PTP_TIME_SEC_L_REG	0x54
 #define HCLGE_PTP_TIME_NSEC_REG		0x58
-#define HCLGE_PTP_TIME_NSEC_MASK	GENMASK(29, 0)
+#define HCLGE_PTP_TIME_NSEC_MASK	0x3fffffffLL
 #define HCLGE_PTP_TIME_NSEC_NEG		BIT(31)
 #define HCLGE_PTP_TIME_SYNC_REG		0x5C
 #define HCLGE_PTP_TIME_SYNC_EN		BIT(0)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 3ffd47b30ad3..ca2f43985a4a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -2469,7 +2469,7 @@ static int hclgevf_init_nic_client_instance(struct hnae3_ae_dev *ae_dev,
 					    struct hnae3_client *client)
 {
 	struct hclgevf_dev *hdev = ae_dev->priv;
-	int rst_cnt = hdev->rst_stats.rst_cnt;
+	u32 rst_cnt = hdev->rst_stats.rst_cnt;
 	int ret;
 
 	ret = client->ops->init_instance(&hdev->nic);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
index 85c2a634c8f9..f5c99ca54369 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
@@ -159,7 +159,7 @@ static bool hclgevf_cmd_crq_empty(struct hclgevf_hw *hw)
 {
 	u32 tail = hclgevf_read_dev(hw, HCLGE_COMM_NIC_CRQ_TAIL_REG);
 
-	return tail == hw->hw.cmq.crq.next_to_use;
+	return tail == (u32)hw->hw.cmq.crq.next_to_use;
 }
 
 static void hclgevf_handle_mbx_response(struct hclgevf_dev *hdev,
-- 
2.33.0


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

* Re: [PATCH V2 net-next 3/8] net: hns3: use hns3_get_ops() helper to reduce the unnecessary middle layer conversion
  2025-06-17  1:02 ` [PATCH V2 net-next 3/8] net: hns3: use hns3_get_ops() " Jijie Shao
@ 2025-06-17 14:12   ` Michal Swiatkowski
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Swiatkowski @ 2025-06-17 14:12 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, horms, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:50AM +0800, Jijie Shao wrote:
> There are too many indirection layers in the HNS3 driver code,
> This issue was previously discussed with the maintainer,
> who suggested adding a helper function to fix the issue.
> In fact, the hns3_get_ops() helper is already defined
> and can fix this issue.
> 
> This patch uses hns3_get_ops() helper to reduce the unnecessary
> middle layer conversion. Apply it to the whole HNS3 driver.
> The former discusstion can be checked from the link.

Thanks for rewording the commit message.
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

> 
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230310081404.947-1-lanhao@huawei.com/

I hope you will add getting hns3 device from netdev too in the future
(as this is main point in the link).

> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
> ChangeLog:
> v1 -> v2:
>   - Change commit message and title, suggested by Michal Swiatkowski.
>   v1: https://lore.kernel.org/all/20250612021317.1487943-1-shaojijie@huawei.com/
> ---

[...]

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

* Re: [PATCH V2 net-next 2/8] net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary middle layer conversion
  2025-06-17  1:02 ` [PATCH V2 net-next 2/8] net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary middle layer conversion Jijie Shao
@ 2025-06-17 14:15   ` Michal Swiatkowski
  0 siblings, 0 replies; 20+ messages in thread
From: Michal Swiatkowski @ 2025-06-17 14:15 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, horms, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:49AM +0800, Jijie Shao wrote:
> There are too many indirection layers in the HNS3 driver code.
> This issue was previously discussed with the maintainer,
> who suggested adding a helper function to fix the issue.
> In fact, the hns3_get_ae_dev() helper is already defined
> and can fix this issue.
> 
> This patch uses hns3_get_ae_dev() helper to reduce the unnecessary
> middle layer conversion. Apply it to the whole HNS3 driver.
> The former discusstion can be checked from the link.

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

> 
> Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230310081404.947-1-lanhao@huawei.com/
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
> ChangeLog:
> v1 -> v2:
>   - Change commit message and title, suggested by Michal Swiatkowski.
>   v1: https://lore.kernel.org/all/20250612021317.1487943-1-shaojijie@huawei.com/
> ---
>  .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  8 ++---
>  .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 12 +++----
>  .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 36 +++++++++----------
>  3 files changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> index 4e5d8bc39a1b..4f6ed7c7ee68 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> @@ -684,7 +684,7 @@ static int hns3_dbg_rx_queue_info(struct hnae3_handle *h,
>  				  char *buf, int len)
>  {
>  	char data_str[ARRAY_SIZE(rx_queue_info_items)][HNS3_DBG_DATA_STR_LEN];
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	char *result[ARRAY_SIZE(rx_queue_info_items)];
>  	struct hns3_nic_priv *priv = h->priv;
>  	char content[HNS3_DBG_INFO_LEN];
> @@ -789,7 +789,7 @@ static int hns3_dbg_tx_queue_info(struct hnae3_handle *h,
>  				  char *buf, int len)
>  {
>  	char data_str[ARRAY_SIZE(tx_queue_info_items)][HNS3_DBG_DATA_STR_LEN];
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	char *result[ARRAY_SIZE(tx_queue_info_items)];
>  	struct hns3_nic_priv *priv = h->priv;
>  	char content[HNS3_DBG_INFO_LEN];
> @@ -1034,7 +1034,7 @@ static int hns3_dbg_tx_bd_info(struct hns3_dbg_data *d, char *buf, int len)
>  static void
>  hns3_dbg_dev_caps(struct hnae3_handle *h, char *buf, int len, int *pos)
>  {
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	unsigned long *caps = ae_dev->caps;
>  	u32 i, state;
>  
> @@ -1364,7 +1364,7 @@ hns3_dbg_common_file_init(struct hnae3_handle *handle, u32 cmd)
>  
>  int hns3_dbg_init(struct hnae3_handle *handle)
>  {
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const char *name = pci_name(handle->pdev);
>  	int ret;
>  	u32 i;
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 5c8c62ea6ac0..6babc636145b 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -547,9 +547,9 @@ void hns3_set_vector_coalesce_rx_ql(struct hns3_enet_tqp_vector *tqp_vector,
>  static void hns3_vector_coalesce_init(struct hns3_enet_tqp_vector *tqp_vector,
>  				      struct hns3_nic_priv *priv)
>  {
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
>  	struct hns3_enet_coalesce *tx_coal = &tqp_vector->tx_group.coal;
>  	struct hns3_enet_coalesce *rx_coal = &tqp_vector->rx_group.coal;
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
>  	struct hns3_enet_coalesce *ptx_coal = &priv->tx_coal;
>  	struct hns3_enet_coalesce *prx_coal = &priv->rx_coal;
>  
> @@ -1304,7 +1304,7 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
>  static bool hns3_tunnel_csum_bug(struct sk_buff *skb)
>  {
>  	struct hns3_nic_priv *priv = netdev_priv(skb->dev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
>  	union l4_hdr_info l4;
>  
>  	/* device version above V3(include V3), the hardware can
> @@ -1504,7 +1504,7 @@ static int hns3_handle_vtags(struct hns3_enet_ring *tx_ring,
>  	 * VLAN enabled, only one VLAN header is allowed in skb, otherwise it
>  	 * will cause RAS error.
>  	 */
> -	ae_dev = pci_get_drvdata(handle->pdev);
> +	ae_dev = hns3_get_ae_dev(handle);
>  	if (unlikely(skb_vlan_tagged_multi(skb) &&
>  		     ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2 &&
>  		     handle->port_base_vlan_state ==
> @@ -4747,7 +4747,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv)
>  
>  static void hns3_nic_init_coal_cfg(struct hns3_nic_priv *priv)
>  {
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
>  	struct hns3_enet_coalesce *tx_coal = &priv->tx_coal;
>  	struct hns3_enet_coalesce *rx_coal = &priv->rx_coal;
>  
> @@ -5226,7 +5226,7 @@ static void hns3_info_show(struct hns3_nic_priv *priv)
>  static void hns3_set_cq_period_mode(struct hns3_nic_priv *priv,
>  				    enum dim_cq_period_mode mode, bool is_tx)
>  {
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(priv->ae_handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(priv->ae_handle);
>  	struct hnae3_handle *handle = priv->ae_handle;
>  	int i;
>  
> @@ -5264,7 +5264,7 @@ void hns3_cq_period_mode_init(struct hns3_nic_priv *priv,
>  
>  static void hns3_state_init(struct hnae3_handle *handle)
>  {
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	struct net_device *netdev = handle->kinfo.netdev;
>  	struct hns3_nic_priv *priv = netdev_priv(netdev);
>  
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> index 6715222aeb66..ae220f49df64 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> @@ -86,7 +86,7 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset);
>  static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
>  {
>  	struct hnae3_handle *h = hns3_get_handle(ndev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	int ret;
>  
>  	if (!h->ae_algo->ops->set_loopback ||
> @@ -171,7 +171,7 @@ static void hns3_lp_setup_skb(struct sk_buff *skb)
>  	 * the purpose of mac or serdes selftest.
>  	 */
>  	handle = hns3_get_handle(ndev);
> -	ae_dev = pci_get_drvdata(handle->pdev);
> +	ae_dev = hns3_get_ae_dev(handle);
>  	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
>  		ethh->h_dest[5] += HNS3_NIC_LB_DST_MAC_ADDR;
>  	eth_zero_addr(ethh->h_source);
> @@ -692,7 +692,7 @@ static void hns3_get_pauseparam(struct net_device *netdev,
>  				struct ethtool_pauseparam *param)
>  {
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  
>  	if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps))
>  		return;
> @@ -706,7 +706,7 @@ static int hns3_set_pauseparam(struct net_device *netdev,
>  			       struct ethtool_pauseparam *param)
>  {
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  
>  	if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps))
>  		return -EOPNOTSUPP;
> @@ -751,7 +751,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
>  				   struct ethtool_link_ksettings *cmd)
>  {
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	const struct hnae3_ae_ops *ops;
>  	u8 module_type;
>  	u8 media_type;
> @@ -861,7 +861,7 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
>  				   const struct ethtool_link_ksettings *cmd)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
>  	int ret;
>  
> @@ -932,7 +932,7 @@ static u32 hns3_get_rss_key_size(struct net_device *netdev)
>  static u32 hns3_get_rss_indir_size(struct net_device *netdev)
>  {
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  
>  	return ae_dev->dev_specs.rss_ind_tbl_size;
>  }
> @@ -954,7 +954,7 @@ static int hns3_set_rss(struct net_device *netdev,
>  			struct netlink_ext_ack *extack)
>  {
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  
>  	if (!h->ae_algo->ops->set_rss)
>  		return -EOPNOTSUPP;
> @@ -1024,7 +1024,7 @@ static int hns3_set_reset(struct net_device *netdev, u32 *flags)
>  {
>  	enum hnae3_reset_type rst_type = HNAE3_NONE_RESET;
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	const struct hnae3_ae_ops *ops = h->ae_algo->ops;
>  	const struct hns3_reset_type_map *rst_type_map;
>  	enum ethtool_reset_flags rst_flags;
> @@ -1189,7 +1189,7 @@ static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push)
>  {
>  	struct hns3_nic_priv *priv = netdev_priv(netdev);
>  	struct hnae3_handle *h = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(h);
>  	u32 old_state = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
>  
>  	if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps) && tx_push)
> @@ -1377,7 +1377,7 @@ static int hns3_check_gl_coalesce_para(struct net_device *netdev,
>  				       struct ethtool_coalesce *cmd)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	u32 rx_gl, tx_gl;
>  
>  	if (cmd->rx_coalesce_usecs > ae_dev->dev_specs.max_int_gl) {
> @@ -1449,7 +1449,7 @@ static int hns3_check_ql_coalesce_param(struct net_device *netdev,
>  					struct ethtool_coalesce *cmd)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  
>  	if ((cmd->tx_max_coalesced_frames || cmd->rx_max_coalesced_frames) &&
>  	    !ae_dev->dev_specs.int_ql_max) {
> @@ -1473,7 +1473,7 @@ hns3_check_cqe_coalesce_param(struct net_device *netdev,
>  			      struct kernel_ethtool_coalesce *kernel_coal)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  
>  	if ((kernel_coal->use_cqe_mode_tx || kernel_coal->use_cqe_mode_rx) &&
>  	    !hnae3_ae_dev_cq_supported(ae_dev)) {
> @@ -1649,7 +1649,7 @@ static void hns3_get_fec_stats(struct net_device *netdev,
>  			       struct ethtool_fec_stats *fec_stats)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
>  
>  	if (!hnae3_ae_dev_fec_stats_supported(ae_dev) || !ops->get_fec_stats)
> @@ -1700,7 +1700,7 @@ static int hns3_get_fecparam(struct net_device *netdev,
>  			     struct ethtool_fecparam *fec)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
>  	u8 fec_ability;
>  	u8 fec_mode;
> @@ -1725,7 +1725,7 @@ static int hns3_set_fecparam(struct net_device *netdev,
>  			     struct ethtool_fecparam *fec)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
>  	u32 fec_mode;
>  
> @@ -1747,7 +1747,7 @@ static int hns3_get_module_info(struct net_device *netdev,
>  #define HNS3_SFF_8636_V1_3 0x03
>  
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
>  	struct hns3_sfp_type sfp_type;
>  	int ret;
> @@ -1797,7 +1797,7 @@ static int hns3_get_module_eeprom(struct net_device *netdev,
>  				  struct ethtool_eeprom *ee, u8 *data)
>  {
>  	struct hnae3_handle *handle = hns3_get_handle(netdev);
> -	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev);
> +	struct hnae3_ae_dev *ae_dev = hns3_get_ae_dev(handle);
>  	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
>  
>  	if (ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2 ||
> -- 
> 2.33.0

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

* Re: [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num"
  2025-06-17  1:02 ` [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num" Jijie Shao
@ 2025-06-18 10:55   ` Simon Horman
  0 siblings, 0 replies; 20+ messages in thread
From: Simon Horman @ 2025-06-18 10:55 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:48AM +0800, Jijie Shao wrote:
> There are spelling mistakes in hclgevf_get_regs. Fix them.
> 
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH V2 net-next 4/8] net: hns3: add \n at the end when print msg
  2025-06-17  1:02 ` [PATCH V2 net-next 4/8] net: hns3: add \n at the end when print msg Jijie Shao
@ 2025-06-18 10:57   ` Simon Horman
  0 siblings, 0 replies; 20+ messages in thread
From: Simon Horman @ 2025-06-18 10:57 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:51AM +0800, Jijie Shao wrote:
> From: Peiyang Wang <wangpeiyang1@huawei.com>
> 
> To make the print message more clearly, add \n at the and of message if
> it is missing currently.
> 
> Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end
  2025-06-17  1:02 ` [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end Jijie Shao
@ 2025-06-18 11:12   ` Simon Horman
  2025-06-18 13:44     ` Jijie Shao
  0 siblings, 1 reply; 20+ messages in thread
From: Simon Horman @ 2025-06-18 11:12 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:52AM +0800, Jijie Shao wrote:
> From: Jian Shen <shenjian15@huawei.com>
> 
> There are several pointers are freed but not set to NULL,
> and their lifetime is not end immediately. To avoid misusing
> there wild pointers, set them to NULL.
> 
> Signed-off-by: Jian Shen <shenjian15@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c        | 1 +
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 4 ++++
>  drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++++
>  3 files changed, 9 insertions(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> index 6a244ba5e051..0d6db46db5ed 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
> @@ -276,6 +276,7 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
>  			good_cnt++;
>  		} else {
>  			kfree_skb(skb);
> +			skb = NULL;

I am sceptical about the merit of setting local variables to NULL like this.
In general defensive coding is not the preferred approach in the Kernel.

And in this case, won't this result in a NULL dereference when
skb_get(skb) is called if the loop this code resides in iterates again?

>  			netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n",
>  				   tx_ret);
>  		}

...

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

* Re: [PATCH V2 net-next 6/8] net: hns3: delete redundant address before the array
  2025-06-17  1:02 ` [PATCH V2 net-next 6/8] net: hns3: delete redundant address before the array Jijie Shao
@ 2025-06-18 11:20   ` Simon Horman
  0 siblings, 0 replies; 20+ messages in thread
From: Simon Horman @ 2025-06-18 11:20 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:53AM +0800, Jijie Shao wrote:
> From: Yonglong Liu <liuyonglong@huawei.com>
> 
> Address before the array is redundant, this patch delete it.
> 
> Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH V2 net-next 7/8] net: hns3: add complete parentheses for some macros
  2025-06-17  1:02 ` [PATCH V2 net-next 7/8] net: hns3: add complete parentheses for some macros Jijie Shao
@ 2025-06-18 11:21   ` Simon Horman
  0 siblings, 0 replies; 20+ messages in thread
From: Simon Horman @ 2025-06-18 11:21 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:54AM +0800, Jijie Shao wrote:
> Add complete parentheses for some macros to fix static check
> warning.
> 
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness
  2025-06-17  1:02 ` [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness Jijie Shao
@ 2025-06-18 11:29   ` Simon Horman
  2025-06-19 11:59     ` Jijie Shao
  0 siblings, 1 reply; 20+ messages in thread
From: Simon Horman @ 2025-06-18 11:29 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Tue, Jun 17, 2025 at 09:02:55AM +0800, Jijie Shao wrote:
> From: Peiyang Wang <wangpeiyang1@huawei.com>
> 
> A static alarm exists in the hns and needs to be cleared.

I'm curious to know if you used a tool to flag this.

> 
> The alarm is comparison of integer expressions of different
> signedness including 's64' and 'long unsigned int',
> 'int' and 'long unsigned int', 'u32' and 'int',
> 'int' and 'unsigned int'.
> 
> Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
>  .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
>  .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 22 +++++++-------
>  .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  2 +-
>  .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  4 +--
>  .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 13 ++++----
>  .../hisilicon/hns3/hns3pf/hclge_main.c        | 30 +++++++++----------
>  .../hisilicon/hns3/hns3pf/hclge_mbx.c         |  7 +++--
>  .../hisilicon/hns3/hns3pf/hclge_mdio.c        |  2 +-
>  .../hisilicon/hns3/hns3pf/hclge_ptp.h         |  2 +-
>  .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  2 +-
>  .../hisilicon/hns3/hns3vf/hclgevf_mbx.c       |  2 +-
>  11 files changed, 44 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
> index 4ad4e8ab2f1f..37396ca4ecfc 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
> @@ -348,7 +348,7 @@ static int hclge_comm_cmd_csq_clean(struct hclge_comm_hw *hw)
>  static int hclge_comm_cmd_csq_done(struct hclge_comm_hw *hw)
>  {
>  	u32 head = hclge_comm_read_dev(hw, HCLGE_COMM_NIC_CSQ_HEAD_REG);
> -	return head == hw->cmq.csq.next_to_use;
> +	return head == (u32)hw->cmq.csq.next_to_use;

Can the type of next_to_use be changed to an unsigned type?
It would be nice to avoid casts.

>  }
>

...

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

* Re: [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end
  2025-06-18 11:12   ` Simon Horman
@ 2025-06-18 13:44     ` Jijie Shao
  0 siblings, 0 replies; 20+ messages in thread
From: Jijie Shao @ 2025-06-18 13:44 UTC (permalink / raw)
  To: Simon Horman
  Cc: shaojijie, davem, edumazet, kuba, pabeni, andrew+netdev,
	shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski


on 2025/6/18 19:12, Simon Horman wrote:
> On Tue, Jun 17, 2025 at 09:02:52AM +0800, Jijie Shao wrote:
>> From: Jian Shen <shenjian15@huawei.com>
>>
>> There are several pointers are freed but not set to NULL,
>> and their lifetime is not end immediately. To avoid misusing
>> there wild pointers, set them to NULL.
>>
>> Signed-off-by: Jian Shen <shenjian15@huawei.com>
>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>> ---
>>   drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c        | 1 +
>>   drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 4 ++++
>>   drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++++
>>   3 files changed, 9 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
>> index 6a244ba5e051..0d6db46db5ed 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
>> @@ -276,6 +276,7 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
>>   			good_cnt++;
>>   		} else {
>>   			kfree_skb(skb);
>> +			skb = NULL;
> I am sceptical about the merit of setting local variables to NULL like this.
> In general defensive coding is not the preferred approach in the Kernel.
>
> And in this case, won't this result in a NULL dereference when
> skb_get(skb) is called if the loop this code resides in iterates again?

Since HNS3_NIC_LB_TEST_PKT_NUM is 1, the loop will only iterate once,
so the current change will not cause any issues.
However, upon reviewing the code, this change is indeed unnecessary and may cause confusion,
so I will drop this change in the v3.

But I hope this patch can still be retained, and the other changes should be appropriate.

Thansk,
Jijie Shao

>
>>   			netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n",
>>   				   tx_ret);
>>   		}
> ...
>

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

* Re: [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness
  2025-06-18 11:29   ` Simon Horman
@ 2025-06-19 11:59     ` Jijie Shao
  2025-06-19 12:54       ` Simon Horman
  0 siblings, 1 reply; 20+ messages in thread
From: Jijie Shao @ 2025-06-19 11:59 UTC (permalink / raw)
  To: Simon Horman
  Cc: shaojijie, davem, edumazet, kuba, pabeni, andrew+netdev,
	shenjian15, wangpeiyang1, liuyonglong, chenhao418,
	jonathan.cameron, shameerali.kolothum.thodi, salil.mehta, netdev,
	linux-kernel, michal.swiatkowski


on 2025/6/18 19:29, Simon Horman wrote:
> On Tue, Jun 17, 2025 at 09:02:55AM +0800, Jijie Shao wrote:
>> From: Peiyang Wang <wangpeiyang1@huawei.com>
>>
>> A static alarm exists in the hns and needs to be cleared.
> I'm curious to know if you used a tool to flag this.

Sorry, the last reply was not cc to netdev...

Some internal tools, and then there are the compiler options, such as -Wsign-compare.

>
>> The alarm is comparison of integer expressions of different
>> signedness including 's64' and 'long unsigned int',
>> 'int' and 'long unsigned int', 'u32' and 'int',
>> 'int' and 'unsigned int'.
>>
>> Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
>> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>> ---
>>   .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
>>   .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 22 +++++++-------
>>   .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  2 +-
>>   .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  4 +--
>>   .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 13 ++++----
>>   .../hisilicon/hns3/hns3pf/hclge_main.c        | 30 +++++++++----------
>>   .../hisilicon/hns3/hns3pf/hclge_mbx.c         |  7 +++--
>>   .../hisilicon/hns3/hns3pf/hclge_mdio.c        |  2 +-
>>   .../hisilicon/hns3/hns3pf/hclge_ptp.h         |  2 +-
>>   .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  2 +-
>>   .../hisilicon/hns3/hns3vf/hclgevf_mbx.c       |  2 +-
>>   11 files changed, 44 insertions(+), 44 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
>> index 4ad4e8ab2f1f..37396ca4ecfc 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
>> @@ -348,7 +348,7 @@ static int hclge_comm_cmd_csq_clean(struct hclge_comm_hw *hw)
>>   static int hclge_comm_cmd_csq_done(struct hclge_comm_hw *hw)
>>   {
>>   	u32 head = hclge_comm_read_dev(hw, HCLGE_COMM_NIC_CSQ_HEAD_REG);
>> -	return head == hw->cmq.csq.next_to_use;
>> +	return head == (u32)hw->cmq.csq.next_to_use;
> Can the type of next_to_use be changed to an unsigned type?
> It would be nice to avoid casts.

Today I plan to modify the next_to_use type,
but I found that if next_to_use is changed to u32,
it will cause many other places to need to synchronously change the variable type.
At a glance, there are dozens of places.

Therefore, I am considering whether this part can remain unchanged.

Thanks
Jijie Shao



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

* Re: [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness
  2025-06-19 11:59     ` Jijie Shao
@ 2025-06-19 12:54       ` Simon Horman
  0 siblings, 0 replies; 20+ messages in thread
From: Simon Horman @ 2025-06-19 12:54 UTC (permalink / raw)
  To: Jijie Shao
  Cc: davem, edumazet, kuba, pabeni, andrew+netdev, shenjian15,
	wangpeiyang1, liuyonglong, chenhao418, jonathan.cameron,
	shameerali.kolothum.thodi, salil.mehta, netdev, linux-kernel,
	michal.swiatkowski

On Thu, Jun 19, 2025 at 07:59:07PM +0800, Jijie Shao wrote:
> 
> on 2025/6/18 19:29, Simon Horman wrote:
> > On Tue, Jun 17, 2025 at 09:02:55AM +0800, Jijie Shao wrote:
> > > From: Peiyang Wang <wangpeiyang1@huawei.com>
> > > 
> > > A static alarm exists in the hns and needs to be cleared.
> > I'm curious to know if you used a tool to flag this.
> 
> Sorry, the last reply was not cc to netdev...
> 
> Some internal tools, and then there are the compiler options, such as -Wsign-compare.
> 
> > 
> > > The alarm is comparison of integer expressions of different
> > > signedness including 's64' and 'long unsigned int',
> > > 'int' and 'long unsigned int', 'u32' and 'int',
> > > 'int' and 'unsigned int'.
> > > 
> > > Signed-off-by: Peiyang Wang <wangpeiyang1@huawei.com>
> > > Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> > > ---
> > >   .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
> > >   .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 22 +++++++-------
> > >   .../net/ethernet/hisilicon/hns3/hns3_enet.h   |  2 +-
> > >   .../ethernet/hisilicon/hns3/hns3_ethtool.c    |  4 +--
> > >   .../hisilicon/hns3/hns3pf/hclge_debugfs.c     | 13 ++++----
> > >   .../hisilicon/hns3/hns3pf/hclge_main.c        | 30 +++++++++----------
> > >   .../hisilicon/hns3/hns3pf/hclge_mbx.c         |  7 +++--
> > >   .../hisilicon/hns3/hns3pf/hclge_mdio.c        |  2 +-
> > >   .../hisilicon/hns3/hns3pf/hclge_ptp.h         |  2 +-
> > >   .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  2 +-
> > >   .../hisilicon/hns3/hns3vf/hclgevf_mbx.c       |  2 +-
> > >   11 files changed, 44 insertions(+), 44 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
> > > index 4ad4e8ab2f1f..37396ca4ecfc 100644
> > > --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
> > > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.c
> > > @@ -348,7 +348,7 @@ static int hclge_comm_cmd_csq_clean(struct hclge_comm_hw *hw)
> > >   static int hclge_comm_cmd_csq_done(struct hclge_comm_hw *hw)
> > >   {
> > >   	u32 head = hclge_comm_read_dev(hw, HCLGE_COMM_NIC_CSQ_HEAD_REG);
> > > -	return head == hw->cmq.csq.next_to_use;
> > > +	return head == (u32)hw->cmq.csq.next_to_use;
> > Can the type of next_to_use be changed to an unsigned type?
> > It would be nice to avoid casts.
> 
> Today I plan to modify the next_to_use type,
> but I found that if next_to_use is changed to u32,
> it will cause many other places to need to synchronously change the variable type.
> At a glance, there are dozens of places.
> 
> Therefore, I am considering whether this part can remain unchanged.

Thanks for checking.

Based on the above I'd say it can remain unchanged.
It improves things. And leaves room for further improvements later.

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

end of thread, other threads:[~2025-06-19 12:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17  1:02 [PATCH V2 net-next 0/8] There are some cleanup for hns3 driver Jijie Shao
2025-06-17  1:02 ` [PATCH V2 net-next 1/8] net: hns3: fix spelling mistake "reg_um" -> "reg_num" Jijie Shao
2025-06-18 10:55   ` Simon Horman
2025-06-17  1:02 ` [PATCH V2 net-next 2/8] net: hns3: use hns3_get_ae_dev() helper to reduce the unnecessary middle layer conversion Jijie Shao
2025-06-17 14:15   ` Michal Swiatkowski
2025-06-17  1:02 ` [PATCH V2 net-next 3/8] net: hns3: use hns3_get_ops() " Jijie Shao
2025-06-17 14:12   ` Michal Swiatkowski
2025-06-17  1:02 ` [PATCH V2 net-next 4/8] net: hns3: add \n at the end when print msg Jijie Shao
2025-06-18 10:57   ` Simon Horman
2025-06-17  1:02 ` [PATCH V2 net-next 5/8] net: hns3: set the freed pointers to NULL when lifetime is not end Jijie Shao
2025-06-18 11:12   ` Simon Horman
2025-06-18 13:44     ` Jijie Shao
2025-06-17  1:02 ` [PATCH V2 net-next 6/8] net: hns3: delete redundant address before the array Jijie Shao
2025-06-18 11:20   ` Simon Horman
2025-06-17  1:02 ` [PATCH V2 net-next 7/8] net: hns3: add complete parentheses for some macros Jijie Shao
2025-06-18 11:21   ` Simon Horman
2025-06-17  1:02 ` [PATCH V2 net-next 8/8] net: hns3: clear hns alarm: comparison of integer expressions of different signedness Jijie Shao
2025-06-18 11:29   ` Simon Horman
2025-06-19 11:59     ` Jijie Shao
2025-06-19 12:54       ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).