Commit 773be16a authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[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
parent 99024599
......@@ -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 {
......
......@@ -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! */
......
......@@ -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 */
......@@ -584,6 +584,14 @@ ctl_table ipv4_table[] = {
.proc_handler = &proc_dointvec_jiffies,
.strategy = &sysctl_jiffies
},
{
.ctl_name = NET_TCP_WESTWOOD,
.procname = "tcp_westwood",
.data = &sysctl_tcp_westwood,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
{ .ctl_name = 0 }
};
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment