Commit 33d0ac49 authored by Robert Schmidt's avatar Robert Schmidt

Simplify MAC FlexRAN agent interface

parent 608a1459
......@@ -40,9 +40,6 @@
#include "common/utils/LOG/log.h"
/*Flags showing if a mac agent has already been registered*/
unsigned int mac_agent_registered[NUM_MAX_ENB];
/*Array containing the Agent-MAC interfaces*/
AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB];
......@@ -1336,11 +1333,17 @@ void flexran_agent_send_sf_trigger(mid_t mod_id) {
int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) {
if (mac_agent_registered[mod_id]) {
int flexran_agent_register_mac_xface(mid_t mod_id)
{
if (agent_mac_xface[mod_id]) {
LOG_E(MAC, "MAC agent for eNB %d is already registered\n", mod_id);
return -1;
}
AGENT_MAC_xface *xface = malloc(sizeof(AGENT_MAC_xface));
if (!xface) {
LOG_E(FLEXRAN_AGENT, "could not allocate memory for MAC agent xface %d\n", mod_id);
return -1;
}
//xface->agent_ctxt = &shared_ctxt[mod_id];
xface->flexran_agent_send_sr_info = flexran_agent_send_sr_info;
......@@ -1350,14 +1353,18 @@ int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) {
xface->dl_scheduler_loaded_lib = NULL;
xface->ul_scheduler_loaded_lib = NULL;
mac_agent_registered[mod_id] = 1;
agent_mac_xface[mod_id] = xface;
return 0;
}
int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) {
int flexran_agent_unregister_mac_xface(mid_t mod_id)
{
if (!agent_mac_xface[mod_id]) {
LOG_E(FLEXRAN_AGENT, "MAC agent CM for eNB %d is not registered\n", mod_id);
return -1;
}
AGENT_MAC_xface *xface = agent_mac_xface[mod_id];
//xface->agent_ctxt = NULL;
xface->flexran_agent_send_sr_info = NULL;
xface->flexran_agent_send_sf_trigger = NULL;
......@@ -1366,14 +1373,13 @@ int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface) {
xface->dl_scheduler_loaded_lib = NULL;
xface->ul_scheduler_loaded_lib = NULL;
mac_agent_registered[mod_id] = 0;
free(xface);
agent_mac_xface[mod_id] = NULL;
return 0;
}
AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id)
{
return agent_mac_xface[mod_id];
}
......@@ -36,6 +36,8 @@
#include "flexran_agent_common.h"
#include "flexran_agent_extern.h"
// for flexran_agent_get_mac_xface()
#include "flexran_agent_extern.h"
/* Initialization function for the agent structures etc */
......@@ -82,9 +84,9 @@ void flexran_agent_send_update_mac_stats(mid_t mod_id);
void flexran_agent_get_pending_dl_mac_config(mid_t mod_id, Protocol__FlexranMessage **msg);
/*Register technology specific interface callbacks*/
int flexran_agent_register_mac_xface(mid_t mod_id, AGENT_MAC_xface *xface);
int flexran_agent_register_mac_xface(mid_t mod_id);
/*Unregister technology specific callbacks*/
int flexran_agent_unregister_mac_xface(mid_t mod_id, AGENT_MAC_xface*xface);
int flexran_agent_unregister_mac_xface(mid_t mod_id);
#endif
......@@ -781,9 +781,9 @@ int parse_dl_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser) {
goto error;
}
// Check what key needs to be set
if (mac_agent_registered[mod_id]) {
if (flexran_agent_get_mac_xface(mod_id)) {
LOG_D(ENB_APP, "Setting parameter %s\n", event.data.scalar.value);
param = dlsym(agent_mac_xface[mod_id]->dl_scheduler_loaded_lib,
param = dlsym(flexran_agent_get_mac_xface(mod_id)->dl_scheduler_loaded_lib,
(char *) event.data.scalar.value);
if (param == NULL) {
goto error;
......@@ -836,9 +836,9 @@ int parse_ul_scheduler_parameters(mid_t mod_id, yaml_parser_t *parser) {
goto error;
}
// Check what key needs to be set
if (mac_agent_registered[mod_id]) {
if (flexran_agent_get_mac_xface(mod_id)) {
LOG_D(ENB_APP, "Setting parameter %s\n", event.data.scalar.value);
param = dlsym(agent_mac_xface[mod_id]->ul_scheduler_loaded_lib,
param = dlsym(flexran_agent_get_mac_xface(mod_id)->ul_scheduler_loaded_lib,
(char *) event.data.scalar.value);
if (param == NULL) {
goto error;
......@@ -882,11 +882,11 @@ int load_dl_scheduler_function(mid_t mod_id, const char *function_name) {
LOG_I(FLEXRAN_AGENT, "Loading function: %s\n", function_name);
void *loaded_scheduler = dlsym(lib, function_name);
if (loaded_scheduler) {
if (mac_agent_registered[mod_id]) {
if (agent_mac_xface[mod_id]->dl_scheduler_loaded_lib != NULL) {
dlclose(agent_mac_xface[mod_id]->dl_scheduler_loaded_lib);
if (flexran_agent_get_mac_xface(mod_id)) {
if (flexran_agent_get_mac_xface(mod_id)->dl_scheduler_loaded_lib != NULL) {
dlclose(flexran_agent_get_mac_xface(mod_id)->dl_scheduler_loaded_lib);
}
agent_mac_xface[mod_id]->dl_scheduler_loaded_lib = lib;
flexran_agent_get_mac_xface(mod_id)->dl_scheduler_loaded_lib = lib;
LOG_I(FLEXRAN_AGENT, "New DL UE scheduler: %s\n", function_name);
}
} else {
......
......@@ -230,14 +230,11 @@ int flexran_agent_start(mid_t mod_id)
new_thread(receive_thread, flexran);
/*Initialize and register the mac xface. Must be modified later
*for more flexibility in agent management */
/* Register and initialize the control modules */
flexran_agent_register_mac_xface(mod_id);
flexran_agent_init_mac_agent(mod_id);
AGENT_MAC_xface *mac_agent_xface = (AGENT_MAC_xface *) malloc(sizeof(AGENT_MAC_xface));
flexran_agent_register_mac_xface(mod_id, mac_agent_xface);
AGENT_RRC_xface *rrc_agent_xface = (AGENT_RRC_xface *) malloc(sizeof(AGENT_RRC_xface));
flexran_agent_register_rrc_xface(mod_id, rrc_agent_xface);
flexran_agent_register_rrc_xface(mod_id);
AGENT_PDCP_xface *pdcp_agent_xface = (AGENT_PDCP_xface *) malloc(sizeof(AGENT_PDCP_xface));
flexran_agent_register_pdcp_xface(mod_id, pdcp_agent_xface);
......@@ -248,11 +245,6 @@ int flexran_agent_start(mid_t mod_id)
flexran_agent_init_timer();
/*
* Initialize the mac agent
*/
flexran_agent_init_mac_agent(mod_id);
/*
* start the enb agent task for tx and interaction with the underlying network function
*/
......
......@@ -209,7 +209,7 @@ int parse_enb_id(mid_t mod_id, yaml_parser_t *parser) {
}
// Check what key needs to be set
// use eNB egistered
if (mac_agent_registered[mod_id]) {
if (flexran_agent_get_mac_xface(mod_id)) {
LOG_I(ENB_APP, "Setting parameter for eNB %s\n", event.data.scalar.value);
if (strcmp((char *) event.data.scalar.tag, YAML_INT_TAG) == 0) { // if int
if ((strtol((char *) event.data.scalar.value, &endptr, 10))== mod_id ) { // enb_id == mod_id: right enb instance to be configured
......
......@@ -36,10 +36,7 @@
#include "flexran_agent_pdcp_defs.h"
/* Control module interface for the communication of the MAC Control Module with the agent */
extern AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB];
/* Flag indicating whether the VSFs for the MAC control module have been registered */
extern unsigned int mac_agent_registered[NUM_MAX_ENB];
AGENT_MAC_xface *flexran_agent_get_mac_xface(mid_t mod_id);
/* Control module interface for the communication of the RRC Control Module with the agent */
extern AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB];
......
......@@ -769,6 +769,5 @@ err_code_t flexran_agent_destroy_cont_stats_update(mid_t mod_id) {
flexran_agent_destroy_flexran_message(stats_context[mod_id].prev_stats_reply);
free(stats_context[mod_id].mutex);
// mac_agent_registered[mod_id] = 0;
return 1;
}
......@@ -7022,8 +7022,7 @@ if (ue_context_p->ue_context.nb_of_modify_e_rabs > 0) {
ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.rrc_TransactionIdentifier,
&ul_dcch_msg->message.choice.c1.choice.rrcConnectionReestablishmentComplete.criticalExtensions.choice.rrcConnectionReestablishmentComplete_r8);
//WARNING:Inform the controller about the UE activation. Should be moved to RRC agent in the future
if (mac_agent_registered[ctxt_pP->module_id]) {
if (rrc_agent_registered[ctxt_pP->module_id]) {
agent_rrc_xface[ctxt_pP->eNB_index]->flexran_agent_notify_ue_state_change(ctxt_pP->module_id,
ue_context_p->ue_id_rnti,
PROTOCOL__FLEX_UE_STATE_CHANGE_TYPE__FLUESC_ACTIVATED);
......
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