summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2004-01-31 19:17:59 -0800
committerDavid S. Miller <davem@nuts.davemloft.net>2004-01-31 19:17:59 -0800
commit773be16ac8414a8b10b5e31ea12310d8ca49eb47 (patch)
treeeafde879a46d1b1ba604b964e075eed4b9fda479 /include
parent9902459906dfedde06688ce4582621d8c7e3575b (diff)
[TCP]: Port 2.4.x version of TCP Westwood support to 2.6.x
Original 2.4.x version by Angelo Dell'Aera (buffer@antifork.org) Here is the 2.4 version with some cleanups converted to 2.6. - use tcp_ prefix (dave) - get rid of rwlock not needed (dave) - do some hand optimization of the inline's - don't make init inline - get rid of extra whitespace - eliminate accessor for mss_cache
Diffstat (limited to 'include')
-rw-r--r--include/linux/sysctl.h1
-rw-r--r--include/linux/tcp.h14
-rw-r--r--include/net/tcp.h64
3 files changed, 79 insertions, 0 deletions
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index b8806feac0b5..935be9d21b69 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -311,6 +311,7 @@ enum
NET_TCP_FRTO=92,
NET_TCP_LOW_LATENCY=93,
NET_IPV4_IPFRAG_SECRET_INTERVAL=94,
+ NET_TCP_WESTWOOD=95,
};
enum {
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index d25e5bd21c4d..1b35358879ce 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -374,6 +374,20 @@ struct tcp_opt {
__u32 frto_highmark; /* snd_nxt when RTO occurred */
unsigned long last_synq_overflow;
+
+/* TCP Westwood structure */
+ struct {
+ __u32 bw_sample; /* bandwidth sample */
+ __u32 bw_ns_est; /* first bandwidth estimation..not too smoothed 8) */
+ __u32 bw_est; /* bandwidth estimate */
+ __u32 rtt_win_sx; /* here starts a new evaluation... */
+ __u32 bk;
+ __u32 snd_una; /* used for evaluating the number of acked bytes */
+ __u32 cumul_ack;
+ __u32 accounted;
+ __u32 rtt;
+ __u32 rtt_min; /* minimum observed RTT */
+ } westwood;
};
/* WARNING: don't change the layout of the members in tcp_sock! */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index cec451adf4bf..55c5ea8f16ac 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -579,6 +579,7 @@ extern int sysctl_tcp_adv_win_scale;
extern int sysctl_tcp_tw_reuse;
extern int sysctl_tcp_frto;
extern int sysctl_tcp_low_latency;
+extern int sysctl_tcp_westwood;
extern atomic_t tcp_memory_allocated;
extern atomic_t tcp_sockets_allocated;
@@ -2019,4 +2020,67 @@ struct tcp_iter_state {
extern int tcp_proc_register(struct tcp_seq_afinfo *afinfo);
extern void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo);
+/* TCP Westwood functions and constants */
+
+#define TCP_WESTWOOD_INIT_RTT (20*HZ) /* maybe too conservative?! */
+#define TCP_WESTWOOD_RTT_MIN (HZ/20) /* 50ms */
+
+static inline void tcp_westwood_update_rtt(struct tcp_opt *tp, __u32 rtt_seq)
+{
+ if (sysctl_tcp_westwood)
+ tp->westwood.rtt = rtt_seq;
+}
+
+void __tcp_westwood_fast_bw(struct sock *, struct sk_buff *);
+void __tcp_westwood_slow_bw(struct sock *, struct sk_buff *);
+
+static inline void tcp_westwood_fast_bw(struct sock *sk, struct sk_buff *skb)
+{
+ if (sysctl_tcp_westwood)
+ __tcp_westwood_fast_bw(sk, skb);
+}
+
+static inline void tcp_westwood_slow_bw(struct sock *sk, struct sk_buff *skb)
+{
+ if (sysctl_tcp_westwood)
+ __tcp_westwood_slow_bw(sk, skb);
+}
+
+static inline __u32 __tcp_westwood_bw_rttmin(const struct tcp_opt *tp)
+{
+ return max((tp->westwood.bw_est) * (tp->westwood.rtt_min) /
+ (__u32) (tp->mss_cache),
+ 2U);
+}
+
+static inline __u32 tcp_westwood_bw_rttmin(const struct tcp_opt *tp)
+{
+ return sysctl_tcp_westwood ? __tcp_westwood_bw_rttmin(tp) : 0;
+}
+
+static inline int tcp_westwood_ssthresh(struct tcp_opt *tp)
+{
+ __u32 ssthresh = 0;
+
+ if (sysctl_tcp_westwood) {
+ ssthresh = __tcp_westwood_bw_rttmin(tp);
+ if (ssthresh)
+ tp->snd_ssthresh = ssthresh;
+ }
+
+ return (ssthresh != 0);
+}
+
+static inline int tcp_westwood_cwnd(struct tcp_opt *tp)
+{
+ __u32 cwnd = 0;
+
+ if (sysctl_tcp_westwood) {
+ cwnd = __tcp_westwood_bw_rttmin(tp);
+ if (cwnd)
+ tp->snd_cwnd = cwnd;
+ }
+
+ return (cwnd != 0);
+}
#endif /* _TCP_H */