ia64/linux-2.6.18-xen.hg

view net/sctp/ssnmap.c @ 871:9cbcc9008446

xen/x86: don't initialize cpu_data[]'s apicid field on generic code

Afaict, this is not only redundant with the intialization done in
drivers/xen/core/smpboot.c, but actually results - at least for
secondary CPUs - in the Xen-specific value written to be later
overwritten with whatever the generic code determines (with no
guarantee that the two values are identical).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 14 10:09:15 2009 +0100 (2009-05-14)
parents 831230e53067
children
line source
1 /* SCTP kernel reference Implementation
2 * Copyright (c) 2003 International Business Machines, Corp.
3 *
4 * This file is part of the SCTP kernel reference Implementation
5 *
6 * These functions manipulate sctp SSN tracker.
7 *
8 * The SCTP reference implementation is free software;
9 * you can redistribute it and/or modify it under the terms of
10 * the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * The SCTP reference implementation is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * ************************
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 * See the GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with GNU CC; see the file COPYING. If not, write to
22 * the Free Software Foundation, 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
24 *
25 * Please send any bug reports or fixes you make to the
26 * email address(es):
27 * lksctp developers <lksctp-developers@lists.sourceforge.net>
28 *
29 * Or submit a bug report through the following website:
30 * http://www.sf.net/projects/lksctp
31 *
32 * Written or modified by:
33 * Jon Grimm <jgrimm@us.ibm.com>
34 *
35 * Any bugs reported given to us we will try to fix... any fixes shared will
36 * be incorporated into the next SCTP release.
37 */
39 #include <linux/types.h>
40 #include <net/sctp/sctp.h>
41 #include <net/sctp/sm.h>
43 #define MAX_KMALLOC_SIZE 131072
45 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
46 __u16 out);
48 /* Storage size needed for map includes 2 headers and then the
49 * specific needs of in or out streams.
50 */
51 static inline size_t sctp_ssnmap_size(__u16 in, __u16 out)
52 {
53 return sizeof(struct sctp_ssnmap) + (in + out) * sizeof(__u16);
54 }
57 /* Create a new sctp_ssnmap.
58 * Allocate room to store at least 'len' contiguous TSNs.
59 */
60 struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
61 gfp_t gfp)
62 {
63 struct sctp_ssnmap *retval;
64 int size;
66 size = sctp_ssnmap_size(in, out);
67 if (size <= MAX_KMALLOC_SIZE)
68 retval = kmalloc(size, gfp);
69 else
70 retval = (struct sctp_ssnmap *)
71 __get_free_pages(gfp, get_order(size));
72 if (!retval)
73 goto fail;
75 if (!sctp_ssnmap_init(retval, in, out))
76 goto fail_map;
78 retval->malloced = 1;
79 SCTP_DBG_OBJCNT_INC(ssnmap);
81 return retval;
83 fail_map:
84 if (size <= MAX_KMALLOC_SIZE)
85 kfree(retval);
86 else
87 free_pages((unsigned long)retval, get_order(size));
88 fail:
89 return NULL;
90 }
93 /* Initialize a block of memory as a ssnmap. */
94 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
95 __u16 out)
96 {
97 memset(map, 0x00, sctp_ssnmap_size(in, out));
99 /* Start 'in' stream just after the map header. */
100 map->in.ssn = (__u16 *)&map[1];
101 map->in.len = in;
103 /* Start 'out' stream just after 'in'. */
104 map->out.ssn = &map->in.ssn[in];
105 map->out.len = out;
107 return map;
108 }
110 /* Clear out the ssnmap streams. */
111 void sctp_ssnmap_clear(struct sctp_ssnmap *map)
112 {
113 size_t size;
115 size = (map->in.len + map->out.len) * sizeof(__u16);
116 memset(map->in.ssn, 0x00, size);
117 }
119 /* Dispose of a ssnmap. */
120 void sctp_ssnmap_free(struct sctp_ssnmap *map)
121 {
122 if (map && map->malloced) {
123 int size;
125 size = sctp_ssnmap_size(map->in.len, map->out.len);
126 if (size <= MAX_KMALLOC_SIZE)
127 kfree(map);
128 else
129 free_pages((unsigned long)map, get_order(size));
130 SCTP_DBG_OBJCNT_DEC(ssnmap);
131 }
132 }