update the lchan name to always reflect VAMOS shadowness

Change gsm_lchan_name_compute() to a function that in-place updates the
lchan->name. That allows calling it numerous times with the talloc
handled internally. Rename it to lchan_update_name().

Add 'shadow' to lchan_update_name() and lchan_fsm_update_id() for VAMOS
shadow lchans, and also print the lchan index that it is a shadow for,
instead of the index in the lchan array.

When set_pchan_is() updates the VAMOSness of the lchans, call
lchan_fsm_update_id(). From lchan_fsm_update_id() also call
lchan_update_name().

This is a bit convoluted for legacy reasons. There are utility programs
and C tests using bts_trx.c but not lchan_fsm.c. lchan_update_name()
lives in gsm_data.c for that reason. This patch calls
lchan_update_name() from lchan_fsm_update_id() and not vice versa to
avoid having to add stubbed lchan_fsm_update_id() functions to all
utility programs and C tests.

We can't easily unify the lchan->name and lchan->fi->id without lots of
refactoring rippling through all those little utility programs and C
tests.

Change-Id: I7c2bae3b895a91f1b99b4147ecc0e3009cb7439a
This commit is contained in:
Neels Hofmeyr 2021-05-29 23:08:22 +00:00
parent d163aa3805
commit 426941e87f
7 changed files with 25 additions and 12 deletions

View File

@ -1008,7 +1008,7 @@ const char *gsm_lchant_name(enum gsm_chan_t c);
const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
char *gsm_lchan_name_compute(void *ctx, const struct gsm_lchan *lchan);
void lchan_update_name(struct gsm_lchan *lchan);
static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
{

View File

@ -83,3 +83,4 @@ bool lchan_may_receive_data(struct gsm_lchan *lchan);
void lchan_forget_conn(struct gsm_lchan *lchan);
void lchan_fsm_skip_error(struct gsm_lchan *lchan);
void lchan_fsm_update_id(struct gsm_lchan *lchan);

View File

@ -302,14 +302,15 @@ static void assignment_fsm_update_id(struct gsm_subscriber_connection *conn)
return;
}
osmo_fsm_inst_update_id_f(conn->assignment.fi, "%s_%u-%u-%u-%s%s%s-%u",
osmo_fsm_inst_update_id_f(conn->assignment.fi, "%s_%u-%u-%u-%s%s%s-%s%u",
conn->fi->id,
new_lchan->ts->trx->bts->nr, new_lchan->ts->trx->nr, new_lchan->ts->nr,
gsm_pchan_id(new_lchan->ts->pchan_on_init),
(new_lchan->ts->pchan_on_init == new_lchan->ts->pchan_is)? "" : "as",
(new_lchan->ts->pchan_on_init == new_lchan->ts->pchan_is)? ""
: gsm_pchan_id(new_lchan->ts->pchan_is),
new_lchan->nr);
new_lchan->vamos.is_secondary ? "shadow" : "",
new_lchan->nr - (new_lchan->vamos.is_secondary ? new_lchan->ts->max_primary_lchans : 0));
}
static bool lchan_type_compat_with_mode(enum gsm_chan_t type, const struct channel_mode_and_rate *ch_mode_rate)

View File

@ -111,7 +111,7 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
lchan->nr = l;
lchan->type = GSM_LCHAN_NONE;
lchan->name = gsm_lchan_name_compute(trx, lchan);
lchan_update_name(lchan);
}
}

View File

@ -334,12 +334,15 @@ char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts)
return ts2str;
}
char *gsm_lchan_name_compute(void *ctx, const struct gsm_lchan *lchan)
void lchan_update_name(struct gsm_lchan *lchan)
{
struct gsm_bts_trx_ts *ts = lchan->ts;
return talloc_asprintf(ctx, "(bts=%d,trx=%d,ts=%d,ss=%d%s)",
ts->trx->bts->nr, ts->trx->nr, ts->nr, lchan->nr,
lchan->vamos.is_secondary ? "-VAMOS" : "");
if (lchan->name)
talloc_free(lchan->name);
lchan->name = talloc_asprintf(ts->trx, "(bts=%d,trx=%d,ts=%d,ss=%s%d)",
ts->trx->bts->nr, ts->trx->nr, ts->nr,
lchan->vamos.is_secondary ? "shadow" : "",
lchan->nr - (lchan->vamos.is_secondary ? ts->max_primary_lchans : 0));
}
/* obtain the MO structure for a given object instance */

View File

@ -411,11 +411,16 @@ void lchan_mode_modify(struct gsm_lchan *lchan, struct lchan_modify_info *info)
}
}
static void lchan_fsm_update_id(struct gsm_lchan *lchan)
void lchan_fsm_update_id(struct gsm_lchan *lchan)
{
osmo_fsm_inst_update_id_f(lchan->fi, "%u-%u-%u-%s-%u",
lchan_update_name(lchan);
if (!lchan->fi)
return;
osmo_fsm_inst_update_id_f(lchan->fi, "%u-%u-%u-%s-%s%u",
lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
gsm_pchan_id(lchan->ts->pchan_on_init), lchan->nr);
gsm_pchan_id(lchan->ts->pchan_on_init),
lchan->vamos.is_secondary ? "shadow" : "",
lchan->nr - (lchan->vamos.is_secondary ? lchan->ts->max_primary_lchans : 0));
if (lchan->fi_rtp)
osmo_fsm_inst_update_id_f(lchan->fi_rtp, lchan->fi->id);
}

View File

@ -204,11 +204,14 @@ void ts_set_pchan_is(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config pchan_
lchan->vamos.is_secondary = false;
else
lchan->vamos.is_secondary = true;
lchan_fsm_update_id(lchan);
}
break;
default:
ts_for_n_lchans(lchan, ts, ts->max_lchans_possible)
ts_for_n_lchans(lchan, ts, ts->max_lchans_possible) {
lchan->vamos.is_secondary = false;
lchan_fsm_update_id(lchan);
}
break;
}
}