Commit b4c04aaf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a34b1023
......@@ -35,21 +35,12 @@
{{- slapparameter_dict.get(name, defaults.get(name)) }}
{%- endmacro %}
{%- import 'lte.jinja2' as lte with context -%}
{#- J is used around macro calls to retrieve returned objects.
It is needed to workaround jinja2 limitation that macro can return only
strings - not arbitrary objects: we return objects as JSON-encoded string
and J decodes them.
By convention macros that return JSON-encoded objects start with "j" prefix.
Usage example:
set obj = J(jmymacro(...))
#}
{%- set J = json_module.loads %}
{%- import 'lte.jinja2' as lte with context %}
{%- set iru_dict = lte.iru_dict %}
{%- set icell_dict = lte.icell_dict %}
{%- set J = lte.J %}
{%- set jref_of_shared = lte.jref_of_shared %}
{%- set jcell_ru_ref = lte.jcell_ru_ref %}
{#- XXX error(slave, msg) vvv is debug stub -#}
{%- macro error(slave, msg) %}
......@@ -58,103 +49,11 @@
{%- do assert(False, msg) %}
{%- endmacro %}
{#- bug indicates an error in template logic.
it should not happen. #}
{%- macro bug(msg) %}
{%- do assert(False, msg) %}
{%- endmacro %}
{#- jcell_ru_ref returns RU reference linked from a cell.
if the cell embeds RU definition, its reference comes as `_<cell_ref>_ru`. #}
{%- macro jcell_ru_ref(icell) %}
{{- _jcell_ru_ref(icell, []) }}
{%- endmacro %}
{%- macro _jcell_ru_ref(icell, seen) %}
{%- set cell_ref = J(jref_of_shared(icell)) %}
{%- if cell_ref in seen %}
{%- for x in seen %}
{%- do error(x, "%s form a cycle via RU references" % seen) %}
{%- endfor %}
{#- XXX what to return ? #}
{%- else %}
{%- do seen.append(cell_ref) %}
{%- set ru = icell['_']['ru'] %}
{%- if ru.ru_type == 'ru_ref' %}
{{- ru.ru_ref | tojson }}
{%- elif ru.ru_type == 'ruincell_ref' %}
{#- XXX first check referred cell exist ? #}
{{- _jcell_ru_ref(icell_dict[ru.ruincell_ref], seen) }}
{%- else %}
{#- ru definition is embedded into cell #}
{{- ('_%s_ru' % J(jref_of_shared(icell))) | tojson }}
{%- endif %}
{%- endif %}
{%- endmacro %}
{#- jref_of_shared returns original reference used to request shared instance.
it is extracted from slave_reference which is composed as <partition_id>_<reference>. #}
{%- macro jref_of_shared(slave) %}
{#- do print('jref_of_shared %r' % (slave,)) #}
{%- set ref = slave['slave_reference'] %}
{%- set partition_id = slap_configuration['slap-computer-partition-id'] %}
{%- if ref.startswith(partition_id) %}
{%- set ref = ref[len(partition_id):] %}
{%- endif %}
{%- if ref.startswith('_') %}
{%- set ref = ref[1:] %}
{%- endif %}
{{- ref | tojson }}
{%- endmacro %}
{#- icell_dict keeps cell slave instances: reference -> icell
iru_dict keeps RU slave instances + RU whose definition is embedded into a cell: reference -> iRU
in the kept instances _ is automatically json-decoded
#}
{%- set icell_dict = {} %}
{%- set iru_dict = {} %}
{%- for slave in slap_configuration.get('slave-instance-list', []) %}
{%- set ref = J(jref_of_shared(slave)) %}
{%- set _ = J(slave['_']) %}
{%- do slave.update({'_': _}) %}
{%- if 'ru_type' in _ %}
{%- set iru = slave %}
{%- do iru_dict.update({ref: iru}) %}
{%- elif 'cell_type' in _ %}
{%- set icell = slave %}
{%- for k, v in defaults['cell/' + _.cell_type].items() %}
{%- do _.setdefault(k, v) %}
{%- endfor %}
{%- do icell_dict.update({ref: icell}) %}
{%- set ru = _['ru'] %}
{%- if ru.ru_type not in ('ru_ref', 'ruincell_ref') %}
{#- embedded ru definition -> expose it as `_<cell_ref>_ru` #}
{%- do iru_dict.update({'_%s_ru' % ref: {
'_': ru,
'slave_title': '%s. RU' % icell.slave_title,
'slave_reference': icell.slave_reference,
}}) %}
{%- endif %}
{%- else %}
{%- do error(slave, "unknown shared instance type") %}
{%- endif %}
{%- endfor %}
{#- do print('\n>>> iru_dict:'), pprint(iru_dict) #}
{#- do print('\n>>> icell_dict:'), pprint(icell_dict) #}
{#- XXX verify cell_type = lte|nr XXX no - this should be verified by json-schema #}
{#- verify that there is no dangling cell->ru references #}
{#- XXX also verify that there is no dangling cell -> cell refs in ruincell_ref #}
{%- for _, icell in icell_dict|dictsort %}
{%- set ru_ref = J(jcell_ru_ref(icell)) %}
{%- if ru_ref not in iru_dict %}
{%- do error(icell, "referred RU %s does not exist" % ru_ref) %}
{%- endif %}
{%- endfor %}
{%- do lte.load_iru_and_icell() %}
{%- do lte.load_ipeer() %}
{#- XXX verify that lte.qshared_instance_list is empty #}
{#- start of the config -#}
......
{#- Package lte provides helpers for configuring Amarisoft LTE services. -#}
{#- Package lte provides helpers for configuring Amarisoft LTE services in SlapOS.
XXX overview
-#}
{#- XXX rename to amari ? -#}
{#- J is used around macro calls to retrieve returned objects.
It is needed to workaround jinja2 limitation that macro can return only
strings - not arbitrary objects: we return objects as JSON-encoded string
and J decodes them.
By convention macros that return JSON-encoded objects start with "j" prefix.
Usage example:
set obj = J(jmymacro(...))
#}
{%- set J = json_module.loads %}
{#- bug indicates an error in template logic.
it should not happen. #}
{%- macro bug(msg) %}
{%- do assert(False, msg) %}
{%- endmacro %}
{#- ---- loading ---- #}
{#- qshared_instance_list queues not yet loaded shared instances.
load_* routines process this queue and move loaded instances to i<type>_dict registries. #}
{%- set qshared_instance_list = slap_configuration.get('slave-instance-list', []) %}
{#- icell_dict keeps cell shared instances: reference -> icell
iru_dict keeps RU shared instances + RU whose definition is embedded into a cell: reference -> iRU
in the kept instances _ is automatically json-decoded
use load_iru_and_icell to initialize this cell and RU registries.
#}
{%- set icell_dict = {} %}
{%- set iru_dict = {} %}
{%- macro load_iru_and_icell() %}
{%- set qother = [] %}
{%- for ishared in qshared_instance_list %}
{%- set ref = J(jref_of_shared(ishared)) %}
{%- set _ = J(ishared['_']) %}
{%- do ishared.update({'_': _}) %}
{%- if 'ru_type' in _ %}
{%- set iru = ishared %}
{%- do iru_dict.update({ref: iru}) %}
{%- elif 'cell_type' in _ %}
{%- set icell = ishared %}
{%- for k, v in defaults['cell/' + _.cell_type].items() %}
{%- do _.setdefault(k, v) %}
{%- endfor %}
{%- do icell_dict.update({ref: icell}) %}
{%- set ru = _['ru'] %}
{%- if ru.ru_type not in ('ru_ref', 'ruincell_ref') %}
{#- embedded ru definition -> expose it as `_<cell_ref>_ru` #}
{%- do iru_dict.update({'_%s_ru' % ref: {
'_': ru,
'slave_title': '%s. RU' % icell.slave_title,
'slave_reference': icell.slave_reference,
}}) %}
{%- endif %}
{%- else %}
{%- do qother.append(ishared) %}
{%- endif %}
{%- endfor %}
{%- do qshared_instance_list.clear() %}
{%- do qshared_instance_list.extend(qother) %}
{#- do print('\n>>> iru_dict:'), pprint(iru_dict) #}
{#- do print('\n>>> icell_dict:'), pprint(icell_dict) #}
{#- XXX verify cell_type = lte|nr XXX no - this should be verified by json-schema #}
{#- verify that there is no dangling cell->ru references #}
{#- XXX also verify that there is no dangling cell -> cell refs in ruincell_ref #}
{%- for _, icell in icell_dict|dictsort %}
{%- set ru_ref = J(jcell_ru_ref(icell)) %}
{%- if ru_ref not in iru_dict %}
{%- do error(icell, "referred RU %s does not exist" % ru_ref) %}
{%- endif %}
{%- endfor %}
{%- endmacro %}
{#- jcell_ru_ref returns RU reference linked from a cell.
if the cell embeds RU definition, its reference comes as `_<cell_ref>_ru`. #}
{%- macro jcell_ru_ref(icell) %}
{{- _jcell_ru_ref(icell, []) }}
{%- endmacro %}
{%- macro _jcell_ru_ref(icell, seen) %}
{%- set cell_ref = J(jref_of_shared(icell)) %}
{%- if cell_ref in seen %}
{%- for x in seen %}
{%- do error(x, "%s form a cycle via RU references" % seen) %}
{%- endfor %}
{#- XXX what to return ? #}
{%- else %}
{%- do seen.append(cell_ref) %}
{%- set ru = icell['_']['ru'] %}
{%- if ru.ru_type == 'ru_ref' %}
{{- ru.ru_ref | tojson }}
{%- elif ru.ru_type == 'ruincell_ref' %}
{#- XXX first check referred cell exist ? #}
{{- _jcell_ru_ref(icell_dict[ru.ruincell_ref], seen) }}
{%- else %}
{#- ru definition is embedded into cell #}
{{- ('_%s_ru' % J(jref_of_shared(icell))) | tojson }}
{%- endif %}
{%- endif %}
{%- endmacro %}
{#- jref_of_shared returns original reference used to request shared instance.
it is extracted from slave_reference which is composed as <partition_id>_<reference>. #}
{%- macro jref_of_shared(slave) %}
{#- do print('jref_of_shared %r' % (slave,)) #}
{%- set ref = slave['slave_reference'] %}
{%- set partition_id = slap_configuration['slap-computer-partition-id'] %}
{%- if ref.startswith(partition_id) %}
{%- set ref = ref[len(partition_id):] %}
{%- endif %}
{%- if ref.startswith('_') %}
{%- set ref = ref[1:] %}
{%- endif %}
{{- ref | tojson }}
{%- endmacro %}
{#- ipeer_dict keeps peer shared instances: reference -> ipeer
use load_ipeer to initialize this peer registry.
#}
{%- set ipeer_dict = {} %}
{%- macro load_ipeer() %}
// XXX TODO
{%- endmacro %}
{# ---- XXX ---- #}
{#- ru_config emits RF driver configuration for specified Radio Units. #}
{%- macro ru_config(iru_dict, slapparameter_dict) %}
// Radio Units
......
{
log_options: "all.level=error,all.max_size=0,nas.level=debug,nas.max_size=1,rrc.level=debug,rrc.max_size=1,phy.level=info,file.rotate=1G,file.path=/dev/null",
log_filename: "log/ue.log",
rue_bind_addr: "::1",
com_addr: "[::1]:9002",
// Radio Units
rf_driver: {
name: "sdr",
args: "",
},
tx_gain: [],
rx_gain: [],
cell_groups: [{
// LTE cells
group_type: "lte",
multi_ue: true,
cells: [
],
pdcch_decode_opt: false,
pdcch_decode_opt_threshold: 0.1,
}, {
// NR cells
group_type: "nr",
multi_ue: true,
cells: [
]
}],
ue_list: [
],
}
\ No newline at end of file
......@@ -16,10 +16,10 @@
%}
{%- import 'lte.jinja2' as lte with context -%}
{%- set iru_dict = lte.iru_dict %}
{%- set icell_dict = lte.icell_dict %}
{%- set amari = lte %}{#- XXX temp #}
// XXX setup iru + icell
{#- iue_dict keeps ue slave instances: reference -> iue
in the kept instances _ is automatically json-decoded
......@@ -42,6 +42,12 @@
{#- XXX verify ue.ue_type in lte|nr #}
{%- do lte.load_iru_and_icell() %}
{%- do lte.load_ipeer() %}
{#- XXX verify that lte.qshared_instance_list is empty #}
{#- start of the config -#}
{#- start of the config -#}
{
......@@ -54,14 +60,6 @@
{# instantiate radio units #}
{{ amari.ru_config(iru_dict, slapparameter_dict) }}
rf_driver: {
name: "sdr",
args: "dev0=/dev/sdr0",
rx_antenna:"tx_rx",
},
tx_gain: {{ slapparameter_dict.get('tx_gain', 60) }},
rx_gain: {{ slapparameter_dict.get('rx_gain', 40) }},
cell_groups: [{
// LTE cells
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment