lchan_fsm: introduce lchan.activate.ch_mode_rate to allow tweaking

lchan->activate.info.ch_mode_rate should remain unchanged, it is the
immutable request data. However, for VAMOS, we will want to
automatically see that the chan_mode is chosen correctly.

As a first step, place a mutable ch_mode_rate copy at
lchan->activate.ch_mode_rate, i.e. not in .activate.info, but in
.activate. Use that everywhere.

This is mostly a non-functional change, preparing for a subsequent patch
that adds handling of VAMOS shadow lchans.

As side effect of adding lchan_activate_set_ch_mode_rate_and_mr_config()
after MODE_MODIF_ACK (enabling the voice stream after a channel mode
modify), fix AMR config: the call to lchan_mr_config() was missing.

Change-Id: Icc9cc7481b3984fdca34eef49ea91ad3388c06fe
This commit is contained in:
Neels Hofmeyr 2021-05-28 17:03:08 +00:00
parent 441cbead0e
commit 19d797c2fb
5 changed files with 20 additions and 13 deletions

View File

@ -645,6 +645,7 @@ struct gsm_lchan {
struct { struct {
struct lchan_activate_info info; struct lchan_activate_info info;
struct channel_mode_and_rate ch_mode_rate;
struct gsm48_multi_rate_conf mr_conf_filtered; struct gsm48_multi_rate_conf mr_conf_filtered;
bool activ_ack; /*< true as soon as RSL Chan Activ Ack is received */ bool activ_ack; /*< true as soon as RSL Chan Activ Ack is received */
bool immediate_assignment_sent; bool immediate_assignment_sent;

View File

@ -534,7 +534,7 @@ int rsl_tx_chan_activ(struct gsm_lchan *lchan, uint8_t act_type, uint8_t ho_ref)
/* PDCH activation is a job for rsl_tx_dyn_ts_pdch_act_deact(); */ /* PDCH activation is a job for rsl_tx_dyn_ts_pdch_act_deact(); */
OSMO_ASSERT(act_type != RSL_ACT_OSMO_PDCH); OSMO_ASSERT(act_type != RSL_ACT_OSMO_PDCH);
rc = channel_mode_from_lchan(&cm, lchan, &lchan->activate.info.ch_mode_rate, false); rc = channel_mode_from_lchan(&cm, lchan, &lchan->activate.ch_mode_rate, false);
if (rc < 0) { if (rc < 0) {
LOGP(DRSL, LOGL_ERROR, LOGP(DRSL, LOGL_ERROR,
"%s Cannot find channel mode from lchan type\n", "%s Cannot find channel mode from lchan type\n",
@ -608,7 +608,7 @@ int rsl_tx_chan_activ(struct gsm_lchan *lchan, uint8_t act_type, uint8_t ho_ref)
add_power_control_params(msg, RSL_IE_BS_POWER_PARAM, lchan); add_power_control_params(msg, RSL_IE_BS_POWER_PARAM, lchan);
add_power_control_params(msg, RSL_IE_MS_POWER_PARAM, lchan); add_power_control_params(msg, RSL_IE_MS_POWER_PARAM, lchan);
if (gsm48_chan_mode_to_non_vamos(lchan->activate.info.ch_mode_rate.chan_mode) == GSM48_CMODE_SPEECH_AMR) { if (gsm48_chan_mode_to_non_vamos(lchan->activate.ch_mode_rate.chan_mode) == GSM48_CMODE_SPEECH_AMR) {
rc = put_mr_config_for_bts(msg, &lchan->activate.mr_conf_filtered, rc = put_mr_config_for_bts(msg, &lchan->activate.mr_conf_filtered,
(lchan->type == GSM_LCHAN_TCH_F) ? &bts->mr_full : &bts->mr_half); (lchan->type == GSM_LCHAN_TCH_F) ? &bts->mr_full : &bts->mr_half);
if (rc) { if (rc) {

View File

@ -210,7 +210,7 @@ static void send_assignment_complete(struct gsm_subscriber_connection *conn)
if (gscon_is_aoip(conn)) { if (gscon_is_aoip(conn)) {
/* Extrapolate speech codec from speech mode */ /* Extrapolate speech codec from speech mode */
gsm0808_speech_codec_from_chan_type(&sc, perm_spch); gsm0808_speech_codec_from_chan_type(&sc, perm_spch);
sc.cfg = conn->lchan->activate.info.ch_mode_rate.s15_s0; sc.cfg = conn->lchan->activate.ch_mode_rate.s15_s0;
sc_ptr = &sc; sc_ptr = &sc;
} }
} }

View File

@ -639,8 +639,11 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p
lchan->bs_power_db = bts->bs_power_ctrl.bs_power_val_db; lchan->bs_power_db = bts->bs_power_ctrl.bs_power_val_db;
} }
if (gsm48_chan_mode_to_non_vamos(info->ch_mode_rate.chan_mode) == GSM48_CMODE_SPEECH_AMR) { lchan->activate.ch_mode_rate = lchan->activate.info.ch_mode_rate;
if (lchan_mr_config(&lchan->activate.mr_conf_filtered, lchan, info->ch_mode_rate.s15_s0) < 0) { /* future: automatically adjust chan_mode in lchan->activate.ch_mode_rate */
if (gsm48_chan_mode_to_non_vamos(lchan->activate.ch_mode_rate.chan_mode) == GSM48_CMODE_SPEECH_AMR) {
if (lchan_mr_config(&lchan->activate.mr_conf_filtered, lchan, lchan->activate.ch_mode_rate.s15_s0) < 0) {
lchan_fail("Can not generate multirate configuration IE\n"); lchan_fail("Can not generate multirate configuration IE\n");
return; return;
} }
@ -656,7 +659,7 @@ static void lchan_fsm_wait_ts_ready_onenter(struct osmo_fsm_inst *fi, uint32_t p
(use_mgwep_ci ? osmo_mgcpc_ep_ci_name(use_mgwep_ci) : "new") (use_mgwep_ci ? osmo_mgcpc_ep_ci_name(use_mgwep_ci) : "new")
: "none", : "none",
gsm_lchant_name(lchan->type), gsm_lchant_name(lchan->type),
gsm48_chan_mode_name(lchan->activate.info.ch_mode_rate.chan_mode), gsm48_chan_mode_name(lchan->activate.ch_mode_rate.chan_mode),
(lchan->activate.info.encr.alg_id ? : 1)-1, (lchan->activate.info.encr.alg_id ? : 1)-1,
lchan->activate.info.encr.key_len ? osmo_hexdump_nospc(lchan->activate.info.encr.key, lchan->activate.info.encr.key_len ? osmo_hexdump_nospc(lchan->activate.info.encr.key,
lchan->activate.info.encr.key_len) : "none"); lchan->activate.info.encr.key_len) : "none");
@ -806,7 +809,7 @@ static void lchan_fsm_post_activ_ack(struct osmo_fsm_inst *fi)
int rc; int rc;
struct gsm_lchan *lchan = lchan_fi_lchan(fi); struct gsm_lchan *lchan = lchan_fi_lchan(fi);
lchan->current_ch_mode_rate = lchan->activate.info.ch_mode_rate; lchan->current_ch_mode_rate = lchan->activate.ch_mode_rate;
lchan->current_mr_conf = lchan->activate.mr_conf_filtered; lchan->current_mr_conf = lchan->activate.mr_conf_filtered;
lchan->tsc_set = lchan->activate.tsc_set; lchan->tsc_set = lchan->activate.tsc_set;
lchan->tsc = lchan->activate.tsc; lchan->tsc = lchan->activate.tsc;
@ -999,6 +1002,9 @@ static void lchan_fsm_wait_rsl_chan_mode_modify_ack(struct osmo_fsm_inst *fi, ui
.tsc_set = -1, .tsc_set = -1,
.tsc = -1, .tsc = -1,
}; };
lchan->activate.ch_mode_rate = lchan->activate.info.ch_mode_rate;
/* future: automatically adjust chan_mode in lchan->activate.ch_mode_rate */
lchan->activate.concluded = false; lchan->activate.concluded = false;
lchan_fsm_state_chg(LCHAN_ST_WAIT_RLL_RTP_ESTABLISH); lchan_fsm_state_chg(LCHAN_ST_WAIT_RLL_RTP_ESTABLISH);
} else { } else {

View File

@ -268,19 +268,19 @@ static void lchan_rtp_fsm_wait_ipacc_crcx_ack_onenter(struct osmo_fsm_inst *fi,
return; return;
} }
val = ipacc_speech_mode(lchan->activate.info.ch_mode_rate.chan_mode, lchan->type); val = ipacc_speech_mode(lchan->activate.ch_mode_rate.chan_mode, lchan->type);
if (val < 0) { if (val < 0) {
lchan_rtp_fail("Cannot determine Abis/IP speech mode for tch_mode=%s type=%s\n", lchan_rtp_fail("Cannot determine Abis/IP speech mode for tch_mode=%s type=%s\n",
get_value_string(gsm48_chan_mode_names, lchan->activate.info.ch_mode_rate.chan_mode), get_value_string(gsm48_chan_mode_names, lchan->activate.ch_mode_rate.chan_mode),
gsm_lchant_name(lchan->type)); gsm_lchant_name(lchan->type));
return; return;
} }
lchan->abis_ip.speech_mode = val; lchan->abis_ip.speech_mode = val;
val = ipacc_payload_type(lchan->activate.info.ch_mode_rate.chan_mode, lchan->type); val = ipacc_payload_type(lchan->activate.ch_mode_rate.chan_mode, lchan->type);
if (val < 0) { if (val < 0) {
lchan_rtp_fail("Cannot determine Abis/IP payload type for tch_mode=%s type=%s\n", lchan_rtp_fail("Cannot determine Abis/IP payload type for tch_mode=%s type=%s\n",
get_value_string(gsm48_chan_mode_names, lchan->activate.info.ch_mode_rate.chan_mode), get_value_string(gsm48_chan_mode_names, lchan->activate.ch_mode_rate.chan_mode),
gsm_lchant_name(lchan->type)); gsm_lchant_name(lchan->type));
return; return;
} }
@ -834,14 +834,14 @@ static int chan_mode_to_mgcp_bss_pt(enum mgcp_codecs codec)
void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side) void mgcp_pick_codec(struct mgcp_conn_peer *verb_info, const struct gsm_lchan *lchan, bool bss_side)
{ {
enum mgcp_codecs codec = chan_mode_to_mgcp_codec(lchan->activate.info.ch_mode_rate.chan_mode, enum mgcp_codecs codec = chan_mode_to_mgcp_codec(lchan->activate.ch_mode_rate.chan_mode,
lchan->type == GSM_LCHAN_TCH_H? false : true); lchan->type == GSM_LCHAN_TCH_H? false : true);
int custom_pt; int custom_pt;
if (codec < 0) { if (codec < 0) {
LOG_LCHAN(lchan, LOGL_ERROR, LOG_LCHAN(lchan, LOGL_ERROR,
"Unable to determine MGCP codec type for %s in chan-mode %s\n", "Unable to determine MGCP codec type for %s in chan-mode %s\n",
gsm_lchant_name(lchan->type), gsm48_chan_mode_name(lchan->activate.info.ch_mode_rate.chan_mode)); gsm_lchant_name(lchan->type), gsm48_chan_mode_name(lchan->activate.ch_mode_rate.chan_mode));
verb_info->codecs_len = 0; verb_info->codecs_len = 0;
return; return;
} }