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_TEST_MEM_SIZE 2126512128
47 #define NUM_PHY_MSGS 16
49 typedef void* WLS_HANDLE;
51 uint64_t g_shmem_size;
53 WLS_HANDLE g_fapi_wls, g_phy_wls;
55 uint8_t phy_dpdk_init(void);
56 uint8_t phy_wls_init(const char *dev_name, unsigned long long mem_size);
57 uint64_t phy_fapi_recv();
58 uint8_t phy_fapi_send();
66 ret = phy_dpdk_init();
69 printf("\n[PHY] DPDK Init - Failed\n");
72 printf("\n[PHY] DPDK Init - Done\n");
75 ret = phy_wls_init(WLS_TEST_DEV_NAME, WLS_TEST_MEM_SIZE);
78 printf("\n[PHY] WLS Init - Failed\n");
81 printf("\n[PHY] WLS Init - Done\n");
83 // Receive from MAC WLS
84 p_msg = phy_fapi_recv();
87 printf("\n[PHY] Receive from FAPI - Failed\n");
90 printf("\n[PHY] Receive from FAPI - Done\n");
93 ret = phy_fapi_send();
96 printf("\n[PHY] Send to FAPI - Failed\n");
99 printf("\n[PHY] Send to FAPI - Done\n");
101 printf("\n[PHY] Exiting...\n");
106 uint8_t phy_dpdk_init(void)
111 char *argv[] = {"phy_app", "--proc-type=primary",
112 "--file-prefix", "wls", whitelist};
114 int argc = RTE_DIM(argv);
116 /* initialize EAL first */
117 sprintf(whitelist, "-w %s", "0000:00:06.0");
118 printf("[PHY] Calling rte_eal_init: ");
120 for (i = 0; i < RTE_DIM(argv); i++)
122 printf("%s ", argv[i]);
126 if (rte_eal_init(argc, argv) < 0)
127 rte_panic("Cannot init EAL\n");
132 uint8_t phy_wls_init(const char *dev_name, unsigned long long mem_size)
134 g_phy_wls = WLS_Open(dev_name, WLS_SLAVE_CLIENT, mem_size);
135 if(NULL == g_phy_wls)
139 g_shmem_size = mem_size;
141 g_shmem = WLS_Alloc(g_phy_wls, g_shmem_size);
144 printf("Unable to alloc WLS Memory\n");
150 uint64_t phy_fapi_recv()
152 uint8_t num_blks = 0;
162 num_blks = WLS_Wait(g_phy_wls);
163 printf("WLS_Wait returns %d blocks\n",num_blks);
167 p_msg = WLS_Get(g_phy_wls, &msg_size, &msg_id, &flags);
170 printf("\n[PHY] FAPI2PHY WLS Received Block %d\n",i);
175 printf("\n[PHY] FAPI2PHY WLS Get Error for msg %d\n",i);
178 if (flags & WLS_TF_FIN)
185 printf("\n[PHY] FAPI2PHY WLS wait returned 0 blocks exiting \n");
193 uint8_t phy_fapi_send()
195 uint64_t pa_block = 0;
196 uint8_t ret = FAILURE;
199 for (i=0 ; i < NUM_PHY_MSGS; i++)
202 pa_block = (uint64_t) WLS_DequeueBlock((void*) g_phy_wls);
205 printf("\n[PHY] FAPI2PHY WLS Dequeue block %d error\n",i);
209 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);
210 printf("\n[PHY] FAPI2PHY WLS Put Msg %d \n",i);
213 printf("\n[PHY] FAPI2PHY WLS Put Msg Error %d \n",i);