linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/14] redefine some macros of feature abilities judgement
@ 2022-09-24  2:30 Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 01/14] net: hns3: modify macro hnae3_dev_fec_supported Guangbin Huang
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

The macros hnae3_dev_XXX_supported just can be used in hclge layer, but
hns3_enet layer may need to use, so this serial redefine these macros.

Guangbin Huang (14):
  net: hns3: modify macro hnae3_dev_fec_supported
  net: hns3: modify macro hnae3_dev_udp_gso_supported
  net: hns3: modify macro hnae3_dev_qb_supported
  net: hns3: modify macro hnae3_dev_fd_forward_tc_supported
  net: hns3: modify macro hnae3_dev_ptp_supported
  net: hns3: modify macro hnae3_dev_int_ql_supported
  net: hns3: modify macro hnae3_dev_hw_csum_supported
  net: hns3: modify macro hnae3_dev_tx_push_supported
  net: hns3: modify macro hnae3_dev_phy_imp_supported
  net: hns3: modify macro hnae3_dev_ras_imp_supported
  net: hns3: delete redundant macro hnae3_dev_tqp_txrx_indep_supported
  net: hns3: modify macro hnae3_dev_hw_pad_supported
  net: hns3: modify macro hnae3_dev_stash_supported
  net: hns3: modify macro hnae3_dev_pause_supported

 drivers/net/ethernet/hisilicon/hns3/hnae3.h   | 55 +++++++++----------
 .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
 .../hns3/hns3_common/hclge_comm_cmd.h         |  3 -
 .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 10 ++--
 .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 14 ++---
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     |  2 +-
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 38 ++++++-------
 .../hisilicon/hns3/hns3pf/hclge_ptp.c         |  2 +-
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  2 +-
 10 files changed, 62 insertions(+), 68 deletions(-)

-- 
2.33.0


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

* [PATCH net-next 01/14] net: hns3: modify macro hnae3_dev_fec_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 02/14] net: hns3: modify macro hnae3_dev_udp_gso_supported Guangbin Huang
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

The macro hnae3_dev_fec_supported(hdev) just can be used in hclge layer,
so redefine it to hnae3_ae_dev_fec_supported(ae_dev), then it can be used
in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h             | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c      | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 0179fc288f5f..21308c5e280b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -107,8 +107,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_gro_supported(ae_dev) \
 		test_bit(HNAE3_DEV_SUPPORT_GRO_B, (ae_dev)->caps)
 
-#define hnae3_dev_fec_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_FEC_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_fec_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_FEC_B, (ae_dev)->caps)
 
 #define hnae3_dev_udp_gso_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index cdf76fb58d45..f866b6676318 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1705,7 +1705,7 @@ static int hns3_get_fecparam(struct net_device *netdev,
 	u8 fec_ability;
 	u8 fec_mode;
 
-	if (!test_bit(HNAE3_DEV_SUPPORT_FEC_B, ae_dev->caps))
+	if (!hnae3_ae_dev_fec_supported(ae_dev))
 		return -EOPNOTSUPP;
 
 	if (!ops->get_fec)
@@ -1729,7 +1729,7 @@ static int hns3_set_fecparam(struct net_device *netdev,
 	const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
 	u32 fec_mode;
 
-	if (!test_bit(HNAE3_DEV_SUPPORT_FEC_B, ae_dev->caps))
+	if (!hnae3_ae_dev_fec_supported(ae_dev))
 		return -EOPNOTSUPP;
 
 	if (!ops->set_fec)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 7b25d8f89427..0134bc8f7865 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -1179,7 +1179,7 @@ static void hclge_parse_fiber_link_mode(struct hclge_dev *hdev,
 	hclge_convert_setting_sr(speed_ability, mac->supported);
 	hclge_convert_setting_lr(speed_ability, mac->supported);
 	hclge_convert_setting_cr(speed_ability, mac->supported);
-	if (hnae3_dev_fec_supported(hdev))
+	if (hnae3_ae_dev_fec_supported(hdev->ae_dev))
 		hclge_convert_setting_fec(mac);
 
 	if (hnae3_dev_pause_supported(hdev))
@@ -1195,7 +1195,7 @@ static void hclge_parse_backplane_link_mode(struct hclge_dev *hdev,
 	struct hclge_mac *mac = &hdev->hw.mac;
 
 	hclge_convert_setting_kr(speed_ability, mac->supported);
-	if (hnae3_dev_fec_supported(hdev))
+	if (hnae3_ae_dev_fec_supported(hdev->ae_dev))
 		hclge_convert_setting_fec(mac);
 
 	if (hnae3_dev_pause_supported(hdev))
@@ -3232,7 +3232,7 @@ static void hclge_update_advertising(struct hclge_dev *hdev)
 static void hclge_update_port_capability(struct hclge_dev *hdev,
 					 struct hclge_mac *mac)
 {
-	if (hnae3_dev_fec_supported(hdev))
+	if (hnae3_ae_dev_fec_supported(hdev->ae_dev))
 		hclge_convert_setting_fec(mac);
 
 	/* firmware can not identify back plane type, the media type
-- 
2.33.0


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

* [PATCH net-next 02/14] net: hns3: modify macro hnae3_dev_udp_gso_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 01/14] net: hns3: modify macro hnae3_dev_fec_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 03/14] net: hns3: modify macro hnae3_dev_qb_supported Guangbin Huang
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_udp_gso_supported(hdev) to
hnae3_ae_dev_udp_gso_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h     | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 21308c5e280b..3bc3fc528ed9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -110,8 +110,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_fec_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_FEC_B, (ae_dev)->caps)
 
-#define hnae3_dev_udp_gso_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_udp_gso_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, (ae_dev)->caps)
 
 #define hnae3_dev_qb_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_QB_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 39b75b68474c..9e4935a90c8b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -3320,7 +3320,7 @@ static void hns3_set_default_feature(struct net_device *netdev)
 	if (hnae3_ae_dev_fd_supported(ae_dev))
 		netdev->features |= NETIF_F_NTUPLE;
 
-	if (test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, ae_dev->caps))
+	if (hnae3_ae_dev_udp_gso_supported(ae_dev))
 		netdev->features |= NETIF_F_GSO_UDP_L4;
 
 	if (test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, ae_dev->caps))
-- 
2.33.0


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

* [PATCH net-next 03/14] net: hns3: modify macro hnae3_dev_qb_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 01/14] net: hns3: modify macro hnae3_dev_fec_supported Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 02/14] net: hns3: modify macro hnae3_dev_udp_gso_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 04/14] net: hns3: modify macro hnae3_dev_fd_forward_tc_supported Guangbin Huang
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_qb_supported(hdev) to
hnae3_ae_dev_qb_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 3bc3fc528ed9..60e06c7be32d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -113,8 +113,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_udp_gso_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, (ae_dev)->caps)
 
-#define hnae3_dev_qb_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_QB_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_qb_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_QB_B, (ae_dev)->caps)
 
 #define hnae3_dev_fd_forward_tc_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, (hdev)->ae_dev->caps)
-- 
2.33.0


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

* [PATCH net-next 04/14] net: hns3: modify macro hnae3_dev_fd_forward_tc_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (2 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 03/14] net: hns3: modify macro hnae3_dev_qb_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 05/14] net: hns3: modify macro hnae3_dev_ptp_supported Guangbin Huang
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_fd_forward_tc_supported(hdev) to
hnae3_ae_dev_fd_forward_tc_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h             | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c         | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 60e06c7be32d..60fda66e08bd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -116,8 +116,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_qb_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_QB_B, (ae_dev)->caps)
 
-#define hnae3_dev_fd_forward_tc_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_fd_forward_tc_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, (ae_dev)->caps)
 
 #define hnae3_dev_ptp_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_PTP_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 9e4935a90c8b..ede31db761b3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -3331,7 +3331,7 @@ static void hns3_set_default_feature(struct net_device *netdev)
 	if (test_bit(HNAE3_DEV_SUPPORT_UDP_TUNNEL_CSUM_B, ae_dev->caps))
 		netdev->features |= NETIF_F_GSO_UDP_TUNNEL_CSUM;
 
-	if (test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, ae_dev->caps))
+	if (hnae3_ae_dev_fd_forward_tc_supported(ae_dev))
 		netdev->features |= NETIF_F_HW_TC;
 
 	netdev->hw_features |= netdev->features;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 0134bc8f7865..5fa5ae7c32a6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -5649,7 +5649,7 @@ static int hclge_fd_ad_config(struct hclge_dev *hdev, u8 stage, int loc,
 		      action->write_rule_id_to_bd);
 	hnae3_set_field(ad_data, HCLGE_FD_AD_RULE_ID_M, HCLGE_FD_AD_RULE_ID_S,
 			action->rule_id);
-	if (test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, ae_dev->caps)) {
+	if (hnae3_ae_dev_fd_forward_tc_supported(ae_dev)) {
 		hnae3_set_bit(ad_data, HCLGE_FD_AD_TC_OVRD_B,
 			      action->override_tc);
 		hnae3_set_field(ad_data, HCLGE_FD_AD_TC_SIZE_M,
-- 
2.33.0


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

* [PATCH net-next 05/14] net: hns3: modify macro hnae3_dev_ptp_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (3 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 04/14] net: hns3: modify macro hnae3_dev_fd_forward_tc_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 06/14] net: hns3: modify macro hnae3_dev_int_ql_supported Guangbin Huang
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_ptp_supported(hdev) to
hnae3_ae_dev_ptp_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h            | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c     | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 60fda66e08bd..dd2dd085ab3d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -119,8 +119,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_fd_forward_tc_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_FD_FORWARD_TC_B, (ae_dev)->caps)
 
-#define hnae3_dev_ptp_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_PTP_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_ptp_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_PTP_B, (ae_dev)->caps)
 
 #define hnae3_dev_int_ql_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_INT_QL_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 66feb23f7b7b..7de1f91c4877 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -1367,7 +1367,7 @@ int hns3_dbg_init(struct hnae3_handle *handle)
 		if ((hns3_dbg_cmd[i].cmd == HNAE3_DBG_CMD_TM_NODES &&
 		     ae_dev->dev_version <= HNAE3_DEVICE_VERSION_V2) ||
 		    (hns3_dbg_cmd[i].cmd == HNAE3_DBG_CMD_PTP_INFO &&
-		     !test_bit(HNAE3_DEV_SUPPORT_PTP_B, ae_dev->caps)))
+		     !hnae3_ae_dev_ptp_supported(ae_dev)))
 			continue;
 
 		if (!hns3_dbg_cmd[i].init) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
index a40b1583f114..aebd98586e62 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
@@ -486,7 +486,7 @@ int hclge_ptp_init(struct hclge_dev *hdev)
 	struct timespec64 ts;
 	int ret;
 
-	if (!test_bit(HNAE3_DEV_SUPPORT_PTP_B, ae_dev->caps))
+	if (!hnae3_ae_dev_ptp_supported(ae_dev))
 		return 0;
 
 	if (!hdev->ptp) {
-- 
2.33.0


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

* [PATCH net-next 06/14] net: hns3: modify macro hnae3_dev_int_ql_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (4 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 05/14] net: hns3: modify macro hnae3_dev_ptp_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 07/14] net: hns3: modify macro hnae3_dev_hw_csum_supported Guangbin Huang
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_int_ql_supported(hdev) to
hnae3_ae_dev_int_ql_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

DTS:
Feature or Bugfix:

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index dd2dd085ab3d..ed06f8db2a27 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -122,8 +122,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_ptp_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_PTP_B, (ae_dev)->caps)
 
-#define hnae3_dev_int_ql_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_INT_QL_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_int_ql_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_INT_QL_B, (ae_dev)->caps)
 
 #define hnae3_dev_hw_csum_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, (hdev)->ae_dev->caps)
-- 
2.33.0


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

* [PATCH net-next 07/14] net: hns3: modify macro hnae3_dev_hw_csum_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (5 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 06/14] net: hns3: modify macro hnae3_dev_int_ql_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 08/14] net: hns3: modify macro hnae3_dev_tx_push_supported Guangbin Huang
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_hw_csum_supported(hdev) to
hnae3_ae_dev_hw_csum_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h     | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index ed06f8db2a27..b802de61e63b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -125,8 +125,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_int_ql_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_INT_QL_B, (ae_dev)->caps)
 
-#define hnae3_dev_hw_csum_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_hw_csum_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, (ae_dev)->caps)
 
 #define hnae3_dev_tx_push_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index ede31db761b3..878c60d58061 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -3323,7 +3323,7 @@ static void hns3_set_default_feature(struct net_device *netdev)
 	if (hnae3_ae_dev_udp_gso_supported(ae_dev))
 		netdev->features |= NETIF_F_GSO_UDP_L4;
 
-	if (test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, ae_dev->caps))
+	if (hnae3_ae_dev_hw_csum_supported(ae_dev))
 		netdev->features |= NETIF_F_HW_CSUM;
 	else
 		netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
@@ -5235,7 +5235,7 @@ static void hns3_state_init(struct hnae3_handle *handle)
 	if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
 		set_bit(HNAE3_PFLAG_LIMIT_PROMISC, &handle->supported_pflags);
 
-	if (test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, ae_dev->caps))
+	if (hnae3_ae_dev_hw_csum_supported(ae_dev))
 		set_bit(HNS3_NIC_STATE_HW_TX_CSUM_ENABLE, &priv->state);
 
 	if (hnae3_ae_dev_rxd_adv_layout_supported(ae_dev))
-- 
2.33.0


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

* [PATCH net-next 08/14] net: hns3: modify macro hnae3_dev_tx_push_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (6 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 07/14] net: hns3: modify macro hnae3_dev_hw_csum_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 09/14] net: hns3: modify macro hnae3_dev_phy_imp_supported Guangbin Huang
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_tx_push_supported(hdev) to
hnae3_ae_dev_tx_push_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h               | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c           | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c        | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index b802de61e63b..2a6d2ff3056b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -128,8 +128,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_hw_csum_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_HW_TX_CSUM_B, (ae_dev)->caps)
 
-#define hnae3_dev_tx_push_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_tx_push_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, (ae_dev)->caps)
 
 #define hnae3_dev_phy_imp_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 878c60d58061..fa7949fb2cb0 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -5229,7 +5229,7 @@ static void hns3_state_init(struct hnae3_handle *handle)
 
 	set_bit(HNS3_NIC_STATE_INITED, &priv->state);
 
-	if (test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps))
+	if (hnae3_ae_dev_tx_push_supported(ae_dev))
 		set_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
 
 	if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index f866b6676318..dd1a32659800 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1192,7 +1192,7 @@ static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push)
 	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
 	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)
+	if (!hnae3_ae_dev_tx_push_supported(ae_dev) && tx_push)
 		return -EOPNOTSUPP;
 
 	if (tx_push == old_state)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 5fa5ae7c32a6..a93df064da46 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -1709,7 +1709,7 @@ static int hclge_alloc_tqps(struct hclge_dev *hdev)
 		 * the queue can execute push mode or doorbell mode on
 		 * device memory.
 		 */
-		if (test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps))
+		if (hnae3_ae_dev_tx_push_supported(ae_dev))
 			tqp->q.mem_base = hdev->hw.hw.mem_base +
 					  HCLGE_TQP_MEM_OFFSET(hdev, i);
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 34ac33783e97..191daa5cc537 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -353,7 +353,7 @@ static int hclgevf_alloc_tqps(struct hclgevf_dev *hdev)
 		 * the queue can execute push mode or doorbell mode on
 		 * device memory.
 		 */
-		if (test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps))
+		if (hnae3_ae_dev_tx_push_supported(ae_dev))
 			tqp->q.mem_base = hdev->hw.hw.mem_base +
 					  HCLGEVF_TQP_MEM_OFFSET(hdev, i);
 
-- 
2.33.0


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

* [PATCH net-next 09/14] net: hns3: modify macro hnae3_dev_phy_imp_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (7 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 08/14] net: hns3: modify macro hnae3_dev_tx_push_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 10/14] net: hns3: modify macro hnae3_dev_ras_imp_supported Guangbin Huang
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_phy_imp_supported(hdev) to
hnae3_ae_dev_phy_imp_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h      |  4 ++--
 .../hisilicon/hns3/hns3_common/hclge_comm_cmd.c  |  2 +-
 .../hisilicon/hns3/hns3_common/hclge_comm_cmd.h  |  3 ---
 .../net/ethernet/hisilicon/hns3/hns3_ethtool.c   |  4 ++--
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c        |  2 +-
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c  | 16 ++++++++--------
 6 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 2a6d2ff3056b..494402074cb9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -131,8 +131,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_tx_push_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, (ae_dev)->caps)
 
