pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/32225 )

Change subject: Move NSVC structs to be part of NSE
......................................................................

Move NSVC structs to be part of NSE

The NSVCs exist inside an NSE. Rearrange data model to have proper
relations.

Change-Id: I1cfe9366594836c622673d461ab8b2edd1a2b58a
---
M include/osmo-bts/bts.h
M src/common/bts.c
M src/common/oml.c
M src/common/pcu_sock.c
M src/common/vty.c
5 files changed, 47 insertions(+), 31 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h
index 03a29e4..6a4d23e 100644
--- a/include/osmo-bts/bts.h
+++ b/include/osmo-bts/bts.h
@@ -125,9 +125,10 @@
 };

 /* GPRS NSVC; ip.access specific NM Object */
-struct gsm_bts_gprs_nsvc {
+struct gsm_gprs_nse;
+struct gsm_gprs_nsvc {
        struct gsm_abis_mo mo;
-       struct gsm_bts *bts;
+       struct gsm_gprs_nse *nse;
        /* data read via VTY config file, to configure the BTS
         * via OML from BSC */
        int id;
@@ -141,6 +142,7 @@
        struct gsm_abis_mo mo;
        uint16_t nsei;
        uint8_t timer[7];
+       struct gsm_gprs_nsvc nsvc[2];
 };

 /* GPRS CELL; ip.access specific NM Object */
@@ -241,7 +243,6 @@
        struct {
                struct gsm_gprs_nse nse;
                struct gsm_gprs_cell cell;
-               struct gsm_bts_gprs_nsvc nsvc[2];
                uint8_t rac;
        } gprs;

diff --git a/src/common/bts.c b/src/common/bts.c
index 5845fb2..23e4456 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -232,6 +232,7 @@
 struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)
 {
        struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts);
+       struct gsm_gprs_nse *nse = &bts->gprs.nse;
        int i;

        if (!bts)
@@ -264,12 +265,11 @@
        gsm_mo_init(&bts->mo, bts, NM_OC_BTS, bts->nr, 0xff, 0xff);

        /* NM GPRS NSE */
-       bts->gprs.nse.mo.fi = osmo_fsm_inst_alloc(&nm_gprs_nse_fsm, bts, 
&bts->gprs.nse,
+       nse->mo.fi = osmo_fsm_inst_alloc(&nm_gprs_nse_fsm, bts, nse,
                                                  LOGL_INFO, NULL);
-       osmo_fsm_inst_update_id_f(bts->gprs.nse.mo.fi, "gprs_nse%d", bts->nr);
-       gsm_mo_init(&bts->gprs.nse.mo, bts, NM_OC_GPRS_NSE, bts->nr, 0xff, 
0xff);
-       memcpy(&bts->gprs.nse.timer, bts_nse_timer_default,
-               sizeof(bts->gprs.nse.timer));
+       osmo_fsm_inst_update_id_f(nse->mo.fi, "gprs_nse%d", bts->nr);
+       gsm_mo_init(&nse->mo, bts, NM_OC_GPRS_NSE, bts->nr, 0xff, 0xff);
+       memcpy(&nse->timer, bts_nse_timer_default, sizeof(nse->timer));

        /* NM GPRS CELL */
        bts->gprs.cell.mo.fi = osmo_fsm_inst_alloc(&nm_gprs_cell_fsm, bts, 
&bts->gprs.cell,
@@ -279,11 +279,11 @@
        memcpy(&bts->gprs.cell.rlc_cfg, &rlc_cfg_default, 
sizeof(bts->gprs.cell.rlc_cfg));
        memcpy(&bts->gprs.cell.timer, bts_cell_timer_default, 
sizeof(bts->gprs.cell.timer));

-       for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
-               bts->gprs.nsvc[i].bts = bts;
-               bts->gprs.nsvc[i].id = i;
-               gsm_mo_init(&bts->gprs.nsvc[i].mo, bts, NM_OC_GPRS_NSVC,
-                               bts->nr, i, 0xff);
+       for (i = 0; i < ARRAY_SIZE(nse->nsvc); i++) {
+               struct gsm_gprs_nsvc *nsvc = &nse->nsvc[i];
+               nsvc->nse = nse;
+               nsvc->id = i;
+               gsm_mo_init(&nsvc->mo, bts, NM_OC_GPRS_NSVC, 
nse->mo.obj_inst.bts_nr, i, 0xff);
        }

        /* create our primary TRX. It will be initialized during bts_init() */
@@ -384,8 +384,8 @@
        oml_mo_state_init(&bts->gprs.cell.mo, NM_OPSTATE_DISABLED, 
NM_AVSTATE_NOT_INSTALLED);

        /* set BTS attr to dependency */
-       oml_mo_state_init(&bts->gprs.nsvc[0].mo, NM_OPSTATE_DISABLED, 
NM_AVSTATE_DEPENDENCY);
-       oml_mo_state_init(&bts->gprs.nsvc[1].mo, NM_OPSTATE_DISABLED, 
NM_AVSTATE_DEPENDENCY);
+       oml_mo_state_init(&bts->gprs.nse.nsvc[0].mo, NM_OPSTATE_DISABLED, 
NM_AVSTATE_DEPENDENCY);
+       oml_mo_state_init(&bts->gprs.nse.nsvc[1].mo, NM_OPSTATE_DISABLED, 
NM_AVSTATE_DEPENDENCY);

        /* allocate a talloc pool for ORTP to ensure it doesn't have to go back
         * to the libc malloc all the time */
@@ -460,8 +460,8 @@
        osmo_fsm_inst_dispatch(bts->gprs.nse.mo.fi, NM_EV_SW_ACT, NULL);

        /* those should all be in DEPENDENCY */
-       oml_tx_state_changed(&bts->gprs.nsvc[0].mo);
-       oml_tx_state_changed(&bts->gprs.nsvc[1].mo);
+       oml_tx_state_changed(&bts->gprs.nse.nsvc[0].mo);
+       oml_tx_state_changed(&bts->gprs.nse.nsvc[1].mo);

        /* All other objects start off-line until the BTS Model code says 
otherwise */
        for (i = 0; i < bts->num_trx; i++) {
diff --git a/src/common/oml.c b/src/common/oml.c
index e23a087..fd8c22c 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -1373,7 +1373,7 @@
        return 0;
 }

-static int oml_ipa_mo_set_attr_nsvc(struct gsm_bts_gprs_nsvc *nsvc,
+static int oml_ipa_mo_set_attr_nsvc(struct gsm_gprs_nsvc *nsvc,
                                    const struct tlv_parsed *tp)
 {
        if (TLVP_PRES_LEN(tp, NM_ATT_IPACC_NSVCI, 2))
@@ -1746,9 +1746,9 @@
                mo = &bts->gprs.cell.mo;
                break;
        case NM_OC_GPRS_NSVC:
-               if (obj_inst->trx_nr >= ARRAY_SIZE(bts->gprs.nsvc))
+               if (obj_inst->trx_nr >= ARRAY_SIZE(bts->gprs.nse.nsvc))
                        return NULL;
-               mo = &bts->gprs.nsvc[obj_inst->trx_nr].mo;
+               mo = &bts->gprs.nse.nsvc[obj_inst->trx_nr].mo;
                break;
        }
        return mo;
@@ -1813,9 +1813,9 @@
                obj = &bts->gprs.cell;
                break;
        case NM_OC_GPRS_NSVC:
-               if (obj_inst->trx_nr >= ARRAY_SIZE(bts->gprs.nsvc))
+               if (obj_inst->trx_nr >= ARRAY_SIZE(bts->gprs.nse.nsvc))
                        return NULL;
-               obj = &bts->gprs.nsvc[obj_inst->trx_nr];
+               obj = &bts->gprs.nse.nsvc[obj_inst->trx_nr];
                break;
        }
        return obj;
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 5e4b06b..bce067a 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -239,11 +239,13 @@
        struct gprs_rlc_cfg *rlcc;
        struct gsm_bts_trx *trx;
        int i;
+       struct gsm_gprs_nse *nse;

        LOGP(DPCU, LOGL_INFO, "Sending info\n");

        /* FIXME: allow multiple BTS */
        bts = llist_entry(net->bts_list.next, struct gsm_bts, list);
+       nse = &bts->gprs.nse;
        rlcc = &bts->gprs.cell.rlc_cfg;

        msg = pcu_msgb_alloc(PCU_IF_MSG_INFO_IND, bts->nr);
@@ -271,8 +273,8 @@
        info_ind->rac = bts->gprs.rac;

        /* NSE */
-       info_ind->nsei = bts->gprs.nse.nsei;
-       memcpy(info_ind->nse_timer, bts->gprs.nse.timer, 7);
+       info_ind->nsei = nse->nsei;
+       memcpy(info_ind->nse_timer, nse->timer, 7);
        memcpy(info_ind->cell_timer, bts->gprs.cell.timer, 11);

        /* cell attributes */
@@ -323,8 +325,8 @@
        info_ind->initial_mcs = rlcc->initial_mcs;

        /* NSVC */
-       for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
-               const struct gsm_bts_gprs_nsvc *nsvc = &bts->gprs.nsvc[i];
+       for (i = 0; i < ARRAY_SIZE(nse->nsvc); i++) {
+               const struct gsm_gprs_nsvc *nsvc = &nse->nsvc[i];
                info_ind->nsvci[i] = nsvc->nsvci;
                /* PCUIF beauty: the NSVC addresses are sent in the network 
byte order,
                 * while the port numbers need to be send in the host order.  
Sigh. */
@@ -363,7 +365,7 @@
        void *hdlr_data, void *signal_data)
 {
        struct gsm_network *net = &bts_gsmnet;
-       struct gsm_bts_gprs_nsvc *nsvc;
+       struct gsm_gprs_nsvc *nsvc;
        struct gsm_bts *bts;
        struct gsm48_system_information_type_3 *si3;
        int id;
diff --git a/src/common/vty.c b/src/common/vty.c
index 1ef79f0..bc2afb6 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1361,21 +1361,22 @@
 static void gprs_dump_vty(struct vty *vty, const struct gsm_bts *bts)
 {
        unsigned int i;
+       const struct gsm_gprs_nse *nse = &bts->gprs.nse;

        /* GPRS parameters received from the BSC */
        vty_out(vty, "BTS %u, RAC %u, NSEI %u, BVCI %u%s",
                bts->nr, bts->gprs.rac,
-               bts->gprs.nse.nsei,
+               nse->nsei,
                bts->gprs.cell.bvci,
                VTY_NEWLINE);

        vty_out(vty, "  Cell NM state: ");
        net_dump_nmstate(vty, &bts->gprs.cell.mo.nm_state);
        vty_out(vty, "  NSE NM state: ");
-       net_dump_nmstate(vty, &bts->gprs.nse.mo.nm_state);
+       net_dump_nmstate(vty, &nse->mo.nm_state);

-       for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
-               const struct gsm_bts_gprs_nsvc *nsvc = &bts->gprs.nsvc[i];
+       for (i = 0; i < ARRAY_SIZE(nse->nsvc); i++) {
+               const struct gsm_gprs_nsvc *nsvc = &nse->nsvc[i];

                vty_out(vty, "  NSVC%u (NSVCI %u) NM state: ", i, nsvc->nsvci);
                net_dump_nmstate(vty, &nsvc->mo.nm_state);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/32225
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I1cfe9366594836c622673d461ab8b2edd1a2b58a
Gerrit-Change-Number: 32225
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to