fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/31600 )


Change subject: pcuif_proto: version 11: rework sending IMM ASS over PCH
......................................................................

pcuif_proto: version 11: rework sending IMM ASS over PCH

Change-Id: I1a8246f6d16d4595182432c1920afd3c5eae5079
Related: OS#5198
---
M include/osmo-bts/paging.h
M include/osmo-bts/pcu_if.h
M include/osmo-bts/pcuif_proto.h
M src/common/paging.c
M src/common/pcu_sock.c
5 files changed, 52 insertions(+), 40 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/00/31600/1

diff --git a/include/osmo-bts/paging.h b/include/osmo-bts/paging.h
index fb50323..ff1d1a5 100644
--- a/include/osmo-bts/paging.h
+++ b/include/osmo-bts/paging.h
@@ -37,7 +37,8 @@

 /* Add an IMM.ASS message to the paging queue */
 int paging_add_imm_ass(struct paging_state *ps,
-                      const uint8_t *data, uint8_t len);
+                      uint32_t tlli, uint16_t imsi,
+                      const uint8_t *data);

 /* generate paging message for given gsm time */
 int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time 
*gt,
diff --git a/include/osmo-bts/pcu_if.h b/include/osmo-bts/pcu_if.h
index 6cdc682..83b20d5 100644
--- a/include/osmo-bts/pcu_if.h
+++ b/include/osmo-bts/pcu_if.h
@@ -21,7 +21,7 @@
 int pcu_tx_time_ind(uint32_t fn);
 int pcu_tx_interf_ind(const struct gsm_bts_trx *trx, uint32_t fn);
 int pcu_tx_pag_req(const uint8_t *identity_lv, uint8_t chan_needed);
-int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len);
+int pcu_tx_pch_data_cnf(uint32_t fn, uint32_t tlli);
 int pcu_tx_susp_req(struct gsm_lchan *lchan, uint32_t tlli, const uint8_t 
*ra_id, uint8_t cause);
 int pcu_sock_send(struct gsm_network *net, struct msgb *msg);

diff --git a/include/osmo-bts/pcuif_proto.h b/include/osmo-bts/pcuif_proto.h
index 0fece48..ca4d5d2 100644
--- a/include/osmo-bts/pcuif_proto.h
+++ b/include/osmo-bts/pcuif_proto.h
@@ -6,7 +6,7 @@

 #define PCU_SOCK_DEFAULT       "/tmp/pcu_bts"

-#define PCU_IF_VERSION         0x0a
+#define PCU_IF_VERSION         0x0b
 #define TXT_MAX_LEN    128

 /* msg_type */
@@ -16,7 +16,6 @@
 #define PCU_IF_MSG_SUSP_REQ    0x03    /* BTS forwards GPRS SUSP REQ to PCU */
 #define PCU_IF_MSG_APP_INFO_REQ        0x04    /* BTS asks PCU to transmit APP 
INFO via PACCH */
 #define PCU_IF_MSG_RTS_REQ     0x10    /* ready to send request */
-#define PCU_IF_MSG_DATA_CNF_DT 0x11    /* confirm (with direct tlli) */
 #define PCU_IF_MSG_RACH_IND    0x22    /* receive RACH */
 #define PCU_IF_MSG_INFO_IND    0x32    /* retrieve BTS info */
 #define PCU_IF_MSG_ACT_REQ     0x40    /* activate/deactivate PDCH */
@@ -86,19 +85,12 @@
        int16_t         lqual_cb;       /* !< \brief Link quality in centiBel */
 } __attribute__ ((packed));

-/* data confirmation with direct tlli (instead of raw mac block with tlli) */
-struct gsm_pcu_if_data_cnf_dt {
+/* data confirmation with TLLI */
+struct gsm_pcu_if_data_cnf {
        uint8_t         sapi;
+       uint8_t         spare[3];
        uint32_t        tlli;
        uint32_t        fn;
-       uint16_t        arfcn;
-       uint8_t         trx_nr;
-       uint8_t         ts_nr;
-       uint8_t         block_nr;
-       int8_t          rssi;
-       uint16_t        ber10k;         /* !< \brief BER in units of 0.01% */
-       int16_t         ta_offs_qbits;  /* !< \brief Burst TA Offset in quarter 
bits */
-       int16_t         lqual_cb;       /* !< \brief Link quality in centiBel */
 } __attribute__ ((packed));

 struct gsm_pcu_if_rts_req {
@@ -229,6 +221,17 @@
        uint8_t         data[0];
 } __attribute__ ((packed));

+/* Container for sending a (confirmed) IMMEDIATE ASSIGNMENT message via PCH.
+ * This structure is included in DATA.req with PCU_IF_SAPI_PCH. */
+struct gsm_pcu_if_pch_data {
+       /* TLLI as reference for confirmation */
+       uint32_t tlli;
+       /* IMSI % 1000 for paging group calcilation */
+       uint16_t imsi;
+       /* GSM MAC block (with RR Immediate Assignment message) */
+       uint8_t data[0];
+} __attribute__ ((packed));
+
 struct gsm_pcu_if {
        /* context based information */
        uint8_t         msg_type;       /* message type */
@@ -237,8 +240,7 @@

        union {
                struct gsm_pcu_if_data          data_req;
-               struct gsm_pcu_if_data          data_cnf;
-               struct gsm_pcu_if_data_cnf_dt   data_cnf_dt;
+               struct gsm_pcu_if_data_cnf      data_cnf;
                struct gsm_pcu_if_data          data_ind;
                struct gsm_pcu_if_susp_req      susp_req;
                struct gsm_pcu_if_rts_req       rts_req;
diff --git a/src/common/paging.c b/src/common/paging.c
index 26ba9b0..12123aa 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -63,6 +63,7 @@
                } paging;
                struct {
                        uint8_t msg[GSM_MACBLOCK_LEN];
+                       uint32_t tlli; /* used for confirmation */
                } imm_ass;
        } u;
 };