-#define hnae3_dev_phy_imp_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_phy_imp_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, (ae_dev)->caps)
 
 #define hnae3_dev_ras_imp_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_RAS_IMP_B, (hdev)->ae_dev->caps)
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 f671a63cecde..bfef94360920 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
@@ -87,7 +87,7 @@ int hclge_comm_firmware_compat_config(struct hnae3_ae_dev *ae_dev,
 
 		hnae3_set_bit(compat, HCLGE_COMM_LINK_EVENT_REPORT_EN_B, 1);
 		hnae3_set_bit(compat, HCLGE_COMM_NCSI_ERROR_REPORT_EN_B, 1);
-		if (hclge_comm_dev_phy_imp_supported(ae_dev))
+		if (hnae3_ae_dev_phy_imp_supported(ae_dev))
 			hnae3_set_bit(compat, HCLGE_COMM_PHY_IMP_EN_B, 1);
 		hnae3_set_bit(compat, HCLGE_COMM_MAC_STATS_EXT_EN_B, 1);
 		hnae3_set_bit(compat, HCLGE_COMM_SYNC_RX_RING_HEAD_EN_B, 1);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
index b1f9383b418f..ba2e46adde72 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h
@@ -22,9 +22,6 @@
 #define HCLGE_COMM_SYNC_RX_RING_HEAD_EN_B	4
 #define HCLGE_COMM_LLRS_FEC_EN_B		5
 
-#define hclge_comm_dev_phy_imp_supported(ae_dev) \
-	test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, (ae_dev)->caps)
-
 #define HCLGE_COMM_TYPE_CRQ			0
 #define HCLGE_COMM_TYPE_CSQ			1
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index dd1a32659800..e4278ec95d21 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -789,7 +789,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 		break;
 	case HNAE3_MEDIA_TYPE_COPPER:
 		cmd->base.port = PORT_TP;
