Commit 4821a076 authored by Xin Long's avatar Xin Long Committed by Paolo Abeni
Browse files

sctp: add fair capacity stream scheduler



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 5bbbbe32 ("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: default avatarXin Long <lucien.xin@gmail.com>
Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 46ca833c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,5 +58,6 @@ 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__ */
+7 −0
Original line number Diff line number Diff line
@@ -1429,6 +1429,10 @@ struct sctp_stream_out_ext {
		struct {
			struct list_head rr_list;
		};
		struct {
			struct list_head fc_list;
			__u32 fc_length;
		};
	};
};

@@ -1475,6 +1479,9 @@ struct sctp_stream {
			/* The next stream in line */
			struct sctp_stream_out_ext *rr_next;
		};
		struct {
			struct list_head fc_list;
		};
	};
	struct sctp_stream_interleave *si;
};
+2 −1
Original line number Diff line number Diff line
@@ -1211,7 +1211,8 @@ enum sctp_sched_type {
	SCTP_SS_DEFAULT = SCTP_SS_FCFS,
	SCTP_SS_PRIO,
	SCTP_SS_RR,
	SCTP_SS_MAX = SCTP_SS_RR
	SCTP_SS_FC,
	SCTP_SS_MAX = SCTP_SS_FC
};

/* Probe Interval socket option */
+2 −1
Original line number Diff line number Diff line
@@ -13,7 +13,8 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
	  tsnmap.o bind_addr.o socket.o primitive.o \
	  output.o input.o debug.o stream.o auth.o \
	  offload.o stream_sched.o stream_sched_prio.o \
	  stream_sched_rr.o stream_interleave.o
	  stream_sched_rr.o stream_sched_fc.o \
	  stream_interleave.o

sctp_diag-y := diag.o

+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ void sctp_sched_ops_init(void)
	sctp_sched_ops_fcfs_init();
	sctp_sched_ops_prio_init();
	sctp_sched_ops_rr_init();
	sctp_sched_ops_fc_init();
}

static void sctp_sched_free_sched(struct sctp_stream *stream)
Loading