Print this page
8654 unused local typedef in rpc code
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/rpc/xdrrdma_sizeof.c
+++ new/usr/src/uts/common/rpc/xdrrdma_sizeof.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + *
25 + * Copyright 2017 RackTop Systems.
24 26 */
25 27
26 28 #include <rpc/types.h>
27 29 #include <rpc/xdr.h>
28 30 #include <sys/types.h>
29 31 #include <sys/sdt.h>
30 32 #include <rpc/auth.h>
31 33 #include <rpc/rpc_rdma.h>
32 34
33 35 struct private {
34 36 int min_chunk;
35 37 uint_t flags; /* controls setting for rdma xdr */
36 38 int num_chunk;
37 39 caddr_t inline_buf; /* temporary buffer for xdr inlining */
38 40 int inline_len; /* inline buffer length */
39 41 uint_t xp_reply_chunk_len;
40 42 uint_t xp_reply_chunk_len_alt;
41 43 };
42 44
43 45 /* ARGSUSED */
44 46 static bool_t
45 47 x_putint32_t(XDR *xdrs, int32_t *ip)
46 48 {
47 49 xdrs->x_handy += BYTES_PER_XDR_UNIT;
48 50 return (TRUE);
49 51 }
50 52
51 53 /* ARGSUSED */
52 54 static bool_t
53 55 x_putbytes(XDR *xdrs, char *bp, int len)
54 56 {
55 57 struct private *xdrp = (struct private *)xdrs->x_private;
56 58
57 59 /*
58 60 * min_chunk = 0, means that the stream of bytes, to estimate size of,
59 61 * contains no chunks to seperate out. See xdrrdma_putbytes()
60 62 */
61 63 if (len < xdrp->min_chunk || !(xdrp->flags & XDR_RDMA_CHUNK)) {
62 64 xdrs->x_handy += len;
63 65 return (TRUE);
64 66 }
65 67 /*
66 68 * Chunk item. No impact on xdr size.
67 69 */
68 70 xdrp->num_chunk++;
69 71
70 72 return (TRUE);
71 73 }
72 74
73 75 static uint_t
74 76 x_getpostn(XDR *xdrs)
75 77 {
76 78 return (xdrs->x_handy);
77 79 }
78 80
79 81 /* ARGSUSED */
80 82 static bool_t
81 83 x_setpostn(XDR *xdrs, uint_t pos)
82 84 {
83 85 /* This is not allowed */
84 86 return (FALSE);
85 87 }
86 88
87 89 /* ARGSUSED */
88 90 static bool_t
89 91 x_control(XDR *xdrs, int request, void *info)
90 92 {
91 93 int32_t *int32p;
92 94 uint_t in_flags;
93 95 rdma_chunkinfo_t *rcip = NULL;
94 96 rdma_chunkinfo_lengths_t *rcilp = NULL;
95 97 struct private *xdrp = (struct private *)xdrs->x_private;
96 98
97 99 switch (request) {
98 100 case XDR_RDMA_SET_FLAGS:
99 101 /*
100 102 * Set the flags provided in the *info in xp_flags for rdma xdr
101 103 * stream control.
102 104 */
103 105 int32p = (int32_t *)info;
104 106 in_flags = (uint_t)(*int32p);
105 107
106 108 xdrp->flags = in_flags;
107 109 return (TRUE);
108 110
109 111 case XDR_RDMA_GET_FLAGS:
110 112 /*
111 113 * Get the flags provided in xp_flags return through *info
112 114 */
113 115 int32p = (int32_t *)info;
114 116
115 117 *int32p = (int32_t)xdrp->flags;
116 118 return (TRUE);
117 119
118 120 case XDR_RDMA_GET_CHUNK_LEN:
119 121 rcilp = (rdma_chunkinfo_lengths_t *)info;
120 122 rcilp->rcil_len = xdrp->xp_reply_chunk_len;
121 123 rcilp->rcil_len_alt = xdrp->xp_reply_chunk_len_alt;
122 124
123 125 return (TRUE);
124 126
125 127 case XDR_RDMA_ADD_CHUNK:
126 128 rcip = (rdma_chunkinfo_t *)info;
127 129
128 130 switch (rcip->rci_type) {
129 131 case RCI_WRITE_UIO_CHUNK:
130 132 xdrp->xp_reply_chunk_len_alt += rcip->rci_len;
131 133 break;
132 134
133 135 case RCI_WRITE_ADDR_CHUNK:
134 136 xdrp->xp_reply_chunk_len_alt += rcip->rci_len;
135 137 break;
136 138
137 139 case RCI_REPLY_CHUNK:
138 140 xdrp->xp_reply_chunk_len += rcip->rci_len;
139 141 break;
140 142 }
141 143 return (TRUE);
142 144
143 145 default:
144 146 return (FALSE);
145 147 }
146 148 }
147 149
148 150 /* ARGSUSED */
149 151 static rpc_inline_t *
150 152 x_inline(XDR *xdrs, int len)
151 153 {
152 154 struct private *xdrp = (struct private *)xdrs->x_private;
153 155
154 156 if (len == 0) {
155 157 return (NULL);
156 158 }
157 159 if (xdrs->x_op != XDR_ENCODE) {
158 160 return (NULL);
159 161 }
160 162 if (len >= xdrp->min_chunk) {
161 163 return (NULL);
162 164 }
163 165 if (len <= xdrp->inline_len) {
164 166 /* inline_buf was already allocated, just reuse it */
165 167 xdrs->x_handy += len;
166 168 return ((rpc_inline_t *)xdrp->inline_buf);
167 169 } else {
168 170 /* Free the earlier space and allocate new area */
169 171 if (xdrp->inline_buf)
170 172 mem_free(xdrp->inline_buf, xdrp->inline_len);
171 173 if ((xdrp->inline_buf = (caddr_t)mem_alloc(len)) == NULL) {
172 174 xdrp->inline_len = 0;
173 175 return (NULL);
174 176 }
175 177 xdrp->inline_len = len;
176 178 xdrs->x_handy += len;
177 179 return ((rpc_inline_t *)xdrp->inline_buf);
178 180 }
179 181 }
180 182
181 183 static int
182 184 harmless()
183 185 {
184 186 /* Always return FALSE/NULL, as the case may be */
185 187 return (0);
186 188 }
187 189
188 190 static void
189 191 x_destroy(XDR *xdrs)
190 192 {
191 193 struct private *xdrp = (struct private *)xdrs->x_private;
192 194
193 195 xdrs->x_handy = 0;
194 196 if (xdrp) {
195 197 if (xdrp->inline_buf)
196 198 mem_free(xdrp->inline_buf, xdrp->inline_len);
197 199 mem_free(xdrp, sizeof (struct private));
198 200 xdrs->x_private = NULL;
199 201 }
200 202 xdrs->x_base = 0;
201 203 }
202 204
203 205 static bool_t
204 206 xdrrdma_common(XDR *xdrs, int min_chunk)
205 207 {
206 208 struct private *xdrp;
207 209
208 210 xdrs->x_ops = xdrrdma_xops();
209 211 xdrs->x_op = XDR_ENCODE;
210 212 xdrs->x_handy = 0;
211 213 xdrs->x_base = NULL;
212 214 xdrs->x_private = kmem_zalloc(sizeof (struct private), KM_SLEEP);
213 215 xdrp = (struct private *)xdrs->x_private;
214 216 xdrp->min_chunk = min_chunk;
215 217 xdrp->flags = 0;
216 218 if (xdrp->min_chunk != 0)
217 219 xdrp->flags |= XDR_RDMA_CHUNK;
218 220
219 221 xdrp->xp_reply_chunk_len = 0;
220 222 xdrp->xp_reply_chunk_len_alt = 0;
221 223
222 224 return (TRUE);
223 225 }
224 226
225 227 unsigned int
226 228 xdrrdma_sizeof(xdrproc_t func, void *data, int min_chunk,
227 229 uint_t *reply_size, uint_t *reply_size_alt)
228 230 {
229 231 XDR x;
230 232 struct xdr_ops ops;
231 233 bool_t stat;
232 234 struct private *xdrp;
233 235
234 236 x.x_ops = &ops;
235 237 (void) xdrrdma_common(&x, min_chunk);
236 238
237 239 stat = func(&x, data);
238 240 xdrp = (struct private *)x.x_private;
239 241 if (xdrp) {
240 242 if (reply_size != NULL)
241 243 *reply_size = xdrp->xp_reply_chunk_len;
242 244 if (reply_size_alt != NULL)
243 245 *reply_size_alt = xdrp->xp_reply_chunk_len_alt;
244 246 if (xdrp->inline_buf)
245 247 mem_free(xdrp->inline_buf, xdrp->inline_len);
246 248 mem_free(xdrp, sizeof (struct private));
247 249 }
248 250 return (stat == TRUE ? (unsigned int)x.x_handy: 0);
249 251 }
250 252
251 253 unsigned int
252 254 xdrrdma_authsize(AUTH *auth, struct cred *cred, int min_chunk)
253 255 {
254 256 XDR x;
255 257 struct xdr_ops ops;
256 258 bool_t stat;
257 259 struct private *xdrp;
258 260
259 261 x.x_ops = &ops;
260 262 (void) xdrrdma_common(&x, min_chunk);
261 263
262 264 stat = AUTH_MARSHALL(auth, &x, cred);
263 265 xdrp = (struct private *)x.x_private;
264 266 if (xdrp) {
265 267 if (xdrp->inline_buf)
266 268 mem_free(xdrp->inline_buf, xdrp->inline_len);
267 269 mem_free(xdrp, sizeof (struct private));
↓ open down ↓ |
234 lines elided |
↑ open up ↑ |
268 270 }
269 271 return (stat == TRUE ? (unsigned int)x.x_handy: 0);
270 272 }
271 273
272 274 struct xdr_ops *
273 275 xdrrdma_xops(void)
274 276 {
275 277 static struct xdr_ops ops;
276 278
277 279 /* to stop ANSI-C compiler from complaining */
278 - typedef bool_t (* dummyfunc1)(XDR *, long *);
279 - typedef bool_t (* dummyfunc2)(XDR *, caddr_t, int);
280 - typedef bool_t (* dummyfunc3)(XDR *, int32_t *);
280 + typedef bool_t (* dummyfunc1)(XDR *, caddr_t, int);
281 +#if defined(_LP64) || defined(_KERNEL)
282 + typedef bool_t (* dummyfunc2)(XDR *, int32_t *);
283 +#endif
281 284
282 285 ops.x_putbytes = x_putbytes;
283 286 ops.x_inline = x_inline;
284 287 ops.x_getpostn = x_getpostn;
285 288 ops.x_setpostn = x_setpostn;
286 289 ops.x_destroy = x_destroy;
287 290 ops.x_control = x_control;
288 291
289 292 #if defined(_LP64) || defined(_KERNEL)
290 - ops.x_getint32 = (dummyfunc3)harmless;
293 + ops.x_getint32 = (dummyfunc2)harmless;
291 294 ops.x_putint32 = x_putint32_t;
292 295 #endif
293 296
294 297 /* the other harmless ones */
295 - ops.x_getbytes = (dummyfunc2)harmless;
298 + ops.x_getbytes = (dummyfunc1)harmless;
296 299
297 300 return (&ops);
298 301 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX