Skip to content

Commit be1f4f4

Browse files
david-laightdavem330
authored andcommitted
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>
1 parent 63ae889 commit be1f4f4

3 files changed

Lines changed: 24 additions & 73 deletions

File tree

‎include/net/sctp/command.h‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,38 @@ typedef struct {
210210
/* Initialize a block of memory as a command sequence.
211211
* Return 0 if the initialization fails.
212212
*/
213-
int sctp_init_cmd_seq(sctp_cmd_seq_t *seq);
213+
static 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+
214219

215220
/* Add a command to an sctp_cmd_seq_t.
216221
*
217222
* Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
218223
* to wrap data which goes in the obj argument.
219224
*/
220-
void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj);
225+
static 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+
}
221233

222234
/* Return the next command structure in an sctp_cmd_seq.
223235
* Return NULL at the end of the sequence.
224236
*/
225-
sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq);
237+
static inline sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
238+
{
239+
sctp_cmd_t *retval = NULL;
226240

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+
}
228246

247+
#endif /* __net_sctp_command_h__ */

‎net/sctp/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_NET_SCTPPROBE) += sctp_probe.o
88
sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
99
protocol.o endpointola.o associola.o \
1010
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 \
1212
tsnmap.o bind_addr.o socket.o primitive.o \
1313
output.o input.o debug.o ssnmap.o auth.o
1414

‎net/sctp/command.c‎

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)