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_send.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_10_1
48
*
49
*   DESCRIPTION
50
*
51
*       Testing mcapi_msg_send for each priority:
52
*
53
*           Node 0 – Create an endpoint
54
*           Node 1 – Issue get endpoint request, then transmit data using
55
*           each supported priority to the target endpoint
56
*
57
*************************************************************************/
58
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_10_1)
59
{
60
    int                 i;
61
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
62
    char                buffer[MCAPID_MSG_LEN];
63
    size_t              rx_len;
64
 
65
    /* Don't let any other test run while this test is running. */
66
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
67
 
68
    /* Store the endpoint to which the other side should reply. */
69
    mcapi_put32((unsigned char*)buffer, MCAPID_MGMT_LOCAL_ENDP_OFFSET, mcapi_struct->local_endp);
70
 
71
    /* Traverse through all the priorities. */
72
    for (i = 0; i < MCAPI_PRIO_COUNT; i++)
73
    {
74
        /* Send a message. */
75
        mcapi_msg_send(mcapi_struct->local_endp, mcapi_struct->foreign_endp,
76
                       buffer, MCAPID_MSG_LEN, i, &mcapi_struct->status);
77
 
78
        /* Wait for a response. */
79
        if (mcapi_struct->status == MCAPI_SUCCESS)
80
        {
81
            mcapi_msg_recv(mcapi_struct->local_endp, buffer, MCAPID_MSG_LEN,
82
                           &rx_len, &mcapi_struct->status);
83
 
84
            if (mcapi_struct->status != MCAPI_SUCCESS)
85
            {
86
                break;
87
            }
88
        }
89
 
90
        else
91
        {
92
            break;
93
        }
94
    }
95
 
96
    /* Set the state of the test to completed. */
97
    mcapi_struct->state = 0;
98
 
99
    /* Allow the next test to run. */
100
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
101
 
102
} /* MCAPI_FTS_Tx_2_10_1 */
103
 
104
/************************************************************************
105
*
106
*   FUNCTION
107
*
108
*       MCAPI_FTS_Tx_2_10_2
109
*
110
*   DESCRIPTION
111
*
112
*       Testing mcapi_msg_send for each priority to a closed receive
113
*       endpoint:
114
*
115
*           Node 0 – Create an endpoint, then close it after the other
116
*                    side has issued successful get request
117
*           Node 1 – Issue get endpoint request, then transmit data
118
*                    using each supported priority to the target endpoint
119
*
120
*************************************************************************/
121
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_10_2)
122
{
123
    int                 i;
124
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
125
    char                buffer[MCAPID_MGMT_PKT_LEN];
126
    mcapi_endpoint_t    endpoint;
127
    size_t              rx_len;
128
    mcapi_status_t      status;
129
 
130
    /* Don't let any other test run while this test is running. */
131
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
132
 
133
    /* Indicate that the endpoint should be created. */
134
    mcapi_struct->status =
135
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
136
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
137
 
138
    /* Wait for a response. */
139
    if (mcapi_struct->status == MCAPI_SUCCESS)
140
    {
141
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
142
 
143
        if (mcapi_struct->status == MCAPI_SUCCESS)
144
        {
145
            /* Get the endpoint. */
146
            endpoint = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID, 1024, &mcapi_struct->status);
147
 
148
            if (mcapi_struct->status == MCAPI_SUCCESS)
149
            {
150
                /* Tell the other side to delete the endpoint. */
151
                mcapi_struct->status =
152
                    MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
153
                                           mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
154
 
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 (mcapi_struct->status == MCAPI_SUCCESS)
161
                    {
162
                        /* Traverse through all the priorities. */
163
                        for (i = 0; i < MCAPI_PRIO_COUNT; i++)
164
                        {
165
                            /* Send a message to a closed endpoint. */
166
                            mcapi_msg_send(mcapi_struct->local_endp, endpoint,
167
                                           buffer, MCAPID_MGMT_PKT_LEN, i, &status);
168
 
169
                            /* Make the call to receive data. */
170
                            mcapi_msg_recv_i(mcapi_struct->local_endp, buffer,
171
                                             MCAPID_MGMT_PKT_LEN, &mcapi_struct->request,
172
                                             &status);
173
 
174
                            /* No data should be received. */
175
                            mcapi_wait(&mcapi_struct->request, &rx_len, &status, MCAPI_FTS_TIMEOUT);
176
 
177
                            if (status != MCAPI_TIMEOUT)
178
                            {
179
                                mcapi_struct->status = -1;
180
                                break;
181
                            }
182
 
183
                            mcapi_cancel(&mcapi_struct->request, &status);
184
                        }
185
                    }
186
                }
187
            }
188
        }