@@ -269,11 +270,12 @@

 /* Add an IMM.ASS message to the paging queue */
 int paging_add_imm_ass(struct paging_state *ps,
-                      const uint8_t *data, uint8_t len)
+                      uint32_t tlli, uint16_t imsi,
+                      const uint8_t *data)
 {
        struct llist_head *group_q;
        struct paging_record *pr;
-       uint16_t imsi, paging_group;
+       uint16_t paging_group;
 
        check_congestion(ps);

@@ -284,15 +286,6 @@
                return -ENOSPC;
        }

-       if (len != GSM_MACBLOCK_LEN + 3) {
-               LOGP(DPAG, LOGL_ERROR, "IMM.ASS invalid length %d\n", len);
-               return -EINVAL;
-       }
-       len -= 3;
-
-       imsi = 100 * ((*(data++)) - '0');
-       imsi += 10 * ((*(data++)) - '0');
-       imsi += (*(data++)) - '0';
        paging_group = gsm0502_calc_paging_group(&ps->chan_desc, imsi);

        group_q = &ps->paging_queue[paging_group];
@@ -301,9 +294,10 @@
        if (!pr)
                return -ENOMEM;
        pr->type = PAGING_RECORD_IMM_ASS;
+       pr->u.imm_ass.tlli = tlli;

-       LOGP(DPAG, LOGL_INFO, "Add IMM.ASS to queue (group=%u)\n",
-               paging_group);
+       LOGP(DPAG, LOGL_INFO, "Add IMM.ASS to queue (pgroup=%u, tlli=0x%04x)\n",
+            paging_group, tlli);
        memcpy(pr->u.imm_ass.msg, data, GSM_MACBLOCK_LEN);

        /* enqueue the new message to the HEAD of the queue */
@@ -633,8 +627,7 @@
                        /* get message and free record */
                        memcpy(out_buf, pr[num_pr]->u.imm_ass.msg,
                                                        GSM_MACBLOCK_LEN);
-                       pcu_tx_pch_data_cnf(gt->fn, pr[num_pr]->u.imm_ass.msg,
-                                                       GSM_MACBLOCK_LEN);
+                       pcu_tx_pch_data_cnf(gt->fn, pr[num_pr]->u.imm_ass.tlli);
                        talloc_free(pr[num_pr]);
                        return GSM_MACBLOCK_LEN;
                }
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index bdf5958..7c20e5f 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -621,13 +621,12 @@
        return pcu_sock_send(&bts_gsmnet, msg);
 }

-int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len)
+int pcu_tx_pch_data_cnf(uint32_t fn, uint32_t tlli)
 {
        struct gsm_network *net = &bts_gsmnet;
        struct gsm_bts *bts;
        struct msgb *msg;
        struct gsm_pcu_if *pcu_prim;
-       struct gsm_pcu_if_data *data_cnf;

        /* FIXME: allow multiple BTS */
        bts = llist_entry(net->bts_list.next, struct gsm_bts, list);
@@ -638,12 +637,11 @@
        if (!msg)
                return -ENOMEM;
        pcu_prim = (struct gsm_pcu_if *) msg->data;
-       data_cnf = &pcu_prim->u.data_cnf;
-
-       data_cnf->sapi = PCU_IF_SAPI_PCH;
-       data_cnf->fn = fn;
-       memcpy(data_cnf->data, data, len);
-       data_cnf->len = len;
+       pcu_prim->u.data_cnf = (struct gsm_pcu_if_data_cnf) {
+               .sapi = PCU_IF_SAPI_PCH,
+               .tlli = tlli,
+               .fn = fn,
+       };

        return pcu_sock_send(&bts_gsmnet, msg);
 }
@@ -681,8 +679,16 @@

        switch (data_req->sapi) {
        case PCU_IF_SAPI_PCH:
-               paging_add_imm_ass(bts->paging_state, data_req->data, 
data_req->len);
+       {
+               const struct gsm_pcu_if_pch_data *pd = (void *)&data_req->data;
+               if (OSMO_UNLIKELY(data_req->len != (sizeof(*pd) + 
GSM_MACBLOCK_LEN))) {
+                       LOGP(DPCU, LOGL_ERROR, "Rx malformed DATA.req for 
PCH\n");
+                       rc = -EINVAL;
+                       break;
+               }
+               rc = paging_add_imm_ass(bts->paging_state, pd->tlli, pd->imsi, 
&pd->data[0]);
                break;
+       }
        case PCU_IF_SAPI_AGCH:
                msg = msgb_alloc(data_req->len, "pcu_agch");
                if (!msg) {

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I1a8246f6d16d4595182432c1920afd3c5eae5079
Gerrit-Change-Number: 31600
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to