1 |
145 |
lanttu |
/*
|
2 |
|
|
Copyright (c) 2008, The Multicore Association
|
3 |
|
|
All rights reserved.
|
4 |
|
|
|
5 |
|
|
Redistribution and use in source and binary forms, with or without
|
6 |
|
|
modification, are permitted provided that the following conditions are
|
7 |
|
|
met:
|
8 |
|
|
|
9 |
|
|
(1) Redistributions of source code must retain the above copyright
|
10 |
|
|
notice, this list of conditions and the following disclaimer.
|
11 |
|
|
|
12 |
|
|
(2) Redistributions in binary form must reproduce the above copyright
|
13 |
|
|
notice, this list of conditions and the following disclaimer in the
|
14 |
|
|
documentation and/or other materials provided with the distribution.
|
15 |
|
|
|
16 |
|
|
(3) Neither the name of the Multicore Association nor the names of its
|
17 |
|
|
contributors may be used to endorse or promote products derived from
|
18 |
|
|
this software without specific prior written permission.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
21 |
|
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22 |
|
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
23 |
|
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
24 |
|
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
25 |
|
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
26 |
|
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
27 |
|
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
28 |
|
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
29 |
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
30 |
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
#include <mcapi.h>
|
34 |
|
|
#include <mcapi_trans.h>
|
35 |
|
|
#include <mcapi_config.h> /* for MCAPI version */
|
36 |
|
|
|
37 |
|
|
#include <string.h> /* for strncpy */
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
/* FIXME: (errata B5) anyone can get an endpoint handle and call receive on it. should
|
41 |
|
|
this be an error? It seems like only the node that owns the receive
|
42 |
|
|
endpoint should be able to call receive. */
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
/* The following 3 functions are useful for debugging but are not part of the spec */
|
46 |
|
|
char* mcapi_display_status (mcapi_status_t status) {
|
47 |
|
|
switch (status) {
|
48 |
|
|
case (MCAPI_INCOMPLETE): return "MCAPI_INCOMPLETE"; break;
|
49 |
|
|
case (MCAPI_SUCCESS): return "MCAPI_SUCCESS"; break;
|
50 |
|
|
case (MCAPI_ENO_INIT): return "MCAPI_ENO_INIT"; break;
|
51 |
|
|
case (MCAPI_EMESS_LIMIT): return "MCAPI_EMESS_LIMIT"; break;
|
52 |
|
|
case (MCAPI_ENO_BUFFER): return "MCAPI_ENO_BUFFER"; break;
|
53 |
|
|
case (MCAPI_ENO_REQUEST): return "MCAPI_ENO_REQUEST"; break;
|
54 |
|
|
case (MCAPI_ENO_MEM): return "MCAPI_ENO_MEM"; break;
|
55 |
|
|
case (MCAPI_ENO_FINAL): return "MCAPI_ENO_FINAL"; break;
|
56 |
|
|
case (MCAPI_ENODE_NOTINIT): return "MCAPI_ENODE_NOTINIT"; break;
|
57 |
|
|
case (MCAPI_EEP_NOTALLOWED): return "MCAPI_EEP_NOTALLOWED"; break;
|
58 |
|
|
case (MCAPI_EPORT_NOTVALID): return "MCAPI_EPORT_NOTVALID"; break;
|
59 |
|
|
case (MCAPI_ENODE_NOTVALID): return "MCAPI_ENODE_NOTVALID"; break;
|
60 |
|
|
case (MCAPI_ENOT_OWNER): return "MCAPI_ENOT_OWNER"; break;
|
61 |
|
|
case (MCAPI_ECHAN_OPEN): return "MCAPI_ECHAN_OPEN"; break;
|
62 |
|
|
case (MCAPI_ENO_ENDPOINT): return "MCAPI_ENO_ENDPOINT"; break;
|
63 |
|
|
case (MCAPI_ECONNECTED): return "MCAPI_ECONNECTED"; break;
|
64 |
|
|
case (MCAPI_EATTR_INCOMP): return "MCAPI_EATTR_INCOMP"; break;
|
65 |
|
|
case (MCAPI_ECHAN_TYPE): return "MCAPI_ECHAN_TYPE"; break;
|
66 |
|
|
case (MCAPI_EDIR): return "MCAPI_EDIR"; break;
|
67 |
|
|
case (MCAPI_ENOT_HANDLE): return "MCAPI_ENOT_HANDLE"; break;
|
68 |
|
|
case (MCAPI_ENOT_ENDP): return "MCAPI_ENOT_ENDP"; break;
|
69 |
|
|
case (MCAPI_EPACK_LIMIT): return "MCAPI_EPACK_LIMIT"; break;
|
70 |
|
|
case (MCAPI_ENOT_VALID_BUF): return "MCAPI_ENOT_VALID_BUF"; break;
|
71 |
|
|
case (MCAPI_ENOT_OPEN): return "MCAPI_ENOT_OPEN"; break;
|
72 |
|
|
case (MCAPI_EREQ_CANCELED): return "MCAPI_EREQ_CANCELED"; break;
|
73 |
|
|
case (MCAPI_ENOTREQ_HANDLE): return "MCAPI_ENOTREQ_HANDLE"; break;
|
74 |
|
|
case (MCAPI_EENDP_ISCREATED):return "MCAPI_EENDP_ISCREATED"; break;
|
75 |
|
|
case (MCAPI_EENDP_LIMIT): return "MCAPI_EENDP_LIMIT"; break;
|
76 |
|
|
case (MCAPI_ENOT_CONNECTED): return "MCAPI_ENOT_CONNECTED"; break;
|
77 |
|
|
case (MCAPI_ESCL_SIZE): return "MCAPI_ESCL_SIZE"; break;
|
78 |
|
|
case (MCAPI_EPRIO): return "MCAPI_EPRIO"; break;
|
79 |
|
|
case (MCAPI_INITIALIZED): return "MCAPI_INITIALIZED"; break;
|
80 |
|
|
case (MCAPI_EPARAM): return "MCAPI_EPARAM"; break;
|
81 |
|
|
case (MCAPI_ETRUNCATED): return "MCAPI_ETRUNCATED"; break;
|
82 |
|
|
case (MCAPI_EREQ_TIMEOUT): return "MCAPI_EREQ_TIMEOUT"; break;
|
83 |
|
|
default : return "UNKNOWN";
|
84 |
|
|
};
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
void mcapi_set_debug_level (int d) {
|
88 |
|
|
mcapi_trans_set_debug_level (d);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
void mcapi_display_state (void* handle) {
|
92 |
|
|
mcapi_trans_display_state(handle);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
/***********************************************************************
|
97 |
|
|
NAME
|
98 |
|
|
mcapi_initialize - Initializes the MCAPI implementation.
|
99 |
|
|
DESCRIPTION
|
100 |
|
|
mcapi_initialize() initializes the MCAPI environment on a given MCAPI node.
|
101 |
|
|
It has to be called by each node using MCAPI. mcapi_version is set to the
|
102 |
|
|
to the implementation version number. A node is a process, a thread, or a
|
103 |
|
|
processor (or core) with an independent program counter running a piece
|
104 |
|
|
of code. In other words, an MCAPI node is an independent thread of
|
105 |
|
|
control. An MCAPI node can call mcapi_initialize() once per node, and it
|
106 |
|
|
is an error to call mcapi_initialize() multiple times from a given node.
|
107 |
|
|
A given MCAPI implementation will specify what is a node (i.e., what
|
108 |
|
|
thread of control - process, thread, or other -- is a node) in that
|
109 |
|
|
implementation. A thread and process are just two examples of threads
|
110 |
|
|
of control, and there could be other.
|
111 |
|
|
RETURN VALUE
|
112 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
113 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
114 |
|
|
ERRORS
|
115 |
|
|
MCAPI_ENO_INIT The MCAPI environment could not be initialized.
|
116 |
|
|
MCAPI_INITIALIZED The MCAPI environment has already been initialized.
|
117 |
|
|
MCAPI_ENODE_NOTVALID The parameter is not a valid node.
|
118 |
|
|
MCAPI_EPARAM Incorrect mcapi_status or mcapi_version parameter.
|
119 |
|
|
NOTE
|
120 |
|
|
SEE ALSO
|
121 |
|
|
mcapi_finalize()
|
122 |
|
|
************************************************************************/
|
123 |
|
|
void mcapi_initialize(
|
124 |
|
|
MCAPI_IN mcapi_node_t node_id,
|
125 |
|
|
MCAPI_OUT mcapi_version_t* mcapi_version,
|
126 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
127 |
|
|
{
|
128 |
|
|
if (!valid_status_param(mcapi_status)) {
|
129 |
|
|
if (mcapi_status != NULL) {
|
130 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
131 |
|
|
}
|
132 |
|
|
} else {
|
133 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
134 |
|
|
if (!valid_version_param(mcapi_version)) {
|
135 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
136 |
|
|
} else {
|
137 |
|
|
(void)strncpy(*mcapi_version,MCAPI_VERSION,sizeof(MCAPI_VERSION));
|
138 |
|
|
if (!mcapi_trans_valid_node(node_id)) {
|
139 |
|
|
*mcapi_status = MCAPI_ENODE_NOTVALID;
|
140 |
|
|
} else if (mcapi_trans_initialized(node_id)) {
|
141 |
|
|
*mcapi_status = MCAPI_INITIALIZED;
|
142 |
|
|
} else if (!mcapi_trans_initialize(node_id)) {
|
143 |
|
|
*mcapi_status = MCAPI_ENO_INIT;
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
|
|
}
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
/***********************************************************************
|
150 |
|
|
NAME
|
151 |
|
|
mcapi_finalize - Finalizes the MCAPI implementation.
|
152 |
|
|
DESCRIPTION
|
153 |
|
|
mcapi_finalize() finalizes the MCAPI environment on a given MCAPI node.
|
154 |
|
|
It has to be called by each node using MCAPI. It is an error to call
|
155 |
|
|
mcapi_finalize() without first calling mcapi_initialize(). An MCAPI
|
156 |
|
|
node can call mcapi_finalize() once for each call to
|
157 |
|
|
mcapi_initialize(), but it is an error to call mcapi_finalize()
|
158 |
|
|
multiple times from a given node unless mcapi_initialize() has been
|
159 |
|
|
called prior to each mcapi_finalize() call.
|
160 |
|
|
RETURN VALUE
|
161 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
162 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
163 |
|
|
ERRORS
|
164 |
|
|
MCAPI_ENO_FINAL The MCAPI environment could not be finalized.
|
165 |
|
|
MCAPI_EPARAM Incorrect mcapi_status_ parameter.
|
166 |
|
|
NOTE
|
167 |
|
|
SEE ALSO
|
168 |
|
|
mcapi_initialize()
|
169 |
|
|
************************************************************************/
|
170 |
|
|
void mcapi_finalize(
|
171 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
172 |
|
|
{
|
173 |
|
|
if (! valid_status_param(mcapi_status)) {
|
174 |
|
|
if (mcapi_status != NULL) {
|
175 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
176 |
|
|
}
|
177 |
|
|
} else {
|
178 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
179 |
|
|
if (! mcapi_trans_finalize()) {
|
180 |
|
|
*mcapi_status = MCAPI_ENO_FINAL;
|
181 |
|
|
}
|
182 |
|
|
}
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
/***********************************************************************
|
186 |
|
|
NAME
|
187 |
|
|
mcapi_get_node_id - return the node number associated with the local node
|
188 |
|
|
DESCRIPTION
|
189 |
|
|
Returns the node id associated with the local node.
|
190 |
|
|
RETURN VALUE
|
191 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
192 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
193 |
|
|
ERRORS
|
194 |
|
|
MCAPI_ENODE_NOTINIT The node is not initialized.
|
195 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
196 |
|
|
NOTE
|
197 |
|
|
SEE ALSO
|
198 |
|
|
************************************************************************/
|
199 |
|
|
mcapi_uint_t mcapi_get_node_id(
|
200 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
201 |
|
|
{
|
202 |
|
|
mcapi_uint_t node;
|
203 |
|
|
|
204 |
|
|
if (! valid_status_param(mcapi_status)) {
|
205 |
|
|
if (mcapi_status != NULL) {
|
206 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
207 |
|
|
}
|
208 |
|
|
} else {
|
209 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
210 |
|
|
if (!mcapi_trans_get_node_num(&node)) {
|
211 |
|
|
*mcapi_status = MCAPI_ENODE_NOTINIT;
|
212 |
|
|
}
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
return node;
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
/***********************************************************************
|
219 |
|
|
NAME
|
220 |
|
|
mcapi_create_endpoint - create an endpoint.
|
221 |
|
|
DESCRIPTION
|
222 |
|
|
mcapi_create_endpoint() is used to create endpoints, using the node_id
|
223 |
|
|
of the local node calling the API function and specific port_id,
|
224 |
|
|
returning a reference to a globally unique endpoint which can later be
|
225 |
|
|
referenced by name using mcapi_get_endpoint() (see Section 4.2.3). The
|
226 |
|
|
port_id can be set to MCAPI_PORT ANY to request the next available
|
227 |
|
|
endpoint on the local node.
|
228 |
|
|
MCAPI supports a simple static naming scheme to create endpoints based
|
229 |
|
|
on global tuple names. Other nodes can access the created endpoint by
|
230 |
|
|
calling mcapi_get_endpoint() and specifying the appropriate node and
|
231 |
|
|
port id's. Enpoints can be passed on to other endpoints and an
|
232 |
|
|
endpoint created using MCAPI_PORT ANY has to be passed on to other
|
233 |
|
|
endpoints by the creator, to facilitate communication.
|
234 |
|
|
Static naming allows the programmer to define an MCAPI communication
|
235 |
|
|
topology at compile time. This facilitates simple initialization.
|
236 |
|
|
Section 7.1 illustrates an example of initialization and bootstrapping
|
237 |
|
|
using static naming. Creating endpoints using MCAPI_PORT ANY provides
|
238 |
|
|
a convenient method to create endpoints without having to specify the
|
239 |
|
|
port_id.
|
240 |
|
|
RETURN VALUE
|
241 |
|
|
On success, an endpoint is returned and *mcapi_status is set to
|
242 |
|
|
MCAPI_SUCCESS. On error, MCAPI_NULL is returned and *mcapi_status is
|
243 |
|
|
set to the appropriate error defined below.
|
244 |
|
|
ERRORS
|
245 |
|
|
MCAPI_EPORT_NOTVALID The parameter is not a valid port.
|
246 |
|
|
MCAPI_EENDP_ISCREATED The endpoint is already created.
|
247 |
|
|
MCAPI_ENODE_NOTINIT The node is not initialized.
|
248 |
|
|
MCAPI_EENDP_LIMIT Exceeded maximum number of endpoints allowed.
|
249 |
|
|
MCAPI_EEP_NOTALLOWED Endpoints cannot be created on this node.
|
250 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
251 |
|
|
NOTE
|
252 |
|
|
The node number can only be set using the mcapi_intialize() function.
|
253 |
|
|
SEE ALSO
|
254 |
|
|
mcapi_initialize()
|
255 |
|
|
************************************************************************/
|
256 |
|
|
mcapi_endpoint_t mcapi_create_endpoint(
|
257 |
|
|
MCAPI_IN mcapi_port_t port_id,
|
258 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
259 |
|
|
{
|
260 |
|
|
mcapi_endpoint_t e;
|
261 |
|
|
|
262 |
|
|
if (! valid_status_param(mcapi_status)) {
|
263 |
|
|
if (mcapi_status != NULL) {
|
264 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
265 |
|
|
}
|
266 |
|
|
} else {
|
267 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
268 |
|
|
if (mcapi_trans_endpoint_exists (port_id)) {
|
269 |
|
|
*mcapi_status = MCAPI_EENDP_ISCREATED;
|
270 |
|
|
} else if (mcapi_trans_num_endpoints () == MAX_ENDPOINTS) {
|
271 |
|
|
*mcapi_status = MCAPI_EENDP_LIMIT;
|
272 |
|
|
} else if (!mcapi_trans_valid_port(port_id)) {
|
273 |
|
|
*mcapi_status = MCAPI_EPORT_NOTVALID;
|
274 |
|
|
} else if (!mcapi_trans_create_endpoint(&e,port_id,MCAPI_FALSE)) {
|
275 |
|
|
*mcapi_status = MCAPI_EEP_NOTALLOWED;
|
276 |
|
|
}
|
277 |
|
|
}
|
278 |
|
|
return e;
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
|
282 |
|
|
/***********************************************************************
|
283 |
|
|
NAME
|
284 |
|
|
mcapi_get_endpoint_i - obtain the endpoint associated with a given tuple.
|
285 |
|
|
DESCRIPTION
|
286 |
|
|
mcapi_get_endpoint_i() allows other nodes ("third parties") to get the
|
287 |
|
|
endpoint identifier for the endpoint associated with a global tuple name
|
288 |
|
|
<node_id, port_id>. This function is non-blocking and will return
|
289 |
|
|
immediately.
|
290 |
|
|
RETURN VALUE
|
291 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
292 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
293 |
|
|
ERRORS
|
294 |
|
|
MCAPI_EPORT_NOTVALID The parameter is not a valid port.
|
295 |
|
|
MCAPI_ENODE_NOTVALID The parameter is not a valid node.
|
296 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
297 |
|
|
NOTE
|
298 |
|
|
Use the mcapi_test(), mcapi_wait() and mcapi_wait_any() functions to
|
299 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
300 |
|
|
SEE ALSO
|
301 |
|
|
mcapi_get_node_id()
|
302 |
|
|
************************************************************************/
|
303 |
|
|
void mcapi_get_endpoint_i(
|
304 |
|
|
MCAPI_IN mcapi_node_t node_id,
|
305 |
|
|
MCAPI_IN mcapi_port_t port_id,
|
306 |
|
|
MCAPI_OUT mcapi_endpoint_t* endpoint,
|
307 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
308 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
309 |
|
|
{
|
310 |
|
|
if (! valid_status_param(mcapi_status)) {
|
311 |
|
|
if (mcapi_status != NULL) {
|
312 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
313 |
|
|
}
|
314 |
|
|
} else {
|
315 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
316 |
|
|
if (! mcapi_trans_valid_node (node_id)){
|
317 |
|
|
*mcapi_status = MCAPI_ENODE_NOTVALID;
|
318 |
|
|
} else if ( ! mcapi_trans_valid_port (port_id)) {
|
319 |
|
|
*mcapi_status = MCAPI_EPORT_NOTVALID;
|
320 |
|
|
}
|
321 |
|
|
mcapi_trans_get_endpoint_i (endpoint,node_id,port_id,request,mcapi_status);
|
322 |
|
|
}
|
323 |
|
|
}
|
324 |
|
|
|
325 |
|
|
/***********************************************************************
|
326 |
|
|
NAME
|
327 |
|
|
mcapi_get_endpoint - obtain the endpoint associated with a given tuple.
|
328 |
|
|
DESCRIPTION
|
329 |
|
|
mcapi_get_endpoint() allows other nodes ("third parties") to get the
|
330 |
|
|
endpoint identifier for the endpoint associated with a global tuple name
|
331 |
|
|
<node_id, port_id>. This function will block until the specified remote
|
332 |
|
|
endpoint has been created via the mcapi_create_endpoint() call.
|
333 |
|
|
RETURN VALUE
|
334 |
|
|
On success, an endpoint is returned and *mcapi_status is set to
|
335 |
|
|
MCAPI_SUCCESS. On error, MCAPI_NULL is returned and *mcapi_status is set
|
336 |
|
|
to the appropriate error defined below.
|
337 |
|
|
ERRORS
|
338 |
|
|
MCAPI_EPORT_NOTVALID The parameter is not a valid port.
|
339 |
|
|
MCAPI_ENODE_NOTVALID The parameter is not a valid node.
|
340 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
341 |
|
|
NOTE
|
342 |
|
|
SEE ALSO
|
343 |
|
|
************************************************************************/
|
344 |
|
|
mcapi_endpoint_t mcapi_get_endpoint(
|
345 |
|
|
MCAPI_IN mcapi_node_t node_id,
|
346 |
|
|
MCAPI_IN mcapi_port_t port_id,
|
347 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
348 |
|
|
{
|
349 |
|
|
mcapi_endpoint_t e;
|
350 |
|
|
|
351 |
|
|
if (! valid_status_param(mcapi_status)) {
|
352 |
|
|
if (mcapi_status != NULL) {
|
353 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
354 |
|
|
}
|
355 |
|
|
} else {
|
356 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
357 |
|
|
if (! mcapi_trans_valid_node (node_id)){
|
358 |
|
|
*mcapi_status = MCAPI_ENODE_NOTVALID;
|
359 |
|
|
} else if ( ! mcapi_trans_valid_port (port_id)) {
|
360 |
|
|
*mcapi_status = MCAPI_EPORT_NOTVALID;
|
361 |
|
|
} else {
|
362 |
|
|
mcapi_trans_get_endpoint (&e,node_id,port_id);
|
363 |
|
|
}
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
return e;
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
/***********************************************************************
|
370 |
|
|
NAME
|
371 |
|
|
mcapi_delete_endpoint - delete an endpoint.
|
372 |
|
|
DESCRIPTION
|
373 |
|
|
Deletes an MCAPI endpoint. Pending messages are discarded. If an
|
374 |
|
|
endpoint has been connected to a packet or scalar channel, the
|
375 |
|
|
appropriate close method must be called before deleting the endpoint.
|
376 |
|
|
Delete is a blocking operation. Since the connection is closed before
|
377 |
|
|
deleting the endpoint, the delete method does not require any
|
378 |
|
|
cross-process synchronization and is guaranteed to return in a timely
|
379 |
|
|
manner (operation will return without having to block on any IPC to any
|
380 |
|
|
remote nodes). It is an error to attempt to delete an endpoint that has
|
381 |
|
|
not been closed. Only the node that created an endpoint can delete it.
|
382 |
|
|
RETURN VALUE
|
383 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
384 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
385 |
|
|
ERRORS
|
386 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
387 |
|
|
MCAPI_ECHAN_OPEN A channel is open, deletion is not allowed.
|
388 |
|
|
MCAPI_ENOT_OWNER An endpoint can only be deleted by its creator.
|
389 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
390 |
|
|
NOTE
|
391 |
|
|
SEE ALSO
|
392 |
|
|
mcapi_create_endpoint()
|
393 |
|
|
************************************************************************/
|
394 |
|
|
void mcapi_delete_endpoint(
|
395 |
|
|
MCAPI_IN mcapi_endpoint_t endpoint,
|
396 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
397 |
|
|
{
|
398 |
|
|
if (! valid_status_param(mcapi_status)) {
|
399 |
|
|
if (mcapi_status != NULL) {
|
400 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
401 |
|
|
}
|
402 |
|
|
} else {
|
403 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
404 |
|
|
if ( ! mcapi_trans_valid_endpoint(endpoint)) {
|
405 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
406 |
|
|
} else if (!mcapi_trans_endpoint_isowner (endpoint)) {
|
407 |
|
|
*mcapi_status = MCAPI_ENOT_OWNER;
|
408 |
|
|
} else if ( mcapi_trans_endpoint_channel_isopen (endpoint)) {
|
409 |
|
|
*mcapi_status = MCAPI_ECHAN_OPEN;
|
410 |
|
|
} else {
|
411 |
|
|
/* delete the endpoint */
|
412 |
|
|
mcapi_trans_delete_endpoint (endpoint);
|
413 |
|
|
}
|
414 |
|
|
}
|
415 |
|
|
}
|
416 |
|
|
|
417 |
|
|
/***********************************************************************
|
418 |
|
|
NAME
|
419 |
|
|
mcapi_get_endpoint_attribute - get endpoint attributes.
|
420 |
|
|
DESCRIPTION
|
421 |
|
|
mcapi_get_endpoint_attribute() allows the programmer to query endpoint
|
422 |
|
|
attributes related to buffer management or quality of service.
|
423 |
|
|
attribute_num indicates which one of the endpoint attributes is being
|
424 |
|
|
referenced. attribute points to a structure or scalar to be filled with
|
425 |
|
|
the value of the attribute specified by attribute_num. attribute size
|
426 |
|
|
is the size in bytes of the structure or scalar. See Section 3.2 and the
|
427 |
|
|
example mcapi.h for a description of attributes. The
|
428 |
|
|
mcapi_get_endpoint_attribute() function returns the requested attribute
|
429 |
|
|
value by reference.
|
430 |
|
|
It is an error to attempt a connection between endpoints whose attributes
|
431 |
|
|
are set in an incompatible way (for now, whether attributes are compatible
|
432 |
|
|
or not is implementation defined). It is also an error to attempt to
|
433 |
|
|
change the attributes of endpoints that are connected.
|
434 |
|
|
RETURN VALUE
|
435 |
|
|
On success, *attribute is filled with the requested attribute and
|
436 |
|
|
*mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status is
|
437 |
|
|
set to an error code and *attribute is not modified.
|
438 |
|
|
ERRORS
|
439 |
|
|
MCAPI_ENOT_ENDP Argument is not an endpoint descriptor.
|
440 |
|
|
MCAPI_EATTR_NUM Unknown attribute number.
|
441 |
|
|
MCAPI_EATTR_SIZE Incorrect attribute size.
|
442 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
443 |
|
|
NOTE
|
444 |
|
|
SEE ALSO
|
445 |
|
|
mcapi_set_endpoint_attribute()
|
446 |
|
|
************************************************************************/
|
447 |
|
|
void mcapi_get_endpoint_attribute(
|
448 |
|
|
MCAPI_IN mcapi_endpoint_t endpoint,
|
449 |
|
|
MCAPI_IN mcapi_uint_t attribute_num,
|
450 |
|
|
MCAPI_OUT void* attribute,
|
451 |
|
|
MCAPI_IN size_t attribute_size,
|
452 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
453 |
|
|
{
|
454 |
|
|
/* FIXME: (errata A3) Not implemented */
|
455 |
|
|
}
|
456 |
|
|
|
457 |
|
|
/***********************************************************************
|
458 |
|
|
NAME
|
459 |
|
|
mcapi_set_endpoint_attribute - set endpoint attributes.
|
460 |
|
|
DESCRIPTION
|
461 |
|
|
mcapi_set_endpoint_attribute() allows the programmer to assign endpoint
|
462 |
|
|
attributes related to buffer management or quality of service.
|
463 |
|
|
attribute_num indicates which one of the endpoint attributes is being
|
464 |
|
|
referenced. attribute points to a structure or scalar to be filled with
|
465 |
|
|
the value of the attribute specified by attribute_num. attribute size is
|
466 |
|
|
the size in bytes of the structure or scalar. See Section 3.2 and mcapi.h
|
467 |
|
|
for a description of attributes.
|
468 |
|
|
It is an error to attempt a connection between endpoints whose attributes
|
469 |
|
|
are set in an incompatible way (for now, whether attributes are compatible
|
470 |
|
|
or not is implementation defined). It is also an error to attempt to
|
471 |
|
|
change the attributes of endpoints that are connected.
|
472 |
|
|
RETURN VALUE
|
473 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
474 |
|
|
is set to the appropriate error defined below.
|
475 |
|
|
ERRORS
|
476 |
|
|
MCAPI_ENOT_ENDP Argument is not an endpoint descriptor.
|
477 |
|
|
MCAPI_EATTR_NUM Unknown attribute number.
|
478 |
|
|
MCAPI_EATTR_SIZE Incorrect attribute size.
|
479 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
480 |
|
|
MCAPI_ECONNECTED Attribute changes not allowed on connected endpoints.
|
481 |
|
|
MCAPI_EREAD_ONLY Attribute cannot be modified.
|
482 |
|
|
NOTE
|
483 |
|
|
SEE ALSO
|
484 |
|
|
mcapi_get_endpoint_attribute()
|
485 |
|
|
4.3 MCAPI Messages
|
486 |
|
|
MCAPI Messages facilitate connectionless transfer of data buffers. The
|
487 |
|
|
messaging API provides a "user-specified buffer" communications interface
|
488 |
|
|
- the programmer specifies a buffer of data to be sent on the send side,
|
489 |
|
|
and the user specifies an empty buffer to be filled with incoming data on
|
490 |
|
|
the receive side. The implementation must be able to transfer messages to
|
491 |
|
|
and from any buffer the programmer specifies, although the implementation
|
492 |
|
|
may use extra buffering internally to queue up data between the sender
|
493 |
|
|
and receiver.
|
494 |
|
|
************************************************************************/
|
495 |
|
|
void mcapi_set_endpoint_attribute(
|
496 |
|
|
MCAPI_IN mcapi_endpoint_t endpoint,
|
497 |
|
|
MCAPI_IN mcapi_uint_t attribute_num,
|
498 |
|
|
MCAPI_IN const void* attribute,
|
499 |
|
|
MCAPI_IN size_t attribute_size,
|
500 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
501 |
|
|
{
|
502 |
|
|
/* FIXME: (errata A3) not implemented */
|
503 |
|
|
}
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
/***********************************************************************
|
507 |
|
|
NAME
|
508 |
|
|
mcapi_msg_send_i - sends a (connectionless) message from a send endpoint
|
509 |
|
|
to a receive endpoint.
|
510 |
|
|
DESCRIPTION
|
511 |
|
|
Sends a (connectionless) message from a send endpoint to a receive
|
512 |
|
|
endpoint. It is a non-blocking function, and returns immediately.
|
513 |
|
|
send_endpoint, is a local endpoint identifying the send endpoint,
|
514 |
|
|
receive_endpoint identifies a receive endpoint. buffer is the application
|
515 |
|
|
provided buffer, buffer_size is the buffer size in bytes, priority
|
516 |
|
|
determines the message priority and request is the identifier used to
|
517 |
|
|
determine if the send operation has completed on the sending endpoint
|
518 |
|
|
and the buffer can be reused by the application. Furthermore, this
|
519 |
|
|
method will abandon the send and return MCAPI_ENO_MEM if the system
|
520 |
|
|
cannot allocate enough memory at the send endpoint to queue up the
|
521 |
|
|
outgoing message.
|
522 |
|
|
RETURN VALUE
|
523 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
524 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
525 |
|
|
ERRORS
|
526 |
|
|
MCAPI_ENOT_ENDP Argument is not an endpoint descriptor.
|
527 |
|
|
MCAPI_EMESS_LIMIT The message size exceeds the maximum size allowed by the
|
528 |
|
|
MCAPI implementation.
|
529 |
|
|
MCAPI_ENO_BUFFER No more message buffers available.
|
530 |
|
|
MCAPI_ENO_REQUEST No more request handles available.
|
531 |
|
|
MCAPI_ENO_MEM No memory available.
|
532 |
|
|
MCAPI_EPRIO Incorrect priority level.
|
533 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
534 |
|
|
NOTE
|
535 |
|
|
Use the mcapi_test(), mcapi_wait() and mcapi_wait_any() functions to
|
536 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
537 |
|
|
SEE ALSO
|
538 |
|
|
************************************************************************/
|
539 |
|
|
void mcapi_msg_send_i(
|
540 |
|
|
MCAPI_IN mcapi_endpoint_t send_endpoint,
|
541 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
542 |
|
|
MCAPI_IN void* buffer,
|
543 |
|
|
MCAPI_IN size_t buffer_size,
|
544 |
|
|
MCAPI_IN mcapi_priority_t priority,
|
545 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
546 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
547 |
|
|
{
|
548 |
|
|
/* MCAPI_ENO_BUFFER, MCAPI_ENO_REQUEST, and MCAPI_ENO_MEM handled at the transport layer */
|
549 |
|
|
if (! valid_status_param(mcapi_status)) {
|
550 |
|
|
if (mcapi_status != NULL) {
|
551 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
552 |
|
|
}
|
553 |
|
|
} else {
|
554 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
555 |
|
|
if (! mcapi_trans_valid_priority (priority)){
|
556 |
|
|
*mcapi_status = MCAPI_EPRIO;
|
557 |
|
|
} else if (!mcapi_trans_valid_endpoints(send_endpoint,receive_endpoint)) {
|
558 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP; /* FIXME (errata A1) */
|
559 |
|
|
} else if (buffer_size > MAX_MSG_SIZE) {
|
560 |
|
|
*mcapi_status = MCAPI_EMESS_LIMIT;
|
561 |
|
|
}
|
562 |
|
|
mcapi_trans_msg_send_i (send_endpoint,receive_endpoint,buffer,buffer_size,request,mcapi_status);
|
563 |
|
|
}
|
564 |
|
|
}
|
565 |
|
|
|
566 |
|
|
|
567 |
|
|
/***********************************************************************
|
568 |
|
|
NAME
|
569 |
|
|
mcapi_msg_send - sends a (connectionless) message from a send endpoint to
|
570 |
|
|
a receive endpoint.
|
571 |
|
|
DESCRIPTION
|
572 |
|
|
Sends a (connectionless) message from a send endpoint to a receive endpoint.
|
573 |
|
|
It is a blocking function, and returns once the buffer can be reused by the
|
574 |
|
|
application. send_endpoint is a local endpoint identifying the send endpoint,
|
575 |
|
|
receive_endpoint identifies a receive endpoint. buffer is the application
|
576 |
|
|
provided buffer and buffer_size is the buffer size in bytes, and priority
|
577 |
|
|
determines the message priority
|
578 |
|
|
RETURN VALUE
|
579 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
580 |
|
|
is set to the appropriate error defined below. Success means that the entire
|
581 |
|
|
buffer has been sent.
|
582 |
|
|
ERRORS
|
583 |
|
|
MCAPI_ENOT_ENDP Argument is not an endpoint descriptor.
|
584 |
|
|
MCAPI_EMESS_LIMIT The message size exceeds the maximum size allowed by the
|
585 |
|
|
MCAPI implementation.
|
586 |
|
|
MCAPI_ENO_BUFFER No more message buffers available.
|
587 |
|
|
MCAPI_EPRIO Incorrect priority level.
|
588 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
589 |
|
|
NOTE
|
590 |
|
|
SEE ALSO
|
591 |
|
|
************************************************************************/
|
592 |
|
|
void mcapi_msg_send(
|
593 |
|
|
MCAPI_IN mcapi_endpoint_t send_endpoint,
|
594 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
595 |
|
|
MCAPI_IN void* buffer,
|
596 |
|
|
MCAPI_IN size_t buffer_size,
|
597 |
|
|
MCAPI_IN mcapi_priority_t priority,
|
598 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
599 |
|
|
{
|
600 |
|
|
|
601 |
|
|
/* FIXME: (errata B1) is it an error to send a message to a connected endpoint? */
|
602 |
|
|
|
603 |
|
|
/* MCAPI_ENO_BUFFER handled at the transport layer */
|
604 |
|
|
if (! valid_status_param(mcapi_status)) {
|
605 |
|
|
if (mcapi_status != NULL) {
|
606 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
607 |
|
|
}
|
608 |
|
|
} else {
|
609 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
610 |
|
|
if (! mcapi_trans_valid_priority (priority)) {
|
611 |
|
|
*mcapi_status = MCAPI_EPRIO;
|
612 |
|
|
} else if (!mcapi_trans_valid_endpoints(send_endpoint,receive_endpoint)) {
|
613 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP; /* FIXME (errata A1) */
|
614 |
|
|
} else if (buffer_size > MAX_MSG_SIZE) {
|
615 |
|
|
*mcapi_status = MCAPI_EMESS_LIMIT;
|
616 |
|
|
} else if ( !mcapi_trans_msg_send (send_endpoint,receive_endpoint,buffer,buffer_size)) {
|
617 |
|
|
/* assume couldn't get a buffer */
|
618 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
619 |
|
|
}
|
620 |
|
|
}
|
621 |
|
|
}
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
/***********************************************************************
|
625 |
|
|
NAME
|
626 |
|
|
mcapi_msg_recv_i - receives a (connectionless) message from a receive
|
627 |
|
|
endpoint.
|
628 |
|
|
DESCRIPTION
|
629 |
|
|
Receives a (connectionless) message from a receive endpoint. It is a
|
630 |
|
|
non-blocking function, and returns immediately. receive_endpoint is a
|
631 |
|
|
local endpoint identifying the receive endpoint. buffer is the
|
632 |
|
|
application provided buffer, and buffer_size is the buffer size in bytes.
|
633 |
|
|
request is the identifier used to determine if the receive operation has
|
634 |
|
|
completed (all the data is in the buffer).
|
635 |
|
|
RETURN VALUE
|
636 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
637 |
|
|
is set to the appropriate error defined below.
|
638 |
|
|
ERRORS
|
639 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
640 |
|
|
MCAPI_ETRUNCATED The message size exceeds the buffer_size.
|
641 |
|
|
MCAPI_ENO_REQUEST No more request handles available.
|
642 |
|
|
MCAPI_EPARAM Incorrect buffer, request and/or mcapi_status parameter.
|
643 |
|
|
NOTE
|
644 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
645 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
646 |
|
|
SEE ALSO
|
647 |
|
|
************************************************************************/
|
648 |
|
|
void mcapi_msg_recv_i(
|
649 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
650 |
|
|
MCAPI_OUT void* buffer,
|
651 |
|
|
MCAPI_IN size_t buffer_size,
|
652 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
653 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
654 |
|
|
{
|
655 |
|
|
/* MCAPI_ENO_REQUEST handled at the transport layer */
|
656 |
|
|
|
657 |
|
|
if (! valid_status_param(mcapi_status)) {
|
658 |
|
|
if (mcapi_status != NULL) {
|
659 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
660 |
|
|
}
|
661 |
|
|
} else {
|
662 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
663 |
|
|
if (! valid_buffer_param(buffer)) {
|
664 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
665 |
|
|
} else if (! valid_request_param(request)) {
|
666 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
667 |
|
|
} else if (!mcapi_trans_valid_endpoint(receive_endpoint)) {
|
668 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
669 |
|
|
}
|
670 |
|
|
mcapi_trans_msg_recv_i(receive_endpoint,buffer,buffer_size,request,mcapi_status);
|
671 |
|
|
}
|
672 |
|
|
}
|
673 |
|
|
|
674 |
|
|
|
675 |
|
|
|
676 |
|
|
/***********************************************************************
|
677 |
|
|
NAME
|
678 |
|
|
mcapi_msg_recv - receives a (connectionless) message from a receive endpoint.
|
679 |
|
|
DESCRIPTION
|
680 |
|
|
Receives a (connectionless) message from a receive endpoint. It is a
|
681 |
|
|
blocking function, and returns once a message is available and the received
|
682 |
|
|
data filled into the buffer. receive_endpoint is a local endpoint identifying
|
683 |
|
|
the receive endpoint. buffer is the application provided buffer, and
|
684 |
|
|
buffer_size is the buffer size in bytes. The received_size parameter is
|
685 |
|
|
filled with the actual size of the received message.
|
686 |
|
|
RETURN VALUE
|
687 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
688 |
|
|
is set to the appropriate error defined below.
|
689 |
|
|
ERRORS
|
690 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
691 |
|
|
MCAPI_ETRUNCATED The message size exceeds the buffer_size.
|
692 |
|
|
MCAPI_EPARAM Incorrect buffer and/or mcapi_status parameter.
|
693 |
|
|
NOTE
|
694 |
|
|
SEE ALSO
|
695 |
|
|
************************************************************************/
|
696 |
|
|
void mcapi_msg_recv(
|
697 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
698 |
|
|
MCAPI_OUT void* buffer,
|
699 |
|
|
MCAPI_IN size_t buffer_size,
|
700 |
|
|
MCAPI_OUT size_t* received_size,
|
701 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
702 |
|
|
{
|
703 |
|
|
/* FIXME: (errata B1) is it an error to try to receive a message on a connected endpoint? */
|
704 |
|
|
if (! valid_status_param(mcapi_status)) {
|
705 |
|
|
if (mcapi_status != NULL) {
|
706 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
707 |
|
|
}
|
708 |
|
|
} else {
|
709 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
710 |
|
|
if (! valid_buffer_param(buffer)) {
|
711 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
712 |
|
|
} else if (!mcapi_trans_valid_endpoint(receive_endpoint)) {
|
713 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
714 |
|
|
} else {
|
715 |
|
|
mcapi_trans_msg_recv(receive_endpoint,buffer,buffer_size,received_size);
|
716 |
|
|
if (*received_size > buffer_size) {
|
717 |
|
|
*received_size = buffer_size;
|
718 |
|
|
*mcapi_status = MCAPI_ETRUNCATED;
|
719 |
|
|
}
|
720 |
|
|
}
|
721 |
|
|
}
|
722 |
|
|
}
|
723 |
|
|
|
724 |
|
|
|
725 |
|
|
/***********************************************************************
|
726 |
|
|
NAME
|
727 |
|
|
mcapi_msg_available - checks if messages are available on a receive
|
728 |
|
|
endpoint.
|
729 |
|
|
DESCRIPTION
|
730 |
|
|
Checks if messages are available on a receive endpoint. The function
|
731 |
|
|
returns in a timely fashion. The number of "available" incoming messages
|
732 |
|
|
is defined as the number of mcapi_msg_recv() operations that are guaranteed
|
733 |
|
|
to not block waiting for incoming data. receive_endpoint is a local
|
734 |
|
|
identifier for the receive endpoint. The call only checks the availability
|
735 |
|
|
of messages and does not de-queue them. mcapi_msg_available() can only be
|
736 |
|
|
used to check availability on endpoints on the node local to the caller.
|
737 |
|
|
RETURN VALUE
|
738 |
|
|
On success, the number of available messages is returned and *mcapi_status
|
739 |
|
|
is set to MCAPI_SUCCESS. On error, MCAPI_NULL is returned and *mcapi_status
|
740 |
|
|
is set to the appropriate error defined below.
|
741 |
|
|
ERRORS
|
742 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
743 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
744 |
|
|
NOTE
|
745 |
|
|
The status code must be checked to distinguish between no messages and an
|
746 |
|
|
error condition.
|
747 |
|
|
SEE ALSO
|
748 |
|
|
4.4 MCAPI Packet Channels
|
749 |
|
|
MCAPI packet channels transfer data packets between a pair of connected
|
750 |
|
|
endpoints. A connection between two endpoints is established via a
|
751 |
|
|
two-phase process. First, some node in the system calls
|
752 |
|
|
mcapi_connect_pktchan_i() to define a connection between two endpoints.
|
753 |
|
|
This function returns immediately. In the second phase, both sender and
|
754 |
|
|
receiver open their end of the channel by invoking
|
755 |
|
|
mcapi_open_pktchan_send_i() and mcapi_open_pktchan_recv_i(), respectively.
|
756 |
|
|
The connection is synchronized when both the sender and receiver open
|
757 |
|
|
functions have completed. In order to avoid deadlock situations, the
|
758 |
|
|
open functions are non-blocking.
|
759 |
|
|
This two-phased binding approach has several important benefits. The
|
760 |
|
|
"connect" call can be made by any node in the system, which allows the
|
761 |
|
|
programmer to define the entire channel topology in a single piece of
|
762 |
|
|
code. This code could even be auto-generated by some static connection
|
763 |
|
|
tool. This makes it easy to change the channel topology without having
|
764 |
|
|
to modify multiple source files. This approach also allows the sender
|
765 |
|
|
and receiver to do their work without any knowledge of what remote nodes
|
766 |
|
|
they are connected to. This allows for better modularity and application
|
767 |
|
|
scaling.
|
768 |
|
|
Packet channels provide a "system-specified buffer" interface. The
|
769 |
|
|
programmer specifies the address of a buffer of data to be sent on the
|
770 |
|
|
send side, but the receiver's recv method returns a buffer of data at an
|
771 |
|
|
address chosen by the system. This is different from the "user-specified
|
772 |
|
|
buffer" interface use by MCAPI messaging - with messages the programmer
|
773 |
|
|
chooses the buffer in which data is received, and with packet channels
|
774 |
|
|
the system chooses the buffer.
|
775 |
|
|
************************************************************************/
|
776 |
|
|
mcapi_uint_t mcapi_msg_available(
|
777 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
778 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
779 |
|
|
{
|
780 |
|
|
mcapi_uint_t rc = 0;
|
781 |
|
|
if (! valid_status_param(mcapi_status)) {
|
782 |
|
|
if (mcapi_status != NULL) {
|
783 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
784 |
|
|
}
|
785 |
|
|
} else {
|
786 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
787 |
|
|
if( !mcapi_trans_valid_endpoint(receive_endpoint)) {
|
788 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
789 |
|
|
} else {
|
790 |
|
|
rc = mcapi_trans_msg_available(receive_endpoint);
|
791 |
|
|
}
|
792 |
|
|
}
|
793 |
|
|
return rc;
|
794 |
|
|
}
|
795 |
|
|
|
796 |
|
|
/***********************************************************************
|
797 |
|
|
NAME
|
798 |
|
|
mcapi_connect_pktchan_i - connects send & receive side endpoints.
|
799 |
|
|
DESCRIPTION
|
800 |
|
|
Connects a pair of endpoints into a unidirectional FIFO channel. The
|
801 |
|
|
connect operation can be performed by the sender, the receiver, or by a
|
802 |
|
|
third party. The connect can happen once at the start of the program, or
|
803 |
|
|
dynamically at run time.
|
804 |
|
|
Connect is a non-blocking function. Synchronization to ensure the channel
|
805 |
|
|
has been created is provided by the open call discussed later.
|
806 |
|
|
Attempts to make multiple connections to a single endpoint will be detected
|
807 |
|
|
as errors. The type of channel connected to an endpoint must match the type
|
808 |
|
|
of open call invoked by that endpoint; the open function will return an error
|
809 |
|
|
if the opened channel type does not match the connected channel type, or if
|
810 |
|
|
the attributes of the endpoints are incompatible.
|
811 |
|
|
It is an error to attempt a connection between endpoints whose attributes
|
812 |
|
|
are set in an incompatible way (for now, whether attributes are compatible
|
813 |
|
|
or not is implementation defined). It is also an error to attempt to change
|
814 |
|
|
the attributes of endpoints that are connected.
|
815 |
|
|
RETURN VALUE
|
816 |
|
|
On success *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
817 |
|
|
is set to the appropriate error defined below.
|
818 |
|
|
ERRORS
|
819 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
820 |
|
|
MCAPI_ECONNECTED A channel connection has already been established for
|
821 |
|
|
one or both of the specified endpoints.
|
822 |
|
|
MCAPI_ENO_REQUEST No more request handles available.
|
823 |
|
|
MCAPI_EATTR_INCOMP Connection of endpoints with incompatible attributes
|
824 |
|
|
not allowed.
|
825 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
826 |
|
|
NOTE
|
827 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
828 |
|
|
query the status and mcapi_cancel() function to cancel the operation.
|
829 |
|
|
SEE ALSO
|
830 |
|
|
************************************************************************/
|
831 |
|
|
void mcapi_connect_pktchan_i(
|
832 |
|
|
MCAPI_IN mcapi_endpoint_t send_endpoint,
|
833 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
834 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
835 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
836 |
|
|
{
|
837 |
|
|
/* MCAPI_ENO_REQUEST handled at the transport layer */
|
838 |
|
|
|
839 |
|
|
if (! valid_status_param(mcapi_status)) {
|
840 |
|
|
if (mcapi_status != NULL) {
|
841 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
842 |
|
|
}
|
843 |
|
|
} else {
|
844 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
845 |
|
|
if ( ! mcapi_trans_valid_endpoints(send_endpoint,receive_endpoint)) {
|
846 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
847 |
|
|
} else if (( mcapi_trans_channel_connected (send_endpoint)) ||
|
848 |
|
|
( mcapi_trans_channel_connected (receive_endpoint))) {
|
849 |
|
|
*mcapi_status = MCAPI_ECONNECTED;
|
850 |
|
|
} else if (! mcapi_trans_compatible_endpoint_attributes (send_endpoint,receive_endpoint)) {
|
851 |
|
|
*mcapi_status = MCAPI_EATTR_INCOMP;
|
852 |
|
|
}
|
853 |
|
|
mcapi_trans_connect_pktchan_i (send_endpoint,receive_endpoint,request,mcapi_status);
|
854 |
|
|
}
|
855 |
|
|
}
|
856 |
|
|
|
857 |
|
|
|
858 |
|
|
|
859 |
|
|
/***********************************************************************
|
860 |
|
|
NAME
|
861 |
|
|
mcapi_open_pktchan_recv_i - Creates a typed, local representation of the
|
862 |
|
|
channel. It also provides synchronization for channel creation between
|
863 |
|
|
two endpoints. Opens are required on both receive and send endpoints.
|
864 |
|
|
DESCRIPTION
|
865 |
|
|
Opens the receive end of a packet channel. The corresponding calls are
|
866 |
|
|
required on both sides for synchronization to ensure that the channel
|
867 |
|
|
has been created. It is a non-blocking function, and the recv_handle is
|
868 |
|
|
filled in upon successful completion. No specific ordering of calls
|
869 |
|
|
between sender and receiver is required since the call is non-blocking.
|
870 |
|
|
receive_endpoint is the endpoint associated with the channel. The open
|
871 |
|
|
call returns a typed, local handle for the connected channel that is
|
872 |
|
|
used for channel receive operations.
|
873 |
|
|
RETURN VALUE
|
874 |
|
|
On success, a valid request is returned by and *mcapi_status is set to
|
875 |
|
|
MCAPI_SUCCESS. On error *mcapi_status is set to the appropriate error
|
876 |
|
|
defined below.
|
877 |
|
|
ERRORS
|
878 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
879 |
|
|
MCAPI_ENOT_CONNECTED The channel is not connected (cannot be opened).
|
880 |
|
|
MCAPI_ECHAN_TYPE Attempt to open a packet channel on an endpoint that
|
881 |
|
|
has been connected with a different channel type.
|
882 |
|
|
MCAPI_EDIR Attempt to open a send handle on a port that was connected
|
883 |
|
|
as a receiver, or vice versa.
|
884 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
885 |
|
|
NOTE
|
886 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
887 |
|
|
query the status and mcapi_cancel() function to cancel the operation.
|
888 |
|
|
SEE ALSO
|
889 |
|
|
************************************************************************/
|
890 |
|
|
void mcapi_open_pktchan_recv_i(
|
891 |
|
|
MCAPI_OUT mcapi_pktchan_recv_hndl_t* recv_handle,
|
892 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
893 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
894 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
895 |
|
|
{
|
896 |
|
|
/* FIXME: (errata B2) shouldn't this function also check MCAPI_ENO_REQUEST, there are several
|
897 |
|
|
non-blocking functions that don't check for this - is that intentional or an
|
898 |
|
|
oversight in the spec? */
|
899 |
|
|
|
900 |
|
|
if (! valid_status_param(mcapi_status)) {
|
901 |
|
|
if (mcapi_status != NULL) {
|
902 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
903 |
|
|
}
|
904 |
|
|
} else {
|
905 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
906 |
|
|
if (! valid_request_param(request)) {
|
907 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
908 |
|
|
} else if (! mcapi_trans_valid_endpoint(receive_endpoint) ) {
|
909 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
910 |
|
|
} else if ( mcapi_trans_channel_type (receive_endpoint) == MCAPI_SCL_CHAN) {
|
911 |
|
|
*mcapi_status = MCAPI_ECHAN_TYPE;
|
912 |
|
|
} else if (! mcapi_trans_recv_endpoint (receive_endpoint)) {
|
913 |
|
|
*mcapi_status = MCAPI_EDIR;
|
914 |
|
|
} else if ( !mcapi_trans_connected (receive_endpoint)) {
|
915 |
|
|
*mcapi_status = MCAPI_ENOT_CONNECTED;
|
916 |
|
|
}
|
917 |
|
|
mcapi_trans_open_pktchan_recv_i(recv_handle,receive_endpoint,request,mcapi_status);
|
918 |
|
|
}
|
919 |
|
|
}
|
920 |
|
|
|
921 |
|
|
/***********************************************************************
|
922 |
|
|
NAME
|
923 |
|
|
mcapi_open_pktchan_send_i - Creates a typed, local representation of the
|
924 |
|
|
channel. It also provides synchronization for channel creation between two
|
925 |
|
|
endpoints. Opens are required on both receive and send endpoints.
|
926 |
|
|
DESCRIPTION
|
927 |
|
|
Opens the send end of a packet channel. The corresponding calls are
|
928 |
|
|
required on both sides for synchronization to ensure that the channel
|
929 |
|
|
has been created. It is a non-blocking function, and the send_handle is
|
930 |
|
|
filled in upon successful completion. No specific ordering of calls
|
931 |
|
|
between sender and receiver is required since the call is non-blocking.
|
932 |
|
|
send_endpoint is the endpoint associated with the channel. The open call
|
933 |
|
|
returns a typed, local handle for the connected endpoint that is used by
|
934 |
|
|
channel send operations.
|
935 |
|
|
RETURN VALUE
|
936 |
|
|
On success, a valid request is returned and *mcapi_status is set to
|
937 |
|
|
MCAPI_SUCCESS. On error, *mcapi_status is set to the appropriate error
|
938 |
|
|
defined below.
|
939 |
|
|
ERRORS
|
940 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
941 |
|
|
MCAPI_ECHAN_TYPE Attempt to open a packet channel on an endpoint that has
|
942 |
|
|
been connected with a different channel type.
|
943 |
|
|
MCAPI_EDIR Attempt to open a send handle on a port that was connected
|
944 |
|
|
as a receiver, or vice versa.
|
945 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
946 |
|
|
NOTE
|
947 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
948 |
|
|
query the status and mcapi_cancel() function to cancel the operation.
|
949 |
|
|
SEE ALSO
|
950 |
|
|
************************************************************************/
|
951 |
|
|
void mcapi_open_pktchan_send_i(
|
952 |
|
|
MCAPI_OUT mcapi_pktchan_send_hndl_t* send_handle,
|
953 |
|
|
MCAPI_IN mcapi_endpoint_t send_endpoint,
|
954 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
955 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
956 |
|
|
{
|
957 |
|
|
/* FIXME: (errata B2) shouldn't this function also check MCAPI_ENO_REQUEST? */
|
958 |
|
|
/* FIXME: (errata B4) shouldn't this function also check MCAPI_ENOT_CONNECTED? I do, but it's not in the spec */
|
959 |
|
|
|
960 |
|
|
if (! valid_status_param(mcapi_status)) {
|
961 |
|
|
if (mcapi_status != NULL) {
|
962 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
963 |
|
|
}
|
964 |
|
|
} else {
|
965 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
966 |
|
|
if (! valid_request_param(request)) {
|
967 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
968 |
|
|
} else if (! mcapi_trans_valid_endpoint(send_endpoint) ) {
|
969 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
970 |
|
|
} else if ( mcapi_trans_channel_type (send_endpoint) == MCAPI_SCL_CHAN){
|
971 |
|
|
*mcapi_status = MCAPI_ECHAN_TYPE;
|
972 |
|
|
} else if (! mcapi_trans_send_endpoint (send_endpoint)) {
|
973 |
|
|
*mcapi_status = MCAPI_EDIR;
|
974 |
|
|
} else if ( !mcapi_trans_connected (send_endpoint)) {
|
975 |
|
|
// TODO: the status is not updated before this?
|
976 |
|
|
// *mcapi_status = MCAPI_ENOT_CONNECTED;
|
977 |
|
|
}
|
978 |
|
|
mcapi_trans_open_pktchan_send_i(send_handle,send_endpoint,request,mcapi_status);
|
979 |
|
|
}
|
980 |
|
|
}
|
981 |
|
|
|
982 |
|
|
/***********************************************************************
|
983 |
|
|
NAME
|
984 |
|
|
mcapi_pktchan_send_i - sends a (connected) packet on a channel.
|
985 |
|
|
DESCRIPTION
|
986 |
|
|
Sends a packet on a connected channel. It is a non-blocking function,
|
987 |
|
|
and returns immediately. buffer is the application provided buffer and
|
988 |
|
|
size is the buffer size. request is the identifier used to determine if
|
989 |
|
|
the send operation has completed on the sending endpoint and the buffer
|
990 |
|
|
can be reused. While this method returns immediately, data transfer will
|
991 |
|
|
not complete until there is sufficient free space in the channels receive
|
992 |
|
|
buffer. A subsequent call to mcapi_wait() will block until space becomes
|
993 |
|
|
available at the receiver, the send operation has completed, and the send
|
994 |
|
|
buffer is available for reuse. Furthermore, this method will abandon the
|
995 |
|
|
send and return MCAPI_ENO_MEM if the system cannot allocate enough
|
996 |
|
|
memory at the send endpoint to queue up the outgoing packet.
|
997 |
|
|
RETURN VALUE
|
998 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
999 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
1000 |
|
|
ERRORS
|
1001 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1002 |
|
|
MCAPI_EPACK_LIMIT The packet size exceeds the maximum size
|
1003 |
|
|
allowed by the MCAPI implementation.
|
1004 |
|
|
MCAPI_ENO_BUFFER No more packet buffers available.
|
1005 |
|
|
MCAPI_ENO_REQUEST No more request handles available.
|
1006 |
|
|
MCAPI_ENO_MEM No memory available.
|
1007 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
1008 |
|
|
NOTE
|
1009 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any()
|
1010 |
|
|
functions to query the status and mcapi_cancel() function to cancel the
|
1011 |
|
|
operation.
|
1012 |
|
|
SEE ALSO
|
1013 |
|
|
************************************************************************/
|
1014 |
|
|
void mcapi_pktchan_send_i(
|
1015 |
|
|
MCAPI_IN mcapi_pktchan_send_hndl_t send_handle,
|
1016 |
|
|
MCAPI_IN void* buffer,
|
1017 |
|
|
MCAPI_IN size_t size,
|
1018 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1019 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1020 |
|
|
{
|
1021 |
|
|
/* MCAPI_ENO_BUFFER, MCAPI_ENO_REQUEST and MCAPI_ENO_MEM handled at the transport layer */
|
1022 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1023 |
|
|
if (mcapi_status != NULL) {
|
1024 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1025 |
|
|
}
|
1026 |
|
|
} else {
|
1027 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1028 |
|
|
if (! valid_request_param(request)) {
|
1029 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1030 |
|
|
} else if (! mcapi_trans_valid_pktchan_send_handle(send_handle) ) {
|
1031 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1032 |
|
|
} else if ( size > MAX_PKT_SIZE) {
|
1033 |
|
|
*mcapi_status = MCAPI_EPACK_LIMIT;
|
1034 |
|
|
}
|
1035 |
|
|
mcapi_trans_pktchan_send_i(send_handle,buffer,size,request,mcapi_status);
|
1036 |
|
|
}
|
1037 |
|
|
}
|
1038 |
|
|
|
1039 |
|
|
/***********************************************************************
|
1040 |
|
|
NAME
|
1041 |
|
|
mcapi_pktchan_send - sends a (connected) packet on a channel.
|
1042 |
|
|
DESCRIPTION
|
1043 |
|
|
Sends a packet on a connected channel. It is a blocking function, and
|
1044 |
|
|
returns once the buffer can be reused. send_handle is the efficient local
|
1045 |
|
|
send handle which represents the send endpoint associated with the channel.
|
1046 |
|
|
buffer is the application provided buffer and size is the buffer size. Since
|
1047 |
|
|
channels behave like FIFPs, this method will block if there is no free space
|
1048 |
|
|
in the channel's receive buffer. When sufficient space becomes available
|
1049 |
|
|
(due to receive calls), the funciton will complete.
|
1050 |
|
|
RETURN VALUE
|
1051 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
1052 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
1053 |
|
|
ERRORS
|
1054 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1055 |
|
|
MCAPI_EPACK_LIMIT The packet size exceeds the maximum size
|
1056 |
|
|
allowed by the MCAPI implementation.
|
1057 |
|
|
MCAPI_ENO_BUFFER No more packet buffers available.
|
1058 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1059 |
|
|
NOTE
|
1060 |
|
|
SEE ALSO
|
1061 |
|
|
************************************************************************/
|
1062 |
|
|
void mcapi_pktchan_send(
|
1063 |
|
|
MCAPI_IN mcapi_pktchan_send_hndl_t send_handle,
|
1064 |
|
|
MCAPI_IN void* buffer,
|
1065 |
|
|
MCAPI_IN size_t size,
|
1066 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1067 |
|
|
{
|
1068 |
|
|
|
1069 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1070 |
|
|
if (mcapi_status != NULL) {
|
1071 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1072 |
|
|
}
|
1073 |
|
|
} else {
|
1074 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1075 |
|
|
if (! mcapi_trans_valid_pktchan_send_handle(send_handle) ) {
|
1076 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1077 |
|
|
} else if ( size > MAX_PKT_SIZE) {
|
1078 |
|
|
*mcapi_status = MCAPI_EPACK_LIMIT;
|
1079 |
|
|
} else {
|
1080 |
|
|
if (!mcapi_trans_pktchan_send (send_handle,buffer,size)) {
|
1081 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1082 |
|
|
}
|
1083 |
|
|
}
|
1084 |
|
|
}
|
1085 |
|
|
}
|
1086 |
|
|
|
1087 |
|
|
|
1088 |
|
|
/***********************************************************************
|
1089 |
|
|
NAME
|
1090 |
|
|
mcapi_pktchan_recv_i - receives a (connected) packet on a channel.
|
1091 |
|
|
DESCRIPTION
|
1092 |
|
|
Receives a packet on a connected channel. It is a non-blocking function,
|
1093 |
|
|
and returns immediately. receive_handle is the receive endpoint. At some
|
1094 |
|
|
point in the future, when the receive operation completes, the buffer
|
1095 |
|
|
parameter is filled with the address of a system-supplied buffer containing
|
1096 |
|
|
the received packet. After the receive request has completed and the
|
1097 |
|
|
application is finished with buffer, buffer should be returned to the system
|
1098 |
|
|
by calling mcapi_pktchan_free(). request is the identifier used to determine
|
1099 |
|
|
if the receive operation has completed and buffer is ready for use; the
|
1100 |
|
|
mcapi_test() , mcapi_wait() or mcapi_wait_any() function will return the
|
1101 |
|
|
actual size of the received packet.
|
1102 |
|
|
RETURN VALUE
|
1103 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
1104 |
|
|
is set to the appropriate error defined below.
|
1105 |
|
|
ERRORS
|
1106 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1107 |
|
|
MCAPI_EPACKLIMIT The packet size exceeds the maximum size allowed by the
|
1108 |
|
|
MCAPI implementation.
|
1109 |
|
|
MCAPI_ENO_BUFFER No more packet buffers available.
|
1110 |
|
|
MCAPI_ENO_REQUEST No more request handles available.
|
1111 |
|
|
MCAPI_EPARAM Incorrect buffer, request and/or mcapi_status parameter.
|
1112 |
|
|
NOTE
|
1113 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
1114 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
1115 |
|
|
SEE ALSO
|
1116 |
|
|
************************************************************************/
|
1117 |
|
|
void mcapi_pktchan_recv_i(
|
1118 |
|
|
MCAPI_IN mcapi_pktchan_recv_hndl_t receive_handle,
|
1119 |
|
|
MCAPI_OUT void** buffer,
|
1120 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1121 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1122 |
|
|
{
|
1123 |
|
|
/* MCAPI_EPACKLIMIT, MCAPI_ENO_BUFFER, and MCAPI_ENO_REQUEST are handled at the transport layer */
|
1124 |
|
|
|
1125 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1126 |
|
|
if (mcapi_status != NULL) {
|
1127 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1128 |
|
|
}
|
1129 |
|
|
} else {
|
1130 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1131 |
|
|
if (! valid_request_param(request)) {
|
1132 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1133 |
|
|
} else if (! valid_buffer_param(buffer)) {
|
1134 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1135 |
|
|
} else if (! mcapi_trans_valid_pktchan_recv_handle(receive_handle) ) {
|
1136 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1137 |
|
|
}
|
1138 |
|
|
mcapi_trans_pktchan_recv_i (receive_handle,buffer,request,mcapi_status);
|
1139 |
|
|
}
|
1140 |
|
|
}
|
1141 |
|
|
|
1142 |
|
|
/***********************************************************************
|
1143 |
|
|
NAME
|
1144 |
|
|
mcapi_pktchan_recv - receives a data packet on a (connected) channel.
|
1145 |
|
|
DESCRIPTION
|
1146 |
|
|
Receives a packet on a connected channel. It is a blocking function, and
|
1147 |
|
|
returns when the data has been written to the buffer. receive_handle is
|
1148 |
|
|
the efficient local representation of the receive endpoint associated with
|
1149 |
|
|
the channel. buffer is filled with a pointer to the system-supplied
|
1150 |
|
|
receive buffer and received_size is filled with the size of the packet in
|
1151 |
|
|
that buffer. When the application finishes with buffer, it must return
|
1152 |
|
|
it to the system by calling mcapi_pktchan_free().
|
1153 |
|
|
RETURN VALUE
|
1154 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error,
|
1155 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
1156 |
|
|
ERRORS
|
1157 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1158 |
|
|
MCAPI_EPACKLIMIT The package size exceeds the maximum size allowed by
|
1159 |
|
|
the MCAPI implementation.
|
1160 |
|
|
MCAPI_ENO_BUFFER No more packet buffers available.
|
1161 |
|
|
MCAPI_EPARAM Incorrect buffer and/or mcapi_status parameter.
|
1162 |
|
|
NOTE
|
1163 |
|
|
SEE ALSO
|
1164 |
|
|
************************************************************************/
|
1165 |
|
|
void mcapi_pktchan_recv(
|
1166 |
|
|
MCAPI_IN mcapi_pktchan_recv_hndl_t receive_handle,
|
1167 |
|
|
MCAPI_OUT void** buffer,
|
1168 |
|
|
MCAPI_OUT size_t* received_size,
|
1169 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1170 |
|
|
{
|
1171 |
|
|
|
1172 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1173 |
|
|
if (mcapi_status != NULL) {
|
1174 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1175 |
|
|
}
|
1176 |
|
|
} else {
|
1177 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1178 |
|
|
if (! valid_buffer_param(buffer)) {
|
1179 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1180 |
|
|
} else if (! mcapi_trans_valid_pktchan_recv_handle(receive_handle) ) {
|
1181 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1182 |
|
|
} else {
|
1183 |
|
|
if (mcapi_trans_pktchan_recv (receive_handle,buffer,received_size)) {
|
1184 |
|
|
if ( *received_size > MAX_PKT_SIZE) {
|
1185 |
|
|
*mcapi_status = MCAPI_EPACK_LIMIT;
|
1186 |
|
|
}
|
1187 |
|
|
} else {
|
1188 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1189 |
|
|
}
|
1190 |
|
|
}
|
1191 |
|
|
}
|
1192 |
|
|
}
|
1193 |
|
|
|
1194 |
|
|
/***********************************************************************
|
1195 |
|
|
NAME
|
1196 |
|
|
mcapi_pktchan_available - checks if packets are available on a receive
|
1197 |
|
|
endpoint.
|
1198 |
|
|
DESCRIPTION
|
1199 |
|
|
Checks if packets are available on a receive endpoint. This function
|
1200 |
|
|
returns in a timely fashion. The number of available packets is defined
|
1201 |
|
|
as the number of receive operations that could be performed without
|
1202 |
|
|
blocking to wait for incoming data. receive_handle is the efficient
|
1203 |
|
|
local handle for the packet channel. The call only checks the
|
1204 |
|
|
availability of messages and does not de-queue them.
|
1205 |
|
|
RETURN VALUE
|
1206 |
|
|
On success, the number of available packets are returned and *mcapi_status
|
1207 |
|
|
is set to MCAPI_SUCCESS. On error, MCAPI_NULL is returned and *mcapi_status
|
1208 |
|
|
is set to the appropriate error defined below.
|
1209 |
|
|
ERRORS
|
1210 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1211 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1212 |
|
|
NOTE
|
1213 |
|
|
The status code must be checked to distinguish between no messages and
|
1214 |
|
|
an error condition.
|
1215 |
|
|
SEE ALSO
|
1216 |
|
|
************************************************************************/
|
1217 |
|
|
mcapi_uint_t mcapi_pktchan_available(
|
1218 |
|
|
MCAPI_IN mcapi_pktchan_recv_hndl_t receive_handle,
|
1219 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1220 |
|
|
{
|
1221 |
|
|
int num = 0;
|
1222 |
|
|
|
1223 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1224 |
|
|
if (mcapi_status != NULL) {
|
1225 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1226 |
|
|
}
|
1227 |
|
|
} else {
|
1228 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1229 |
|
|
if (! mcapi_trans_valid_pktchan_recv_handle(receive_handle) ) {
|
1230 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1231 |
|
|
} else {
|
1232 |
|
|
num = mcapi_trans_pktchan_available(receive_handle);
|
1233 |
|
|
}
|
1234 |
|
|
}
|
1235 |
|
|
return num;
|
1236 |
|
|
}
|
1237 |
|
|
|
1238 |
|
|
/***********************************************************************
|
1239 |
|
|
NAME
|
1240 |
|
|
mcapi_pktchan_free - releases a packet buffer obtained from a
|
1241 |
|
|
mcapi_pktchan_recv() call.
|
1242 |
|
|
DESCRIPTION
|
1243 |
|
|
When a user is finished with a packet buffer obtained from
|
1244 |
|
|
mcapi_pktchan_recv_i() or mcapi_pktchan_recv(), they should invoke this
|
1245 |
|
|
function to return the buffer to the system. Buffers can be freed in any
|
1246 |
|
|
order. This function is guaranteed to return in a timely fashion.
|
1247 |
|
|
RETURN VALUE
|
1248 |
|
|
On success *mcapi_status is set to MCAPI_SUCCESS. On error, *mcapi_status
|
1249 |
|
|
is set to the appropriate error defined below.
|
1250 |
|
|
ERRORS
|
1251 |
|
|
MCAPI_ENOT_VALID_BUF Argument is not a valid buffer descriptor.
|
1252 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1253 |
|
|
NOTE
|
1254 |
|
|
SEE ALSO
|
1255 |
|
|
mcapi_pktchan_recv(), mcapi_pktchan_recv_i()
|
1256 |
|
|
************************************************************************/
|
1257 |
|
|
void mcapi_pktchan_free(
|
1258 |
|
|
MCAPI_IN void* buffer,
|
1259 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1260 |
|
|
{
|
1261 |
|
|
|
1262 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1263 |
|
|
if (mcapi_status != NULL) {
|
1264 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1265 |
|
|
}
|
1266 |
|
|
} else {
|
1267 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1268 |
|
|
if (!mcapi_trans_pktchan_free (buffer)) {
|
1269 |
|
|
*mcapi_status = MCAPI_ENOT_VALID_BUF;
|
1270 |
|
|
}
|
1271 |
|
|
}
|
1272 |
|
|
}
|
1273 |
|
|
|
1274 |
|
|
|
1275 |
|
|
/***********************************************************************
|
1276 |
|
|
NAME
|
1277 |
|
|
mcapi_packetchan_recv_close_i - closes channel on a receive endpoint.
|
1278 |
|
|
DESCRIPTION
|
1279 |
|
|
Closes the receive side of a channel. The sender makes the send-side
|
1280 |
|
|
call and the receiver makes the receive-side call. The corresponding
|
1281 |
|
|
calls are required on both sides to ensure that the channel has been
|
1282 |
|
|
properly closed. It is a non-blocking function, and returns immediately.
|
1283 |
|
|
receive_handle is the receive endpoint identifier. All pending packets
|
1284 |
|
|
are discarded, and any attempt to send more packets will give an error.
|
1285 |
|
|
RETURN VALUE
|
1286 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error
|
1287 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
1288 |
|
|
ERRORS
|
1289 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1290 |
|
|
MCAPI_ENOT_OPEN The endpoint is not open.
|
1291 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
1292 |
|
|
NOTE
|
1293 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
1294 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
1295 |
|
|
SEE ALSO
|
1296 |
|
|
************************************************************************/
|
1297 |
|
|
void mcapi_pktchan_recv_close_i(
|
1298 |
|
|
MCAPI_IN mcapi_pktchan_recv_hndl_t receive_handle,
|
1299 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1300 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1301 |
|
|
{
|
1302 |
|
|
|
1303 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1304 |
|
|
if (mcapi_status != NULL) {
|
1305 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1306 |
|
|
}
|
1307 |
|
|
} else {
|
1308 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1309 |
|
|
if (! valid_request_param(request)) {
|
1310 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1311 |
|
|
} else if (! mcapi_trans_valid_pktchan_recv_handle(receive_handle) ) {
|
1312 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1313 |
|
|
} else if (! mcapi_trans_pktchan_recv_isopen (receive_handle)) {
|
1314 |
|
|
*mcapi_status = MCAPI_ENOT_OPEN;
|
1315 |
|
|
}
|
1316 |
|
|
mcapi_trans_pktchan_recv_close_i (receive_handle,request,mcapi_status);
|
1317 |
|
|
}
|
1318 |
|
|
}
|
1319 |
|
|
|
1320 |
|
|
|
1321 |
|
|
/***********************************************************************
|
1322 |
|
|
NAME
|
1323 |
|
|
mcapi_pktchan_send_close_i - closes channel on a send endpoint.
|
1324 |
|
|
DESCRIPTION
|
1325 |
|
|
Closes the send side of a channel. The sender makes the send-side call
|
1326 |
|
|
and the receiver makes the receive-side call. The corresponding calls
|
1327 |
|
|
are required on both sides to ensure that the channel has been properly
|
1328 |
|
|
closed. It is a non-blocking function, and returns immediately.
|
1329 |
|
|
send_handle is the send endpoint identifier. Pending packets at the
|
1330 |
|
|
receiver are not discarded.
|
1331 |
|
|
RETURN VALUE
|
1332 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error *mcapi_status
|
1333 |
|
|
is set to the appropriate error defined below.
|
1334 |
|
|
ERRORS
|
1335 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1336 |
|
|
MCAPI_ENOT_OPEN The endpoint is not open.
|
1337 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
1338 |
|
|
NOTE
|
1339 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
1340 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
1341 |
|
|
SEE ALSO
|
1342 |
|
|
************************************************************************/
|
1343 |
|
|
void mcapi_pktchan_send_close_i(
|
1344 |
|
|
MCAPI_IN mcapi_pktchan_send_hndl_t send_handle,
|
1345 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1346 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1347 |
|
|
{
|
1348 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1349 |
|
|
if (mcapi_status != NULL) {
|
1350 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1351 |
|
|
}
|
1352 |
|
|
} else {
|
1353 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1354 |
|
|
if (! mcapi_trans_valid_pktchan_recv_handle(send_handle) ) {
|
1355 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1356 |
|
|
} else if (! mcapi_trans_pktchan_send_isopen (send_handle)) {
|
1357 |
|
|
*mcapi_status = MCAPI_ENOT_OPEN;
|
1358 |
|
|
} if (! valid_request_param(request)) {
|
1359 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1360 |
|
|
}
|
1361 |
|
|
mcapi_trans_pktchan_send_close_i (send_handle,request,mcapi_status);
|
1362 |
|
|
}
|
1363 |
|
|
}
|
1364 |
|
|
|
1365 |
|
|
|
1366 |
|
|
/***********************************************************************
|
1367 |
|
|
NAME
|
1368 |
|
|
mcapi_connect_sclchan_i - connects a pair of scalar channel endpoints.
|
1369 |
|
|
DESCRIPTION
|
1370 |
|
|
Connects a pair of endpoints. The connect operation can be performed by
|
1371 |
|
|
the sender, the receiver, or by a third party. The connect can happen
|
1372 |
|
|
once at the start of the program, or dynamically at run time.
|
1373 |
|
|
mcapi_connect_sclchan_i() is a non-blocking function. Synchronization
|
1374 |
|
|
to ensure the channel has been created is provided by the open call
|
1375 |
|
|
discussed later.
|
1376 |
|
|
Note that this function behaves like the packetchannel connect call.
|
1377 |
|
|
Attempts to make multiple connections to a single endpoint will be
|
1378 |
|
|
detected as errors. The type of channel connected to an endpoint must
|
1379 |
|
|
match the type of open call invoked by that endpoint; the open
|
1380 |
|
|
function will return an error if the opened channel type does not
|
1381 |
|
|
match the connected channel type, or if the attributes of the endpoints
|
1382 |
|
|
are incompatible.
|
1383 |
|
|
It is an error to attempt a connection between endpoints whose
|
1384 |
|
|
attributes are set in an incompatible way (for now, whether attributes
|
1385 |
|
|
are compatible or not is implementation defined). It is also an error
|
1386 |
|
|
to attempt to change the attributes of endpoints that are connected.
|
1387 |
|
|
RETURN VALUE
|
1388 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error
|
1389 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
1390 |
|
|
ERRORS
|
1391 |
|
|
MCAPI_ENOT_ENDP Argument is not a valid endpoint descriptor.
|
1392 |
|
|
MCAPI_ECONNECTED A channel connection has already been established for
|
1393 |
|
|
one or both of the specified endpoints.
|
1394 |
|
|
MCAPI_EATTR_INCOMP Connection of endpoints with incompatible attributes
|
1395 |
|
|
not allowed.
|
1396 |
|
|
MCAPI_ENO_REQUEST No more request handles available.
|
1397 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
1398 |
|
|
NOTE
|
1399 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
1400 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
1401 |
|
|
SEE ALSO
|
1402 |
|
|
************************************************************************/
|
1403 |
|
|
void mcapi_connect_sclchan_i(
|
1404 |
|
|
MCAPI_IN mcapi_endpoint_t send_endpoint,
|
1405 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
1406 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1407 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1408 |
|
|
{
|
1409 |
|
|
|
1410 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1411 |
|
|
if (mcapi_status != NULL) {
|
1412 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1413 |
|
|
}
|
1414 |
|
|
} else {
|
1415 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1416 |
|
|
if (! valid_request_param(request)) {
|
1417 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1418 |
|
|
} else if ( ! mcapi_trans_valid_endpoints(send_endpoint,receive_endpoint)) {
|
1419 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
1420 |
|
|
} else if (( mcapi_trans_channel_connected (send_endpoint)) ||
|
1421 |
|
|
( mcapi_trans_channel_connected (receive_endpoint))) {
|
1422 |
|
|
*mcapi_status = MCAPI_ECONNECTED;
|
1423 |
|
|
} else if (! mcapi_trans_compatible_endpoint_attributes (send_endpoint,receive_endpoint)) {
|
1424 |
|
|
*mcapi_status = MCAPI_EATTR_INCOMP;
|
1425 |
|
|
}
|
1426 |
|
|
mcapi_trans_connect_sclchan_i (send_endpoint,receive_endpoint,request,mcapi_status);
|
1427 |
|
|
}
|
1428 |
|
|
}
|
1429 |
|
|
|
1430 |
|
|
|
1431 |
|
|
/***********************************************************************
|
1432 |
|
|
NAME
|
1433 |
|
|
mcapi_open_sclchan_recv_i - Creates a typed, local representation of a
|
1434 |
|
|
scalar channel.
|
1435 |
|
|
DESCRIPTION
|
1436 |
|
|
Opens the receive end of a scalar channel. It also provides
|
1437 |
|
|
synchronization for channel creation between two endpoints. The
|
1438 |
|
|
corresponding calls are required on both sides to synchronize the
|
1439 |
|
|
endpoints. It is a non-blocking function, and the recv_handle is filled
|
1440 |
|
|
in upon successful completion. No specific ordering of calls between
|
1441 |
|
|
sender and receiver is required since the call is non-blocking.
|
1442 |
|
|
receive_endpoint is the local endpoint identifier. The call returns a
|
1443 |
|
|
local handle for the connected channel.
|
1444 |
|
|
RETURN VALUE
|
1445 |
|
|
On success, a channel handle is returned by reference and *mcapi_status
|
1446 |
|
|
is set to MCAPI_SUCCESS. On error, *mcapi_status is set to the
|
1447 |
|
|
appropriate error defined below.
|
1448 |
|
|
ERRORS
|
1449 |
|
|
MCAPI_ENOT_ENDP Argument is not an endpoint descriptor.
|
1450 |
|
|
MCAPI_ENOT_CONNECTED The channel is not connected (cannot be opened).
|
1451 |
|
|
MCAPI_ECHAN_TYPE Attempt to open a packet channel on an endpoint that
|
1452 |
|
|
has been connected with a different channel type.
|
1453 |
|
|
MCAPI_EDIR Attempt to open a send handle on a port that was connected
|
1454 |
|
|
as a receiver, or vice versa.
|
1455 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
1456 |
|
|
NOTE
|
1457 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
1458 |
|
|
query the status and mcapi_cancel() function to cancel the operation.
|
1459 |
|
|
SEE ALSO
|
1460 |
|
|
************************************************************************/
|
1461 |
|
|
void mcapi_open_sclchan_recv_i(
|
1462 |
|
|
MCAPI_OUT mcapi_sclchan_recv_hndl_t* receive_handle,
|
1463 |
|
|
MCAPI_IN mcapi_endpoint_t receive_endpoint,
|
1464 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1465 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1466 |
|
|
{
|
1467 |
|
|
/* FIXME: (errata B2) shouldn't this function also check MCAPI_ENO_REQUEST? */
|
1468 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1469 |
|
|
if (mcapi_status != NULL) {
|
1470 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1471 |
|
|
}
|
1472 |
|
|
} else {
|
1473 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1474 |
|
|
if (! valid_request_param(request)) {
|
1475 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1476 |
|
|
} else if (! mcapi_trans_valid_endpoint(receive_endpoint) ) {
|
1477 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
1478 |
|
|
} else if ( mcapi_trans_channel_type (receive_endpoint) == MCAPI_PKT_CHAN) {
|
1479 |
|
|
*mcapi_status = MCAPI_ECHAN_TYPE;
|
1480 |
|
|
} else if (! mcapi_trans_recv_endpoint (receive_endpoint)) {
|
1481 |
|
|
*mcapi_status = MCAPI_EDIR;
|
1482 |
|
|
} else if ( !mcapi_trans_connected (receive_endpoint)) {
|
1483 |
|
|
*mcapi_status = MCAPI_ENOT_CONNECTED;
|
1484 |
|
|
}
|
1485 |
|
|
mcapi_trans_open_sclchan_recv_i(receive_handle,receive_endpoint,request,mcapi_status);
|
1486 |
|
|
}
|
1487 |
|
|
}
|
1488 |
|
|
|
1489 |
|
|
/***********************************************************************
|
1490 |
|
|
NAME
|
1491 |
|
|
mcapi_open_sclchan_send_i - Creates a typed, local representation of a
|
1492 |
|
|
scalar channel.
|
1493 |
|
|
DESCRIPTION
|
1494 |
|
|
Opens the send end of a scalar channel. . It also provides
|
1495 |
|
|
synchronization for channel creation between two endpoints. The
|
1496 |
|
|
corresponding calls are required on both sides to synchronize the
|
1497 |
|
|
endpoints. It is a non-blocking function, and the send_handle is filled
|
1498 |
|
|
in upon successful completion. No specific ordering of calls between
|
1499 |
|
|
sender and receiver is required since the call is non-blocking.
|
1500 |
|
|
send_endpoint is the local endpoint identifier. The call returns a
|
1501 |
|
|
local handle for connected channel.
|
1502 |
|
|
RETURN VALUE
|
1503 |
|
|
On success, a channel handle is returned by reference and *mcapi_status
|
1504 |
|
|
is set to MCAPI_SUCCESS. On error, *mcapi_status is set to the appropriate
|
1505 |
|
|
error defined below.
|
1506 |
|
|
ERRORS
|
1507 |
|
|
MCAPI_ENOT_ENDP Argument is not an endpoint descriptor.
|
1508 |
|
|
MCAPI_ECHAN_TYPE Attempt to open a packet channel on an endpoint that has
|
1509 |
|
|
been connected with a different channel type.
|
1510 |
|
|
MCAPI_EDIR Attempt to open a send handle on a port that was connected as
|
1511 |
|
|
a receiver, or vice versa.
|
1512 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
1513 |
|
|
NOTE
|
1514 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
1515 |
|
|
query the status and mcapi_cancel() function to cancel the operation.
|
1516 |
|
|
SEE ALSO
|
1517 |
|
|
************************************************************************/
|
1518 |
|
|
void mcapi_open_sclchan_send_i(
|
1519 |
|
|
MCAPI_OUT mcapi_sclchan_send_hndl_t* send_handle,
|
1520 |
|
|
MCAPI_IN mcapi_endpoint_t send_endpoint,
|
1521 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
1522 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1523 |
|
|
{
|
1524 |
|
|
|
1525 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1526 |
|
|
if (mcapi_status != NULL) {
|
1527 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1528 |
|
|
}
|
1529 |
|
|
} else {
|
1530 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1531 |
|
|
if (! valid_request_param(request)) {
|
1532 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1533 |
|
|
} else if (! mcapi_trans_valid_endpoint(send_endpoint) ) {
|
1534 |
|
|
*mcapi_status = MCAPI_ENOT_ENDP;
|
1535 |
|
|
} else if (mcapi_trans_channel_type (send_endpoint) == MCAPI_PKT_CHAN){
|
1536 |
|
|
*mcapi_status = MCAPI_ECHAN_TYPE;
|
1537 |
|
|
} else if (! mcapi_trans_send_endpoint (send_endpoint)) {
|
1538 |
|
|
*mcapi_status = MCAPI_EDIR;
|
1539 |
|
|
} else if ( !mcapi_trans_connected (send_endpoint)) {
|
1540 |
|
|
*mcapi_status = MCAPI_ENOT_CONNECTED;
|
1541 |
|
|
}
|
1542 |
|
|
/* FIXME:(errata B2) shouldn't this function also check MCAPI_ENO_REQUEST */
|
1543 |
|
|
/* FIXME: (errata B4) shouldn't this function also check MCAPI_ENOT_CONNECTED.
|
1544 |
|
|
I do, but it's not in the spec */
|
1545 |
|
|
mcapi_trans_open_sclchan_send_i(send_handle,send_endpoint,request,mcapi_status);
|
1546 |
|
|
}
|
1547 |
|
|
}
|
1548 |
|
|
|
1549 |
|
|
/***********************************************************************
|
1550 |
|
|
NAME
|
1551 |
|
|
mcapi_sclchan_send_uint64 - sends a (connected) 64-bit scalar on a channel.
|
1552 |
|
|
DESCRIPTION
|
1553 |
|
|
Sends a scalar on a connected channel. It is a blocking function, and
|
1554 |
|
|
returns immediately unless the buffer is full. send_handle is the send
|
1555 |
|
|
endpoint identifier. dataword is the scalar. Since channels behave like
|
1556 |
|
|
FIFOs, this method will block if there is no free space in the channel's
|
1557 |
|
|
receive buffer. When sufficient space becomes available
|
1558 |
|
|
(due to receive calls), the function will complete.
|
1559 |
|
|
RETURN VALUE
|
1560 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error *mcapi_status is
|
1561 |
|
|
set to the appropriate error defined below. Optionally, implementations may
|
1562 |
|
|
choose to always set *mcapi_status to MCAPI_SUCCESS for performance reasons.
|
1563 |
|
|
ERRORS
|
1564 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1565 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1566 |
|
|
NOTE
|
1567 |
|
|
SEE ALSO
|
1568 |
|
|
************************************************************************/
|
1569 |
|
|
void mcapi_sclchan_send_uint64(
|
1570 |
|
|
MCAPI_IN mcapi_sclchan_send_hndl_t send_handle,
|
1571 |
|
|
MCAPI_IN mcapi_uint64_t dataword,
|
1572 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1573 |
|
|
{
|
1574 |
|
|
/* FIXME: (errata B3) this function needs to check MCAPI_ENO_BUFFER */
|
1575 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1576 |
|
|
if (mcapi_status != NULL) {
|
1577 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1578 |
|
|
}
|
1579 |
|
|
} else {
|
1580 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1581 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1582 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1583 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,dataword,8)) {
|
1584 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER; /* MR: added this */
|
1585 |
|
|
}
|
1586 |
|
|
}
|
1587 |
|
|
}
|
1588 |
|
|
|
1589 |
|
|
|
1590 |
|
|
|
1591 |
|
|
|
1592 |
|
|
/***********************************************************************
|
1593 |
|
|
NAME
|
1594 |
|
|
mcapi_sclchan_send_uint32 - sends a (connected) 32-bit scalar on a
|
1595 |
|
|
channel.
|
1596 |
|
|
DESCRIPTION
|
1597 |
|
|
Sends a scalar on a connected channel. It is a blocking function, and
|
1598 |
|
|
returns immediately unless the buffer is full. send_handle is the send
|
1599 |
|
|
endpoint identifier. dataword is the scalar. Since channels behave like
|
1600 |
|
|
FIFOs, this method will block if there is no free space in the channel's
|
1601 |
|
|
receive buffer. When sufficient space becomes available
|
1602 |
|
|
(due to receive calls), the function will complete.
|
1603 |
|
|
RETURN VALUE
|
1604 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error
|
1605 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
1606 |
|
|
Optionally, implementations may choose to always set *mcapi_status to
|
1607 |
|
|
MCAPI_SUCCESS for performance reasons.
|
1608 |
|
|
ERRORS
|
1609 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1610 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1611 |
|
|
NOTE
|
1612 |
|
|
SEE ALSO
|
1613 |
|
|
************************************************************************/
|
1614 |
|
|
void mcapi_sclchan_send_uint32(
|
1615 |
|
|
MCAPI_IN mcapi_sclchan_send_hndl_t send_handle,
|
1616 |
|
|
MCAPI_IN mcapi_uint32_t dataword,
|
1617 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1618 |
|
|
{
|
1619 |
|
|
/* FIXME: (errata B3) this function needs to check MCAPI_ENO_BUFFER */
|
1620 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1621 |
|
|
if (mcapi_status != NULL) {
|
1622 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1623 |
|
|
}
|
1624 |
|
|
} else {
|
1625 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1626 |
|
|
#ifdef __TCE__
|
1627 |
|
|
uint64_t data64;
|
1628 |
|
|
data64.lo = dataword;
|
1629 |
|
|
|
1630 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1631 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1632 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,data64,4)) {
|
1633 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1634 |
|
|
}
|
1635 |
|
|
#else
|
1636 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1637 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1638 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,dataword,4)) {
|
1639 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1640 |
|
|
}
|
1641 |
|
|
#endif
|
1642 |
|
|
}
|
1643 |
|
|
}
|
1644 |
|
|
|
1645 |
|
|
/***********************************************************************
|
1646 |
|
|
NAME
|
1647 |
|
|
mcapi_sclchan_send_uint16 - sends a (connected) 16-bit scalar on a channel.
|
1648 |
|
|
DESCRIPTION
|
1649 |
|
|
Sends a scalar on a connected channel. It is a blocking function, and
|
1650 |
|
|
returns immediately unless the buffer is full. send_handle is the send
|
1651 |
|
|
endpoint identifier. dataword is the scalar. Since channels behave like
|
1652 |
|
|
FIFOs, this method will block if there is no free space in the channel's
|
1653 |
|
|
receive buffer. When sufficient space becomes available (due to receive
|
1654 |
|
|
calls), the function will complete.
|
1655 |
|
|
RETURN VALUE
|
1656 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error *mcapi_status
|
1657 |
|
|
is set to the appropriate error defined below. Optionally, implementations
|
1658 |
|
|
may choose to always set *mcapi_status to MCAPI_SUCCESS for performance
|
1659 |
|
|
reasons.
|
1660 |
|
|
ERRORS
|
1661 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1662 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1663 |
|
|
NOTE
|
1664 |
|
|
SEE ALSO
|
1665 |
|
|
************************************************************************/
|
1666 |
|
|
void mcapi_sclchan_send_uint16(
|
1667 |
|
|
MCAPI_IN mcapi_sclchan_send_hndl_t send_handle,
|
1668 |
|
|
MCAPI_IN mcapi_uint16_t dataword,
|
1669 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1670 |
|
|
{
|
1671 |
|
|
/* FIXME: (errata B3) this function needs to check MCAPI_ENO_BUFFER */
|
1672 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1673 |
|
|
if (mcapi_status != NULL) {
|
1674 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1675 |
|
|
}
|
1676 |
|
|
} else {
|
1677 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1678 |
|
|
|
1679 |
|
|
#ifdef __TCE__
|
1680 |
|
|
uint64_t data64;
|
1681 |
|
|
data64.lo = dataword;
|
1682 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1683 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1684 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,data64,2)) {
|
1685 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1686 |
|
|
}
|
1687 |
|
|
#else
|
1688 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1689 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1690 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,dataword,2)) {
|
1691 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1692 |
|
|
}
|
1693 |
|
|
#endif
|
1694 |
|
|
}
|
1695 |
|
|
}
|
1696 |
|
|
|
1697 |
|
|
|
1698 |
|
|
/***********************************************************************
|
1699 |
|
|
NAME
|
1700 |
|
|
mcapi_sclchan_send_uint8 - sends a (connected) 8-bit scalar on a channel.
|
1701 |
|
|
DESCRIPTION
|
1702 |
|
|
Sends a scalar on a connected channel. It is a blocking function, and
|
1703 |
|
|
returns immediately unless the buffer is full. send_handle is the send
|
1704 |
|
|
endpoint identifier. dataword is the scalar. Since channels behave like
|
1705 |
|
|
FIFOs, this method will block if there is no free space in the channel's
|
1706 |
|
|
receive buffer. When sufficient space becomes available (due to receive
|
1707 |
|
|
calls), the function will complete.
|
1708 |
|
|
RETURN VALUE
|
1709 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error *mcapi_status
|
1710 |
|
|
is set to the appropriate error defined below. Optionally,
|
1711 |
|
|
implementations may choose to always set *mcapi_status to MCAPI_SUCCESS
|
1712 |
|
|
for performance reasons.
|
1713 |
|
|
ERRORS
|
1714 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1715 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1716 |
|
|
NOTE
|
1717 |
|
|
SEE ALSO
|
1718 |
|
|
************************************************************************/
|
1719 |
|
|
void mcapi_sclchan_send_uint8(
|
1720 |
|
|
MCAPI_IN mcapi_sclchan_send_hndl_t send_handle,
|
1721 |
|
|
MCAPI_IN mcapi_uint8_t dataword,
|
1722 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1723 |
|
|
{
|
1724 |
|
|
/* FIXME: (errata B3) this function needs to check MCAPI_ENO_BUFFER */
|
1725 |
|
|
|
1726 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1727 |
|
|
if (mcapi_status != NULL) {
|
1728 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1729 |
|
|
}
|
1730 |
|
|
} else {
|
1731 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1732 |
|
|
|
1733 |
|
|
#ifdef __TCE__
|
1734 |
|
|
uint64_t data64;
|
1735 |
|
|
data64.lo = dataword;
|
1736 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1737 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1738 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,data64,1)) {
|
1739 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1740 |
|
|
}
|
1741 |
|
|
#else
|
1742 |
|
|
if (! mcapi_trans_valid_sclchan_send_handle(send_handle) ) {
|
1743 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1744 |
|
|
} else if (!mcapi_trans_sclchan_send (send_handle,dataword,1)) {
|
1745 |
|
|
*mcapi_status = MCAPI_ENO_BUFFER;
|
1746 |
|
|
}
|
1747 |
|
|
#endif
|
1748 |
|
|
}
|
1749 |
|
|
}
|
1750 |
|
|
|
1751 |
|
|
/***********************************************************************
|
1752 |
|
|
NAME
|
1753 |
|
|
mcapi_sclchan_recv_uint64 - receives a (connected) 64-bit scalar on a
|
1754 |
|
|
channel.
|
1755 |
|
|
DESCRIPTION
|
1756 |
|
|
Receives a scalar on a connected channel. It is a blocking function,
|
1757 |
|
|
and returns when a scalar is available. receive_handle is the receive
|
1758 |
|
|
endpoint identifier.
|
1759 |
|
|
RETURN VALUE
|
1760 |
|
|
On success, a value of type uint64_t is returned and *mcapi_status is
|
1761 |
|
|
set to MCAPI_SUCCESS. On error, the return value is undefined and
|
1762 |
|
|
*mcapi_status is set to the appropriate error defined below. Optionally,
|
1763 |
|
|
implementations may choose to always set *mcapi_status to MCAPI_SUCCESS
|
1764 |
|
|
for performance reasons.
|
1765 |
|
|
ERRORS
|
1766 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1767 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1768 |
|
|
MCAPI_ESCL_SIZE Incorrect scalar size.
|
1769 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1770 |
|
|
NOTE
|
1771 |
|
|
The receive scalar size must match the send size.
|
1772 |
|
|
SEE ALSO
|
1773 |
|
|
************************************************************************/
|
1774 |
|
|
mcapi_uint64_t mcapi_sclchan_recv_uint64(
|
1775 |
|
|
MCAPI_IN mcapi_sclchan_recv_hndl_t receive_handle,
|
1776 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1777 |
|
|
{
|
1778 |
|
|
uint32_t exp_size = 8;
|
1779 |
|
|
#ifdef __TCE__
|
1780 |
|
|
uint64_t dataword;
|
1781 |
|
|
dataword.lo = 0;
|
1782 |
|
|
dataword.hi = 0;
|
1783 |
|
|
#else
|
1784 |
|
|
uint64_t dataword = 0;
|
1785 |
|
|
#endif
|
1786 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1787 |
|
|
if (mcapi_status != NULL) {
|
1788 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1789 |
|
|
}
|
1790 |
|
|
} else {
|
1791 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1792 |
|
|
if (! mcapi_trans_valid_sclchan_recv_handle(receive_handle) ) {
|
1793 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1794 |
|
|
}else if (! mcapi_trans_sclchan_recv (receive_handle,&dataword,exp_size)) {
|
1795 |
|
|
*mcapi_status = MCAPI_ESCL_SIZE;
|
1796 |
|
|
}
|
1797 |
|
|
}
|
1798 |
|
|
return dataword;
|
1799 |
|
|
}
|
1800 |
|
|
|
1801 |
|
|
/***********************************************************************
|
1802 |
|
|
NAME
|
1803 |
|
|
mcapi_sclchan_recv_uint32 - receives a 32-bit scalar on a (connected)
|
1804 |
|
|
channel.
|
1805 |
|
|
DESCRIPTION
|
1806 |
|
|
Receives a scalar on a connected channel. It is a blocking function,
|
1807 |
|
|
and returns when a scalar is available. receive_handle is the receive
|
1808 |
|
|
endpoint identifier.
|
1809 |
|
|
RETURN VALUE
|
1810 |
|
|
On success, a value of type uint32_t is returned and *mcapi_status is
|
1811 |
|
|
set to MCAPI_SUCCESS. On error, the return value is undefined and
|
1812 |
|
|
*mcapi_status is set to the appropriate error defined below. Optionally,
|
1813 |
|
|
implementations may choose to always set *mcapi_status to MCAPI_SUCCESS
|
1814 |
|
|
for performance reasons.
|
1815 |
|
|
ERRORS
|
1816 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1817 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1818 |
|
|
MCAPI_ESCL_SIZE Incorrect scalar size.
|
1819 |
|
|
|
1820 |
|
|
NOTE
|
1821 |
|
|
The receive scalar size must match the send size.
|
1822 |
|
|
SEE ALSO
|
1823 |
|
|
************************************************************************/
|
1824 |
|
|
mcapi_uint32_t mcapi_sclchan_recv_uint32(
|
1825 |
|
|
MCAPI_IN mcapi_sclchan_recv_hndl_t receive_handle,
|
1826 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1827 |
|
|
{
|
1828 |
|
|
uint32_t exp_size = 4;
|
1829 |
|
|
#ifdef __TCE__
|
1830 |
|
|
uint64_t dataword;
|
1831 |
|
|
dataword.lo = 0;
|
1832 |
|
|
dataword.hi = 0;
|
1833 |
|
|
#else
|
1834 |
|
|
uint64_t dataword = 0;
|
1835 |
|
|
#endif
|
1836 |
|
|
|
1837 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1838 |
|
|
if (mcapi_status != NULL) {
|
1839 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1840 |
|
|
}
|
1841 |
|
|
} else {
|
1842 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1843 |
|
|
if (! mcapi_trans_valid_sclchan_recv_handle(receive_handle) ) {
|
1844 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1845 |
|
|
} else if (! mcapi_trans_sclchan_recv (receive_handle,&dataword,exp_size)) {
|
1846 |
|
|
*mcapi_status = MCAPI_ESCL_SIZE;
|
1847 |
|
|
}
|
1848 |
|
|
}
|
1849 |
|
|
#ifdef __TCE__
|
1850 |
|
|
return dataword.lo;
|
1851 |
|
|
#else
|
1852 |
|
|
return dataword;
|
1853 |
|
|
#endif
|
1854 |
|
|
}
|
1855 |
|
|
|
1856 |
|
|
|
1857 |
|
|
/***********************************************************************
|
1858 |
|
|
NAME
|
1859 |
|
|
mcapi_sclchan_recv_uint16 - receives a 16-bit scalar on a (connected)
|
1860 |
|
|
channel.
|
1861 |
|
|
DESCRIPTION
|
1862 |
|
|
Receives a scalar on a connected channel. It is a blocking function, and
|
1863 |
|
|
returns when a scalar is available. receive_handle is the receive endpoint
|
1864 |
|
|
identifier.
|
1865 |
|
|
RETURN VALUE
|
1866 |
|
|
On success, a value of type uint16_t is returned and *mcapi_status is
|
1867 |
|
|
set to MCAPI_SUCCESS. On error, the return value is undefined and
|
1868 |
|
|
*mcapi_status is set to the appropriate error defined below. Optionally,
|
1869 |
|
|
implementations may choose to always set *mcapi_status to MCAPI_SUCCESS
|
1870 |
|
|
for performance reasons.
|
1871 |
|
|
ERRORS
|
1872 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1873 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1874 |
|
|
MCAPI_ESCL_SIZE Incorrect scalar size.
|
1875 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1876 |
|
|
NOTE
|
1877 |
|
|
The receive scalar size must match the send size.
|
1878 |
|
|
SEE ALSO
|
1879 |
|
|
************************************************************************/
|
1880 |
|
|
mcapi_uint16_t mcapi_sclchan_recv_uint16(
|
1881 |
|
|
MCAPI_IN mcapi_sclchan_recv_hndl_t receive_handle,
|
1882 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1883 |
|
|
{
|
1884 |
|
|
uint32_t exp_size = 2;
|
1885 |
|
|
#ifdef __TCE__
|
1886 |
|
|
uint64_t dataword;
|
1887 |
|
|
dataword.lo = 0;
|
1888 |
|
|
dataword.hi = 0;
|
1889 |
|
|
#else
|
1890 |
|
|
uint64_t dataword = 0;
|
1891 |
|
|
#endif
|
1892 |
|
|
|
1893 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1894 |
|
|
if (mcapi_status != NULL) {
|
1895 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1896 |
|
|
}
|
1897 |
|
|
} else {
|
1898 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1899 |
|
|
if (! mcapi_trans_valid_sclchan_recv_handle(receive_handle) ) {
|
1900 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1901 |
|
|
} else if (! mcapi_trans_sclchan_recv (receive_handle,&dataword,exp_size)) {
|
1902 |
|
|
*mcapi_status = MCAPI_ESCL_SIZE;
|
1903 |
|
|
}
|
1904 |
|
|
}
|
1905 |
|
|
#ifdef __TCE__
|
1906 |
|
|
return dataword.lo;
|
1907 |
|
|
#else
|
1908 |
|
|
return dataword;
|
1909 |
|
|
#endif
|
1910 |
|
|
}
|
1911 |
|
|
|
1912 |
|
|
|
1913 |
|
|
/***********************************************************************
|
1914 |
|
|
NAME
|
1915 |
|
|
mcapi_sclchan_recv_uint8 - receives a (connected) 8-bit scalar on a
|
1916 |
|
|
channel.
|
1917 |
|
|
DESCRIPTION
|
1918 |
|
|
Receives a scalar on a connected channel. It is a blocking function,
|
1919 |
|
|
and returns when a scalar is available. receive_handle is the receive
|
1920 |
|
|
endpoint identifier.
|
1921 |
|
|
RETURN VALUE
|
1922 |
|
|
On success, a value of type uint8_t is returned and *mcapi_status is set
|
1923 |
|
|
to MCAPI_SUCCESS. On error, the return value is undefined and
|
1924 |
|
|
*mcapi_status is set to the appropriate error defined below. Optionally,
|
1925 |
|
|
implementations may choose to always set *mcapi_status to MCAPI_SUCCESS
|
1926 |
|
|
for performance reasons.
|
1927 |
|
|
ERRORS
|
1928 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1929 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1930 |
|
|
MCAPI_ESCL_SIZE Incorrect scalar size.
|
1931 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1932 |
|
|
NOTE
|
1933 |
|
|
The receive scalar size must match the send size.
|
1934 |
|
|
SEE ALSO
|
1935 |
|
|
************************************************************************/
|
1936 |
|
|
mcapi_uint8_t mcapi_sclchan_recv_uint8(
|
1937 |
|
|
MCAPI_IN mcapi_sclchan_recv_hndl_t receive_handle,
|
1938 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1939 |
|
|
{
|
1940 |
|
|
uint32_t exp_size = 1;
|
1941 |
|
|
#ifdef __TCE__
|
1942 |
|
|
uint64_t dataword;
|
1943 |
|
|
dataword.lo = 0;
|
1944 |
|
|
dataword.hi = 0;
|
1945 |
|
|
#else
|
1946 |
|
|
uint64_t dataword = 0;
|
1947 |
|
|
#endif
|
1948 |
|
|
|
1949 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1950 |
|
|
if (mcapi_status != NULL) {
|
1951 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1952 |
|
|
}
|
1953 |
|
|
} else {
|
1954 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
1955 |
|
|
if (! mcapi_trans_valid_sclchan_recv_handle(receive_handle) ) {
|
1956 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
1957 |
|
|
} else if (! mcapi_trans_sclchan_recv (receive_handle,&dataword,exp_size)) {
|
1958 |
|
|
*mcapi_status = MCAPI_ESCL_SIZE;
|
1959 |
|
|
}
|
1960 |
|
|
}
|
1961 |
|
|
#ifdef __TCE__
|
1962 |
|
|
return dataword.lo;
|
1963 |
|
|
#else
|
1964 |
|
|
return dataword;
|
1965 |
|
|
#endif
|
1966 |
|
|
}
|
1967 |
|
|
|
1968 |
|
|
|
1969 |
|
|
/***********************************************************************
|
1970 |
|
|
NAME
|
1971 |
|
|
mcapi_sclchan_available - checks if scalars are available on a receive
|
1972 |
|
|
endpoint.
|
1973 |
|
|
DESCRIPTION
|
1974 |
|
|
Checks if scalars are available on a receive endpoint. The function returns
|
1975 |
|
|
immediately. receive_endpoint is the receive endpoint identifier. The call
|
1976 |
|
|
only checks the availability of messages does not de-queue them.
|
1977 |
|
|
RETURN VALUE
|
1978 |
|
|
On success, the number of available scalars are returned and *mcapi_status
|
1979 |
|
|
is set to MCAPI_SUCCESS. On error, MCAPI_NULL is returned and *mcapi_status
|
1980 |
|
|
is set to the appropriate error defined below.
|
1981 |
|
|
ERRORS
|
1982 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
1983 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
1984 |
|
|
NOTE
|
1985 |
|
|
The status code must be checked to distinguish between no messages and an
|
1986 |
|
|
error condition.
|
1987 |
|
|
SEE ALSO
|
1988 |
|
|
************************************************************************/
|
1989 |
|
|
mcapi_uint_t mcapi_sclchan_available (
|
1990 |
|
|
MCAPI_IN mcapi_sclchan_recv_hndl_t receive_handle,
|
1991 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
1992 |
|
|
{
|
1993 |
|
|
int num = 0;
|
1994 |
|
|
|
1995 |
|
|
if (! valid_status_param(mcapi_status)) {
|
1996 |
|
|
if (mcapi_status != NULL) {
|
1997 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
1998 |
|
|
}
|
1999 |
|
|
} else {
|
2000 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
2001 |
|
|
if (! mcapi_trans_valid_sclchan_recv_handle(receive_handle) ) {
|
2002 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
2003 |
|
|
} else {
|
2004 |
|
|
num = mcapi_trans_sclchan_available_i(receive_handle);
|
2005 |
|
|
}
|
2006 |
|
|
}
|
2007 |
|
|
return num;
|
2008 |
|
|
}
|
2009 |
|
|
|
2010 |
|
|
/***********************************************************************
|
2011 |
|
|
NAME
|
2012 |
|
|
mcapi_ sclchan_recv_close_i - closes channel on a receive endpoint.
|
2013 |
|
|
DESCRIPTION
|
2014 |
|
|
Closes the receive side of a channel. The corresponding calls are required
|
2015 |
|
|
on both send and receive sides to ensure that the channel is properly
|
2016 |
|
|
closed. It is a non-blocking function, and returns immediately.
|
2017 |
|
|
receive_handle is the receive endpoint identifier. All pending scalars
|
2018 |
|
|
are discarded, and any attempt to send more scalars will give an error.
|
2019 |
|
|
RETURN VALUE
|
2020 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error
|
2021 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
2022 |
|
|
ERRORS
|
2023 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
2024 |
|
|
MCAPI_ENOT_OPEN The endpoint is not open.
|
2025 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
2026 |
|
|
NOTE
|
2027 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
2028 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
2029 |
|
|
SEE ALSO
|
2030 |
|
|
************************************************************************/
|
2031 |
|
|
void mcapi_sclchan_recv_close_i(
|
2032 |
|
|
MCAPI_IN mcapi_sclchan_recv_hndl_t receive_handle,
|
2033 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
2034 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
2035 |
|
|
{
|
2036 |
|
|
|
2037 |
|
|
if (! valid_status_param(mcapi_status)) {
|
2038 |
|
|
if (mcapi_status != NULL) {
|
2039 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2040 |
|
|
}
|
2041 |
|
|
} else {
|
2042 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
2043 |
|
|
if (! valid_request_param(request)) {
|
2044 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2045 |
|
|
} else if (! mcapi_trans_valid_sclchan_recv_handle(receive_handle) ) {
|
2046 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
2047 |
|
|
} else if (! mcapi_trans_sclchan_recv_isopen (receive_handle)) {
|
2048 |
|
|
*mcapi_status = MCAPI_ENOT_OPEN;
|
2049 |
|
|
}
|
2050 |
|
|
mcapi_trans_sclchan_recv_close_i (receive_handle,request,mcapi_status);
|
2051 |
|
|
}
|
2052 |
|
|
}
|
2053 |
|
|
|
2054 |
|
|
|
2055 |
|
|
/***********************************************************************
|
2056 |
|
|
NAME
|
2057 |
|
|
mcapi_sclchan_send_close_i - closes channel on a send endpoint.
|
2058 |
|
|
DESCRIPTION
|
2059 |
|
|
Closes the send side of a channel. The corresponding calls are required on
|
2060 |
|
|
both send and receive sides to ensure that the channel is properly closed.
|
2061 |
|
|
It is a non-blocking function, and returns immediately. send_handle is
|
2062 |
|
|
the send endpoint identifier. Pending scalars at the receiver are not
|
2063 |
|
|
discarded.
|
2064 |
|
|
RETURN VALUE
|
2065 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error
|
2066 |
|
|
*mcapi_status is set to the appropriate error defined below.
|
2067 |
|
|
ERRORS
|
2068 |
|
|
MCAPI_ENOT_HANDLE Argument is not a channel handle.
|
2069 |
|
|
MCAPI_ENOT_OPEN The endpoint is not open.
|
2070 |
|
|
MCAPI_EPARAM Incorrect request or mcapi_status parameter.
|
2071 |
|
|
NOTE
|
2072 |
|
|
Use the mcapi_test() , mcapi_wait() and mcapi_wait_any() functions to
|
2073 |
|
|
query the status of and mcapi_cancel() function to cancel the operation.
|
2074 |
|
|
SEE ALSO
|
2075 |
|
|
************************************************************************/
|
2076 |
|
|
void mcapi_sclchan_send_close_i(
|
2077 |
|
|
MCAPI_IN mcapi_sclchan_send_hndl_t send_handle,
|
2078 |
|
|
MCAPI_OUT mcapi_request_t* request,
|
2079 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
2080 |
|
|
{
|
2081 |
|
|
|
2082 |
|
|
if (! valid_status_param(mcapi_status)) {
|
2083 |
|
|
if (mcapi_status != NULL) {
|
2084 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2085 |
|
|
}
|
2086 |
|
|
} else {
|
2087 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
2088 |
|
|
if (! valid_request_param(request)) {
|
2089 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2090 |
|
|
} else if (! mcapi_trans_valid_sclchan_recv_handle(send_handle) ) {
|
2091 |
|
|
*mcapi_status = MCAPI_ENOT_HANDLE;
|
2092 |
|
|
} else if (! mcapi_trans_sclchan_send_isopen (send_handle)) {
|
2093 |
|
|
*mcapi_status = MCAPI_ENOT_OPEN;
|
2094 |
|
|
}
|
2095 |
|
|
mcapi_trans_sclchan_send_close_i (send_handle,request,mcapi_status);
|
2096 |
|
|
}
|
2097 |
|
|
}
|
2098 |
|
|
|
2099 |
|
|
|
2100 |
|
|
/***********************************************************************
|
2101 |
|
|
NAME
|
2102 |
|
|
mcapi_test - tests if non-blocking operation has completed.
|
2103 |
|
|
DESCRIPTION
|
2104 |
|
|
Checks if a non-blocking operation has completed. The function returns
|
2105 |
|
|
in a timely fashion. request is the identifier for the non-blocking
|
2106 |
|
|
operation. The call only checks the completion of an operation and
|
2107 |
|
|
doesn't affect any messages/packets/scalars. If the specified request
|
2108 |
|
|
completes and the pending operation was a send or receive operation,
|
2109 |
|
|
the size parameter is set to the number of bytes that were either sent
|
2110 |
|
|
or received by the non-blocking transaction.
|
2111 |
|
|
RETURN VALUE
|
2112 |
|
|
On success, MCAPI_TRUE is returned and *mcapi_status is set to
|
2113 |
|
|
MCAPI_SUCCESS. If the operation has not completed MCAPI_FALSE is
|
2114 |
|
|
returned and *mcapi_status is set to MCAPI_INCOMPLETE. On error
|
2115 |
|
|
MCAPI_FALSE is returned and *mcapi_status is set to the appropriate
|
2116 |
|
|
error defined below.
|
2117 |
|
|
ERRORS
|
2118 |
|
|
MCAPI_ENOTREQ_HANDLE Argument is not a valid request handle.
|
2119 |
|
|
MCAPI_EPARAM Incorrect size and/or mcapi_status parameter.
|
2120 |
|
|
NOTE
|
2121 |
|
|
SEE ALSO
|
2122 |
|
|
mcapi_endpoint_t mcapi_get_endpoint_i(),
|
2123 |
|
|
mcapi_msg_send_i(),
|
2124 |
|
|
mcapi_msg_recv_i(),
|
2125 |
|
|
mcapi_connect_pktchan_i(),
|
2126 |
|
|
mcapi_open_pktchan_recv_i(),
|
2127 |
|
|
mcapi_open_pktchan_send_i(),
|
2128 |
|
|
mcapi_pktchan_send_i(),
|
2129 |
|
|
mcapi_pktchan_recv_i(),
|
2130 |
|
|
mcapi_pktchan_recv_close_i(),
|
2131 |
|
|
mcapi_pktchan_send_close_i(),
|
2132 |
|
|
mcapi_connect_sclchan_i(),
|
2133 |
|
|
mcapi_open_sclchan_recv_i(),
|
2134 |
|
|
mcapi_open_sclchan_send_i(),
|
2135 |
|
|
mcapi_sclchan_recv_close_i(),
|
2136 |
|
|
mcapi_sclchan_send_close_i()
|
2137 |
|
|
************************************************************************/
|
2138 |
|
|
mcapi_boolean_t mcapi_test(
|
2139 |
|
|
MCAPI_IN mcapi_request_t* request,
|
2140 |
|
|
MCAPI_OUT size_t* size,
|
2141 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
2142 |
|
|
{
|
2143 |
|
|
mcapi_boolean_t rc = MCAPI_FALSE;
|
2144 |
|
|
|
2145 |
|
|
if (! valid_status_param(mcapi_status)) {
|
2146 |
|
|
if (mcapi_status != NULL) {
|
2147 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2148 |
|
|
}
|
2149 |
|
|
} else {
|
2150 |
|
|
*mcapi_status = MCAPI_INCOMPLETE;
|
2151 |
|
|
if (! valid_size_param(size)) {
|
2152 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2153 |
|
|
rc = MCAPI_TRUE;
|
2154 |
|
|
} else {
|
2155 |
|
|
rc = mcapi_trans_test_i(request,size,mcapi_status);
|
2156 |
|
|
}
|
2157 |
|
|
}
|
2158 |
|
|
return rc;
|
2159 |
|
|
}
|
2160 |
|
|
/***********************************************************************
|
2161 |
|
|
NAME
|
2162 |
|
|
mcapi_wait - waits for a non-blocking operation to complete.
|
2163 |
|
|
DESCRIPTION
|
2164 |
|
|
Wait until a non-blocking operation has completed. It is a blocking function
|
2165 |
|
|
and returns when the operation has completed, has been canceled, or a timeout
|
2166 |
|
|
has occurred. request is the identifier for the non-blocking operation. The
|
2167 |
|
|
call only waits for the completion of an operation (all buffers referenced in
|
2168 |
|
|
the operation have been filled or consumed and can now be safely accessed by
|
2169 |
|
|
the application) and doesn't affect any messages/packets/scalars. The size
|
2170 |
|
|
parameter is set to number of bytes that were either sent or received by the
|
2171 |
|
|
non-blocking transaction that completed (size is irrelevant for non-blocking
|
2172 |
|
|
connect and close calls). The mcapi_wait() call will return if the request
|
2173 |
|
|
is cancelled by a call to mcapi_cancel(), and the returned mcapi_status will
|
2174 |
|
|
indicate that the request was cancelled. The units for timeout are
|
2175 |
|
|
implementation defined. If a timeout occurs the returned status will indicate
|
2176 |
|
|
that the timeout occurred. A value of MCAPI_INFINITE for the timeout
|
2177 |
|
|
parameter indicates no timeout is requested.
|
2178 |
|
|
RETURN VALUE
|
2179 |
|
|
On success, MCAPI_TRUE is returned and *mcapi_status is set to MCAPI_SUCCESS.
|
2180 |
|
|
On error MCAPI_FALSE is returned and *mcapi_status is set to the appropriate
|
2181 |
|
|
error defined below.
|
2182 |
|
|
ERRORS
|
2183 |
|
|
MCAPI_ENOTREQ_HANDLE Argument is not a valid request handle.
|
2184 |
|
|
MCAPI_EREQ_CANCELED The request was canceled, by another thread (during the
|
2185 |
|
|
waiting)
|
2186 |
|
|
.
|
2187 |
|
|
MCAPI_EREQ_TIMEOUT The operation timed out.
|
2188 |
|
|
MCAPI_EPARAM Incorrect size and/or mcapi_status parameter.
|
2189 |
|
|
NOTE
|
2190 |
|
|
SEE ALSO
|
2191 |
|
|
mcapi_endpoint_t mcapi_get_endpoint_i(),
|
2192 |
|
|
mcapi_msg_send_i(),
|
2193 |
|
|
mcapi_msg_recv_i(),
|
2194 |
|
|
mcapi_connect_pktchan_i(),
|
2195 |
|
|
mcapi_open_pktchan_recv_i(),
|
2196 |
|
|
mcapi_open_pktchan_send_i(),
|
2197 |
|
|
mcapi_pktchan_send_i(),
|
2198 |
|
|
mcapi_pktchan_recv_i(),
|
2199 |
|
|
mcapi_pktchan_recv_close_i(),
|
2200 |
|
|
mcapi_pktchan_send_close_i(),
|
2201 |
|
|
mcapi_connect_sclchan_i(),
|
2202 |
|
|
mcapi_open_sclchan_recv_i(),
|
2203 |
|
|
mcapi_open_sclchan_send_i(),
|
2204 |
|
|
mcapi_sclchan_recv_close_i(),
|
2205 |
|
|
mcapi_sclchan_send_close_i()
|
2206 |
|
|
************************************************************************/
|
2207 |
|
|
mcapi_boolean_t mcapi_wait(
|
2208 |
|
|
MCAPI_IN mcapi_request_t* request,
|
2209 |
|
|
MCAPI_OUT size_t* size,
|
2210 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status,
|
2211 |
|
|
MCAPI_IN mcapi_timeout_t timeout)
|
2212 |
|
|
{
|
2213 |
|
|
mcapi_boolean_t rc = MCAPI_FALSE;
|
2214 |
|
|
|
2215 |
|
|
if (! valid_status_param(mcapi_status)) {
|
2216 |
|
|
if (mcapi_status != NULL) {
|
2217 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2218 |
|
|
}
|
2219 |
|
|
} else {
|
2220 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
2221 |
|
|
if (! valid_size_param(size)) {
|
2222 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2223 |
|
|
rc = MCAPI_TRUE;
|
2224 |
|
|
} else {
|
2225 |
|
|
rc = mcapi_trans_wait(request,size,mcapi_status,timeout);
|
2226 |
|
|
}
|
2227 |
|
|
}
|
2228 |
|
|
return rc;
|
2229 |
|
|
}
|
2230 |
|
|
|
2231 |
|
|
/***********************************************************************
|
2232 |
|
|
NAME
|
2233 |
|
|
mcapi_wait_any - waits for any non-blocking operation in a list to complete.
|
2234 |
|
|
DESCRIPTION
|
2235 |
|
|
Wait until any non-blocking operation of a list has completed. It is a
|
2236 |
|
|
blocking function and returns the index into the requests array (starting
|
2237 |
|
|
from 0) indicating which of any outstanding operations has completed.
|
2238 |
|
|
number is the number of requests in the array. requests is the array of
|
2239 |
|
|
mcapi_request_t identifiers for the non-blocking operations. The call only
|
2240 |
|
|
waits for the completion of an operation and doesn't affect any
|
2241 |
|
|
messages/packets/scalars. The size parameter is set to number of bytes
|
2242 |
|
|
that were either sent or received by the non-blocking transaction that
|
2243 |
|
|
completed (size is irrelevant for non-blocking connect and close calls).
|
2244 |
|
|
The mcapi_wait_any() call will return 0 if all the requests are cancelled
|
2245 |
|
|
by calls to mcapi_cancel() (during the waiting). The returned status will
|
2246 |
|
|
indicate that a request was cancelled. The units for timeout are implementation
|
2247 |
|
|
defined. If a timeout occurs the mcapi_status parameter will indicate that
|
2248 |
|
|
a timeout occurred. A value of MCAPI_INFINITE for the timeout parameter
|
2249 |
|
|
indicates no timeout is requested.
|
2250 |
|
|
RETURN VALUE
|
2251 |
|
|
On success, the index into the requests array of the mcapi_request_t
|
2252 |
|
|
identifier that has completed or has been canceled is returned and
|
2253 |
|
|
*mcapi_status is set to MCAPI_SUCCESS. On error MCAPI_NULL is returned
|
2254 |
|
|
and *mcapi_status is set to the appropriate error defined below.
|
2255 |
|
|
ERRORS
|
2256 |
|
|
MCAPI_ENOTREQ_HANDLE Argument is not a valid request handle.
|
2257 |
|
|
MCAPI_EREQ_CANCELED One of the requests was canceled, by another thread
|
2258 |
|
|
(during the waiting).
|
2259 |
|
|
MCAPI_EREQ_TIMEOUT The operation timed out.
|
2260 |
|
|
MCAPI_EPARAM Incorrect requests, size, and/or mcapi_status parameter.
|
2261 |
|
|
NOTE
|
2262 |
|
|
SEE ALSO
|
2263 |
|
|
mcapi_endpoint_t mcapi_get_endpoint_i(),
|
2264 |
|
|
mcapi_msg_send_i(),
|
2265 |
|
|
mcapi_msg_recv_i(),
|
2266 |
|
|
mcapi_connect_pktchan_i(),
|
2267 |
|
|
mcapi_open_pktchan_recv_i(),
|
2268 |
|
|
mcapi_open_pktchan_send_i(),
|
2269 |
|
|
mcapi_pktchan_send_i(),
|
2270 |
|
|
mcapi_pktchan_recv_i(),
|
2271 |
|
|
mcapi_pktchan_recv_close_i(),
|
2272 |
|
|
mcapi_pktchan_send_close_i(),
|
2273 |
|
|
mcapi_connect_sclchan_i(),
|
2274 |
|
|
mcapi_open_sclchan_recv_i(),
|
2275 |
|
|
mcapi_open_sclchan_send_i(),
|
2276 |
|
|
mcapi_sclchan_recv_close_i(),
|
2277 |
|
|
mcapi_sclchan_send_close_i()
|
2278 |
|
|
************************************************************************/
|
2279 |
|
|
mcapi_int_t mcapi_wait_any(
|
2280 |
|
|
MCAPI_IN size_t number,
|
2281 |
|
|
MCAPI_IN mcapi_request_t** requests,
|
2282 |
|
|
MCAPI_OUT size_t* size,
|
2283 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status,
|
2284 |
|
|
MCAPI_IN mcapi_timeout_t timeout)
|
2285 |
|
|
{
|
2286 |
|
|
mcapi_boolean_t rc = MCAPI_FALSE;
|
2287 |
|
|
|
2288 |
|
|
if (! valid_status_param(mcapi_status)) {
|
2289 |
|
|
if (mcapi_status != NULL) {
|
2290 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2291 |
|
|
}
|
2292 |
|
|
} else {
|
2293 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
2294 |
|
|
if (! valid_size_param(size)) {
|
2295 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2296 |
|
|
rc = MCAPI_TRUE;
|
2297 |
|
|
} else {
|
2298 |
|
|
rc = mcapi_trans_wait_any(number,requests,size,mcapi_status,timeout);
|
2299 |
|
|
}
|
2300 |
|
|
}
|
2301 |
|
|
return rc;
|
2302 |
|
|
}
|
2303 |
|
|
|
2304 |
|
|
|
2305 |
|
|
/***********************************************************************
|
2306 |
|
|
NAME
|
2307 |
|
|
mcapi_cancel - cancels an outstanding non-blocking operation.
|
2308 |
|
|
DESCRIPTION
|
2309 |
|
|
Cancels an outstanding non-blocking operation. It is a blocking function
|
2310 |
|
|
and returns when the operation has been canceled. request is the identifier
|
2311 |
|
|
for the non-blocking operation. Any pending calls to mcapi_wait() or
|
2312 |
|
|
mcapi_wait_any() for this request will also be cancelled. The returned
|
2313 |
|
|
status of a canceled mcapi_wait() or mcapi_wait_any() call will indicate
|
2314 |
|
|
that the request was cancelled.
|
2315 |
|
|
RETURN VALUE
|
2316 |
|
|
On success, *mcapi_status is set to MCAPI_SUCCESS. On error *mcapi_status
|
2317 |
|
|
is set to the appropriate error defined below.
|
2318 |
|
|
ERRORS
|
2319 |
|
|
MCAPI_ENOTREQ_HANDLE Argument is not a valid request handle (the operation
|
2320 |
|
|
may have completed).
|
2321 |
|
|
MCAPI_EPARAM Incorrect mcapi_status parameter.
|
2322 |
|
|
NOTE
|
2323 |
|
|
SEE ALSO
|
2324 |
|
|
mcapi_endpoint_t mcapi_get_endpoint_i(),
|
2325 |
|
|
mcapi_msg_send_i(),
|
2326 |
|
|
mcapi_msg_recv_i(),
|
2327 |
|
|
mcapi_connect_pktchan_i(),
|
2328 |
|
|
mcapi_open_pktchan_recv_i(),
|
2329 |
|
|
mcapi_open_pktchan_send_i(),
|
2330 |
|
|
mcapi_pktchan_send_i(),
|
2331 |
|
|
mcapi_pktchan_recv_i(),
|
2332 |
|
|
mcapi_pktchan_recv_close_i(),
|
2333 |
|
|
mcapi_pktchan_send_close_i(),
|
2334 |
|
|
mcapi_connect_sclchan_i(),
|
2335 |
|
|
mcapi_open_sclchan_recv_i(),
|
2336 |
|
|
mcapi_open_sclchan_send_i(),
|
2337 |
|
|
mcapi_sclchan_recv_close_i(),
|
2338 |
|
|
mcapi_sclchan_send_close_i()
|
2339 |
|
|
************************************************************************/
|
2340 |
|
|
void mcapi_cancel(
|
2341 |
|
|
MCAPI_IN mcapi_request_t* request,
|
2342 |
|
|
MCAPI_OUT mcapi_status_t* mcapi_status)
|
2343 |
|
|
{
|
2344 |
|
|
if (! valid_status_param(mcapi_status)) {
|
2345 |
|
|
if (mcapi_status != NULL) {
|
2346 |
|
|
*mcapi_status = MCAPI_EPARAM;
|
2347 |
|
|
}
|
2348 |
|
|
} else {
|
2349 |
|
|
*mcapi_status = MCAPI_SUCCESS;
|
2350 |
|
|
mcapi_trans_cancel(request,mcapi_status);
|
2351 |
|
|
}
|
2352 |
|
|
}
|
2353 |
|
|
|
2354 |
|
|
|
2355 |
|
|
|