189
    }
190
 
191
    /* Set the state of the test to completed. */
192
    mcapi_struct->state = 0;
193
 
194
    /* Allow the next test to run. */
195
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
196
 
197
} /* MCAPI_FTS_Tx_2_10_2 */
198
 
199
/************************************************************************
200
*
201
*   FUNCTION
202
*
203
*       MCAPI_FTS_Tx_2_10_3
204
*
205
*   DESCRIPTION
206
*
207
*       Testing mcapi_msg_send when no buffers remain in the system
208
*       for transmission.
209
*
210
*           Node 0 – Create an endpoint, send enough data to Node 1 to
211
*           exhaust all receive buffers
212
*
213
*           Node 1 – Create an endpoint, issue get endpoint request for
214
*           Node 0, wait for all buffers to be used up, attempt to
215
*           retransmit a message to Node 0
216
*
217
*************************************************************************/
218
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_10_3)
219
{
220
    int                 i, j;
221
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
222
    char                buffer[MCAPID_MSG_LEN];
223
    mcapi_status_t      status;
224
    size_t              rx_len;
225
 
226
    /* Don't let any other test run while this test is running. */
227
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
228
 
229
    /* Indicate that the endpoint should be created. */
230
    mcapi_struct->status =
231
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
232
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
233
    status_assert(mcapi_struct->status);
234
 
235
    /* Wait for a response. */
236
    mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
237
    status_assert(mcapi_struct->status);
238
 
239
    /* If the endpoint was created. */
240
    for (i = 0; i < TEST_BUF_COUNT; i ++)
241
    {
242
        /* Issue a NO OP to cause the other side to send an ACK. */
243
        mcapi_struct->status =
244
            MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_NO_OP, 1024,
245
                                   mcapi_struct->local_endp, 0,
246
                                   MCAPI_DEFAULT_PRIO);
247
        if (mcapi_struct->status != MCAPI_SUCCESS)
248
        {
249
            break;
250
        }
251
    }
252
 
253
    /* Try to send a buffer of data. */
254
    mcapi_msg_send(mcapi_struct->local_endp, mcapi_struct->foreign_endp,
255
                   buffer, MCAPID_MSG_LEN, MCAPI_DEFAULT_PRIO,
256
                   &mcapi_struct->status);
257
    status_assert_code(mcapi_struct->status, MCAPI_ERR_TRANSMISSION);
258
 
259
    /* Receive all the pending data. */
260
    for (j = 0; j < i; j ++)
261
    {
262
        mcapi_msg_recv_i(mcapi_struct->local_endp, buffer, MCAPID_MSG_LEN,
263
                         &mcapi_struct->request, &status);
264
        status_assert(status);
265
 
266
        /* Wait for data. */
267
        mcapi_wait(&mcapi_struct->request, &rx_len, &status, MCAPI_FTS_TIMEOUT);
268
        status_assert(status);
269
    }
270
 
271
    /* Tell the other side to delete the endpoint. */
272
    status =
273
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
274
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
275
    status_assert(status);
276
 
277
    /* Wait for a response before releasing the mutex. */
278
    status = MCAPID_RX_Mgmt_Response(mcapi_struct);
279
    status_assert(status);
280
 
281
    /* Set the state of the test to completed. */
282
    mcapi_struct->state = 0;
283
 
284
    /* Allow the next test to run. */
285
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
286
 
287
} /* MCAPI_FTS_Tx_2_10_3 */

powered by: WebSVN 2.1.0

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