diff mbox series

[RFCv8,net-next,45/55] net: vlan: adjust the prototype of vlan functions

Message ID 20220918094336.28958-46-shenjian15@huawei.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: extend the type of netdev_features_t to bitmap | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count fail Series longer than 15 patches (and no cover letter)
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2534 this patch: 2534
netdev/cc_maintainers warning 4 maintainers not CCed: edumazet@google.com william.xuanziyang@huawei.com wsa+renesas@sang-engineering.com pabeni@redhat.com
netdev/build_clang fail Errors and warnings before: 7593 this patch: 7214
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 2508 this patch: 2443
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 107 lines checked
netdev/kdoc success Errors and warnings before: 4 this patch: 4
netdev/source_inline success Was 0 now: 0

Commit Message

shenjian (K) Sept. 18, 2022, 9:43 a.m. UTC
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 mbox series

Patch

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