Multi RC REPORT service styles support
Issue: unforeseen capability of having the same RAN Parameter ID across different REPORT service styles. Solution: keep only RAN Parameter IDs from REPORT styles that are supported by OAI. Implement sequence array where each element is combination of RIC request ID (unique per RIC SUBSCRIPTION) and Event Trigger Definition. This way we can properly check further conditions for a certain RAN Parameter ID. (e.g. if xApp is subscribed to RRC Connected and/or other modes, for "RRC State Changed To" RAN Parameter ID) Next steps: for new RAN Parameter ID, add new sequence array. Co-authored-by: Bischoff <tano.bischoff@hhi.fraunhofer.de> Co-authored-by: Shrinish Donde <shrinish.donde@hhi.fraunhofer.de> Co-authored-by: Khanh Toan Pham <khanh.toan.pham@hhi.fraunhofer.de>
This commit is contained in:
co-authored by
Bischoff
Shrinish Donde
Khanh Toan Pham
parent
0053a3d0f4
commit
9e2c889dba
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "ran_func_rc_subs.h"
|
||||
#include "common/utils/assertions.h"
|
||||
#include "common/utils/alg/find.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
@@ -29,86 +30,36 @@
|
||||
|
||||
static pthread_mutex_t rc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
int cmp_ric_req_id(struct ric_req_id_s *c1, struct ric_req_id_s *c2)
|
||||
static bool eq_int(const void* value, const void* it)
|
||||
{
|
||||
if (c1->ric_req_id < c2->ric_req_id)
|
||||
return -1;
|
||||
|
||||
if (c1->ric_req_id > c2->ric_req_id)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
const uint32_t ric_req_id = *(uint32_t *)value;
|
||||
const ran_param_data_t *dit = (const ran_param_data_t *)it;
|
||||
return ric_req_id == dit->ric_req_id;
|
||||
}
|
||||
|
||||
RB_GENERATE(ric_id_2_param_id_trees, ric_req_id_s, entries, cmp_ric_req_id);
|
||||
|
||||
void init_rc_subs_data(rc_subs_data_t* rc_subs_data)
|
||||
void init_rc_subs_data(rc_subs_data_t *rc_subs_data)
|
||||
{
|
||||
pthread_mutex_lock(&rc_mutex);
|
||||
|
||||
// Initialize hash table
|
||||
DevAssert(rc_subs_data->htable == NULL);
|
||||
|
||||
// Initialize RB trees
|
||||
// 1 RB tree = 1 ran_param_id => many ric_req_id(s)
|
||||
for (size_t i = 0; i < END_E2SM_RC_RAN_PARAM_ID; i++) {
|
||||
RB_INIT(&rc_subs_data->rb[i]);
|
||||
}
|
||||
|
||||
rc_subs_data->htable = hashtable_create(MAX_NUM_RIC_REQ_ID, NULL, free);
|
||||
assert(rc_subs_data->htable != NULL && "Memory exhausted");
|
||||
// Initialize sequence array
|
||||
seq_arr_init(&rc_subs_data->rs4_param202, sizeof(ran_param_data_t));
|
||||
pthread_mutex_unlock(&rc_mutex);
|
||||
}
|
||||
|
||||
void insert_rc_subs_data(rc_subs_data_t* rc_subs_data, uint32_t ric_req_id, arr_ran_param_id_t* arr_ran_param_id)
|
||||
void insert_rc_subs_data(seq_arr_t *seq_arr, ran_param_data_t *data)
|
||||
{
|
||||
pthread_mutex_lock(&rc_mutex);
|
||||
|
||||
// Insert in hash table
|
||||
DevAssert(rc_subs_data->htable != NULL);
|
||||
uint64_t key = ric_req_id;
|
||||
// Check if the subscription already exists
|
||||
AssertFatal(hashtable_is_key_exists(rc_subs_data->htable, key) == HASH_TABLE_KEY_NOT_EXISTS, "RIC req ID %d already subscribed", ric_req_id);
|
||||
arr_ran_param_id_t* data = malloc(sizeof(*data));
|
||||
assert(data != NULL);
|
||||
*data = *arr_ran_param_id;
|
||||
hashtable_rc_t ret = hashtable_insert(rc_subs_data->htable, key, data);
|
||||
assert(ret == HASH_TABLE_OK && "Hash table not ok");
|
||||
|
||||
// Insert in RB trees
|
||||
// 1 RB tree = 1 ran_param_id => many ric_req_id(s)
|
||||
const size_t sz = arr_ran_param_id->len;
|
||||
rb_ric_req_id_t *node = calloc(1, sizeof(*node));
|
||||
assert(node != NULL);
|
||||
node->ric_req_id = ric_req_id;
|
||||
for (size_t i = 0; i < sz; i++) {
|
||||
RB_INSERT(ric_id_2_param_id_trees, &rc_subs_data->rb[arr_ran_param_id->ran_param_id[i]], node);
|
||||
}
|
||||
|
||||
// Insert (RIC request ID + Event Trigger Definition) in specific RAN Parameter ID sequence
|
||||
seq_arr_push_back(seq_arr, data, sizeof(*data));
|
||||
pthread_mutex_unlock(&rc_mutex);
|
||||
}
|
||||
|
||||
void remove_rc_subs_data(rc_subs_data_t* rc_subs_data, uint32_t ric_req_id)
|
||||
void remove_rc_subs_data(rc_subs_data_t *rc_subs_data, uint32_t ric_req_id)
|
||||
{
|
||||
pthread_mutex_lock(&rc_mutex);
|
||||
DevAssert(rc_subs_data->htable != NULL);
|
||||
|
||||
uint64_t key = ric_req_id;
|
||||
// Get the array of ran_param_id(s)
|
||||
void *data = NULL;
|
||||
hashtable_rc_t ret = hashtable_get(rc_subs_data->htable, key, &data);
|
||||
AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %d not found\n", ric_req_id);
|
||||
arr_ran_param_id_t arr_ran_param_id = *(arr_ran_param_id_t *)data;
|
||||
// Remove ric_req_id with its ran_param_id(s) from hash table
|
||||
ret = hashtable_remove(rc_subs_data->htable, key);
|
||||
|
||||
// Remove ric_req_id from each ran_param_id tree where subscribed
|
||||
rb_ric_req_id_t *node = calloc(1, sizeof(*node));
|
||||
assert(node != NULL);
|
||||
node->ric_req_id = ric_req_id;
|
||||
for (size_t i = 0; i < arr_ran_param_id.len; i++) {
|
||||
RB_REMOVE(ric_id_2_param_id_trees, &rc_subs_data->rb[arr_ran_param_id.ran_param_id[i]], node);
|
||||
}
|
||||
|
||||
/* find the sequence element that matches RIC request ID */
|
||||
elm_arr_t elm = find_if(&rc_subs_data->rs4_param202, (void *)&ric_req_id, eq_int);
|
||||
ran_param_data_t *data = elm.it;
|
||||
free_e2sm_rc_event_trigger(&data->ev_tr);
|
||||
seq_arr_erase(&rc_subs_data->rs4_param202, elm.it);
|
||||
pthread_mutex_unlock(&rc_mutex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user