OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [openmcapi/] [1.0/] [test/] [func/] [fts_mcapi_sclchan_recv_x.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * Copyright (c) 2010, Mentor Graphics Corporation
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 met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
 * POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
30
/*
31
*   FILENAME
32
*
33
*       fts_main.c
34
*
35
*
36
*************************************************************************/
37
 
38
#include "fts_defs.h"
39
#include "support_suite/mcapid_support.h"
40
 
41
extern MCAPI_MUTEX      MCAPID_FTS_Mutex;
42
 
43
/************************************************************************
44
*
45
*   FUNCTION
46
*
47
*       MCAPI_FTS_Tx_2_29_1
48
*
49
*   DESCRIPTION
50
*
51
*       Testing mcapi_sclchan_recv_uint64, mcapi_sclchan_recv_uint32,
52
*       mcapi_sclchan_recv_uint16, mcapi_sclchan_recv_uint8 - receive data
53
*       over open connection.
54
*
55
*       For each scalar size:
56
*
57
*           Node 0 – Create endpoint, open send side, wait for connection,
58
*                    send data
59
*
60
*           Node 1 – Create endpoint, open receive side, get endpoint on
61
*                    Node 0, open connection, wait for data
62
*
63
*************************************************************************/
64
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_29_1)
65
{
66
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
67
    size_t                      rx_len;
68
    mcapi_status_t              status;
69
    mcapi_endpoint_t            tx_endp, rx_endp;
70
    mcapi_request_t             request;
71
    int                         i;
72
    mcapi_uint64_t              recv_64bit;
73
    mcapi_uint32_t              recv_32bit;
74
    mcapi_uint16_t              recv_16bit;
75
    mcapi_uint8_t               recv_8bit;
76
 
77
    /* Don't let any other test run while this test is running. */
78
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
79
 
80
    /* An extra endpoint is required for the connection. */
81
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
82
 
83
    if (mcapi_struct->status == MCAPI_SUCCESS)
84
    {
85
        /* Indicate that a remote endpoint should be created. */
86
        mcapi_struct->status =
87
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
88
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
89
 
90
        if (mcapi_struct->status == MCAPI_SUCCESS)
91
        {
92
            /* Wait for a response. */
93
            mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
94
 
95
            /* If the endpoint was created. */
96
            if (mcapi_struct->status == MCAPI_SUCCESS)
97
            {
98
                /* Indicate that the endpoint should be opened as a sender. */
99
                mcapi_struct->status =
100
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_TX_SIDE_SCL,
101
                                           1024, mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
102
 
103
                if (mcapi_struct->status == MCAPI_SUCCESS)
104
                {
105
                    /* Wait for a response. */
106
                    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
107
 
108
                    /* If the receive side was opened. */
109
                    if (mcapi_struct->status ==MGC_MCAPI_ERR_NOT_CONNECTED)
110
                    {
111
                        /* Get the send side endpoint. */
112
                        tx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024, &mcapi_struct->status);
113
 
114
                        if (mcapi_struct->status == MCAPI_SUCCESS)
115
                        {
116
                            /* Connect the two endpoints. */
117
                            mcapi_connect_sclchan_i(tx_endp, rx_endp,
118
                                                    &mcapi_struct->request,
119
                                                    &mcapi_struct->status);
120
 
121
                            if (mcapi_struct->status == MCAPI_SUCCESS)
122
                            {
123
                                /* Wait for the connection to complete. */
124
                                mcapi_wait(&mcapi_struct->request, &rx_len,
125
                                            &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
126
 
127
                                /* Open the local endpoint as the receiver. */
128
                                mcapi_open_sclchan_recv_i(&mcapi_struct->scl_rx_handle, rx_endp,
129
                                                          &request, &mcapi_struct->status);
130
 
131
                                if (mcapi_struct->status == MCAPI_SUCCESS)
132
                                {
133
                                    /* Wait for the open to return successfully. */
134
                                    mcapi_wait(&request, &rx_len,
135
                                               &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
136
 
137
                                    /* Test each scalar size. */
138
                                    for (i = MCAPID_TX_64_BIT_SCL; i <= MCAPID_TX_8_BIT_SCL; i ++)
139
                                    {
140
                                        /* Tell the other side to send some data. */
141
                                        mcapi_struct->status =
142
                                            MCAPID_TX_Mgmt_Message(mcapi_struct, i, 1024,
143
                                                                   mcapi_struct->local_endp,
144
                                                                   0, MCAPI_DEFAULT_PRIO);
145
 
146
                                        if (mcapi_struct->status == MCAPI_SUCCESS)
147
                                        {
148
                                            /* Wait for the response. */
149
                                            mcapi_struct->status =
150
                                                MCAPID_RX_Mgmt_Response(mcapi_struct);
151
 
152
                                            if (mcapi_struct->status == MCAPI_SUCCESS)
153
                                            {
154
                                                /* Receive the proper scalar size. */
155
                                                switch (i)
156
                                                {
157
                                                    case MCAPID_TX_64_BIT_SCL:
158
 
159
                                                        recv_64bit =
160
                                                            mcapi_sclchan_recv_uint64(mcapi_struct->scl_rx_handle,
161
                                                                                      &mcapi_struct->status);
162
 
163
                                                        /* If success was returned with the wrong value,
164
                                                         * set an error.
165
                                                         */
166
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
167
                                                             (recv_64bit != MCAPI_FTS_64BIT_SCALAR) )
168
                                                        {
169
                                                             mcapi_struct->status = -1;
170
                                                        }
171
 
172
                                                        break;
173
 
174
                                                    case MCAPID_TX_32_BIT_SCL:
175
 
176
                                                        recv_32bit =
177
                                                            mcapi_sclchan_recv_uint32(mcapi_struct->scl_rx_handle,
178
                                                                                      &mcapi_struct->status);
179
 
180
                                                        /* If success was returned with the wrong value,
181
                                                         * set an error.
182
                                                         */
183
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
184
                                                             (recv_32bit != MCAPI_FTS_32BIT_SCALAR) )
185
                                                        {
186
                                                             mcapi_struct->status = -1;
187
                                                        }
188
 
189
                                                        break;
190
 
191
                                                    case MCAPID_TX_16_BIT_SCL:
192
 
193
                                                        recv_16bit =
194
                                                            mcapi_sclchan_recv_uint16(mcapi_struct->scl_rx_handle,
195
                                                                                      &mcapi_struct->status);
196
 
197
                                                        /* If success was returned with the wrong value,
198
                                                         * set an error.
199
                                                         */
200
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
201
                                                             (recv_16bit != MCAPI_FTS_16BIT_SCALAR) )
202
                                                        {
203
                                                             mcapi_struct->status = -1;
204
                                                        }
205
 
206
                                                        break;
207
 
208
                                                    case MCAPID_TX_8_BIT_SCL:
209
 
210
                                                        recv_8bit =
211
                                                            mcapi_sclchan_recv_uint8(mcapi_struct->scl_rx_handle,
212
                                                                                     &mcapi_struct->status);
213
 
214
                                                        /* If success was returned with the wrong value,
215
                                                         * set an error.
216
                                                         */
217
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
218
                                                             (recv_8bit != MCAPI_FTS_8BIT_SCALAR) )
219
                                                        {
220
                                                             mcapi_struct->status = -1;
221
                                                        }
222
 
223
                                                        break;
224
 
225
                                                    default:
226
 
227
                                                        break;
228
                                                }
229
 
230
                                                if (mcapi_struct->status != MCAPI_SUCCESS)
231
                                                    break;
232
                                            }
233
 
234
                                            else
235
                                                break;
236
                                        }
237
 
238
                                        else
239
                                            break;
240
                                    }
241
 
242
                                    /* Close the receive side. */
243
                                    mcapi_sclchan_recv_close_i(mcapi_struct->scl_rx_handle,
244
                                                               &request, &status);
245
                                }
246
                            }
247
                        }
248
 
249
                        /* Tell the other side to close the send side. */
250
                        status =
251
                            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CLOSE_TX_SIDE_SCL, 1024,
252
                                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
253
 
254
                        if (status == MCAPI_SUCCESS)
255
                        {
256
                            /* Wait for the response. */
257
                            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
258
                        }
259
                    }
260
                }
261
 
262
                /* Tell the other side to delete the endpoint. */
263
                status =
264
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
265
                                           mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
266
 
267
                if (status == MCAPI_SUCCESS)
268
                {
269
                    /* Wait for the response. */
270
                    status = MCAPID_RX_Mgmt_Response(mcapi_struct);
271
                }
272
            }
