#include "restore_to_hal.h"
#include <stdlib.h>
#include <string.h>
#include <amxc/amxc_macros.h>
#include <amxc/amxc.h>
#include <amxp/amxp_timer.h>
#include "data_model.h"
#include "dm_info.h"
#include "pon_ctrl.h"
#include "xpon_mgr_constants.h"
#include "xpon_trace.h"
Go to the source code of this file.
◆ rth_task_t
Task to enable an object in the HAL.
- path: path of object to be enabled, e.g. "XPON.ONU.1"
- cntr: when enabling an XPON.ONU instance, tr181-xpon waits for a few seconds until the XPON.ONU instance has at least one EthernetUNI instance and one ANI instance. Enabling the XPON.ONU instance before tr181-xpon has discovered its EthernetUNI or ANI instance(s) might cause errors. E.g. the vendor module might already try to update the Status field of the EthernetUNI instance. This counter keeps track of how many times tr181-xpon checked the number of EthernetUNIs and ANIs of the XPON.ONU instance given by 'path'. If the counter goes above MAX_CHECKS_ON_NR_OF_UNIS_AND_ANIS, tr181-xpon enables the XPON.UNI instance even if its number of EthernetUNIs or ANIs is still 0. The field 'cntr' tracks more or less a number of seconds. By setting the MAX_CHECKS value to 4, tr181-xpon waits max about 4 to 5 seconds for both an EthernetUNI and ANI to appear. If 'path' refers to something else than an XPON.ONU instance, this counter is don't care.
- it: iterator to put it in s_rth_tasks
◆ handle_rth_tasks()
static void handle_rth_tasks |
( |
amxp_timer_t * |
timer, |
|
|
UNUSED void * |
priv |
|
) |
| |
|
static |
Handle all tasks in the list s_rth_tasks to restore their Enable=1 setting.
For each task in the list, do the following:
- If the path in the task does not refer to an XPON.ONU instance, call pon_ctrl_set_enable(), remove the task from the list and delete it.
- If the path in the task refers to an XPON.ONU instance, check its number of EthernetUNIs and ANIs. If they are both non zero, or if the 'cntr' field of the task is larger than MAX_CHECKS_ON_NR_OF_UNIS_AND_ANIS, call pon_ctrl_set_enable(), remove the task from the list and delete it. Else increment the field 'cntr' and keep the task in the list. See doc of field 'cntr' of 'struct _rth_task' above for more info on this behavior.
Restart timer with timeout of 1 s if there are still tasks in the list.
Definition at line 177 of file restore_to_hal.c.
180 SAH_TRACEZ_WARNING(
ME,
"No tasks");
188 uint32_t n_ethernet_unis;
192 task = amxc_llist_it_get_data(it,
rth_task_t, it);
193 path = amxc_string_get(&task->
path, 0);
200 path, n_ethernet_unis, n_anis, task->
cntr);
201 if((n_ethernet_unis != 0) && (n_anis != 0)) {
204 SAH_TRACEZ_WARNING(
ME,
"Enable %s despite n_ethernet_unis=%d n_anis=%d",
205 path, n_ethernet_unis, n_anis);
215 amxc_llist_it_take(it);
221 amxp_timer_start(timer, 1000);
uint32_t dm_get_nr_of_ani_instances(const char *const onu_path)
uint32_t dm_get_nr_of_ethernet_uni_instances(const char *const onu_path)
object_id_t dm_get_object_id(const char *path)
enum _xpon_object_id object_id_t
void pon_ctrl_set_enable(const char *const path, bool enable)
static const uint8_t MAX_CHECKS_ON_NR_OF_UNIS_AND_ANIS
static amxc_llist_t s_rth_tasks
static void rth_task_clean(rth_task_t *const task)
#define SAH_TRACEZ_DEBUG(zone, format,...)
◆ rth_cleanup()
void rth_cleanup |
( |
void |
| ) |
|
Definition at line 234 of file restore_to_hal.c.
237 SAH_TRACEZ_WARNING(
ME,
"size(s_rth_tasks)=%zd != 0",
static void rth_task_delete(amxc_llist_it_t *hit)
static amxp_timer_t * s_timer_handle_rth_tasks
◆ rth_disable()
void rth_disable |
( |
const char *const |
object | ) |
|
Remove task to enable an object in the HAL if such task exists.
- Parameters
-
[in] | object | object path, e.g. "XPON.ONU.1" |
Definition at line 286 of file restore_to_hal.c.
293 task = amxc_llist_it_get_data(it,
rth_task_t, it);
294 path = amxc_string_get(&task->
path, 0);
295 if(strcmp(
object, path) == 0) {
296 amxc_llist_it_take(it);
◆ rth_init()
Definition at line 226 of file restore_to_hal.c.
230 SAH_TRACEZ_ERROR(
ME,
"Failed to create timer to handle tasks");
static void handle_rth_tasks(amxp_timer_t *timer, UNUSED void *priv)
◆ rth_schedule_enable()
void rth_schedule_enable |
( |
const char *const |
object | ) |
|
Schedule task to enable an object in the HAL.
- Parameters
-
[in] | object | object path, e.g. "XPON.ONU.1" |
The function creates a task to enable the object in the HAL, appends it to the list of tasks managed by this restore_to_hal part, and starts the timer to handle all tasks in that list.
If there is already a task in the list to enable the object, the function immediately returns.
Definition at line 256 of file restore_to_hal.c.
265 task = amxc_llist_it_get_data(it,
rth_task_t, it);
266 path = amxc_string_get(&task->
path, 0);
267 if(strncmp(path,
object, strlen(
object)) == 0) {
static rth_task_t * rth_task_create(const char *const path)
◆ rth_task_clean()
static void rth_task_clean |
( |
rth_task_t *const |
task | ) |
|
|
static |
◆ rth_task_create()
static rth_task_t* rth_task_create |
( |
const char *const |
path | ) |
|
|
static |
Create task and append it to 's_rth_tasks'.
If it fails to create the task or to append the task to 's_rth_tasks', the function is a no-op.
- Returns
- task created on success, else NULL
Definition at line 132 of file restore_to_hal.c.
135 when_null_trace(task, exit, ERROR,
"Failed to allocate memory");
137 amxc_string_init(&task->
path, 0);
138 amxc_string_set(&task->
path, path);
141 SAH_TRACEZ_ERROR(
ME,
"Failed to append task to 's_rth_tasks'");
142 SAH_TRACEZ_ERROR(
ME,
" path='%s'", path);
◆ rth_task_delete()
static void rth_task_delete |
( |
amxc_llist_it_t * |
hit | ) |
|
|
static |
◆ MAX_CHECKS_ON_NR_OF_UNIS_AND_ANIS
const uint8_t MAX_CHECKS_ON_NR_OF_UNIS_AND_ANIS = 4 |
|
static |
◆ s_rth_tasks
◆ s_timer_handle_rth_tasks
amxp_timer_t* s_timer_handle_rth_tasks = NULL |
|
static |