Skip to content

Commit

Permalink
Use s1ap_state get enb/ue funcs and remove s1ap_mme versions
Browse files Browse the repository at this point in the history
Summary:
As part of our goal to make MME stateless (can crash/update and come back up without losing enb/ue context), we are making the S1AP task stateless as a POC. To make a C program "stateless", we are going off the idea that only the database state needs to be good at all times -- therefore we let the message/state processing happen as normal except that the state is moved from separate globals into one global state that is committed to the db at the end of processing each message.

In this diff, we change s1ap task to use the s1ap_state getter methods introduced in the previous diff. We also remove the old methods provided by s1ap_mme.c that did the same thing.

Reviewed By: ssanadhya

Differential Revision: D14685282

fbshipit-source-id: a34ee5da7bb9a4fd35c904a6081afcac48452534
  • Loading branch information
sciencemanx authored and facebook-github-bot committed Apr 3, 2019
1 parent d68fac6 commit b56fd50
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 191 deletions.
129 changes: 8 additions & 121 deletions lte/gateway/c/oai/tasks/s1ap/s1ap_mme.c
Expand Up @@ -255,7 +255,8 @@ void *s1ap_mme_thread(__attribute__((unused)) void *args)
if (timer_arg.timer_class == S1AP_UE_TIMER) {
mme_ue_s1ap_id_t mme_ue_s1ap_id = timer_arg.instance_id;
if (
(ue_ref_p = s1ap_is_ue_mme_id_in_list(mme_ue_s1ap_id)) == NULL) {
(ue_ref_p =
s1ap_state_get_ue_mmeid(s1ap_state, mme_ue_s1ap_id)) == NULL) {
OAILOG_WARNING(
LOG_S1AP,
"Timer expired but no assoicated UE context for UE id %d\n",
Expand All @@ -278,7 +279,8 @@ void *s1ap_mme_thread(__attribute__((unused)) void *args)
}
} else if (timer_arg.timer_class == S1AP_ENB_TIMER) {
sctp_assoc_id_t assoc_id = timer_arg.instance_id;
if ((enb_ref_p = s1ap_is_enb_assoc_id_in_list(assoc_id)) == NULL) {
if (
(enb_ref_p = s1ap_state_get_enb(s1ap_state, assoc_id)) == NULL) {
OAILOG_WARNING(
LOG_S1AP,
"Timer expired but no assoicated eNB context for eNB assoc_id "
Expand Down Expand Up @@ -460,6 +462,7 @@ bool s1ap_dump_ue_hash_cb(
s1ap_dump_ue(ue_ref);
return false;
}

//------------------------------------------------------------------------------
void s1ap_dump_ue(const ue_description_t *const ue_ref)
{
Expand All @@ -474,44 +477,6 @@ void s1ap_dump_ue(const ue_description_t *const ue_ref)
#endif
}

//------------------------------------------------------------------------------
bool s1ap_enb_compare_by_enb_id_cb(
__attribute__((unused)) const hash_key_t keyP,
void *const elementP,
void *parameterP,
void **resultP)
{
const uint32_t *const enb_id_p = (const uint32_t *const) parameterP;
enb_description_t *enb_ref = (enb_description_t *) elementP;
if (*enb_id_p == enb_ref->enb_id) {
*resultP = elementP;
return true;
}
return false;
}
//------------------------------------------------------------------------------
enb_description_t *s1ap_is_enb_id_in_list(const uint32_t enb_id)
{
enb_description_t *enb_ref = NULL;
uint32_t *enb_id_p = (uint32_t *) &enb_id;
hashtable_ts_apply_callback_on_elements(
(hash_table_ts_t *const) & s1ap_state->enbs,
s1ap_enb_compare_by_enb_id_cb,
(void *) enb_id_p,
(void **) &enb_ref);
return enb_ref;
}

//------------------------------------------------------------------------------
enb_description_t *s1ap_is_enb_assoc_id_in_list(
const sctp_assoc_id_t sctp_assoc_id)
{
enb_description_t *enb_ref = NULL;
hashtable_ts_get(
&s1ap_state->enbs, (const hash_key_t) sctp_assoc_id, (void **) &enb_ref);
return enb_ref;
}

//------------------------------------------------------------------------------
// TODO: (amar) unused function check with OAI.
bool s1ap_ue_compare_by_enb_ue_s1ap_id_cb(
Expand All @@ -528,18 +493,6 @@ bool s1ap_ue_compare_by_enb_ue_s1ap_id_cb(
}
return false;
}
//------------------------------------------------------------------------------
ue_description_t *s1ap_is_ue_enb_id_in_list(
enb_description_t *enb_ref,
const enb_ue_s1ap_id_t enb_ue_s1ap_id)
{
ue_description_t *ue_ref = NULL;
hashtable_ts_get(
(hash_table_ts_t *const) & enb_ref->ue_coll,
(const hash_key_t) enb_ue_s1ap_id,
(void **) &ue_ref);
return ue_ref;
}

//------------------------------------------------------------------------------
bool s1ap_ue_compare_by_mme_ue_id_cb(
Expand Down Expand Up @@ -586,83 +539,17 @@ bool s1ap_enb_find_ue_by_mme_ue_id_cb(
}
return false;
}
//------------------------------------------------------------------------------
bool s1ap_ue_compare_by_s11_sgw_teid_cb(
__attribute__((unused)) const hash_key_t keyP,
void *const elementP,
void *parameterP,
void **resultP)
{
s11_teid_t *s11_sgw_teid_p = (s11_teid_t *) parameterP;
ue_description_t *ue_ref = (ue_description_t *) elementP;
if (*s11_sgw_teid_p == ue_ref->s11_sgw_teid) {
*resultP = elementP;
return true;
}
return false;
}

//------------------------------------------------------------------------------
bool s1ap_enb_find_ue_by_s11_sgw_teid_cb(
__attribute((unused)) const hash_key_t keyP,
void *const elementP,
void *parameterP,
void **resultP)
{
enb_description_t *enb_ref = (enb_description_t *) elementP;

hashtable_ts_apply_callback_on_elements(
(hash_table_ts_t *const) & enb_ref->ue_coll,
s1ap_ue_compare_by_s11_sgw_teid_cb,
parameterP,
resultP);
if (*resultP) {
return true;
}
return false;
}

//------------------------------------------------------------------------------
ue_description_t *s1ap_is_ue_mme_id_in_list(
const mme_ue_s1ap_id_t mme_ue_s1ap_id)
{
ue_description_t *ue_ref = NULL;
mme_ue_s1ap_id_t *mme_ue_s1ap_id_p = (mme_ue_s1ap_id_t *) &mme_ue_s1ap_id;

hashtable_ts_apply_callback_on_elements(
&s1ap_state->enbs,
s1ap_enb_find_ue_by_mme_ue_id_cb,
(void *) mme_ue_s1ap_id_p,
(void **) &ue_ref);
OAILOG_TRACE(LOG_S1AP, "Return ue_ref %p \n", ue_ref);
return ue_ref;
}

//------------------------------------------------------------------------------
// TODO(amar) unused function check with OAI.
ue_description_t *s1ap_is_s11_sgw_teid_in_list(const s11_teid_t teid)
{
ue_description_t *ue_ref = NULL;
s11_teid_t *teid_id_p = (s11_teid_t *) &teid;

hashtable_ts_apply_callback_on_elements(
&s1ap_state->enbs,
s1ap_enb_find_ue_by_s11_sgw_teid_cb,
(void *) teid_id_p,
(void **) &ue_ref);
return ue_ref;
}

//------------------------------------------------------------------------------
void s1ap_notified_new_ue_mme_s1ap_id_association(
const sctp_assoc_id_t sctp_assoc_id,
const enb_ue_s1ap_id_t enb_ue_s1ap_id,
const mme_ue_s1ap_id_t mme_ue_s1ap_id)
{
enb_description_t *enb_ref = s1ap_is_enb_assoc_id_in_list(sctp_assoc_id);
enb_description_t *enb_ref = s1ap_state_get_enb(s1ap_state, sctp_assoc_id);
if (enb_ref) {
ue_description_t *ue_ref =
s1ap_is_ue_enb_id_in_list(enb_ref, enb_ue_s1ap_id);
s1ap_state_get_ue_enbid(s1ap_state, enb_ref, enb_ue_s1ap_id);
if (ue_ref) {
ue_ref->mme_ue_s1ap_id = mme_ue_s1ap_id;
hashtable_rc_t h_rc = hashtable_ts_insert(
Expand Down Expand Up @@ -721,7 +608,7 @@ ue_description_t *s1ap_new_ue(
enb_description_t *enb_ref = NULL;
ue_description_t *ue_ref = NULL;

enb_ref = s1ap_is_enb_assoc_id_in_list(sctp_assoc_id);
enb_ref = s1ap_state_get_enb(s1ap_state, sctp_assoc_id);
DevAssert(enb_ref != NULL);
ue_ref = calloc(1, sizeof(ue_description_t));
/*
Expand Down
34 changes: 6 additions & 28 deletions lte/gateway/c/oai/tasks/s1ap/s1ap_mme.h
Expand Up @@ -154,34 +154,6 @@ int s1ap_mme_init(void);
**/
void s1ap_mme_exit(void);

/** \brief Look for given eNB id in the list
* \param enb_id The unique eNB id to search in list
* @returns NULL if no eNB matchs the eNB id, or reference to the eNB element in list if matches
**/
enb_description_t *s1ap_is_enb_id_in_list(const uint32_t enb_id);

/** \brief Look for given eNB SCTP assoc id in the list
* \param enb_id The unique sctp assoc id to search in list
* @returns NULL if no eNB matchs the sctp assoc id, or reference to the eNB element in list if matches
**/
enb_description_t *s1ap_is_enb_assoc_id_in_list(
const sctp_assoc_id_t sctp_assoc_id);

/** \brief Look for given ue eNB id in the list
* \param enb_id The unique ue_eNB id to search in list
* @returns NULL if no UE matchs the ue_enb_id, or reference to the ue element in list if matches
**/
ue_description_t *s1ap_is_ue_enb_id_in_list(
enb_description_t *enb_ref,
const enb_ue_s1ap_id_t enb_ue_s1ap_id);

/** \brief Look for given ue mme id in the list
* \param enb_id The unique ue_mme_id to search in list
* @returns NULL if no UE matchs the ue_mme_id, or reference to the ue element in list if matches
**/
ue_description_t *s1ap_is_ue_mme_id_in_list(const mme_ue_s1ap_id_t ue_mme_id);
ue_description_t *s1ap_is_s11_sgw_teid_in_list(const s11_teid_t teid);

/** \brief associate mainly 2(3) identifiers in S1AP layer: {mme_ue_s1ap_id_t, sctp_assoc_id (,enb_ue_s1ap_id)}
**/
void s1ap_notified_new_ue_mme_s1ap_id_association(
Expand Down Expand Up @@ -245,6 +217,12 @@ bool s1ap_enb_compare_by_enb_id_cb(
void *parameterP,
void __attribute__((unused)) * *unused_resultP);

bool s1ap_enb_find_ue_by_mme_ue_id_cb(
__attribute__((unused)) const hash_key_t keyP,
void *const elementP,
void *parameterP,
void **resultP);

/** \brief Remove target UE from the list
* \param ue_ref UE structure reference to remove
**/
Expand Down

0 comments on commit b56fd50

Please sign in to comment.