All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jian Shen <shenjian15@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>,
	<ecree.xilinx@gmail.com>, <andrew@lunn.ch>,
	<hkallweit1@gmail.com>, <alexandr.lobakin@intel.com>,
	<saeed@kernel.org>, <leon@kernel.org>
Cc: <netdev@vger.kernel.org>, <linuxarm@huawei.com>
Subject: [RFCv8 PATCH net-next 45/55] net: vlan: adjust the prototype of vlan functions
Date: Sun, 18 Sep 2022 09:43:26 +0000	[thread overview]
Message-ID: <20220918094336.28958-46-shenjian15@huawei.com> (raw)
In-Reply-To: <20220918094336.28958-1-shenjian15@huawei.com>

There are some functions of vlan driver using netdev_features_t
as parameters or return netdev_features_t directly or both.

For the prototype of netdev_features_t will be extended to be
larger than 8 bytes, so change the prototype of the function,
change the prototype of input features to 'netdev_features_t *',
and return the features pointer as output parameter.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 include/linux/if_vlan.h |  6 +++---
 net/8021q/vlan.c        |  4 ++--
 net/8021q/vlan.h        | 26 ++++++++++++--------------
 net/8021q/vlan_dev.c    |  4 ++--
 net/core/dev.c          |  4 ++--
 net/core/netpoll.c      |  2 +-
 6 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 4fef74864267..3179db99ebc2 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -316,14 +316,14 @@ static inline bool eth_type_vlan(__be16 ethertype)
 	}
 }
 
-static inline bool vlan_hw_offload_capable(netdev_features_t features,
+static inline bool vlan_hw_offload_capable(const netdev_features_t *features,
 					   __be16 proto)
 {
 	if (proto == htons(ETH_P_8021Q) &&
-	    netdev_feature_test(NETIF_F_HW_VLAN_CTAG_TX_BIT, features))
+	    netdev_feature_test(NETIF_F_HW_VLAN_CTAG_TX_BIT, *features))
 		return true;
 	if (proto == htons(ETH_P_8021AD) &&
-	    netdev_feature_test(NETIF_F_HW_VLAN_STAG_TX_BIT, features))
+	    netdev_feature_test(NETIF_F_HW_VLAN_STAG_TX_BIT, *features))
 		return true;
 	return false;
 }
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index aec2e74ccfd9..f366f4048e3d 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -321,7 +321,7 @@ static void vlan_transfer_features(struct net_device *dev,
 
 	netif_inherit_tso_max(vlandev, dev);
 
-	if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
+	if (vlan_hw_offload_capable(&dev->features, vlan->vlan_proto))
 		vlandev->hard_header_len = dev->hard_header_len;
 	else
 		vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN;
@@ -332,7 +332,7 @@ static void vlan_transfer_features(struct net_device *dev,
 
 	vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
 	vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE);
-	vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev);
+	vlan_tnl_features(vlan->real_dev, &vlandev->hw_enc_features);
 
 	netdev_update_features(vlandev);
 }
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 2acb89660ab5..c72413f438e2 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -104,22 +104,20 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
 	return NULL;
 }
 
