tcp: add accessors to read/set tp->snd_cwnd
[platform/kernel/linux-rpi.git] / include / net / tcp.h
index 91ac329..3b97db2 100644 (file)
@@ -1199,9 +1199,20 @@ static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
 
 #define TCP_INFINITE_SSTHRESH  0x7fffffff
 
+static inline u32 tcp_snd_cwnd(const struct tcp_sock *tp)
+{
+       return tp->snd_cwnd;
+}
+
+static inline void tcp_snd_cwnd_set(struct tcp_sock *tp, u32 val)
+{
+       WARN_ON_ONCE((int)val <= 0);
+       tp->snd_cwnd = val;
+}
+
 static inline bool tcp_in_slow_start(const struct tcp_sock *tp)
 {
-       return tp->snd_cwnd < tp->snd_ssthresh;
+       return tcp_snd_cwnd(tp) < tp->snd_ssthresh;
 }
 
 static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp)
@@ -1227,8 +1238,8 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk)
                return tp->snd_ssthresh;
        else
                return max(tp->snd_ssthresh,
-                          ((tp->snd_cwnd >> 1) +
-                           (tp->snd_cwnd >> 2)));
+                          ((tcp_snd_cwnd(tp) >> 1) +
+                           (tcp_snd_cwnd(tp) >> 2)));
 }
 
 /* Use define here intentionally to get WARN_ON location shown at the caller */
@@ -1270,7 +1281,7 @@ static inline bool tcp_is_cwnd_limited(const struct sock *sk)
 
        /* If in slow start, ensure cwnd grows to twice what was ACKed. */
        if (tcp_in_slow_start(tp))
-               return tp->snd_cwnd < 2 * tp->max_packets_out;
+               return tcp_snd_cwnd(tp) < 2 * tp->max_packets_out;
 
        return tp->is_cwnd_limited;
 }