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_cancel.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
#include "mcapid.h"
41
 
42
extern MCAPI_MUTEX      MCAPID_FTS_Mutex;
43
 
44
/************************************************************************
45
*
46
*   FUNCTION
47
*
48
*       MCAPI_FTS_Tx_2_36_1
49
*
50
*   DESCRIPTION
51
*
52
*       Testing mcapi_cancel while getting a foreign endpoint.
53
*
54
*           Node 0 – Waits for get endpoint request, wait for request to
55
*           be canceled, create endpoint
56
*
57
*           Node 1 – Issue get endpoint request to Node 0, cancel request
58
*
59
*************************************************************************/
60
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_1)
61
{
62
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
63
    mcapi_endpoint_t    endpoint;
64
    mcapi_status_t      status;
65
 
66
    /* Don't let any other test run while this test is running. */
67
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
68
 
69
    /* Set endpoint to 0xffffffff for testing purposes. */
70
    endpoint = 0xffffffff;
71
 
72
    /* Get the foreign endpoint. */
73
    mcapi_get_endpoint_i(0, 1024, &endpoint, &mcapi_struct->request,
74
                         &mcapi_struct->status);
75
 
76
    if (mcapi_struct->status == MCAPI_SUCCESS)
77
    {
78
        /* Cancel the request. */
79
        mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
80
 
81
        /* Indicate that the endpoint should be created. */
82
        status =
83
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
84
                                   mcapi_struct->local_endp, 500, MCAPI_DEFAULT_PRIO);
85
 
86
        /* Wait for a response. */
87
        if (status == MCAPI_SUCCESS)
88
        {
89
            /* Wait for a response. */
90
            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
91
 
92
            MCAPID_Sleep(1000);
93
 
94
            /* Ensure the endpoint pointer was not updated when the
95
             * endpoint was created.
96
             */
97
            if (endpoint != 0xffffffff)
98
            {
99
                mcapi_struct->status = -1;
100
            }
101
 
102
            /* Tell the other side to delete the endpoint. */
103
            status =
104
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
105
                                       mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
106
 
107
            if (status == MCAPI_SUCCESS)
108
            {
109
                /* Wait for a response before releasing the mutex. */
110
                status = MCAPID_RX_Mgmt_Response(mcapi_struct);
111
            }
112
        }
113
    }
114
 
115
    /* Set the state of the test to completed. */
116
    mcapi_struct->state = 0;
117
 
118
    /* Allow the next test to run. */
119
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
120
 
121
} /* MCAPI_FTS_Tx_2_36_1 */
122
 
123
#ifdef LCL_MGMT_UNBROKEN
124
/************************************************************************
125
*
126
*   FUNCTION
127
*
128
*       MCAPI_FTS_Tx_2_36_2
129
*
130
*   DESCRIPTION
131
*
132
*       Testing mcapi_cancel while getting a foreign endpoint with
133
*       multiple threads waiting for the request.
134
*
135
*           Node 0 – Waits for get endpoint request, wait for request to
136
*           be canceled, create endpoint
137
*
138
*           Node 1 – Issue get endpoint request to Node 0, cause another
139
*                    thread to also wait for completion of the request,
140
*                    cancel request
141
*
142
*************************************************************************/
143
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_2)
144
{
145
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv, svc_struct;
146
    mcapi_endpoint_t    endpoint;
147
    mcapi_status_t      status;
148
 
149
    /* Don't let any other test run while this test is running. */
150
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
151
 
152
    /* Set up the structure for getting the local management server. */
153
    svc_struct.type = MCAPI_MSG_TX_TYPE;
154
    svc_struct.local_port = MCAPI_PORT_ANY;
155
    svc_struct.node = FUNC_FRONTEND_NODE_ID;
156
    svc_struct.service = "lcl_mgmt";
157
    svc_struct.thread_entry = MCAPI_NULL;
158
 
159
    /* Create the client service. */
160
    MCAPID_Create_Service(&svc_struct);
161
 
162
    /* Set endpoint to 0xffffffff for testing purposes. */
163
    endpoint = 0xffffffff;
164
 
165
    /* Get the foreign endpoint. */
166
    mcapi_get_endpoint_i(0, 1024, &endpoint, &svc_struct.request,
167
                         &mcapi_struct->status);
168
 
169
    if (mcapi_struct->status == MCAPI_SUCCESS)
170
    {
171
        /* Cause another thread to wait on the request too. */
172
        mcapi_struct->status =
173
            MCAPID_TX_Mgmt_Message(&svc_struct, MCAPID_WAIT_REQUEST, 0,
174
                                   svc_struct.local_endp, 0,
175
                                   MCAPI_DEFAULT_PRIO);
176
 
177
        /* Let the thread wait. */
178
        MCAPID_Sleep(1000);
179
 
180
        /* Cancel the request. */
181
        mcapi_cancel(&svc_struct.request, &mcapi_struct->status);
182
 
183
        /* Wait for a response from the thread waiting for the request. */
184
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(&svc_struct);
185
 
186
        if (mcapi_struct->status != MCAPI_ERR_REQUEST_CANCELLED)
187
        {
188
            mcapi_struct->status = -1;
189
        }
190
 
191
        else
192
        {
193
            /* Indicate that the endpoint should be created. */
194
            mcapi_struct->status =
195
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
196
                                       mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
197
 
198
            /* Wait for a response. */
199
            if (mcapi_struct->status == MCAPI_SUCCESS)
200
            {
201
                /* Wait for a response. */
202
                mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
203
 
204
                MCAPID_Sleep(1000);
205
 
206
                /* Ensure the endpoint pointer was not updated when the
207
                 * endpoint was created.
208
                 */
209
                if (endpoint != 0xffffffff)
210
                {
211
                    mcapi_struct->status = -1;
212
                }
213
 
214
                /* Tell the other side to delete the endpoint. */
215
                status =
216
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
217
                                           mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
218
 
219
                if (status == MCAPI_SUCCESS)
220
                {
221
                    /* Wait for a response before releasing the mutex. */
222
                    status = MCAPID_RX_Mgmt_Response(mcapi_struct);
223
                }
224
            }
225
        }
226
    }
227
 
228
    /* Destroy the client service. */
229
    MCAPID_Destroy_Service(&svc_struct, 1);
230
 
231
    /* Set the state of the test to completed. */
232
    mcapi_struct->state = 0;
233
 
234
    /* Allow the next test to run. */
235
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
236
 
237
} /* MCAPI_FTS_Tx_2_36_2 */
238
#endif
239
 
240
/************************************************************************
241
*
242
*   FUNCTION
243
*
244
*       MCAPI_FTS_Tx_2_36_3
245
*
246
*   DESCRIPTION
247
*
248
*       Testing mcapi_cancel for mcapi_msg_recv_i().
249
*
250
*           Node 0 – Wait for message receive request to be canceled,
251
*                    transmit data to endpoint
252
*
253
*           Node 1 – Issue message receive call on endpoint, cancel request
254
*
255
*************************************************************************/
256
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_3)
257
{
258
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
259
    mcapi_endpoint_t    rx_endp;
260
    mcapi_status_t      status;
261
    char                buffer[MCAPID_MGMT_PKT_LEN];
262
 
263
    /* Don't let any other test run while this test is running. */
264
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
265
 
266
    /* An extra endpoint is required for this test. */
267
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
268
 
269
    if (mcapi_struct->status == MCAPI_SUCCESS)
270
    {
271
        memset(buffer, 0, MCAPID_MGMT_PKT_LEN);
272
 
273
        /* Make the call to receive data on this endpoint. */
274
        mcapi_msg_recv_i(rx_endp, buffer, MCAPID_MGMT_PKT_LEN,
275
                         &mcapi_struct->request, &mcapi_struct->status);
276
 
277
        if (mcapi_struct->status == MCAPI_SUCCESS)
278
        {
279
            /* Cancel the request. */
280
            mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
281
 
282
            /* Indicate that an endpoint should be created. */
283
            mcapi_struct->status =
284
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
285
                                       mcapi_struct->local_endp, 500, MCAPI_DEFAULT_PRIO);
286
 
287
            /* Wait for a response. */
288
            if (mcapi_struct->status == MCAPI_SUCCESS)
289
            {
290
                /* Wait for a response. */
291
                mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
292
 
293
                if (mcapi_struct->status == MCAPI_SUCCESS)
294
                {
295
                    /* Indicate that a message should be sent. */
296
                    mcapi_struct->status =
297
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP,
298
                                               1024, rx_endp, 0, MCAPI_DEFAULT_PRIO);
299
 
300
                    if (mcapi_struct->status == MCAPI_SUCCESS)
301
                    {
302
                        /* Wait for the data. */
303
                        MCAPID_Sleep(1000);
304
 
305
                        /* Ensure the data is still on the endpoint waiting to
306
                         * be received.
307
                         */
308
                        if (mcapi_msg_available(rx_endp, &status) != 1)
309
                        {
310
                            mcapi_struct->status = -1;
311
                        }
312
                    }
313
 
314
                    /* Tell the other side to delete the endpoint. */
315
                    status =
316
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
317
                                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
318
 
319
                    if (status == MCAPI_SUCCESS)
320
                    {
321
                        /* Wait for a response before releasing the mutex. */
322
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
323
                    }
324
                }
325
            }
326
        }
