net/sctp/stream_sched_fc.c

Source file repositories/reference/linux-study-clean/net/sctp/stream_sched_fc.c

File Facts

System
Linux kernel
Corpus path
net/sctp/stream_sched_fc.c
Extension
.c
Size
5729 bytes
Lines
226
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

if (pos->fc_length <= (U32_MAX >> 2)) {
				pos->fc_length = 0;
				continue;
			}
			pos->fc_length -= (U32_MAX >> 2);
		}
	}
	soute->fc_length += ch->skb->len;

	if (list_empty(&soute->outq)) {
		list_del_init(&soute->fc_list);
		return;
	}

	pos = soute;
	list_for_each_entry_continue(pos, &stream->fc_list, fc_list)
		if ((__u64)pos->fc_length * soute->fc_weight >=
		    (__u64)soute->fc_length * pos->fc_weight)
			break;
	list_move_tail(&soute->fc_list, &pos->fc_list);
}

static void sctp_sched_fc_sched_all(struct sctp_stream *stream)
{
	struct sctp_association *asoc;
	struct sctp_chunk *ch;

	asoc = container_of(stream, struct sctp_association, stream);
	list_for_each_entry(ch, &asoc->outqueue.out_chunk_list, list) {
		__u16 sid = sctp_chunk_stream_no(ch);

		if (SCTP_SO(stream, sid)->ext)
			sctp_sched_fc_sched(stream, SCTP_SO(stream, sid)->ext);
	}
}

static void sctp_sched_fc_unsched_all(struct sctp_stream *stream)
{
	struct sctp_stream_out_ext *soute, *tmp;

	list_for_each_entry_safe(soute, tmp, &stream->fc_list, fc_list)
		list_del_init(&soute->fc_list);
}

static const struct sctp_sched_ops sctp_sched_fc = {
	.set = sctp_sched_fc_set,
	.get = sctp_sched_fc_get,
	.init = sctp_sched_fc_init,
	.init_sid = sctp_sched_fc_init_sid,
	.free_sid = sctp_sched_fc_free_sid,
	.enqueue = sctp_sched_fc_enqueue,
	.dequeue = sctp_sched_fc_dequeue,
	.dequeue_done = sctp_sched_fc_dequeue_done,
	.sched_all = sctp_sched_fc_sched_all,
	.unsched_all = sctp_sched_fc_unsched_all,
};

void sctp_sched_ops_fc_init(void)
{
	sctp_sched_ops_register(SCTP_SS_FC, &sctp_sched_fc);
}

static const struct sctp_sched_ops sctp_sched_wfq = {
	.set = sctp_sched_wfq_set,
	.get = sctp_sched_wfq_get,
	.init = sctp_sched_fc_init,
	.init_sid = sctp_sched_fc_init_sid,
	.free_sid = sctp_sched_fc_free_sid,
	.enqueue = sctp_sched_fc_enqueue,
	.dequeue = sctp_sched_fc_dequeue,
	.dequeue_done = sctp_sched_fc_dequeue_done,
	.sched_all = sctp_sched_fc_sched_all,
	.unsched_all = sctp_sched_fc_unsched_all,
};

void sctp_sched_ops_wfq_init(void)
{
	sctp_sched_ops_register(SCTP_SS_WFQ, &sctp_sched_wfq);
}

Annotation

Implementation Notes