aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r--include/net/tcp.h156
1 files changed, 17 insertions, 139 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index ec9e20c27179..a166918ca56d 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -721,11 +721,16 @@ static inline int tcp_ack_scheduled(struct tcp_sock *tp)
721 return tp->ack.pending&TCP_ACK_SCHED; 721 return tp->ack.pending&TCP_ACK_SCHED;
722} 722}
723 723
724static __inline__ void tcp_dec_quickack_mode(struct tcp_sock *tp) 724static __inline__ void tcp_dec_quickack_mode(struct tcp_sock *tp, unsigned int pkts)
725{ 725{
726 if (tp->ack.quick && --tp->ack.quick == 0) { 726 if (tp->ack.quick) {
727 /* Leaving quickack mode we deflate ATO. */ 727 if (pkts >= tp->ack.quick) {
728 tp->ack.ato = TCP_ATO_MIN; 728 tp->ack.quick = 0;
729
730 /* Leaving quickack mode we deflate ATO. */
731 tp->ack.ato = TCP_ATO_MIN;
732 } else
733 tp->ack.quick -= pkts;
729 } 734 }
730} 735}
731 736
@@ -843,7 +848,9 @@ extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb,
843 848
844/* tcp_output.c */ 849/* tcp_output.c */
845 850
846extern int tcp_write_xmit(struct sock *, int nonagle); 851extern void __tcp_push_pending_frames(struct sock *sk, struct tcp_sock *tp,
852 unsigned int cur_mss, int nonagle);
853extern int tcp_may_send_now(struct sock *sk, struct tcp_sock *tp);
847extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); 854extern int tcp_retransmit_skb(struct sock *, struct sk_buff *);
848extern void tcp_xmit_retransmit_queue(struct sock *); 855extern void tcp_xmit_retransmit_queue(struct sock *);
849extern void tcp_simple_retransmit(struct sock *); 856extern void tcp_simple_retransmit(struct sock *);
@@ -855,10 +862,13 @@ extern int tcp_write_wakeup(struct sock *);
855extern void tcp_send_fin(struct sock *sk); 862extern void tcp_send_fin(struct sock *sk);
856extern void tcp_send_active_reset(struct sock *sk, int priority); 863extern void tcp_send_active_reset(struct sock *sk, int priority);
857extern int tcp_send_synack(struct sock *); 864extern int tcp_send_synack(struct sock *);
858extern void tcp_push_one(struct sock *, unsigned mss_now); 865extern void tcp_push_one(struct sock *, unsigned int mss_now);
859extern void tcp_send_ack(struct sock *sk); 866extern void tcp_send_ack(struct sock *sk);
860extern void tcp_send_delayed_ack(struct sock *sk); 867extern void tcp_send_delayed_ack(struct sock *sk);
861 868
869/* tcp_input.c */
870extern void tcp_cwnd_application_limited(struct sock *sk);
871
862/* tcp_timer.c */ 872/* tcp_timer.c */
863extern void tcp_init_xmit_timers(struct sock *); 873extern void tcp_init_xmit_timers(struct sock *);
864extern void tcp_clear_xmit_timers(struct sock *); 874extern void tcp_clear_xmit_timers(struct sock *);
@@ -958,7 +968,7 @@ static inline void tcp_reset_xmit_timer(struct sock *sk, int what, unsigned long
958static inline void tcp_initialize_rcv_mss(struct sock *sk) 968static inline void tcp_initialize_rcv_mss(struct sock *sk)
959{ 969{
960 struct tcp_sock *tp = tcp_sk(sk); 970 struct tcp_sock *tp = tcp_sk(sk);
961 unsigned int hint = min(tp->advmss, tp->mss_cache_std); 971 unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache);
962 972
963 hint = min(hint, tp->rcv_wnd/2); 973 hint = min(hint, tp->rcv_wnd/2);
964 hint = min(hint, TCP_MIN_RCVMSS); 974 hint = min(hint, TCP_MIN_RCVMSS);
@@ -1225,28 +1235,6 @@ static inline void tcp_sync_left_out(struct tcp_sock *tp)
1225 tp->left_out = tp->sacked_out + tp->lost_out; 1235 tp->left_out = tp->sacked_out + tp->lost_out;
1226} 1236}
1227 1237
1228extern void tcp_cwnd_application_limited(struct sock *sk);
1229
1230/* Congestion window validation. (RFC2861) */
1231
1232static inline void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp)
1233{
1234 __u32 packets_out = tp->packets_out;
1235
1236 if (packets_out >= tp->snd_cwnd) {
1237 /* Network is feed fully. */
1238 tp->snd_cwnd_used = 0;
1239 tp->snd_cwnd_stamp = tcp_time_stamp;
1240 } else {
1241 /* Network starves. */
1242 if (tp->packets_out > tp->snd_cwnd_used)
1243 tp->snd_cwnd_used = tp->packets_out;
1244
1245 if ((s32)(tcp_time_stamp - tp->snd_cwnd_stamp) >= tp->rto)
1246 tcp_cwnd_application_limited(sk);
1247 }
1248}
1249
1250/* Set slow start threshould and cwnd not falling to slow start */ 1238/* Set slow start threshould and cwnd not falling to slow start */
1251static inline void __tcp_enter_cwr(struct tcp_sock *tp) 1239static inline void __tcp_enter_cwr(struct tcp_sock *tp)
1252{ 1240{
@@ -1279,12 +1267,6 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp)
1279 return 3; 1267 return 3;
1280} 1268}
1281 1269
1282static __inline__ int tcp_minshall_check(const struct tcp_sock *tp)
1283{
1284 return after(tp->snd_sml,tp->snd_una) &&
1285 !after(tp->snd_sml, tp->snd_nxt);
1286}
1287
1288static __inline__ void tcp_minshall_update(struct tcp_sock *tp, int mss, 1270static __inline__ void tcp_minshall_update(struct tcp_sock *tp, int mss,
1289 const struct sk_buff *skb) 1271 const struct sk_buff *skb)
1290{ 1272{
@@ -1292,122 +1274,18 @@ static __inline__ void tcp_minshall_update(struct tcp_sock *tp, int mss,
1292 tp->snd_sml = TCP_SKB_CB(skb)->end_seq; 1274 tp->snd_sml = TCP_SKB_CB(skb)->end_seq;
1293} 1275}
1294 1276
1295/* Return 0, if packet can be sent now without violation Nagle's rules:
1296 1. It is full sized.
1297 2. Or it contains FIN.
1298 3. Or TCP_NODELAY was set.
1299 4. Or TCP_CORK is not set, and all sent packets are ACKed.
1300 With Minshall's modification: all sent small packets are ACKed.
1301 */
1302
1303static __inline__ int
1304tcp_nagle_check(const struct tcp_sock *tp, const struct sk_buff *skb,
1305 unsigned mss_now, int nonagle)
1306{
1307 return (skb->len < mss_now &&
1308 !(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN) &&
1309 ((nonagle&TCP_NAGLE_CORK) ||
1310 (!nonagle &&
1311 tp->packets_out &&
1312 tcp_minshall_check(tp))));
1313}
1314
1315extern void tcp_set_skb_tso_segs(struct sock *, struct sk_buff *);
1316
1317/* This checks if the data bearing packet SKB (usually sk->sk_send_head)
1318 * should be put on the wire right now.
1319 */
1320static __inline__ int tcp_snd_test(struct sock *sk,
1321 struct sk_buff *skb,
1322 unsigned cur_mss, int nonagle)
1323{
1324 struct tcp_sock *tp = tcp_sk(sk);
1325 int pkts = tcp_skb_pcount(skb);
1326
1327 if (!pkts) {
1328 tcp_set_skb_tso_segs(sk, skb);
1329 pkts = tcp_skb_pcount(skb);
1330 }
1331
1332 /* RFC 1122 - section 4.2.3.4
1333 *
1334 * We must queue if
1335 *
1336 * a) The right edge of this frame exceeds the window
1337 * b) There are packets in flight and we have a small segment
1338 * [SWS avoidance and Nagle algorithm]
1339 * (part of SWS is done on packetization)
1340 * Minshall version sounds: there are no _small_
1341 * segments in flight. (tcp_nagle_check)
1342 * c) We have too many packets 'in flight'
1343 *
1344 * Don't use the nagle rule for urgent data (or
1345 * for the final FIN -DaveM).
1346 *
1347 * Also, Nagle rule does not apply to frames, which
1348 * sit in the middle of queue (they have no chances
1349 * to get new data) and if room at tail of skb is
1350 * not enough to save something seriously (<32 for now).
1351 */
1352
1353 /* Don't be strict about the congestion window for the
1354 * final FIN frame. -DaveM
1355 */
1356 return (((nonagle&TCP_NAGLE_PUSH) || tp->urg_mode
1357 || !tcp_nagle_check(tp, skb, cur_mss, nonagle)) &&
1358 (((tcp_packets_in_flight(tp) + (pkts-1)) < tp->snd_cwnd) ||
1359 (TCP_SKB_CB(skb)->flags & TCPCB_FLAG_FIN)) &&
1360 !after(TCP_SKB_CB(skb)->end_seq, tp->snd_una + tp->snd_wnd));
1361}
1362
1363static __inline__ void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *tp) 1277static __inline__ void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *tp)
1364{ 1278{
1365 if (!tp->packets_out && !tp->pending) 1279 if (!tp->packets_out && !tp->pending)
1366 tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0, tp->rto); 1280 tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0, tp->rto);
1367} 1281}
1368 1282
1369static __inline__ int tcp_skb_is_last(const struct sock *sk,
1370 const struct sk_buff *skb)
1371{
1372 return skb->next == (struct sk_buff *)&sk->sk_write_queue;
1373}
1374
1375/* Push out any pending frames which were held back due to
1376 * TCP_CORK or attempt at coalescing tiny packets.
1377 * The socket must be locked by the caller.
1378 */
1379static __inline__ void __tcp_push_pending_frames(struct sock *sk,
1380 struct tcp_sock *tp,
1381 unsigned cur_mss,
1382 int nonagle)
1383{
1384 struct sk_buff *skb = sk->sk_send_head;
1385
1386 if (skb) {
1387 if (!tcp_skb_is_last(sk, skb))
1388 nonagle = TCP_NAGLE_PUSH;
1389 if (!tcp_snd_test(sk, skb, cur_mss, nonagle) ||
1390 tcp_write_xmit(sk, nonagle))
1391 tcp_check_probe_timer(sk, tp);
1392 }
1393 tcp_cwnd_validate(sk, tp);
1394}
1395
1396static __inline__ void tcp_push_pending_frames(struct sock *sk, 1283static __inline__ void tcp_push_pending_frames(struct sock *sk,
1397 struct tcp_sock *tp) 1284 struct tcp_sock *tp)
1398{ 1285{
1399 __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 1), tp->nonagle); 1286 __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 1), tp->nonagle);
1400} 1287}
1401 1288
1402static __inline__ int tcp_may_send_now(struct sock *sk, struct tcp_sock *tp)
1403{
1404 struct sk_buff *skb = sk->sk_send_head;
1405
1406 return (skb &&
1407 tcp_snd_test(sk, skb, tcp_current_mss(sk, 1),
1408 tcp_skb_is_last(sk, skb) ? TCP_NAGLE_PUSH : tp->nonagle));
1409}
1410
1411static __inline__ void tcp_init_wl(struct tcp_sock *tp, u32 ack, u32 seq) 1289static __inline__ void tcp_init_wl(struct tcp_sock *tp, u32 ack, u32 seq)
1412{ 1290{
1413 tp->snd_wl1 = seq; 1291 tp->snd_wl1 = seq;