lsquic_rechist.h revision b62ec17f
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_rechist.h -- History of received packets. 450aadb33SDmitri Tikhonov * 550aadb33SDmitri Tikhonov * The purpose of received packet history is to generate ACK frames. 650aadb33SDmitri Tikhonov */ 750aadb33SDmitri Tikhonov 850aadb33SDmitri Tikhonov#ifndef LSQUIC_RECHIST_H 950aadb33SDmitri Tikhonov#define LSQUIC_RECHIST_H 1 1050aadb33SDmitri Tikhonov 115392f7a3SLiteSpeed Tech 12b62ec17fSDmitri Tikhonov/* Structure is exposed to facilitate some manipulations in unit tests. */ 13b62ec17fSDmitri Tikhonovstruct rechist_elem { 14b62ec17fSDmitri Tikhonov lsquic_packno_t re_low; 15b62ec17fSDmitri Tikhonov unsigned re_count; 16b62ec17fSDmitri Tikhonov unsigned re_next; /* UINT_MAX means no next element */ 17b62ec17fSDmitri Tikhonov}; 18b62ec17fSDmitri Tikhonov 1950aadb33SDmitri Tikhonov 2050aadb33SDmitri Tikhonovstruct lsquic_rechist { 21b62ec17fSDmitri Tikhonov /* elems and masks are allocated in contiguous memory */ 22b62ec17fSDmitri Tikhonov struct rechist_elem *rh_elems; 23b62ec17fSDmitri Tikhonov uintptr_t *rh_masks; 2450aadb33SDmitri Tikhonov lsquic_packno_t rh_cutoff; 2550aadb33SDmitri Tikhonov lsquic_time_t rh_largest_acked_received; 26b62ec17fSDmitri Tikhonov unsigned rh_n_masks; 27b62ec17fSDmitri Tikhonov unsigned rh_n_alloced; 28b62ec17fSDmitri Tikhonov unsigned rh_n_used; 29b62ec17fSDmitri Tikhonov unsigned rh_head; 3050aadb33SDmitri Tikhonov enum { 3150aadb33SDmitri Tikhonov RH_CUTOFF_SET = (1 << 0), 3250aadb33SDmitri Tikhonov } rh_flags; 33b62ec17fSDmitri Tikhonov struct 34b62ec17fSDmitri Tikhonov { 35b62ec17fSDmitri Tikhonov struct lsquic_packno_range range; 36b62ec17fSDmitri Tikhonov unsigned next; 37b62ec17fSDmitri Tikhonov } rh_iter; 38b62ec17fSDmitri Tikhonov#if LSQUIC_TEST 39b62ec17fSDmitri Tikhonov unsigned rh_n_ops; 40de46bf2fSDmitri Tikhonov#endif 4150aadb33SDmitri Tikhonov}; 4250aadb33SDmitri Tikhonov 4350aadb33SDmitri Tikhonovtypedef struct lsquic_rechist lsquic_rechist_t; 4450aadb33SDmitri Tikhonov 4550aadb33SDmitri Tikhonovvoid 46b62ec17fSDmitri Tikhonovlsquic_rechist_init (struct lsquic_rechist *, int is_ietf); 4750aadb33SDmitri Tikhonov 4850aadb33SDmitri Tikhonovvoid 4950aadb33SDmitri Tikhonovlsquic_rechist_cleanup (struct lsquic_rechist *); 5050aadb33SDmitri Tikhonov 5150aadb33SDmitri Tikhonovenum received_st { 5250aadb33SDmitri Tikhonov REC_ST_OK, 5350aadb33SDmitri Tikhonov REC_ST_DUP, 5450aadb33SDmitri Tikhonov REC_ST_ERR, 5550aadb33SDmitri Tikhonov}; 5650aadb33SDmitri Tikhonov 5750aadb33SDmitri Tikhonovenum received_st 5850aadb33SDmitri Tikhonovlsquic_rechist_received (lsquic_rechist_t *, lsquic_packno_t, 5950aadb33SDmitri Tikhonov lsquic_time_t now); 6050aadb33SDmitri Tikhonov 6150aadb33SDmitri Tikhonovvoid 6250aadb33SDmitri Tikhonovlsquic_rechist_stop_wait (lsquic_rechist_t *, lsquic_packno_t); 6350aadb33SDmitri Tikhonov 6450aadb33SDmitri Tikhonovconst struct lsquic_packno_range * 6550aadb33SDmitri Tikhonovlsquic_rechist_first (lsquic_rechist_t *); 6650aadb33SDmitri Tikhonov 6750aadb33SDmitri Tikhonovconst struct lsquic_packno_range * 6850aadb33SDmitri Tikhonovlsquic_rechist_next (lsquic_rechist_t *); 6950aadb33SDmitri Tikhonov 7050aadb33SDmitri Tikhonovlsquic_packno_t 7150aadb33SDmitri Tikhonovlsquic_rechist_largest_packno (const lsquic_rechist_t *); 7250aadb33SDmitri Tikhonov 7350aadb33SDmitri Tikhonovlsquic_packno_t 7450aadb33SDmitri Tikhonovlsquic_rechist_cutoff (const lsquic_rechist_t *); 7550aadb33SDmitri Tikhonov 7650aadb33SDmitri Tikhonovlsquic_time_t 7750aadb33SDmitri Tikhonovlsquic_rechist_largest_recv (const lsquic_rechist_t *); 7850aadb33SDmitri Tikhonov 79c51ce338SDmitri Tikhonovsize_t 80c51ce338SDmitri Tikhonovlsquic_rechist_mem_used (const struct lsquic_rechist *); 81c51ce338SDmitri Tikhonov 82b1a7c3f9SDmitri Tikhonovconst struct lsquic_packno_range * 83b62ec17fSDmitri Tikhonovlsquic_rechist_peek (struct lsquic_rechist *); 84b1a7c3f9SDmitri Tikhonov 85b62ec17fSDmitri Tikhonov#define lsquic_rechist_is_empty(rechist_) ((rechist_)->rh_n_used == 0) 86b1a7c3f9SDmitri Tikhonov 8750aadb33SDmitri Tikhonov#endif 88