lsquic_hpi.h revision fbc6cc04
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_hpi.h - HPI: (Extensible) HTTP Priority Iterator 4 * 5 * https://tools.ietf.org/html/draft-ietf-httpbis-priority-01 6 * 7 * Changing a stream's priority when the stream is in the iterator 8 * does not change the stream's position in the iterator. 9 */ 10 11#ifndef LSQUIC_HPI 12#define LSQUIC_HPI 1 13 14struct lsquic_conn_public; 15 16/* We add 1 to the urgency when we place them on hpi_streams. Critical 17 * streams get the highest-priority slot zero. 18 */ 19#define N_HPI_PRIORITIES (2 + LSQUIC_MAX_HTTP_URGENCY) 20 21 22struct http_prio_iter 23{ 24 const char *hpi_name; /* Used for logging */ 25 struct lsquic_conn_public *hpi_conn_pub; 26 enum { 27 HPI_MH_4K = 1 << 0, 28 HPI_MH_MALLOC = 1 << 1, 29 } hpi_flags; 30 unsigned hpi_set[2]; /* Bitmask */ 31 unsigned hpi_counts[N_HPI_PRIORITIES]; /* For non-incr only */ 32 unsigned hpi_heaped; /* Bitmask */ 33 struct lsquic_streams_tailq hpi_streams[2][N_HPI_PRIORITIES]; 34 struct min_heap hpi_min_heap; 35 /* We do this because http_prio_iter is used in a union with 36 * stream_prio_iter, which is over 4KB on the stack. Since we 37 * are already allocating this memory on the stack, we might as well 38 * use it. 39 */ 40 struct min_heap_elem hpi_min_heap_els[236]; 41}; 42 43 44void 45lsquic_hpi_init (void *, struct lsquic_stream *first, 46 struct lsquic_stream *last, uintptr_t next_ptr_offset, 47 struct lsquic_conn_public *, const char *name, 48 int (*filter)(void *filter_ctx, struct lsquic_stream *), 49 void *filter_ctx); 50 51struct lsquic_stream * 52lsquic_hpi_first (void *); 53 54struct lsquic_stream * 55lsquic_hpi_next (void *); 56 57void 58lsquic_hpi_drop_non_high (void *); 59 60void 61lsquic_hpi_drop_high (void *); 62 63void 64lsquic_hpi_cleanup (void *); 65 66#ifndef NDEBUG 67#define LSQUIC_HPI_HEAP_TEST_STACK_OK (1 << 0) 68#define LSQUIC_HPI_HEAP_TEST_4K_OK (1 << 1) 69#if LSQUIC_TEST 70void 71lsquic_hpi_set_heap_test (int val); 72#endif 73#endif 74 75#endif 76