lsquic_spi.h revision 50aadb33
150aadb33SDmitri Tikhonov/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_spi.h - SPI: Stream Priority Iterator 450aadb33SDmitri Tikhonov * 550aadb33SDmitri Tikhonov * SPI purposefully does not support switching stream priorities while 650aadb33SDmitri Tikhonov * iterator is active, because this puts iteration termination outside 750aadb33SDmitri Tikhonov * of our control. One can imagine (admittedly theoretical) scenario 850aadb33SDmitri Tikhonov * in which the user keeps on switching stream priorities around and 950aadb33SDmitri Tikhonov * causing an infinite loop. 1050aadb33SDmitri Tikhonov */ 1150aadb33SDmitri Tikhonov 1250aadb33SDmitri Tikhonov#ifndef LSQUIC_SPI 1350aadb33SDmitri Tikhonov#define LSQUIC_SPI 1 1450aadb33SDmitri Tikhonov 1550aadb33SDmitri Tikhonov#include <stdint.h> 1650aadb33SDmitri Tikhonov 1750aadb33SDmitri Tikhonovenum spi_flags { 1850aadb33SDmitri Tikhonov SPI_EXHAUST_PRIO = (1 << 0), /* Exhaust priority level before moving on */ 1950aadb33SDmitri Tikhonov}; 2050aadb33SDmitri Tikhonov 2150aadb33SDmitri Tikhonov 2250aadb33SDmitri Tikhonovstruct stream_prio_iter 2350aadb33SDmitri Tikhonov{ 2450aadb33SDmitri Tikhonov lsquic_cid_t spi_cid; /* Used for logging */ 2550aadb33SDmitri Tikhonov const char *spi_name; /* Used for logging */ 2650aadb33SDmitri Tikhonov uint64_t spi_set[4]; /* 256 bits */ 2750aadb33SDmitri Tikhonov enum stream_flags spi_onlist_mask; 2850aadb33SDmitri Tikhonov enum spi_flags spi_flags:8; 2950aadb33SDmitri Tikhonov unsigned char spi_cur_prio; 3050aadb33SDmitri Tikhonov unsigned char spi_prev_prio; 3150aadb33SDmitri Tikhonov struct lsquic_stream *spi_prev_stream, 3250aadb33SDmitri Tikhonov *spi_next_stream; 3350aadb33SDmitri Tikhonov struct lsquic_streams_tailq spi_streams[256]; 3450aadb33SDmitri Tikhonov}; 3550aadb33SDmitri Tikhonov 3650aadb33SDmitri Tikhonov 3750aadb33SDmitri Tikhonovvoid 3850aadb33SDmitri Tikhonovlsquic_spi_init_ext (struct stream_prio_iter *, struct lsquic_stream *first, 3950aadb33SDmitri Tikhonov struct lsquic_stream *last, uintptr_t next_ptr_offset, 4050aadb33SDmitri Tikhonov unsigned onlist_mask, int (*filter)(void *, struct lsquic_stream *), 4150aadb33SDmitri Tikhonov void *filter_ctx, lsquic_cid_t cid, const char *name); 4250aadb33SDmitri Tikhonov 4350aadb33SDmitri Tikhonov#define lsquic_spi_init(spi, first, last, off, mask, cid, name) \ 4450aadb33SDmitri Tikhonov lsquic_spi_init_ext(spi, first, last, off, mask, NULL, NULL, cid, name) 4550aadb33SDmitri Tikhonov 4650aadb33SDmitri Tikhonov#define lsquic_spi_init_simple(spi, first, last, off, mask) \ 4750aadb33SDmitri Tikhonov lsquic_spi_init(spi, first, last, off, mask, 0, NULL) 4850aadb33SDmitri Tikhonov 4950aadb33SDmitri Tikhonovstruct lsquic_stream * 5050aadb33SDmitri Tikhonovlsquic_spi_first (struct stream_prio_iter *); 5150aadb33SDmitri Tikhonov 5250aadb33SDmitri Tikhonovstruct lsquic_stream * 5350aadb33SDmitri Tikhonovlsquic_spi_next (struct stream_prio_iter *); 5450aadb33SDmitri Tikhonov 5550aadb33SDmitri Tikhonovvoid 5650aadb33SDmitri Tikhonovlsquic_spi_exhaust_on (struct stream_prio_iter *); 5750aadb33SDmitri Tikhonov 5850aadb33SDmitri Tikhonov#endif 59