Lines Matching refs:nr

41 static void newreno_set_max_dgram_size(OSSL_CC_NEWRENO *nr,
43 static void newreno_update_diag(OSSL_CC_NEWRENO *nr);
50 OSSL_CC_NEWRENO *nr; in newreno_new() local
52 if ((nr = OPENSSL_zalloc(sizeof(*nr))) == NULL) in newreno_new()
55 nr->now_cb = now_cb; in newreno_new()
56 nr->now_cb_arg = now_cb_arg; in newreno_new()
58 newreno_set_max_dgram_size(nr, QUIC_MIN_INITIAL_DGRAM_LEN); in newreno_new()
59 newreno_reset((OSSL_CC_DATA *)nr); in newreno_new()
61 return (OSSL_CC_DATA *)nr; in newreno_new()
69 static void newreno_set_max_dgram_size(OSSL_CC_NEWRENO *nr, in newreno_set_max_dgram_size() argument
73 int is_reduced = (max_dgram_size < nr->max_dgram_size); in newreno_set_max_dgram_size()
75 nr->max_dgram_size = max_dgram_size; in newreno_set_max_dgram_size()
81 nr->k_init_wnd = 10 * max_dgram_size; in newreno_set_max_dgram_size()
82 if (nr->k_init_wnd > max_init_wnd) in newreno_set_max_dgram_size()
83 nr->k_init_wnd = max_init_wnd; in newreno_set_max_dgram_size()
85 nr->k_min_wnd = 2 * max_dgram_size; in newreno_set_max_dgram_size()
88 nr->cong_wnd = nr->k_init_wnd; in newreno_set_max_dgram_size()
90 newreno_update_diag(nr); in newreno_set_max_dgram_size()
95 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_reset() local
97 nr->k_loss_reduction_factor_num = 1; in newreno_reset()
98 nr->k_loss_reduction_factor_den = 2; in newreno_reset()
99 nr->persistent_cong_thresh = 3; in newreno_reset()
101 nr->cong_wnd = nr->k_init_wnd; in newreno_reset()
102 nr->bytes_in_flight = 0; in newreno_reset()
103 nr->bytes_acked = 0; in newreno_reset()
104 nr->slow_start_thresh = UINT64_MAX; in newreno_reset()
105 nr->cong_recovery_start_time = ossl_time_zero(); in newreno_reset()
107 nr->processing_loss = 0; in newreno_reset()
108 nr->tx_time_of_last_loss = ossl_time_zero(); in newreno_reset()
109 nr->in_congestion_recovery = 0; in newreno_reset()
114 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_set_input_params() local
125 newreno_set_max_dgram_size(nr, value); in newreno_set_input_params()
151 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_bind_diagnostic() local
171 nr->p_diag_max_dgram_payload_len = new_p_max_dgram_payload_len; in newreno_bind_diagnostic()
174 nr->p_diag_cur_cwnd_size = new_p_cur_cwnd_size; in newreno_bind_diagnostic()
177 nr->p_diag_min_cwnd_size = new_p_min_cwnd_size; in newreno_bind_diagnostic()
180 nr->p_diag_cur_bytes_in_flight = new_p_cur_bytes_in_flight; in newreno_bind_diagnostic()
183 nr->p_diag_cur_state = new_p_cur_state; in newreno_bind_diagnostic()
185 newreno_update_diag(nr); in newreno_bind_diagnostic()
200 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_unbind_diagnostic() local
203 (void **)&nr->p_diag_max_dgram_payload_len); in newreno_unbind_diagnostic()
205 (void **)&nr->p_diag_cur_cwnd_size); in newreno_unbind_diagnostic()
207 (void **)&nr->p_diag_min_cwnd_size); in newreno_unbind_diagnostic()
209 (void **)&nr->p_diag_cur_bytes_in_flight); in newreno_unbind_diagnostic()
211 (void **)&nr->p_diag_cur_state); in newreno_unbind_diagnostic()
215 static void newreno_update_diag(OSSL_CC_NEWRENO *nr) in newreno_update_diag() argument
217 if (nr->p_diag_max_dgram_payload_len != NULL) in newreno_update_diag()
218 *nr->p_diag_max_dgram_payload_len = nr->max_dgram_size; in newreno_update_diag()
220 if (nr->p_diag_cur_cwnd_size != NULL) in newreno_update_diag()
221 *nr->p_diag_cur_cwnd_size = nr->cong_wnd; in newreno_update_diag()
223 if (nr->p_diag_min_cwnd_size != NULL) in newreno_update_diag()
224 *nr->p_diag_min_cwnd_size = nr->k_min_wnd; in newreno_update_diag()
226 if (nr->p_diag_cur_bytes_in_flight != NULL) in newreno_update_diag()
227 *nr->p_diag_cur_bytes_in_flight = nr->bytes_in_flight; in newreno_update_diag()
229 if (nr->p_diag_cur_state != NULL) { in newreno_update_diag()
230 if (nr->in_congestion_recovery) in newreno_update_diag()
231 *nr->p_diag_cur_state = 'R'; in newreno_update_diag()
232 else if (nr->cong_wnd < nr->slow_start_thresh) in newreno_update_diag()
233 *nr->p_diag_cur_state = 'S'; in newreno_update_diag()
235 *nr->p_diag_cur_state = 'A'; in newreno_update_diag()
239 static int newreno_in_cong_recovery(OSSL_CC_NEWRENO *nr, OSSL_TIME tx_time) in newreno_in_cong_recovery() argument
241 return ossl_time_compare(tx_time, nr->cong_recovery_start_time) <= 0; in newreno_in_cong_recovery()
244 static void newreno_cong(OSSL_CC_NEWRENO *nr, OSSL_TIME tx_time) in newreno_cong() argument
249 if (newreno_in_cong_recovery(nr, tx_time)) in newreno_cong()
253 nr->in_congestion_recovery = 1; in newreno_cong()
254 nr->cong_recovery_start_time = nr->now_cb(nr->now_cb_arg); in newreno_cong()
257 nr->slow_start_thresh in newreno_cong()
258 = safe_muldiv_u64(nr->cong_wnd, in newreno_cong()
259 nr->k_loss_reduction_factor_num, in newreno_cong()
260 nr->k_loss_reduction_factor_den, in newreno_cong()
264 nr->slow_start_thresh = UINT64_MAX; in newreno_cong()
266 nr->cong_wnd = nr->slow_start_thresh; in newreno_cong()
267 if (nr->cong_wnd < nr->k_min_wnd) in newreno_cong()
268 nr->cong_wnd = nr->k_min_wnd; in newreno_cong()
271 static void newreno_flush(OSSL_CC_NEWRENO *nr, uint32_t flags) in newreno_flush() argument
273 if (!nr->processing_loss) in newreno_flush()
276 newreno_cong(nr, nr->tx_time_of_last_loss); in newreno_flush()
279 nr->cong_wnd = nr->k_min_wnd; in newreno_flush()
280 nr->cong_recovery_start_time = ossl_time_zero(); in newreno_flush()
283 nr->processing_loss = 0; in newreno_flush()
284 newreno_update_diag(nr); in newreno_flush()
289 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_get_tx_allowance() local
291 if (nr->bytes_in_flight >= nr->cong_wnd) in newreno_get_tx_allowance()
294 return nr->cong_wnd - nr->bytes_in_flight; in newreno_get_tx_allowance()
313 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_on_data_sent() local
315 nr->bytes_in_flight += num_bytes; in newreno_on_data_sent()
316 newreno_update_diag(nr); in newreno_on_data_sent()
320 static int newreno_is_cong_limited(OSSL_CC_NEWRENO *nr) in newreno_is_cong_limited() argument
325 if (nr->bytes_in_flight >= nr->cong_wnd) in newreno_is_cong_limited()
328 wnd_rem = nr->cong_wnd - nr->bytes_in_flight; in newreno_is_cong_limited()
335 return (nr->cong_wnd < nr->slow_start_thresh && wnd_rem <= nr->cong_wnd / 2) in newreno_is_cong_limited()
336 || wnd_rem <= 3 * nr->max_dgram_size; in newreno_is_cong_limited()
342 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_on_data_acked() local
348 nr->bytes_in_flight -= info->tx_size; in newreno_on_data_acked()
360 if (!newreno_is_cong_limited(nr)) in newreno_on_data_acked()
377 if (newreno_in_cong_recovery(nr, info->tx_time)) { in newreno_on_data_acked()
379 } else if (nr->cong_wnd < nr->slow_start_thresh) { in newreno_on_data_acked()
381 nr->cong_wnd += info->tx_size; in newreno_on_data_acked()
382 nr->in_congestion_recovery = 0; in newreno_on_data_acked()
385 nr->bytes_acked += info->tx_size; in newreno_on_data_acked()
390 if (nr->bytes_acked >= nr->cong_wnd) { in newreno_on_data_acked()
391 nr->bytes_acked -= nr->cong_wnd; in newreno_on_data_acked()
392 nr->cong_wnd += nr->max_dgram_size; in newreno_on_data_acked()
395 nr->in_congestion_recovery = 0; in newreno_on_data_acked()
399 newreno_update_diag(nr); in newreno_on_data_acked()
406 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_on_data_lost() local
408 if (info->tx_size > nr->bytes_in_flight) in newreno_on_data_lost()
411 nr->bytes_in_flight -= info->tx_size; in newreno_on_data_lost()
413 if (!nr->processing_loss) { in newreno_on_data_lost()
415 if (ossl_time_compare(info->tx_time, nr->tx_time_of_last_loss) <= 0) in newreno_on_data_lost()
424 nr->processing_loss = 1; in newreno_on_data_lost()
429 nr->bytes_acked = 0; in newreno_on_data_lost()
432 nr->tx_time_of_last_loss in newreno_on_data_lost()
433 = ossl_time_max(nr->tx_time_of_last_loss, info->tx_time); in newreno_on_data_lost()
436 newreno_update_diag(nr); in newreno_on_data_lost()
442 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_on_data_lost_finished() local
444 newreno_flush(nr, flags); in newreno_on_data_lost_finished()
451 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_on_data_invalidated() local
453 nr->bytes_in_flight -= num_bytes; in newreno_on_data_invalidated()
454 newreno_update_diag(nr); in newreno_on_data_invalidated()
461 OSSL_CC_NEWRENO *nr = (OSSL_CC_NEWRENO *)cc; in newreno_on_ecn() local
463 nr->processing_loss = 1; in newreno_on_ecn()
464 nr->bytes_acked = 0; in newreno_on_ecn()
465 nr->tx_time_of_last_loss = info->largest_acked_time; in newreno_on_ecn()
466 newreno_flush(nr, 0); in newreno_on_ecn()