1 /******************************************************************************
3 * Copyright (c) 2019 Intel.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 *******************************************************************************/
20 * @brief This file is test PHY wls lib main process
22 * @ingroup group_testphywls
23 * @author Intel Corporation
31 #include <rte_cfgfile.h>
32 #include <rte_string_fns.h>
33 #include <rte_common.h>
34 #include <rte_string_fns.h>
35 #include <rte_lcore.h>
36 #include <rte_debug.h>
37 #include <rte_launch.h>
43 #define WLS_TEST_DEV_NAME "wls"
44 #define WLS_TEST_MSG_ID 1
45 #define WLS_TEST_MSG_SIZE 100
46 #define WLS_MAC_MEMORY_SIZE 0x3EA80000
47 #define WLS_PHY_MEMORY_SIZE 0x18000000
48 #define NUM_PHY_MSGS 16
50 typedef void* WLS_HANDLE;
52 uint64_t g_shmem_size;
54 WLS_HANDLE g_fapi_wls, g_phy_wls;
56 uint8_t phy_dpdk_init(void);
57 uint8_t phy_wls_init(const char *dev_name, uint64_t nWlsMacMemSize, uint64_t nWlsPhyMemSize);
58 uint64_t phy_fapi_recv();
59 uint8_t phy_fapi_send();
67 ret = phy_dpdk_init();
70 printf("\n[PHY] DPDK Init - Failed\n");
73 printf("\n[PHY] DPDK Init - Done\n");
76 ret = phy_wls_init(WLS_TEST_DEV_NAME, WLS_MAC_MEMORY_SIZE, WLS_PHY_MEMORY_SIZE);
79 printf("\n[PHY] WLS Init - Failed\n");
82 printf("\n[PHY] WLS Init - Done\n");
84 // Receive from MAC WLS
85 p_msg = phy_fapi_recv();
88 printf("\n[PHY] Receive from FAPI - Failed\n");
91 printf("\n[PHY] Receive from FAPI - Done\n");
94 ret = phy_fapi_send();
97 printf("\n[PHY] Send to FAPI - Failed\n");
100 printf("\n[PHY] Send to FAPI - Done\n");
102 printf("\n[PHY] Exiting...\n");
107 uint8_t phy_dpdk_init(void)
112 char *argv[] = {"phy_app", "--proc-type=primary",
113 "--file-prefix", "wls", whitelist};
115 int argc = RTE_DIM(argv);
117 /* initialize EAL first */
118 sprintf(whitelist, "-a%s", "0000:00:06.0");
119 printf("[PHY] Calling rte_eal_init: ");
121 for (i = 0; i < RTE_DIM(argv); i++)
123 printf("%s ", argv[i]);
127 if (rte_eal_init(argc, argv) < 0)
128 rte_panic("Cannot init EAL\n");
133 uint8_t phy_wls_init(const char *dev_name, uint64_t nWlsMacMemSize, uint64_t nWlsPhyMemSize)
135 g_phy_wls = WLS_Open(dev_name, WLS_SLAVE_CLIENT, &nWlsMacMemSize, &nWlsPhyMemSize);
136 if(NULL == g_phy_wls)
140 g_shmem_size = nWlsMacMemSize+nWlsPhyMemSize;
142 g_shmem = WLS_Alloc(g_phy_wls, g_shmem_size);
145 printf("Unable to alloc WLS Memory\n");
151 uint64_t phy_fapi_recv()
153 uint8_t num_blks = 0;
163 num_blks = WLS_Wait(g_phy_wls);
164 printf("WLS_Wait returns %d blocks\n",num_blks);
168 p_msg = WLS_Get(g_phy_wls, &msg_size, &msg_id, &flags);
171 printf("\n[PHY] FAPI2PHY WLS Received Block %d\n",i);
176 printf("\n[PHY] FAPI2PHY WLS Get Error for msg %d\n",i);
179 if (flags & WLS_TF_FIN)
186 printf("\n[PHY] FAPI2PHY WLS wait returned 0 blocks exiting \n");
194 uint8_t phy_fapi_send()
196 uint64_t pa_block = 0;
197 uint8_t ret = FAILURE;
200 for (i=0 ; i < NUM_PHY_MSGS; i++)
203 pa_block = (uint64_t) WLS_DequeueBlock((void*) g_phy_wls);
206 printf("\n[PHY] FAPI2PHY WLS Dequeue block %d error\n",i);
210 ret = WLS_Put(g_phy_wls, pa_block, WLS_TEST_MSG_SIZE, WLS_TEST_MSG_ID, (i== (NUM_PHY_MSGS-1))? WLS_TF_FIN:0);
211 printf("\n[PHY] FAPI2PHY WLS Put Msg %d \n",i);
214 printf("\n[PHY] FAPI2PHY WLS Put Msg Error %d \n",i);