2019-05-23 12:14:41 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
/* SCTP kernel implementation
|
|
|
|
* (C) Copyright Red Hat Inc. 2017
|
|
|
|
*
|
|
|
|
* This file is part of the SCTP kernel implementation
|
|
|
|
*
|
|
|
|
* These functions manipulate sctp stream queue/scheduling.
|
|
|
|
*
|
|
|
|
* Please send any bug reports or fixes you make to the
|
|
|
|
* email addresched(es):
|
|
|
|
* lksctp developers <linux-sctp@vger.kernel.org>
|
|
|
|
*
|
|
|
|
* Written or modified by:
|
|
|
|
* Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <net/sctp/sctp.h>
|
|
|
|
#include <net/sctp/sm.h>
|
|
|
|
#include <net/sctp/stream_sched.h>
|
|
|
|
|
|
|
|
/* First Come First Serve (a.k.a. FIFO)
|
|
|
|
* RFC DRAFT ndata Section 3.1
|
|
|
|
*/
|
|
|
|
static int sctp_sched_fcfs_set(struct sctp_stream *stream, __u16 sid,
|
|
|
|
__u16 value, gfp_t gfp)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sctp_sched_fcfs_get(struct sctp_stream *stream, __u16 sid,
|
|
|
|
__u16 *value)
|
|
|
|
{
|
|
|
|
*value = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sctp_sched_fcfs_init(struct sctp_stream *stream)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sctp_sched_fcfs_init_sid(struct sctp_stream *stream, __u16 sid,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_sched_fcfs_free(struct sctp_stream *stream)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_sched_fcfs_enqueue(struct sctp_outq *q,
|
|
|
|
struct sctp_datamsg *msg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sctp_chunk *sctp_sched_fcfs_dequeue(struct sctp_outq *q)
|
|
|
|
{
|
|
|
|
struct sctp_stream *stream = &q->asoc->stream;
|
|
|
|
struct sctp_chunk *ch = NULL;
|
|
|
|
struct list_head *entry;
|
|
|
|
|
|
|
|
if (list_empty(&q->out_chunk_list))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (stream->out_curr) {
|
|
|
|
ch = list_entry(stream->out_curr->ext->outq.next,
|
|
|
|
struct sctp_chunk, stream_list);
|
|
|
|
} else {
|
|
|
|
entry = q->out_chunk_list.next;
|
|
|
|
ch = list_entry(entry, struct sctp_chunk, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
sctp_sched_dequeue_common(q, ch);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_sched_fcfs_dequeue_done(struct sctp_outq *q,
|
|
|
|
struct sctp_chunk *chunk)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_sched_fcfs_sched_all(struct sctp_stream *stream)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_sched_fcfs_unsched_all(struct sctp_stream *stream)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct sctp_sched_ops sctp_sched_fcfs = {
|
|
|
|
.set = sctp_sched_fcfs_set,
|
|
|
|
.get = sctp_sched_fcfs_get,
|
|
|
|
.init = sctp_sched_fcfs_init,
|
|
|
|
.init_sid = sctp_sched_fcfs_init_sid,
|
|
|
|
.free = sctp_sched_fcfs_free,
|
|
|
|
.enqueue = sctp_sched_fcfs_enqueue,
|
|
|
|
.dequeue = sctp_sched_fcfs_dequeue,
|
|
|
|
.dequeue_done = sctp_sched_fcfs_dequeue_done,
|
|
|
|
.sched_all = sctp_sched_fcfs_sched_all,
|
|
|
|
.unsched_all = sctp_sched_fcfs_unsched_all,
|
|
|
|
};
|
|
|
|
|
2017-11-26 15:16:08 +03:00
|
|
|
static void sctp_sched_ops_fcfs_init(void)
|
|
|
|
{
|
|
|
|
sctp_sched_ops_register(SCTP_SS_FCFS, &sctp_sched_fcfs);
|
|
|
|
}
|
|
|
|
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
/* API to other parts of the stack */
|
|
|
|
|
2017-11-26 15:16:08 +03:00
|
|
|
static struct sctp_sched_ops *sctp_sched_ops[SCTP_SS_MAX + 1];
|
sctp: introduce priority based stream scheduler
This patch introduces RFC Draft ndata section 3.4 Priority Based
Scheduler (SCTP_SS_PRIO).
It works by having a struct sctp_stream_priority for each priority
configured. This struct is then enlisted on a queue ordered per priority
if, and only if, there is a stream with data queued, so that dequeueing
is very straightforward: either finish current datamsg or simply dequeue
from the highest priority queued, which is the next stream pointed, and
that's it.
If there are multiple streams assigned with the same priority and with
data queued, it will do round robin amongst them while respecting
datamsgs boundaries (when not using idata chunks), to be reasonably
fair.
We intentionally don't maintain a list of priorities nor a list of all
streams with the same priority to save memory. The first would mean at
least 2 other pointers per priority (which, for 1000 priorities, that
can mean 16kB) and the second would also mean 2 other pointers but per
stream. As SCTP supports up to 65535 streams on a given asoc, that's
1MB. This impacts when giving a priority to some stream, as we have to
find out if the new priority is already being used and if we can free
the old one, and also when tearing down.
The new fields in struct sctp_stream_out_ext and sctp_stream are added
under a union because that memory is to be shared with other schedulers.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:16 +03:00
|
|
|
|
2017-11-26 15:16:08 +03:00
|
|
|
void sctp_sched_ops_register(enum sctp_sched_type sched,
|
|
|
|
struct sctp_sched_ops *sched_ops)
|
|
|
|
{
|
|
|
|
sctp_sched_ops[sched] = sched_ops;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sctp_sched_ops_init(void)
|
|
|
|
{
|
|
|
|
sctp_sched_ops_fcfs_init();
|
|
|
|
sctp_sched_ops_prio_init();
|
|
|
|
sctp_sched_ops_rr_init();
|
|
|
|
}
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
|
|
|
|
int sctp_sched_set_sched(struct sctp_association *asoc,
|
|
|
|
enum sctp_sched_type sched)
|
|
|
|
{
|
|
|
|
struct sctp_sched_ops *n = sctp_sched_ops[sched];
|
|
|
|
struct sctp_sched_ops *old = asoc->outqueue.sched;
|
|
|
|
struct sctp_datamsg *msg = NULL;
|
|
|
|
struct sctp_chunk *ch;
|
|
|
|
int i, ret = 0;
|
|
|
|
|
|
|
|
if (old == n)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (sched > SCTP_SS_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (old) {
|
|
|
|
old->free(&asoc->stream);
|
|
|
|
|
|
|
|
/* Give the next scheduler a clean slate. */
|
|
|
|
for (i = 0; i < asoc->stream.outcnt; i++) {
|
2018-08-10 20:11:42 +03:00
|
|
|
void *p = SCTP_SO(&asoc->stream, i)->ext;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
|
|
|
|
if (!p)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
p += offsetofend(struct sctp_stream_out_ext, outq);
|
|
|
|
memset(p, 0, sizeof(struct sctp_stream_out_ext) -
|
|
|
|
offsetofend(struct sctp_stream_out_ext, outq));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
asoc->outqueue.sched = n;
|
|
|
|
n->init(&asoc->stream);
|
|
|
|
for (i = 0; i < asoc->stream.outcnt; i++) {
|
2018-08-10 20:11:42 +03:00
|
|
|
if (!SCTP_SO(&asoc->stream, i)->ext)
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
ret = n->init_sid(&asoc->stream, i, GFP_KERNEL);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have to requeue all chunks already queued. */
|
|
|
|
list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list) {
|
|
|
|
if (ch->msg == msg)
|
|
|
|
continue;
|
|
|
|
msg = ch->msg;
|
|
|
|
n->enqueue(&asoc->outqueue, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
err:
|
|
|
|
n->free(&asoc->stream);
|
|
|
|
asoc->outqueue.sched = &sctp_sched_fcfs; /* Always safe */
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sctp_sched_get_sched(struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i <= SCTP_SS_MAX; i++)
|
|
|
|
if (asoc->outqueue.sched == sctp_sched_ops[i])
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sctp_sched_set_value(struct sctp_association *asoc, __u16 sid,
|
|
|
|
__u16 value, gfp_t gfp)
|
|
|
|
{
|
|
|
|
if (sid >= asoc->stream.outcnt)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-08-10 20:11:42 +03:00
|
|
|
if (!SCTP_SO(&asoc->stream, sid)->ext) {
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = sctp_stream_init_ext(&asoc->stream, sid);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return asoc->outqueue.sched->set(&asoc->stream, sid, value, gfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
int sctp_sched_get_value(struct sctp_association *asoc, __u16 sid,
|
|
|
|
__u16 *value)
|
|
|
|
{
|
|
|
|
if (sid >= asoc->stream.outcnt)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-08-10 20:11:42 +03:00
|
|
|
if (!SCTP_SO(&asoc->stream, sid)->ext)
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return asoc->outqueue.sched->get(&asoc->stream, sid, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sctp_sched_dequeue_done(struct sctp_outq *q, struct sctp_chunk *ch)
|
|
|
|
{
|
2017-12-14 19:41:30 +03:00
|
|
|
if (!list_is_last(&ch->frag_list, &ch->msg->chunks) &&
|
2019-07-08 19:57:06 +03:00
|
|
|
!q->asoc->peer.intl_capable) {
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
struct sctp_stream_out *sout;
|
|
|
|
__u16 sid;
|
|
|
|
|
|
|
|
/* datamsg is not finish, so save it as current one,
|
|
|
|
* in case application switch scheduler or a higher
|
|
|
|
* priority stream comes in.
|
|
|
|
*/
|
|
|
|
sid = sctp_chunk_stream_no(ch);
|
2018-08-10 20:11:42 +03:00
|
|
|
sout = SCTP_SO(&q->asoc->stream, sid);
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
q->asoc->stream.out_curr = sout;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
q->asoc->stream.out_curr = NULL;
|
|
|
|
q->sched->dequeue_done(q, ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Auxiliary functions for the schedulers */
|
|
|
|
void sctp_sched_dequeue_common(struct sctp_outq *q, struct sctp_chunk *ch)
|
|
|
|
{
|
|
|
|
list_del_init(&ch->list);
|
|
|
|
list_del_init(&ch->stream_list);
|
|
|
|
q->out_qlen -= ch->skb->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sctp_sched_ops *sched = sctp_sched_ops_from_stream(stream);
|
2018-08-10 20:11:42 +03:00
|
|
|
struct sctp_stream_out_ext *ext = SCTP_SO(stream, sid)->ext;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
|
2018-08-10 20:11:42 +03:00
|
|
|
INIT_LIST_HEAD(&ext->outq);
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 01:20:13 +03:00
|
|
|
return sched->init_sid(stream, sid, gfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream)
|
|
|
|
{
|
|
|
|
struct sctp_association *asoc;
|
|
|
|
|
|
|
|
asoc = container_of(stream, struct sctp_association, stream);
|
|
|
|
|
|
|
|
return asoc->outqueue.sched;
|
|
|
|
}
|