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_recv.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_11_1
48
*
49
*   DESCRIPTION
50
*
51
*       Testing mcapi_msg_recv for each priority:
52
*
53
*           Node 1 – Create an endpoint, indicate to Node 0 to transmit
54
*                    data with a specific priority, issue a receive call on
55
*                    the endpoint
56
*
57
*           Node 0 – Transmit data using the indicated priority to the
58
*                    target endpoint
59
*
60
*************************************************************************/
61
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_11_1)
62
{
63
    int                 i;
64
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
65
    char                buffer[MCAPID_MGMT_PKT_LEN];
66
    size_t              rx_len;
67
    mcapi_status_t      status;
68
 
69
    /* Don't let any other test run while this test is running. */
70
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
71
 
72
    /* Indicate that a remote endpoint should be created for sending data
73
     * to this node.
74
     */
75
    mcapi_struct->status =
76
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
77
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
78
    status_assert(mcapi_struct->status);
79
 
80
    /* Wait for a response. */
81
    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
82
    status_assert(mcapi_struct->status);
83
 
84
    /* If the endpoint was created. */
85
    /* Traverse through all priorities. */
86
    for (i = 0; i < MCAPI_PRIO_COUNT; i ++)
87
    {
88
        /* Issue a NO OP call with a 1000 millisecond pause to cause
89
         * the other side to cause Node 0 to send just an ACK.
90
         */
91
        mcapi_struct->status =
92
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
93
                                   mcapi_struct->local_endp, 1000, i);
94
        status_assert(mcapi_struct->status);
95
 
96
        /* Wait for the ACK. */
97
        mcapi_msg_recv(mcapi_struct->local_endp, buffer, MCAPID_MGMT_PKT_LEN,
98
                       &rx_len, &mcapi_struct->status);
99
        status_assert(mcapi_struct->status);
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
    status_assert(status);
107
 
108
    /* Wait for the response. */
109
    status = MCAPID_RX_Mgmt_Response(mcapi_struct);
110
    status_assert(status);
111
 
112
    /* Set the state of the test to completed. */
113
    mcapi_struct->state = 0;
114
 
115
    /* Allow the next test to run. */
116
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
117
 
118
} /* MCAPI_FTS_Tx_2_11_1 */
119
 
120
/************************************************************************
121
*
122
*   FUNCTION
123
*
124
*       MCAPI_FTS_Tx_2_11_2
125
*
126
*   DESCRIPTION
127
*
128
*       Testing mcapi_msg_recv with receive length too small.
129
*
130
*           Node 1 – Transmit data to Node 1
131
*
132
*           Node 0 – Create an endpoint, indicate to Node 0 to transmit
133
*                    data, issue a receive call on the endpoint specifying
134
*                    too small a receive buffer size
135
*
136
*************************************************************************/
137
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_11_2)
138
{
139
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
140
    char                buffer[MCAPID_MGMT_PKT_LEN];
141
    size_t              rx_len;
142
    mcapi_status_t      status;
143
 
144
    /* Don't let any other test run while this test is running. */
145
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
146
 
147
    /* Indicate that a remote endpoint should be created for sending data
148
     * to this node.
149
     */
150
    mcapi_struct->status =
151
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
152
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
153
 
154
    /* Wait for a response. */
155
    if (mcapi_struct->status == MCAPI_SUCCESS)
156
    {
157
        /* Wait for the response. */
158
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
159
 
160
        /* If the endpoint was created. */
161
        if (mcapi_struct->status == MCAPI_SUCCESS)
162
        {
163
            /* Issue a NO OP to cause the other side to send one packet only. */
164
            mcapi_struct->status =
165
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
166
                                       mcapi_struct->local_endp, 0,
167
                                       MCAPI_DEFAULT_PRIO);
168
 
169
            if (mcapi_struct->status == MCAPI_SUCCESS)
170
            {
171
                /* Wait for the ACK specifying too small a buffer size to
172
                 * receive the data.
173
                 */
174
                mcapi_msg_recv(mcapi_struct->local_endp, buffer, 1, &rx_len,
175
                               &mcapi_struct->status);
176
 
177
                if (mcapi_struct->status == MCAPI_ERR_MSG_TRUNCATED)
178
                {
179
                    mcapi_struct->status = MCAPI_SUCCESS;
180
                }
181
 
182
                else
183
                {
184
                    mcapi_struct->status = -1;
185
                }
186
 
187
                /* Receive the buffer. */
188
                mcapi_msg_recv(mcapi_struct->local_endp, buffer, MCAPID_MGMT_PKT_LEN,
189
                               &rx_len, &status);
190
            }
191
        }
192
 
193
        /* Tell the other side to delete the endpoint. */
194
        status =
195
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
196
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
197
 
198
        if (status == MCAPI_SUCCESS)
199
        {
200
            /* Wait for the response. */
201
            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
202
        }
203
    }
204
 
205
    /* Set the state of the test to completed. */
206
    mcapi_struct->state = 0;
207
 
208
    /* Allow the next test to run. */
209
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
210
 
211
} /* MCAPI_FTS_Tx_2_11_2 */
212
 
213
/************************************************************************
214
*
215
*   FUNCTION
216
*
217
*       MCAPI_FTS_Tx_2_11_3
218
*
219
*   DESCRIPTION
220
*
221
*       Testing mcapi_msg_recv blocking for data to become available.
222
*
223
*           Node 1 – Wait for Node 1 to issue the receive request, transmit
224
*                    data to Node 1
225
*
226
*           Node 0 – Create an endpoint, indicate to Node 0 to transmit
227
*                    data in 1000 ms, issue a receive call on the endpoint
228
*
229
*************************************************************************/
230
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_11_3)
231
{
232
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
233
    char                buffer[MCAPID_MGMT_PKT_LEN];
234
    size_t              rx_len;
235
    mcapi_status_t      status;
236
 
237
    /* Don't let any other test run while this test is running. */
238
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
239
 
240
    /* Indicate that a remote endpoint should be created for sending data
241
     * to this node.
242
     */
243
    mcapi_struct->status =
244
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
245
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
246
 
247
    /* Wait for a response. */
248
    if (mcapi_struct->status == MCAPI_SUCCESS)
249
    {
250
        /* Wait for the response. */
251
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
252
 
253
        /* If the endpoint was created. */
254
        if (mcapi_struct->status == MCAPI_SUCCESS)
255
        {
256
            /* Issue a NO OP to cause one message to be sent only. */
257
            mcapi_struct->status =
258
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
259
                                       mcapi_struct->local_endp, 1000,
260
                                       MCAPI_DEFAULT_PRIO);
261
 
262
            if (mcapi_struct->status == MCAPI_SUCCESS)
263
            {
264
                /* Wait for the data. */
265
                mcapi_msg_recv(mcapi_struct->local_endp, buffer, MCAPID_MGMT_PKT_LEN,
266
                               &rx_len, &mcapi_struct->status);
267
            }
268
        }
269
 
270
        /* Tell the other side to delete the endpoint. */
271
        status =
272
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
273
                                   mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
274
 
275
        if (status == MCAPI_SUCCESS)
276
        {
277
            /* Wait for the response. */
278
            status = MCAPID_RX_Mgmt_Response(mcapi_struct);
279
        }
280
    }
281
 
282
    /* Set the state of the test to completed. */
283
    mcapi_struct->state = 0;
284
 
285
    /* Allow the next test to run. */
286
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
287
 
288
} /* MCAPI_FTS_Tx_2_11_3 */

powered by: WebSVN 2.1.0

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