-		if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
+		if (hnae3_ae_dev_phy_imp_supported(ae_dev) &&
 		    ops->get_phy_link_ksettings)
 			ops->get_phy_link_ksettings(h, cmd);
 		else if (!netdev->phydev)
@@ -890,7 +890,7 @@ static int hns3_set_link_ksettings(struct net_device *netdev,
 			return -EINVAL;
 
 		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
-	} else if (test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, ae_dev->caps) &&
+	} else if (hnae3_ae_dev_phy_imp_supported(ae_dev) &&
 		   ops->set_phy_link_ksettings) {
 		return ops->set_phy_link_ksettings(handle, cmd);
 	}
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index 142415c84c6b..90000ec07d55 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -1932,7 +1932,7 @@ static int hclge_dbg_dump_loopback(struct hclge_dev *hdev, char *buf, int len)
 		loopback_en = phydev->loopback_enabled;
 		pos += scnprintf(buf + pos, len - pos, "phy loopback: %s\n",
 				 state_str[loopback_en]);
-	} else if (hnae3_dev_phy_imp_supported(hdev)) {
+	} else if (hnae3_ae_dev_phy_imp_supported(hdev->ae_dev)) {
 		loopback_en = req_common->enable &
 			      HCLGE_CMD_GE_PHY_INNER_LOOP_B;
 		pos += scnprintf(buf + pos, len - pos, "phy loopback: %s\n",
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index a93df064da46..7995e3388778 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -751,7 +751,7 @@ static int hclge_get_sset_count(struct hnae3_handle *handle, int stringset)
 
 		if ((hdev->hw.mac.phydev && hdev->hw.mac.phydev->drv &&
 		     hdev->hw.mac.phydev->drv->set_loopback) ||
-		    hnae3_dev_phy_imp_supported(hdev)) {
+		    hnae3_ae_dev_phy_imp_supported(hdev->ae_dev)) {
 			count += 1;
 			handle->flags |= HNAE3_SUPPORT_PHY_LOOPBACK;
 		}
@@ -3433,7 +3433,7 @@ static int hclge_update_tp_port_info(struct hclge_dev *hdev)
 	struct ethtool_link_ksettings cmd;
 	int ret;
 
-	if (!hnae3_dev_phy_imp_supported(hdev))
+	if (!hnae3_ae_dev_phy_imp_supported(hdev->ae_dev))
 		return 0;
 
 	ret = hclge_get_phy_link_ksettings(&hdev->vport->nic, &cmd);
@@ -3451,7 +3451,7 @@ static int hclge_tp_port_init(struct hclge_dev *hdev)
 {
 	struct ethtool_link_ksettings cmd;
 
-	if (!hnae3_dev_phy_imp_supported(hdev))
+	if (!hnae3_ae_dev_phy_imp_supported(hdev->ae_dev))
 		return 0;
 
 	cmd.base.autoneg = hdev->hw.mac.autoneg;
@@ -7852,7 +7852,7 @@ static int hclge_set_phy_loopback(struct hclge_dev *hdev, bool en)
 	int ret;
 
 	if (!phydev) {
-		if (hnae3_dev_phy_imp_supported(hdev))
+		if (hnae3_ae_dev_phy_imp_supported(hdev->ae_dev))
 			return hclge_set_common_loopback(hdev, en,
 							 HNAE3_LOOP_PHY);
 		return -ENOTSUPP;
@@ -9369,7 +9369,7 @@ static int hclge_mii_ioctl(struct hclge_dev *hdev, struct ifreq *ifr, int cmd)
 {
 	struct mii_ioctl_data *data = if_mii(ifr);
 
-	if (!hnae3_dev_phy_imp_supported(hdev))
+	if (!hnae3_ae_dev_phy_imp_supported(hdev->ae_dev))
 		return -EOPNOTSUPP;
 
 	switch (cmd) {
@@ -10975,7 +10975,7 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
 	struct phy_device *phydev = hdev->hw.mac.phydev;
 	u32 fc_autoneg;
 
-	if (phydev || hnae3_dev_phy_imp_supported(hdev)) {
+	if (phydev || hnae3_ae_dev_phy_imp_supported(hdev->ae_dev)) {
 		fc_autoneg = hclge_get_autoneg(handle);
 		if (auto_neg != fc_autoneg) {
 			dev_info(&hdev->pdev->dev,
@@ -10994,7 +10994,7 @@ static int hclge_set_pauseparam(struct hnae3_handle *handle, u32 auto_neg,
 
 	hclge_record_user_pauseparam(hdev, rx_en, tx_en);
 
-	if (!auto_neg || hnae3_dev_phy_imp_supported(hdev))
+	if (!auto_neg || hnae3_ae_dev_phy_imp_supported(hdev->ae_dev))
 		return hclge_cfg_pauseparam(hdev, rx_en, tx_en);
 
 	if (phydev)
@@ -11588,7 +11588,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
 		goto err_msi_irq_uninit;
 
 	if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER &&
-	    !hnae3_dev_phy_imp_supported(hdev)) {
+	    !hnae3_ae_dev_phy_imp_supported(hdev->ae_dev)) {
 		ret = hclge_mac_mdio_config(hdev);
 		if (ret)
 			goto err_msi_irq_uninit;
-- 
2.33.0


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

* [PATCH net-next 10/14] net: hns3: modify macro hnae3_dev_ras_imp_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (8 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 09/14] net: hns3: modify macro hnae3_dev_phy_imp_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 11/14] net: hns3: delete redundant macro hnae3_dev_tqp_txrx_indep_supported Guangbin Huang
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_ras_imp_supported(hdev) to
hnae3_ae_dev_ras_imp_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h             | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 494402074cb9..0d8e0c461a31 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -134,8 +134,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_phy_imp_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_PHY_IMP_B, (ae_dev)->caps)
 
-#define hnae3_dev_ras_imp_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_RAS_IMP_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_ras_imp_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_RAS_IMP_B, (ae_dev)->caps)
 
 #define hnae3_dev_tqp_txrx_indep_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_TQP_TXRX_INDEP_B, (hdev)->ae_dev->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 7995e3388778..cc3ba2a16f5e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4579,7 +4579,7 @@ static void hclge_errhand_service_task(struct hclge_dev *hdev)
 	if (!test_and_clear_bit(HCLGE_STATE_ERR_SERVICE_SCHED, &hdev->state))
 		return;
 
-	if (hnae3_dev_ras_imp_supported(hdev))
+	if (hnae3_ae_dev_ras_imp_supported(hdev->ae_dev))
 		hclge_handle_err_recovery(hdev);
 	else
 		hclge_misc_err_recovery(hdev);
@@ -11671,7 +11671,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
 	hclge_clear_resetting_state(hdev);
 
 	/* Log and clear the hw errors those already occurred */
-	if (hnae3_dev_ras_imp_supported(hdev))
+	if (hnae3_ae_dev_ras_imp_supported(hdev->ae_dev))
 		hclge_handle_occurred_error(hdev);
 	else
 		hclge_handle_all_hns_hw_errors(ae_dev);
@@ -12035,7 +12035,7 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
 		return ret;
 
 	/* Log and clear the hw errors those already occurred */
-	if (hnae3_dev_ras_imp_supported(hdev))
+	if (hnae3_ae_dev_ras_imp_supported(hdev->ae_dev))
 		hclge_handle_occurred_error(hdev);
 	else
 		hclge_handle_all_hns_hw_errors(ae_dev);
-- 
2.33.0


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

* [PATCH net-next 11/14] net: hns3: delete redundant macro hnae3_dev_tqp_txrx_indep_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (9 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 10/14] net: hns3: modify macro hnae3_dev_ras_imp_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 12/14] net: hns3: modify macro hnae3_dev_hw_pad_supported Guangbin Huang
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

There is macro hnae3_ae_dev_tqp_txrx_indep_supported(ae_dev) can be used
in both hclge and hns3_enet layer.

The macro hnae3_dev_tqp_txrx_indep_supported(hdev) is redundant, so delete
it.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 0d8e0c461a31..12730cbc3bfe 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -137,9 +137,6 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_ras_imp_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_RAS_IMP_B, (ae_dev)->caps)
 
-#define hnae3_dev_tqp_txrx_indep_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_TQP_TXRX_INDEP_B, (hdev)->ae_dev->caps)
-
 #define hnae3_dev_hw_pad_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_HW_PAD_B, (hdev)->ae_dev->caps)
 
-- 
2.33.0


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

* [PATCH net-next 12/14] net: hns3: modify macro hnae3_dev_hw_pad_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (10 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 11/14] net: hns3: delete redundant macro hnae3_dev_tqp_txrx_indep_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 13/14] net: hns3: modify macro hnae3_dev_stash_supported Guangbin Huang
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_hw_pad_supported(hdev) to
hnae3_ae_dev_hw_pad_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 12730cbc3bfe..99140a7617f3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -137,8 +137,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_ras_imp_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_RAS_IMP_B, (ae_dev)->caps)
 
-#define hnae3_dev_hw_pad_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_HW_PAD_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_hw_pad_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_HW_PAD_B, (ae_dev)->caps)
 
 #define hnae3_dev_stash_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_STASH_B, (hdev)->ae_dev->caps)
-- 
2.33.0


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

* [PATCH net-next 13/14] net: hns3: modify macro hnae3_dev_stash_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (11 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 12/14] net: hns3: modify macro hnae3_dev_hw_pad_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24  2:30 ` [PATCH net-next 14/14] net: hns3: modify macro hnae3_dev_pause_supported Guangbin Huang
  2022-09-24 11:27 ` [PATCH net-next 00/14] redefine some macros of feature abilities judgement Leon Romanovsky
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_stash_supported(hdev) to
hnae3_ae_dev_stash_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 99140a7617f3..94b71701a74d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -140,8 +140,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_hw_pad_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_HW_PAD_B, (ae_dev)->caps)
 
-#define hnae3_dev_stash_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_STASH_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_stash_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_STASH_B, (ae_dev)->caps)
 
 #define hnae3_dev_pause_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, (hdev)->ae_dev->caps)
-- 
2.33.0


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

* [PATCH net-next 14/14] net: hns3: modify macro hnae3_dev_pause_supported
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (12 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 13/14] net: hns3: modify macro hnae3_dev_stash_supported Guangbin Huang
@ 2022-09-24  2:30 ` Guangbin Huang
  2022-09-24 11:27 ` [PATCH net-next 00/14] redefine some macros of feature abilities judgement Leon Romanovsky
  14 siblings, 0 replies; 20+ messages in thread
From: Guangbin Huang @ 2022-09-24  2:30 UTC (permalink / raw)
  To: davem, kuba
  Cc: edumazet, pabeni, netdev, linux-kernel, huangguangbin2,
	lipeng321, lanhao

Redefine macro hnae3_dev_pause_supported(hdev) to
hnae3_ae_dev_pause_supported(ae_dev), so it can be
used in both hclge and hns3_enet layer.

Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h             | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c      | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 94b71701a74d..1bd695e88cca 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -143,8 +143,8 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_stash_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_STASH_B, (ae_dev)->caps)
 
-#define hnae3_dev_pause_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, (hdev)->ae_dev->caps)
+#define hnae3_ae_dev_pause_supported(ae_dev) \
+	test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, (ae_dev)->caps)
 
 #define hnae3_ae_dev_tqp_txrx_indep_supported(ae_dev) \
 	test_bit(HNAE3_DEV_SUPPORT_TQP_TXRX_INDEP_B, (ae_dev)->caps)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index e4278ec95d21..58f19006e403 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -701,7 +701,7 @@ static void hns3_get_pauseparam(struct net_device *netdev,
 	struct hnae3_handle *h = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
 
-	if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps))
+	if (!hnae3_ae_dev_pause_supported(ae_dev))
 		return;
 
 	if (h->ae_algo->ops->get_pauseparam)
@@ -715,7 +715,7 @@ static int hns3_set_pauseparam(struct net_device *netdev,
 	struct hnae3_handle *h = hns3_get_handle(netdev);
 	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev);
 
-	if (!test_bit(HNAE3_DEV_SUPPORT_PAUSE_B, ae_dev->caps))
+	if (!hnae3_ae_dev_pause_supported(ae_dev))
 		return -EOPNOTSUPP;
 
 	netif_dbg(h, drv, netdev,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index cc3ba2a16f5e..e8e18bac5b50 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -1182,7 +1182,7 @@ static void hclge_parse_fiber_link_mode(struct hclge_dev *hdev,
 	if (hnae3_ae_dev_fec_supported(hdev->ae_dev))
 		hclge_convert_setting_fec(mac);
 
-	if (hnae3_dev_pause_supported(hdev))
+	if (hnae3_ae_dev_pause_supported(hdev->ae_dev))
 		linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, mac->supported);
 
 	linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, mac->supported);
@@ -1198,7 +1198,7 @@ static void hclge_parse_backplane_link_mode(struct hclge_dev *hdev,
 	if (hnae3_ae_dev_fec_supported(hdev->ae_dev))
 		hclge_convert_setting_fec(mac);
 
-	if (hnae3_dev_pause_supported(hdev))
+	if (hnae3_ae_dev_pause_supported(hdev->ae_dev))
 		linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, mac->supported);
 
 	linkmode_set_bit(ETHTOOL_LINK_MODE_Backplane_BIT, mac->supported);
@@ -1230,7 +1230,7 @@ static void hclge_parse_copper_link_mode(struct hclge_dev *hdev,
 		linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, supported);
 	}
 
