[IA64] Fix memcpy_mck.S for current binutils
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / net / tcp_ecn.h
blobdc1456389a9727f54425ab18f875fd3c7d51b2da
1 #ifndef _NET_TCP_ECN_H_
2 #define _NET_TCP_ECN_H_ 1
4 #include <net/inet_ecn.h>
6 #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH))
8 #define TCP_ECN_OK 1
9 #define TCP_ECN_QUEUE_CWR 2
10 #define TCP_ECN_DEMAND_CWR 4
12 static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp)
14 if (tp->ecn_flags&TCP_ECN_OK)
15 tp->ecn_flags |= TCP_ECN_QUEUE_CWR;
19 /* Output functions */
21 static inline void TCP_ECN_send_synack(struct tcp_sock *tp,
22 struct sk_buff *skb)
24 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR;
25 if (!(tp->ecn_flags&TCP_ECN_OK))
26 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE;
29 static inline void TCP_ECN_send_syn(struct sock *sk, struct tcp_sock *tp,
30 struct sk_buff *skb)
32 tp->ecn_flags = 0;
33 if (sysctl_tcp_ecn && !(sk->sk_route_caps & NETIF_F_TSO)) {
34 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
35 tp->ecn_flags = TCP_ECN_OK;
36 sock_set_flag(sk, SOCK_NO_LARGESEND);
40 static __inline__ void
41 TCP_ECN_make_synack(struct open_request *req, struct tcphdr *th)
43 if (req->ecn_ok)
44 th->ece = 1;
47 static inline void TCP_ECN_send(struct sock *sk, struct tcp_sock *tp,
48 struct sk_buff *skb, int tcp_header_len)
50 if (tp->ecn_flags & TCP_ECN_OK) {
51 /* Not-retransmitted data segment: set ECT and inject CWR. */
52 if (skb->len != tcp_header_len &&
53 !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
54 INET_ECN_xmit(sk);
55 if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
56 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
57 skb->h.th->cwr = 1;
59 } else {
60 /* ACK or retransmitted segment: clear ECT|CE */
61 INET_ECN_dontxmit(sk);
63 if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
64 skb->h.th->ece = 1;
68 /* Input functions */
70 static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb)
72 if (skb->h.th->cwr)
73 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
76 static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp)
78 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
81 static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb)
83 if (tp->ecn_flags&TCP_ECN_OK) {
84 if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags))
85 tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
86 /* Funny extension: if ECT is not set on a segment,
87 * it is surely retransmit. It is not in ECN RFC,
88 * but Linux follows this rule. */
89 else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags)))
90 tcp_enter_quickack_mode(tp);
94 static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th)
96 if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr))
97 tp->ecn_flags &= ~TCP_ECN_OK;
100 static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th)
102 if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr))
103 tp->ecn_flags &= ~TCP_ECN_OK;
106 static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th)
108 if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK))
109 return 1;
110 return 0;
113 static inline void TCP_ECN_openreq_child(struct tcp_sock *tp,
114 struct open_request *req)
116 tp->ecn_flags = req->ecn_ok ? TCP_ECN_OK : 0;
119 static __inline__ void
120 TCP_ECN_create_request(struct open_request *req, struct tcphdr *th)
122 if (sysctl_tcp_ecn && th->ece && th->cwr)
123 req->ecn_ok = 1;
126 #endif