273
        }
274
 
275
        /* Delete the endpoint used in the connection. */
276
        mcapi_delete_endpoint(rx_endp, &status);
277
    }
278
 
279
    /* Set the state of the test to completed. */
280
    mcapi_struct->state = 0;
281
 
282
    /* Allow the next test to run. */
283
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
284
 
285
} /* MCAPI_FTS_Tx_2_29_1 */
286
 
287
/************************************************************************
288
*
289
*   FUNCTION
290
*
291
*       MCAPI_FTS_Tx_2_29_2
292
*
293
*   DESCRIPTION
294
*
295
*       Testing mcapi_pktchan_recv_uint64, mcapi_pktchan_recv_uint32,
296
*       mcapi_pktchan_recv_uint16, mcapi_pktchan_recv_uint8 - receive data
297
*       over closed connection - no data on endpoint when closed.
298
*
299
*       For each data size:
300
*
301
*           Node 0 – Create endpoint, open send side, wait for connection,
302
*                    close send side
303
*
304
*           Node 1 – Create endpoint, open receive side, get endpoint on
305
*                    Node 0, open connection, wait for data
306
*
307
*************************************************************************/
308
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_29_2)
309
{
310
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
311
    size_t                      rx_len;
312
    mcapi_status_t              status;
313
    mcapi_endpoint_t            tx_endp, rx_endp;
314
    mcapi_request_t             request;
315
    int                         i;
316
    mcapi_uint64_t              recv_64bit;
317
    mcapi_uint32_t              recv_32bit;
318
    mcapi_uint16_t              recv_16bit;
319
    mcapi_uint8_t               recv_8bit;
320
 
321
    /* Don't let any other test run while this test is running. */
322
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
323
 
324
    /* An extra endpoint is required for the connection. */
325
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
326
 
327
    if (mcapi_struct->status == MCAPI_SUCCESS)
328
    {
329
        /* Indicate that a remote endpoint should be created. */
330
        mcapi_struct->status =
331
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
332
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
333
 
334
        if (mcapi_struct->status == MCAPI_SUCCESS)
335
        {
336
            /* Wait for a response. */
337
            mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
338
 
339
            /* If the endpoint was created. */
340
            if (mcapi_struct->status == MCAPI_SUCCESS)
341
            {
342
                /* Indicate that the endpoint should be opened as a sender. */
343
                mcapi_struct->status =
344
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_TX_SIDE_SCL,
345
                                           1024, mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
346
 
347
                if (mcapi_struct->status == MCAPI_SUCCESS)
348
                {
349
                    /* Wait for a response. */
350
                    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
351
 
352
                    /* If the receive side was opened. */
353
                    if (mcapi_struct->status ==MGC_MCAPI_ERR_NOT_CONNECTED)
354
                    {
355
                        /* Get the send side endpoint. */
356
                        tx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024, &mcapi_struct->status);
357
 
358
                        if (mcapi_struct->status == MCAPI_SUCCESS)
359
                        {
360
                            /* Connect the two endpoints. */
361
                            mcapi_connect_sclchan_i(tx_endp, rx_endp,
362
                                                    &mcapi_struct->request,
363
                                                    &mcapi_struct->status);
364
 
365
                            if (mcapi_struct->status == MCAPI_SUCCESS)
366
                            {
367
                                /* Wait for the connection to complete. */
368
                                mcapi_wait(&mcapi_struct->request, &rx_len,
369
                                            &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
370
 
371
                                /* Open the local endpoint as the receiver. */
372
                                mcapi_open_sclchan_recv_i(&mcapi_struct->scl_rx_handle, rx_endp,
373
                                                          &request, &mcapi_struct->status);
374
 
375
                                if (mcapi_struct->status == MCAPI_SUCCESS)
376
                                {
377
                                    /* Wait for the open to return successfully. */
378
                                    mcapi_wait(&request, &rx_len,
379
                                               &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
380
 
381
                                    /* Tell the other side to close the send side. */
382
                                    mcapi_struct->status =
383
                                        MCAPID_TX_Mgmt_Message(mcapi_struct,
384
                                                               MCAPID_MGMT_CLOSE_TX_SIDE_SCL,
385
                                                               1024, mcapi_struct->local_endp,
386
                                                               0, MCAPI_DEFAULT_PRIO);
387
 
388
                                    if (mcapi_struct->status == MCAPI_SUCCESS)
389
                                    {
390
                                        /* Wait for the response. */
391
                                        mcapi_struct->status =
392
                                            MCAPID_RX_Mgmt_Response(mcapi_struct);
393
                                    }
394
 
395
                                    if (mcapi_struct->status == MCAPI_SUCCESS)
396
                                    {
397
                                        /* Test each scalar size. */
398
                                        for (i = MCAPID_TX_64_BIT_SCL; i <= MCAPID_TX_8_BIT_SCL; i ++)
399
                                        {
400
                                            /* Receive the proper scalar size. */
401
                                            switch (i)
402
                                            {
403
                                                case MCAPID_TX_64_BIT_SCL:
404
 
405
                                                    recv_64bit =
406
                                                        mcapi_sclchan_recv_uint64(mcapi_struct->scl_rx_handle,
407
                                                                                  &mcapi_struct->status);
408
 
409
                                                    /* If success was returned with the wrong value,
410
                                                     * set an error.
411
                                                     */
412
                                                    if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
413
                                                         (recv_64bit != MCAPI_FTS_64BIT_SCALAR) )
414
                                                    {
415
                                                        mcapi_struct->status = -1;
416
                                                    }
417
 
418
                                                    break;
419
 
420
                                                case MCAPID_TX_32_BIT_SCL:
421
 
422
                                                    recv_32bit =
423
                                                        mcapi_sclchan_recv_uint32(mcapi_struct->scl_rx_handle,
424
                                                                                  &mcapi_struct->status);
425
 
426
                                                    /* If success was returned with the wrong value,
427
                                                     * set an error.
428
                                                     */
429
                                                    if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
430
                                                         (recv_32bit != MCAPI_FTS_32BIT_SCALAR) )
431
                                                    {
432
                                                        mcapi_struct->status = -1;
433
                                                    }
434
 
435
                                                    break;
436
 
437
                                                case MCAPID_TX_16_BIT_SCL:
438
 
439
                                                    recv_16bit =
440
                                                        mcapi_sclchan_recv_uint16(mcapi_struct->scl_rx_handle,
441
                                                                                  &mcapi_struct->status);
442
 
443
                                                    /* If success was returned with the wrong value,
444
                                                     * set an error.
445
                                                     */
446
                                                    if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
447
                                                         (recv_16bit != MCAPI_FTS_16BIT_SCALAR) )
448
                                                    {
449
                                                        mcapi_struct->status = -1;
450
                                                    }
451
 
452
                                                    break;
453
 
454
                                                case MCAPID_TX_8_BIT_SCL:
455
 
456
                                                    recv_8bit =
457
                                                        mcapi_sclchan_recv_uint8(mcapi_struct->scl_rx_handle,
458
                                                                                 &mcapi_struct->status);
459
 
460
                                                    /* If success was returned with the wrong value,
461
                                                     * set an error.
462
                                                     */
463
                                                    if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
464
                                                         (recv_8bit != MCAPI_FTS_8BIT_SCALAR) )
465
                                                    {
466
                                                        mcapi_struct->status = -1;
467
                                                    }
468
 
469
                                                    break;
470
 
471
                                                default:
472
 
473
                                                    break;
474
                                            }
475
 
476
                                            /* An error should have been returned. */
477
                                            if (mcapi_struct->status == MCAPI_ERR_CHAN_INVALID)
478
                                            {
479
                                                mcapi_struct->status = MCAPI_SUCCESS;
480
                                            }
481
 
482
                                            else
483
                                                break;
484
                                        }
485
                                    }
486
 
487
                                    /* Close the receive side. */
488
                                    mcapi_sclchan_recv_close_i(mcapi_struct->scl_rx_handle,
489
                                                               &request, &status);
490
                                }
491
                            }
492
                        }
493
                    }
494
                }
495
 
496
                /* Tell the other side to delete the endpoint. */
497
                status =
498
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
499
                                           mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
500
 
501
                if (status == MCAPI_SUCCESS)
502
                {
503
                    /* Wait for the response. */
504
                    status = MCAPID_RX_Mgmt_Response(mcapi_struct);
505
                }
506
            }
