gro: get out of core files
Subsystems (13)
cover gro: get out of core files
From: Eric Dumazet <[email protected]>
Move GRO related content into net/core/gro.c
and include/net/gro.h.
This reduces GRO scope to where it is really needed, and shrinks too big files (include/linux/netdevice.h and net/core/dev.c)
Eric Dumazet (4):
net: move gro definitions to include/net/gro.h
net: gro: move skb_gro_receive_list to udp_offload.c
net: gro: move skb_gro_receive into net/core/gro.c
net: gro: populate net/core/gro.c
.../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + .../net/ethernet/hisilicon/hns3/hns3_enet.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_rx.c | 1 + drivers/net/ethernet/qlogic/qede/qede_fp.c | 1 + drivers/net/geneve.c | 1 + drivers/net/vxlan.c | 1 + include/linux/netdevice.h | 351 +------- include/net/gro.h | 420 +++++++++- include/net/ip.h | 8 - include/net/ip6_checksum.h | 8 - include/net/udp.h | 24 - net/core/Makefile | 2 +- net/core/dev.c | 668 +-------------- net/core/gro.c | 766 ++++++++++++++++++ net/core/skbuff.c | 142 ---- net/ipv4/af_inet.c | 1 + net/ipv4/esp4_offload.c | 1 + net/ipv4/fou.c | 1 + net/ipv4/gre_offload.c | 1 + net/ipv4/tcp_offload.c | 1 + net/ipv4/udp_offload.c | 28 + net/ipv6/esp6_offload.c | 1 + net/ipv6/tcpv6_offload.c | 1 + net/ipv6/udp_offload.c | 1 + 25 files changed, 1230 insertions(+), 1202 deletions(-) create mode 100644 net/core/gro.c
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
PATCH 1/4 net: move gro definitions to include/net/gro.h
From: Eric Dumazet <[email protected]>
include/linux/netdevice.h became too big, move gro stuff into include/net/gro.h
--- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + .../net/ethernet/hisilicon/hns3/hns3_enet.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_rx.c | 1 + drivers/net/ethernet/qlogic/qede/qede_fp.c | 1 + drivers/net/geneve.c | 1 + drivers/net/vxlan.c | 1 + include/linux/netdevice.h | 348 --------------- include/net/gro.h | 396 +++++++++++++++++- include/net/ip.h | 8 - include/net/ip6_checksum.h | 8 - include/net/udp.h | 24 -- net/core/skbuff.c | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/esp4_offload.c | 1 + net/ipv4/fou.c | 1 + net/ipv4/gre_offload.c | 1 + net/ipv4/tcp_offload.c | 1 + net/ipv4/udp_offload.c | 1 + net/ipv6/esp6_offload.c | 1 + net/ipv6/tcpv6_offload.c | 1 + net/ipv6/udp_offload.c | 1 + 22 files changed, 411 insertions(+), 390 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +1 -0
@@ -25,6 +25,7 @@#include <linux/ip.h> #include <linux/crash_dump.h> #include <net/tcp.h> +#include <net/gro.h> #include <net/ipv6.h> #include <net/ip6_checksum.h> #include <linux/prefetch.h>
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -0
@@ -37,6 +37,7 @@#include <linux/if_bridge.h> #include <linux/rtc.h> #include <linux/bpf.h> +#include <net/gro.h> #include <net/ip.h> #include <net/tcp.h> #include <net/udp.h>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +1 -0
@@ -17,6 +17,7 @@#include <linux/skbuff.h> #include <linux/sctp.h> #include <net/gre.h> +#include <net/gro.h> #include <net/ip6_checksum.h> #include <net/pkt_cls.h> #include <net/tcp.h>
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -0
@@ -37,6 +37,7 @@#include <net/ip6_checksum.h> #include <net/page_pool.h> #include <net/inet_ecn.h> +#include <net/gro.h> #include <net/udp.h> #include <net/tcp.h> #include "en.h"
drivers/net/ethernet/qlogic/qede/qede_fp.c +1 -0
@@ -10,6 +10,7 @@#include <linux/bpf_trace.h> #include <net/udp_tunnel.h> #include <linux/ip.h> +#include <net/gro.h> #include <net/ipv6.h> #include <net/tcp.h> #include <linux/if_ether.h>
drivers/net/geneve.c +1 -0
@@ -17,6 +17,7 @@#include <net/gro_cells.h> #include <net/rtnetlink.h> #include <net/geneve.h> +#include <net/gro.h> #include <net/protocol.h> #define GENEVE_NETDEV_VER "0.6"
drivers/net/vxlan.c +1 -0
@@ -17,6 +17,7 @@#include <linux/ethtool.h> #include <net/arp.h> #include <net/ndisc.h> +#include <net/gro.h> #include <net/ipv6_stubs.h> #include <net/ip.h> #include <net/icmp.h>
include/linux/netdevice.h +0 -348
360 lines not on this page · raw message
include/net/gro.h +394 -2
413 lines not on this page · raw message
include/net/ip.h +0 -8
@@ -568,14 +568,6 @@ static inline void iph_to_flow_copy_v4addrs(struct flow_keys *flow, flow->control.addr_type =FLOW_DISSECTOR_KEY_IPV4_ADDRS ; } -static inline __wsum inet_gro_compute_pseudo (struct sk_buff *skb,int proto) -{ -const struct iphdr *iph =skb_gro_network_header (skb); - -return csum_tcpudp_nofold (iph->saddr, iph->daddr, -skb_gro_len (skb), proto,0 ); -} -/* * Map a multicast IP onto multicast MAC for type ethernet. */
include/net/ip6_checksum.h +0 -8
@@ -43,14 +43,6 @@ static inline __wsum ip6_compute_pseudo(struct sk_buff *skb, int proto) skb->len, proto, 0)); } -static inline __wsum ip6_gro_compute_pseudo (struct sk_buff *skb,int proto) -{ -const struct ipv6hdr *iph =skb_gro_network_header (skb); - -return ~csum_unfold (csum_ipv6_magic (&iph->saddr, &iph->daddr, -skb_gro_len (skb), proto,0 )); -} - static __inline__ __sum16 tcp_v6_check(int len, const struct in6_addr *saddr, const struct in6_addr *daddr,
include/net/udp.h +0 -24
@@ -167,36 +167,12 @@ static inline void udp_csum_pull_header(struct sk_buff *skb)typedef struct sock *(*udp_lookup_t )(const struct sk_buff *skb,__be16 sport,__be16 dport); -INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp4_gro_receive(struct list_head *, -struct sk_buff *)); -INDIRECT_CALLABLE_DECLARE(int udp4_gro_complete(struct sk_buff *, int)); -INDIRECT_CALLABLE_DECLARE(struct sk_buff *udp6_gro_receive(struct list_head *, -struct sk_buff *)); -INDIRECT_CALLABLE_DECLARE(int udp6_gro_complete(struct sk_buff *, int)); INDIRECT_CALLABLE_DECLARE(void udp_v6_early_demux(struct sk_buff *)); INDIRECT_CALLABLE_DECLARE(int udpv6_rcv(struct sk_buff *)); -struct sk_buff *udp_gro_receive (struct list_head *head,struct sk_buff *skb, -struct udphdr *uh,struct sock *sk); -int udp_gro_complete (struct sk_buff *skb,int nhoff,udp_lookup_t lookup); -struct sk_buff *__udp_gso_segment (struct sk_buff *gso_skb,netdev_features_t features,bool is_ipv6); -static inline struct udphdr *udp_gro_udphdr (struct sk_buff *skb) -{ -struct udphdr *uh; -unsigned int hlen, off; - - off =skb_gro_offset (skb); - hlen = off +sizeof (*uh); - uh =skb_gro_header_fast (skb, off); -if (skb_gro_header_hard (skb, hlen)) - uh =skb_gro_header_slow (skb, hlen, off); - -return uh; -} -/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ static inline int udp_lib_hash (struct sock *sk) {
net/core/skbuff.c +1 -0
@@ -64,6 +64,7 @@#include <net/protocol.h> #include <net/dst.h> +#include <net/gro.h> #include <net/sock.h> #include <net/checksum.h> #include <net/ip6_checksum.h>
net/ipv4/af_inet.c +1 -0
@@ -99,6 +99,7 @@#include <net/route.h> #include <net/ip_fib.h> #include <net/inet_connection_sock.h> +#include <net/gro.h> #include <net/tcp.h> #include <net/udp.h> #include <net/udplite.h>
net/ipv4/esp4_offload.c +1 -0
@@ -16,6 +16,7 @@#include <crypto/authenc.h> #include <linux/err.h> #include <linux/module.h> +#include <net/gro.h> #include <net/ip.h> #include <net/xfrm.h> #include <net/esp.h>
net/ipv4/fou.c +1 -0
@@ -9,6 +9,7 @@#include <linux/types.h> #include <linux/kernel.h> #include <net/genetlink.h> +#include <net/gro.h> #include <net/gue.h> #include <net/fou.h> #include <net/ip.h>
net/ipv4/gre_offload.c +1 -0
@@ -10,6 +10,7 @@#include <linux/init.h> #include <net/protocol.h> #include <net/gre.h> +#include <net/gro.h> static struct sk_buff *gre_gso_segment (struct sk_buff *skb,netdev_features_t features)
net/ipv4/tcp_offload.c +1 -0
@@ -8,6 +8,7 @@#include <linux/indirect_call_wrapper.h> #include <linux/skbuff.h> +#include <net/gro.h> #include <net/tcp.h> #include <net/protocol.h>
net/ipv4/udp_offload.c +1 -0
@@ -7,6 +7,7 @@*/ #include <linux/skbuff.h> +#include <net/gro.h> #include <net/udp.h> #include <net/protocol.h> #include <net/inet_common.h>
net/ipv6/esp6_offload.c +1 -0
@@ -16,6 +16,7 @@#include <crypto/authenc.h> #include <linux/err.h> #include <linux/module.h> +#include <net/gro.h> #include <net/ip.h> #include <net/xfrm.h> #include <net/esp.h>
net/ipv6/tcpv6_offload.c +1 -0
@@ -7,6 +7,7 @@*/ #include <linux/indirect_call_wrapper.h> #include <linux/skbuff.h> +#include <net/gro.h> #include <net/protocol.h> #include <net/tcp.h> #include <net/ip6_checksum.h>
net/ipv6/udp_offload.c +1 -0
@@ -13,6 +13,7 @@#include <net/udp.h> #include <net/ip6_checksum.h> #include "ip6_offload.h" +#include <net/gro.h> static struct sk_buff *udp6_ufo_fragment (struct sk_buff *skb,netdev_features_t features)
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
kernel test robot
build botRe: [PATCH net-next 1/4] net: move gro definitions to include/net/gro.h
I love your patch! Yet something to improve:
Hi Eric,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/gro-get-out-of-core-files/20211116-010906 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 1274a4eb318debe33e395bb8bcf8b98e6eb4670f config: csky-defconfig (attached as .config) compiler: csky-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/4a142ba0812a293afcb259b08c89ab80cb3dac6d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Eric-Dumazet/gro-get-out-of-core-files/20211116-010906 git checkout 4a142ba0812a293afcb259b08c89ab80cb3dac6d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=csky
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from net/ipv4/af_inet.c:102:
include/net/gro.h: In function 'ip6_gro_compute_pseudo':
include/net/gro.h:413:29: error: implicit declaration of function 'csum_ipv6_magic'; did you mean 'csum_tcpudp_magic'? [-Werror=implicit-function-declaration]
413 | return ~csum_unfold(csum_ipv6_magic(&iph->saddr, &iph->daddr,
| ^~~~~~~~~~~~~~~
| csum_tcpudp_magic
In file included from include/net/udplite.h:8,
from net/ipv4/af_inet.c:105:
include/net/ip6_checksum.h: At top level:
>> include/net/ip6_checksum.h:34:9: error: conflicting types for 'csum_ipv6_magic'; have '__sum16(const struct in6_addr *, const struct in6_addr *, __u32, __u8, __wsum)' {aka 'short unsigned int(const struct in6_addr *, const struct in6_addr *, unsigned int, unsigned char, unsigned int)'}
34 | __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
| ^~~~~~~~~~~~~~~
In file included from net/ipv4/af_inet.c:102:
include/net/gro.h:413:29: note: previous implicit declaration of 'csum_ipv6_magic' with type 'int()'
413 | return ~csum_unfold(csum_ipv6_magic(&iph->saddr, &iph->daddr,
| ^~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +34 include/net/ip6_checksum.h
^1da177e4c3f41 Linus Torvalds 2005-04-16 32 ^1da177e4c3f41 Linus Torvalds 2005-04-16 33 #ifndef _HAVE_ARCH_IPV6_CSUM acb3e04119fbf9 Cong Wang 2013-01-07 @34 __sum16 csum_ipv6_magic(const struct in6_addr *saddr, 56649d5d3c4cb0 Al Viro 2006-11-14 35 const struct in6_addr *daddr, 1e94082963747b Alexander Duyck 2016-03-11 36 __u32 len, __u8 proto, __wsum csum); ^1da177e4c3f41 Linus Torvalds 2005-04-16 37 #endif 8663e02aba154e Vlad Yasevich 2012-11-15 38
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH 2/4 net: gro: move skb_gro_receive_list to udp_offload.c
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
This helper is used once, no need to keep it in fat net/core/skbuff.c
--- include/linux/netdevice.h | 1 - net/core/skbuff.c | 26 -------------------------- net/ipv4/udp_offload.c | 27 +++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 27 deletions(-)
include/linux/netdevice.h +0 -1
@@ -2903,7 +2903,6 @@ struct net_device *dev_get_by_napi_id(unsigned int napi_id);int netdev_get_name (struct net *net,char *name,int ifindex);int dev_restart (struct net_device *dev);int skb_gro_receive (struct sk_buff *p,struct sk_buff *skb); -int skb_gro_receive_list (struct sk_buff *p,struct sk_buff *skb); static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
net/core/skbuff.c +0 -26
@@ -3920,32 +3920,6 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb, }EXPORT_SYMBOL_GPL (skb_segment_list); -int skb_gro_receive_list (struct sk_buff *p,struct sk_buff *skb) -{ -if (unlikely (p->len + skb->len >=65536 )) -return -E2BIG ; - -if (NAPI_GRO_CB (p)->last == p) -skb_shinfo (p)->frag_list = skb; -else -NAPI_GRO_CB (p)->last->next = skb; - -skb_pull (skb,skb_gro_offset (skb)); - -NAPI_GRO_CB (p)->last = skb; -NAPI_GRO_CB (p)->count++; - p->data_len += skb->len; - -/* sk owenrship - if any - completely transferred to the aggregated packet */ - skb->destructor =NULL ; - p->truesize += skb->truesize; - p->len += skb->len; - -NAPI_GRO_CB (skb)->same_flow =1 ; - -return 0 ; -} -/** * skb_segment - Perform protocol segmentation on skb. * @head_skb: buffer to segment
net/ipv4/udp_offload.c +27 -0
@@ -425,6 +425,33 @@ static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,return segs; } +static int skb_gro_receive_list (struct sk_buff *p,struct sk_buff *skb) +{ +if (unlikely (p->len + skb->len >=65536 )) +return -E2BIG ; + +if (NAPI_GRO_CB (p)->last == p) +skb_shinfo (p)->frag_list = skb; +else +NAPI_GRO_CB (p)->last->next = skb; + +skb_pull (skb,skb_gro_offset (skb)); + +NAPI_GRO_CB (p)->last = skb; +NAPI_GRO_CB (p)->count++; + p->data_len += skb->len; + +/* sk owenrship - if any - completely transferred to the aggregated packet */ + skb->destructor =NULL ; + p->truesize += skb->truesize; + p->len += skb->len; + +NAPI_GRO_CB (skb)->same_flow =1 ; + +return 0 ; +} + +#define UDP_GRO_CNT_MAX 64static struct sk_buff *udp_gro_receive_segment (struct list_head *head,struct sk_buff *skb)
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
PATCH 3/4 net: gro: move skb_gro_receive into net/core/gro.c
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
net/core/gro.c will contain all core gro functions, to shrink net/core/skbuff.c and net/core/dev.c
--- include/linux/netdevice.h | 1 - include/net/gro.h | 2 + net/core/Makefile | 2 +- net/core/gro.c | 118 ++++++++++++++++++++++++++++++++++++++ net/core/skbuff.c | 117 ------------------------------------- 5 files changed, 121 insertions(+), 119 deletions(-) create mode 100644 net/core/gro.c
include/linux/netdevice.h +0 -1
@@ -2902,7 +2902,6 @@ struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);struct net_device *dev_get_by_napi_id (unsigned int napi_id);int netdev_get_name (struct net *net,char *name,int ifindex);int dev_restart (struct net_device *dev); -int skb_gro_receive (struct sk_buff *p,struct sk_buff *skb); static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
include/net/gro.h +2 -0
@@ -414,4 +414,6 @@ static inline __wsum ip6_gro_compute_pseudo(struct sk_buff *skb, int proto) skb_gro_len(skb), proto, 0)); } +int skb_gro_receive (struct sk_buff *p,struct sk_buff *skb); +#endif /* _NET_IPV6_GRO_H */
net/core/Makefile +1 -1
@@ -11,7 +11,7 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \ - fib_notifier.o xdp.o flow_offload.o + fib_notifier.o xdp.o flow_offload.o gro.o obj-y += net-sysfs.o obj-$(CONFIG_PAGE_POOL) += page_pool.o
net/core/gro.c new file +118 -0
118 lines not on this page · raw message
net/core/skbuff.c +0 -117
129 lines not on this page · raw message
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
PATCH 4/4 net: gro: populate net/core/gro.c
In reply to Eric DumazetFrom: Eric Dumazet <[email protected]>
Move gro code and data from net/core/dev.c to net/core/gro.c to ease maintenance.
gro_normal_list() and gro_normal_one() are inlined because they are called from both files.
--- include/linux/netdevice.h | 1 + include/net/gro.h | 22 ++ net/core/dev.c | 668 +------------------------------------- net/core/gro.c | 648 ++++++++++++++++++++++++++++++++++++ 4 files changed, 672 insertions(+), 667 deletions(-)
include/linux/netdevice.h +1 -0
@@ -3657,6 +3657,7 @@ int netif_rx_ni(struct sk_buff *skb);int netif_rx_any_context (struct sk_buff *skb);int netif_receive_skb (struct sk_buff *skb);int netif_receive_skb_core (struct sk_buff *skb); +void netif_receive_skb_list_internal (struct list_head *head);void netif_receive_skb_list (struct list_head *head);gro_result_t napi_gro_receive (struct napi_struct *napi,struct sk_buff *skb);void napi_gro_flush (struct napi_struct *napi,bool flush_old);
include/net/gro.h +22 -0
@@ -416,4 +416,26 @@ static inline __wsum ip6_gro_compute_pseudo(struct sk_buff *skb, int proto)int skb_gro_receive (struct sk_buff *p,struct sk_buff *skb); +/* Pass the currently batched GRO_NORMAL SKBs up to the stack. */ +static inline void gro_normal_list (struct napi_struct *napi) +{ +if (!napi->rx_count) +return ; +netif_receive_skb_list_internal (&napi->rx_list); +INIT_LIST_HEAD (&napi->rx_list); + napi->rx_count =0 ; +} + +/* Queue one GRO_NORMAL SKB up for list processing. If batch size exceeded, +* pass the whole batch up to the stack. +*/ +static inline void gro_normal_one (struct napi_struct *napi,struct sk_buff *skb,int segs) +{ +list_add_tail (&skb->list, &napi->rx_list); + napi->rx_count += segs; +if (napi->rx_count >= gro_normal_batch) +gro_normal_list (napi); +} + +#endif /* _NET_IPV6_GRO_H */
net/core/dev.c +1 -667
714 lines not on this page · raw message
net/core/gro.c +648 -0
656 lines not on this page · raw message
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 10 lines · On Mon, 15 Nov 2021 09:05:50 -0800 you wrote:
From: Eric Dumazet <[email protected]>
Move GRO related content into
net/core/gro.c
andinclude/net/gro.h.This reduces GRO scope to where it is really needed, and shrinks too big files (
include/linux/netdevice.handnet/core/dev.c)[...]
Here is the summary with links:
- [net-next,1/4] net: move gro definitions to include/net/gro.h
https://git.kernel.org/netdev/net-next/c/4721031c3559 - [net-next,2/4] net: gro: move skb_gro_receive_list to udp_offload.c https://git.kernel.org/netdev/net-next/c/0b935d7f8c07 - [net-next,3/4] net: gro: move skb_gro_receive into net/core/gro.c https://git.kernel.org/netdev/net-next/c/e456a18a390b - [net-next,4/4] net: gro: populate net/core/gro.c https://git.kernel.org/netdev/net-next/c/587652bbdd06
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html