-	if (hnae3_dev_pause_supported(hdev)) {
+	if (hnae3_ae_dev_pause_supported(hdev->ae_dev)) {
 		linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, supported);
 		linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, supported);
 	}
-- 
2.33.0


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

* Re: [PATCH net-next 00/14] redefine some macros of feature abilities judgement
  2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
                   ` (13 preceding siblings ...)
  2022-09-24  2:30 ` [PATCH net-next 14/14] net: hns3: modify macro hnae3_dev_pause_supported Guangbin Huang
@ 2022-09-24 11:27 ` Leon Romanovsky
  2022-09-26 12:56   ` huangguangbin (A)
  14 siblings, 1 reply; 20+ messages in thread
From: Leon Romanovsky @ 2022-09-24 11:27 UTC (permalink / raw)
  To: Guangbin Huang, kuba
  Cc: davem, edumazet, pabeni, netdev, linux-kernel, lipeng321, lanhao

On Sat, Sep 24, 2022 at 10:30:10AM +0800, Guangbin Huang wrote:
> The macros hnae3_dev_XXX_supported just can be used in hclge layer, but
> hns3_enet layer may need to use, so this serial redefine these macros.

IMHO, you shouldn't add new obfuscated code, but delete it.

Jakub,

The more drivers authors will obfuscate in-kernel primitives and reinvent
their own names, macros e.t.c, the less external reviewers you will be able
to attract.