-static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev)
+static inline void vlan_tnl_features(struct net_device *real_dev,
+				     netdev_features_t *features)
 {
-	netdev_features_t ret;
-
-	netdev_features_or(ret, NETIF_F_CSUM_MASK, NETIF_F_GSO_SOFTWARE);
-	netdev_features_set(ret, NETIF_F_GSO_ENCAP_ALL);
-	netdev_features_mask(ret, real_dev->hw_enc_features);
-
-	if (netdev_features_intersects(ret, NETIF_F_GSO_ENCAP_ALL) &&
-	    netdev_features_intersects(ret, NETIF_F_CSUM_MASK)) {
-		netdev_features_clear(ret, NETIF_F_CSUM_MASK);
-		netdev_feature_add(NETIF_F_HW_CSUM_BIT, ret);
-		return ret;
+	netdev_features_or(*features, NETIF_F_CSUM_MASK, NETIF_F_GSO_SOFTWARE);
+	netdev_features_set(*features, NETIF_F_GSO_ENCAP_ALL);
+	netdev_features_mask(*features, real_dev->hw_enc_features);
+
+	if (netdev_features_intersects(*features, NETIF_F_GSO_ENCAP_ALL) &&
+	    netdev_features_intersects(*features, NETIF_F_CSUM_MASK)) {
+		netdev_features_clear(*features, NETIF_F_CSUM_MASK);
+		netdev_feature_add(NETIF_F_HW_CSUM_BIT, *features);
+		return;
 	}
-	netdev_features_zero(ret);
-	return ret;
+	netdev_features_zero(*features);
 }
 
 #define vlan_group_for_each_dev(grp, i, dev) \
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 2fa0b4ea260b..321adf534177 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -583,7 +583,7 @@ static int vlan_dev_init(struct net_device *dev)
 
 	netdev_vlan_features_andnot(dev, real_dev->vlan_features,
 				    NETIF_F_ALL_FCOE);
-	dev->hw_enc_features = vlan_tnl_features(real_dev);
+	vlan_tnl_features(real_dev, &dev->hw_enc_features);
 	dev->mpls_features = real_dev->mpls_features;
 
 	/* ipv6 shared card related stuff */
@@ -601,7 +601,7 @@ static int vlan_dev_init(struct net_device *dev)
 #endif
 
 	dev->needed_headroom = real_dev->needed_headroom;
-	if (vlan_hw_offload_capable(real_dev->features, vlan->vlan_proto)) {
+	if (vlan_hw_offload_capable(&real_dev->features, vlan->vlan_proto)) {
 		dev->header_ops      = &vlan_passthru_header_ops;
 		dev->hard_header_len = real_dev->hard_header_len;
 	} else {
diff --git a/net/core/dev.c b/net/core/dev.c
index ad6202d2543e..21ef38eeb38a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3622,7 +3622,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *first, struct net_device *de
 }
 
 static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb,
-					  netdev_features_t features)
+					  const netdev_features_t *features)
 {
 	if (skb_vlan_tag_present(skb) &&
 	    !vlan_hw_offload_capable(features, skb->vlan_proto))
@@ -3657,7 +3657,7 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
 	netdev_features_t features;
 
 	netif_skb_features(skb, &features);
-	skb = validate_xmit_vlan(skb, features);
+	skb = validate_xmit_vlan(skb, &features);
 	if (unlikely(!skb))
 		goto out_null;
 
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 94dd11aa1b83..17af85316407 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -80,7 +80,7 @@ static netdev_tx_t netpoll_start_xmit(struct sk_buff *skb,
 	netif_skb_features(skb, &features);
 
 	if (skb_vlan_tag_present(skb) &&
-	    !vlan_hw_offload_capable(features, skb->vlan_proto)) {
+	    !vlan_hw_offload_capable(&features, skb->vlan_proto)) {
 		skb = __vlan_hwaccel_push_inside(skb);
 		if (unlikely(!skb)) {
 			/* This is actually a packet drop, but we
-- 
2.33.0


  parent reply	other threads:[~2022-09-18  9:50 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18  9:42 [RFCv8 PATCH net-next 00/55] net: extend the type of netdev_features_t to bitmap Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 01/55] net: introduce operation helpers for netdev features Jian Shen
2022-09-20 20:10   ` Jakub Kicinski
2022-09-21  3:04     ` shenjian (K)
2022-09-18  9:42 ` [RFCv8 PATCH net-next 02/55] net: replace general features macroes with global netdev_features variables Jian Shen
2022-09-18 12:05   ` kernel test robot
2022-09-20 20:12   ` Jakub Kicinski
2022-09-21  6:33     ` shenjian (K)
2022-09-21 10:01       ` shenjian (K)
2022-09-21 12:50         ` Jakub Kicinski
2022-09-22 14:47           ` shenjian (K)
2022-09-18  9:42 ` [RFCv8 PATCH net-next 03/55] treewide: replace multiple feature bits with DECLARE_NETDEV_FEATURE_SET Jian Shen
2022-09-20 20:13   ` Jakub Kicinski
2022-09-18  9:42 ` [RFCv8 PATCH net-next 04/55] net: sfc: replace const features initialization " Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 05/55] net: atlantic: replace const features initialization with NETDEV_FEATURE_SET Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 06/55] iwlwifi: " Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 07/55] net: ethernet: mtk_eth_soc: " Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 08/55] ravb: " Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 09/55] test_bpf: " Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 10/55] treewide: replace NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK by netdev_csum_gso_features_mask Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 11/55] treewide: replace NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM by netdev_ip_csum_features Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 12/55] treewide: replace NETIF_F_TSO | NETIF_F_TSO6 by netdev_general_tso_features Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 13/55] treewide: replace VLAN tag feature array by const vlan features Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 14/55] net: simplify the netdev features expressions for xxx_gso_segment Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 15/55] treewide: simplify the netdev features expression Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 16/55] treewide: adjust the handle for netdev features '0' Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 17/55] treewide: adjust features initialization Jian Shen
2022-09-18  9:42 ` [RFCv8 PATCH net-next 18/55] net: mlx4: adjust the net device feature relative macroes Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 19/55] net: mlx5e: adjust " Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 20/55] net: mlxsw: adjust input parameter for function mlxsw_sp_handle_feature Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 21/55] net: iavf: adjust net device features relative macroes Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 22/55] net: core: adjust netdev_sync_xxx_features Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 23/55] net: adjust the build check for net_gso_ok() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 24/55] treewide: use netdev_feature_add helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 25/55] treewide: use netdev_features_or/set helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 26/55] treewide: use netdev_feature_change helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 27/55] treewide: use netdev_feature_del helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 28/55] treewide: use netdev_features_andnot/clear helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 29/55] treewide: use netdev_features_xor/toggle helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 30/55] treewide: use netdev_feature_test helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 31/55] treewide: use netdev_features_intersects helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 32/55] treewide: use netdev_features_and/mask helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 33/55] treewide: use netdev_features_subset helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 34/55] treewide: use netdev_features_equal helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 35/55] treewide: use netdev_features_empty helpers Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 36/55] net: adjust the prototype of netdev_increment_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 37/55] net: adjust the prototype of netdev_add_tso_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 38/55] net: core: adjust prototype of several functions used in net/core/dev.c Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 39/55] net: adjust the prototype of netdev_intersect_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 40/55] net: adjust the prototype of netif_skb_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 41/55] net: adjust the prototype of xxx_features_check() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 42/55] net: adjust the prototype of ndo_fix_features Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 43/55] net: adjust the prototype of xxx_set_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 44/55] net: adjust the prototype fo xxx_gso_segment() family Jian Shen
2022-09-18  9:43 ` Jian Shen [this message]
2022-09-18  9:43 ` [RFCv8 PATCH net-next 46/55] net: adjust the prototype of netif_needs_gso() and relative functions Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 47/55] net: adjust the prototype of skb_needs_linearize() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 48/55] net: adjust the prototype of validate_xmit_xfrm() and relative functions Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 49/55] net: adjust the prototype of can_checksum_protocol() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 50/55] net: tap: adjust the prototype of update_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 51/55] net: mlx4: adjust the prototype of check_csum() and mlx4_en_update_loopback_state() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 52/55] net: gve: adjust the prototype of gve_rx(), gve_clean_rx_done() and gve_rx_complete_skb() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 53/55] net: sfc: adjust the prototype of xxx_supported_features() Jian Shen
2022-09-18  9:43 ` [RFCv8 PATCH net-next 54/55] treewide: use netdev_features_copy helpers Jian Shen
2022-09-18 12:05   ` kernel test robot
2022-09-18  9:43 ` [RFCv8 PATCH net-next 55/55] net: redefine the prototype of netdev_features_t Jian Shen
2022-09-20 20:16 ` [RFCv8 PATCH net-next 00/55] net: extend the type of netdev_features_t to bitmap Jakub Kicinski
2022-11-25 15:44 ` Alexander Lobakin
2022-11-28 15:22   ` shenjian (K)
2022-11-28 15:51     ` Alexander Lobakin
2023-09-13 10:28       ` Alexander Lobakin
2023-09-16  7:20         ` shenjian (K)
2023-09-18 14:25           ` Alexander Lobakin
2023-10-03 19:28             ` Jakub Kicinski

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=20220918094336.28958-46-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@huawei.com \
    --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.