All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jian Shen <shenjian15@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <andrew@lunn.ch>,
	<ecree.xilinx@gmail.com>, <hkallweit1@gmail.com>,
	<alexandr.lobakin@intel.com>, <saeed@kernel.org>,
	<leon@kernel.org>
Cc: <netdev@vger.kernel.org>, <linuxarm@openeuler.org>
Subject: [RFCv7 PATCH net-next 05/36] net: atlantic: replace const features initialization with NETDEV_FEATURE_SET
Date: Wed, 10 Aug 2022 11:05:53 +0800	[thread overview]
Message-ID: <20220810030624.34711-6-shenjian15@huawei.com> (raw)
In-Reply-To: <20220810030624.34711-1-shenjian15@huawei.com>

The atlantic driver use netdev_features in global structure
initialization. Changed the its netdev_features_t memeber
to netdev_features_t *, and make it refer to a netdev_features_t
global variables.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 .../net/ethernet/aquantia/atlantic/aq_hw.h    |  2 +-
 .../net/ethernet/aquantia/atlantic/aq_main.c  | 58 ++++++++++++++++++-
 .../net/ethernet/aquantia/atlantic/aq_nic.c   |  6 +-
 .../net/ethernet/aquantia/atlantic/aq_nic.h   |  6 +-
 .../aquantia/atlantic/hw_atl/hw_atl_a0.c      |  8 +--
 .../aquantia/atlantic/hw_atl/hw_atl_b0.c      | 15 +----
 .../aquantia/atlantic/hw_atl2/hw_atl2.c       | 15 +----
 7 files changed, 69 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index dbd284660135..b4ee2625fbba 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -43,7 +43,7 @@ enum aq_tc_mode {
 
 /* NIC H/W capabilities */
 struct aq_hw_caps_s {
-	u64 hw_features;
+	const netdev_features_t *hw_features;
 	u64 link_speed_msk;
 	unsigned int hw_priv_flags;
 	u32 media_type;
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
index 88595863d8bc..71acce12baec 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c
@@ -17,6 +17,7 @@
 #include "aq_vec.h"
 
 #include <linux/netdevice.h>
+#include <linux/netdev_features_helper.h>
 #include <linux/module.h>
 #include <linux/ip.h>
 #include <linux/udp.h>
@@ -36,6 +37,49 @@ static const struct net_device_ops aq_ndev_ops;
 
 static struct workqueue_struct *aq_ndev_wq;
 
+static DECLARE_NETDEV_FEATURE_SET(hw_atl2_feature_set,
+				  NETIF_F_HW_CSUM_BIT,
+				  NETIF_F_RXCSUM_BIT,
+				  NETIF_F_RXHASH_BIT,
+				  NETIF_F_SG_BIT,
+				  NETIF_F_TSO_BIT,
+				  NETIF_F_TSO6_BIT,
+				  NETIF_F_LRO_BIT,
+				  NETIF_F_NTUPLE_BIT,
+				  NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+				  NETIF_F_HW_VLAN_CTAG_RX_BIT,
+				  NETIF_F_HW_VLAN_CTAG_TX_BIT,
+				  NETIF_F_GSO_UDP_L4_BIT,
+				  NETIF_F_GSO_PARTIAL_BIT,
+				  NETIF_F_HW_TC_BIT);
+static DECLARE_NETDEV_FEATURE_SET(hw_atl_a0_feature_set,
+				  NETIF_F_HW_CSUM_BIT,
+				  NETIF_F_RXHASH_BIT,
+				  NETIF_F_RXCSUM_BIT,
+				  NETIF_F_SG_BIT,
+				  NETIF_F_TSO_BIT,
+				  NETIF_F_NTUPLE_BIT,
+				  NETIF_F_HW_VLAN_CTAG_FILTER_BIT);
+static DECLARE_NETDEV_FEATURE_SET(hw_atl_b0_feature_set,
+				  NETIF_F_HW_CSUM_BIT,
+				  NETIF_F_RXCSUM_BIT,
+				  NETIF_F_RXHASH_BIT,
+				  NETIF_F_SG_BIT,
+				  NETIF_F_TSO_BIT,
+				  NETIF_F_TSO6_BIT,
+				  NETIF_F_LRO_BIT,
+				  NETIF_F_NTUPLE_BIT,
+				  NETIF_F_HW_VLAN_CTAG_FILTER_BIT,
+				  NETIF_F_HW_VLAN_CTAG_RX_BIT,
+				  NETIF_F_HW_VLAN_CTAG_TX_BIT,
+				  NETIF_F_GSO_UDP_L4_BIT,
+				  NETIF_F_GSO_PARTIAL_BIT,
+				  NETIF_F_HW_TC_BIT);
+
+netdev_features_t hw_atl2_features __ro_after_init;
+netdev_features_t hw_atl_a0_features __ro_after_init;
+netdev_features_t hw_atl_b0_features __ro_after_init;
+
 void aq_ndev_schedule_work(struct work_struct *work)
 {
 	queue_work(aq_ndev_wq, work);
@@ -184,7 +228,7 @@ static int aq_ndev_set_features(struct net_device *ndev,
 
 	aq_cfg->features = features;
 
-	if (aq_cfg->aq_hw_caps->hw_features & NETIF_F_LRO) {
+	if (*aq_cfg->aq_hw_caps->hw_features & NETIF_F_LRO) {
 		is_lro = features & NETIF_F_LRO;
 
 		if (aq_cfg->is_lro != is_lro) {
@@ -511,6 +555,16 @@ static const struct net_device_ops aq_ndev_ops = {
 	.ndo_xdp_xmit = aq_xdp_xmit,
 };
 
+static void __init aq_features_init(void)
+{
+	netdev_features_set_array(&hw_atl2_feature_set,
+				  &hw_atl2_features);
+	netdev_features_set_array(&hw_atl_a0_feature_set,
+				  &hw_atl_a0_features);
+	netdev_features_set_array(&hw_atl_b0_feature_set,
+				  &hw_atl_b0_features);
+}
+
 static int __init aq_ndev_init_module(void)
 {
 	int ret;
@@ -527,6 +581,8 @@ static int __init aq_ndev_init_module(void)
 		return ret;
 	}
 
+	aq_features_init();
+
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 2a726e6213b4..a8de1fb20a3f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -145,7 +145,7 @@ void aq_nic_cfg_start(struct aq_nic_s *self)
 		cfg->link_irq_vec = 0;
 
 	cfg->link_speed_msk &= cfg->aq_hw_caps->link_speed_msk;
-	cfg->features = cfg->aq_hw_caps->hw_features;
+	cfg->features = *cfg->aq_hw_caps->hw_features;
 	cfg->is_vlan_rx_strip = !!(cfg->features & NETIF_F_HW_VLAN_CTAG_RX);
 	cfg->is_vlan_tx_insert = !!(cfg->features & NETIF_F_HW_VLAN_CTAG_TX);
 	cfg->is_vlan_force_promisc = true;
@@ -383,8 +383,8 @@ void aq_nic_ndev_init(struct aq_nic_s *self)
 	const struct aq_hw_caps_s *aq_hw_caps = self->aq_nic_cfg.aq_hw_caps;
 	struct aq_nic_cfg_s *aq_nic_cfg = &self->aq_nic_cfg;
 
-	self->ndev->hw_features |= aq_hw_caps->hw_features;
-	self->ndev->features = aq_hw_caps->hw_features;
+	self->ndev->hw_features |= *aq_hw_caps->hw_features;
+	self->ndev->features = *aq_hw_caps->hw_features;
 	netdev_vlan_features_set_array(self->ndev, &aq_nic_vlan_feature_set);
 	self->ndev->gso_partial_features = NETIF_F_GSO_UDP_L4;
 	self->ndev->priv_flags = aq_hw_caps->hw_priv_flags;
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
index 935ba889bd9a..cf9ac3084e3f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
@@ -26,6 +26,10 @@ struct aq_macsec_cfg;
 struct aq_ptp_s;
 enum aq_rx_filter_type;
 
+extern netdev_features_t hw_atl2_features __ro_after_init;
+extern netdev_features_t hw_atl_a0_features __ro_after_init;
+extern netdev_features_t hw_atl_b0_features __ro_after_init;
+
 enum aq_fc_mode {
 	AQ_NIC_FC_OFF = 0,
 	AQ_NIC_FC_TX,
@@ -40,7 +44,7 @@ struct aq_fc_info {
 
 struct aq_nic_cfg_s {
 	const struct aq_hw_caps_s *aq_hw_caps;
-	u64 features;
+	netdev_features_t features;
 	u32 rxds;		/* rx ring size, descriptors # */
 	u32 txds;		/* tx ring size, descriptors # */
 	u32 vecs;		/* allocated rx/tx vectors */
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
index 9dfd68f0fda9..539e90af7615 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
@@ -34,13 +34,7 @@
 	.txhwb_alignment = 4096U,		     \
 	.tx_rings = HW_ATL_A0_TX_RINGS,		     \
 	.rx_rings = HW_ATL_A0_RX_RINGS,		     \
-	.hw_features = NETIF_F_HW_CSUM |	     \
-			NETIF_F_RXHASH |	     \
-			NETIF_F_RXCSUM |	     \
-			NETIF_F_SG |		     \
-			NETIF_F_TSO |		     \
-			NETIF_F_NTUPLE |	     \
-			NETIF_F_HW_VLAN_CTAG_FILTER, \
+	.hw_features = &hw_atl_a0_features,          \
 	.hw_priv_flags = IFF_UNICAST_FLT,	     \
 	.flow_control = true,			     \
 	.mtu = HW_ATL_A0_MTU_JUMBO,		     \
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
index 54e70f07b573..0ba71726238a 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
@@ -36,20 +36,7 @@
 	.txhwb_alignment = 4096U,	  \
 	.tx_rings = HW_ATL_B0_TX_RINGS,   \
 	.rx_rings = HW_ATL_B0_RX_RINGS,   \
-	.hw_features = NETIF_F_HW_CSUM |  \
-			NETIF_F_RXCSUM |  \
-			NETIF_F_RXHASH |  \
-			NETIF_F_SG |      \
-			NETIF_F_TSO |     \
-			NETIF_F_TSO6 |    \
-			NETIF_F_LRO |     \
-			NETIF_F_NTUPLE |  \
-			NETIF_F_HW_VLAN_CTAG_FILTER | \
-			NETIF_F_HW_VLAN_CTAG_RX |     \
-			NETIF_F_HW_VLAN_CTAG_TX |     \
-			NETIF_F_GSO_UDP_L4      |     \
-			NETIF_F_GSO_PARTIAL |         \
-			NETIF_F_HW_TC,                \
+	.hw_features = &hw_atl_b0_features, \
 	.hw_priv_flags = IFF_UNICAST_FLT, \
 	.flow_control = true,		  \
 	.mtu = HW_ATL_B0_MTU_JUMBO,	  \
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c
index 5dfc751572ed..34613222e9ff 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c
@@ -37,20 +37,7 @@ static int hw_atl2_act_rslvr_table_set(struct aq_hw_s *self, u8 location,
 	.txhwb_alignment = 4096U,	  \
 	.tx_rings = HW_ATL2_TX_RINGS,   \
 	.rx_rings = HW_ATL2_RX_RINGS,   \
-	.hw_features = NETIF_F_HW_CSUM |  \
-			NETIF_F_RXCSUM |  \
-			NETIF_F_RXHASH |  \
-			NETIF_F_SG |      \
-			NETIF_F_TSO |     \
-			NETIF_F_TSO6 |    \
-			NETIF_F_LRO |     \
-			NETIF_F_NTUPLE |  \
-			NETIF_F_HW_VLAN_CTAG_FILTER | \
-			NETIF_F_HW_VLAN_CTAG_RX |     \
-			NETIF_F_HW_VLAN_CTAG_TX |     \
-			NETIF_F_GSO_UDP_L4      |     \
-			NETIF_F_GSO_PARTIAL     |     \
-			NETIF_F_HW_TC,                \
+	.hw_features = &hw_atl2_features, \
 	.hw_priv_flags = IFF_UNICAST_FLT, \
 	.flow_control = true,		  \
 	.mtu = HW_ATL2_MTU_JUMBO,	  \
-- 
2.33.0


  parent reply	other threads:[~2022-08-10  3:14 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10  3:05 [RFCv7 PATCH net-next 00/36] net: extend the type of netdev_features_t to bitmap Jian Shen
2022-08-10  3:05 ` [RFCv7 PATCH net-next 01/36] net: introduce operation helpers for netdev features Jian Shen
2022-08-10  9:43   ` Alexander Lobakin
2022-08-10 11:32     ` shenjian (K)
2022-08-11 10:49       ` Alexander Lobakin
2022-08-12  2:39         ` shenjian (K)
2022-08-10  3:05 ` [RFCv7 PATCH net-next 02/36] net: replace general features macroes with global netdev_features variables Jian Shen
2022-08-10  9:58   ` Alexander Lobakin
2022-08-10 12:01     ` shenjian (K)
2022-08-11 11:05       ` Alexander Lobakin
2022-08-12 10:58         ` shenjian (K)
2022-08-10 20:21   ` kernel test robot
2022-08-10  3:05 ` [RFCv7 PATCH net-next 03/36] net: replace multiple feature bits with DECLARE_NETDEV_FEATURE_SET Jian Shen
2022-08-10 10:37   ` Alexander Lobakin
2022-08-10 12:15     ` shenjian (K)
2022-08-10  3:05 ` [RFCv7 PATCH net-next 04/36] net: sfc: replace const features initialization " Jian Shen
2022-08-10  3:05 ` Jian Shen [this message]
2022-08-10  3:05 ` [RFCv7 PATCH net-next 06/36] iwlwifi: replace const features initialization with NETDEV_FEATURE_SET Jian Shen
2022-08-10  3:05 ` [RFCv7 PATCH net-next 07/36] net: ethernet: mtk_eth_soc: " Jian Shen
2022-08-10  3:05 ` [RFCv7 PATCH net-next 08/36] ravb: " Jian Shen
2022-08-10  3:05 ` [RFCv7 PATCH net-next 09/36] test_bpf: " Jian Shen
2022-08-10  3:05 ` [RFCv7 PATCH net-next 10/36] treewide: replace NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK by netdev_csum_gso_features_mask Jian Shen
2022-08-10  3:05 ` [RFCv7 PATCH net-next 11/36] treewide: replace NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM by netdev_ip_csum_features Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 12/36] treewide: replace NETIF_F_TSO | NETIF_F_TSO6 by netdev_general_tso_features Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 13/36] treewide: replace VLAN tag feature array by const vlan features Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 14/36] net: simplify the netdev features expressions for xxx_gso_segment Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 15/36] treewide: simplify the netdev features expression Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 16/36] treewide: use replace features '0' by netdev_empty_features Jian Shen
2022-08-10 10:48   ` Alexander Lobakin
2022-08-10 12:25     ` shenjian (K)
2022-08-11 12:35       ` Alexander Lobakin
2022-08-10  3:06 ` [RFCv7 PATCH net-next 17/36] treewide: adjust features initialization Jian Shen
2022-08-10 10:58   ` Alexander Lobakin
2022-08-10 14:06     ` shenjian (K)
2022-08-10  3:06 ` [RFCv7 PATCH net-next 18/36] net: mlx4: adjust the net device feature relative macroes Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 19/36] net: mlx5e: adjust " Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 20/36] net: mlxsw: adjust input parameter for function mlxsw_sp_handle_feature Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 21/36] net: iavf: adjust net device features relative macroes Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 22/36] net: core: adjust netdev_sync_xxx_features Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 23/36] net: adjust the build check for net_gso_ok() Jian Shen
2022-08-10 11:09   ` Alexander Lobakin
2022-08-10 14:41     ` shenjian (K)
2022-08-10  3:06 ` [RFCv7 PATCH net-next 24/36] treewide: use netdev_feature_add helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 25/36] treewide: use netdev_features_or/set helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 26/36] treewide: use netdev_feature_change helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 27/36] treewide: use netdev_feature_del helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 28/36] treewide: use netdev_features_andnot and netdev_features_clear helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 29/36] treewide: use netdev_features_xor helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 30/36] treewide: use netdev_feature_test helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 31/36] treewide: use netdev_features_intersects helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 32/36] net: use netdev_features_and and netdev_features_mask helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 33/36] treewide: use netdev_features_subset helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 34/36] treewide: use netdev_features_equal helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 35/36] treewide: use netdev_features_empty helpers Jian Shen
2022-08-10  3:06 ` [RFCv7 PATCH net-next 36/36] net: redefine the prototype of netdev_features_t Jian Shen
2022-08-10 11:35   ` Alexander Lobakin
     [not found]     ` <3df89822-7dec-c01e-0df9-15b8e6f7d4e5@huawei.com>
2022-08-11 13:07       ` Alexander Lobakin
2022-08-11 15:13         ` Jakub Kicinski
2022-08-12 11:43           ` shenjian (K)
2022-08-12 11:30         ` shenjian (K)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220810030624.34711-6-shenjian15@huawei.com \
    --to=shenjian15@huawei.com \
    --cc=alexandr.lobakin@intel.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linuxarm@openeuler.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeed@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.