IMHO, netdev should have more active position do not allow obfuscated code.

Thanks

> 
> Guangbin Huang (14):
>   net: hns3: modify macro hnae3_dev_fec_supported
>   net: hns3: modify macro hnae3_dev_udp_gso_supported
>   net: hns3: modify macro hnae3_dev_qb_supported
>   net: hns3: modify macro hnae3_dev_fd_forward_tc_supported
>   net: hns3: modify macro hnae3_dev_ptp_supported
>   net: hns3: modify macro hnae3_dev_int_ql_supported
>   net: hns3: modify macro hnae3_dev_hw_csum_supported
>   net: hns3: modify macro hnae3_dev_tx_push_supported
>   net: hns3: modify macro hnae3_dev_phy_imp_supported
>   net: hns3: modify macro hnae3_dev_ras_imp_supported
>   net: hns3: delete redundant macro hnae3_dev_tqp_txrx_indep_supported
>   net: hns3: modify macro hnae3_dev_hw_pad_supported
>   net: hns3: modify macro hnae3_dev_stash_supported
>   net: hns3: modify macro hnae3_dev_pause_supported
> 
>  drivers/net/ethernet/hisilicon/hns3/hnae3.h   | 55 +++++++++----------
>  .../hns3/hns3_common/hclge_comm_cmd.c         |  2 +-
>  .../hns3/hns3_common/hclge_comm_cmd.h         |  3 -
>  .../ethernet/hisilicon/hns3/hns3_debugfs.c    |  2 +-
>  .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 10 ++--
>  .../ethernet/hisilicon/hns3/hns3_ethtool.c    | 14 ++---
>  .../hisilicon/hns3/hns3pf/hclge_debugfs.c     |  2 +-
>  .../hisilicon/hns3/hns3pf/hclge_main.c        | 38 ++++++-------
>  .../hisilicon/hns3/hns3pf/hclge_ptp.c         |  2 +-
>  .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  2 +-
>  10 files changed, 62 insertions(+), 68 deletions(-)
> 
> -- 
> 2.33.0
> 

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

* Re: [PATCH net-next 00/14] redefine some macros of feature abilities judgement
  2022-09-24 11:27 ` [PATCH net-next 00/14] redefine some macros of feature abilities judgement Leon Romanovsky
@ 2022-09-26 12:56   ` huangguangbin (A)
  2022-09-26 17:11     ` Jakub Kicinski
  0 siblings, 1 reply; 20+ messages in thread
From: huangguangbin (A) @ 2022-09-26 12:56 UTC (permalink / raw)
  To: Leon Romanovsky, kuba
  Cc: davem, edumazet, pabeni, netdev, linux-kernel, lipeng321, lanhao



On 2022/9/24 19:27, Leon Romanovsky wrote:
> On Sat, Sep 24, 2022 at 10:30:10AM +0800, Guangbin Huang wrote:
>> The macros hnae3_dev_XXX_supported just can be used in hclge layer, but
>> hns3_enet layer may need to use, so this serial redefine these macros.
> 
> IMHO, you shouldn't add new obfuscated code, but delete it.
> 
> Jakub,
> 
> The more drivers authors will obfuscate in-kernel primitives and reinvent
> their own names, macros e.t.c, the less external reviewers you will be able
> to attract.
> 
> IMHO, netdev should have more active position do not allow obfuscated code.
> 
> Thanks
> 

Hi, Leon
I'm sorry, I can not get your point. Can you explain in more detail?
Do you mean the name "macro" should not be used?

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

* Re: [PATCH net-next 00/14] redefine some macros of feature abilities judgement
  2022-09-26 12:56   ` huangguangbin (A)
@ 2022-09-26 17:11     ` Jakub Kicinski
  2022-09-27  3:21       ` huangguangbin (A)
  2022-09-27 10:24       ` Leon Romanovsky
  0 siblings, 2 replies; 20+ messages in thread
From: Jakub Kicinski @ 2022-09-26 17:11 UTC (permalink / raw)
  To: huangguangbin (A)
  Cc: Leon Romanovsky, davem, edumazet, pabeni, netdev, linux-kernel,
	lipeng321, lanhao

On Mon, 26 Sep 2022 20:56:26 +0800 huangguangbin (A) wrote:
> On 2022/9/24 19:27, Leon Romanovsky wrote:
> > On Sat, Sep 24, 2022 at 10:30:10AM +0800, Guangbin Huang wrote:  
> >> The macros hnae3_dev_XXX_supported just can be used in hclge layer, but
> >> hns3_enet layer may need to use, so this serial redefine these macros.  
> > 
> > IMHO, you shouldn't add new obfuscated code, but delete it.
> > 
> > Jakub,
> > 
> > The more drivers authors will obfuscate in-kernel primitives and reinvent
> > their own names, macros e.t.c, the less external reviewers you will be able
> > to attract.
> > 
> > IMHO, netdev should have more active position do not allow obfuscated code.
> > 
> > Thanks
> >   
> 
> Hi, Leon
> I'm sorry, I can not get your point. Can you explain in more detail?
> Do you mean the name "macro" should not be used?

He is saying that you should try to remove those macros rather than
touch them up. The macros may seem obvious to people working on the
driver but to upstream reviewers any local conventions obfuscate the
code and require looking up definitions.

For example the first patch is better off as:

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 0179fc288f5f..449d496b824b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -107,9 +107,6 @@ enum HNAE3_DEV_CAP_BITS {
 #define hnae3_ae_dev_gro_supported(ae_dev) \
 		test_bit(HNAE3_DEV_SUPPORT_GRO_B, (ae_dev)->caps)
 
-#define hnae3_dev_fec_supported(hdev) \
-	test_bit(HNAE3_DEV_SUPPORT_FEC_B, (hdev)->ae_dev->caps)
-
 #define hnae3_dev_udp_gso_supported(hdev) \
 	test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, (hdev)->ae_dev->caps)
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 6962a9d69cf8..ded92f7dbd79 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -1179,7 +1179,7 @@ static void hclge_parse_fiber_link_mode(struct hclge_dev *hdev,
 	hclge_convert_setting_sr(speed_ability, mac->supported);
 	hclge_convert_setting_lr(speed_ability, mac->supported);
 	hclge_convert_setting_cr(speed_ability, mac->supported);
-	if (hnae3_dev_fec_supported(hdev))
+	if (test_bit(HNAE3_DEV_SUPPORT_FEC_B, hdev->caps))
 		hclge_convert_setting_fec(mac);
 
 	if (hnae3_dev_pause_supported(hdev))
@@ -1195,7 +1195,7 @@ static void hclge_parse_backplane_link_mode(struct hclge_dev *hdev,
 	struct hclge_mac *mac = &hdev->hw.mac;
 
 	hclge_convert_setting_kr(speed_ability, mac->supported);
-	if (hnae3_dev_fec_supported(hdev))
+	if (test_bit(HNAE3_DEV_SUPPORT_FEC_B, hdev->caps))
 		hclge_convert_setting_fec(mac);
 
 	if (hnae3_dev_pause_supported(hdev))
@@ -3232,7 +3232,7 @@ static void hclge_update_advertising(struct hclge_dev *hdev)
 static void hclge_update_port_capability(struct hclge_dev *hdev,
 					 struct hclge_mac *mac)
 {
-	if (hnae3_dev_fec_supported(hdev))
+	if (test_bit(HNAE3_DEV_SUPPORT_FEC_B, hdev->caps))
 		hclge_convert_setting_fec(mac);
 
 	/* firmware can not identify back plane type, the media type

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

* Re: [PATCH net-next 00/14] redefine some macros of feature abilities judgement
  2022-09-26 17:11     ` Jakub Kicinski
@ 2022-09-27  3:21       ` huangguangbin (A)
  2022-09-27 10:24       ` Leon Romanovsky
  1 sibling, 0 replies; 20+ messages in thread
From: huangguangbin (A) @ 2022-09-27  3:21 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Leon Romanovsky, davem, edumazet, pabeni, netdev, linux-kernel,
	lipeng321, lanhao