507
        }
508
 
509
        /* Delete the endpoint used in the connection. */
510
        mcapi_delete_endpoint(rx_endp, &status);
511
    }
512
 
513
    /* Set the state of the test to completed. */
514
    mcapi_struct->state = 0;
515
 
516
    /* Allow the next test to run. */
517
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
518
 
519
} /* MCAPI_FTS_Tx_2_29_2 */
520
 
521
/************************************************************************
522
*
523
*   FUNCTION
524
*
525
*       MCAPI_FTS_Tx_2_29_3
526
*
527
*   DESCRIPTION
528
*
529
*       Testing mcapi_sclchan_recv_uint64, mcapi_sclchan_recv_uint32,
530
*       mcapi_sclchan_recv_uint16, mcapi_sclhan_recv_uint8 - receive data
531
*       over closed connection - data on endpoint when closed.
532
*
533
*       For each scalar size:
534
*
535
*           Node 0 – Create endpoint, open send side, wait for connection,
536
*                    send data, close send side
537
*
538
*           Node 1 – Create endpoint, open receive side, get endpoint on
539
*                    Node 0, open connection, wait for data
540
*
541
*************************************************************************/
542
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_29_3)
543
{
544
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
545
    size_t                      rx_len;
546
    mcapi_status_t              status;
547
    mcapi_endpoint_t            tx_endp, rx_endp;
548
    mcapi_request_t             request;
549
    int                         i;
550
    mcapi_uint64_t              recv_64bit;
551
    mcapi_uint32_t              recv_32bit;
552
    mcapi_uint16_t              recv_16bit;
553
    mcapi_uint8_t               recv_8bit;
554
 
555
    /* Don't let any other test run while this test is running. */
556
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
557
 
558
    /* An extra endpoint is required for the connection. */
559
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
560
 
561
    if (mcapi_struct->status == MCAPI_SUCCESS)
562
    {
563
        /* Indicate that a remote endpoint should be created. */
564
        mcapi_struct->status =
565
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
566
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
567
 
568
        if (mcapi_struct->status == MCAPI_SUCCESS)
569
        {
570
            /* Wait for a response. */
571
            mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
572
 
573
            /* If the endpoint was created. */
574
            if (mcapi_struct->status == MCAPI_SUCCESS)
575
            {
576
                /* Test each scalar size. */
577
                for (i = MCAPID_TX_64_BIT_SCL; i <= MCAPID_TX_8_BIT_SCL; i ++)
578
                {
579
                    /* Indicate that the endpoint should be opened as a sender. */
580
                    mcapi_struct->status =
581
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_TX_SIDE_SCL,
582
                                               1024, mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
583
 
584
                    if (mcapi_struct->status == MCAPI_SUCCESS)
585
                    {
586
                        /* Wait for a response. */
587
                        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
588
 
589
                        /* If the receive side was opened. */
590
                        if (mcapi_struct->status ==MGC_MCAPI_ERR_NOT_CONNECTED)
591
                        {
592
                            /* Get the send side endpoint. */
593
                            tx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024, &mcapi_struct->status);
594
 
595
                            if (mcapi_struct->status == MCAPI_SUCCESS)
596
                            {
597
                                /* Connect the two endpoints. */
598
                                mcapi_connect_sclchan_i(tx_endp, rx_endp,
599
                                                        &mcapi_struct->request,
600
                                                        &mcapi_struct->status);
601
 
602
                                if (mcapi_struct->status == MCAPI_SUCCESS)
603
                                {
604
                                    /* Wait for the connection to complete. */
605
                                    mcapi_wait(&mcapi_struct->request, &rx_len,
606
                                                &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
607
 
608
                                    /* Open the local endpoint as the receiver. */
609
                                    mcapi_open_sclchan_recv_i(&mcapi_struct->scl_rx_handle,
610
                                                              rx_endp, &request,
611
                                                              &mcapi_struct->status);
612
 
613
                                    if (mcapi_struct->status == MCAPI_SUCCESS)
614
                                    {
615
                                        /* Wait for the open to return successfully. */
616
                                        mcapi_wait(&request, &rx_len,
617
                                                   &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
618
 
619
                                        /* Tell the other side to send some data. */
620
                                        mcapi_struct->status =
621
                                            MCAPID_TX_Mgmt_Message(mcapi_struct, i, 1024,
622
                                                                   mcapi_struct->local_endp,
623
                                                                   0, MCAPI_DEFAULT_PRIO);
624
 
625
                                        if (mcapi_struct->status == MCAPI_SUCCESS)
626
                                        {
627
                                            /* Wait for the response. */
628
                                            mcapi_struct->status =
629
                                                MCAPID_RX_Mgmt_Response(mcapi_struct);
630
 
631
                                            if (mcapi_struct->status == MCAPI_SUCCESS)
632
                                            {
633
                                                /* Tell the other side to close the send side. */
634
                                                mcapi_struct->status =
635
                                                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CLOSE_TX_SIDE_SCL, 1024,
636
                                                                           mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
637
                                            }
638
 
639
                                            if (mcapi_struct->status == MCAPI_SUCCESS)
640
                                            {
641
                                                /* Wait for the response. */
642
                                                mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
643
                                            }
644
 
645
                                            if (mcapi_struct->status == MCAPI_SUCCESS)
646
                                            {
647
                                                /* Receive the proper scalar size. */
648
                                                switch (i)
649
                                                {
650
                                                    case MCAPID_TX_64_BIT_SCL:
651
 
652
                                                        recv_64bit =
653
                                                            mcapi_sclchan_recv_uint64(mcapi_struct->scl_rx_handle,
654
                                                                                      &mcapi_struct->status);
655
 
656
                                                        /* If success was returned with the wrong value,
657
                                                         * set an error.
658
                                                         */
659
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
660
                                                             (recv_64bit != MCAPI_FTS_64BIT_SCALAR) )
661
                                                        {
662
                                                            mcapi_struct->status = -1;
663
                                                        }
664
 
665
                                                        break;
666
 
667
                                                    case MCAPID_TX_32_BIT_SCL:
668
 
669
                                                        recv_32bit =
670
                                                            mcapi_sclchan_recv_uint32(mcapi_struct->scl_rx_handle,
671
                                                                                      &mcapi_struct->status);
672
 
673
                                                        /* If success was returned with the wrong value,
674
                                                         * set an error.
675
                                                         */
676
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
677
                                                             (recv_32bit != MCAPI_FTS_32BIT_SCALAR) )
678
                                                        {
679
                                                            mcapi_struct->status = -1;
680
                                                        }
681
 
682
                                                        break;
683
 
684
                                                    case MCAPID_TX_16_BIT_SCL:
685
 
686
                                                        recv_16bit =
687
                                                            mcapi_sclchan_recv_uint16(mcapi_struct->scl_rx_handle,
688
                                                                                      &mcapi_struct->status);
689
 
690
                                                        /* If success was returned with the wrong value,
691
                                                         * set an error.
692
                                                         */
693
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
694
                                                             (recv_16bit != MCAPI_FTS_16BIT_SCALAR) )
695
                                                        {
696
                                                            mcapi_struct->status = -1;
697
                                                        }
698
 
699
                                                        break;
700
 
701
                                                    case MCAPID_TX_8_BIT_SCL:
702
 
703
                                                        recv_8bit =
704
                                                            mcapi_sclchan_recv_uint8(mcapi_struct->scl_rx_handle,
705
                                                                                     &mcapi_struct->status);
706
 
707
                                                        /* If success was returned with the wrong value,
708
                                                         * set an error.
709
                                                         */
710
                                                        if ( (mcapi_struct->status == MCAPI_SUCCESS) &&
711
                                                             (recv_8bit != MCAPI_FTS_8BIT_SCALAR) )
712
                                                        {
713
                                                            mcapi_struct->status = -1;
714
                                                        }
715
 
716
                                                        break;
717
 
718
                                                    default:
719
 
720
                                                        break;
721
                                                }
722
 
723
                                                if (mcapi_struct->status != MCAPI_SUCCESS)
724
                                                    break;
725
                                            }
726
 
727
                                            else
728
                                                break;
729
                                        }
730
 
731
                                        else
732
                                            break;
733
                                    }
734
 
735
                                    /* Close the receive side. */
736
                                    mcapi_sclchan_recv_close_i(mcapi_struct->scl_rx_handle,
737
                                                               &request, &status);
738
                                }
739
                            }
740
                        }
741
                    }
742
                }
743
 
744
                /* Tell the other side to delete the endpoint. */
745
                status =
746
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
747
                                           mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
748
 
749
                if (status == MCAPI_SUCCESS)
750
                {
751
                    /* Wait for the response. */
752
                    status = MCAPID_RX_Mgmt_Response(mcapi_struct);
753
                }
754
            }
755
        }
756
 
757
        /* Delete the endpoint used in the connection. */
758
        mcapi_delete_endpoint(rx_endp, &status);
759
    }
760
 
761
    /* Set the state of the test to completed. */
762
    mcapi_struct->state = 0;
763
 
764
    /* Allow the next test to run. */
765
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
766
 
767
} /* MCAPI_FTS_Tx_2_29_3 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.