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_send_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_28_1
48
*
49
*   DESCRIPTION
50
*
51
*       Testing mcapi_sclchan_send_uint64, mcapi_sclchan_send_uint32,
52
*       mcapi_sclchan_send_uint16, mcapi_sclchan_send_uint8 - send data
53
*       over open connection.
54
*
55
*       For each scalar size:
56
*
57
*           Node 0 – Create endpoint, open receive side, wait for data
58
*
59
*           Node 1 – Create endpoint, open send side, get endpoint on
60
*                    Node 0, issue connection, send data
61
*
62
*************************************************************************/
63
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_28_1)
64
{
65
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
66
    size_t                      rx_len;
67
    mcapi_status_t              status;
68
    mcapi_endpoint_t            rx_endp;
69
    mcapi_request_t             request;
70
    int                         i;
71
 
72
    /* Don't let any other test run while this test is running. */
73
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
74
 
75
    /* Send a scalar of each size to the other side. */
76
    for (i = MCAPID_RX_64_BIT_SCL; i <= MCAPID_RX_8_BIT_SCL; i ++)
77
    {
78
        /* Tell the other side to receive the specified scalar size. */
79
        mcapi_struct->status = MCAPI_FTS_Specify_Scalar_Size(mcapi_struct, i);
80
 
81
        if (mcapi_struct->status == MCAPI_SUCCESS)
82
        {
83
            /* Wait for the response. */
84
            mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
85
 
86
            if (mcapi_struct->status == MCAPI_SUCCESS)
87
            {
88
                /* Open the local endpoint as the sender. */
89
                mcapi_open_sclchan_send_i(&mcapi_struct->scl_tx_handle,
90
                                          mcapi_struct->local_endp,
91
                                          &request, &mcapi_struct->status);
92
 
93
                if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
94
                {
95
                    /* Get the receive side endpoint. */
96
                    rx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, mcapi_struct->foreign_endp,
97
                                                 &mcapi_struct->status);
98
 
99
                    if (mcapi_struct->status == MCAPI_SUCCESS)
100
                    {
101
                        /* Connect the two endpoints. */
102
                        mcapi_connect_sclchan_i(mcapi_struct->local_endp, rx_endp,
103
                                                &mcapi_struct->request,
104
                                                &mcapi_struct->status);
105
 
106
                        if (mcapi_struct->status == MCAPI_SUCCESS)
107
                        {
108
                            mcapi_wait(&request, &rx_len,
109
                                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
110
 
111
                            if (mcapi_struct->status == MCAPI_SUCCESS)
112
                            {
113
                                /* Send some data. */
114
                                switch (i)
115
                                {
116
                                    case MCAPID_RX_64_BIT_SCL:
117
 
118
                                        mcapi_sclchan_send_uint64(mcapi_struct->scl_tx_handle,
119
                                                                  MCAPI_FTS_64BIT_SCALAR,
120
                                                                  &mcapi_struct->status);
121
 
122
                                        break;
123
 
124
                                    case MCAPID_RX_32_BIT_SCL:
125
 
126
                                        mcapi_sclchan_send_uint32(mcapi_struct->scl_tx_handle,
127
                                                                  MCAPI_FTS_32BIT_SCALAR,
128
                                                                  &mcapi_struct->status);
129
 
130
                                        break;
131
 
132
                                    case MCAPID_RX_16_BIT_SCL:
133
 
134
                                        mcapi_sclchan_send_uint16(mcapi_struct->scl_tx_handle,
135
                                                                  MCAPI_FTS_16BIT_SCALAR,
136
                                                                  &mcapi_struct->status);
137
 
138
                                        break;
139
 
140
                                    case MCAPID_RX_8_BIT_SCL:
141
 
142
                                        mcapi_sclchan_send_uint8(mcapi_struct->scl_tx_handle,
143
                                                                 MCAPI_FTS_8BIT_SCALAR,
144
                                                                 &mcapi_struct->status);
145
 
146
                                        break;
147
 
148
                                    default:
149
 
150
                                        break;
151
                                }
152
 
153
                                if (mcapi_struct->status != MCAPI_SUCCESS)
154
                                    break;
155
                            }
156
 
157
                            /* Close the send side. */
158
                            mcapi_sclchan_send_close_i(mcapi_struct->scl_tx_handle,
159
                                                       &request, &status);
160
 
161
                            /* Wait for the response that the other side has closed. */
162
                            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
163
                        }
164
                    }
165
                }
166
            }
167
        }
168
    }
169
 
170
    /* Set the state of the test to completed. */
171
    mcapi_struct->state = 0;
172
 
173
    /* Allow the next test to run. */
174
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
175
 
176
} /* MCAPI_FTS_Tx_2_28_1 */
177
 
