From 62a2f833c7f2b82c6a02541679fe10fee791fe29 Mon Sep 17 00:00:00 2001
From: winckel <winckel@eurecom.fr>
Date: Fri, 31 Jan 2014 10:21:54 +0000
Subject: [PATCH] Added some physical parameters into the configuration file.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4994 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair2/ENB_APP/enb_config.c                 | 80 +++++++++++++++----
 openair2/ENB_APP/enb_config.h                 | 37 ++++++---
 .../GENERIC-LTE-EPC/CONF/enb.pft.sud.conf     |  9 +++
 3 files changed, 97 insertions(+), 29 deletions(-)

diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 3e70743441..5b95f968df 100755
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -60,7 +60,7 @@ int enb_config_init(char* lib_config_file_name_pP) {
   config_setting_t *setting_mme_addresses;
   config_setting_t *setting_mme_address;
   config_setting_t *setting_enb;
-  int               num_enbs, num_mme_address, i, j, parse_error, enb_properties_index;
+  int               num_enbs, num_mme_address, i, j, parse_error = 0, enb_properties_index;
   long int          enb_id;
   const char*       cell_type;
   long int          tac;
@@ -68,11 +68,15 @@ int enb_config_init(char* lib_config_file_name_pP) {
   long int          mcc;
   long int          mnc;
   const char*       default_drx;
+  const char*       frame_type;
+  const char*       prefix_type;
+  long int          downlink_frequency;
+  long int          uplink_frequency_offset;
   char*             ipv4;
   char*             ipv6;
   char*             active;
   char*             preference;
-  char*             active_enb[MAX_ENB];
+  const char*       active_enb[MAX_ENB];
 
 
   memset((char*)g_enb_properties, 0 , MAX_ENB * sizeof(Enb_properties_t*));
@@ -87,7 +91,7 @@ int enb_config_init(char* lib_config_file_name_pP) {
       {
           LOG_E(ENB_APP, "%s:%d - %s\n", lib_config_file_name_pP, config_error_line(&cfg), config_error_text(&cfg));
           config_destroy(&cfg);
-          AssertFatal (1 == 0, "Failed to parse eNB configuration file %s!\n", lib_config_file_name_pP);
+          AssertFatal (0, "Failed to parse eNB configuration file %s!\n", lib_config_file_name_pP);
       }
   }
   else
@@ -133,8 +137,7 @@ int enb_config_init(char* lib_config_file_name_pP) {
                      && config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_DEFAULT_PAGING_DRX,  &default_drx)
                 )
             ) {
-              parse_error = 1;
-              AssertFatal (parse_error == 0,
+              AssertError (0, parse_error ++,
                       "Failed to parse eNB configuration file %s, %u th enb\n",
                       lib_config_file_name_pP, i);
           }
@@ -149,9 +152,9 @@ int enb_config_init(char* lib_config_file_name_pP) {
                   } else  if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
                       g_enb_properties[enb_properties_index]->cell_type = CELL_HOME_ENB;
                   } else {
-                      AssertFatal (1 == 0,
-                              "Failed to parse eNB configuration file %s, enb %d unknown value for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
-                              lib_config_file_name_pP, i);
+                      AssertError (0, parse_error ++,
+                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
+                              lib_config_file_name_pP, i, cell_type);
                   }
                   g_enb_properties[enb_properties_index]->eNB_name = strdup(enb_name);
                   g_enb_properties[enb_properties_index]->tac      = (uint16_t)tac;
