pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/31076 )
Change subject: rlcmac: Introduce primitives for SAPs towards higher layers
......................................................................
rlcmac: Introduce primitives for SAPs towards higher layers
The GRR primitives and types are kept 1-to-1 ABI compatible
to those at libosmo-gprs-llc so that they can be forwarded as pointers.
Still, we want to keep the types duplicated in order to avoid having to
depend one library on another, since the forwarding of one layer to the
other is done by the app and can use whatever it wishes on either side.
Related: OS#5500
Change-Id: I1870fa6a264612c5a669bfb832e6e8c0a892cb74
---
M include/osmocom/gprs/llc/llc_prim.h
M include/osmocom/gprs/rlcmac/Makefile.am
M include/osmocom/gprs/rlcmac/rlcmac.h
A include/osmocom/gprs/rlcmac/rlcmac_prim.h
M include/osmocom/gprs/rlcmac/rlcmac_private.h
M src/rlcmac/Makefile.am
A src/rlcmac/rlcmac.c
A src/rlcmac/rlcmac_prim.c
A src/rlcmac/ts_44_064.c
9 files changed, 577 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/include/osmocom/gprs/llc/llc_prim.h b/include/osmocom/gprs/llc/llc_prim.h
index 378a4a6..1a317e1 100644
--- a/include/osmocom/gprs/llc/llc_prim.h
+++ b/include/osmocom/gprs/llc/llc_prim.h
@@ -197,6 +197,7 @@
};
/* Parameters for OSMO_GPRS_LLC_GRR_* prims */
+/* This is expected to stay ABI compatible with libosmo-gprs-rlcmac struct
osmo_gprs_rlcmac_grr_prim */
struct osmo_gprs_llc_grr_prim {
/* Common fields */
uint32_t tlli;
diff --git a/include/osmocom/gprs/rlcmac/Makefile.am
b/include/osmocom/gprs/rlcmac/Makefile.am
index 0182bfd..db16d94 100644
--- a/include/osmocom/gprs/rlcmac/Makefile.am
+++ b/include/osmocom/gprs/rlcmac/Makefile.am
@@ -4,6 +4,7 @@
rlcmac_HEADERS = \
rlcmac.h \
+ rlcmac_prim.h \
gprs_rlcmac.h \
$(NULL)
diff --git a/include/osmocom/gprs/rlcmac/rlcmac.h b/include/osmocom/gprs/rlcmac/rlcmac.h
index 0497643..2b5f208 100644
--- a/include/osmocom/gprs/rlcmac/rlcmac.h
+++ b/include/osmocom/gprs/rlcmac/rlcmac.h
@@ -2,6 +2,33 @@
/* Radio Link Control / Medium Access Control (RLCMAC) definitions from 3GPP TS 44.060
*/
+#include <stdint.h>
+#include <stddef.h>
+
+#include <osmocom/core/msgb.h>
+
+enum osmo_gprs_rlcmac_location {
+ OSMO_GPRS_RLCMAC_LOCATION_UNSET,
+ OSMO_GPRS_RLCMAC_LOCATION_MS,
+ OSMO_GPRS_RLCMAC_LOCATION_PCU,
+};
+
+/* Section TS 44.064 6.2.3 Service Access Point Identifier (SAPI) */
+enum osmo_gprs_rlcmac_llc_sapi {
+ OSMO_GPRS_RLCMAC_LLC_SAPI_GMM = 1,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_TOM2 = 2,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP3 = 3,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP5 = 5,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_SMS = 7,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_TOM8 = 8,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP9 = 9,
+ OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP11 = 11,
+};
+
+extern const struct value_string osmo_gprs_rlcmac_llc_sapi_names[];
+
+int osmo_gprs_rlcmac_init(enum osmo_gprs_rlcmac_location location);
+
enum osmo_gprs_rlcmac_log_cat {
OSMO_GPRS_RLCMAC_LOGC_RLCMAC,
_OSMO_GPRS_RLCMAC_LOGC_MAX,
diff --git a/include/osmocom/gprs/rlcmac/rlcmac_prim.h
b/include/osmocom/gprs/rlcmac/rlcmac_prim.h
new file mode 100644
index 0000000..443dede
--- /dev/null
+++ b/include/osmocom/gprs/rlcmac/rlcmac_prim.h
@@ -0,0 +1,115 @@
+#pragma once
+
+/* GPRS Radio Resource SAP as per:
+ * 3GPP TS 44.060 4.3
+ * 3GPP TS 24.007 9.3
+ * 3GPP TS 44.064 7.2.3
+ */
+
+#include <osmocom/core/prim.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/gsm48.h>
+#include <osmocom/gprs/rlcmac/rlcmac.h>
+
+/* TS 24.007 Section 9.3 */
+enum osmo_gprs_rlcmac_prim_sap {
+ OSMO_GPRS_RLCMAC_SAP_GRR,
+ OSMO_GPRS_RLCMAC_SAP_GMMRR,
+};
+
+extern const struct value_string osmo_gprs_rlcmac_prim_sap_names[];
+static inline const char *osmo_gprs_rlcmac_prim_sap_name(enum osmo_gprs_rlcmac_prim_sap
val)
+{
+ return get_value_string(osmo_gprs_rlcmac_prim_sap_names, val);
+}
+
+/* TS 24.007 Section 9.3.1 "Service primitives for GRR-SAP (GSM only)"
+ * TS 04.64 Section 7.2.3 "LLE - RLC/MAC primitives" (MS side) */
+enum osmo_gprs_rlcmac_grr_prim_type {
+ OSMO_GPRS_RLCMAC_GRR_DATA, /* Req/Ind: TLLI, LL-PDU, SAPI, Cause, QoS, Radio Prio */
+ OSMO_GPRS_RLCMAC_GRR_UNITDATA, /* Req/Ind: TLLI, LL-PDU, SAPI, QoS, Radio Prio */
+};
+
+extern const struct value_string osmo_gprs_rlcmac_grr_prim_type_names[];
+static inline const char *osmo_gprs_rlcmac_grr_prim_type_name(enum
osmo_gprs_rlcmac_grr_prim_type val)
+{
+ return get_value_string(osmo_gprs_rlcmac_grr_prim_type_names, val);
+}
+
+/* Parameters for OSMO_GPRS_RLCMAC_GRR_* prims */
+struct osmo_gprs_rlcmac_grr_prim {
+ /* Common fields */
+ uint32_t tlli;
+ uint8_t *ll_pdu;
+ size_t ll_pdu_len;
+ /* Specific fields */
+ union {
+ /* OSMO_GPRS_RLCMAC_GRR_DATA | Req */
+ struct {
+ uint8_t sapi;
+ uint8_t radio_prio;
+ uint8_t qos_params[3];
+ } data_req;
+ /* OSMO_GPRS_RLCMAC_GRR_UNITDATA | Req */
+ struct {
+ uint8_t sapi;
+ uint8_t radio_prio;
+ uint8_t qos_params[3];
+ uint8_t cause;
+ } unitdata_req;
+ };
+};
+
+/* TS 24.007 Section 9.3.2 "Service primitives for GMMRR-SAP (GSM only)" */
+enum osmo_gprs_rlcmac_gmmrr_prim_type {
+ OSMO_GPRS_RLCMAC_GMMRR_ASSIGN, /* Req: newTLLI */
+ OSMO_GPRS_RLCMAC_GMMRR_PAGE, /* Ind: TLLI */
+};
+
+extern const struct value_string osmo_gprs_rlcmac_gmmrr_prim_type_names[];
+static inline const char *osmo_gprs_rlcmac_gmmrr_prim_type_name(enum
osmo_gprs_rlcmac_gmmrr_prim_type val)
+{
+ return get_value_string(osmo_gprs_rlcmac_gmmrr_prim_type_names, val);
+}
+
+/* Parameters for OSMO_GPRS_RLCMAC_GRR_* prims */
+struct osmo_gprs_rlcmac_gmmrr_prim {
+ /* Common fields (none) */
+ union {
+ /* OSMO_GPRS_RLCMAC_GMMRR_ASSIGN | Req */
+ struct {
+ uint32_t new_tlli;
+ } assign_req;
+ /* OSMO_GPRS_RLCMAC_GMMRR_PAGE | Ind */
+ struct {
+ uint32_t tlli;
+ } page_ind;
+ };
+};
+
+struct osmo_gprs_rlcmac_prim {
+ struct osmo_prim_hdr oph;
+ union {
+ struct osmo_gprs_rlcmac_grr_prim grr;
+ struct osmo_gprs_rlcmac_gmmrr_prim gmmrr;
+ };
+};
+
+typedef int (*osmo_gprs_rlcmac_prim_up_cb)(struct osmo_gprs_rlcmac_prim *rlcmac_prim,
void *up_user_data);
+void osmo_gprs_rlcmac_prim_set_up_cb(osmo_gprs_rlcmac_prim_up_cb up_cb, void
*up_user_data);
+
+typedef int (*osmo_gprs_rlcmac_prim_down_cb)(struct osmo_gprs_rlcmac_prim *rlcmac_prim,
void *down_user_data);
+void osmo_gprs_rlcmac_prim_set_down_cb(osmo_gprs_rlcmac_prim_down_cb down_cb, void
*down_user_data);
+
+int osmo_gprs_rlcmac_prim_upper_down(struct osmo_gprs_rlcmac_prim *rlcmac_prim);
+int osmo_gprs_rlcmac_prim_lower_up(struct osmo_gprs_rlcmac_prim *rlcmac_prim);
+
+const char *osmo_gprs_rlcmac_prim_name(const struct osmo_gprs_rlcmac_prim *rlcmac_prim);
+
+/* Alloc primitive for GRR SAP: */
+struct osmo_gprs_rlcmac_prim *osmo_gprs_rlcmac_prim_alloc_grr_unitdata_req(
+ uint32_t tlli, uint8_t *ll_pdu, size_t ll_pdu_len);
+
+/* Alloc primitive for GMMRR SAP: */
+struct osmo_gprs_rlcmac_prim *osmo_gprs_rlcmac_prim_alloc_gmmrr_asign_req(
+ uint32_t new_tlli);
diff --git a/include/osmocom/gprs/rlcmac/rlcmac_private.h
b/include/osmocom/gprs/rlcmac/rlcmac_private.h
index 17bc745..fb3ec7a 100644
--- a/include/osmocom/gprs/rlcmac/rlcmac_private.h
+++ b/include/osmocom/gprs/rlcmac/rlcmac_private.h
@@ -2,9 +2,36 @@
/* RLCMAC private header */
+#include <stdint.h>
+#include <stddef.h>
+
+#include <osmocom/core/msgb.h>
+
+#include <osmocom/gprs/rlcmac/rlcmac_prim.h>
#include <osmocom/gprs/rlcmac/rlcmac.h>
extern int g_rlcmac_log_cat[_OSMO_GPRS_RLCMAC_LOGC_MAX];
#define LOGRLCMAC(lvl, fmt, args...) LOGP(g_rlcmac_log_cat[OSMO_GPRS_RLCMAC_LOGC_RLCMAC],
lvl, fmt, ## args)
#define LOGRLCMACC(lvl, fmt, args...)
LOGPC(g_rlcmac_log_cat[OSMO_GPRS_RLCMAC_LOGC_RLCMAC], lvl, fmt, ## args)
+
+#define msgb_rlcmac_prim(msg) ((struct osmo_gprs_rlcmac_prim *)(msg)->l1h)
+
+struct gprs_rlcmac_ctx {
+ enum osmo_gprs_rlcmac_location location;
+ osmo_gprs_rlcmac_prim_up_cb rlcmac_up_cb;
+ void *rlcmac_up_cb_user_data;
+
+ osmo_gprs_rlcmac_prim_down_cb rlcmac_down_cb;
+ void *rlcmac_down_cb_user_data;
+};
+
+extern struct gprs_rlcmac_ctx *g_ctx;
+
+/* rlcmac_prim.c */
+int gprs_rlcmac_prim_call_up_cb(struct osmo_gprs_rlcmac_prim *rlcmac_prim);
+int gprs_rlcmac_prim_call_down_cb(struct osmo_gprs_rlcmac_prim *rlcmac_prim);
+
+struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_grr_unitdata_ind(
+ uint32_t tlli, uint8_t *ll_pdu, size_t ll_pdu_len);
+struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_gmmrr_page_ind(uint32_t tlli);
diff --git a/src/rlcmac/Makefile.am b/src/rlcmac/Makefile.am
index 8aa8dc2..2e82e25 100644
--- a/src/rlcmac/Makefile.am
+++ b/src/rlcmac/Makefile.am
@@ -22,9 +22,12 @@
$(NULL)
libosmo_gprs_rlcmac_la_SOURCES = \
+ rlcmac.c \
+ rlcmac_prim.c \
ts_24_008.c \
ts_44_018.c \
ts_44_060.c \
+ ts_44_064.c \
misc.c \
$(NULL)
diff --git a/src/rlcmac/rlcmac.c b/src/rlcmac/rlcmac.c
new file mode 100644
index 0000000..faf3489
--- /dev/null
+++ b/src/rlcmac/rlcmac.c
@@ -0,0 +1,39 @@
+/* GPRS RLCMAC as per 3GPP TS 44.060 */
+/*
+ * (C) 2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/gprs/rlcmac/rlcmac.h>
+#include <osmocom/gprs/rlcmac/rlcmac_prim.h>
+#include <osmocom/gprs/rlcmac/rlcmac_private.h>
+
+struct gprs_rlcmac_ctx *g_ctx;
+
+int osmo_gprs_rlcmac_init(enum osmo_gprs_rlcmac_location location)
+{
+ OSMO_ASSERT(location == OSMO_GPRS_RLCMAC_LOCATION_MS || location ==
OSMO_GPRS_RLCMAC_LOCATION_PCU)
+
+ if (g_ctx)
+ talloc_free(g_ctx);
+
+ g_ctx = talloc_zero(NULL, struct gprs_rlcmac_ctx);
+ g_ctx->location = location;
+
+ return 0;
+}
diff --git a/src/rlcmac/rlcmac_prim.c b/src/rlcmac/rlcmac_prim.c
new file mode 100644
index 0000000..1d5dcc9
--- /dev/null
+++ b/src/rlcmac/rlcmac_prim.c
@@ -0,0 +1,329 @@
+/* GPRS Radio Resource SAP as per:
+ * 3GPP TS 44.060 4.3
+ * 3GPP TS 24.007 9.3
+ * 3GPP TS 44.064 7.2.3
+ */
+/*
+ * (C) 2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdint.h>
+#include <errno.h>
+
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/crypt/gprs_cipher.h>
+#include <osmocom/gsm/gsm_utils.h>
+
+#include <osmocom/gprs/rlcmac/rlcmac.h>
+#include <osmocom/gprs/rlcmac/rlcmac_prim.h>
+#include <osmocom/gprs/rlcmac/rlcmac_private.h>
+
+#define RLCMAC_MSGB_HEADROOM 0
+
+const struct value_string osmo_gprs_rlcmac_prim_sap_names[] = {
+ { OSMO_GPRS_RLCMAC_SAP_GRR, "GRR" },
+ { OSMO_GPRS_RLCMAC_SAP_GMMRR, "GMMRR" },
+ { 0, NULL }
+};
+
+const struct value_string osmo_gprs_rlcmac_grr_prim_type_names[] = {
+ { OSMO_GPRS_RLCMAC_GRR_DATA, "DATA" },
+ { OSMO_GPRS_RLCMAC_GRR_UNITDATA, "UNITDATA" },
+ { 0, NULL }
+};
+
+const struct value_string osmo_gprs_rlcmac_gmmrr_prim_type_names[] = {
+ { OSMO_GPRS_RLCMAC_GMMRR_ASSIGN, "ASSIGN" },
+ { OSMO_GPRS_RLCMAC_GMMRR_PAGE, "PAGE" },
+ { 0, NULL }
+};
+
+const char *osmo_gprs_rlcmac_prim_name(const struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ static char name_buf[256];
+ const char *sap = osmo_gprs_rlcmac_prim_sap_name(rlcmac_prim->oph.sap);
+ const char *op = get_value_string(osmo_prim_op_names, rlcmac_prim->oph.operation);
+ const char *type;
+
+ switch (rlcmac_prim->oph.sap) {
+ case OSMO_GPRS_RLCMAC_SAP_GRR:
+ type = osmo_gprs_rlcmac_grr_prim_type_name(rlcmac_prim->oph.primitive);
+ break;
+ case OSMO_GPRS_RLCMAC_SAP_GMMRR:
+ type = osmo_gprs_rlcmac_gmmrr_prim_type_name(rlcmac_prim->oph.primitive);
+ break;
+ default:
+ type = "unsupported-rlcmac-sap";
+ }
+
+ snprintf(name_buf, sizeof(name_buf), "%s-%s.%s", sap, type, op);
+ return name_buf;
+}
+
+static int rlcmac_up_cb_dummy(struct osmo_gprs_rlcmac_prim *rlcmac_prim, void
*user_data)
+{
+ LOGRLCMAC(LOGL_INFO, "rlcmac_up_cb_dummy(%s)\n",
osmo_gprs_rlcmac_prim_name(rlcmac_prim));
+ return 0;
+}
+
+static int rlcmac_down_cb_dummy(struct osmo_gprs_rlcmac_prim *rlcmac_prim, void
*user_data)
+{
+ LOGRLCMAC(LOGL_INFO, "rlcmac_down_cb_dummy(%s)\n",
osmo_gprs_rlcmac_prim_name(rlcmac_prim));
+ return 0;
+}
+
+/* Set callback used by LLC layer to push primitives to higher layers in protocol stack
*/
+void osmo_gprs_rlcmac_prim_set_up_cb(osmo_gprs_rlcmac_prim_up_cb up_cb, void
*up_user_data)
+{
+ g_ctx->rlcmac_up_cb = up_cb;
+ g_ctx->rlcmac_up_cb_user_data = up_user_data;
+}
+
+/* Set callback used by LLC layer to push primitives to lower layers in protocol stack
*/
+void osmo_gprs_rlcmac_prim_set_down_cb(osmo_gprs_rlcmac_prim_down_cb down_cb, void
*down_user_data)
+{
+ g_ctx->rlcmac_down_cb = down_cb;
+ g_ctx->rlcmac_down_cb_user_data = down_user_data;
+}
+
+/********************************
+ * Primitive allocation:
+ ********************************/
+
+/* allocate a msgb containing a struct osmo_gprs_rlcmac_prim + optional l3 data */
+static struct msgb *gprs_rlcmac_prim_msgb_alloc(unsigned int l3_len)
+{
+ const int headroom = RLCMAC_MSGB_HEADROOM;
+ const int size = headroom + sizeof(struct osmo_gprs_rlcmac_prim) + l3_len;
+ struct msgb *msg = msgb_alloc_headroom(size, headroom, "rlcmac_prim");
+
+ if (!msg)
+ return NULL;
+
+ msg->l1h = msgb_put(msg, sizeof(struct osmo_gprs_rlcmac_prim));
+
+ return msg;
+}
+
+static struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc(enum
osmo_gprs_rlcmac_prim_sap sap,
+ unsigned int type,
+ enum osmo_prim_operation operation,
+ unsigned int l3_len)
+{
+ struct msgb *msg = gprs_rlcmac_prim_msgb_alloc(l3_len);
+ struct osmo_gprs_rlcmac_prim *rlcmac_prim = msgb_rlcmac_prim(msg);
+
+ osmo_prim_init(&rlcmac_prim->oph, sap, type, operation, msg);
+ return rlcmac_prim;
+}
+
+static inline
+struct osmo_gprs_rlcmac_prim *rlcmac_prim_grr_alloc(enum osmo_gprs_rlcmac_grr_prim_type
type,
+ enum osmo_prim_operation operation,
+ unsigned int l3_len)
+{
+ return gprs_rlcmac_prim_alloc(OSMO_GPRS_RLCMAC_SAP_GRR, type, operation, l3_len);
+}
+
+static inline
+struct osmo_gprs_rlcmac_prim *rlcmac_prim_gmmrr_alloc(enum
osmo_gprs_rlcmac_gmmrr_prim_type type,
+ enum osmo_prim_operation operation,
+ unsigned int l3_len)
+{
+ return gprs_rlcmac_prim_alloc(OSMO_GPRS_RLCMAC_SAP_GMMRR, type, operation, l3_len);
+}
+
+/* 3GPP TS 44.064 7.2.3.2 GRR-UNITDATA.ind (MS):*/
+struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_grr_unitdata_ind(
+ uint32_t tlli, uint8_t *ll_pdu,
+ size_t ll_pdu_len)
+{
+ struct osmo_gprs_rlcmac_prim *rlcmac_prim;
+ rlcmac_prim = rlcmac_prim_grr_alloc(OSMO_GPRS_RLCMAC_GRR_UNITDATA, PRIM_OP_INDICATION,
ll_pdu_len);
+ rlcmac_prim->grr.tlli = tlli;
+ rlcmac_prim->grr.ll_pdu = ll_pdu;
+ rlcmac_prim->grr.ll_pdu_len = ll_pdu_len;
+ return rlcmac_prim;
+}
+
+/* 3GPP TS 44.064 7.2.3.2 GRR-UL-UNITDATA.req (MS):*/
+struct osmo_gprs_rlcmac_prim *osmo_gprs_rlcmac_prim_alloc_grr_unitdata_req(
+ uint32_t tlli, uint8_t *ll_pdu, size_t ll_pdu_len)
+{
+ struct osmo_gprs_rlcmac_prim *rlcmac_prim;
+ rlcmac_prim = rlcmac_prim_grr_alloc(OSMO_GPRS_RLCMAC_GRR_UNITDATA, PRIM_OP_REQUEST,
ll_pdu_len);
+ rlcmac_prim->grr.tlli = tlli;
+ rlcmac_prim->grr.ll_pdu = ll_pdu;
+ rlcmac_prim->grr.ll_pdu_len = ll_pdu_len;
+ return rlcmac_prim;
+}
+
+/* 3GPP TS 24.007 9.3.2.1 GMMRR-ASSIGN-REQ:*/
+struct osmo_gprs_rlcmac_prim *osmo_gprs_rlcmac_prim_alloc_gmmrr_assign_req(uint32_t
new_tlli)
+{
+ struct osmo_gprs_rlcmac_prim *rlcmac_prim;
+ rlcmac_prim = rlcmac_prim_gmmrr_alloc(OSMO_GPRS_RLCMAC_GMMRR_ASSIGN, PRIM_OP_REQUEST,
0);
+ rlcmac_prim->gmmrr.assign_req.new_tlli = new_tlli;
+ return rlcmac_prim;
+}
+
+/* 3GPP TS 24.007 9.3.2.2 GMMRR-PAGE-IND:*/
+struct osmo_gprs_rlcmac_prim *gprs_rlcmac_prim_alloc_gmmrr_page_ind(uint32_t tlli)
+{
+ struct osmo_gprs_rlcmac_prim *rlcmac_prim;
+ rlcmac_prim = rlcmac_prim_gmmrr_alloc(OSMO_GPRS_RLCMAC_GMMRR_PAGE, PRIM_OP_INDICATION,
0);
+ rlcmac_prim->gmmrr.page_ind.tlli = tlli;
+ return rlcmac_prim;
+}
+
+int gprs_rlcmac_prim_handle_unsupported(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ LOGRLCMAC(LOGL_ERROR, "Unsupported rlcmac_prim! %s\n",
osmo_gprs_rlcmac_prim_name(rlcmac_prim));
+ msgb_free(rlcmac_prim->oph.msg);
+ return -ENOTSUP;
+}
+
+/********************************
+ * Handling from/to upper layers:
+ ********************************/
+
+static int rlcmac_prim_handle_grr_data_req(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ int rc = gprs_rlcmac_prim_handle_unsupported(rlcmac_prim);
+ return rc;
+}
+
+static int rlcmac_prim_handle_grr_unitdata_req(struct osmo_gprs_rlcmac_prim
*rlcmac_prim)
+{
+ int rc = gprs_rlcmac_prim_handle_unsupported(rlcmac_prim);
+ return rc;
+}
+
+int gprs_rlcmac_prim_call_up_cb(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ int rc;
+ if (g_ctx->rlcmac_up_cb)
+ rc = g_ctx->rlcmac_up_cb(rlcmac_prim, g_ctx->rlcmac_up_cb_user_data);
+ else
+ rc = rlcmac_up_cb_dummy(rlcmac_prim, g_ctx->rlcmac_up_cb_user_data);
+ /* Special return value '1' means: do not free */
+ if (rc != 1)
+ msgb_free(rlcmac_prim->oph.msg);
+ return rc;
+}
+
+static int gprs_rlcmac_prim_grr_upper_down(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ int rc;
+
+ switch (OSMO_PRIM_HDR(&rlcmac_prim->oph)) {
+ case OSMO_PRIM(OSMO_GPRS_RLCMAC_GRR_DATA, PRIM_OP_REQUEST):
+ rc = rlcmac_prim_handle_grr_data_req(rlcmac_prim);
+ break;
+ case OSMO_PRIM(OSMO_GPRS_RLCMAC_GRR_UNITDATA, PRIM_OP_REQUEST):
+ rc = rlcmac_prim_handle_grr_unitdata_req(rlcmac_prim);
+ break;
+ default:
+ rc = -ENOTSUP;
+ }
+ return rc;
+}
+
+static int rlcmac_prim_handle_gmmrr_assign_req(struct osmo_gprs_rlcmac_prim
*rlcmac_prim)
+{
+ int rc = gprs_rlcmac_prim_handle_unsupported(rlcmac_prim);
+ return rc;
+}
+
+static int gprs_rlcmac_prim_gmmrr_upper_down(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ int rc;
+
+ switch (OSMO_PRIM_HDR(&rlcmac_prim->oph)) {
+ case OSMO_PRIM(OSMO_GPRS_RLCMAC_GMMRR_ASSIGN, PRIM_OP_REQUEST):
+ rc = rlcmac_prim_handle_gmmrr_assign_req(rlcmac_prim);
+ break;
+ default:
+ rc = -ENOTSUP;
+ }
+ return rc;
+}
+
+/* RLC/MAC higher layers (RLCMAC) push GRR/GMMRR primitive down to RLC/MAC layer: */
+int osmo_gprs_rlcmac_prim_upper_down(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ int rc;
+
+ LOGRLCMAC(LOGL_INFO, "Rx from upper layers: %s\n",
osmo_gprs_rlcmac_prim_name(rlcmac_prim));
+
+ switch (rlcmac_prim->oph.sap) {
+ case OSMO_GPRS_RLCMAC_SAP_GRR:
+ rc = gprs_rlcmac_prim_grr_upper_down(rlcmac_prim);
+ break;
+ case OSMO_GPRS_RLCMAC_SAP_GMMRR:
+ rc = gprs_rlcmac_prim_gmmrr_upper_down(rlcmac_prim);
+ break;
+ default:
+ rc = gprs_rlcmac_prim_handle_unsupported(rlcmac_prim);
+ }
+ return rc;
+}
+
+/********************************
+ * Handling from/to lower layers:
+ ********************************/
+
+int gprs_rlcmac_prim_call_down_cb(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ int rc;
+ if (g_ctx->rlcmac_down_cb)
+ rc = g_ctx->rlcmac_down_cb(rlcmac_prim, g_ctx->rlcmac_down_cb_user_data);
+ else
+ rc = rlcmac_down_cb_dummy(rlcmac_prim, g_ctx->rlcmac_down_cb_user_data);
+ /* Special return value '1' means: do not free */
+ if (rc != 1)
+ msgb_free(rlcmac_prim->oph.msg);
+ return rc;
+}
+
+int osmo_gprs_rlcmac_prim_lower_up(struct osmo_gprs_rlcmac_prim *rlcmac_prim)
+{
+ OSMO_ASSERT(g_ctx);
+ OSMO_ASSERT(rlcmac_prim);
+ struct msgb *msg = rlcmac_prim->oph.msg;
+ int rc;
+
+ LOGRLCMAC(LOGL_INFO, "Rx from lower layers: %s\n",
osmo_gprs_rlcmac_prim_name(rlcmac_prim));
+
+ switch (rlcmac_prim->oph.sap) {
+ // TODO
+ //case OSMO_GPRS_LLC_SAP_GRR:
+ // OSMO_ASSERT(g_ctx->location == OSMO_GPRS_LLC_LOCATION_MS);
+ // rc = gprs_rlcmac_prim_lower_up_grr(rlcmac_prim);
+ default:
+ rc = -EINVAL;
+ }
+
+ /* Special return value '1' means: do not free */
+ if (rc != 1)
+ msgb_free(msg);
+ return rc;
+}
diff --git a/src/rlcmac/ts_44_064.c b/src/rlcmac/ts_44_064.c
new file mode 100644
index 0000000..5ad9af5
--- /dev/null
+++ b/src/rlcmac/ts_44_064.c
@@ -0,0 +1,35 @@
+/* GPRS RLC/MAC definitions from TS 44.064 (LLC) */
+/*
+ * (C) 2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/core/utils.h>
+#include <osmocom/gprs/rlcmac/rlcmac.h>
+
+const struct value_string osmo_gprs_rlcmac_llc_sapi_names[] = {
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_GMM, "GMM" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_TOM2, "TOM2" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP3, "SNDCP3" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP5, "SNDCP5" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_SMS, "SMS" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_TOM8, "TOM8" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP9, "SNDCP9" },
+ { OSMO_GPRS_RLCMAC_LLC_SAPI_SNDCP11, "SNDCP11" },
+ { 0, NULL }
+};
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/31076
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I1870fa6a264612c5a669bfb832e6e8c0a892cb74
Gerrit-Change-Number: 31076
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged