O-RAN E Maintenance Release contribution for ODULOW
[o-du/phy.git] / wls_lib / test / mac / mac_main.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19 /**
20  * @brief This file is test MAC wls lib main process
21  * @file mac_main.c
22  * @ingroup group_testmacwls
23  * @author Intel Corporation
24  **/
25
26
27 #include <stdint.h>
28 #include <stdio.h>
29
30 #include "wls_lib.h"
31 #include "mac_wls.h"
32
33 #define WLS_TEST_DEV_NAME "wls"
34 #define WLS_TEST_MSG_ID   1
35 #define WLS_TEST_MSG_SIZE 100
36
37 #define N_MAC_MSGS   16
38
39 int main()
40 {
41     p_fapi_api_queue_elem_t p_list_elem;
42     unsigned int ret;
43     unsigned int n= N_MAC_MSGS; 
44     unsigned int i;
45
46     // DPDK init
47     ret = mac_dpdk_init();
48     if (ret)
49     {
50         printf("\n[MAC] DPDK Init - Failed\n");
51         return FAILURE;
52     }
53     printf("\n[MAC] DPDK Init - Done\n");
54
55     wls_mac_init(WLS_TEST_DEV_NAME, WLS_MSG_BLOCK_SIZE);
56     printf("\n[MAC] WLS Init - Done\n");
57
58     for (i=0; i< N_MAC_MSGS; i++)
59     {
60     p_list_elem = wls_mac_create_elem(WLS_TEST_MSG_ID, WLS_TEST_MSG_SIZE, 1, 0);
61       printf("\n[MAC] MAC Create Element %d- Done\n", i);
62
63     if(p_list_elem)
64     {
65         wls_mac_send_msg_to_phy((void *)p_list_elem);
66                 printf("\n[MAC] Send to FAPI %d- Done\n",i);
67         }
68     }
69
70     // Receive from FAPI WLS
71     wls_mac_rx_task();
72
73     printf("\n[MAC] Exiting...\n");
74
75     return SUCCESS;
76 }
77