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_msg_available.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_13_1
49
*
50
*   DESCRIPTION
51
*
52
*       Testing mcapi_msg_available with one message on the endpoint.
53
*
54
*           Node 0 – Create endpoint, check for message count on endpoint
55
*
56
*************************************************************************/
57
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_13_1)
58
{
59
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
60
    size_t              count;
61
 
62
    /* Don't let any other test run while this test is running. */
63
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
64
 
65
    /* Check the number of messages on the endpoint. */
66
    count =
67
        mcapi_msg_available(mcapi_struct->local_endp, &mcapi_struct->status);
68
 
69
    /* There should be no data on the endpoint. */
70
    if ( (count != 0) || (mcapi_struct->status != MCAPI_SUCCESS) )
71
    {
72
        mcapi_struct->status = -1;
73
    }
74
 
75
    /* Set the state of the test to completed. */
76
    mcapi_struct->state = 0;
77
 
78
    /* Allow the next test to run. */
79
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
80
 
81
} /* MCAPI_FTS_Tx_2_13_1 */
82
 
83
/************************************************************************
84
*
85
*   FUNCTION
86
*
87
*       MCAPI_FTS_Tx_2_13_2
88
*
89
*   DESCRIPTION
90
*
91
*       Testing mcapi_msg_available with one message on the endpoint.
92
*
93
*           Node 1 – Create endpoint, transmit one packet to Node 1
94
*
95
*           Node 0 – Create endpoint, indicate to Node 0 to transmit
96
*                    one message, check for message count on endpoint
97
*
98
*************************************************************************/
99
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_13_2)
100
{
101
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
102
    char                buffer[MCAPID_MGMT_PKT_LEN];
103
    size_t              rx_len;
104
    mcapi_status_t      status;
105
 
106
    /* Don't let any other test run while this test is running. */
107
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
108
 
109
    /* Indicate that a remote endpoint should be created for sending data
110
     * to this node.
111
     */
112
    mcapi_struct->status =
113
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
114
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
115
 
116
    /* Wait for a response. */
117
    if (mcapi_struct->status == MCAPI_SUCCESS)
118
    {
119
        /* Wait for the response. */
120
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
121
 
122
        /* If the endpoint was created. */
123
        if (mcapi_struct->status == MCAPI_SUCCESS)
124
        {
125
            /* Issue a NO OP to cause just one message to be sent. */
126
            mcapi_struct->status =
127
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
128
                                       mcapi_struct->local_endp, 0,
129
                                       MCAPI_DEFAULT_PRIO);
130
 
131
            if (mcapi_struct->status == MCAPI_SUCCESS)
132
            {
133
                /* Check the number of messages on the endpoint. */
134
                while (mcapi_msg_available(mcapi_struct->local_endp,
135
                                           &mcapi_struct->status) == 0)
136
                {
137
                    if (mcapi_struct->status != MCAPI_SUCCESS)
138
                        break;
139
 
140
                    MCAPID_Sleep(250);
141
                }
142
 
143
                if (mcapi_struct->status == MCAPI_SUCCESS)
144
                {
145
                    /* Make the call to receive the data. */
146
                    mcapi_msg_recv(mcapi_struct->local_endp, buffer,
147
                                   MCAPID_MGMT_PKT_LEN, &rx_len, &mcapi_struct->status);
148
                }
149
            }
150
        }
151
 
152
        /* Tell the other side to delete the endpoint. */
153
        status =
154
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
155
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
156
 
157
        if (status == MCAPI_SUCCESS)
158
        {
159
            /* Wait for the response. */
160
            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
161
        }
162
    }
163
 
164
    /* Set the state of the test to completed. */
165
    mcapi_struct->state = 0;
166
 
167
    /* Allow the next test to run. */
168
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
169
 
170
} /* MCAPI_FTS_Tx_2_13_2 */
171
 
172
/************************************************************************
173
*
174
*   FUNCTION
175
*
176
*       MCAPI_FTS_Tx_2_13_3
177
*
178
*   DESCRIPTION
179
*
180
*       Testing mcapi_msg_available with two messages on the endpoint.
181
*
182
*           Node 1 – Create endpoint, transmit two packets to Node 1
183
*
184
*           Node 0 – Create endpoint, indicate to Node 0 to transmit
185
*                    two messages, check for message count on endpoint
186
*
187
*************************************************************************/
188
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_13_3)
189
{
190
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
191
    char                buffer[MCAPID_MGMT_PKT_LEN];
192
    size_t              rx_len;
193
    mcapi_status_t      status;
194
 
195
    /* Don't let any other test run while this test is running. */
196
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
197
 
198
    /* Indicate that a remote endpoint should be created for sending data
199
     * to this node.
200
     */
201
    mcapi_struct->status =
202
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
203
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
204
 
205
    /* Wait for a response. */
206
    if (mcapi_struct->status == MCAPI_SUCCESS)
207
    {
208
        /* Wait for the response. */
209
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
210
 
211
        /* If the endpoint was created. */
212
        if (mcapi_struct->status == MCAPI_SUCCESS)
213
        {
214
            /* Issue a NO OP to cause a message to be sent. */
215
            mcapi_struct->status =
216
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
217
                                       mcapi_struct->local_endp, 0,
218
                                       MCAPI_DEFAULT_PRIO);
219
 
220
            if (mcapi_struct->status == MCAPI_SUCCESS)
221
            {
222
                /* Issue a second NO OP to cause another message to be sent. */
223
                mcapi_struct->status =
224
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
225
                                           mcapi_struct->local_endp, 0,
226
                                           MCAPI_DEFAULT_PRIO);
227
 
228
                if (mcapi_struct->status == MCAPI_SUCCESS)
229
                {
230
                    /* Check the number of messages on the endpoint. */
231
                    while (mcapi_msg_available(mcapi_struct->local_endp,
232
                                               &mcapi_struct->status) != 2)
233
                    {
234
                        if (mcapi_struct->status != MCAPI_SUCCESS)
235
                            break;
236
 
237
                        MCAPID_Sleep(250);
238
                    }
239
 
240
                    if (mcapi_struct->status == MCAPI_SUCCESS)
241
                    {
242
                        /* Make the call to receive the data. */
243
                        mcapi_msg_recv(mcapi_struct->local_endp, buffer,
244
                                       MCAPID_MGMT_PKT_LEN, &rx_len,
245
                                       &mcapi_struct->status);
246
 
247
                        if (mcapi_struct->status == MCAPI_SUCCESS)
248
                        {
249
                            /* Make the call to receive the data. */
250
                            mcapi_msg_recv(mcapi_struct->local_endp, buffer,
251
                                           MCAPID_MGMT_PKT_LEN, &rx_len,
252
                                           &mcapi_struct->status);
253
                        }
254
                    }
255
                }
256
            }
257
        }
258
 
259
        /* Tell the other side to delete the endpoint. */
260
        status =
261
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
262
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
263
 
264
        if (status == MCAPI_SUCCESS)
265
        {
266
            /* Wait for the response. */
267
            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
268
        }
269
    }
270
 
271
    /* Set the state of the test to completed. */
272
    mcapi_struct->state = 0;
273
 
274
    /* Allow the next test to run. */
275
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
276
 
277
} /* MCAPI_FTS_Tx_2_13_3 */

powered by: WebSVN 2.1.0

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