Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/ppp/sppp/sppp_mod.c
+++ new/usr/src/uts/common/io/ppp/sppp/sppp_mod.c
1 1 /*
2 2 * sppp_mod.c - modload support for PPP pseudo-device driver.
3 3 *
4 4 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5 5 * Use is subject to license terms.
6 6 *
7 7 * Permission to use, copy, modify, and distribute this software and its
8 8 * documentation is hereby granted, provided that the above copyright
9 9 * notice appears in all copies.
10 10 *
11 11 * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
12 12 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13 13 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 14 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
15 15 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
16 16 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
17 17 *
18 18 * Copyright (c) 1994 The Australian National University.
19 19 * All rights reserved.
20 20 *
21 21 * Permission to use, copy, modify, and distribute this software and its
22 22 * documentation is hereby granted, provided that the above copyright
23 23 * notice appears in all copies. This software is provided without any
24 24 * warranty, express or implied. The Australian National University
25 25 * makes no representations about the suitability of this software for
26 26 * any purpose.
27 27 *
28 28 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
29 29 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
30 30 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
31 31 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
32 32 * OF SUCH DAMAGE.
33 33 *
34 34 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
35 35 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
36 36 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
37 37 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
38 38 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
39 39 * OR MODIFICATIONS.
40 40 *
41 41 * This driver is derived from the original SVR4 STREAMS PPP driver
42 42 * originally written by Paul Mackerras <paul.mackerras@cs.anu.edu.au>.
43 43 *
44 44 * Adi Masputra <adi.masputra@sun.com> rewrote and restructured the code
45 45 * for improved performance and scalability.
46 46 */
47 47
48 48 #define RCSID " $Id: sppp_mod.c,v 1.0 2000/05/08 10:53:28 masputra Exp $"
49 49
50 50 #include <sys/types.h>
51 51 #include <sys/systm.h>
52 52 #include <sys/ddi.h>
53 53 #include <sys/conf.h>
54 54 #include <sys/sunddi.h>
55 55 #include <sys/stat.h>
56 56 #include <sys/kstat.h>
57 57 #include <net/pppio.h>
58 58 #include <sys/modctl.h>
59 59
60 60 #include "s_common.h"
61 61 #include "sppp.h"
62 62
63 63 static int _mi_driver_attach(dev_info_t *, ddi_attach_cmd_t);
64 64 static int _mi_driver_detach(dev_info_t *, ddi_detach_cmd_t);
65 65 static int _mi_driver_info(dev_info_t *, ddi_info_cmd_t, void *, void **);
66 66
67 67 /*
68 68 * Globals for PPP multiplexer module wrapper
69 69 */
70 70 extern const char sppp_module_description[];
71 71 static dev_info_t *_mi_dip;
72 72
73 73 #define PPP_MI_HIWAT (PPP_MTU * 16) /* XXX find more meaningful value */
74 74 #define PPP_MI_LOWAT (PPP_MTU * 14) /* XXX find more meaningful value */
75 75
76 76 static struct module_info sppp_modinfo = {
77 77 PPP_MOD_ID, /* mi_idnum */
78 78 PPP_DRV_NAME, /* mi_idname */
79 79 0, /* mi_minpsz */
80 80 PPP_MAXMTU, /* mi_maxpsz */
81 81 PPP_MI_HIWAT, /* mi_hiwat */
82 82 PPP_MI_LOWAT /* mi_lowat */
83 83 };
84 84
85 85 static struct qinit sppp_urinit = {
86 86 NULL, /* qi_putp */
87 87 NULL, /* qi_srvp */
88 88 sppp_open, /* qi_qopen */
89 89 sppp_close, /* qi_qclose */
90 90 NULL, /* qi_qadmin */
91 91 &sppp_modinfo, /* qi_minfo */
92 92 NULL /* qi_mstat */
93 93 };
94 94
95 95 static struct qinit sppp_uwinit = {
96 96 (int (*)())sppp_uwput, /* qi_putp */
97 97 (int (*)())sppp_uwsrv, /* qi_srvp */
98 98 NULL, /* qi_qopen */
99 99 NULL, /* qi_qclose */
100 100 NULL, /* qi_qadmin */
101 101 &sppp_modinfo, /* qi_minfo */
102 102 NULL /* qi_mstat */
103 103 };
104 104
105 105 static struct qinit sppp_lrinit = {
106 106 (int (*)())sppp_lrput, /* qi_putp */
107 107 (int (*)())sppp_lrsrv, /* qi_srvp */
108 108 NULL, /* qi_qopen */
109 109 NULL, /* qi_qclose */
110 110 NULL, /* qi_qadmin */
111 111 &sppp_modinfo, /* qi_minfo */
112 112 NULL /* qi_mstat */
113 113 };
114 114
115 115 static struct qinit sppp_lwinit = {
116 116 NULL, /* qi_putp */
117 117 (int (*)())sppp_lwsrv, /* qi_srvp */
118 118 NULL, /* qi_qopen */
119 119 NULL, /* qi_qclose */
120 120 NULL, /* qi_qadmin */
121 121 &sppp_modinfo, /* qi_minfo */
122 122 NULL /* qi_mstat */
123 123 };
124 124
125 125 static struct streamtab sppp_tab = {
126 126 &sppp_urinit, /* st_rdinit */
127 127 &sppp_uwinit, /* st_wrinit */
128 128 &sppp_lrinit, /* st_muxrinit */
129 129 &sppp_lwinit /* st_muxwrinit */
130 130 };
131 131
132 132 /*
133 133 * Descriptions for flags values in cb_flags field:
134 134 *
135 135 * D_MTQPAIR:
136 136 * An inner perimeter that spans the queue pair.
137 137 * D_MTOUTPERIM:
138 138 * An outer perimeter that spans over all queues in the module.
139 139 * D_MTOCEXCL:
140 140 * Open & close procedures are entered exclusively at outer perimeter.
141 141 * D_MTPUTSHARED:
142 142 * Entry to put procedures are done with SHARED (reader) acess
143 143 * and not EXCLUSIVE (writer) access.
144 144 *
145 145 * Therefore:
146 146 *
147 147 * 1. Open and close procedures are entered with EXCLUSIVE (writer)
148 148 * access at the inner perimeter, and with EXCLUSIVE (writer) access at
149 149 * the outer perimeter.
150 150 *
151 151 * 2. Put procedures are entered with SHARED (reader) access at the inner
152 152 * perimeter, and with SHARED (reader) access at the outer perimeter.
153 153 *
154 154 * 3. Service procedures are entered with EXCLUSIVE (writer) access at
155 155 * the inner perimeter, and with SHARED (reader) access at the
156 156 * outer perimeter.
157 157 *
158 158 * Do not attempt to modify these flags unless the entire corresponding
159 159 * driver code is changed to accomodate the newly represented MT-STREAMS
160 160 * flags. Doing so without making proper modifications to the driver code
161 161 * will severely impact the intended driver behavior, and thus may affect
162 162 * the system's stability and performance.
163 163 */
164 164 DDI_DEFINE_STREAM_OPS(sppp_ops, \
165 165 nulldev, nulldev, \
166 166 _mi_driver_attach, _mi_driver_detach, nodev, _mi_driver_info, \
167 167 D_NEW | D_MP | D_MTQPAIR | D_MTOUTPERIM | D_MTOCEXCL | D_MTPUTSHARED, \
↓ open down ↓ |
167 lines elided |
↑ open up ↑ |
168 168 &sppp_tab, ddi_quiesce_not_supported);
169 169
170 170 static struct modldrv modldrv = {
171 171 &mod_driverops, /* drv_modops */
172 172 (char *)sppp_module_description, /* drv_linkinfo */
173 173 &sppp_ops /* drv_dev_ops */
174 174 };
175 175
176 176 static struct modlinkage modlinkage = {
177 177 MODREV_1, /* ml_rev, has to be MODREV_1 */
178 - &modldrv, /* ml_linkage, NULL-terminated list */
179 - NULL /* of linkage structures */
178 + { &modldrv, NULL } /* ml_linkage, NULL-terminated list */
180 179 };
181 180
182 181 int
183 182 _init(void)
184 183 {
185 184 return (mod_install(&modlinkage));
186 185 }
187 186
188 187 int
189 188 _fini(void)
190 189 {
191 190 return (mod_remove(&modlinkage));
192 191 }
193 192
194 193 int
195 194 _info(struct modinfo *modinfop)
196 195 {
197 196 return (mod_info(&modlinkage, modinfop));
198 197 }
199 198
200 199 /*
201 200 * _mi_driver_attach()
202 201 *
203 202 * Description:
204 203 * Attach a point-to-point interface to the system.
205 204 */
206 205 static int
207 206 _mi_driver_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
208 207 {
209 208 if (cmd != DDI_ATTACH) {
210 209 return (DDI_FAILURE);
211 210 }
212 211 _mi_dip = dip;
213 212 if (ddi_create_minor_node(dip, PPP_DRV_NAME, S_IFCHR,
214 213 0, DDI_PSEUDO, CLONE_DEV) == DDI_FAILURE) {
215 214 ddi_remove_minor_node(dip, NULL);
216 215 return (DDI_FAILURE);
217 216 }
218 217 sppp_dlpi_pinfoinit();
219 218 return (DDI_SUCCESS);
220 219 }
221 220
222 221 /*
223 222 * _mi_driver_detach()
224 223 *
225 224 * Description:
226 225 * Detach an interface to the system.
227 226 */
228 227 static int
229 228 _mi_driver_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
230 229 {
231 230 if (cmd != DDI_DETACH) {
232 231 return (DDI_FAILURE);
233 232 }
234 233 ddi_remove_minor_node(dip, NULL);
235 234 _mi_dip = NULL;
236 235 return (DDI_SUCCESS);
237 236 }
238 237
239 238 /*
240 239 * _mi_driver_info()
241 240 *
242 241 * Description:
243 242 * Translate "dev_t" to a pointer to the associated "dev_info_t".
244 243 */
245 244 /* ARGSUSED */
246 245 static int
247 246 _mi_driver_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
248 247 void **result)
249 248 {
250 249 int rc;
251 250
252 251 switch (infocmd) {
253 252 case DDI_INFO_DEVT2DEVINFO:
254 253 if (_mi_dip == NULL) {
255 254 rc = DDI_FAILURE;
256 255 } else {
257 256 *result = (void *)_mi_dip;
258 257 rc = DDI_SUCCESS;
259 258 }
260 259 break;
261 260 case DDI_INFO_DEVT2INSTANCE:
262 261 *result = NULL;
263 262 rc = DDI_SUCCESS;
264 263 break;
265 264 default:
266 265 rc = DDI_FAILURE;
267 266 break;
268 267 }
269 268 return (rc);
270 269 }
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX