This is the base code for tipc gso, and tipc_gso_segment() will only be called after gso packets are built in the next patch.
Signed-off-by: Xin Long <lucien....@gmail.com> --- include/linux/skbuff.h | 2 ++ net/tipc/Makefile | 2 +- net/tipc/core.c | 3 +++ net/tipc/msg.h | 2 ++ net/tipc/offload.c | 29 +++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 net/tipc/offload.c diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index b2db9cd9a73f..148bf0ed7336 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -599,6 +599,8 @@ enum { SKB_GSO_UDP_L4 = 1 << 17, SKB_GSO_FRAGLIST = 1 << 18, + + SKB_GSO_TIPC = 1 << 19, }; #if BITS_PER_LONG > 32 diff --git a/net/tipc/Makefile b/net/tipc/Makefile index ee49a9f1dd4f..ff276bf78d03 100644 --- a/net/tipc/Makefile +++ b/net/tipc/Makefile @@ -9,7 +9,7 @@ tipc-y += addr.o bcast.o bearer.o \ core.o link.o discover.o msg.o \ name_distr.o subscr.o monitor.o name_table.o net.o \ netlink.o netlink_compat.o node.o socket.o eth_media.o \ - topsrv.o group.o trace.o + topsrv.o group.o trace.o offload.o CFLAGS_trace.o += -I$(src) diff --git a/net/tipc/core.c b/net/tipc/core.c index 3f4542e0f065..1f59371aa036 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c @@ -186,6 +186,8 @@ static int __init tipc_init(void) if (err) goto out_netlink_compat; + tipc_offload_init(); + pr_info("Started in single node mode\n"); return 0; @@ -210,6 +212,7 @@ static int __init tipc_init(void) static void __exit tipc_exit(void) { + tipc_offload_exit(); tipc_netlink_compat_stop(); tipc_netlink_stop(); tipc_bearer_cleanup(); diff --git a/net/tipc/msg.h b/net/tipc/msg.h index 64ae4c4c44f8..d6c6231b8208 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h @@ -1203,6 +1203,8 @@ bool tipc_msg_pskb_copy(u32 dst, struct sk_buff_head *msg, bool __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno, struct sk_buff *skb); bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy); +void tipc_offload_init(void); +void tipc_offload_exit(void); static inline u16 buf_seqno(struct sk_buff *skb) { diff --git a/net/tipc/offload.c b/net/tipc/offload.c new file mode 100644 index 000000000000..f8a81c8886f0 --- /dev/null +++ b/net/tipc/offload.c @@ -0,0 +1,29 @@ +#include <linux/netdevice.h> +#include <linux/skbuff.h> +#include "msg.h" + +static struct sk_buff *tipc_gso_segment(struct sk_buff *skb, + netdev_features_t features) +{ + if (!(skb_shinfo(skb)->gso_type & SKB_GSO_TIPC)) + return ERR_PTR(-EINVAL); + + return skb_segment(skb, (features | NETIF_F_HW_CSUM) & ~NETIF_F_SG); +} + +static struct packet_offload tipc_packet_offload __read_mostly = { + .type = cpu_to_be16(ETH_P_TIPC), + .callbacks = { + .gso_segment = tipc_gso_segment, + }, +}; + +void tipc_offload_init(void) +{ + dev_add_offload(&tipc_packet_offload); +} + +void tipc_offload_exit(void) +{ + dev_remove_offload(&tipc_packet_offload); +} -- 2.27.0 _______________________________________________ tipc-discussion mailing list tipc-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tipc-discussion