Skip to content

Commit 1ba896f

Browse files
lxindavem330
authored andcommitted
sctp: remove extern from stream sched
Now each stream sched ops is defined in different .c file and added into the global ops in another .c file, it uses extern to make this work. However extern is not good coding style to get them in and even make C=2 reports errors for this. This patch adds sctp_sched_ops_xxx_init for each stream sched ops in their .c file, then get them into the global ops by calling them when initializing sctp module. Fixes: 637784a ("sctp: introduce priority based stream scheduler") Fixes: ac1ed8b ("sctp: introduce round robin stream scheduler") Signed-off-by: Xin Long <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent af2697a commit 1ba896f

File tree

6 files changed

+41
-9
lines changed

6 files changed

+41
-9
lines changed

include/net/sctp/sctp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ void sctp_remaddr_proc_exit(struct net *net);
194194
*/
195195
int sctp_offload_init(void);
196196

197+
/*
198+
* sctp/stream_sched.c
199+
*/
200+
void sctp_sched_ops_init(void);
201+
197202
/*
198203
* sctp/stream.c
199204
*/

include/net/sctp/stream_sched.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@ void sctp_sched_dequeue_common(struct sctp_outq *q, struct sctp_chunk *ch);
6969
int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp);
7070
struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream);
7171

72+
void sctp_sched_ops_register(enum sctp_sched_type sched,
73+
struct sctp_sched_ops *sched_ops);
74+
void sctp_sched_ops_prio_init(void);
75+
void sctp_sched_ops_rr_init(void);
76+
7277
#endif /* __sctp_stream_sched_h__ */

net/sctp/protocol.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,7 @@ static __init int sctp_init(void)
14991499
INIT_LIST_HEAD(&sctp_address_families);
15001500
sctp_v4_pf_init();
15011501
sctp_v6_pf_init();
1502+
sctp_sched_ops_init();
15021503

15031504
status = register_pernet_subsys(&sctp_defaults_ops);
15041505
if (status)

net/sctp/stream_sched.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,27 @@ static struct sctp_sched_ops sctp_sched_fcfs = {
119119
.unsched_all = sctp_sched_fcfs_unsched_all,
120120
};
121121

122+
static void sctp_sched_ops_fcfs_init(void)
123+
{
124+
sctp_sched_ops_register(SCTP_SS_FCFS, &sctp_sched_fcfs);
125+
}
126+
122127
/* API to other parts of the stack */
123128

124-
extern struct sctp_sched_ops sctp_sched_prio;
125-
extern struct sctp_sched_ops sctp_sched_rr;
129+
static struct sctp_sched_ops *sctp_sched_ops[SCTP_SS_MAX + 1];
126130

127-
static struct sctp_sched_ops *sctp_sched_ops[] = {
128-
&sctp_sched_fcfs,
129-
&sctp_sched_prio,
130-
&sctp_sched_rr,
131-
};
131+
void sctp_sched_ops_register(enum sctp_sched_type sched,
132+
struct sctp_sched_ops *sched_ops)
133+
{
134+
sctp_sched_ops[sched] = sched_ops;
135+
}
136+
137+
void sctp_sched_ops_init(void)
138+
{
139+
sctp_sched_ops_fcfs_init();
140+
sctp_sched_ops_prio_init();
141+
sctp_sched_ops_rr_init();
142+
}
132143

133144
int sctp_sched_set_sched(struct sctp_association *asoc,
134145
enum sctp_sched_type sched)

net/sctp/stream_sched_prio.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static void sctp_sched_prio_unsched_all(struct sctp_stream *stream)
333333
sctp_sched_prio_unsched(soute);
334334
}
335335

336-
struct sctp_sched_ops sctp_sched_prio = {
336+
static struct sctp_sched_ops sctp_sched_prio = {
337337
.set = sctp_sched_prio_set,
338338
.get = sctp_sched_prio_get,
339339
.init = sctp_sched_prio_init,
@@ -345,3 +345,8 @@ struct sctp_sched_ops sctp_sched_prio = {
345345
.sched_all = sctp_sched_prio_sched_all,
346346
.unsched_all = sctp_sched_prio_unsched_all,
347347
};
348+
349+
void sctp_sched_ops_prio_init(void)
350+
{
351+
sctp_sched_ops_register(SCTP_SS_PRIO, &sctp_sched_prio);
352+
}

net/sctp/stream_sched_rr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void sctp_sched_rr_unsched_all(struct sctp_stream *stream)
187187
sctp_sched_rr_unsched(stream, soute);
188188
}
189189

190-
struct sctp_sched_ops sctp_sched_rr = {
190+
static struct sctp_sched_ops sctp_sched_rr = {
191191
.set = sctp_sched_rr_set,
192192
.get = sctp_sched_rr_get,
193193
.init = sctp_sched_rr_init,
@@ -199,3 +199,8 @@ struct sctp_sched_ops sctp_sched_rr = {
199199
.sched_all = sctp_sched_rr_sched_all,
200200
.unsched_all = sctp_sched_rr_unsched_all,
201201
};
202+
203+
void sctp_sched_ops_rr_init(void)
204+
{
205+
sctp_sched_ops_register(SCTP_SS_RR, &sctp_sched_rr);
206+
}

0 commit comments

Comments
 (0)