pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/30897 )
Change subject: modem: do not depend on $(top_srcdir)/src/misc/rslms.c ......................................................................
modem: do not depend on $(top_srcdir)/src/misc/rslms.c
Change-Id: Ic4d7e1956530aa10ff3125d6d857efe47ea37d38 Related: SYS#5500 --- M src/host/layer23/src/modem/Makefile.am M src/host/layer23/src/modem/app_modem.c 2 files changed, 71 insertions(+), 8 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
diff --git a/src/host/layer23/src/modem/Makefile.am b/src/host/layer23/src/modem/Makefile.am index 522456a..3fa1ceb 100644 --- a/src/host/layer23/src/modem/Makefile.am +++ b/src/host/layer23/src/modem/Makefile.am @@ -15,7 +15,6 @@
modem_SOURCES = \ $(top_srcdir)/src/common/main.c \ - $(top_srcdir)/src/misc/rslms.c \ app_modem.c \ $(NULL) modem_LDADD = \ diff --git a/src/host/layer23/src/modem/app_modem.c b/src/host/layer23/src/modem/app_modem.c index 48c216d..d643991 100644 --- a/src/host/layer23/src/modem/app_modem.c +++ b/src/host/layer23/src/modem/app_modem.c @@ -39,8 +39,6 @@ #include <osmocom/bb/common/l1ctl.h> #include <osmocom/bb/common/l23_app.h> #include <osmocom/bb/common/sysinfo.h> -#include <osmocom/bb/misc/rslms.h> -#include <osmocom/bb/misc/layer3.h>
#include <l1ctl_proto.h>
@@ -143,7 +141,7 @@ return 0; }
-int gsm48_rx_bcch(struct msgb *msg, struct osmocom_ms *ms) +static int modem_rx_bcch(struct msgb *msg, struct osmocom_ms *ms) { const struct gsm48_system_information_type_header *si_hdr = msgb_l3(msg); const uint8_t si_type = si_hdr->system_information; @@ -165,7 +163,7 @@ }; }
-static int gsm48_rx_imm_ass(struct msgb *msg, struct osmocom_ms *ms) +static int modem_rx_imm_ass(struct msgb *msg, struct osmocom_ms *ms) { const struct gsm48_imm_ass *ia = msgb_l3(msg); uint8_t ch_type, ch_subch, ch_ts; @@ -243,7 +241,7 @@ return false; }
-int gsm48_rx_ccch(struct msgb *msg, struct osmocom_ms *ms) +static int modem_rx_ccch(struct msgb *msg, struct osmocom_ms *ms) { const struct gsm48_system_information_type_header *sih = msgb_l3(msg);
@@ -265,12 +263,76 @@
switch (sih->system_information) { case GSM48_MT_RR_IMM_ASS: - return gsm48_rx_imm_ass(msg, ms); + return modem_rx_imm_ass(msg, ms); default: return 0; } }
+static int modem_rx_rslms_rll_ud(struct osmocom_ms *ms, struct msgb *msg) +{ + const struct abis_rsl_rll_hdr *rllh = msgb_l2(msg); + struct tlv_parsed tv; + + DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n", + rllh->chan_nr, rllh->link_id); + + if (rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg) - sizeof(*rllh)) < 0) { + LOGP(DRSL, LOGL_ERROR, "%s(): rsl_tlv_parse() failed\n", __func__); + return -EINVAL; + } + + if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) { + LOGP(DRSL, LOGL_ERROR, "UNIT_DATA_IND without L3 INFO ?!?\n"); + return -EINVAL; + } + + msg->l3h = (uint8_t *)TLVP_VAL(&tv, RSL_IE_L3_INFO); + + switch (rllh->chan_nr) { + case RSL_CHAN_PCH_AGCH: + return modem_rx_ccch(msg, ms); + case RSL_CHAN_BCCH: + return modem_rx_bcch(msg, ms); + default: + return 0; + } +} + +static int modem_rx_rslms_rll(struct osmocom_ms *ms, struct msgb *msg) +{ + const struct abis_rsl_rll_hdr *rllh = msgb_l2(msg); + + switch (rllh->c.msg_type) { + case RSL_MT_UNIT_DATA_IND: + return modem_rx_rslms_rll_ud(ms, msg); + default: + LOGP(DRSL, LOGL_NOTICE, "Unhandled RSLms RLL message " + "(msg_type 0x%02x)\n", rllh->c.msg_type); + return -EINVAL; + } +} + +static int modem_rslms_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx) +{ + const struct abis_rsl_common_hdr *rslh = msgb_l2(msg); + int rc; + + switch (rslh->msg_discr & 0xfe) { + case ABIS_RSL_MDISC_RLL: + rc = modem_rx_rslms_rll((struct osmocom_ms *)ctx, msg); + break; + default: + LOGP(DRSL, LOGL_NOTICE, "Unhandled RSLms message " + "(msg_discr 0x%02x)\n", rslh->msg_discr); + rc = -EINVAL; + break; + } + + msgb_free(msg); + return rc; +} + void layer3_app_reset(void) { memset(&app_data, 0x00, sizeof(app_data)); @@ -306,7 +368,9 @@ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL); l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
- return layer3_init(ms); + lapdm_channel_set_l3(&ms->lapdm_channel, &modem_rslms_cb, ms); + + return 0; }
static int l23_cfg_supported(void)