pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/32022 )


Change subject: layer23: modem: Test GMM layer through VTY
......................................................................

layer23: modem: Test GMM layer through VTY

Recent work on libosmo-gprs-gmm already allows triggering GPRS Attach
procedure. Let's add some code to use it so we can already test the
entire stack GMM->LLC->RLCMAC (SM layer still missing).

Depends: libosmo-gprs.git Change-Id I212053b3a3f27ef7d63503c3d5ef08453b2d2056
Related: OS#5501
Change-Id: Iba0663075468670a29aceafe5196cae3cab050eb
---
M src/host/layer23/src/modem/gmm.c
M src/host/layer23/src/modem/llc.c
M src/host/layer23/src/modem/vty.c
3 files changed, 63 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/22/32022/1

diff --git a/src/host/layer23/src/modem/gmm.c b/src/host/layer23/src/modem/gmm.c
index 3488162..f88226e 100644
--- a/src/host/layer23/src/modem/gmm.c
+++ b/src/host/layer23/src/modem/gmm.c
@@ -82,6 +82,17 @@
        return rc;
 }

+static int modem_gmm_prim_llc_down_cb(struct osmo_gprs_llc_prim *llc_prim, 
void *user_data)
+{
+       int rc;
+
+       rc = osmo_gprs_llc_prim_upper_down(llc_prim);
+
+       /* LLC took ownership of the message, tell GMM layer to not free it: */
+       rc = 1;
+       return rc;
+}
+
 int modem_gmm_init(struct osmocom_ms *ms)
 {
        int rc;
@@ -93,5 +104,8 @@

        osmo_gprs_gmm_prim_set_up_cb(modem_gmm_prim_up_cb, ms);
        osmo_gprs_gmm_prim_set_down_cb(modem_gmm_prim_down_cb, ms);
+       osmo_gprs_gmm_prim_set_llc_down_cb(modem_gmm_prim_llc_down_cb, ms);
+
+       osmo_gprs_gmm_enable_gprs(true);
        return rc;
 }
diff --git a/src/host/layer23/src/modem/llc.c b/src/host/layer23/src/modem/llc.c
index 8d9d5bd..5352e0f 100644
--- a/src/host/layer23/src/modem/llc.c
+++ b/src/host/layer23/src/modem/llc.c
@@ -32,6 +32,7 @@
 #include <osmocom/gprs/gprs_msgb.h>
 #include <osmocom/gprs/llc/llc_prim.h>
 #include <osmocom/gprs/llc/llc.h>
+#include <osmocom/gprs/gmm/gmm_prim.h>
 #include <osmocom/gprs/rlcmac/rlcmac_prim.h>
 #include <osmocom/gprs/sndcp/sndcp_prim.h>

@@ -41,7 +42,7 @@

 static int modem_llc_handle_ll_gmm(struct osmo_gprs_llc_prim *llc_prim)
 {
-       struct msgb *msg;
+       int rc;

        switch (llc_prim->oph.primitive) {
        case OSMO_GPRS_LLC_LL_UNITDATA:
@@ -57,15 +58,10 @@
                return -EINVAL;
        }

-       msg = msgb_alloc(4096, "gsm0408_rx");
-       msgb_tlli(msg) = llc_prim->ll.tlli;
-       msgb_gmmh(msg) = msgb_put(msg, llc_prim->ll.l3_pdu_len);
-       if (llc_prim->ll.l3_pdu_len > 0)
-               memcpy(msgb_gmmh(msg), llc_prim->ll.l3_pdu, 
llc_prim->ll.l3_pdu_len);
-
-       //TODO: submit to GMM?
-       //TODO: free msg?
-       return 0;
+       /* GMM took ownership of the message, tell LLC layer to not free it: */
+       rc = osmo_gprs_gmm_prim_llc_lower_up(llc_prim);
+       rc = 1;
+       return rc;
 }

 static int modem_llc_handle_ll_sndcp(struct osmo_gprs_llc_prim *llc_prim)
diff --git a/src/host/layer23/src/modem/vty.c b/src/host/layer23/src/modem/vty.c
index 4fa8e1d..37d1584 100644
--- a/src/host/layer23/src/modem/vty.c
+++ b/src/host/layer23/src/modem/vty.c
@@ -25,6 +25,7 @@

 #include <osmocom/gprs/llc/llc.h>
 #include <osmocom/gprs/llc/llc_prim.h>
+#include <osmocom/gprs/gmm/gmm_prim.h>

 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/command.h>
@@ -152,6 +153,32 @@
        return CMD_SUCCESS;
 }

+DEFUN_HIDDEN(test_gmm_reg_attch,
+            test_gmm_reg_attch_cmd,
+            "test MS_NAME gmm attach",
+            TEST_CMD_DESC MS_NAME_DESC LLC_CMDG_DESC
+            "Enqueue a GMM GMMREG-ATTACH.req for transmission\n"
+            "Hard-coded GMM Attach Request (SAPI=GMM, TLLI=0xe1c5d364)\n")
+{
+       struct osmo_gprs_gmm_prim *gmm_prim;
+       const uint32_t tlli = 0xe1c5d364;
+       struct osmocom_ms *ms;
+
+       if ((ms = l23_vty_get_ms(argv[0], vty)) == NULL)
+               return CMD_WARNING;
+
+       gmm_prim = osmo_gprs_gmm_prim_alloc_gmmreg_attach_req();
+       gmm_prim->gmmreg.attach_req.ptmsi = tlli;
+       gmm_prim->gmmreg.attach_req.attach_type = 
OSMO_GPRS_GMM_ATTACH_TYPE_GPRS;
+
+       if (osmo_gprs_gmm_prim_upper_down(gmm_prim) != 0) {
+               vty_out(vty, "Failed to enqueue an GMM PDU%s", VTY_NEWLINE);
+               return CMD_WARNING;
+       }
+
+       return CMD_SUCCESS;
+}
+
 /* per APN config */
 DEFUN(cfg_ms_apn, cfg_ms_apn_cmd, "apn APN_NAME",
        "Configure an APN\n"
@@ -335,6 +362,7 @@
        install_element_ve(&test_grr_tx_chan_req_cmd);
        install_element_ve(&test_llc_unitdata_req_hexpdu_cmd);
        install_element_ve(&test_llc_unitdata_req_gmm_attch_cmd);
+       install_element_ve(&test_gmm_reg_attch_cmd);
        install_element(CONFIG_NODE, &l23_cfg_ms_cmd);

        install_element(MS_NODE, &cfg_ms_apn_cmd);

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Iba0663075468670a29aceafe5196cae3cab050eb
Gerrit-Change-Number: 32022
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to