aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Laight <David.Laight@ACULAB.COM>2014-07-04 10:35:51 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-08 17:38:48 -0400
commitbe1f4f48cef17c6ea9350db04c774dc8eb252158 (patch)
tree64352a351a16a0ff3eb9bdbe850f68868d5dd263
parent63ae88949bc7f6b56438d430c55060d9eda981af (diff)
net: sctp: Inline the functions from command.c
sctp_init_cmd_seq() and sctp_next_cmd() are only called from one place. The call sequence for sctp_add_cmd_sf() is likely to be longer than the inlined code. With sctp_add_cmd_sf() inlined the compiler can optimise repeated calls. Signed-off-by: David Laight <david.laight@aculab.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sctp/command.h27
-rw-r--r--net/sctp/Makefile2
-rw-r--r--net/sctp/command.c68
3 files changed, 24 insertions, 73 deletions
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 4b7cd695e431..0e91a42065db 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -210,19 +210,38 @@ typedef struct {
210/* Initialize a block of memory as a command sequence. 210/* Initialize a block of memory as a command sequence.
211 * Return 0 if the initialization fails. 211 * Return 0 if the initialization fails.
212 */ 212 */
213int sctp_init_cmd_seq(sctp_cmd_seq_t *seq); 213static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
214{
215 memset(seq, 0, sizeof(sctp_cmd_seq_t));
216 return 1; /* We always succeed. */
217}
218
214 219
215/* Add a command to an sctp_cmd_seq_t. 220/* Add a command to an sctp_cmd_seq_t.
216 * 221 *
217 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above 222 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
218 * to wrap data which goes in the obj argument. 223 * to wrap data which goes in the obj argument.
219 */ 224 */
220void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj); 225static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb,
226 sctp_arg_t obj)
227{
228 BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS);
229
230 seq->cmds[seq->next_free_slot].verb = verb;
231 seq->cmds[seq->next_free_slot++].obj = obj;
232}
221 233
222/* Return the next command structure in an sctp_cmd_seq. 234/* Return the next command structure in an sctp_cmd_seq.
223 * Return NULL at the end of the sequence. 235 * Return NULL at the end of the sequence.
224 */ 236 */
225sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq); 237static inline sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
238{
239 sctp_cmd_t *retval = NULL;
226 240
227#endif /* __net_sctp_command_h__ */ 241 if (seq->next_cmd < seq->next_free_slot)
242 retval = &seq->cmds[seq->next_cmd++];
243
244 return retval;
245}
228 246
247#endif /* __net_sctp_command_h__ */
diff --git a/net/sctp/Makefile b/net/sctp/Makefile
index 5c30b7a873df..3b4ffb021cf1 100644
--- a/net/sctp/Makefile
+++ b/net/sctp/Makefile
@@ -8,7 +8,7 @@ obj-$(CONFIG_NET_SCTPPROBE) += sctp_probe.o
8sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \ 8sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
9 protocol.o endpointola.o associola.o \ 9 protocol.o endpointola.o associola.o \
10 transport.o chunk.o sm_make_chunk.o ulpevent.o \ 10 transport.o chunk.o sm_make_chunk.o ulpevent.o \
11 inqueue.o outqueue.o ulpqueue.o command.o \ 11 inqueue.o outqueue.o ulpqueue.o \
12 tsnmap.o bind_addr.o socket.o primitive.o \ 12 tsnmap.o bind_addr.o socket.o primitive.o \
13 output.o input.o debug.o ssnmap.o auth.o 13 output.o input.o debug.o ssnmap.o auth.o
14 14
diff --git a/net/sctp/command.c b/net/sctp/command.c
deleted file mode 100644
index dd7375851618..000000000000
--- a/net/sctp/command.c
+++ /dev/null
@@ -1,68 +0,0 @@
1/* SCTP kernel implementation Copyright (C) 1999-2001
2 * Cisco, Motorola, and IBM
3 * Copyright 2001 La Monte H.P. Yarroll
4 *
5 * This file is part of the SCTP kernel implementation
6 *
7 * These functions manipulate sctp command sequences.
8 *
9 * This SCTP implementation is free software;
10 * you can redistribute it and/or modify it under the terms of
11 * the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This SCTP implementation is distributed in the hope that it
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * ************************
18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GNU CC; see the file COPYING. If not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 * Please send any bug reports or fixes you make to the
26 * email address(es):
27 * lksctp developers <linux-sctp@vger.kernel.org>
28 *
29 * Written or modified by:
30 * La Monte H.P. Yarroll <piggy@acm.org>
31 * Karl Knutson <karl@athena.chicago.il.us>
32 */
33
34#include <linux/types.h>
35#include <net/sctp/sctp.h>
36#include <net/sctp/sm.h>
37
38/* Initialize a block of memory as a command sequence. */
39int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
40{
41 memset(seq, 0, sizeof(sctp_cmd_seq_t));
42 return 1; /* We always succeed. */
43}
44
45/* Add a command to a sctp_cmd_seq_t.
46 * Return 0 if the command sequence is full.
47 */
48void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
49{
50 BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS);
51
52 seq->cmds[seq->next_free_slot].verb = verb;
53 seq->cmds[seq->next_free_slot++].obj = obj;
54}
55
56/* Return the next command structure in a sctp_cmd_seq.
57 * Returns NULL at the end of the sequence.
58 */
59sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
60{
61 sctp_cmd_t *retval = NULL;
62
63 if (seq->next_cmd < seq->next_free_slot)
64 retval = &seq->cmds[seq->next_cmd++];
65
66 return retval;
67}
68