{#- Package lte provides helpers for configuring LTE cells. -#}

{#- cell_tdd_config returns tdd_config for an LTE cell. #}
{%- macro cell_tdd_config(cell) %}
{%-   set _ = {'[Configuration 2] 5ms 2UL 6DL (default)':        2,
               '[Configuration 6] 5ms 5UL 3DL (maximum uplink)': 6} %}
{{-   _[cell.get('tdd_ul_dl_config', '[Configuration 2] 5ms 2UL 6DL (default)')]  }}
{%- endmacro -%}

{#- cell_n_rb_dl returns n_rb_dl for an LTE cell. #}
{%- macro cell_n_rb_dl(cell) %}
{%-   set _ = {'1.4 MHz':  6,
               '3 MHz':   15,
               '5 MHz':   25,
               '10 MHz':  50,
               '15 MHz':  75,
               '20 MHz': 100}   %}
{{-   _[cell['bandwidth']] }}
{%- endmacro -%}


{#- cell_drb_config returns drb_config section for an LTE cell.
    DRB configuration varies in beteen FDD and TDD modes. #}
{%- macro cell_drb_config(cell) %}
{%-   if cell['rf_mode'] == 'tdd' %}
{%-     set T_REORDERING = 65 %}
{%-   else %}
{%-     set T_REORDERING = 35 %}
{%-   endif %}
  [
  {
    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,
    },
  },
  ]
{%- endmacro %}
