X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=fapi_5g%2Fsource%2Futils%2Fnr5g_fapi_config_loader.c;h=561c309a0140cfa2f60272cd275a8146986519dd;hb=HEAD;hp=a6fa6bd6003d666aaed52f3748234f8c89f4cc8c;hpb=70d9d920dd4e575f085f1f1a9050fefd1c10e127;p=o-du%2Fphy.git diff --git a/fapi_5g/source/utils/nr5g_fapi_config_loader.c b/fapi_5g/source/utils/nr5g_fapi_config_loader.c index a6fa6bd..561c309 100644 --- a/fapi_5g/source/utils/nr5g_fapi_config_loader.c +++ b/fapi_5g/source/utils/nr5g_fapi_config_loader.c @@ -1,6 +1,6 @@ /****************************************************************************** * -* Copyright (c) 2019 Intel. +* Copyright (c) 2021 Intel. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,55 @@ char *fgets_s( size_t len, FILE * fp); +void nr5g_fapi_get_worker_info( + struct rte_cfgfile *cfg_file, + unsigned int num_cpus, + nr5g_fapi_thread_params_t * thread_params, + const char* worker_name) +{ + const char *entry; + + entry = rte_cfgfile_get_entry(cfg_file, worker_name, "core_id"); + if (entry) { + thread_params->thread_worker.core_id = (uint8_t) atoi(entry); + if (thread_params->thread_worker.core_id >= (uint8_t) num_cpus) { + printf("Core Id is not in the range 0 to %d: configured: %d\n", + num_cpus, thread_params->thread_worker.core_id); + exit(-1); + } + } + + entry = + rte_cfgfile_get_entry(cfg_file, worker_name, + "thread_sched_policy"); + if (entry) { + thread_params->thread_worker.thread_sched_policy = (uint8_t) atoi(entry); + if (thread_params->thread_worker.thread_sched_policy != SCHED_FIFO && + thread_params->thread_worker.thread_sched_policy != SCHED_RR) { + printf("Thread Policy valid range is Schedule Policy [1: SCHED_FIFO" + " 2: SCHED_RR]: configured: %d\n", + thread_params->thread_worker.thread_sched_policy); + exit(-1); + } + } + + int min_prio = + sched_get_priority_min(thread_params->thread_worker.thread_sched_policy); + int max_prio = + sched_get_priority_max(thread_params->thread_worker.thread_sched_policy); + entry = + rte_cfgfile_get_entry(cfg_file, worker_name, "thread_priority"); + if (entry) { + thread_params->thread_worker.thread_priority = (uint8_t) atoi(entry); + if (thread_params->thread_worker.thread_priority < min_prio && + thread_params->thread_worker.thread_priority > max_prio) { + printf("Thread priority valid range is %d to %d: configured: %d\n", + min_prio, max_prio, thread_params->thread_worker.thread_priority); + exit(-1); + } + } +} + p_nr5g_fapi_cfg_t nr5g_fapi_config_loader( char *prgname, const char *cfg_fname) @@ -32,7 +81,7 @@ p_nr5g_fapi_cfg_t nr5g_fapi_config_loader( struct rte_cfgfile *cfg_file; p_nr5g_fapi_cfg_t cfg; const char *entry; - size_t dev_name_len; + size_t dev_name_len, mem_zone_name_len; unsigned int num_cpus = 0; char check_core_count[255], *max_core; FILE *fp = NULL; @@ -69,81 +118,20 @@ p_nr5g_fapi_cfg_t nr5g_fapi_config_loader( } pclose(fp); num_cpus = atoi(max_core); - entry = rte_cfgfile_get_entry(cfg_file, "MAC2PHY_WORKER", "core_id"); - if (entry) { - cfg->mac2phy_worker.core_id = (uint8_t) atoi(entry); - if (cfg->mac2phy_worker.core_id >= (uint8_t) num_cpus) { - printf("Core Id is not in the range 0 to %d: configured: %d\n", - num_cpus, cfg->mac2phy_worker.core_id); - exit(-1); - } - } - entry = - rte_cfgfile_get_entry(cfg_file, "MAC2PHY_WORKER", - "thread_sched_policy"); - if (entry) { - cfg->mac2phy_worker.thread_sched_policy = (uint8_t) atoi(entry); - if (cfg->mac2phy_worker.thread_sched_policy != SCHED_FIFO && - cfg->mac2phy_worker.thread_sched_policy != SCHED_RR) { - printf("Thread Poicy valid range is Schedule Policy [0: SCHED_FIFO" - " 1: SCHED_RR]: configured: %d\n", - cfg->mac2phy_worker.thread_sched_policy); - exit(-1); - } - } - - int min_prio = - sched_get_priority_min(cfg->mac2phy_worker.thread_sched_policy); - int max_prio = - sched_get_priority_max(cfg->mac2phy_worker.thread_sched_policy); - entry = - rte_cfgfile_get_entry(cfg_file, "MAC2PHY_WORKER", "thread_priority"); - if (entry) { - cfg->mac2phy_worker.thread_priority = (uint8_t) atoi(entry); - if (cfg->mac2phy_worker.thread_priority < min_prio && - cfg->mac2phy_worker.thread_priority > max_prio) { - printf("Thread priority valid range is %d to %d: configured: %d\n", - min_prio, max_prio, cfg->mac2phy_worker.thread_priority); - exit(-1); - } - } - - entry = rte_cfgfile_get_entry(cfg_file, "PHY2MAC_WORKER", "core_id"); - if (entry) { - cfg->phy2mac_worker.core_id = (uint8_t) atoi(entry); - if (cfg->phy2mac_worker.core_id >= (uint8_t) num_cpus) { - printf("Core Id is not in the range 0 to %d configured: %d\n", - num_cpus, cfg->phy2mac_worker.core_id); - exit(-1); - } - } - - entry = - rte_cfgfile_get_entry(cfg_file, "PHY2MAC_WORKER", - "thread_sched_policy"); - if (entry) { - cfg->phy2mac_worker.thread_sched_policy = (uint8_t) atoi(entry); - if (cfg->phy2mac_worker.thread_sched_policy != SCHED_FIFO && - cfg->phy2mac_worker.thread_sched_policy != SCHED_RR) { - printf("Thread Poicy valid range is Schedule Policy [0: SCHED_FIFO" - " 1: SCHED_RR] configured: %d\n", - cfg->phy2mac_worker.thread_sched_policy); - exit(-1); - } + cfg->is_urllc_enabled = TRUE; + entry = rte_cfgfile_get_entry(cfg_file, "URLLC", "is_enabled"); + if (entry) + { + cfg->is_urllc_enabled = (bool)atoi(entry); + if (!cfg->is_urllc_enabled) + printf("URLLC disabled\n"); } - entry = - rte_cfgfile_get_entry(cfg_file, "PHY2MAC_WORKER", "thread_priority"); - if (entry) { - cfg->phy2mac_worker.thread_priority = (uint8_t) atoi(entry); - if (cfg->phy2mac_worker.thread_priority < min_prio && - cfg->phy2mac_worker.thread_priority > max_prio) { - printf("Thread priority valid range is %d to %d configured: %d\n", - min_prio, max_prio, cfg->phy2mac_worker.thread_priority); - exit(-1); - } - } + nr5g_fapi_get_worker_info(cfg_file, num_cpus, &cfg->mac2phy_thread_params, "MAC2PHY_WORKER"); + nr5g_fapi_get_worker_info(cfg_file, num_cpus, &cfg->phy2mac_thread_params, "PHY2MAC_WORKER"); + nr5g_fapi_get_worker_info(cfg_file, num_cpus, &cfg->urllc_mac2phy_thread_params, "MAC2PHY_URLLC_WORKER"); + nr5g_fapi_get_worker_info(cfg_file, num_cpus, &cfg->urllc_phy2mac_thread_params, "PHY2MAC_URLLC_WORKER"); entry = rte_cfgfile_get_entry(cfg_file, "WLS_CFG", "device_name"); if (entry) { @@ -184,6 +172,13 @@ p_nr5g_fapi_cfg_t nr5g_fapi_config_loader( } } + entry = rte_cfgfile_get_entry(cfg_file, "DPDK", "dpdk_memory_zone"); + if (entry) { + mem_zone_name_len = (strlen(entry) > (NR5G_FAPI_MEMORY_ZONE_NAME_LEN)) ? + (NR5G_FAPI_MEMORY_ZONE_NAME_LEN) : strlen(entry); + rte_strlcpy(cfg->dpdk.memory_zone, entry, mem_zone_name_len + 1); + } + return cfg; }