Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: tso: inline tso_count_descs()

tso_count_descs() is a small function doing simple calculation,
and tso_count_descs() is used in fast path, so inline it to
reduce the overhead of calls.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Link: https://lore.kernel.org/r/20221212032426.16050-1-linyunsheng@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Yunsheng Lin and committed by
Jakub Kicinski
d7b061b8 8f18655c

+7 -9
+7 -1
include/net/tso.h
··· 2 2 #ifndef _TSO_H 3 3 #define _TSO_H 4 4 5 + #include <linux/skbuff.h> 5 6 #include <net/ip.h> 6 7 7 8 #define TSO_HEADER_SIZE 256 ··· 17 16 u32 tcp_seq; 18 17 }; 19 18 20 - int tso_count_descs(const struct sk_buff *skb); 19 + /* Calculate the worst case buffer count */ 20 + static inline int tso_count_descs(const struct sk_buff *skb) 21 + { 22 + return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; 23 + } 24 + 21 25 void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso, 22 26 int size, bool is_last); 23 27 void tso_build_data(const struct sk_buff *skb, struct tso_t *tso, int size);
-8
net/core/tso.c
··· 5 5 #include <net/tso.h> 6 6 #include <asm/unaligned.h> 7 7 8 - /* Calculate expected number of TX descriptors */ 9 - int tso_count_descs(const struct sk_buff *skb) 10 - { 11 - /* The Marvell Way */ 12 - return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags; 13 - } 14 - EXPORT_SYMBOL(tso_count_descs); 15 - 16 8 void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso, 17 9 int size, bool is_last) 18 10 {