327
 
328
        /* Delete the extra endpoint. */
329
        mcapi_delete_endpoint(rx_endp, &status);
330
    }
331
 
332
    /* Set the state of the test to completed. */
333
    mcapi_struct->state = 0;
334
 
335
    /* Allow the next test to run. */
336
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
337
 
338
} /* MCAPI_FTS_Tx_2_36_3 */
339
 
340
/************************************************************************
341
*
342
*   FUNCTION
343
*
344
*       MCAPI_FTS_Tx_2_36_4
345
*
346
*   DESCRIPTION
347
*
348
*       Testing mcapi_cancel for mcapi_open_pktchan_recv_i().
349
*
350
*           Node 0 – Wait for open packet channel request to be canceled,
351
*                    open connection
352
*
353
*           Node 1 – Issue call to open receive side of packet channel,
354
*                    cancel request, ensure endpoint is reusable for channel
355
*                    connection or message send/recv
356
*
357
*************************************************************************/
358
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_4)
359
{
360
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
361
    mcapi_endpoint_t    rx_endp, tx_endp;
362
    size_t              rx_len = 0;
363
    mcapi_status_t      status;
364
 
365
    /* Don't let any other test run while this test is running. */
366
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
367
 
368
    /* An extra endpoint is required for this test. */
369
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
370
 
371
    if (mcapi_struct->status == MCAPI_SUCCESS)
372
    {
373
        /* Open receive side of a packet channel. */
374
        mcapi_open_pktchan_recv_i(&mcapi_struct->pkt_rx_handle, rx_endp,
375
                                  &mcapi_struct->request,
376
                                  &mcapi_struct->status);
377
 
378
        if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
379
        {
380
            /* Cancel the request. */
381
            mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
382
 
383
            if (mcapi_struct->status == MCAPI_SUCCESS)
384
            {
385
                /* Indicate that an endpoint should be created. */
386
                mcapi_struct->status =
387
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP,
388
                                           1024, mcapi_struct->local_endp, 0,
389
                                           MCAPI_DEFAULT_PRIO);
390
 
391
                if (mcapi_struct->status == MCAPI_SUCCESS)
392
                {
393
                    /* Wait for a response. */
394
                    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
395
 
396
                    if (mcapi_struct->status == MCAPI_SUCCESS)
397
                    {
398
                        /* Indicate that the send side should be opened. */
399
                        mcapi_struct->status =
400
                            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_TX_SIDE_PKT,
401
                                                   1024, mcapi_struct->local_endp, 0,
402
                                                   MCAPI_DEFAULT_PRIO);
403
 
404
                        /* Wait for a response. */
405
                        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
406
                    }
407
                }
408
 
409
                if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
410
                {
411
                    /* Get the foreign endpoint. */
412
                    tx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024,
413
                                                 &mcapi_struct->status);
414
 
415
                    if (mcapi_struct->status == MCAPI_SUCCESS)
416
                    {
417
                        /* Connect the two endpoints. */
418
                        mcapi_connect_pktchan_i(tx_endp, rx_endp,
419
                                                &mcapi_struct->request,
420
                                                &mcapi_struct->status);
421
 
422
                        if (mcapi_struct->status == MCAPI_SUCCESS)
423
                        {
424
                            /* Wait for the connection. */
425
                            mcapi_wait(&mcapi_struct->request, &rx_len,
426
                                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
427
 
428
                            if (mcapi_struct->status == MCAPI_SUCCESS)
429
                            {
430
                                /* Try to close the receive side. */
431
                                mcapi_packetchan_recv_close_i(mcapi_struct->pkt_rx_handle,
432
                                                              &mcapi_struct->request,
433
                                                              &mcapi_struct->status);
434
 
435
                                /* An error should be returned since the call to open
436
                                 * the receive side was canceled.
437
                                 */
438
                                if (mcapi_struct->status == MCAPI_ERR_CHAN_NOTOPEN)
439
                                {
440
                                    mcapi_struct->status = MCAPI_SUCCESS;
441
                                }
442
 
443
                                else
444
                                {
445
                                    mcapi_struct->status = -1;
446
                                }
447
                            }
448
                        }
449
                    }
450
 
451
                    /* Indicate that the send side should be closed. */
452
                    status =
453
                        MCAPID_TX_Mgmt_Message(mcapi_struct,
454
                                               MCAPID_MGMT_CLOSE_TX_SIDE_PKT, 1024,
455
                                               mcapi_struct->local_endp, 0,
456
                                               MCAPI_DEFAULT_PRIO);
457
 
458
                    if (status == MCAPI_SUCCESS)
459
                    {
460
                        /* Wait for a response. */
461
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
462
                    }
463
 
464
                    /* Indicate that an endpoint should be deleted. */
465
                    status =
466
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP,
467
                                               1024, mcapi_struct->local_endp, 0,
468
                                               MCAPI_DEFAULT_PRIO);
469
 
470
                    if (status == MCAPI_SUCCESS)
471
                    {
472
                        /* Wait for a response. */
473
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
474
                    }
475
                }
476
            }
