Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/2786 to look at the new patch set (#3). Extend Get Attribute responder * detect if attributes are requested for BTS or TRX and act accordingly * report TRX phy version * report TRX nominal power Note: including phy_link.h to oml.c somehow breaks the tests so we have to add stub functions to unbreak them. Change-Id: I9f72305bbf1ab74745bffac1bee9f539f5a6de32 Related: OS#1614 --- M src/common/oml.c M tests/agch/agch_test.c M tests/cipher/cipher_test.c M tests/handover/handover_test.c M tests/paging/paging_test.c 5 files changed, 85 insertions(+), 28 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/86/2786/3 diff --git a/src/common/oml.c b/src/common/oml.c index 9dddf57..4fe6916 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -46,6 +46,7 @@ #include <osmo-bts/bts_model.h> #include <osmo-bts/bts.h> #include <osmo-bts/signal.h> +#include <osmo-bts/phy_link.h> static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg); @@ -153,37 +154,94 @@ return mo_buf; } -static inline struct msgb *add_bts_attr(const struct gsm_bts *bts) +static inline void add_bts_attrs(struct msgb *msg, const struct gsm_bts *bts) { - struct msgb *a = oml_msgb_alloc(); - - if (!a) - return NULL; - - abis_nm_put_sw_file(a, btstype2str(GSM_BTS_TYPE_OSMOBTS), PACKAGE_VERSION, true); - abis_nm_put_sw_file(a, btsatttr2str(BTS_TYPE_VARIANT), btsvariant2str(bts->variant), true); + abis_nm_put_sw_file(msg, btstype2str(GSM_BTS_TYPE_OSMOBTS), PACKAGE_VERSION, true); + abis_nm_put_sw_file(msg, btsatttr2str(BTS_TYPE_VARIANT), btsvariant2str(bts->variant), true); if (strlen(bts->sub_model)) - abis_nm_put_sw_file(a, btsatttr2str(BTS_SUB_MODEL), bts->sub_model, true); - - return a; + abis_nm_put_sw_file(msg, btsatttr2str(BTS_SUB_MODEL), bts->sub_model, true); } -static inline int handle_attr(const struct gsm_abis_mo *mo, const uint8_t *attr, uint16_t attr_len, uint8_t *out) +static inline void add_trx_attr(struct msgb *msg, struct gsm_bts_trx *trx) +{ + struct phy_instance *pinst = trx_phy_instance(trx); + + abis_nm_put_sw_file(msg, btsatttr2str(TRX_PHY_VERSION), strlen(pinst->version) ? pinst->version : "Unknown", + true); +} +/* Add nominal TRX power (if available) as 3GPP TS 52.021 §9.4.28 Manufacturer Dependent State */ +static inline void add_trx_power(struct msgb *msg, struct gsm_bts_trx *trx) +{ + uint8_t power = get_p_nominal_mdBm(trx); + + if (power <= 0) + power = trx->nominal_power; + + if (power <= 0) + power = trx->bts->c0->nominal_power; + + if (power <= 0) + return; + + msgb_tv_put(msg, NM_ATT_MANUF_STATE, power); +} + +/* copy all the attributes accumulated in msg to out and return the total length of out buffer */ +static inline int cleanup_attr_msg(struct msgb *msg, int length, uint8_t *out) +{ + int len = 0; + + if (msg) { + memcpy(out + length - 1, msgb_data(msg), msg->len); + len = msg->len; + msgb_free(msg); + } + + return length + len; +} + +/* assemble values of supported attributes and list of unsupported ones */ +static inline int handle_attrs(const struct gsm_bts *bts, const struct gsm_abis_mo *mo, + const uint8_t *attr, uint16_t attr_len, uint8_t *out) { uint16_t i, attr_out_index = 1; /* byte 0 is reserved for unsupported attributes counter */ - struct msgb *ba = NULL; - int length; + struct msgb *attr_buf = oml_msgb_alloc(); + + if (!attr_buf) + return -ENOMEM; for (i = 0; i < attr_len; i++) { switch (attr[i]) { case NM_ATT_SW_CONFIG: switch (mo->obj_class) { case NM_OC_BTS: - ba = add_bts_attr(mo->bts); + add_bts_attrs(attr_buf, mo->bts); + break; + case NM_OC_BASEB_TRANSC: + add_trx_attr(attr_buf, gsm_bts_trx_num(bts, mo->obj_inst.trx_nr)); break; default: - LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute Response\n", + LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute " + "Response(NM_ATT_SW_CONFIG)\n", + get_value_string(abis_nm_obj_class_names, mo->obj_class)); + return -EINVAL; + } + break; + case NM_ATT_MANUF_STATE: + switch (mo->obj_class) { + case NM_OC_BTS: + LOGP(DOML, LOGL_NOTICE, "BTS does not support NM_ATT_MANUF_STATE in Get Attribute " + "Response\n"); + out[attr_out_index] = attr[i]; + attr_out_index++; + break; + case NM_OC_BASEB_TRANSC: + add_trx_power(attr_buf, gsm_bts_trx_num(bts, mo->obj_inst.trx_nr)); + break; + default: + LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute " + "Response(NM_ATT_MANUF_STATE)\n", get_value_string(abis_nm_obj_class_names, mo->obj_class)); return -EINVAL; } @@ -204,19 +262,11 @@ } else out[0] = attr_out_index - 1; /* Count number of unhandled attributes */ - length = attr_out_index + 1; - - if (ba) { - memcpy(out + attr_out_index, msgb_data(ba), ba->len); - length += ba->len; - msgb_free(ba); - } - - return length; + return cleanup_attr_msg(attr_buf, attr_out_index + 1, out); } /* send 3GPP TS 52.021 §8.11.2 Get Attribute Response */ -static int oml_tx_attr_resp(struct gsm_abis_mo *mo, const uint8_t *attr, uint16_t attr_len) +static int oml_tx_attr_resp(const struct gsm_bts *bts, struct gsm_abis_mo *mo, const uint8_t *attr, uint16_t attr_len) { struct msgb *nmsg = oml_msgb_alloc(); uint8_t resp[MAX_VERSION_LENGTH * attr_len * 2]; /* heuristic for Attribute Response Info space requirements */ @@ -227,7 +277,7 @@ if (!nmsg) return -ENOMEM; - len = handle_attr(mo, attr, attr_len, resp); + len = handle_attrs(bts, mo, attr, attr_len, resp); if (len < 0) { LOGP(DOML, LOGL_ERROR, "Tx Get Attribute Response FAILED with %d\n", len); msgb_free(nmsg); @@ -489,7 +539,7 @@ return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT); } - rc = oml_tx_attr_resp(mo, TLVP_VAL(&tp, NM_ATT_LIST_REQ_ATTR), TLVP_LEN(&tp, NM_ATT_LIST_REQ_ATTR)); + rc = oml_tx_attr_resp(bts, mo, TLVP_VAL(&tp, NM_ATT_LIST_REQ_ATTR), TLVP_LEN(&tp, NM_ATT_LIST_REQ_ATTR)); if (rc < 0) { LOGP(DOML, LOGL_ERROR, "Failed to respond to O&M Get Attributes message: %s\n", strerror(-rc)); switch (-rc) { diff --git a/tests/agch/agch_test.c b/tests/agch/agch_test.c index e275c64..cf05a8d 100644 --- a/tests/agch/agch_test.c +++ b/tests/agch/agch_test.c @@ -35,6 +35,8 @@ 0x08, 0x59, 0x51, 0x30, 0x99, 0x00, 0x00, 0x00, 0x19 }; +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) { return 0; } + static int count_imm_ass_rej_refs(struct gsm48_imm_ass_rej *rej) { int count = 0; diff --git a/tests/cipher/cipher_test.c b/tests/cipher/cipher_test.c index c913925..957dbca 100644 --- a/tests/cipher/cipher_test.c +++ b/tests/cipher/cipher_test.c @@ -37,6 +37,8 @@ abort(); \ } +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) { return 0; } + static void test_cipher_parsing(void) { int i; diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c index 611c441..3ca595a 100644 --- a/tests/handover/handover_test.c +++ b/tests/handover/handover_test.c @@ -270,6 +270,7 @@ int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, struct tlv_parsed *new_attr, int obj_kind, void *obj) { return 0; } int bts_model_opstart(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj) { return 0; } int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj, uint8_t adm_state) { return 0; } +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) { return 0; } int bts_model_init(struct gsm_bts *bts) { return 0; } int bts_model_trx_deact_rf(struct gsm_bts_trx *trx) { return 0; } int bts_model_trx_close(struct gsm_bts_trx *trx) { return 0; } diff --git a/tests/paging/paging_test.c b/tests/paging/paging_test.c index 1d5f216..32bf484 100644 --- a/tests/paging/paging_test.c +++ b/tests/paging/paging_test.c @@ -41,6 +41,8 @@ abort(); \ } +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) { return 0; } + static void test_paging_smoke(void) { int rc; -- To view, visit https://gerrit.osmocom.org/2786 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I9f72305bbf1ab74745bffac1bee9f539f5a6de32 Gerrit-PatchSet: 3 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max <msur...@sysmocom.de> Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org> Gerrit-Reviewer: Jenkins Builder