diff mbox series

[RFCv8,net-next,39/55] net: adjust the prototype of netdev_intersect_features()

Message ID 20220918094336.28958-40-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: 3581 this patch: 3581
netdev/cc_maintainers warning 4 maintainers not CCed: edumazet@google.com oss-drivers@corigine.com simon.horman@corigine.com pabeni@redhat.com
netdev/build_clang fail Errors and warnings before: 10618 this patch: 9919
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: 3165 this patch: 3133
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 67 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shenjian (K) Sept. 18, 2022, 9:43 a.m. UTC
The fcuntion netdev_intersect_features() using netdev_features_t
as parameters, and returns netdev_features_t directly. 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 parameters.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 .../net/ethernet/netronome/nfp/nfp_net_repr.c |  2 +-
 include/linux/netdev_feature_helpers.h        | 25 +++++++++++--------
 net/8021q/vlan_dev.c                          |  4 +--
 net/core/dev.c                                |  2 +-
 4 files changed, 18 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
index 8a15ec010282..0ab4f1b5e547 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c
@@ -248,7 +248,7 @@  nfp_repr_fix_features(struct net_device *netdev, netdev_features_t features)
 	if (netdev_features_intersects(lower_features, netdev_ip_csum_features))
 		netdev_feature_add(NETIF_F_HW_CSUM_BIT, lower_features);
 
-	features = netdev_intersect_features(features, lower_features);
+	netdev_intersect_features(&features, &features, &lower_features);
 	tmp = NETIF_F_SOFT_FEATURES;
 	netdev_feature_add(NETIF_F_HW_TC_BIT, tmp);
 	netdev_features_mask(tmp, old_features);
diff --git a/include/linux/netdev_feature_helpers.h b/include/linux/netdev_feature_helpers.h
index 60bc021648e4..a15bd3a3b574 100644
--- a/include/linux/netdev_feature_helpers.h
+++ b/include/linux/netdev_feature_helpers.h
@@ -697,21 +697,24 @@  static inline bool __netdev_features_subset(const netdev_features_t *feats1,
 #define netdev_gso_partial_features_clear_set(ndev, ...)		\
 	__netdev_gso_partial_features_clear_set(ndev, __UNIQUE_ID(feat_set), __VA_ARGS__)
 
-static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
-							  netdev_features_t f2)
+static inline void netdev_intersect_features(netdev_features_t *ret,
+					     const netdev_features_t *f1,
+					     const netdev_features_t *f2)
 {
-	netdev_features_t ret;
-
-	if (netdev_feature_test(NETIF_F_HW_CSUM_BIT, f1) !=
-	    netdev_feature_test(NETIF_F_HW_CSUM_BIT, f2)) {
-		if (netdev_feature_test(NETIF_F_HW_CSUM_BIT, f1))
-			netdev_features_set(f1, netdev_ip_csum_features);
+	netdev_features_t local_f1;
+	netdev_features_t local_f2;
+
+	netdev_features_copy(local_f1, *f1);
+	netdev_features_copy(local_f2, *f2);
+	if (netdev_feature_test(NETIF_F_HW_CSUM_BIT, local_f1) !=
+	    netdev_feature_test(NETIF_F_HW_CSUM_BIT, local_f2)) {
+		if (netdev_feature_test(NETIF_F_HW_CSUM_BIT, local_f1))
+			netdev_features_set(local_f1, netdev_ip_csum_features);
 		else
-			netdev_features_set(f2, netdev_ip_csum_features);
+			netdev_features_set(local_f2, netdev_ip_csum_features);
 	}
 
-	netdev_features_and(ret, f1, f2);
-	return ret;
+	netdev_features_and(*ret, local_f1, local_f2);
 }
 
 static inline void
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 04588800df24..d03348e29f36 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -655,14 +655,14 @@  static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
 
 	tmp = real_dev->vlan_features;
 	netdev_feature_add(NETIF_F_RXCSUM_BIT, tmp);
-	lower_features = netdev_intersect_features(tmp, real_dev->features);
+	netdev_intersect_features(&lower_features, &tmp, &real_dev->features);
 
 	/* Add HW_CSUM setting to preserve user ability to control
 	 * checksum offload on the vlan device.
 	 */
 	if (netdev_features_intersects(lower_features, netdev_ip_csum_features))
 		netdev_feature_add(NETIF_F_HW_CSUM_BIT, lower_features);
-	features = netdev_intersect_features(features, lower_features);
+	netdev_intersect_features(&features, &features, &lower_features);
 	netdev_features_or(tmp, NETIF_F_SOFT_FEATURES, NETIF_F_GSO_SOFTWARE);
 	netdev_features_mask(tmp, old_features);
 	netdev_features_set(features, tmp);
diff --git a/net/core/dev.c b/net/core/dev.c
index ac53e727d88f..e36347e0abe7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3565,7 +3565,7 @@  netdev_features_t netif_skb_features(struct sk_buff *skb)
 	if (skb_vlan_tagged(skb)) {
 		netdev_features_or(tmp, dev->vlan_features,
 				   netdev_tx_vlan_features);
-		features = netdev_intersect_features(features, tmp);
+		netdev_intersect_features(&features, &features, &tmp);
 	}
 
 	if (dev->netdev_ops->ndo_features_check)