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_pktchan_send_i.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_17_1
48
*
49
*   DESCRIPTION
50
*
51
*       Testing mcapi_pktchan_send_i - send data over open connection.
52
*
53
*           Node 0 – Create endpoint, open receive side, wait for data
54
*
55
*           Node 1 – Create endpoint, open send side, get endpoint on
56
*                    Node 0, issue connection, send data
57
*
58
*************************************************************************/
59
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_17_1)
60
{
61
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
62
    size_t                      rx_len;
63
    mcapi_status_t              status;
64
    mcapi_endpoint_t            rx_endp;
65
    mcapi_request_t             request;
66
    char                        buffer[MCAPID_MSG_LEN];
67
 
68
    /* Don't let any other test run while this test is running. */
69
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
70
 
71
    /* Open the local endpoint as the sender. */
72
    mcapi_open_pktchan_send_i(&mcapi_struct->pkt_tx_handle,
73
                              mcapi_struct->local_endp, &request,
74
                              &mcapi_struct->status);
75
 
76
    if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
77
    {
78
        /* Get the receive side endpoint. */
79
        rx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID,
80
                                     mcapi_struct->foreign_endp,
81
                                     &mcapi_struct->status);
82
 
83
        if (mcapi_struct->status == MCAPI_SUCCESS)
84
        {
85
            /* Connect the two endpoints. */
86
            mcapi_connect_pktchan_i(mcapi_struct->local_endp, rx_endp,
87
                                    &mcapi_struct->request,
88
                                    &mcapi_struct->status);
89
 
90
            if (mcapi_struct->status == MCAPI_SUCCESS)
91
            {
92
                /* Wait for the open to complete. */
93
                mcapi_wait(&request, &rx_len, &mcapi_struct->status,
94
                           MCAPI_FTS_TIMEOUT);
95
 
96
                if (mcapi_struct->status == MCAPI_SUCCESS)
97
                {
98
                    /* Send some data. */
99
                    mcapi_pktchan_send_i(mcapi_struct->pkt_tx_handle, buffer,
100
                                         MCAPID_MSG_LEN, &mcapi_struct->request,
101
                                         &mcapi_struct->status);
102
 
103
                    if (mcapi_struct->status == MCAPI_SUCCESS)
104
                    {
105
                        /* Wait for the data to be sent. */
106
                        mcapi_wait(&mcapi_struct->request, &rx_len, &mcapi_struct->status,
107
                                   MCAPI_FTS_TIMEOUT);
108
                    }
109
                }
110
 
111
                /* Close the send side. */
112
                mcapi_packetchan_send_close_i(mcapi_struct->pkt_tx_handle,
113
                                              &request, &status);
114
            }
115
        }
116
    }
117
 
118
    /* Set the state of the test to completed. */
119
    mcapi_struct->state = 0;
120
 
121
    /* Allow the next test to run. */
122
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
123
 
124
} /* MCAPI_FTS_Tx_2_17_1 */
125
 
