diff mbox series

[RFCv8,net-next,46/55] net: adjust the prototype of netif_needs_gso() and relative functions

Message ID 20220918094336.28958-47-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: 4386 this patch: 4386
netdev/cc_maintainers warning 20 maintainers not CCed: sstabellini@kernel.org xen-devel@lists.xenproject.org hca@linux.ibm.com vyasevich@gmail.com yoshfuji@linux-ipv6.org pabeni@redhat.com agordeev@linux.ibm.com wintera@linux.ibm.com wenjia@linux.ibm.com edumazet@google.com dsahern@kernel.org jgross@suse.com svens@linux.ibm.com marcelo.leitner@gmail.com linux-s390@vger.kernel.org oleksandr_tyshchenko@epam.com nhorman@tuxdriver.com borntraeger@linux.ibm.com gor@linux.ibm.com linux-sctp@vger.kernel.org
netdev/build_clang fail Errors and warnings before: 15022 this patch: 15022
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: 3924 this patch: 3956
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns WARNING: line length of 97 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

shenjian (K) Sept. 18, 2022, 9:43 a.m. UTC
The functions netif_needs_gso(), net_gso_ok(), and skb_gso_ok()
using netdev_features_t as parameters.

For the prototype of netdev_features_t will be extended to be
larger than 8 bytes, so change the prototype of these functions,
change the prototype of input features to 'netdev_features_t *'.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 drivers/net/tap.c                 |  2 +-
 drivers/net/xen-netfront.c        |  2 +-
 drivers/s390/net/qeth_core_main.c |  4 ++--
 include/linux/netdevice.h         | 11 ++++++-----
 include/net/sock.h                |  2 +-
 net/core/dev.c                    |  4 ++--
 net/core/skbuff.c                 |  2 +-
 net/ipv4/tcp_offload.c            |  2 +-
 net/sctp/offload.c                |  2 +-
 9 files changed, 16 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index dfbfd8dfcf67..e3045a7badd8 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -341,7 +341,7 @@  rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
 	 */
 	if (q->flags & IFF_VNET_HDR)
 		netdev_features_set(features, tap->tap_features);
-	if (netif_needs_gso(skb, features)) {
+	if (netif_needs_gso(skb, &features)) {
 		struct sk_buff *segs = __skb_gso_segment(skb, &features, false);
 		struct sk_buff *next;
 
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 654f805f4522..a7887060feb3 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -777,7 +777,7 @@  static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev
 	netif_skb_features(skb, &features);
 	if (unlikely(!netif_carrier_ok(dev) ||
 		     (slots > 1 && !xennet_can_sg(dev)) ||
-		     netif_needs_gso(skb, features))) {
+		     netif_needs_gso(skb, &features))) {
 		spin_unlock_irqrestore(&queue->tx_lock, flags);
 		goto drop;
 	}
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index b3ca79930c42..6695f8dda8f4 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -6882,7 +6882,7 @@  void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
 		netdev_features_t restricted;
 
 		netdev_features_zero(restricted);
-		if (skb_is_gso(skb) && !netif_needs_gso(skb, *features))
+		if (skb_is_gso(skb) && !netif_needs_gso(skb, features))
 			netdev_features_set(restricted, NETIF_F_ALL_TSO);
 
 		switch (vlan_get_protocol(skb)) {
@@ -6914,7 +6914,7 @@  void qeth_features_check(struct sk_buff *skb, struct net_device *dev,
 	 * additional buffer element. This reduces buffer utilization, and
 	 * hurts throughput. So compress small segments into one element.
 	 */
-	if (netif_needs_gso(skb, *features)) {
+	if (netif_needs_gso(skb, features)) {
 		/* match skb_segment(): */
 		unsigned int doffset = skb->data - skb_mac_header(skb);
 		unsigned int hsize = skb_shinfo(skb)->gso_size;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index fb1f85274e3b..f0fad437bdb7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4917,7 +4917,7 @@  void passthru_features_check(struct sk_buff *skb, struct net_device *dev,
 			     netdev_features_t *features);
 void netif_skb_features(struct sk_buff *skb, netdev_features_t *features);
 
-static inline bool net_gso_ok(netdev_features_t features, int gso_type)
+static inline bool net_gso_ok(const netdev_features_t *features, int gso_type)
 {
 #define ASSERT_GSO_TYPE(fl, feat)	\
 		static_assert((fl) == (feat) - NETIF_F_GSO_SHIFT)
@@ -4952,17 +4952,18 @@  static inline bool net_gso_ok(netdev_features_t features, int gso_type)
 	if (new_gso_type) { /* placeholder for new gso type */
 	}
 
-	return (features & feature) == feature;
+	return (*features & feature) == feature;
 }
 
-static inline bool skb_gso_ok(struct sk_buff *skb, netdev_features_t features)
+static inline bool skb_gso_ok(struct sk_buff *skb,
+			      const netdev_features_t *features)
 {
 	return net_gso_ok(features, skb_shinfo(skb)->gso_type) &&
-	       (!skb_has_frag_list(skb) || netdev_feature_test(NETIF_F_FRAGLIST_BIT, features));
+	       (!skb_has_frag_list(skb) || netdev_feature_test(NETIF_F_FRAGLIST_BIT, *features));
 }
 
 static inline bool netif_needs_gso(struct sk_buff *skb,
-				   netdev_features_t features)
+				   const netdev_features_t *features)
 {
 	return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
 		unlikely((skb->ip_summed != CHECKSUM_PARTIAL) &&
diff --git a/include/net/sock.h b/include/net/sock.h
index 35404aedf51c..acdef93d0657 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2237,7 +2237,7 @@  bool sk_mc_loop(struct sock *sk);
 
 static inline bool sk_can_gso(const struct sock *sk)
 {
-	return net_gso_ok(sk->sk_route_caps, sk->sk_gso_type);
+	return net_gso_ok(&sk->sk_route_caps, sk->sk_gso_type);
 }
 
 void sk_setup_caps(struct sock *sk, struct dst_entry *dst);
diff --git a/net/core/dev.c b/net/core/dev.c
index 21ef38eeb38a..3436b640db67 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3404,7 +3404,7 @@  struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
 				    dev->gso_partial_features);
 		netdev_feature_add(NETIF_F_GSO_ROBUST_BIT, partial_features);
 		netdev_features_set(partial_features, features);
-		if (!skb_gso_ok(skb, partial_features))
+		if (!skb_gso_ok(skb, &partial_features))
 			netdev_feature_del(NETIF_F_GSO_PARTIAL_BIT, features);
 	}
 
@@ -3665,7 +3665,7 @@  static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
 	if (unlikely(!skb))
 		goto out_null;
 
-	if (netif_needs_gso(skb, features)) {
+	if (netif_needs_gso(skb, &features)) {
 		struct sk_buff *segs;
 
 		segs = skb_gso_segment(skb, &features);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b5916c98128b..124de0e772fc 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4068,7 +4068,7 @@  struct sk_buff *skb_segment(struct sk_buff *head_skb,
 			unsigned int frag_len;
 
 			if (!list_skb ||
-			    !net_gso_ok(features, skb_shinfo(head_skb)->gso_type))
+			    !net_gso_ok(&features, skb_shinfo(head_skb)->gso_type))
 				goto normal;
 
 			/* If we get here then all the required
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index 930dfb9557ed..b6c3c3b419a5 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -85,7 +85,7 @@  struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
 
 	netdev_features_copy(features, *feats);
 	netdev_feature_add(NETIF_F_GSO_ROBUST_BIT, features);
-	if (skb_gso_ok(skb, features)) {
+	if (skb_gso_ok(skb, &features)) {
 		/* Packet is from an untrusted source, reset gso_segs. */
 
 		skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss);
diff --git a/net/sctp/offload.c b/net/sctp/offload.c
index d4e1f70e32b8..413642ef1221 100644
--- a/net/sctp/offload.c
+++ b/net/sctp/offload.c
@@ -52,7 +52,7 @@  static struct sk_buff *sctp_gso_segment(struct sk_buff *skb,
 	__skb_pull(skb, sizeof(*sh));
 
 	netdev_feature_add(NETIF_F_GSO_ROBUST_BIT, tmp);
-	if (skb_gso_ok(skb, tmp)) {
+	if (skb_gso_ok(skb, &tmp)) {
 		/* Packet is from an untrusted source, reset gso_segs. */
 		struct skb_shared_info *pinfo = skb_shinfo(skb);
 		struct sk_buff *frag_iter;