Skip to content

Commit d7b061b

Browse files
Yunsheng Linkuba-moo
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8f18655 commit d7b061b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

include/net/tso.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef _TSO_H
33
#define _TSO_H
44

5+
#include <linux/skbuff.h>
56
#include <net/ip.h>
67

78
#define TSO_HEADER_SIZE 256
@@ -16,7 +17,12 @@ struct tso_t {
1617
u32 tcp_seq;
1718
};
1819

19-
int tso_count_descs(const struct sk_buff *skb);
20+
/* Calculate the worst case buffer count */
21+
static inline int tso_count_descs(const struct sk_buff *skb)
22+
{
23+
return skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags;
24+
}
25+
2026
void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso,
2127
int size, bool is_last);
2228
void tso_build_data(const struct sk_buff *skb, struct tso_t *tso, int size);

net/core/tso.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
#include <net/tso.h>
66
#include <asm/unaligned.h>
77

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-
168
void tso_build_hdr(const struct sk_buff *skb, char *hdr, struct tso_t *tso,
179
int size, bool is_last)
1810
{

0 commit comments

Comments
 (0)