126
/************************************************************************
127
*
128
*   FUNCTION
129
*
130
*       MCAPI_FTS_Tx_2_17_2
131
*
132
*   DESCRIPTION
133
*
134
*       Testing mcapi_pktchan_send_i - send data over closed connection.
135
*
136
*           Node 0 – Create endpoint, open receive side, wait for
137
*                    connection, close receive side.
138
*
139
*           Node 1 – Create endpoint, open send side, get endpoint on
140
*                    Node 0, issue connection, send data
141
*
142
*************************************************************************/
143
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_17_2)
144
{
145
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
146
    size_t                      rx_len;
147
    mcapi_endpoint_t            rx_endp;
148
    mcapi_request_t             request;
149
    char                        buffer[MCAPID_MSG_LEN];
150
 
151
    /* Don't let any other test run while this test is running. */
152
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
153
 
154
    /* Open the local endpoint as the sender. */
155
    mcapi_open_pktchan_send_i(&mcapi_struct->pkt_tx_handle,
156
                              mcapi_struct->local_endp, &request,
157
                              &mcapi_struct->status);
158
 
159
    if (mcapi_struct->status == MGC_MCAPI_ERR_NOT_CONNECTED)
160
    {
161
        /* Get the receive side endpoint. */
162
        rx_endp = mcapi_get_endpoint(FUNC_BACKEND_NODE_ID,
163
                                     mcapi_struct->foreign_endp,
164
                                     &mcapi_struct->status);
165
 
166
        if (mcapi_struct->status == MCAPI_SUCCESS)
167
        {
168
            /* Connect the two endpoints. */
169
            mcapi_connect_pktchan_i(mcapi_struct->local_endp, rx_endp,
170
                                    &mcapi_struct->request,
171
                                    &mcapi_struct->status);
172
 
173
            if (mcapi_struct->status == MCAPI_SUCCESS)
174
            {
175
                /* Wait for the open to complete. */
176
                mcapi_wait(&request, &rx_len, &mcapi_struct->status,
177
                           MCAPI_FTS_TIMEOUT);
178
 
179
                if (mcapi_struct->status == MCAPI_SUCCESS)
180
                {
181
                    /* Close the send side. */
182
                    mcapi_packetchan_send_close_i(mcapi_struct->pkt_tx_handle,
183
                                                  &request, &mcapi_struct->status);
184
 
185
                    if (mcapi_struct->status == MCAPI_SUCCESS)
186
                    {
187
                        /* Wait for the operation to complete. */
188
                        mcapi_wait(&request, &rx_len, &mcapi_struct->status,
189
                                   MCAPI_FTS_TIMEOUT);
190
 
191
                        if (mcapi_struct->status == MCAPI_SUCCESS)
192
                        {
193
                            /* Send some data over the closed connection. */
194
                            mcapi_pktchan_send_i(mcapi_struct->pkt_tx_handle, buffer,
195
                                                 MCAPID_MSG_LEN, &mcapi_struct->request,
196
                                                 &mcapi_struct->status);
197
 
198
                            /* Ensure the proper error code was returned. */
199
                            if (mcapi_struct->status == MCAPI_ERR_CHAN_INVALID)
200
                            {
201
                                mcapi_struct->status = MCAPI_SUCCESS;
202
                            }
203
 
204
                            else
205
                            {
206
                                mcapi_struct->status = -1;
207
                            }
208
                        }
209
                    }
210
                }
211
            }
212
        }
213
    }
214
 
215
    /* Set the state of the test to completed. */
216
    mcapi_struct->state = 0;
217
 
218
    /* Allow the next test to run. */
219
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
220
 
221
} /* MCAPI_FTS_Tx_2_17_2 */
222
 
