Commit d7852ff4 authored by Sakthivel Velumani's avatar Sakthivel Velumani

SDAP entity manager changes

1. Use standard linked list macro in SDAP to manage entities.
2. Lock sdap list and each entity. Each entity contains two mutex each
   for tx_entity() and rx_entity(). This is necessary because both
   functions are called on different threads and locking them with a
   common mutex blocks execution long enough to cause dropped packets
   if there is simultaneous traffic in DL and UL. The locks in tx and rx
   functions prevent the functions being called after the entity has
   been deleted by another thread.
parent faca3a37
......@@ -79,6 +79,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "nfapi/oai_integration/vendor_ext.h"
#include "gnb_config.h"
#include "openair2/E1AP/e1ap_common.h"
#include "openair2/SDAP/nr_sdap/nr_sdap_entity.h"
#ifdef ENABLE_AERIAL
#include "nfapi/oai_integration/aerial/fapi_nvIPC.h"
#endif
......@@ -313,6 +314,7 @@ static int create_gNB_tasks(ngran_node_t node_type, configmodule_interface_t *cf
AssertFatal(RC.nb_nr_inst == 1, "multiple RRC instances are not supported\n");
RC.nrrrc = calloc(1, sizeof(*RC.nrrrc));
RC.nrrrc[0] = calloc(1,sizeof(gNB_RRC_INST));
sdap_init();
RCconfig_NRRRC(RC.nrrrc[0]);
}
......
......@@ -86,6 +86,7 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "nr_nas_msg_sim.h"
#include <openair1/PHY/MODULATION/nr_modulation.h>
#include "openair2/GNB_APP/gnb_paramdef.h"
#include "openair2/SDAP/nr_sdap/nr_sdap_entity.h"
extern const char *duplex_mode[];
THREAD_STRUCT thread_struct;
......@@ -514,6 +515,7 @@ int main(int argc, char **argv)
ue_id_g = (node_number == 0) ? 0 : node_number - 2;
AssertFatal(ue_id_g >= 0, "UE id is expected to be nonnegative.\n");
sdap_init();
if(node_number == 0)
init_pdcp(0);
else
......
......@@ -134,6 +134,7 @@ static void *ue_tun_read_thread(void *arg)
if (entity == NULL) {
break;
}
nr_sdap_lock(entity, SDAP_MUTEX_TX);
entity->tx_entity(entity,
&ctxt,
SRB_FLAG_NO,
......@@ -147,6 +148,8 @@ static void *ue_tun_read_thread(void *arg)
NULL,
entity->qfi,
dc);
stop_thread = entity->stop_thread;
nr_sdap_unlock(entity, SDAP_MUTEX_TX);
}
free(arg);
......@@ -196,6 +199,7 @@ bool sdap_data_req(protocol_ctxt_t *ctxt_p,
return false;
}
nr_sdap_lock(sdap_entity, SDAP_MUTEX_TX);
bool ret = sdap_entity->tx_entity(sdap_entity,
ctxt_p,
srb_flag,
......@@ -209,6 +213,7 @@ bool sdap_data_req(protocol_ctxt_t *ctxt_p,
destinationL2Id,
qfi,
rqi);
nr_sdap_unlock(sdap_entity, SDAP_MUTEX_TX);
return ret;
}
......@@ -233,6 +238,7 @@ void sdap_data_ind(rb_id_t pdcp_entity,
return;
}
nr_sdap_lock(sdap_entity, SDAP_MUTEX_RX);
sdap_entity->rx_entity(sdap_entity,
pdcp_entity,
is_gnb,
......@@ -241,4 +247,5 @@ void sdap_data_ind(rb_id_t pdcp_entity,
ue_id,
buf,
size);
nr_sdap_unlock(sdap_entity, SDAP_MUTEX_RX);
}
This diff is collapsed.
......@@ -118,10 +118,17 @@ typedef struct nr_sdap_entity_s {
char *buf,
int size);
/* List of entities */
struct nr_sdap_entity_s *next_entity;
/* SDAP TX and RX are handled by different threads. Common mutex would block one thread if the other is busy.
Protecting the tx_entity() and rx_entity() is required to prevent accessing the data after the SDAP entity
has been deleted by another thread. Hence, a separate mutex is used for tx and rx threads. */
pthread_mutex_t mutex[2]; // 0: tx mutex, 1: rx mutex
} nr_sdap_entity_t;
enum Sdap_Mutex_Type {
SDAP_MUTEX_TX,
SDAP_MUTEX_RX,
};
/* QFI to DRB Mapping Related Function */
void nr_sdap_qfi2drb_map_update(nr_sdap_entity_t *entity, uint8_t qfi, rb_id_t drb, bool has_sdap_rx, bool has_sdap_tx);
......@@ -187,7 +194,7 @@ void nr_sdap_release_drb(ue_id_t ue_id, int drb_id, int pdusession_id);
* @param[in] pdusession_id Unique identifier for the Packet Data Unit Session. ID Range [0, 256].
* @return True, if successfully deleted entity, false otherwise.
*/
bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id);
bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id, bool deleteIF);
/**
* @brief Function to delete all SDAP Entities based on the ue_id.
......@@ -217,6 +224,7 @@ bool is_sdap_tx(bool is_gnb, NR_SDAP_Config_t *sdap_config);
void nr_reconfigure_sdap_entity(NR_SDAP_Config_t *sdap_config, ue_id_t ue_id, int pdusession_id, int drb_id);
void set_qfi(uint8_t qfi, uint8_t pduid, ue_id_t ue_id);
bool nr_sdap_get_first_ue_id(ue_id_t *ret);
void remove_ue_ip_if(ue_id_t ue_id, int pdusession_id);
void nr_sdap_lock(nr_sdap_entity_t *ent, enum Sdap_Mutex_Type mutexType);
void nr_sdap_unlock(nr_sdap_entity_t *ent, enum Sdap_Mutex_Type mutexType);
void sdap_init(void);
#endif
......@@ -1310,7 +1310,7 @@ void *nas_nrue(void *args_p)
case NAS_PDU_SESSION_REL: {
// TODO: Initiate PDU session release request & send NAS signal to network
nas_pdu_session_req_t *pdu_rel = &NAS_PDU_SESSION_REL(msg_p);
remove_ue_ip_if(instance, pdu_rel->pdusession_id);
nr_sdap_delete_entity(instance, pdu_rel->pdusession_id, true);
break;
}
......
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