477
        }
478
 
479
        /* Delete the extra endpoint. */
480
        mcapi_delete_endpoint(rx_endp, &status);
481
    }
482
 
483
    /* Set the state of the test to completed. */
484
    mcapi_struct->state = 0;
485
 
486
    /* Allow the next test to run. */
487
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
488
 
489
} /* MCAPI_FTS_Tx_2_36_4 */
490
 
491
/************************************************************************
492
*
493
*   FUNCTION
494
*
495
*       MCAPI_FTS_Tx_2_36_5
496
*
497
*   DESCRIPTION
498
*
499
*       Testing mcapi_cancel for mcapi_open_pktchan_send_i().
500
*
501
*           Node 0 – Wait for open packet channel request to be canceled,
502
*                    open connection
503
*
504
*           Node 1 – Issue call to open send side of packet channel,
505
*                    cancel request, ensure endpoint is reusable for channel
506
*                    connection or message send/recv
507
*
508
*************************************************************************/
509
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_5)
510
{
511
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
512
    mcapi_endpoint_t    rx_endp, tx_endp;
513
    size_t              rx_len = 0;
514
    mcapi_status_t      status;
515
 
516
    /* Don't let any other test run while this test is running. */
517
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
518
 
519
    /* An extra endpoint is required for this test. */
520
    tx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
521
 
522
    if (mcapi_struct->status == MCAPI_SUCCESS)
523
    {
524
        /* Open send side of a packet channel. */
525
        mcapi_open_pktchan_send_i(&mcapi_struct->pkt_tx_handle, tx_endp,
526
                                  &mcapi_struct->request,
527
                                  &mcapi_struct->status);
528
 
529
        if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
530
        {
531
            /* Cancel the request. */
532
            mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
533
 
534
            if (mcapi_struct->status == MCAPI_SUCCESS)
535
            {
536
                /* Indicate that an endpoint should be created. */
537
                mcapi_struct->status =
538
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP,
539
                                           1024, mcapi_struct->local_endp, 0,
540
                                           MCAPI_DEFAULT_PRIO);
541
 
542
                if (mcapi_struct->status == MCAPI_SUCCESS)
543
                {
544
                    /* Wait for a response. */
545
                    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
546
 
547
                    if (mcapi_struct->status == MCAPI_SUCCESS)
548
                    {
549
                        /* Indicate that the receive side should be opened. */
550
                        mcapi_struct->status =
551
                            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_RX_SIDE_PKT,
552
                                                   1024, mcapi_struct->local_endp, 0,
553
                                                   MCAPI_DEFAULT_PRIO);
554
 
555
                        /* Wait for a response. */
556
                        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
557
                    }
558
                }
559
 
560
                if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
561
                {
562
                    /* Get the foreign endpoint. */
563
                    rx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024,
564
                                                 &mcapi_struct->status);
565
 
566
                    if (mcapi_struct->status == MCAPI_SUCCESS)
567
                    {
568
                        /* Connect the two endpoints. */
569
                        mcapi_connect_pktchan_i(tx_endp, rx_endp,
570
                                                &mcapi_struct->request,
571
                                                &mcapi_struct->status);
572
 
573
                        if (mcapi_struct->status == MCAPI_SUCCESS)
574
                        {
575
                            /* Wait for the connection. */
576
                            mcapi_wait(&mcapi_struct->request, &rx_len,
577
                                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
578
 
579
                            if (mcapi_struct->status == MCAPI_SUCCESS)
580
                            {
581
                                /* Try to close the send side. */
582
                                mcapi_packetchan_send_close_i(mcapi_struct->pkt_tx_handle,
583
                                                              &mcapi_struct->request,
584
                                                              &mcapi_struct->status);
585
 
586
                                /* An error should be returned since the call to open
587
                                 * the receive side was canceled.
588
                                 */
589
                                if (mcapi_struct->status == MCAPI_ERR_CHAN_NOTOPEN)
590
                                {
591
                                    mcapi_struct->status = MCAPI_SUCCESS;
592
                                }
593
 
594
                                else
595
                                {
596
                                    mcapi_struct->status = -1;
597
                                }
598
                            }
599
                        }
600
                    }
601
 
602
                    /* Indicate that the receive side should be closed. */
603
                    status =
604
                        MCAPID_TX_Mgmt_Message(mcapi_struct,
605
                                               MCAPID_MGMT_CLOSE_RX_SIDE_PKT, 1024,
606
                                               mcapi_struct->local_endp, 0,
607
                                               MCAPI_DEFAULT_PRIO);
608
 
609
                    if (status == MCAPI_SUCCESS)
610
                    {
611
                        /* Wait for a response. */
612
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
613
                    }
614
 
615
                    /* Indicate that an endpoint should be deleted. */
616
                    status =
617
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP,
618
                                               1024, mcapi_struct->local_endp, 0,
619
                                               MCAPI_DEFAULT_PRIO);
620
 
621
                    if (status == MCAPI_SUCCESS)
622
                    {
623
                        /* Wait for a response. */
624
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
625
                    }
626
                }
627
            }
