net/sctp/stream_sched_prio.c
Source file repositories/reference/linux-study-clean/net/sctp/stream_sched_prio.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/stream_sched_prio.c- Extension
.c- Size
- 8082 bytes
- Lines
- 320
- 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.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hnet/sctp/sctp.hnet/sctp/sm.hnet/sctp/stream_sched.h
Detected Declarations
function sctp_sched_prio_head_putfunction sctp_sched_prio_next_streamfunction sctp_sched_prio_unschedfunction sctp_sched_prio_schedfunction list_for_each_entryfunction sctp_sched_prio_setfunction sctp_sched_prio_getfunction sctp_sched_prio_initfunction sctp_sched_prio_init_sidfunction sctp_sched_prio_free_sidfunction sctp_sched_prio_enqueuefunction sctp_sched_prio_dequeue_donefunction sctp_sched_prio_sched_allfunction sctp_sched_prio_unsched_allfunction sctp_sched_ops_prio_init
Annotated Snippet
if (list_empty(&prio_head->active)) {
list_del_init(&prio_head->prio_sched);
/* If there is no stream left, clear next */
prio_head->next = NULL;
}
}
return scheduled;
}
static void sctp_sched_prio_sched(struct sctp_stream *stream,
struct sctp_stream_out_ext *soute)
{
struct sctp_stream_priorities *prio, *prio_head;
prio_head = soute->prio_head;
/* Nothing to do if already scheduled */
if (!list_empty(&soute->prio_list))
return;
/* Schedule the stream. If there is a next, we schedule the new
* one before it, so it's the last in round robin order.
* If there isn't, we also have to schedule the priority.
*/
if (prio_head->next) {
list_add(&soute->prio_list, prio_head->next->prio_list.prev);
return;
}
list_add(&soute->prio_list, &prio_head->active);
prio_head->next = soute;
list_for_each_entry(prio, &stream->prio_list, prio_sched) {
if (prio->prio > prio_head->prio) {
list_add(&prio_head->prio_sched, prio->prio_sched.prev);
return;
}
}
list_add_tail(&prio_head->prio_sched, &stream->prio_list);
}
static int sctp_sched_prio_set(struct sctp_stream *stream, __u16 sid,
__u16 prio, gfp_t gfp)
{
struct sctp_stream_out *sout = SCTP_SO(stream, sid);
struct sctp_stream_out_ext *soute = sout->ext;
struct sctp_stream_priorities *prio_head, *old;
bool reschedule = false;
old = soute->prio_head;
if (old && old->prio == prio)
return 0;
prio_head = sctp_sched_prio_get_head(stream, prio, gfp);
if (!prio_head)
return -ENOMEM;
reschedule = sctp_sched_prio_unsched(soute);
soute->prio_head = prio_head;
if (reschedule)
sctp_sched_prio_sched(stream, soute);
sctp_sched_prio_head_put(old);
return 0;
}
static int sctp_sched_prio_get(struct sctp_stream *stream, __u16 sid,
__u16 *value)
{
*value = SCTP_SO(stream, sid)->ext->prio_head->prio;
return 0;
}
static int sctp_sched_prio_init(struct sctp_stream *stream)
{
INIT_LIST_HEAD(&stream->prio_list);
return 0;
}
static int sctp_sched_prio_init_sid(struct sctp_stream *stream, __u16 sid,
gfp_t gfp)
{
INIT_LIST_HEAD(&SCTP_SO(stream, sid)->ext->prio_list);
return sctp_sched_prio_set(stream, sid, 0, gfp);
}
static void sctp_sched_prio_free_sid(struct sctp_stream *stream, __u16 sid)
Annotation
- Immediate include surface: `linux/list.h`, `net/sctp/sctp.h`, `net/sctp/sm.h`, `net/sctp/stream_sched.h`.
- Detected declarations: `function sctp_sched_prio_head_put`, `function sctp_sched_prio_next_stream`, `function sctp_sched_prio_unsched`, `function sctp_sched_prio_sched`, `function list_for_each_entry`, `function sctp_sched_prio_set`, `function sctp_sched_prio_get`, `function sctp_sched_prio_init`, `function sctp_sched_prio_init_sid`, `function sctp_sched_prio_free_sid`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.