On 2022/9/27 1:11, Jakub Kicinski wrote:
> On Mon, 26 Sep 2022 20:56:26 +0800 huangguangbin (A) wrote:
>> On 2022/9/24 19:27, Leon Romanovsky wrote:
>>> On Sat, Sep 24, 2022 at 10:30:10AM +0800, Guangbin Huang wrote:
>>>> The macros hnae3_dev_XXX_supported just can be used in hclge layer, but
>>>> hns3_enet layer may need to use, so this serial redefine these macros.
>>>
>>> IMHO, you shouldn't add new obfuscated code, but delete it.
>>>
>>> Jakub,
>>>
>>> The more drivers authors will obfuscate in-kernel primitives and reinvent
>>> their own names, macros e.t.c, the less external reviewers you will be able
>>> to attract.
>>>
>>> IMHO, netdev should have more active position do not allow obfuscated code.
>>>
>>> Thanks
>>>    
>>
>> Hi, Leon
>> I'm sorry, I can not get your point. Can you explain in more detail?
>> Do you mean the name "macro" should not be used?
> 
> He is saying that you should try to remove those macros rather than
> touch them up. The macros may seem obvious to people working on the
> driver but to upstream reviewers any local conventions obfuscate the
> code and require looking up definitions.
> 
> For example the first patch is better off as:
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> index 0179fc288f5f..449d496b824b 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
> @@ -107,9 +107,6 @@ enum HNAE3_DEV_CAP_BITS {
>   #define hnae3_ae_dev_gro_supported(ae_dev) \
>   		test_bit(HNAE3_DEV_SUPPORT_GRO_B, (ae_dev)->caps)
>   
> -#define hnae3_dev_fec_supported(hdev) \
> -	test_bit(HNAE3_DEV_SUPPORT_FEC_B, (hdev)->ae_dev->caps)
> -
>   #define hnae3_dev_udp_gso_supported(hdev) \
>   	test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, (hdev)->ae_dev->caps)
>   
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> index 6962a9d69cf8..ded92f7dbd79 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
> @@ -1179,7 +1179,7 @@ static void hclge_parse_fiber_link_mode(struct hclge_dev *hdev,
>   	hclge_convert_setting_sr(speed_ability, mac->supported);
>   	hclge_convert_setting_lr(speed_ability, mac->supported);
>   	hclge_convert_setting_cr(speed_ability, mac->supported);
> -	if (hnae3_dev_fec_supported(hdev))
> +	if (test_bit(HNAE3_DEV_SUPPORT_FEC_B, hdev->caps))
>   		hclge_convert_setting_fec(mac);
>   
>   	if (hnae3_dev_pause_supported(hdev))
> @@ -1195,7 +1195,7 @@ static void hclge_parse_backplane_link_mode(struct hclge_dev *hdev,
>   	struct hclge_mac *mac = &hdev->hw.mac;
>   
>   	hclge_convert_setting_kr(speed_ability, mac->supported);
> -	if (hnae3_dev_fec_supported(hdev))
> +	if (test_bit(HNAE3_DEV_SUPPORT_FEC_B, hdev->caps))
>   		hclge_convert_setting_fec(mac);
>   
>   	if (hnae3_dev_pause_supported(hdev))
> @@ -3232,7 +3232,7 @@ static void hclge_update_advertising(struct hclge_dev *hdev)
>   static void hclge_update_port_capability(struct hclge_dev *hdev,
>   					 struct hclge_mac *mac)
>   {
> -	if (hnae3_dev_fec_supported(hdev))
> +	if (test_bit(HNAE3_DEV_SUPPORT_FEC_B, hdev->caps))
>   		hclge_convert_setting_fec(mac);
>   
>   	/* firmware can not identify back plane type, the media type
> .
> 
Ok, I see, thanks!

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

* Re: [PATCH net-next 00/14] redefine some macros of feature abilities judgement
  2022-09-26 17:11     ` Jakub Kicinski
  2022-09-27  3:21       ` huangguangbin (A)
@ 2022-09-27 10:24       ` Leon Romanovsky
  1 sibling, 0 replies; 20+ messages in thread
From: Leon Romanovsky @ 2022-09-27 10:24 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: huangguangbin (A),
	davem, edumazet, pabeni, netdev, linux-kernel, lipeng321, lanhao

On Mon, Sep 26, 2022 at 10:11:35AM -0700, Jakub Kicinski wrote:
> On Mon, 26 Sep 2022 20:56:26 +0800 huangguangbin (A) wrote:
> > On 2022/9/24 19:27, Leon Romanovsky wrote:
> > > On Sat, Sep 24, 2022 at 10:30:10AM +0800, Guangbin Huang wrote:  
> > >> The macros hnae3_dev_XXX_supported just can be used in hclge layer, but
> > >> hns3_enet layer may need to use, so this serial redefine these macros.  
> > > 
> > > IMHO, you shouldn't add new obfuscated code, but delete it.
> > > 
> > > Jakub,
> > > 
> > > The more drivers authors will obfuscate in-kernel primitives and reinvent
> > > their own names, macros e.t.c, the less external reviewers you will be able
> > > to attract.
> > > 
> > > IMHO, netdev should have more active position do not allow obfuscated code.
> > > 
> > > Thanks
> > >   
> > 
> > Hi, Leon
> > I'm sorry, I can not get your point. Can you explain in more detail?
> > Do you mean the name "macro" should not be used?
> 
> He is saying that you should try to remove those macros rather than
> touch them up. 

Exactly, thanks Jakub.

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

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

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-24  2:30 [PATCH net-next 00/14] redefine some macros of feature abilities judgement Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 01/14] net: hns3: modify macro hnae3_dev_fec_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 02/14] net: hns3: modify macro hnae3_dev_udp_gso_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 03/14] net: hns3: modify macro hnae3_dev_qb_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 04/14] net: hns3: modify macro hnae3_dev_fd_forward_tc_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 05/14] net: hns3: modify macro hnae3_dev_ptp_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 06/14] net: hns3: modify macro hnae3_dev_int_ql_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 07/14] net: hns3: modify macro hnae3_dev_hw_csum_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 08/14] net: hns3: modify macro hnae3_dev_tx_push_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 09/14] net: hns3: modify macro hnae3_dev_phy_imp_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 10/14] net: hns3: modify macro hnae3_dev_ras_imp_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 11/14] net: hns3: delete redundant macro hnae3_dev_tqp_txrx_indep_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 12/14] net: hns3: modify macro hnae3_dev_hw_pad_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 13/14] net: hns3: modify macro hnae3_dev_stash_supported Guangbin Huang
2022-09-24  2:30 ` [PATCH net-next 14/14] net: hns3: modify macro hnae3_dev_pause_supported Guangbin Huang
2022-09-24 11:27 ` [PATCH net-next 00/14] redefine some macros of feature abilities judgement Leon Romanovsky
2022-09-26 12:56   ` huangguangbin (A)
2022-09-26 17:11     ` Jakub Kicinski
2022-09-27  3:21       ` huangguangbin (A)
2022-09-27 10:24       ` Leon Romanovsky

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