lsquic_spi.h revision 7d09751d
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 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
175392f7a3SLiteSpeed Techenum stream_q_flags;
185392f7a3SLiteSpeed Tech
1950aadb33SDmitri Tikhonov
2050aadb33SDmitri Tikhonovstruct stream_prio_iter
2150aadb33SDmitri Tikhonov{
225392f7a3SLiteSpeed Tech    const struct lsquic_conn       *spi_conn;           /* Used for logging */
2350aadb33SDmitri Tikhonov    const char                     *spi_name;           /* Used for logging */
2450aadb33SDmitri Tikhonov    uint64_t                        spi_set[4];         /* 256 bits */
255392f7a3SLiteSpeed Tech    enum stream_q_flags             spi_onlist_mask;
26a0e1aeeeSDmitri Tikhonov    unsigned                        spi_n_added;
2750aadb33SDmitri Tikhonov    unsigned char                   spi_cur_prio;
2850aadb33SDmitri Tikhonov    unsigned char                   spi_prev_prio;
2950aadb33SDmitri Tikhonov    struct lsquic_stream           *spi_prev_stream,
3050aadb33SDmitri Tikhonov                                   *spi_next_stream;
3150aadb33SDmitri Tikhonov    struct lsquic_streams_tailq     spi_streams[256];
3250aadb33SDmitri Tikhonov};
3350aadb33SDmitri Tikhonov
3450aadb33SDmitri Tikhonov
3550aadb33SDmitri Tikhonovvoid
36c51ce338SDmitri Tikhonovlsquic_spi_init (struct stream_prio_iter *, struct lsquic_stream *first,
3750aadb33SDmitri Tikhonov         struct lsquic_stream *last, uintptr_t next_ptr_offset,
385392f7a3SLiteSpeed Tech         enum stream_q_flags onlist_mask, const struct lsquic_conn *,
395392f7a3SLiteSpeed Tech         const char *name,
4019f667fbSDmitri Tikhonov         int (*filter)(void *filter_ctx, struct lsquic_stream *),
4119f667fbSDmitri Tikhonov         void *filter_ctx);
4250aadb33SDmitri Tikhonov
4350aadb33SDmitri Tikhonovstruct lsquic_stream *
4450aadb33SDmitri Tikhonovlsquic_spi_first (struct stream_prio_iter *);
4550aadb33SDmitri Tikhonov
4650aadb33SDmitri Tikhonovstruct lsquic_stream *
4750aadb33SDmitri Tikhonovlsquic_spi_next (struct stream_prio_iter *);
4850aadb33SDmitri Tikhonov
4950aadb33SDmitri Tikhonovvoid
5050aadb33SDmitri Tikhonovlsquic_spi_exhaust_on (struct stream_prio_iter *);
5150aadb33SDmitri Tikhonov
52c51ce338SDmitri Tikhonovvoid
53c51ce338SDmitri Tikhonovlsquic_spi_drop_non_high (struct stream_prio_iter *);
54c51ce338SDmitri Tikhonov
55c51ce338SDmitri Tikhonovvoid
56c51ce338SDmitri Tikhonovlsquic_spi_drop_high (struct stream_prio_iter *);
57c51ce338SDmitri Tikhonov
5850aadb33SDmitri Tikhonov#endif
59