178
/************************************************************************
179
*
180
*   FUNCTION
181
*
182
*       MCAPI_FTS_Tx_2_28_2
183
*
184
*   DESCRIPTION
185
*
186
*       Testing mcapi_sclchan_send_uint64, mcapi_sclchan_send_uint32,
187
*       mcapi_sclchan_send_uint16, mcapi_sclchan_send_uint8 - send data
188
*       over closed connection.
189
*
190
*       For each scalar size:
191
*
192
*           Node 0 – Create endpoint, open receive side, wait for connection
193
*                    to open, close receive side
194
*
195
*           Node 1 – Create endpoint, open send side, get endpoint on
196
*                    Node 0, issue connection, send data
197
*
198
*************************************************************************/
199
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_28_2)
200
{
201
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
202
    size_t                      rx_len;
203
    mcapi_status_t              status;
204
    mcapi_endpoint_t            tx_endp, rx_endp;
205
    mcapi_request_t             request;
206
    int                         i;
207
 
208
    /* Don't let any other test run while this test is running. */
209
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
210
 
211
    /* An additional endpoint is required for this test. */
212
    tx_endp = mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
213
 
214
    if (mcapi_struct->status == MCAPI_SUCCESS)
215
    {
216
        /* Tell the other side to receive a bogus scalar size so the
217
         * receive side is opened.
218
         */
219
        mcapi_struct->status =
220
            MCAPI_FTS_Specify_Scalar_Size(mcapi_struct, 0xffffffff);
221
 
222
        if (mcapi_struct->status == MCAPI_SUCCESS)
223
        {
224
            /* Wait for the response. */
225
            mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
226
 
227
            /* An error should be returned since the scalar size was bogus. */
228
            if (mcapi_struct->status == -1)
229
            {
230
                /* Open the local endpoint as the sender. */
231
                mcapi_open_sclchan_send_i(&mcapi_struct->scl_tx_handle,
232
                                          tx_endp, &request,
233
                                          &mcapi_struct->status);
234
 
235
                if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
236
                {
237
                    /* Get the receive side endpoint. */
238
                    rx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, mcapi_struct->foreign_endp,
239
                                                 &mcapi_struct->status);
240
 
241
                    if (mcapi_struct->status == MCAPI_SUCCESS)
242
                    {
243
                        /* Connect the two endpoints. */
244
                        mcapi_connect_sclchan_i(tx_endp, rx_endp,
245
                                                &mcapi_struct->request,
246
                                                &mcapi_struct->status);
247
 
248
                        if (mcapi_struct->status == MCAPI_SUCCESS)
249
                        {
250
                            /* Wait for the send side to open. */
251
                            mcapi_wait(&request, &rx_len,
252
                                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
253
 
254
                            if (mcapi_struct->status == MCAPI_SUCCESS)
255
                            {
256
                                /* Wait for the response that the other side has closed. */
257
                                status = MCAPID_RX_Mgmt_Response(mcapi_struct);
258
 
259
                                /* Let the close request get processed. */
260
                                MCAPID_Sleep(1000);
261
 
262
                                for (i = MCAPID_RX_64_BIT_SCL; i <= MCAPID_RX_8_BIT_SCL; i ++)
263
                                {
264
                                    /* Send some data. */
265
                                    switch (i)
266
                                    {
267
                                        case MCAPID_RX_64_BIT_SCL:
268
 
269
                                            mcapi_sclchan_send_uint64(mcapi_struct->scl_tx_handle,
270
                                                                      MCAPI_FTS_64BIT_SCALAR,
271
                                                                      &mcapi_struct->status);
272
 
273
                                            break;
274
 
275
                                        case MCAPID_RX_32_BIT_SCL:
276
 
277
                                            mcapi_sclchan_send_uint32(mcapi_struct->scl_tx_handle,
278
                                                                      MCAPI_FTS_32BIT_SCALAR,
279
                                                                      &mcapi_struct->status);
280
 
281
                                            break;
282
 
283
                                        case MCAPID_RX_16_BIT_SCL:
284
 
285
                                            mcapi_sclchan_send_uint16(mcapi_struct->scl_tx_handle,
286
                                                                      MCAPI_FTS_16BIT_SCALAR,
287
                                                                      &mcapi_struct->status);
288
 
289
                                            break;
290
 
291
                                        case MCAPID_RX_8_BIT_SCL:
292
 
293
                                            mcapi_sclchan_send_uint8(mcapi_struct->scl_tx_handle,
294
                                                                     MCAPI_FTS_8BIT_SCALAR,
295
                                                                     &mcapi_struct->status);
296
 
297
                                            break;
298
 
299
                                        default:
300
 
301
                                            break;
302
                                    }
303
 
304
                                    if (mcapi_struct->status == MCAPI_ERR_CHAN_INVALID)
305
                                    {
306
                                        mcapi_struct->status = MCAPI_SUCCESS;
307
                                    }
308
 
309
                                    else
310
                                    {
311
                                        mcapi_struct->status = -1;
312
                                        break;
313
                                    }
314
                                }
315
                            }
316
 
317
                            /* Close the send side. */
318
                            mcapi_sclchan_send_close_i(mcapi_struct->scl_tx_handle,
319
                                                       &request, &status);
320
                        }
321
                    }
322
                }
323
            }
324
        }
325
 
326
        /* Delete the extra endpoint. */
327
        mcapi_delete_endpoint(tx_endp, &status);
328
    }
329
 
330
    /* Set the state of the test to completed. */
331
    mcapi_struct->state = 0;
332
 
333
    /* Allow the next test to run. */
334
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
335
 
336
} /* MCAPI_FTS_Tx_2_28_2 */

powered by: WebSVN 2.1.0

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