@@ -167,11 +170,51 @@ int enb_config_init(char* lib_config_file_name_pP) {
                   } else  if (strcmp(default_drx, "PAGING_DRX_256") == 0) {
                       g_enb_properties[enb_properties_index]->default_drx = PAGING_DRX_256;
                   } else {
-                      AssertFatal (1 == 0,
-                              "Failed to parse eNB configuration file %s, enb %d unknown value for default_drx choice: PAGING_DRX_32..PAGING_DRX_256 !\n",
-                              lib_config_file_name_pP, i);
+                      AssertError (0, parse_error ++,
+                              "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for default_drx choice: PAGING_DRX_32..PAGING_DRX_256 !\n",
+                              lib_config_file_name_pP, i, default_drx);
+                  }
+
+                  // Parse optional physical parameters
+                  if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_FRAME_TYPE, &frame_type)) {
+                      if (strcmp(frame_type, "FDD") == 0) {
+                          g_enb_properties[enb_properties_index]->frame_type = FDD;
+                      } else  if (strcmp(frame_type, "TDD") == 0) {
+                          g_enb_properties[enb_properties_index]->frame_type = TDD;
+                      } else {
+                          AssertError (0, parse_error ++,
+                                  "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for frame_type choice: FDD or TDD !\n",
+                                  lib_config_file_name_pP, i, frame_type);
+                      }
+                  } else {
+                      g_enb_properties[enb_properties_index]->frame_type = FDD; // Default frame type
+                  }
+
+                  if(config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_PREFIX_TYPE, &prefix_type)) {
+                      if (strcmp(prefix_type, "NORMAL") == 0) {
+                          g_enb_properties[enb_properties_index]->prefix_type = NORMAL;
+                      } else  if (strcmp(prefix_type, "EXTENDED") == 0) {
+                          g_enb_properties[enb_properties_index]->prefix_type = EXTENDED;
+                      } else {
+                          AssertError (0, parse_error ++,
+                                  "Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for prefix_type choice: NORMAL or EXTENDED !\n",
+                                  lib_config_file_name_pP, i, prefix_type);
+                      }
+                  } else {
+                      g_enb_properties[enb_properties_index]->prefix_type = NORMAL; // Default prefix type
+                  }
+
+                  if(config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_DOWNLINK_FREQUENCY, &downlink_frequency)) {
+                      g_enb_properties[enb_properties_index]->downlink_frequency = downlink_frequency;
+                  } else {
+                      g_enb_properties[enb_properties_index]->downlink_frequency = 2680000000; // Default downlink frequency
+                  }
+
+                  if(config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET, &uplink_frequency_offset)) {
+                      g_enb_properties[enb_properties_index]->uplink_frequency_offset = uplink_frequency_offset;
+                  } else {
+                      g_enb_properties[enb_properties_index]->uplink_frequency_offset = -120000000; // Default uplink frequency offset
                   }
-                  AssertFatal (parse_error == 0, "Failed to parse eNB configuration file %s, enb %d\n", lib_config_file_name_pP, i);
 
                   setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS);
                   num_mme_address     = config_setting_length(setting_mme_addresses);
@@ -185,9 +228,8 @@ int enb_config_init(char* lib_config_file_name_pP) {
                               && config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, (const char **)&preference)
                             )
                         ) {
-                          parse_error = 1;
-                          AssertFatal (parse_error == 0,
-                                  "Failed to parse eNB configuration file %s, %u th enb %u th mme address\n",
+                          AssertError (0, parse_error ++,
+                                  "Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
                                   lib_config_file_name_pP, i, j);
                       }
                       g_enb_properties[enb_properties_index]->nb_mme += 1;
@@ -216,8 +258,12 @@ int enb_config_init(char* lib_config_file_name_pP) {
           }
       }
   }
-  AssertFatal (enb_properties_index == g_num_enb_properties,
-          "Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs!\n",
+  AssertError (enb_properties_index == g_num_enb_properties, parse_error ++,
+          "Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs !\n",
           lib_config_file_name_pP, g_num_enb_properties, enb_properties_index);
+
+  AssertFatal (parse_error == 0,
+               "Failed to parse eNB configuration file %s, found %d error%s !\n",
+               lib_config_file_name_pP, parse_error, parse_error > 1 ? "s" : "");
   return 0;
 }
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index a5b6e749bb..f58c0d6104 100755
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -32,26 +32,33 @@
 #define ENB_CONFIG_H_
 
 #include "commonDef.h"
+#include "PHY/impl_defs_lte.h"
 #include "s1ap_messages_types.h"
 
-
 #define ENB_CONFIG_STRING_ACTIVE_ENBS               "Active_eNBs"
+
 #define ENB_CONFIG_STRING_ENB_LIST                  "eNBs"
 #define ENB_CONFIG_STRING_ENB_ID                    "eNB_ID"
 #define ENB_CONFIG_STRING_CELL_TYPE                 "cell_type"
 #define ENB_CONFIG_STRING_ENB_NAME                  "eNB_name"
