lsquic_spi.h revision c51ce338
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 Tikhonov
1850aadb33SDmitri Tikhonovstruct stream_prio_iter
1950aadb33SDmitri Tikhonov{
2050aadb33SDmitri Tikhonov    lsquic_cid_t                    spi_cid;            /* Used for logging */
2150aadb33SDmitri Tikhonov    const char                     *spi_name;           /* Used for logging */
2250aadb33SDmitri Tikhonov    uint64_t                        spi_set[4];         /* 256 bits */
2350aadb33SDmitri Tikhonov    enum stream_flags               spi_onlist_mask;
2450aadb33SDmitri Tikhonov    unsigned char                   spi_cur_prio;
2550aadb33SDmitri Tikhonov    unsigned char                   spi_prev_prio;
2650aadb33SDmitri Tikhonov    struct lsquic_stream           *spi_prev_stream,
2750aadb33SDmitri Tikhonov                                   *spi_next_stream;
2850aadb33SDmitri Tikhonov    struct lsquic_streams_tailq     spi_streams[256];
2950aadb33SDmitri Tikhonov};
3050aadb33SDmitri Tikhonov
3150aadb33SDmitri Tikhonov
3250aadb33SDmitri Tikhonovvoid
33c51ce338SDmitri Tikhonovlsquic_spi_init (struct stream_prio_iter *, struct lsquic_stream *first,
3450aadb33SDmitri Tikhonov         struct lsquic_stream *last, uintptr_t next_ptr_offset,
35c51ce338SDmitri Tikhonov         unsigned onlist_mask, lsquic_cid_t cid, const char *name);
3650aadb33SDmitri Tikhonov
3750aadb33SDmitri Tikhonovstruct lsquic_stream *
3850aadb33SDmitri Tikhonovlsquic_spi_first (struct stream_prio_iter *);
3950aadb33SDmitri Tikhonov
4050aadb33SDmitri Tikhonovstruct lsquic_stream *
4150aadb33SDmitri Tikhonovlsquic_spi_next (struct stream_prio_iter *);
4250aadb33SDmitri Tikhonov
4350aadb33SDmitri Tikhonovvoid
4450aadb33SDmitri Tikhonovlsquic_spi_exhaust_on (struct stream_prio_iter *);
4550aadb33SDmitri Tikhonov
46c51ce338SDmitri Tikhonovvoid
47c51ce338SDmitri Tikhonovlsquic_spi_drop_non_high (struct stream_prio_iter *);
48c51ce338SDmitri Tikhonov
49c51ce338SDmitri Tikhonovvoid
50c51ce338SDmitri Tikhonovlsquic_spi_drop_high (struct stream_prio_iter *);
51c51ce338SDmitri Tikhonov
5250aadb33SDmitri Tikhonov#endif
53