Lines Matching defs:stream
10 * This file contains sctp stream maniuplation primitives and helpers.
25 static void sctp_stream_shrink_out(struct sctp_stream *stream, __u16 outcnt)
31 asoc = container_of(stream, struct sctp_association, stream);
55 static void sctp_stream_free_ext(struct sctp_stream *stream, __u16 sid)
59 if (!SCTP_SO(stream, sid)->ext)
62 sched = sctp_sched_ops_from_stream(stream);
63 sched->free_sid(stream, sid);
64 kfree(SCTP_SO(stream, sid)->ext);
65 SCTP_SO(stream, sid)->ext = NULL;
68 /* Migrates chunks from stream queues to new stream queues if needed,
72 static void sctp_stream_outq_migrate(struct sctp_stream *stream,
77 if (stream->outcnt > outcnt)
78 sctp_stream_shrink_out(stream, outcnt);
87 SCTP_SO(new, i)->ext = SCTP_SO(stream, i)->ext;
88 SCTP_SO(stream, i)->ext = NULL;
92 for (i = outcnt; i < stream->outcnt; i++)
93 sctp_stream_free_ext(stream, i);
96 static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt,
101 if (outcnt <= stream->outcnt)
104 ret = genradix_prealloc(&stream->out, outcnt, gfp);
109 stream->outcnt = outcnt;
113 static int sctp_stream_alloc_in(struct sctp_stream *stream, __u16 incnt,
118 if (incnt <= stream->incnt)
121 ret = genradix_prealloc(&stream->in, incnt, gfp);
126 stream->incnt = incnt;
130 int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt,
133 struct sctp_sched_ops *sched = sctp_sched_ops_from_stream(stream);
138 /* Initial stream->out size may be very big, so free it and alloc
141 if (outcnt == stream->outcnt)
145 sched->unsched_all(stream);
146 sctp_stream_outq_migrate(stream, NULL, outcnt);
147 sched->sched_all(stream);
149 ret = sctp_stream_alloc_out(stream, outcnt, gfp);
153 for (i = 0; i < stream->outcnt; i++)
154 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
157 sctp_stream_interleave_init(stream);
161 return sctp_stream_alloc_in(stream, incnt, gfp);
164 int sctp_stream_init_ext(struct sctp_stream *stream, __u16 sid)
172 SCTP_SO(stream, sid)->ext = soute;
174 ret = sctp_sched_init_sid(stream, sid, GFP_KERNEL);
176 kfree(SCTP_SO(stream, sid)->ext);
177 SCTP_SO(stream, sid)->ext = NULL;
183 void sctp_stream_free(struct sctp_stream *stream)
185 struct sctp_sched_ops *sched = sctp_sched_ops_from_stream(stream);
188 sched->unsched_all(stream);
189 for (i = 0; i < stream->outcnt; i++)
190 sctp_stream_free_ext(stream, i);
191 genradix_free(&stream->out);
192 genradix_free(&stream->in);
195 void sctp_stream_clear(struct sctp_stream *stream)
199 for (i = 0; i < stream->outcnt; i++) {
200 SCTP_SO(stream, i)->mid = 0;
201 SCTP_SO(stream, i)->mid_uo = 0;
204 for (i = 0; i < stream->incnt; i++)
205 SCTP_SI(stream, i)->mid = 0;
208 void sctp_stream_update(struct sctp_stream *stream, struct sctp_stream *new)
210 struct sctp_sched_ops *sched = sctp_sched_ops_from_stream(stream);
212 sched->unsched_all(stream);
213 sctp_stream_outq_migrate(stream, new, new->outcnt);
214 sctp_stream_free(stream);
216 stream->out = new->out;
217 stream->in = new->in;
218 stream->outcnt = new->outcnt;
219 stream->incnt = new->incnt;
221 sched->sched_all(stream);
241 static bool sctp_stream_outq_is_empty(struct sctp_stream *stream,
247 asoc = container_of(stream, struct sctp_association, stream);
257 if (SCTP_SO(stream, sid)->ext &&
258 !list_empty(&SCTP_SO(stream, sid)->ext->outq))
268 struct sctp_stream *stream = &asoc->stream;
298 if (str_list[i] >= stream->outcnt)
307 if (str_list[i] >= stream->incnt)
328 if (out && !sctp_stream_outq_is_empty(stream, str_nums, nstr_list)) {
346 SCTP_SO(stream, str_list[i])->state =
349 for (i = 0; i < stream->outcnt; i++)
350 SCTP_SO(stream, i)->state = SCTP_STREAM_CLOSED;
365 SCTP_SO(stream, str_list[i])->state =
368 for (i = 0; i < stream->outcnt; i++)
369 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
382 struct sctp_stream *stream = &asoc->stream;
402 for (i = 0; i < stream->outcnt; i++)
403 SCTP_SO(stream, i)->state = SCTP_STREAM_CLOSED;
413 for (i = 0; i < stream->outcnt; i++)
414 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
427 struct sctp_stream *stream = &asoc->stream;
446 outcnt = stream->outcnt + out;
447 incnt = stream->incnt + in;
455 retval = sctp_stream_alloc_out(stream, outcnt, GFP_KERNEL);
496 * of all stream reconf params, so it's safe to use it
522 struct sctp_stream *stream = &asoc->stream;
557 if (ntohs(str_p[i]) >= stream->incnt) {
589 SCTP_SI(stream, ntohs(str_p[i]))->mid = 0;
591 for (i = 0; i < stream->incnt; i++)
592 SCTP_SI(stream, i)->mid = 0;
611 struct sctp_stream *stream = &asoc->stream;
643 if (ntohs(str_p[i]) >= stream->outcnt) {
649 if (!sctp_stream_outq_is_empty(stream, nums, str_p)) {
661 SCTP_SO(stream, ntohs(str_p[i]))->state =
664 for (i = 0; i < stream->outcnt; i++)
665 SCTP_SO(stream, i)->state = SCTP_STREAM_CLOSED;
689 struct sctp_stream *stream = &asoc->stream;
731 asoc->stream.si->report_ftsn(&asoc->ulpq, max_tsn_seen);
760 for (i = 0; i < stream->outcnt; i++) {
761 SCTP_SO(stream, i)->mid = 0;
762 SCTP_SO(stream, i)->mid_uo = 0;
764 for (i = 0; i < stream->incnt; i++)
765 SCTP_SI(stream, i)->mid = 0;
785 struct sctp_stream *stream = &asoc->stream;
806 incnt = stream->incnt + in;
810 if (sctp_stream_alloc_in(stream, incnt, GFP_ATOMIC))
836 stream->incnt = incnt;
855 struct sctp_stream *stream = &asoc->stream;
885 outcnt = stream->outcnt + out;
889 ret = sctp_stream_alloc_out(stream, outcnt, GFP_ATOMIC);
901 stream->outcnt = outcnt;
919 struct sctp_stream *stream = &asoc->stream;
954 sout = SCTP_SO(stream, ntohs(str_p[i]));
959 for (i = 0; i < stream->outcnt; i++) {
960 sout = SCTP_SO(stream, i);
969 for (i = 0; i < stream->outcnt; i++)
970 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
1008 asoc->stream.si->report_ftsn(&asoc->ulpq, mtsn);
1026 for (i = 0; i < stream->outcnt; i++) {
1027 SCTP_SO(stream, i)->mid = 0;
1028 SCTP_SO(stream, i)->mid_uo = 0;
1030 for (i = 0; i < stream->incnt; i++)
1031 SCTP_SI(stream, i)->mid = 0;
1034 for (i = 0; i < stream->outcnt; i++)
1035 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
1045 number = stream->outcnt - nums;
1048 for (i = number; i < stream->outcnt; i++)
1049 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
1051 sctp_stream_shrink_out(stream, number);
1052 stream->outcnt = number;