Deleted Added
full compact
sctp_cc_functions.c (171440) sctp_cc_functions.c (171477)
1/*-
2 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

--- 29 unchanged lines hidden (view full) ---

38#include <netinet/sctp_input.h>
39#include <netinet/sctp_indata.h>
40#include <netinet/sctp_uio.h>
41#include <netinet/sctp_timer.h>
42#include <netinet/sctp_auth.h>
43#include <netinet/sctp_asconf.h>
44#include <netinet/sctp_cc_functions.h>
45#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

--- 29 unchanged lines hidden (view full) ---

38#include <netinet/sctp_input.h>
39#include <netinet/sctp_indata.h>
40#include <netinet/sctp_uio.h>
41#include <netinet/sctp_timer.h>
42#include <netinet/sctp_auth.h>
43#include <netinet/sctp_asconf.h>
44#include <netinet/sctp_cc_functions.h>
45#include <sys/cdefs.h>
46__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 171440 2007-07-14 09:36:28Z rrs $");
46__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 171477 2007-07-17 20:58:26Z rrs $");
47void
48sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
49{
50 /*
51 * We take the max of the burst limit times a MTU or the
52 * INITIAL_CWND. We then limit this to 4 MTU's of sending.
53 */
54 net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));

--- 175 unchanged lines hidden (view full) ---

