mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
As it says in rfc8260#section-3.5 about the fair capacity scheduler:
A fair capacity distribution between the streams is used. This
scheduler considers the lengths of the messages of each stream and
schedules them in a specific way to maintain an equal capacity for
all streams. The details are implementation dependent. interleaving
user messages allows for a better realization of the fair capacity
usage.
This patch adds Fair Capacity Scheduler based on the foundations added
by commit 5bbbbe32a4
("sctp: introduce stream scheduler foundations"):
A fc_list and a fc_length are added into struct sctp_stream_out_ext and
a fc_list is added into struct sctp_stream. In .enqueue, when there are
chunks enqueued into a stream, this stream will be linked into stream->
fc_list by its fc_list ordered by its fc_length. In .dequeue, it always
picks up the 1st skb from stream->fc_list. In .dequeue_done, fc_length
is increased by chunk's len and update its location in stream->fc_list
according to the its new fc_length.
Note that when the new fc_length overflows in .dequeue_done, instead of
resetting all fc_lengths to 0, we only reduced them by U32_MAX / 4 to
avoid a moment of imbalance in the scheduling, as Marcelo suggested.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
64 lines
2.3 KiB
C
64 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/* SCTP kernel implementation
|
|
* (C) Copyright Red Hat Inc. 2017
|
|
*
|
|
* These are definitions used by the stream schedulers, defined in RFC
|
|
* draft ndata (https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-11)
|
|
*
|
|
* Please send any bug reports or fixes you make to the
|
|
* email addresses:
|
|
* lksctp developers <linux-sctp@vger.kernel.org>
|
|
*
|
|
* Written or modified by:
|
|
* Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
|
|
*/
|
|
|
|
#ifndef __sctp_stream_sched_h__
|
|
#define __sctp_stream_sched_h__
|
|
|
|
struct sctp_sched_ops {
|
|
/* Property handling for a given stream */
|
|
int (*set)(struct sctp_stream *stream, __u16 sid, __u16 value,
|
|
gfp_t gfp);
|
|
int (*get)(struct sctp_stream *stream, __u16 sid, __u16 *value);
|
|
|
|
/* Init the specific scheduler */
|
|
int (*init)(struct sctp_stream *stream);
|
|
/* Init a stream */
|
|
int (*init_sid)(struct sctp_stream *stream, __u16 sid, gfp_t gfp);
|
|
/* free a stream */
|
|
void (*free_sid)(struct sctp_stream *stream, __u16 sid);
|
|
|
|
/* Enqueue a chunk */
|
|
void (*enqueue)(struct sctp_outq *q, struct sctp_datamsg *msg);
|
|
/* Dequeue a chunk */
|
|
struct sctp_chunk *(*dequeue)(struct sctp_outq *q);
|
|
/* Called only if the chunk fit the packet */
|
|
void (*dequeue_done)(struct sctp_outq *q, struct sctp_chunk *chunk);
|
|
/* Sched all chunks already enqueued */
|
|
void (*sched_all)(struct sctp_stream *steam);
|
|
/* Unched all chunks already enqueued */
|
|
void (*unsched_all)(struct sctp_stream *steam);
|
|
};
|
|
|
|
int sctp_sched_set_sched(struct sctp_association *asoc,
|
|
enum sctp_sched_type sched);
|
|
int sctp_sched_get_sched(struct sctp_association *asoc);
|
|
int sctp_sched_set_value(struct sctp_association *asoc, __u16 sid,
|
|
__u16 value, gfp_t gfp);
|
|
int sctp_sched_get_value(struct sctp_association *asoc, __u16 sid,
|
|
__u16 *value);
|
|
void sctp_sched_dequeue_done(struct sctp_outq *q, struct sctp_chunk *ch);
|
|
|
|
void sctp_sched_dequeue_common(struct sctp_outq *q, struct sctp_chunk *ch);
|
|
int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp);
|
|
struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream);
|
|
|
|
void sctp_sched_ops_register(enum sctp_sched_type sched,
|
|
struct sctp_sched_ops *sched_ops);
|
|
void sctp_sched_ops_prio_init(void);
|
|
void sctp_sched_ops_rr_init(void);
|
|
void sctp_sched_ops_fc_init(void);
|
|
|
|
#endif /* __sctp_stream_sched_h__ */
|