628
        }
629
 
630
        /* Delete the extra endpoint. */
631
        mcapi_delete_endpoint(tx_endp, &status);
632
    }
633
 
634
    /* Set the state of the test to completed. */
635
    mcapi_struct->state = 0;
636
 
637
    /* Allow the next test to run. */
638
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
639
 
640
} /* MCAPI_FTS_Tx_2_36_5 */
641
 
642
/************************************************************************
643
*
644
*   FUNCTION
645
*
646
*       MCAPI_FTS_Tx_2_36_6
647
*
648
*   DESCRIPTION
649
*
650
*       Testing mcapi_cancel for mcapi_pktchan_recv_i().
651
*
652
*           Node 0 – Wait for packet channel receive request to be canceled,
653
*                    transmit data to endpoint
654
*
655
*           Node 1 – Issue call to receive data over packet channel,
656
*                    cancel request
657
*
658
*************************************************************************/
659
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_6)
660
{
661
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
662
    mcapi_endpoint_t    rx_endp, tx_endp;
663
    size_t              rx_len = 0;
664
    mcapi_status_t      status;
665
    char                *buffer;
666
 
667
    /* Don't let any other test run while this test is running. */
668
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
669
 
670
    /* An extra endpoint is required for this test. */
671
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
672
 
673
    if (mcapi_struct->status == MCAPI_SUCCESS)
674
    {
675
        /* Indicate that an endpoint should be created. */
676
        mcapi_struct->status =
677
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP,
678
                                   1024, mcapi_struct->local_endp, 0,
679
                                   MCAPI_DEFAULT_PRIO);
680
 
681
        if (mcapi_struct->status == MCAPI_SUCCESS)
682
        {
683
            /* Wait for a response. */
684
            mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
685
 
686
            if (mcapi_struct->status == MCAPI_SUCCESS)
687
            {
688
                /* Indicate that the send side should be opened. */
689
                mcapi_struct->status =
690
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_TX_SIDE_PKT,
691
                                           1024, mcapi_struct->local_endp, 0,
692
                                           MCAPI_DEFAULT_PRIO);
693
 
694
                /* Wait for a response. */
695
                mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
696
            }
697
        }
698
 
699
        if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
700
        {
701
            /* Get the foreign endpoint. */
702
            tx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024,
703
                                         &mcapi_struct->status);
704
 
705
            if (mcapi_struct->status == MCAPI_SUCCESS)
