#define TDD                 1
#define N_RB_DL             {{ slapparameter_dict.get('n_rb_dl', slap_configuration['configuration.default_lte_n_rb_dl']) }}
#define N_ANTENNA_DL        2
#define N_ANTENNA_UL        2

{
  log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,s1ap.level=debug,s1ap.max_size=1,x2ap.level=debug,x2ap.max_size=1,rrc.level=debug,rrc.max_size=1,file.rotate=1G,file.path=/dev/null",
  log_filename: "{{ directory['log'] }}/enb.log",

  rf_driver: {
      name: "sdr",
      args: "dev0=/dev/sdr0",
      rx_antenna:"tx_rx",
  },
  tx_gain: {{ slapparameter_dict.get('tx_gain', slap_configuration['configuration.default_lte_tx_gain']) }},
  rx_gain: {{ slapparameter_dict.get('rx_gain', slap_configuration['configuration.default_lte_rx_gain']) }},

  mme_list: [
{% if slapparameter_dict.get('mme_list', '') %}
{%- for i, k in enumerate(slapparameter_dict['mme_list']) %}
{%- if i == 0 %}
    {
{%- else -%}
    , {
{%- endif %}
         mme_addr: "{{ slapparameter_dict['mme_list'][k]['mme_addr'] }}",
    }
{%- endfor -%}
{% else %}
    {
      mme_addr: "127.0.1.100",
    },
{% endif %}
  ],
{% if slapparameter_dict.get('mme_list', '') %}
{%   if slapparameter_dict.get('use_ipv4', False) %}
  gtp_addr: "{{ gtp_addr_v4 }}",
{%   else %}
  gtp_addr: "{{ gtp_addr_v6 }}",
{%   endif %}
{% else %}
  gtp_addr: "127.0.1.1",
{% endif %}

  enb_id: {{ slapparameter_dict.get('enb_id', '0x1A2D0') }},

  cell_list: [
  {
    plmn_list: [
{%- if slapparameter_dict.get('plmn_list', '') %}
{%- for i, k in enumerate(slapparameter_dict['plmn_list']) %}
{%- if i == 0 -%}
      {
{%- else -%}
      , {
{%- endif %}
      plmn: "{{ slapparameter_dict['plmn_list'][k]['plmn'] }}",
      reserved: {{ str(slapparameter_dict['plmn_list'][k].get('reserved', false)).lower() }},
      attach_without_pdn: {{ str(slapparameter_dict['plmn_list'][k].get('attach_without_pdn', false)).lower() }},
      }
{%- endfor -%}
{% else %}
      "00101",
{% endif %}
    ],

    dl_earfcn: {{ slapparameter_dict.get('dl_earfcn', slap_configuration['configuration.default_dl_earfcn']) }},

    n_id_cell: {{ slapparameter_dict.get('pci', 1) }},
    cell_id: 0x01,
    tac: 0x0001,
    root_sequence_index: 204,
  },
  ],

  cell_default: {
    n_antenna_dl: N_ANTENNA_DL,
    n_antenna_ul: N_ANTENNA_UL,
    
    uldl_config: 2,
    sp_config: 7,

    n_rb_dl: N_RB_DL,
    cyclic_prefix: "normal",

    phich_duration: "normal",
    phich_resource: "1",

    si_value_tag: 0,
    cell_barred: false,
    intra_freq_reselection: true,
    q_rx_lev_min: -70,
    p_max: 10,
    si_window_length: 40,
    sib_sched_list: [ 
      {
        filename: "{{ sib23 }}",
        si_periodicity: 16,
      },
    ],

#if N_RB_DL == 6
    si_coderate: 0.30,
#else
    si_coderate: 0.20,
#endif
    si_pdcch_format: 2,

    n_symb_cch: 0,

    pdsch_dedicated: {
#if N_ANTENNA_DL == 4
      p_a: -6,
#elif N_ANTENNA_DL == 2
      p_a: -3,
#else
      p_a: 0,
#endif
      p_b: -1,
    },

#if N_RB_DL == 6
    pdcch_format: 1,
#else
    pdcch_format: 2,
#endif

#if N_RB_DL == 6
    prach_config_index: 15,
#else
    prach_config_index: 4,
#endif
    prach_freq_offset: -1,

    pucch_dedicated: {
      n1_pucch_sr_count: 11,
      cqi_pucch_n_rb: 1,
      tdd_ack_nack_feedback_mode: "multiplexing",
    },

    pusch_dedicated: {
      beta_offset_ack_index: 9,
      beta_offset_ri_index: 6,
      beta_offset_cqi_index: 6,
    },

    pusch_hopping_offset: -1,

    pusch_msg3_mcs: 0,

#if N_RB_DL == 6
    initial_cqi: 5,
#else
    initial_cqi: 3,
#endif

    dl_256qam: true,
    ul_64qam: true,

    sr_period: 20, 

    cqi_period: 40,

#if N_ANTENNA_DL >= 2
    m_ri: 8,
    transmission_mode: 3,
#endif

    srs_dedicated: {
#if N_RB_DL == 6
      srs_bandwidth_config: 7,
      srs_bandwidth: 1,
#elif N_RB_DL == 15
      srs_bandwidth_config: 6,
      srs_bandwidth: 1,
#elif N_RB_DL == 25
      srs_bandwidth_config: 3,
      srs_bandwidth: 1,
#elif N_RB_DL == 50
      srs_bandwidth_config: 2,
      srs_bandwidth: 2,
#elif N_RB_DL == 75
      srs_bandwidth_config: 2,
      srs_bandwidth: 2,
#else
      srs_bandwidth_config: 2,
      srs_bandwidth: 3,
#endif
      srs_subframe_config: 3,
      srs_period: 40,
      srs_hopping_bandwidth: 0,
    },

    mac_config: {
       ul_max_harq_tx: 5,
       dl_max_harq_tx: 5,
    },

    pusch_max_its: 6,

    dpc: true,
    dpc_pusch_snr_target: 25,
    dpc_pucch_snr_target: 20,

    cipher_algo_pref: [],
    integ_algo_pref: [2, 1],

    inactivity_timer: 10000,

    srb_config: [
      {
        id: 1,
        maxRetxThreshold: 32,
        t_Reordering: 45,
        t_PollRetransmit: 60,
      },
      {
        id: 2 ,
        maxRetxThreshold: 32,
        t_Reordering: 45,
        t_PollRetransmit: 60,
      }
    ],

#define T_REORDERING 65
    drb_config: [
  
  {
    qci: 1, 
    ims_dedicated_bearer: true,
    pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_Size: 7,
      
      
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 12,
      pdcp_SN_SizeDL: 12,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      
      
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 5,
      },
      dl_um: {
        sn_FieldLength: 5,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      
      priority: 7,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 2, 
    ims_dedicated_bearer: true,
    pdcp_config: {
      discardTimer: 150, 
      pdcp_SN_Size: 12,
    },
    nr_pdcp_config: {
      discardTimer: 150, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      t_Reordering: 0,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 10,
      },
      dl_um: {
        sn_FieldLength: 10,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      priority: 9,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 3, 
    pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_Size: 12,
    },
    nr_pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      t_Reordering: 0,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 10,
      },
      dl_um: {
        sn_FieldLength: 10,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      priority: 8,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 4, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 10,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 65, 
    ims_dedicated_bearer: true,
    pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_Size: 7,
      
      
    },
    nr_pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_SizeUL: 12,
      pdcp_SN_SizeDL: 12,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      t_Reordering: 0,
      
      
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 5,
      },
      dl_um: {
        sn_FieldLength: 5,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      
      priority: 5,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 66, 
    ims_dedicated_bearer: true,
    pdcp_config: {
      discardTimer: 150, 
      pdcp_SN_Size: 12,
    },
    nr_pdcp_config: {
      discardTimer: 150, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      t_Reordering: 0,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 10,
      },
      dl_um: {
        sn_FieldLength: 10,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      
      priority: 7,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 67, 
    ims_dedicated_bearer: true,
    pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_Size: 12,
    },
    nr_pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      t_Reordering: 0,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 10,
      },
      dl_um: {
        sn_FieldLength: 10,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      priority: 6,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  
  {
    qci: 5, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 6,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 6, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 12,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 2,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 7, 
    pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_Size: 12,
    },
    nr_pdcp_config: {
      discardTimer: 100, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: false,
      outOfOrderDelivery: false,
      t_Reordering: 0,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_um: {
        sn_FieldLength: 10,
      },
      dl_um: {
        sn_FieldLength: 10,
        t_Reordering: T_REORDERING, 
      },
    },
    logical_channel_config: {
      priority: 13,
      prioritisedBitRate: 0, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 2,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 8, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 14,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 2,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 9, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
    },
    en_dc_split: {
      type: "scg",
      ul_data_threshold: 0
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 15,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 3,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 69, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 4,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 1,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  {
    qci: 70, 
    pdcp_config: {
      discardTimer: 0, 
      statusReportRequired: true,
    },
    nr_pdcp_config: {
      discardTimer: 0, 
      pdcp_SN_SizeUL: 18,
      pdcp_SN_SizeDL: 18,
      statusReportRequired: true,
      outOfOrderDelivery: false,
      restrict_to_ng_enb: true,
    },
    rlc_config: {
      ul_am: {
        t_PollRetransmit: 80, 
        pollPDU: 64,
        pollByte: 125, 
        maxRetxThreshold: 32,
      },
      dl_am: {
        t_Reordering: T_REORDERING, 
        t_StatusProhibit: 10, 
      },
    },
    logical_channel_config: {
      priority: 11,
      prioritisedBitRate: 8, 
      bucketSizeDuration: 100, 
      logicalChannelGroup: 2,
      logicalChannelSR_Mask: false,
      logicalChannelSR_Prohibit: false,
    },
  },
  ]

  },
}