230 /*
231 * JRS 5/14/07 - If CMT PF is on and the destination
232 * is in PF state, set the destination to active
233 * state and set the cwnd to one or two MTU's based
234 * on whether PF1 or PF2 is being used.
235 *
236 * Should we stop any running T3 timer here?
237 */
47void
48sctp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
49{
50 /*
51 * We take the max of the burst limit times a MTU or the
52 * INITIAL_CWND. We then limit this to 4 MTU's of sending.
53 */
54 net->cwnd = min((net->mtu * 4), max((2 * net->mtu), SCTP_INITIAL_CWND));

--- 175 unchanged lines hidden (view full) ---

230 /*
231 * JRS 5/14/07 - If CMT PF is on and the destination
232 * is in PF state, set the destination to active
233 * state and set the cwnd to one or two MTU's based
234 * on whether PF1 or PF2 is being used.
235 *
236 * Should we stop any running T3 timer here?
237 */
238 if (sctp_cmt_pf && ((net->dest_state & SCTP_ADDR_PF) ==
238 if (sctp_cmt_on_off && sctp_cmt_pf && ((net->dest_state & SCTP_ADDR_PF) ==
239 SCTP_ADDR_PF)) {
240 net->dest_state &= ~SCTP_ADDR_PF;
241 net->cwnd = net->mtu * sctp_cmt_pf;
242 SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n",
243 net, net->cwnd);
244 /*
245 * Since the cwnd value is explicitly set,
246 * skip the code that updates the cwnd

--- 472 unchanged lines hidden (view full) ---

719 /*
720 * JRS 5/14/07 - If CMT PF is on and the destination
721 * is in PF state, set the destination to active
722 * state and set the cwnd to one or two MTU's based
723 * on whether PF1 or PF2 is being used.
724 *
725 * Should we stop any running T3 timer here?
726 */
239 SCTP_ADDR_PF)) {
240 net->dest_state &= ~SCTP_ADDR_PF;
241 net->cwnd = net->mtu * sctp_cmt_pf;
242 SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n",
243 net, net->cwnd);
244 /*
245 * Since the cwnd value is explicitly set,
246 * skip the code that updates the cwnd

--- 472 unchanged lines hidden (view full) ---

719 /*
720 * JRS 5/14/07 - If CMT PF is on and the destination
721 * is in PF state, set the destination to active
722 * state and set the cwnd to one or two MTU's based
723 * on whether PF1 or PF2 is being used.
724 *
725 * Should we stop any running T3 timer here?
726 */
727 if (sctp_cmt_pf && ((net->dest_state & SCTP_ADDR_PF) ==
727 if (sctp_cmt_on_off && sctp_cmt_pf && ((net->dest_state & SCTP_ADDR_PF) ==
728 SCTP_ADDR_PF)) {
729 net->dest_state &= ~SCTP_ADDR_PF;
730 net->cwnd = net->mtu * sctp_cmt_pf;
731 SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n",
732 net, net->cwnd);
733 /*
734 * Since the cwnd value is explicitly set,
735 * skip the code that updates the cwnd

--- 306 unchanged lines hidden (view full) ---

1042between(uint32_t seq1, uint32_t seq2, uint32_t seq3)
1043{
1044 return seq3 - seq2 >= seq1 - seq2;
1045}
1046
1047static inline uint32_t
1048htcp_cong_time(struct htcp *ca)
1049{
728 SCTP_ADDR_PF)) {
729 net->dest_state &= ~SCTP_ADDR_PF;
730 net->cwnd = net->mtu * sctp_cmt_pf;
731 SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n",
732 net, net->cwnd);
733 /*
734 * Since the cwnd value is explicitly set,
735 * skip the code that updates the cwnd

--- 306 unchanged lines hidden (view full) ---

1042between(uint32_t seq1, uint32_t seq2, uint32_t seq3)
1043{
1044 return seq3 - seq2 >= seq1 - seq2;
1045}
1046
1047static inline uint32_t
1048htcp_cong_time(struct htcp *ca)
1049{
1050 return ticks - ca->last_cong;
1050 return sctp_get_tick_count() - ca->last_cong;
1051}
1052
1053static inline uint32_t
1054htcp_ccount(struct htcp *ca)
1055{
1056 return htcp_cong_time(ca) / ca->minRTT;
1057}
1058
1059static inline void
1060htcp_reset(struct htcp *ca)
1061{
1062 ca->undo_last_cong = ca->last_cong;
1063 ca->undo_maxRTT = ca->maxRTT;
1064 ca->undo_old_maxB = ca->old_maxB;
1051}
1052
1053static inline uint32_t
1054htcp_ccount(struct htcp *ca)
1055{
1056 return htcp_cong_time(ca) / ca->minRTT;
1057}
1058
1059static inline void
1060htcp_reset(struct htcp *ca)
1061{
1062 ca->undo_last_cong = ca->last_cong;
1063 ca->undo_maxRTT = ca->maxRTT;
1064 ca->undo_old_maxB = ca->old_maxB;
1065 ca->last_cong = ticks;
1065 ca->last_cong = sctp_get_tick_count();
1066}
1067
1068#ifdef SCTP_NOT_USED
1069
1070static uint32_t
1071htcp_cwnd_undo(struct sctp_tcb *stcb, struct sctp_nets *net)
1072{
1073 net->htcp_ca.last_cong = net->htcp_ca.undo_last_cong;

--- 20 unchanged lines hidden (view full) ---

1094 if (net->htcp_ca.maxRTT < srtt && srtt <= net->htcp_ca.maxRTT + MSEC_TO_TICKS(20))
1095 net->htcp_ca.maxRTT = srtt;
1096 }
1097}
1098
1099static void
1100measure_achieved_throughput(struct sctp_tcb *stcb, struct sctp_nets *net)
1101{
1066}
1067
1068#ifdef SCTP_NOT_USED
1069
1070static uint32_t
1071htcp_cwnd_undo(struct sctp_tcb *stcb, struct sctp_nets *net)
1072{
1073 net->htcp_ca.last_cong = net->htcp_ca.undo_last_cong;

--- 20 unchanged lines hidden (view full) ---

1094 if (net->htcp_ca.maxRTT < srtt && srtt <= net->htcp_ca.maxRTT + MSEC_TO_TICKS(20))
1095 net->htcp_ca.maxRTT = srtt;
1096 }
1097}
1098
1099static void
1100measure_achieved_throughput(struct sctp_tcb *stcb, struct sctp_nets *net)
1101{
1102 uint32_t now = ticks;
1102 uint32_t now = sctp_get_tick_count();
1103
1104 if (net->fast_retran_ip == 0)
1105 net->htcp_ca.bytes_acked = net->net_ack;
1106
1107 if (!use_bandwidth_switch)
1108 return;
1109
1110 /* achieved throughput calculations */

--- 187 unchanged lines hidden (view full) ---

1298
1299static void
1300htcp_init(struct sctp_tcb *stcb, struct sctp_nets *net)
1301{
1302 memset(&net->htcp_ca, 0, sizeof(struct htcp));
1303 net->htcp_ca.alpha = ALPHA_BASE;
1304 net->htcp_ca.beta = BETA_MIN;
1305 net->htcp_ca.bytes_acked = net->mtu;
1103
1104 if (net->fast_retran_ip == 0)
1105 net->htcp_ca.bytes_acked = net->net_ack;
1106
1107 if (!use_bandwidth_switch)
1108 return;
1109
1110 /* achieved throughput calculations */

--- 187 unchanged lines hidden (view full) ---

1298
1299static void
1300htcp_init(struct sctp_tcb *stcb, struct sctp_nets *net)
1301{
1302 memset(&net->htcp_ca, 0, sizeof(struct htcp));
1303 net->htcp_ca.alpha = ALPHA_BASE;
1304 net->htcp_ca.beta = BETA_MIN;
1305 net->htcp_ca.bytes_acked = net->mtu;
1306 net->htcp_ca.last_cong = ticks;
1306 net->htcp_ca.last_cong = sctp_get_tick_count();
1307}
1308
1309void
1310sctp_htcp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
1311{
1312 /*
1313 * We take the max of the burst limit times a MTU or the
1314 * INITIAL_CWND. We then limit this to 4 MTU's of sending.

--- 99 unchanged lines hidden (view full) ---

1414 /*
1415 * JRS 5/14/07 - If CMT PF is on and the destination
1416 * is in PF state, set the destination to active
1417 * state and set the cwnd to one or two MTU's based
1418 * on whether PF1 or PF2 is being used.
1419 *
1420 * Should we stop any running T3 timer here?
1421 */
1307}
1308
1309void
1310sctp_htcp_set_initial_cc_param(struct sctp_tcb *stcb, struct sctp_nets *net)
1311{
1312 /*
1313 * We take the max of the burst limit times a MTU or the
1314 * INITIAL_CWND. We then limit this to 4 MTU's of sending.

--- 99 unchanged lines hidden (view full) ---

1414 /*
1415 * JRS 5/14/07 - If CMT PF is on and the destination
1416 * is in PF state, set the destination to active
1417 * state and set the cwnd to one or two MTU's based
1418 * on whether PF1 or PF2 is being used.
1419 *
1420 * Should we stop any running T3 timer here?
1421 */
1422 if (sctp_cmt_pf && ((net->dest_state & SCTP_ADDR_PF) ==
1422 if (sctp_cmt_on_off && sctp_cmt_pf && ((net->dest_state & SCTP_ADDR_PF) ==
1423 SCTP_ADDR_PF)) {
1424 net->dest_state &= ~SCTP_ADDR_PF;
1425 net->cwnd = net->mtu * sctp_cmt_pf;
1426 SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n",
1427 net, net->cwnd);
1428 /*
1429 * Since the cwnd value is explicitly set,
1430 * skip the code that updates the cwnd

--- 156 unchanged lines hidden (view full) ---

1587sctp_htcp_cwnd_update_after_fr_timer(struct sctp_inpcb *inp,
1588 struct sctp_tcb *stcb, struct sctp_nets *net)
1589{
1590 int old_cwnd;
1591
1592 old_cwnd = net->cwnd;
1593
1594 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_EARLY_FR_TMR);
1423 SCTP_ADDR_PF)) {
1424 net->dest_state &= ~SCTP_ADDR_PF;
1425 net->cwnd = net->mtu * sctp_cmt_pf;
1426 SCTPDBG(SCTP_DEBUG_INDATA1, "Destination %p moved from PF to reachable with cwnd %d.\n",
1427 net, net->cwnd);
1428 /*
1429 * Since the cwnd value is explicitly set,
1430 * skip the code that updates the cwnd

--- 156 unchanged lines hidden (view full) ---

1587sctp_htcp_cwnd_update_after_fr_timer(struct sctp_inpcb *inp,
1588 struct sctp_tcb *stcb, struct sctp_nets *net)
1589{
1590 int old_cwnd;
1591
1592 old_cwnd = net->cwnd;
1593
1594 sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_EARLY_FR_TMR);
1595 net->htcp_ca.last_cong = ticks;
1595 net->htcp_ca.last_cong = sctp_get_tick_count();
1596 /*
1597 * make a small adjustment to cwnd and force to CA.
1598 */
1599 if (net->cwnd > net->mtu)
1600 /* drop down one MTU after sending */
1601 net->cwnd -= net->mtu;
1602 if (net->cwnd < net->ssthresh)
1603 /* still in SS move to CA */

--- 28 unchanged lines hidden ---
1596 /*
1597 * make a small adjustment to cwnd and force to CA.
1598 */
1599 if (net->cwnd > net->mtu)
1600 /* drop down one MTU after sending */
1601 net->cwnd -= net->mtu;
1602 if (net->cwnd < net->ssthresh)
1603 /* still in SS move to CA */

--- 28 unchanged lines hidden ---