706
            {
707
                /* Connect the two endpoints. */
708
                mcapi_connect_pktchan_i(tx_endp, rx_endp,
709
                                        &mcapi_struct->request,
710
                                        &mcapi_struct->status);
711
 
712
                if (mcapi_struct->status == MCAPI_SUCCESS)
713
                {
714
                    /* Wait for the connection. */
715
                    mcapi_wait(&mcapi_struct->request, &rx_len,
716
                               &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
717
 
718
                    /* Open receive side of a packet channel. */
719
                    mcapi_open_pktchan_recv_i(&mcapi_struct->pkt_rx_handle, rx_endp,
720
                                              &mcapi_struct->request,
721
                                              &mcapi_struct->status);
722
 
723
                    if (mcapi_struct->status == MCAPI_SUCCESS)
724
                    {
725
                        /* Wait for the open to complete. */
726
                        mcapi_wait(&mcapi_struct->request, &rx_len,
727
                                   &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
728
 
729
                        /* Issue a call to receive a packet. */
730
                        mcapi_pktchan_recv_i(mcapi_struct->pkt_rx_handle,
731
                                             (void**)&buffer,
732
                                             &mcapi_struct->request,
733
                                             &mcapi_struct->status);
734
 
735
                        /* Cancel the call to receive a packet. */
736
                        mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
737
 
738
                        /* Tell the other side to send some data. */
739
                        mcapi_struct->status =
740
                            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_TX_PKT,
741
                                                   1024, mcapi_struct->local_endp,
742
                                                   0, MCAPI_DEFAULT_PRIO);
743
 
744
                        if (mcapi_struct->status == MCAPI_SUCCESS)
745
                        {
746
                            /* Wait for the response. */
747
                            mcapi_struct->status =
748
                                MCAPID_RX_Mgmt_Response(mcapi_struct);
749
 
750
                            if (mcapi_struct->status == MCAPI_SUCCESS)
751
                            {
752
                                /* Ensure the data is still on the endpoint waiting to
753
                                 * be received.
754
                                 */
755
                                if (mcapi_pktchan_available(mcapi_struct->pkt_rx_handle,
756
                                                            &mcapi_struct->status) != 1)
757
                                {
758
                                    mcapi_struct->status = -1;
759
                                }
760
                            }
761
                        }
762
 
763
                        /* Close the receive side. */
764
                        mcapi_packetchan_recv_close_i(mcapi_struct->pkt_rx_handle,
765
                                                      &mcapi_struct->request,
766
                                                      &mcapi_struct->status);
767
                    }
768
                }
769
            }
770
 
771
            /* Indicate that the send side should be closed. */
772
            status =
773
                MCAPID_TX_Mgmt_Message(mcapi_struct,
774
                                       MCAPID_MGMT_CLOSE_TX_SIDE_PKT, 1024,
775
                                       mcapi_struct->local_endp, 0,
776
                                       MCAPI_DEFAULT_PRIO);
777
 
778
            if (status == MCAPI_SUCCESS)
779
            {
780
                /* Wait for a response. */
781
                status = MCAPID_RX_Mgmt_Response(mcapi_struct);
782
            }
783
 
784
            /* Indicate that an endpoint should be deleted. */
785
            status =
786
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP,
787
                                       1024, mcapi_struct->local_endp, 0,
788
                                       MCAPI_DEFAULT_PRIO);
789
 
790
            if (status == MCAPI_SUCCESS)
791
            {
792
                /* Wait for a response. */
793
                status = MCAPID_RX_Mgmt_Response(mcapi_struct);
794
            }
795
        }
796
 
797
        /* Delete the extra endpoint. */
798
        mcapi_delete_endpoint(rx_endp, &status);
799
    }
800
 
801
    /* Set the state of the test to completed. */
802
    mcapi_struct->state = 0;
803
 
804
    /* Allow the next test to run. */
805
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
806
 
807
} /* MCAPI_FTS_Tx_2_36_6 */
808
 