+
 #define ENB_CONFIG_STRING_TRACKING_AREA_CODE        "tracking_area_code"
 #define ENB_CONFIG_STRING_MOBILE_COUNTRY_CODE       "mobile_country_code"
 #define ENB_CONFIG_STRING_MOBILE_NETWORK_CODE       "mobile_network_code"
+
 #define ENB_CONFIG_STRING_DEFAULT_PAGING_DRX        "default_paging_drx"
+
+#define ENB_CONFIG_STRING_FRAME_TYPE                "frame_type"
+#define ENB_CONFIG_STRING_PREFIX_TYPE               "prefix_type"
+#define ENB_CONFIG_STRING_DOWNLINK_FREQUENCY        "downlink_frequency"
+#define ENB_CONFIG_STRING_UPLINK_FREQUENCY_OFFSET   "uplink_frequency_offset"
+
 #define ENB_CONFIG_STRING_MME_IP_ADDRESS            "mme_ip_address"
 #define ENB_CONFIG_STRING_MME_IPV4_ADDRESS          "ipv4"
 #define ENB_CONFIG_STRING_MME_IPV6_ADDRESS          "ipv6"
 #define ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE     "active"
 #define ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE "preference"
 
-
-
 typedef struct mme_ip_address_s {
     unsigned  ipv4:1;
     unsigned  ipv6:1;
@@ -65,33 +72,39 @@ typedef struct Enb_properties_s {
      * For macro eNB ids this field should be 20 bits long.
      * For home eNB ids this field should be 28 bits long.
      */
-    uint32_t         eNB_id;
+    uint32_t            eNB_id;
 
     /* The type of the cell */
-    enum cell_type_e cell_type;
+    enum cell_type_e    cell_type;
 
     /* Optional name for the cell
      * NOTE: the name can be NULL (i.e no name) and will be cropped to 150
      * characters.
      */
-    char            *eNB_name;
+    char               *eNB_name;
 
     /* Tracking area code */
-    uint16_t         tac;
+    uint16_t            tac;
 
     /* Mobile Country Code
      * Mobile Network Code
      */
-    uint16_t         mcc;
-    uint16_t         mnc;
+    uint16_t            mcc;
+    uint16_t            mnc;
 
     /* Default Paging DRX of the eNB as defined in TS 36.304 */
-    paging_drx_t     default_drx;
+    paging_drx_t        default_drx;
+
+    /* Physical parameters */
+    lte_frame_type_t    frame_type;
+    lte_prefix_type_t   prefix_type;
+    uint32_t            downlink_frequency;
+    uint32_t            uplink_frequency_offset;
 
     /* Nb of MME to connect to */
-    uint8_t          nb_mme;
+    uint8_t             nb_mme;
     /* List of MME to connect to */
-    mme_ip_address_t mme_ip_address[S1AP_MAX_NB_MME_IP_ADDRESS];
+    mme_ip_address_t    mme_ip_address[S1AP_MAX_NB_MME_IP_ADDRESS];
 } Enb_properties_t;
 
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.pft.sud.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.pft.sud.conf
index 356ad517ce..f0125fc220 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.pft.sud.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.pft.sud.conf
@@ -3,6 +3,7 @@ Active_eNBs = ( "eNB_Eurecom_0");
 eNBs =
 (
  {
+    ////////// Identification parameters:
     eNB_ID    =  347472;
     
     cell_type =  "CELL_MACRO_ENB";
@@ -16,9 +17,17 @@ eNBs =
     
     mobile_network_code =  92;
     
+    ////////// Channel parameters:
     // Default Paging DRX of the eNB as defined in TS 36.304
     default_paging_drx  =  "PAGING_DRX_256";
     
+    ////////// Physical parameters:
+    frame_type              = "FDD";
+    prefix_type             = "NORMAL";
+    downlink_frequency      = 2680000000;
+    uplink_frequency_offset = -120000000;
+    
+    ////////// MME parameters:
     mme_ip_address      = ( { ipv4       = "192.168.12.31";
                               ipv6       = "2192:168:30::17";
                               active     = "yes";
-- 
GitLab