diff options
Diffstat (limited to 'openbsc/src/libbsc/chan_alloc.c')
-rw-r--r-- | openbsc/src/libbsc/chan_alloc.c | 61 |
1 files changed, 14 insertions, 47 deletions
diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c index 1efe2aac3..a8b15d177 100644 --- a/openbsc/src/libbsc/chan_alloc.c +++ b/openbsc/src/libbsc/chan_alloc.c @@ -345,8 +345,6 @@ void lchan_free(struct gsm_lchan *lchan) } lchan->sacch_deact = 0; - lchan->release_mode = RSL_REL_NORMAL; - /* FIXME: ts_free() the timeslot, if we're the last logical * channel using it */ } @@ -376,51 +374,22 @@ void lchan_reset(struct gsm_lchan *lchan) } } -/* release the next allocated SAPI or return 0 */ -static int _lchan_release_next_sapi(struct gsm_lchan *lchan) -{ - int sapi; - - for (sapi = 1; sapi < ARRAY_SIZE(lchan->sapis); ++sapi) { - uint8_t link_id; - if (lchan->sapis[sapi] == LCHAN_SAPI_UNUSED) - continue; - - link_id = sapi; - if (lchan->type == GSM_LCHAN_TCH_F || lchan->type == GSM_LCHAN_TCH_H) - link_id |= 0x40; - rsl_release_request(lchan, link_id, RSL_REL_LOCAL_END); - return 0; - } - - return 1; -} - /* Drive the release process of the lchan */ -static void _lchan_handle_release(struct gsm_lchan *lchan) +static void _lchan_handle_release(struct gsm_lchan *lchan, + int sach_deact, int mode) { - /* Ask for SAPI != 0 to be freed first and stop if we need to wait */ - if (_lchan_release_next_sapi(lchan) == 0) - return; - - if (lchan->sacch_deact) { + /* Release all SAPIs on the local end and continue */ + rsl_release_sapis_from(lchan, 1, RSL_REL_LOCAL_END); + + /* + * Shall we send a RR Release, start T3109 and wait for the + * release indication from the BTS or just take it down (e.g. + * on assignment requests) + */ + if (sach_deact) gsm48_send_rr_release(lchan); - return; - } - - rsl_release_request(lchan, 0, lchan->release_mode); - rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ); -} - -/* called from abis rsl */ -int rsl_lchan_rll_release(struct gsm_lchan *lchan, uint8_t link_id) -{ - if (lchan->state != LCHAN_S_REL_REQ) - return -1; - - if ((link_id & 0x7) != 0) - _lchan_handle_release(lchan); - return 0; + else + rsl_release_request(lchan, 0, mode); } /* Consider releasing the channel now */ @@ -430,9 +399,7 @@ int lchan_release(struct gsm_lchan *lchan, int sacch_deact, enum rsl_rel_mode mo rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ); lchan->conn = NULL; - lchan->release_mode = mode; - lchan->sacch_deact = sacch_deact; - _lchan_handle_release(lchan); + _lchan_handle_release(lchan, sacch_deact, mode); return 1; } |