223
/************************************************************************
224
*
225
*   FUNCTION
226
*
227
*       MCAPI_FTS_Tx_2_17_3
228
*
229
*   DESCRIPTION
230
*
231
*       Testing mcapi_pktchan_send_i - no buffers remaining in the
232
*       system.
233
*
234
*           Node 0 – Create an endpoint, open receive side, wait for
235
*                    connection.  Create an endpoint, send enough message
236
*                    data to Node 1 to exhaust all receive buffers
237
*
238
*           Node 1 – Create an endpoint, issue get endpoint require for
239
*                    Node 0, open send side, issue connection.  Create an
240
*                    endpoint, issue get endpoint request for Node 0, wait
241
*                    for all buffers to be used up, attempt to transmit a
242
*                    packet to Node 0 over the established connection.
243
*
244
*************************************************************************/
245
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_17_3)
246
{
247
    MCAPID_STRUCT               *mcapi_struct = (MCAPID_STRUCT*)argv;
248
    MCAPID_STRUCT               mcapi_msg_struct;
249
    size_t                      rx_len;
250
    mcapi_status_t              status;
251
    mcapi_request_t             request;
252
    char                        buffer[MCAPID_MSG_LEN];
253
    int                         i, j;
254
 
255
    /* Don't let any other test run while this test is running. */
256
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
257
 
258
    /* Create a new endpoint for sending/receiving control messages. */
259
    mcapi_msg_struct.local_endp =
260
        mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
261
 
262
    if (mcapi_struct->status == MCAPI_SUCCESS)
263
    {
264
        /* Get the management server for the foreign node. */
265
        mcapi_struct->status =
266
            MCAPID_Get_Service("mgmt_svc", &mcapi_msg_struct.foreign_endp);
267
 
268
        if (mcapi_struct->status == MCAPI_SUCCESS)
269
        {
270
            /* Indicate that an endpoint should be created. */
271
            mcapi_struct->status =
272
                MCAPID_TX_Mgmt_Message(&mcapi_msg_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
273
                                       mcapi_msg_struct.local_endp, 0, MCAPI_DEFAULT_PRIO);
274
 
275
            /* Wait for a response. */
276
            if (mcapi_struct->status == MCAPI_SUCCESS)
277
            {
278
                mcapi_struct->status = MCAPID_RX_Mgmt_Response(&mcapi_msg_struct);
279
 
280
                /* If the endpoint was created. */
281
                if (mcapi_struct->status == MCAPI_SUCCESS)
282
                {
283
                    /* Exhaust all local buffers. */
284
                    for (i = 0; i < TEST_BUF_COUNT; i ++)
285
                    {
286
                        /* Issue a NO OP to cause the other side to send an ACK. */
287
                        mcapi_struct->status =
288
                            MCAPID_TX_Mgmt_Message(&mcapi_msg_struct, MCAPID_NO_OP, 1024,
289
                                                   mcapi_msg_struct.local_endp, 0,
290
                                                   MCAPI_DEFAULT_PRIO);
291
 
292
                        if (mcapi_struct->status != MCAPI_SUCCESS)
293
                        {
294
                            break;
295
                        }
296
                    }
297
 
298
                    /* Let the other side run. */
299
                    MCAPID_Sleep(1000);
300
 
301
                    /* Try to send a packet. */
302
                    mcapi_pktchan_send_i(mcapi_struct->pkt_tx_handle, buffer,
303
                                         MCAPID_MSG_LEN, &mcapi_struct->request,
304
                                         &mcapi_struct->status);
305
 
306
                    /* Ensure the proper error code was returned. */
307
                    if (mcapi_struct->status == MCAPI_ERR_TRANSMISSION)
308
                    {
309
                        mcapi_struct->status = MCAPI_SUCCESS;
310
                    }
311
 
312
                    else
313
                    {
314
                        mcapi_struct->status = -1;
315
                    }
316
 
317
                    /* Receive all the pending data. */
318
                    for (j = 0; j < i; j ++)
319
                    {
320
                        mcapi_msg_recv_i(mcapi_msg_struct.local_endp, buffer, MCAPID_MSG_LEN,
321
                                         &mcapi_msg_struct.request, &status);
322
 
323
                        if (status == MCAPI_SUCCESS)
324
                        {
325
                            /* Wait for data. */
326
                            mcapi_wait(&mcapi_msg_struct.request, &rx_len, &status, MCAPI_FTS_TIMEOUT);
327
 
328
                            if (status != MCAPI_SUCCESS)
329
                                break;
330
                        }
331
 
332
                        else
333
                        {
334
                            break;
335
                        }
336
                    }
337
 
338
                    /* Tell the other side to delete the endpoint. */
339
                    status =
340
                        MCAPID_TX_Mgmt_Message(&mcapi_msg_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
341
                                               mcapi_msg_struct.local_endp, 0, MCAPI_DEFAULT_PRIO);
342
 
343
                    if (status == MCAPI_SUCCESS)
344
                    {
345
                        /* Wait for a response before releasing the mutex. */
346
                        status = MCAPID_RX_Mgmt_Response(&mcapi_msg_struct);
347
                    }
348
                }
349
            }
350
        }
351
 
352
        /* Delete the control endpoint. */
353
        mcapi_delete_endpoint(mcapi_msg_struct.local_endp, &status);
354
    }
355
 
356
    /* Close the send side. */
357
    mcapi_packetchan_send_close_i(mcapi_struct->pkt_tx_handle,
358
                                  &request, &mcapi_struct->status);
359
 
360
    /* Set the state of the test to completed. */
361
    mcapi_struct->state = 0;
362
 
363
    /* Allow the next test to run. */
364
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
365
 
366
} /* MCAPI_FTS_Tx_2_17_3 */

powered by: WebSVN 2.1.0

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