809
/************************************************************************
810
*
811
*   FUNCTION
812
*
813
*       MCAPI_FTS_Tx_2_36_7
814
*
815
*   DESCRIPTION
816
*
817
*       Testing mcapi_cancel for mcapi_open_sclchan_recv_i().
818
*
819
*           Node 0 – Wait for open scalar channel request to be canceled,
820
*                    open connection
821
*
822
*           Node 1 – Issue call to open receive side of scalar channel,
823
*                    cancel request, ensure endpoint is reusable for channel
824
*                    connection or message send/recv
825
*
826
*************************************************************************/
827
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_7)
828
{
829
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
830
    mcapi_endpoint_t    rx_endp, tx_endp;
831
    size_t              rx_len = 0;
832
    mcapi_status_t      status;
833
 
834
    /* Don't let any other test run while this test is running. */
835
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
836
 
837
    /* An extra endpoint is required for this test. */
838
    rx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
839
 
840
    if (mcapi_struct->status == MCAPI_SUCCESS)
841
    {
842
        /* Open receive side of a scalar channel. */
843
        mcapi_open_sclchan_recv_i(&mcapi_struct->scl_rx_handle, rx_endp,
844
                                  &mcapi_struct->request,
845
                                  &mcapi_struct->status);
846
 
847
        if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
848
        {
849
            /* Cancel the request. */
850
            mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
851
 
852
            if (mcapi_struct->status == MCAPI_SUCCESS)
853
            {
854
                /* Indicate that an endpoint should be created. */
855
                mcapi_struct->status =
856
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP,
857
                                           1024, mcapi_struct->local_endp, 0,
858
                                           MCAPI_DEFAULT_PRIO);
859
 
860
                if (mcapi_struct->status == MCAPI_SUCCESS)
861
                {
862
                    /* Wait for a response. */
863
                    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
864
 
865
                    if (mcapi_struct->status == MCAPI_SUCCESS)
866
                    {
867
                        /* Indicate that the send side should be opened. */
868
                        mcapi_struct->status =
869
                            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_TX_SIDE_SCL,
870
                                                   1024, mcapi_struct->local_endp, 0,
871
                                                   MCAPI_DEFAULT_PRIO);
872
 
873
                        /* Wait for a response. */
874
                        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
875
                    }
876
                }
877
 
878
                if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
879
                {
880
                    /* Get the foreign endpoint. */
881
                    tx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024,
882
                                                 &mcapi_struct->status);
883
 
884
                    if (mcapi_struct->status == MCAPI_SUCCESS)
885
                    {
886
                        /* Connect the two endpoints. */
887
                        mcapi_connect_sclchan_i(tx_endp, rx_endp,
888
                                                &mcapi_struct->request,
889
                                                &mcapi_struct->status);
890
 
891
                        if (mcapi_struct->status == MCAPI_SUCCESS)
892
                        {
893
                            /* Wait for the connection. */
894
                            mcapi_wait(&mcapi_struct->request, &rx_len,
895
                                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
896
 
897
                            if (mcapi_struct->status == MCAPI_SUCCESS)
898
                            {
899
                                /* Try to close the receive side. */
900
                                mcapi_sclchan_recv_close_i(mcapi_struct->scl_rx_handle,
901
                                                           &mcapi_struct->request,
902
                                                           &mcapi_struct->status);
903
 
904
                                /* An error should be returned since the call to open
905
                                 * the receive side was canceled.
906
                                 */
907
                                if (mcapi_struct->status == MCAPI_ERR_CHAN_NOTOPEN)
908
                                {
909
                                    mcapi_struct->status = MCAPI_SUCCESS;
910
                                }
911
 
912
                                else
913
                                {
914
                                    mcapi_struct->status = -1;
915
                                }
916
                            }
917
                        }
918
                    }
919
 
920
                    /* Indicate that the send side should be closed. */
921
                    status =
922
                        MCAPID_TX_Mgmt_Message(mcapi_struct,
923
                                               MCAPID_MGMT_CLOSE_TX_SIDE_SCL, 1024,
924
                                               mcapi_struct->local_endp, 0,
925
                                               MCAPI_DEFAULT_PRIO);
926
 
927
                    if (status == MCAPI_SUCCESS)
928
                    {
929
                        /* Wait for a response. */
930
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
931
                    }
932
 
933
                    /* Indicate that an endpoint should be deleted. */
934
                    status =
935
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP,
936
                                               1024, mcapi_struct->local_endp, 0,
937
                                               MCAPI_DEFAULT_PRIO);
938
 
939
                    if (status == MCAPI_SUCCESS)
940
                    {
941
                        /* Wait for a response. */
942
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
943
                    }
944
                }
945
            }
946
        }
947
 
948
        /* Delete the extra endpoint. */
949
        mcapi_delete_endpoint(rx_endp, &status);
950
    }
951
 
952
    /* Set the state of the test to completed. */
953
    mcapi_struct->state = 0;
954
 
955
    /* Allow the next test to run. */
956
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
957
 
958
} /* MCAPI_FTS_Tx_2_36_7 */
959
 
