Lines Matching full:ca
49 static inline u32 htcp_cong_time(const struct htcp *ca) in htcp_cong_time() argument
51 return jiffies - ca->last_cong; in htcp_cong_time()
54 static inline u32 htcp_ccount(const struct htcp *ca) in htcp_ccount() argument
56 return htcp_cong_time(ca) / ca->minRTT; in htcp_ccount()
59 static inline void htcp_reset(struct htcp *ca) in htcp_reset() argument
61 ca->undo_last_cong = ca->last_cong; in htcp_reset()
62 ca->undo_maxRTT = ca->maxRTT; in htcp_reset()
63 ca->undo_old_maxB = ca->old_maxB; in htcp_reset()
65 ca->last_cong = jiffies; in htcp_reset()
70 struct htcp *ca = inet_csk_ca(sk); in htcp_cwnd_undo() local
72 if (ca->undo_last_cong) { in htcp_cwnd_undo()
73 ca->last_cong = ca->undo_last_cong; in htcp_cwnd_undo()
74 ca->maxRTT = ca->undo_maxRTT; in htcp_cwnd_undo()
75 ca->old_maxB = ca->undo_old_maxB; in htcp_cwnd_undo()
76 ca->undo_last_cong = 0; in htcp_cwnd_undo()
85 struct htcp *ca = inet_csk_ca(sk); in measure_rtt() local
88 if (ca->minRTT > srtt || !ca->minRTT) in measure_rtt()
89 ca->minRTT = srtt; in measure_rtt()
93 if (ca->maxRTT < ca->minRTT) in measure_rtt()
94 ca->maxRTT = ca->minRTT; in measure_rtt()
95 if (ca->maxRTT < srtt && in measure_rtt()
96 srtt <= ca->maxRTT + msecs_to_jiffies(20)) in measure_rtt()
97 ca->maxRTT = srtt; in measure_rtt()
106 struct htcp *ca = inet_csk_ca(sk); in measure_achieved_throughput() local
110 ca->pkts_acked = sample->pkts_acked; in measure_achieved_throughput()
120 ca->packetcount = 0; in measure_achieved_throughput()
121 ca->lasttime = now; in measure_achieved_throughput()
125 ca->packetcount += sample->pkts_acked; in measure_achieved_throughput()
127 if (ca->packetcount >= tcp_snd_cwnd(tp) - (ca->alpha >> 7 ? : 1) && in measure_achieved_throughput()
128 now - ca->lasttime >= ca->minRTT && in measure_achieved_throughput()
129 ca->minRTT > 0) { in measure_achieved_throughput()
130 __u32 cur_Bi = ca->packetcount * HZ / (now - ca->lasttime); in measure_achieved_throughput()
132 if (htcp_ccount(ca) <= 3) { in measure_achieved_throughput()
134 ca->minB = ca->maxB = ca->Bi = cur_Bi; in measure_achieved_throughput()
136 ca->Bi = (3 * ca->Bi + cur_Bi) / 4; in measure_achieved_throughput()
137 if (ca->Bi > ca->maxB) in measure_achieved_throughput()
138 ca->maxB = ca->Bi; in measure_achieved_throughput()
139 if (ca->minB > ca->maxB) in measure_achieved_throughput()
140 ca->minB = ca->maxB; in measure_achieved_throughput()
142 ca->packetcount = 0; in measure_achieved_throughput()
143 ca->lasttime = now; in measure_achieved_throughput()
147 static inline void htcp_beta_update(struct htcp *ca, u32 minRTT, u32 maxRTT) in htcp_beta_update() argument
150 u32 maxB = ca->maxB; in htcp_beta_update()
151 u32 old_maxB = ca->old_maxB; in htcp_beta_update()
153 ca->old_maxB = ca->maxB; in htcp_beta_update()
155 ca->beta = BETA_MIN; in htcp_beta_update()
156 ca->modeswitch = 0; in htcp_beta_update()
161 if (ca->modeswitch && minRTT > msecs_to_jiffies(10) && maxRTT) { in htcp_beta_update()
162 ca->beta = (minRTT << 7) / maxRTT; in htcp_beta_update()
163 if (ca->beta < BETA_MIN) in htcp_beta_update()
164 ca->beta = BETA_MIN; in htcp_beta_update()
165 else if (ca->beta > BETA_MAX) in htcp_beta_update()
166 ca->beta = BETA_MAX; in htcp_beta_update()
168 ca->beta = BETA_MIN; in htcp_beta_update()
169 ca->modeswitch = 1; in htcp_beta_update()
173 static inline void htcp_alpha_update(struct htcp *ca) in htcp_alpha_update() argument
175 u32 minRTT = ca->minRTT; in htcp_alpha_update()
177 u32 diff = htcp_cong_time(ca); in htcp_alpha_update()
194 ca->alpha = 2 * factor * ((1 << 7) - ca->beta); in htcp_alpha_update()
195 if (!ca->alpha) in htcp_alpha_update()
196 ca->alpha = ALPHA_BASE; in htcp_alpha_update()
210 struct htcp *ca = inet_csk_ca(sk); in htcp_param_update() local
211 u32 minRTT = ca->minRTT; in htcp_param_update()
212 u32 maxRTT = ca->maxRTT; in htcp_param_update()
214 htcp_beta_update(ca, minRTT, maxRTT); in htcp_param_update()
215 htcp_alpha_update(ca); in htcp_param_update()
219 ca->maxRTT = minRTT + ((maxRTT - minRTT) * 95) / 100; in htcp_param_update()
225 const struct htcp *ca = inet_csk_ca(sk); in htcp_recalc_ssthresh() local
228 return max((tcp_snd_cwnd(tp) * ca->beta) >> 7, 2U); in htcp_recalc_ssthresh()
234 struct htcp *ca = inet_csk_ca(sk); in htcp_cong_avoid() local
245 if ((tp->snd_cwnd_cnt * ca->alpha)>>7 >= tcp_snd_cwnd(tp)) { in htcp_cong_avoid()
249 htcp_alpha_update(ca); in htcp_cong_avoid()
251 tp->snd_cwnd_cnt += ca->pkts_acked; in htcp_cong_avoid()
253 ca->pkts_acked = 1; in htcp_cong_avoid()
259 struct htcp *ca = inet_csk_ca(sk); in htcp_init() local
261 memset(ca, 0, sizeof(struct htcp)); in htcp_init()
262 ca->alpha = ALPHA_BASE; in htcp_init()
263 ca->beta = BETA_MIN; in htcp_init()
264 ca->pkts_acked = 1; in htcp_init()
265 ca->last_cong = jiffies; in htcp_init()
273 struct htcp *ca = inet_csk_ca(sk); in htcp_state() local
275 if (ca->undo_last_cong) { in htcp_state()
276 ca->last_cong = jiffies; in htcp_state()
277 ca->undo_last_cong = 0; in htcp_state()