20311498aa53db6e1176e581c24ab553af91f2bd
[openwrt/openwrt.git] / target / linux / generic / backport-4.9 / 024-1-tcp-tsq-add-tsq_flags-tsq_enum.patch
1 From 40fc3423b983b864bf70b03199191260ae9b2ea6 Mon Sep 17 00:00:00 2001
2 From: Eric Dumazet <edumazet@google.com>
3 Date: Sat, 3 Dec 2016 11:14:50 -0800
4 Subject: [PATCH 01/10] tcp: tsq: add tsq_flags / tsq_enum
5
6 This is a cleanup, to ease code review of following patches.
7
8 Old 'enum tsq_flags' is renamed, and a new enumeration is added
9 with the flags used in cmpxchg() operations as opposed to
10 single bit operations.
11
12 Signed-off-by: Eric Dumazet <edumazet@google.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 include/linux/tcp.h | 11 ++++++++++-
16 net/ipv4/tcp_output.c | 16 ++++++++--------
17 2 files changed, 18 insertions(+), 9 deletions(-)
18
19 --- a/include/linux/tcp.h
20 +++ b/include/linux/tcp.h
21 @@ -367,7 +367,7 @@ struct tcp_sock {
22 u32 *saved_syn;
23 };
24
25 -enum tsq_flags {
26 +enum tsq_enum {
27 TSQ_THROTTLED,
28 TSQ_QUEUED,
29 TCP_TSQ_DEFERRED, /* tcp_tasklet_func() found socket was owned */
30 @@ -378,6 +378,15 @@ enum tsq_flags {
31 */
32 };
33
34 +enum tsq_flags {
35 + TSQF_THROTTLED = (1UL << TSQ_THROTTLED),
36 + TSQF_QUEUED = (1UL << TSQ_QUEUED),
37 + TCPF_TSQ_DEFERRED = (1UL << TCP_TSQ_DEFERRED),
38 + TCPF_WRITE_TIMER_DEFERRED = (1UL << TCP_WRITE_TIMER_DEFERRED),
39 + TCPF_DELACK_TIMER_DEFERRED = (1UL << TCP_DELACK_TIMER_DEFERRED),
40 + TCPF_MTU_REDUCED_DEFERRED = (1UL << TCP_MTU_REDUCED_DEFERRED),
41 +};
42 +
43 static inline struct tcp_sock *tcp_sk(const struct sock *sk)
44 {
45 return (struct tcp_sock *)sk;
46 --- a/net/ipv4/tcp_output.c
47 +++ b/net/ipv4/tcp_output.c
48 @@ -784,10 +784,10 @@ static void tcp_tasklet_func(unsigned lo
49 }
50 }
51
52 -#define TCP_DEFERRED_ALL ((1UL << TCP_TSQ_DEFERRED) | \
53 - (1UL << TCP_WRITE_TIMER_DEFERRED) | \
54 - (1UL << TCP_DELACK_TIMER_DEFERRED) | \
55 - (1UL << TCP_MTU_REDUCED_DEFERRED))
56 +#define TCP_DEFERRED_ALL (TCPF_TSQ_DEFERRED | \
57 + TCPF_WRITE_TIMER_DEFERRED | \
58 + TCPF_DELACK_TIMER_DEFERRED | \
59 + TCPF_MTU_REDUCED_DEFERRED)
60 /**
61 * tcp_release_cb - tcp release_sock() callback
62 * @sk: socket
63 @@ -808,7 +808,7 @@ void tcp_release_cb(struct sock *sk)
64 nflags = flags & ~TCP_DEFERRED_ALL;
65 } while (cmpxchg(&tp->tsq_flags, flags, nflags) != flags);
66
67 - if (flags & (1UL << TCP_TSQ_DEFERRED))
68 + if (flags & TCPF_TSQ_DEFERRED)
69 tcp_tsq_handler(sk);
70
71 /* Here begins the tricky part :
72 @@ -822,15 +822,15 @@ void tcp_release_cb(struct sock *sk)
73 */
74 sock_release_ownership(sk);
75
76 - if (flags & (1UL << TCP_WRITE_TIMER_DEFERRED)) {
77 + if (flags & TCPF_WRITE_TIMER_DEFERRED) {
78 tcp_write_timer_handler(sk);
79 __sock_put(sk);
80 }
81 - if (flags & (1UL << TCP_DELACK_TIMER_DEFERRED)) {
82 + if (flags & TCPF_DELACK_TIMER_DEFERRED) {
83 tcp_delack_timer_handler(sk);
84 __sock_put(sk);
85 }
86 - if (flags & (1UL << TCP_MTU_REDUCED_DEFERRED)) {
87 + if (flags & TCPF_MTU_REDUCED_DEFERRED) {
88 inet_csk(sk)->icsk_af_ops->mtu_reduced(sk);
89 __sock_put(sk);
90 }