960
/************************************************************************
961
*
962
*   FUNCTION
963
*
964
*       MCAPI_FTS_Tx_2_36_8
965
*
966
*   DESCRIPTION
967
*
968
*       Testing mcapi_cancel for mcapi_open_sclchan_send_i().
969
*
970
*           Node 0 – Wait for open scalar channel request to be canceled,
971
*                    open connection
972
*
973
*           Node 1 – Issue call to open send side of scalar channel,
974
*                    cancel request, ensure endpoint is reusable for channel
975
*                    connection or message send/recv
976
*
977
*************************************************************************/
978
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_36_8)
979
{
980
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
981
    mcapi_endpoint_t    rx_endp, tx_endp;
982
    size_t              rx_len = 0;
983
    mcapi_status_t      status;
984
 
985
    /* Don't let any other test run while this test is running. */
986
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
987
 
988
    /* An extra endpoint is required for this test. */
989
    tx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
990
 
991
    if (mcapi_struct->status == MCAPI_SUCCESS)
992
    {
993
        /* Open send side of a scalar channel. */
994
        mcapi_open_sclchan_send_i(&mcapi_struct->scl_tx_handle, tx_endp,
995
                                  &mcapi_struct->request,
996
                                  &mcapi_struct->status);
997
 
998
        if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
999
        {
1000
            /* Cancel the request. */
1001
            mcapi_cancel(&mcapi_struct->request, &mcapi_struct->status);
1002
 
1003
            if (mcapi_struct->status == MCAPI_SUCCESS)
1004
            {
1005
                /* Indicate that an endpoint should be created. */
1006
                mcapi_struct->status =
1007
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP,
1008
                                           1024, mcapi_struct->local_endp, 0,
1009
                                           MCAPI_DEFAULT_PRIO);
1010
 
1011
                if (mcapi_struct->status == MCAPI_SUCCESS)
1012
                {
1013
                    /* Wait for a response. */
1014
                    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
1015
 
1016
                    if (mcapi_struct->status == MCAPI_SUCCESS)
1017
                    {
1018
                        /* Indicate that the receive side should be opened. */
1019
                        mcapi_struct->status =
1020
                            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_OPEN_RX_SIDE_SCL,
1021
                                                   1024, mcapi_struct->local_endp, 0,
1022
                                                   MCAPI_DEFAULT_PRIO);
1023
 
1024
                        /* Wait for a response. */
1025
                        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
1026
                    }
1027
                }
1028
 
1029
                if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
1030
                {
1031
                    /* Get the foreign endpoint. */
1032
                    rx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024,
1033
                                                 &mcapi_struct->status);
1034
 
1035
                    if (mcapi_struct->status == MCAPI_SUCCESS)
1036
                    {
1037
                        /* Connect the two endpoints. */
1038
                        mcapi_connect_sclchan_i(tx_endp, rx_endp,
1039
                                                &mcapi_struct->request,
1040
                                                &mcapi_struct->status);
1041
 
1042
                        if (mcapi_struct->status == MCAPI_SUCCESS)
1043
                        {
1044
                            /* Wait for the connection. */
1045
                            mcapi_wait(&mcapi_struct->request, &rx_len,
1046
                                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
1047
 
1048
                            if (mcapi_struct->status == MCAPI_SUCCESS)
1049
                            {
1050
                                /* Try to close the send side. */
1051
                                mcapi_sclchan_send_close_i(mcapi_struct->scl_tx_handle,
1052
                                                           &mcapi_struct->request,
1053
                                                           &mcapi_struct->status);
1054
 
1055
                                /* An error should be returned since the call to open
1056
                                 * the receive side was canceled.
1057
                                 */
1058
                                if (mcapi_struct->status == MCAPI_ERR_CHAN_NOTOPEN)
1059
                                {
1060
                                    mcapi_struct->status = MCAPI_SUCCESS;
1061
                                }
1062
 
1063
                                else
1064
                                {
1065
                                    mcapi_struct->status = -1;
1066
                                }
1067
                            }
1068
                        }
1069
                    }
1070
 
1071
                    /* Indicate that the receive side should be closed. */
1072
                    status =
1073
                        MCAPID_TX_Mgmt_Message(mcapi_struct,
1074
                                               MCAPID_MGMT_CLOSE_RX_SIDE_SCL, 1024,
1075
                                               mcapi_struct->local_endp, 0,
1076
                                               MCAPI_DEFAULT_PRIO);
1077
 
1078
                    if (status == MCAPI_SUCCESS)
1079
                    {
1080
                        /* Wait for a response. */
1081
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
1082
                    }
1083
 
1084
                    /* Indicate that an endpoint should be deleted. */
1085
                    status =
1086
                        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP,
1087
                                               1024, mcapi_struct->local_endp, 0,
1088
                                               MCAPI_DEFAULT_PRIO);
1089
 
1090
                    if (status == MCAPI_SUCCESS)
1091
                    {
1092
                        /* Wait for a response. */
1093
                        status = MCAPID_RX_Mgmt_Response(mcapi_struct);
1094
                    }
1095
                }
1096
            }
1097
        }
1098
 
1099
        /* Delete the extra endpoint. */
1100
        mcapi_delete_endpoint(tx_endp, &status);
1101
    }
1102
 
1103
    /* Set the state of the test to completed. */
1104
    mcapi_struct->state = 0;
1105
 
1106
    /* Allow the next test to run. */
1107
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
1108
 
1109
} /* MCAPI_FTS_Tx_2_36_8 */

powered by: WebSVN 2.1.0

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