Enhance the FSM instance ID string with meaningful context.
The FSMs should have unique ID strings, providing the user/operator with meaningful context during log messages, etc.
This commit is contained in:
parent
2dca6472b1
commit
f6605e1bd0
|
@ -665,6 +665,7 @@ static struct v52_bcc_proc *v52_le_bcc_create(struct v5x_interface *v5if, uint16
|
|||
talloc_free(bcc);
|
||||
return NULL;
|
||||
}
|
||||
osmo_fsm_inst_update_id_f(bcc->fi, "%s-P%d-L%d-TS%d", v5x_interface_name(v5if), user_port_id, link_id, ts);
|
||||
|
||||
bcc->ref = (bcc_new_ref++) & 0x1fff;
|
||||
bcc->source_id = source_id;
|
||||
|
|
|
@ -777,7 +777,7 @@ struct osmo_fsm_inst *v52_le_lcp_create(void *ctx, struct v5x_link *v5l, uint8_t
|
|||
fi = osmo_fsm_inst_alloc(&v52_le_lcp_fsm, ctx, v5l, LOGL_DEBUG, NULL);
|
||||
if (!fi)
|
||||
return NULL;
|
||||
osmo_fsm_inst_update_id_f(fi, "%d", id);
|
||||
osmo_fsm_inst_update_id_f(fi, "%s-L%d", v5x_interface_name(v5l->interface), id);
|
||||
/* initial state for links that are not in failure state */
|
||||
fi->state = V52_LCPFSM_S_LE20_OP_OPERATIONAL;
|
||||
|
||||
|
|
|
@ -699,6 +699,7 @@ struct v52_pp_proto *v52_le_pp_create(struct v5x_interface *v5if)
|
|||
pp->fi = osmo_fsm_inst_alloc(&v52_le_pp_fsm, pp, pp, LOGL_DEBUG, NULL);
|
||||
if (!pp->fi)
|
||||
goto error;
|
||||
osmo_fsm_inst_update_id_f(pp->fi, "%s", v5x_interface_name(v5if));
|
||||
|
||||
return pp;
|
||||
|
||||
|
|
|
@ -568,3 +568,10 @@ struct v5x_link *v5x_link_find_id(struct v5x_interface *v5if, uint8_t id)
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *v5x_interface_name(const struct v5x_interface *v5if)
|
||||
{
|
||||
static char buf[16];
|
||||
snprintf(buf, sizeof(buf), "IF%u", v5if->id);
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -396,3 +396,5 @@ struct v5x_link *v5x_link_create(struct v5x_interface *v5if, uint8_t id);
|
|||
int v5x_link_destroy(struct v5x_link *v5l);
|
||||
int v5x_link_count(struct v5x_interface *v5if);
|
||||
struct v5x_link *v5x_link_find_id(struct v5x_interface *v5if, uint8_t id);
|
||||
|
||||
const char *v5x_interface_name(const struct v5x_interface *v5if);
|
||||
|
|
|
@ -588,7 +588,7 @@ struct v5x_l1_proto *v5x_l1_fsm_create(void *ctx, struct v5x_link *v5l, uint8_t
|
|||
l1->fi = osmo_fsm_inst_alloc(&v5x_l1_fsm, l1, l1, LOGL_DEBUG, NULL);
|
||||
if (!l1->fi)
|
||||
return NULL;
|
||||
osmo_fsm_inst_update_id_f(l1->fi, "%d", id);
|
||||
osmo_fsm_inst_update_id_f(l1->fi, "%s-L%u", v5x_interface_name(v5l->interface), id);
|
||||
|
||||
return l1;
|
||||
}
|
||||
|
|
|
@ -392,6 +392,9 @@ void v5x_le_ctrl_init(void)
|
|||
struct v5x_ctrl_proto *v5x_le_ctrl_create(enum v5x_ctrl_type type, void *ctx, void *priv, uint16_t nr)
|
||||
{
|
||||
struct v5x_ctrl_proto *ctrl;
|
||||
struct v5x_link *v5l = NULL;
|
||||
struct v5x_interface *v5if = NULL;
|
||||
struct v5x_user_port *v5up = NULL;
|
||||
|
||||
OSMO_ASSERT(priv);
|
||||
|
||||
|
@ -407,7 +410,21 @@ struct v5x_ctrl_proto *v5x_le_ctrl_create(enum v5x_ctrl_type type, void *ctx, vo
|
|||
v5x_le_ctrl_destroy(ctrl);
|
||||
return NULL;
|
||||
}
|
||||
osmo_fsm_inst_update_id_f(ctrl->fi, "%d", nr);
|
||||
|
||||
switch (type) {
|
||||
case V5X_CTRL_TYPE_LINK:
|
||||
v5l = priv;
|
||||
osmo_fsm_inst_update_id_f(ctrl->fi, "%s-LINK-L%u", v5x_interface_name(v5l->interface), nr);
|
||||
break;
|
||||
case V5X_CTRL_TYPE_COMMON:
|
||||
v5if = priv;
|
||||
osmo_fsm_inst_update_id_f(ctrl->fi, "%s-COMMON", v5x_interface_name(v5if));
|
||||
break;
|
||||
case V5X_CTRL_TYPE_PORT:
|
||||
v5up = priv;
|
||||
osmo_fsm_inst_update_id_f(ctrl->fi, "%s-PORT-P%u", v5x_interface_name(v5up->interface), nr);
|
||||
break;
|
||||
}
|
||||
|
||||
return ctrl;
|
||||
}
|
||||
|
|
|
@ -1612,6 +1612,7 @@ void v5x_le_mgmt_init(void)
|
|||
struct v5x_mgmt_proto *v5x_le_mgmt_create(struct v5x_interface *v5if)
|
||||
{
|
||||
struct v5x_mgmt_proto *mgmt;
|
||||
const char *if_name = v5x_interface_name(v5if);
|
||||
int i;
|
||||
|
||||
mgmt = talloc_zero(v5if, struct v5x_mgmt_proto);
|
||||
|
@ -1625,19 +1626,19 @@ struct v5x_mgmt_proto *v5x_le_mgmt_create(struct v5x_interface *v5if)
|
|||
if (v5if->dialect == V5X_DIALECT_V52)
|
||||
mgmt->acc_align = true;
|
||||
|
||||
mgmt->system_fi = osmo_fsm_inst_alloc(&v5x_le_system_fsm, mgmt, mgmt, LOGL_DEBUG, NULL);
|
||||
mgmt->system_fi = osmo_fsm_inst_alloc(&v5x_le_system_fsm, mgmt, mgmt, LOGL_DEBUG, if_name);
|
||||
if (!mgmt->system_fi)
|
||||
goto error;
|
||||
mgmt->pstn_dl_fi = osmo_fsm_inst_alloc(&v5x_le_pstn_dl_fsm, mgmt, mgmt, LOGL_DEBUG, NULL);
|
||||
mgmt->pstn_dl_fi = osmo_fsm_inst_alloc(&v5x_le_pstn_dl_fsm, mgmt, mgmt, LOGL_DEBUG, if_name);
|
||||
if (!mgmt->pstn_dl_fi)
|
||||
goto error;
|
||||
mgmt->pstn_rs_fi = osmo_fsm_inst_alloc(&v5x_le_pstn_rs_fsm, mgmt, mgmt, LOGL_DEBUG, NULL);
|
||||
mgmt->pstn_rs_fi = osmo_fsm_inst_alloc(&v5x_le_pstn_rs_fsm, mgmt, mgmt, LOGL_DEBUG, if_name);
|
||||
if (!mgmt->pstn_rs_fi)
|
||||
goto error;
|
||||
if (v5if->dialect == V5X_DIALECT_V52) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
mgmt->unblk_all_fi[i] = osmo_fsm_inst_alloc(&v5x_le_unblk_all_fsm, mgmt, mgmt, LOGL_DEBUG,
|
||||
NULL);
|
||||
if_name);
|
||||
if (!mgmt->unblk_all_fi[i])
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -553,7 +553,7 @@ struct osmo_fsm_inst *v5x_le_port_isdn_create(struct v5x_user_port *v5up, uint16
|
|||
fi = osmo_fsm_inst_alloc(&v5x_le_ctrl_isdn_port_fsm, v5up, v5up, LOGL_DEBUG, NULL);
|
||||
if (!fi)
|
||||
return NULL;
|
||||
osmo_fsm_inst_update_id_f(fi, "%d", nr);
|
||||
osmo_fsm_inst_update_id_f(fi, "%s-P%d", v5x_interface_name(v5up->interface), nr);
|
||||
|
||||
return fi;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue