Lines Matching refs:rxfc
126 int ossl_quic_rxfc_init(QUIC_RXFC *rxfc, QUIC_RXFC *conn_rxfc, in ossl_quic_rxfc_init() argument
135 rxfc->swm = 0; in ossl_quic_rxfc_init()
136 rxfc->cwm = initial_window_size; in ossl_quic_rxfc_init()
137 rxfc->rwm = 0; in ossl_quic_rxfc_init()
138 rxfc->esrwm = 0; in ossl_quic_rxfc_init()
139 rxfc->hwm = 0; in ossl_quic_rxfc_init()
140 rxfc->cur_window_size = initial_window_size; in ossl_quic_rxfc_init()
141 rxfc->max_window_size = max_window_size; in ossl_quic_rxfc_init()
142 rxfc->parent = conn_rxfc; in ossl_quic_rxfc_init()
143 rxfc->error_code = 0; in ossl_quic_rxfc_init()
144 rxfc->has_cwm_changed = 0; in ossl_quic_rxfc_init()
145 rxfc->epoch_start = ossl_time_zero(); in ossl_quic_rxfc_init()
146 rxfc->now = now; in ossl_quic_rxfc_init()
147 rxfc->now_arg = now_arg; in ossl_quic_rxfc_init()
148 rxfc->is_fin = 0; in ossl_quic_rxfc_init()
149 rxfc->standalone = 0; in ossl_quic_rxfc_init()
153 int ossl_quic_rxfc_init_standalone(QUIC_RXFC *rxfc, in ossl_quic_rxfc_init_standalone() argument
158 if (!ossl_quic_rxfc_init(rxfc, NULL, in ossl_quic_rxfc_init_standalone()
163 rxfc->standalone = 1; in ossl_quic_rxfc_init_standalone()
167 QUIC_RXFC *ossl_quic_rxfc_get_parent(QUIC_RXFC *rxfc) in ossl_quic_rxfc_get_parent() argument
169 return rxfc->parent; in ossl_quic_rxfc_get_parent()
172 void ossl_quic_rxfc_set_max_window_size(QUIC_RXFC *rxfc, in ossl_quic_rxfc_set_max_window_size() argument
175 rxfc->max_window_size = max_window_size; in ossl_quic_rxfc_set_max_window_size()
178 static void rxfc_start_epoch(QUIC_RXFC *rxfc) in rxfc_start_epoch() argument
180 rxfc->epoch_start = rxfc->now(rxfc->now_arg); in rxfc_start_epoch()
181 rxfc->esrwm = rxfc->rwm; in rxfc_start_epoch()
184 static int on_rx_controlled_bytes(QUIC_RXFC *rxfc, uint64_t num_bytes) in on_rx_controlled_bytes() argument
187 uint64_t credit = rxfc->cwm - rxfc->swm; in on_rx_controlled_bytes()
192 rxfc->error_code = OSSL_QUIC_ERR_FLOW_CONTROL_ERROR; in on_rx_controlled_bytes()
195 rxfc->swm += num_bytes; in on_rx_controlled_bytes()
199 int ossl_quic_rxfc_on_rx_stream_frame(QUIC_RXFC *rxfc, uint64_t end, int is_fin) in ossl_quic_rxfc_on_rx_stream_frame() argument
203 if (!rxfc->standalone && rxfc->parent == NULL) in ossl_quic_rxfc_on_rx_stream_frame()
206 if (rxfc->is_fin && ((is_fin && rxfc->hwm != end) || end > rxfc->hwm)) { in ossl_quic_rxfc_on_rx_stream_frame()
208 rxfc->error_code = OSSL_QUIC_ERR_FINAL_SIZE_ERROR; in ossl_quic_rxfc_on_rx_stream_frame()
213 rxfc->is_fin = 1; in ossl_quic_rxfc_on_rx_stream_frame()
215 if (end > rxfc->hwm) { in ossl_quic_rxfc_on_rx_stream_frame()
216 delta = end - rxfc->hwm; in ossl_quic_rxfc_on_rx_stream_frame()
217 rxfc->hwm = end; in ossl_quic_rxfc_on_rx_stream_frame()
219 on_rx_controlled_bytes(rxfc, delta); /* result ignored */ in ossl_quic_rxfc_on_rx_stream_frame()
220 if (rxfc->parent != NULL) in ossl_quic_rxfc_on_rx_stream_frame()
221 on_rx_controlled_bytes(rxfc->parent, delta); /* result ignored */ in ossl_quic_rxfc_on_rx_stream_frame()
222 } else if (end < rxfc->hwm && is_fin) { in ossl_quic_rxfc_on_rx_stream_frame()
223 rxfc->error_code = OSSL_QUIC_ERR_FINAL_SIZE_ERROR; in ossl_quic_rxfc_on_rx_stream_frame()
234 static int rxfc_cwm_bump_desired(QUIC_RXFC *rxfc) in rxfc_cwm_bump_desired() argument
237 uint64_t window_rem = rxfc->cwm - rxfc->rwm; in rxfc_cwm_bump_desired()
239 = safe_muldiv_uint64_t(rxfc->cur_window_size, in rxfc_cwm_bump_desired()
247 threshold = rxfc->cur_window_size / 2; in rxfc_cwm_bump_desired()
253 return !rxfc->is_fin && window_rem <= threshold; in rxfc_cwm_bump_desired()
256 static int rxfc_should_bump_window_size(QUIC_RXFC *rxfc, OSSL_TIME rtt) in rxfc_should_bump_window_size() argument
277 uint64_t b = rxfc->rwm - rxfc->esrwm; in rxfc_should_bump_window_size()
283 now = rxfc->now(rxfc->now_arg); in rxfc_should_bump_window_size()
284 dt = ossl_time_subtract(now, rxfc->epoch_start); in rxfc_should_bump_window_size()
285 t_window = ossl_time_muldiv(dt, rxfc->cur_window_size, b); in rxfc_should_bump_window_size()
290 static void rxfc_adjust_window_size(QUIC_RXFC *rxfc, uint64_t min_window_size, in rxfc_adjust_window_size() argument
296 new_window_size = rxfc->cur_window_size; in rxfc_adjust_window_size()
298 if (rxfc_should_bump_window_size(rxfc, rtt)) in rxfc_adjust_window_size()
303 if (new_window_size > rxfc->max_window_size) /* takes precedence over min size */ in rxfc_adjust_window_size()
304 new_window_size = rxfc->max_window_size; in rxfc_adjust_window_size()
306 rxfc->cur_window_size = new_window_size; in rxfc_adjust_window_size()
307 rxfc_start_epoch(rxfc); in rxfc_adjust_window_size()
310 static void rxfc_update_cwm(QUIC_RXFC *rxfc, uint64_t min_window_size, in rxfc_update_cwm() argument
315 if (!rxfc_cwm_bump_desired(rxfc)) in rxfc_update_cwm()
318 rxfc_adjust_window_size(rxfc, min_window_size, rtt); in rxfc_update_cwm()
320 new_cwm = rxfc->rwm + rxfc->cur_window_size; in rxfc_update_cwm()
321 if (new_cwm > rxfc->cwm) { in rxfc_update_cwm()
322 rxfc->cwm = new_cwm; in rxfc_update_cwm()
323 rxfc->has_cwm_changed = 1; in rxfc_update_cwm()
327 static int rxfc_on_retire(QUIC_RXFC *rxfc, uint64_t num_bytes, in rxfc_on_retire() argument
331 if (ossl_time_is_zero(rxfc->epoch_start)) in rxfc_on_retire()
333 rxfc_start_epoch(rxfc); in rxfc_on_retire()
335 rxfc->rwm += num_bytes; in rxfc_on_retire()
336 rxfc_update_cwm(rxfc, min_window_size, rtt); in rxfc_on_retire()
340 int ossl_quic_rxfc_on_retire(QUIC_RXFC *rxfc, in ossl_quic_rxfc_on_retire() argument
344 if (rxfc->parent == NULL && !rxfc->standalone) in ossl_quic_rxfc_on_retire()
350 if (rxfc->rwm + num_bytes > rxfc->swm) in ossl_quic_rxfc_on_retire()
354 rxfc_on_retire(rxfc, num_bytes, 0, rtt); in ossl_quic_rxfc_on_retire()
356 if (!rxfc->standalone) in ossl_quic_rxfc_on_retire()
357 rxfc_on_retire(rxfc->parent, num_bytes, rxfc->cur_window_size, rtt); in ossl_quic_rxfc_on_retire()
362 uint64_t ossl_quic_rxfc_get_cwm(const QUIC_RXFC *rxfc) in ossl_quic_rxfc_get_cwm() argument
364 return rxfc->cwm; in ossl_quic_rxfc_get_cwm()
367 uint64_t ossl_quic_rxfc_get_swm(const QUIC_RXFC *rxfc) in ossl_quic_rxfc_get_swm() argument
369 return rxfc->swm; in ossl_quic_rxfc_get_swm()
372 uint64_t ossl_quic_rxfc_get_rwm(const QUIC_RXFC *rxfc) in ossl_quic_rxfc_get_rwm() argument
374 return rxfc->rwm; in ossl_quic_rxfc_get_rwm()
377 uint64_t ossl_quic_rxfc_get_credit(const QUIC_RXFC *rxfc) in ossl_quic_rxfc_get_credit() argument
379 return ossl_quic_rxfc_get_cwm(rxfc) - ossl_quic_rxfc_get_swm(rxfc); in ossl_quic_rxfc_get_credit()
382 int ossl_quic_rxfc_has_cwm_changed(QUIC_RXFC *rxfc, int clear) in ossl_quic_rxfc_has_cwm_changed() argument
384 int r = rxfc->has_cwm_changed; in ossl_quic_rxfc_has_cwm_changed()
387 rxfc->has_cwm_changed = 0; in ossl_quic_rxfc_has_cwm_changed()
392 int ossl_quic_rxfc_get_error(QUIC_RXFC *rxfc, int clear) in ossl_quic_rxfc_get_error() argument
394 int r = rxfc->error_code; in ossl_quic_rxfc_get_error()
397 rxfc->error_code = 0; in ossl_quic_rxfc_get_error()
402 int ossl_quic_rxfc_get_final_size(const QUIC_RXFC *rxfc, uint64_t *final_size) in ossl_quic_rxfc_get_final_size() argument
404 if (!rxfc->is_fin) in ossl_quic_rxfc_get_final_size()
408 *final_size = rxfc->hwm; in ossl_quic_rxfc_get_final_size()