xref: /titanic_44/usr/src/uts/common/avs/ncall/ncall_stub.c (revision 2d6b5ea734bb47d251c82670646fde46af15fd69)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/types.h>
27 #include <sys/errno.h>
28 #include <sys/ddi.h>
29 #include <sys/sunddi.h>
30 
31 #include <sys/varargs.h>
32 #ifdef DS_DDICT
33 #include <sys/nsctl/contract.h>
34 #endif
35 #include "ncall.h"
36 #include "ncall_module.h"
37 
38 static ncall_node_t nodeinfo;
39 
40 
41 /* ARGSUSED */
42 void
43 ncall_stub_register_svc(int svc_id, void (*func)(ncall_t *, int *))
44 {
45 	;
46 }
47 
48 /* ARGSUSED */
49 void
50 ncall_stub_unregister_svc(int svc_id)
51 {
52 	;
53 }
54 
55 /* ARGSUSED */
56 int
57 ncall_stub_nodeid(char *nodename)
58 {
59 	return (nodeinfo.nc_nodeid);
60 }
61 
62 /* ARGSUSED */
63 char *
64 ncall_stub_nodename(int nodeid)
65 {
66 	if (nodeid == nodeinfo.nc_nodeid)
67 		return (nodeinfo.nc_nodename);
68 	else
69 		return ("");
70 }
71 
72 /* ARGSUSED */
73 int
74 ncall_stub_mirror(int nodeid)
75 {
76 	return (-1);
77 }
78 
79 /* ARGSUSED */
80 int
81 ncall_stub_self(void)
82 {
83 	return (nodeinfo.nc_nodeid);
84 }
85 
86 /* ARGSUSED */
87 int
88 ncall_stub_alloc(int host_id, int flags, int net, ncall_t **ncall_p)
89 {
90 	return (ENOLINK);
91 }
92 
93 /* ARGSUSED */
94 int
95 ncall_stub_timedsend(ncall_t *ncall, int flags, int svc_id,
96     struct timeval *t, va_list ap)
97 {
98 	return (ENOLINK);
99 }
100 
101 /* ARGSUSED */
102 int
103 ncall_stub_timedsendnotify(ncall_t *ncall, int flags, int svc_id,
104     struct timeval *t, void (*ncall_callback)(ncall_t *, void *), void *vptr,
105     va_list ap)
106 {
107 	return (ENOLINK);
108 }
109 
110 /* ARGSUSED */
111 int
112 ncall_stub_broadcast(ncall_t *ncall, int flags, int svc_id,
113     struct timeval *t, va_list ap)
114 {
115 	return (ENOLINK);
116 }
117 
118 /* ARGSUSED */
119 int
120 ncall_stub_read_reply(ncall_t *ncall, int n, va_list ap)
121 {
122 	return (ENOLINK);
123 }
124 
125 /* ARGSUSED */
126 void
127 ncall_stub_reset(ncall_t *ncall)
128 {
129 	;
130 }
131 
132 /* ARGSUSED */
133 void
134 ncall_stub_free(ncall_t *ncall)
135 {
136 	;
137 }
138 
139 /* ARGSUSED */
140 int
141 ncall_stub_put_data(ncall_t *ncall, void *data, int len)
142 {
143 	return (ENOLINK);
144 }
145 
146 /* ARGSUSED */
147 int
148 ncall_stub_get_data(ncall_t *ncall, void *data, int len)
149 {
150 	return (ENOLINK);
151 }
152 
153 /* ARGSUSED */
154 int
155 ncall_stub_sender(ncall_t *ncall)
156 {
157 	return (nodeinfo.nc_nodeid);
158 }
159 
160 /* ARGSUSED */
161 void
162 ncall_stub_reply(ncall_t *ncall, va_list ap)
163 {
164 	;
165 }
166 
167 /* ARGSUSED */
168 void
169 ncall_stub_pend(ncall_t *ncall)
170 {
171 	;
172 }
173 
174 /* ARGSUSED */
175 void
176 ncall_stub_done(ncall_t *ncall)
177 {
178 	;
179 }
180 
181 int
182 ncall_stub_ping(char *nodename, int *up)
183 {
184 	int rc = 0;
185 
186 	if (strcmp(nodename, nodeinfo.nc_nodename) == 0) {
187 		*up = 1;
188 	} else {
189 		rc = EHOSTUNREACH;
190 		*up = 0;
191 	}
192 
193 	return (rc);
194 }
195 
196 /* ARGSUSED */
197 int
198 ncall_stub_maxnodes()
199 {
200 	return (0);
201 }
202 
203 
204 /* ARGSUSED */
205 int
206 ncall_stub_nextnode(void **vptr)
207 {
208 	return (0);
209 }
210 
211 /* ARGSUSED */
212 int
213 ncall_stub_errcode(ncall_t *ncall, int *result)
214 {
215 	return (ENOLINK);
216 }
217 
218 
219 
220 
221 static int ncall_stub_stop(void);
222 
223 static ncall_module_t ncall_stubinfo = {
224 	NCALL_MODULE_VER,
225 	"ncall stubs",
226 	ncall_stub_stop,
227 	ncall_stub_register_svc,
228 	ncall_stub_unregister_svc,
229 	ncall_stub_nodeid,
230 	ncall_stub_nodename,
231 	ncall_stub_mirror,
232 	ncall_stub_self,
233 	ncall_stub_alloc,
234 	ncall_stub_timedsend,
235 	ncall_stub_timedsendnotify,
236 	ncall_stub_broadcast,
237 	ncall_stub_read_reply,
238 	ncall_stub_reset,
239 	ncall_stub_free,
240 	ncall_stub_put_data,
241 	ncall_stub_get_data,
242 	ncall_stub_sender,
243 	ncall_stub_reply,
244 	ncall_stub_pend,
245 	ncall_stub_done,
246 	ncall_stub_ping,
247 	ncall_stub_maxnodes,
248 	ncall_stub_nextnode,
249 	ncall_stub_errcode
250 };
251 
252 
253 static int
254 ncall_stub_stop(void)
255 {
256 	bzero(&nodeinfo, sizeof (nodeinfo));
257 	return (ncall_unregister_module(&ncall_stubinfo));
258 }
259 
260 
261 void
262 ncall_init_stub(void)
263 {
264 	(void) ncall_register_module(&ncall_stubinfo, &nodeinfo);
265 }
266