Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/ib/clients/rds/rds_opt.c
+++ new/usr/src/uts/common/io/ib/clients/rds/rds_opt.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
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 /*
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
22 22 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 1990 Mentat Inc.
24 24 */
25 25
26 26 #include <sys/ib/clients/rds/rds.h>
27 27 #include <inet/proto_set.h>
28 28
29 29 #define rds_max_buf 2097152
30 30 opdes_t rds_opt_arr[] = {
31 31
32 -{ SO_TYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), 0 },
33 -{ SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
34 -{ SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
32 +{ SO_TYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, 0, sizeof (int), {0} },
33 +{ SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), {0} },
34 +{ SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, 0, sizeof (int), {0} },
35 35 };
36 36
37 37 /* ARGSUSED */
38 38 int
39 39 rds_opt_default(queue_t *q, t_scalar_t level, t_scalar_t name, uchar_t *ptr)
40 40 {
41 41 /* no default value processed by protocol specific code currently */
42 42 return (-1);
43 43 }
44 44
45 45 /*
46 46 * This routine retrieves the current status of socket options.
47 47 * It returns the size of the option retrieved.
48 48 */
49 49 int
50 50 rds_opt_get(queue_t *q, t_scalar_t level, t_scalar_t name, uchar_t *ptr)
51 51 {
52 52 int *i1 = (int *)(uintptr_t)ptr;
53 53
54 54 switch (level) {
55 55 case SOL_SOCKET:
56 56 switch (name) {
57 57 case SO_TYPE:
58 58 *i1 = SOCK_DGRAM;
59 59 break; /* goto sizeof (int) option return */
60 60
61 61 case SO_SNDBUF:
62 62 *i1 = q->q_hiwat;
63 63 break; /* goto sizeof (int) option return */
64 64 case SO_RCVBUF:
65 65 *i1 = RD(q)->q_hiwat;
66 66 break; /* goto sizeof (int) option return */
67 67 default:
68 68 return (-1);
69 69 }
70 70 break;
71 71 default:
72 72 return (-1);
73 73 }
74 74 return (sizeof (int));
75 75 }
76 76
77 77 /* This routine sets socket options. */
78 78 /* ARGSUSED */
79 79 int
80 80 rds_opt_set(queue_t *q, uint_t optset_context, int level,
81 81 int name, uint_t inlen, uchar_t *invalp, uint_t *outlenp,
82 82 uchar_t *outvalp, void *thisdg_attrs, cred_t *cr)
83 83 {
84 84 int *i1 = (int *)(uintptr_t)invalp;
85 85 boolean_t checkonly;
86 86
87 87 switch (optset_context) {
88 88 case SETFN_OPTCOM_CHECKONLY:
89 89 checkonly = B_TRUE;
90 90 /*
91 91 * Note: Implies T_CHECK semantics for T_OPTCOM_REQ
92 92 * inlen != 0 implies value supplied and
93 93 * we have to "pretend" to set it.
94 94 * inlen == 0 implies that there is no
95 95 * value part in T_CHECK request and just validation
96 96 * done elsewhere should be enough, we just return here.
97 97 */
98 98 if (inlen == 0) {
99 99 *outlenp = 0;
100 100 return (0);
101 101 }
102 102 break;
103 103 case SETFN_OPTCOM_NEGOTIATE:
104 104 checkonly = B_FALSE;
105 105 break;
106 106 default:
107 107 /*
108 108 * We should never get here
109 109 */
110 110 *outlenp = 0;
111 111 return (EINVAL);
112 112 }
113 113
114 114 ASSERT((optset_context != SETFN_OPTCOM_CHECKONLY) ||
115 115 (optset_context == SETFN_OPTCOM_CHECKONLY && inlen != 0));
116 116
117 117 /*
118 118 * For fixed length options, no sanity check
119 119 * of passed in length is done. It is assumed *_optcom_req()
120 120 * routines do the right thing.
121 121 */
122 122
123 123 switch (level) {
124 124 case SOL_SOCKET:
125 125 switch (name) {
126 126
127 127 case SO_SNDBUF:
128 128 if (*i1 > rds_max_buf) {
129 129 *outlenp = 0;
130 130 return (ENOBUFS);
131 131 }
132 132 if (!checkonly) {
133 133 q->q_hiwat = *i1;
134 134 }
135 135 break;
136 136 case SO_RCVBUF:
137 137 if (*i1 > rds_max_buf) {
138 138 *outlenp = 0;
139 139 return (ENOBUFS);
140 140 }
141 141 if (!checkonly) {
142 142 RD(q)->q_hiwat = *i1;
143 143 (void) proto_set_rx_hiwat(RD(q), NULL, *i1);
144 144 }
145 145 break;
146 146 default:
147 147 *outlenp = 0;
148 148 return (EINVAL);
149 149 }
150 150 break;
151 151 default:
152 152 *outlenp = 0;
153 153 return (EINVAL);
154 154 }
155 155 /*
156 156 * Common case of OK return with outval same as inval.
157 157 */
158 158 if (invalp != outvalp) {
159 159 /* don't trust bcopy for identical src/dst */
160 160 (void) bcopy(invalp, outvalp, inlen);
161 161 }
162 162 *outlenp = inlen;
163 163 return (0);
164 164 }
165 165
166 166 uint_t rds_max_optsize; /* initialized when RDS driver is loaded */
167 167
168 168 #define RDS_VALID_LEVELS_CNT A_CNT(rds_valid_levels_arr)
169 169
170 170 #define RDS_OPT_ARR_CNT A_CNT(rds_opt_arr)
171 171
172 172
173 173 optlevel_t rds_valid_levels_arr[] = {
174 174 SOL_SOCKET,
175 175 };
176 176
177 177 /*
178 178 * Initialize option database object for RDS
179 179 *
180 180 * This object represents database of options to search passed to
181 181 * {sock,tpi}optcom_req() interface routine to take care of option
182 182 * management and associated methods.
183 183 */
184 184
185 185 optdb_obj_t rds_opt_obj = {
186 186 rds_opt_default, /* RDS default value function pointer */
187 187 rds_opt_get, /* RDS get function pointer */
188 188 rds_opt_set, /* RDS set function pointer */
189 189 RDS_OPT_ARR_CNT, /* RDS option database count of entries */
190 190 rds_opt_arr, /* RDS option database */
191 191 RDS_VALID_LEVELS_CNT, /* RDS valid level count of entries */
192 192 rds_valid_levels_arr /* RDS valid level array */
193 193 };
↓ open down ↓ |
149 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX