lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

May 2023

  • 1 participants
  • 2583 discussions
[L] Change in libosmocore[master]: codec cosmetic: move old FR ECU code to ecu_fr_old.c
by falconia 17 May '23

17 May '23
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32711 ) Change subject: codec cosmetic: move old FR ECU code to ecu_fr_old.c ...................................................................... codec cosmetic: move old FR ECU code to ecu_fr_old.c The current FR codec ECU implementation consists of two parts: there is a pair of functions that implement the actual functionality, and these functions are also made public as a now-deprecated legacy API - and there is the new ECU abstraction. If the FR ECU implementation behind the generic ECU abstraction is to be changed to a different one, the old implementation still has to be retained for those public legacy osmo_ecu_fr_reset() and osmo_ecu_fr_conceal() API functions to remain available and unbroken. Move this legacy ECU implementation to its own C module in preparation for changing the preferred ECU implementation. Related: OS#6027 Change-Id: Ia169b8bcc6331227a11b78eb7ffca0c7ab838c69 --- M src/codec/Makefile.am M src/codec/ecu_fr.c A src/codec/ecu_fr_old.c 3 files changed, 189 insertions(+), 138 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve lynxis lazus: Looks good to me, approved dexter: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/codec/Makefile.am b/src/codec/Makefile.am index f05ac1f..f7877fe 100644 --- a/src/codec/Makefile.am +++ b/src/codec/Makefile.am @@ -13,6 +13,7 @@ lib_LTLIBRARIES = libosmocodec.la -libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu.c ecu_fr.c +libosmocodec_la_SOURCES = gsm610.c gsm620.c gsm660.c gsm690.c ecu.c ecu_fr.c \ + ecu_fr_old.c libosmocodec_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined libosmocodec_la_LIBADD = $(top_builddir)/src/core/libosmocore.la diff --git a/src/codec/ecu_fr.c b/src/codec/ecu_fr.c index 218d837..124a58c 100644 --- a/src/codec/ecu_fr.c +++ b/src/codec/ecu_fr.c @@ -21,146 +21,9 @@ #include <stdint.h> #include <errno.h> -#include <osmocom/core/bitvec.h> - -#include <osmocom/codec/gsm610_bits.h> #include <osmocom/codec/codec.h> #include <osmocom/codec/ecu.h> -/* See also GSM 06.11, chapter 6 Example solution */ -#define GSM610_XMAXC_REDUCE 4 -#define GSM610_XMAXC_LEN 6 - -/** - * Reduce the XMAXC field. When the XMAXC field reaches - * zero the function will return true. - */ -static bool reduce_xmaxcr(struct bitvec *frame_bitvec, - const unsigned int index) -{ - unsigned int field_index; - uint64_t field; - - field_index = index; - field = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN); - if (field > GSM610_XMAXC_REDUCE) - field -= GSM610_XMAXC_REDUCE; - else - field = 0; - - field_index = index; - bitvec_write_field(frame_bitvec, &field_index, field, GSM610_XMAXC_LEN); - - return field == 0; -} - -/** - * Reduce all XMAXC fields in the frame. When all XMAXC fields - * reach zero, then the function will return true. - */ -static bool reduce_xmaxcr_all(struct bitvec *frame_bitvec) -{ - bool silent = true; - - silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC00); - silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC10); - silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC20); - silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC30); - - return silent; -} - -/* Use certain modifications to conceal the errors in a full rate frame */ -static int conceal_frame(uint8_t *frame) -{ - struct bitvec *frame_bitvec; - unsigned int len; - bool silent; - int rc = 0; - - /* In case we already deal with a silent frame, - * there is nothing to, we just abort immediately */ - if (osmo_fr_check_sid(frame, GSM_FR_BYTES)) - return 0; - - /* Attempt to allocate memory for bitvec */ - frame_bitvec = bitvec_alloc(GSM_FR_BYTES, NULL); - if (!frame_bitvec) - return -ENOMEM; - - /* Convert a frame to bitvec */ - len = bitvec_unpack(frame_bitvec, frame); - if (len != GSM_FR_BYTES) { - rc = -EIO; - goto leave; - } - - /* Fudge frame parameters */ - silent = reduce_xmaxcr_all(frame_bitvec); - - /* If we reached silence level, mute the frame - * completely, this also means that we can - * save the bitvec_pack operation */ - if (silent) { - memset(frame, 0x00, GSM_FR_BYTES); - frame[0] = 0xd0; - goto leave; - } - - /* Convert back to packed byte form */ - len = bitvec_pack(frame_bitvec, frame); - if (len != GSM_FR_BYTES) { - rc = -EIO; - goto leave; - } - -leave: - bitvec_free(frame_bitvec); - return rc; -} - -/*! - * To be called when a good frame is received. - * This function will then create a backup of the frame - * and reset the internal state. - * \param[in] state The state object for the ECU - * \param[out] frame The valid frame (GSM_FR_BYTES bytes in RTP payload format) - */ -void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, const uint8_t *frame) -{ - state->subsequent_lost_frame = false; - memcpy(state->frame_backup, frame, GSM_FR_BYTES); -} - -/*! - * To be called when a bad frame is received. - * This function will then generate a replacement frame - * that can be used to conceal the dropout. - * \param[in] state The state object for the ECU - * \param[out] frame The buffer to fill with GSM_FR_BYTES of replacement frame - * \returns 0 if the frame was sucessfully filled - */ -int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame) -{ - int rc; - - /* For subsequent frames we run the error concealment - * functions on the backed up frame before we restore - * the backup */ - if (state->subsequent_lost_frame) { - rc = conceal_frame(state->frame_backup); - if (rc) - return rc; - } - - /* Restore the backed up frame and set flag in case - * we receive even more bad frames */ - memcpy(frame, state->frame_backup, GSM_FR_BYTES); - state->subsequent_lost_frame = true; - - return 0; -} - /*********************************************************************** * Integration with ECU core ***********************************************************************/ diff --git a/src/codec/ecu_fr_old.c b/src/codec/ecu_fr_old.c new file mode 100644 index 0000000..cfefce1 --- /dev/null +++ b/src/codec/ecu_fr_old.c @@ -0,0 +1,166 @@ +/* + * (C) 2017 by sysmocom - s.f.m.c. GmbH + * (C) 2017 by Philipp Maier <pmaier(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 General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * + * This module implements legacy, deprecated osmo_ecu_fr_reset() and + * osmo_ecu_fr_conceal() functions only - see ecu_fr.c for the new + * GSM-FR ECU implementation. + */ + +#include <stdbool.h> +#include <string.h> +#include <stdint.h> +#include <errno.h> + +#include <osmocom/core/bitvec.h> + +#include <osmocom/codec/gsm610_bits.h> +#include <osmocom/codec/codec.h> +#include <osmocom/codec/ecu.h> + +/* See also GSM 06.11, chapter 6 Example solution */ +#define GSM610_XMAXC_REDUCE 4 +#define GSM610_XMAXC_LEN 6 + +/** + * Reduce the XMAXC field. When the XMAXC field reaches + * zero the function will return true. + */ +static bool reduce_xmaxcr(struct bitvec *frame_bitvec, + const unsigned int index) +{ + unsigned int field_index; + uint64_t field; + + field_index = index; + field = bitvec_read_field(frame_bitvec, &field_index, GSM610_XMAXC_LEN); + if (field > GSM610_XMAXC_REDUCE) + field -= GSM610_XMAXC_REDUCE; + else + field = 0; + + field_index = index; + bitvec_write_field(frame_bitvec, &field_index, field, GSM610_XMAXC_LEN); + + return field == 0; +} + +/** + * Reduce all XMAXC fields in the frame. When all XMAXC fields + * reach zero, then the function will return true. + */ +static bool reduce_xmaxcr_all(struct bitvec *frame_bitvec) +{ + bool silent = true; + + silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC00); + silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC10); + silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC20); + silent &= reduce_xmaxcr(frame_bitvec, GSM610_RTP_XMAXC30); + + return silent; +} + +/* Use certain modifications to conceal the errors in a full rate frame */ +static int conceal_frame(uint8_t *frame) +{ + struct bitvec *frame_bitvec; + unsigned int len; + bool silent; + int rc = 0; + + /* In case we already deal with a silent frame, + * there is nothing to, we just abort immediately */ + if (osmo_fr_check_sid(frame, GSM_FR_BYTES)) + return 0; + + /* Attempt to allocate memory for bitvec */ + frame_bitvec = bitvec_alloc(GSM_FR_BYTES, NULL); + if (!frame_bitvec) + return -ENOMEM; + + /* Convert a frame to bitvec */ + len = bitvec_unpack(frame_bitvec, frame); + if (len != GSM_FR_BYTES) { + rc = -EIO; + goto leave; + } + + /* Fudge frame parameters */ + silent = reduce_xmaxcr_all(frame_bitvec); + + /* If we reached silence level, mute the frame + * completely, this also means that we can + * save the bitvec_pack operation */ + if (silent) { + memset(frame, 0x00, GSM_FR_BYTES); + frame[0] = 0xd0; + goto leave; + } + + /* Convert back to packed byte form */ + len = bitvec_pack(frame_bitvec, frame); + if (len != GSM_FR_BYTES) { + rc = -EIO; + goto leave; + } + +leave: + bitvec_free(frame_bitvec); + return rc; +} + +/*! + * To be called when a good frame is received. + * This function will then create a backup of the frame + * and reset the internal state. + * \param[in] state The state object for the ECU + * \param[out] frame The valid frame (GSM_FR_BYTES bytes in RTP payload format) + */ +void osmo_ecu_fr_reset(struct osmo_ecu_fr_state *state, const uint8_t *frame) +{ + state->subsequent_lost_frame = false; + memcpy(state->frame_backup, frame, GSM_FR_BYTES); +} + +/*! + * To be called when a bad frame is received. + * This function will then generate a replacement frame + * that can be used to conceal the dropout. + * \param[in] state The state object for the ECU + * \param[out] frame The buffer to fill with GSM_FR_BYTES of replacement frame + * \returns 0 if the frame was successfully filled + */ +int osmo_ecu_fr_conceal(struct osmo_ecu_fr_state *state, uint8_t *frame) +{ + int rc; + + /* For subsequent frames we run the error concealment + * functions on the backed up frame before we restore + * the backup */ + if (state->subsequent_lost_frame) { + rc = conceal_frame(state->frame_backup); + if (rc) + return rc; + } + + /* Restore the backed up frame and set flag in case + * we receive even more bad frames */ + memcpy(frame, state->frame_backup, GSM_FR_BYTES); + state->subsequent_lost_frame = true; + + return 0; +} -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32711 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ia169b8bcc6331227a11b78eb7ffca0c7ab838c69 Gerrit-Change-Number: 32711 Gerrit-PatchSet: 2 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[L] Change in libosmocore[master]: codec: replace GSM-FR ECU with new implementation
by falconia 17 May '23

17 May '23
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32685 ) Change subject: codec: replace GSM-FR ECU with new implementation ...................................................................... codec: replace GSM-FR ECU with new implementation The original GSM-FR ECU implementation from 2017 exhibits a lot of defects, as detailed in OS#6027. Replace it with a new implementation based on Themyscira libgsmfrp (a complete Rx DTX handler for GSM-FR), but reduced to just the ECU function, without the comfort noise generator function. (These two functions are coupled together in the classic GSM architecture, but not in libosmocodec ECU model.) Related: OS#6027 Change-Id: I0200e423ca6165c1313ec9a4effc3f3047f5f032 --- M include/osmocom/codec/ecu.h M src/codec/ecu_fr.c M tests/codec/codec_ecu_fr_test.c M tests/codec/codec_ecu_fr_test.ok 4 files changed, 326 insertions(+), 53 deletions(-) Approvals: laforge: Looks good to me, approved dexter: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/codec/ecu.h b/include/osmocom/codec/ecu.h index 668df36..9307ea1 100644 --- a/include/osmocom/codec/ecu.h +++ b/include/osmocom/codec/ecu.h @@ -6,7 +6,7 @@ #include <osmocom/core/defs.h> #include <osmocom/codec/codec.h> -/* ECU state for GSM-FR */ +/* ECU state for GSM-FR - deprecated version only! */ struct osmo_ecu_fr_state { bool subsequent_lost_frame; uint8_t frame_backup[GSM_FR_BYTES]; diff --git a/src/codec/ecu_fr.c b/src/codec/ecu_fr.c index 124a58c..561ad60 100644 --- a/src/codec/ecu_fr.c +++ b/src/codec/ecu_fr.c @@ -1,9 +1,15 @@ /* * (C) 2017 by sysmocom - s.f.m.c. GmbH * (C) 2017 by Philipp Maier <pmaier(a)sysmocom.de> - * * All Rights Reserved * + * Significantly reworked in 2023 by Mother + * Mychaela N. Falconia <falcon(a)freecalypso.org> - however, + * Mother Mychaela's contributions are NOT subject to copyright. + * No rights reserved, all rights relinquished. + * Portions of this code are based on Themyscira libgsmfrp, + * a public domain library by the same author. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,6 +20,46 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * + * + * The present ECU implementation for GSM-FR is closely based on the + * TS 46.011 spec from 3GPP; more specifically, it is based on the + * Example solution presented in Chapter 6 of that spec, adapted for + * libosmocodec ECU architecture, and comes as close to fulfilling + * the spec's officially stated requirements (Chapter 5) as is + * possible within this Osmocom-imposed architecture. Please note + * the following areas where the present implementation fails to + * fulfill the original intent of GSM spec authors: + * + * - The "lost SID" criterion, defined in GSM 06.31, is based on the + * TAF bit from the Radio Subsystem. However, libosmocodec ECU API + * does not include this flag, thus spec requirements related to + * lost SID conditions cannot be implemented in a strictly compliant + * manner. The present implementation improvises its own "lost SID" + * detector (not strictly spec-compliant) by counting frame_out() + * calls in between good traffic frame inputs via frame_in(). + * + * - In the architecture envisioned and assumed in the GSM specs, + * the ECU function of GSM 06.11 was never intended to be a fully + * modular component with its own bona fide I/O interfaces - this + * approach appears to be an Osmocom invention - instead this ECU + * function was intended to be subsumed in the Rx DTX handler + * component of GSM 06.31, also incorporating the comfort noise + * generator of GSM 06.12 - and unlike the narrower-scope ECU, + * this slightly-larger-scope Rx DTX handler is a modular component + * with well-defined I/O interfaces. In the case of BFI conditions + * following a SID, GSM 06.11 spec was written with the assumption + * that the ECU controls the comfort noise generator via internal + * signals, as opposed to emitting "corrected" SID frames on a + * modular interface going to a CN generator located somewhere else. + * Thus the "correct" behavior for a fully modularized ECU is unclear, + * and an argument can be made that the very existence of such a + * fully modularized ECU is incorrect in itself. The present + * implementation re-emits a "rejuvenated" form of the last saved + * SID frame during BFI conditions following a SID within the + * permitted window of 48 frames, then starts emitting muted SIDs + * with Xmaxc decreasing by 4 on each frame, and finally switches + * to emitting non-SID silence frames (Table 1 of TS 46.011) + * once Xmaxc reaches 0. */ #include <stdbool.h> @@ -21,9 +67,212 @@ #include <stdint.h> #include <errno.h> +#include <osmocom/core/prbs.h> + #include <osmocom/codec/codec.h> #include <osmocom/codec/ecu.h> +/* See TS 46.011, Chapter 6 Example solution */ +#define GSM611_XMAXC_REDUCE 4 + +/* The first 5 bytes of RTP encoding neatly contain the magic nibble + * and LARc parameters, which also happens to be the part of SID frames + * that needs to be passed through as-is. */ +#define SID_PREFIX_LEN 5 + +enum ecu_principal_state { + STATE_NO_DATA, + STATE_SPEECH, + STATE_SP_MUTING, + STATE_SID, + STATE_SID_MUTING, +}; + +struct fr_ecu_state { + enum ecu_principal_state pr_state; + uint8_t speech_frame[GSM_FR_BYTES]; + uint8_t sid_prefix[SID_PREFIX_LEN]; + uint8_t sid_xmaxc; + uint8_t sid_reemit_count; + struct osmo_prbs_state prng; +}; + +/* This function is the frame input to the ECU - all inputs to this + * function have been received by the Radio Subsystem as good traffic + * frames in the GSM 06.31 definition. + */ +static void fr_ecu_input(struct fr_ecu_state *fr, const uint8_t *frame) +{ + enum osmo_gsm631_sid_class sidc; + + sidc = osmo_fr_sid_classify(frame); + switch (sidc) { + case OSMO_GSM631_SID_CLASS_SPEECH: + memcpy(fr->speech_frame, frame, GSM_FR_BYTES); + fr->pr_state = STATE_SPEECH; + return; + case OSMO_GSM631_SID_CLASS_INVALID: + /* GSM 06.31 section 6.1.2 says: "an invalid SID frame + * shall be substituted by the last valid SID frame + * and the procedure for valid SID frames be applied." + * However, libosmocodec ECU architecture prevents us + * from doing what the spec says: the frame_in() method + * gets a const frame that can't be modified, and + * frame_out() will never get called when BFI=0, even + * when the "good traffic frame" (in the BFI=0 sense) + * is an invalid SID by the bit-counting rule. + * Thus there is no place where we can re-emit a cached + * copy of the last valid SID upon receiving an invalid SID. + * + * In the standard GSM architecture this problem never + * arises because the ECU is not a separate component + * but is coupled with the CN generator, thus the output + * from the Rx DTX handler block will be a CN frame, + * for both valid-SID and invalid-SID inputs to the block. + * But what can we do within the constraints of libosmocodec + * ECU framework? We treat the invalid SID almost like a + * BFI, doing almost nothing in the frame_in() method, + * but we reset sid_reemit_count because by the rules of + * GSM 06.31 an invalid SID is still an accepted SID frame + * for the purpose of "lost SID" logic. */ + fr->sid_reemit_count = 0; + return; + case OSMO_GSM631_SID_CLASS_VALID: + /* save LARc part */ + memcpy(fr->sid_prefix, frame, SID_PREFIX_LEN); + /* save Xmaxc from the last subframe */ + fr->sid_xmaxc = ((frame[27] & 0x1F) << 1) | (frame[28] >> 7); + fr->pr_state = STATE_SID; + fr->sid_reemit_count = 0; + return; + default: + /* There are only 3 possible SID classifications per GSM 06.31 + * section 6.1.1, thus any other return value is a grave error + * in the code. */ + OSMO_ASSERT(0); + } +} + +/* Reduce all 4 Xmaxc fields in the frame. When all 4 Xmaxc fields + * reach 0, the function will return true for "mute". + */ +static bool reduce_xmaxc(uint8_t *frame) +{ + bool mute_flag = true; + uint8_t sub, xmaxc; + + for (sub = 0; sub < 4; sub++) { + xmaxc = ((frame[sub*7+6] & 0x1F) << 1) | (frame[sub*7+7] >> 7); + if (xmaxc > GSM611_XMAXC_REDUCE) { + xmaxc -= GSM611_XMAXC_REDUCE; + mute_flag = false; + } else + xmaxc = 0; + frame[sub*7+6] &= 0xE0; + frame[sub*7+6] |= xmaxc >> 1; + frame[sub*7+7] &= 0x7F; + frame[sub*7+7] |= (xmaxc & 1) << 7; + } + return mute_flag; +} + +/* TS 46.011 chapter 6, paragraph 4, last sentence: "The grid position + * parameters are chosen randomly between 0 and 3 during this time." + * (The "during this time" qualifier refers to the speech muting state.) + * This sentence in the spec must have been overlooked by previous ECU + * implementors, as this aspect of the muting logic was missing. + */ +static void random_grid_pos(struct fr_ecu_state *fr, uint8_t *frame) +{ + uint8_t sub; + + for (sub = 0; sub < 4; sub++) { + frame[sub*7+6] &= 0x9F; + frame[sub*7+6] |= osmo_prbs_get_ubit(&fr->prng) << 6; + frame[sub*7+6] |= osmo_prbs_get_ubit(&fr->prng) << 5; + } +} + +/* Like reduce_xmaxc() above, but for comfort noise rather than speech. */ +static bool reduce_xmaxc_sid(struct fr_ecu_state *fr) +{ + if (fr->sid_xmaxc > GSM611_XMAXC_REDUCE) { + fr->sid_xmaxc -= GSM611_XMAXC_REDUCE; + return false; + } + fr->sid_xmaxc = 0; + return true; +} + +/* This function implements the part which is peculiar to the present + * "standalone" packaging of GSM-FR ECU, without a directly coupled + * comfort noise generator - it re-emits synthetic SID frames during + * DTX pauses, initially unchanged from the saved SID and later muted. + */ +static void reemit_sid(struct fr_ecu_state *fr, uint8_t *frame) +{ + uint8_t *p, sub; + + memcpy(frame, fr->sid_prefix, SID_PREFIX_LEN); + p = frame + SID_PREFIX_LEN; + for (sub = 0; sub < 4; sub++) { + *p++ = 0; + *p++ = fr->sid_xmaxc >> 1; + *p++ = (fr->sid_xmaxc & 1) << 7; + *p++ = 0; + *p++ = 0; + *p++ = 0; + *p++ = 0; + } +} + +/* This function is responsible for generating the ECU's output + * in the event that the Radio Subsystem does not have a good + * traffic frame - conditions corresponding to BFI=1 in the specs. + */ +static void fr_ecu_output(struct fr_ecu_state *fr, uint8_t *frame) +{ + bool mute; + + switch (fr->pr_state) { + case STATE_NO_DATA: + memcpy(frame, osmo_gsm611_silence_frame, GSM_FR_BYTES); + return; + case STATE_SPEECH: + /* TS 46.011 chapter 6: "The first lost speech frame is + * replaced at the speech decoder input by the previous + * good speech frame." */ + memcpy(frame, fr->speech_frame, GSM_FR_BYTES); + fr->pr_state = STATE_SP_MUTING; + return; + case STATE_SP_MUTING: + mute = reduce_xmaxc(fr->speech_frame); + memcpy(frame, fr->speech_frame, GSM_FR_BYTES); + random_grid_pos(fr, frame); + if (mute) + fr->pr_state = STATE_NO_DATA; + return; + case STATE_SID: + fr->sid_reemit_count++; + if (fr->sid_reemit_count >= 48) { + fr->pr_state = STATE_SID_MUTING; + reduce_xmaxc_sid(fr); + } + reemit_sid(fr, frame); + return; + case STATE_SID_MUTING: + if (reduce_xmaxc_sid(fr)) { + fr->pr_state = STATE_NO_DATA; + memcpy(frame, osmo_gsm611_silence_frame, GSM_FR_BYTES); + } else + reemit_sid(fr, frame); + return; + default: + /* a severe bug in the state machine! */ + OSMO_ASSERT(0); + } +} + /*********************************************************************** * Integration with ECU core ***********************************************************************/ @@ -31,7 +280,8 @@ static struct osmo_ecu_state *ecu_fr_init(void *ctx, enum osmo_ecu_codec codec) { struct osmo_ecu_state *st; - size_t size = sizeof(*st) + sizeof(struct osmo_ecu_fr_state); + struct fr_ecu_state *fr; + size_t size = sizeof(*st) + sizeof(*fr); st = talloc_named_const(ctx, size, "ecu_state_FR"); if (!st) @@ -39,6 +289,9 @@ memset(st, 0, size); st->codec = codec; + fr = (struct fr_ecu_state *) &st->data; + fr->pr_state = STATE_NO_DATA; + osmo_prbs_state_init(&fr->prng, &osmo_prbs15); return st; } @@ -46,22 +299,25 @@ static int ecu_fr_frame_in(struct osmo_ecu_state *st, bool bfi, const uint8_t *frame, unsigned int frame_bytes) { - struct osmo_ecu_fr_state *fr = (struct osmo_ecu_fr_state *) &st->data; + struct fr_ecu_state *fr = (struct fr_ecu_state *) &st->data; + if (bfi) return 0; + if (frame_bytes != GSM_FR_BYTES) + return 0; + if ((frame[0] & 0xF0) != 0xD0) + return 0; - osmo_ecu_fr_reset(fr, frame); + fr_ecu_input(fr, frame); return 0; } static int ecu_fr_frame_out(struct osmo_ecu_state *st, uint8_t *frame_out) { - struct osmo_ecu_fr_state *fr = (struct osmo_ecu_fr_state *) &st->data; + struct fr_ecu_state *fr = (struct fr_ecu_state *) &st->data; - if (osmo_ecu_fr_conceal(fr, frame_out) == 0) - return GSM_FR_BYTES; - else - return -1; + fr_ecu_output(fr, frame_out); + return GSM_FR_BYTES; } static const struct osmo_ecu_ops osmo_ecu_ops_fr = { diff --git a/tests/codec/codec_ecu_fr_test.c b/tests/codec/codec_ecu_fr_test.c index a9dae89..4e5b71d 100644 --- a/tests/codec/codec_ecu_fr_test.c +++ b/tests/codec/codec_ecu_fr_test.c @@ -151,7 +151,7 @@ int i, rc; int j = 0; - printf("=> Testing FR concealment (simple, consecutive bad frames)\n"); + printf("=> Testing FR concealment (simple, using ECU abstraction)\n"); while (sample_frame_hex[j] != NULL) { /* Parse frame from string to hex */ diff --git a/tests/codec/codec_ecu_fr_test.ok b/tests/codec/codec_ecu_fr_test.ok index d925e28..ed5eb9d 100644 --- a/tests/codec/codec_ecu_fr_test.ok +++ b/tests/codec/codec_ecu_fr_test.ok @@ -41,49 +41,49 @@ conceal: 17, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] conceal: 18, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] conceal: 19, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -=> Testing FR concealment (simple, consecutive bad frames) +=> Testing FR concealment (simple, using ECU abstraction) Start with: d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da, XMAXC: [3f, 3f, 3f, 3f] conceal: 00, result: d9ec9be212901f802335598c501f805bad3d4ba01f809b69df5a501f809cd1b4da XMAXC: [3f, 3f, 3f, 3f] -conceal: 01, result: d9ec9be212901d802335598c501d805bad3d4ba01d809b69df5a501d809cd1b4da XMAXC: [3b, 3b, 3b, 3b] -conceal: 02, result: d9ec9be212901b802335598c501b805bad3d4ba01b809b69df5a501b809cd1b4da XMAXC: [37, 37, 37, 37] +conceal: 01, result: d9ec9be212905d802335598c501d805bad3d4ba01d809b69df5a501d809cd1b4da XMAXC: [3b, 3b, 3b, 3b] +conceal: 02, result: d9ec9be212901b802335598c501b805bad3d4ba01b809b69df5a507b809cd1b4da XMAXC: [37, 37, 37, 37] conceal: 03, result: d9ec9be2129019802335598c5019805bad3d4ba019809b69df5a5019809cd1b4da XMAXC: [33, 33, 33, 33] -conceal: 04, result: d9ec9be2129017802335598c5017805bad3d4ba017809b69df5a5017809cd1b4da XMAXC: [2f, 2f, 2f, 2f] +conceal: 04, result: d9ec9be2129017802335598c5017805bad3d4ba057809b69df5a5057809cd1b4da XMAXC: [2f, 2f, 2f, 2f] conceal: 05, result: d9ec9be2129015802335598c5015805bad3d4ba015809b69df5a5015809cd1b4da XMAXC: [2b, 2b, 2b, 2b] -conceal: 06, result: d9ec9be2129013802335598c5013805bad3d4ba013809b69df5a5013809cd1b4da XMAXC: [27, 27, 27, 27] +conceal: 06, result: d9ec9be2129013802335598c5073805bad3d4ba073809b69df5a5013809cd1b4da XMAXC: [27, 27, 27, 27] conceal: 07, result: d9ec9be2129011802335598c5011805bad3d4ba011809b69df5a5011809cd1b4da XMAXC: [23, 23, 23, 23] -conceal: 08, result: d9ec9be212900f802335598c500f805bad3d4ba00f809b69df5a500f809cd1b4da XMAXC: [1f, 1f, 1f, 1f] -conceal: 09, result: d9ec9be212900d802335598c500d805bad3d4ba00d809b69df5a500d809cd1b4da XMAXC: [1b, 1b, 1b, 1b] -conceal: 10, result: d9ec9be212900b802335598c500b805bad3d4ba00b809b69df5a500b809cd1b4da XMAXC: [17, 17, 17, 17] -conceal: 11, result: d9ec9be2129009802335598c5009805bad3d4ba009809b69df5a5009809cd1b4da XMAXC: [13, 13, 13, 13] -conceal: 12, result: d9ec9be2129007802335598c5007805bad3d4ba007809b69df5a5007809cd1b4da XMAXC: [f, f, f, f] -conceal: 13, result: d9ec9be2129005802335598c5005805bad3d4ba005809b69df5a5005809cd1b4da XMAXC: [b, b, b, b] -conceal: 14, result: d9ec9be2129003802335598c5003805bad3d4ba003809b69df5a5003809cd1b4da XMAXC: [7, 7, 7, 7] -conceal: 15, result: d9ec9be2129001802335598c5001805bad3d4ba001809b69df5a5001809cd1b4da XMAXC: [3, 3, 3, 3] -conceal: 16, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -conceal: 17, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -conceal: 18, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -conceal: 19, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] +conceal: 08, result: d9ec9be212904f802335598c500f805bad3d4ba04f809b69df5a500f809cd1b4da XMAXC: [1f, 1f, 1f, 1f] +conceal: 09, result: d9ec9be212900d802335598c500d805bad3d4ba00d809b69df5a506d809cd1b4da XMAXC: [1b, 1b, 1b, 1b] +conceal: 10, result: d9ec9be212900b802335598c506b805bad3d4ba00b809b69df5a500b809cd1b4da XMAXC: [17, 17, 17, 17] +conceal: 11, result: d9ec9be2129009802335598c5009805bad3d4ba049809b69df5a5049809cd1b4da XMAXC: [13, 13, 13, 13] +conceal: 12, result: d9ec9be2129047802335598c5047805bad3d4ba007809b69df5a5007809cd1b4da XMAXC: [f, f, f, f] +conceal: 13, result: d9ec9be2129005802335598c5065805bad3d4ba065809b69df5a5065809cd1b4da XMAXC: [b, b, b, b] +conceal: 14, result: d9ec9be2129063802335598c5003805bad3d4ba003809b69df5a5003809cd1b4da XMAXC: [7, 7, 7, 7] +conceal: 15, result: d9ec9be2129041802335598c5001805bad3d4ba001809b69df5a5001809cd1b4da XMAXC: [3, 3, 3, 3] +conceal: 16, result: d9ec9be2129040002335598c5000005bad3d4ba000009b69df5a5060009cd1b4da XMAXC: [0, 0, 0, 0] +conceal: 17, result: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b XMAXC: [0, 0, 0, 0] +conceal: 18, result: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b XMAXC: [0, 0, 0, 0] +conceal: 19, result: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b XMAXC: [0, 0, 0, 0] Start with: d9ec9be212901d802335598c5013805bad3d4ba01f809b69df5a5019809cd1b4da, XMAXC: [3b, 27, 3f, 33] conceal: 00, result: d9ec9be212901d802335598c5013805bad3d4ba01f809b69df5a5019809cd1b4da XMAXC: [3b, 27, 3f, 33] -conceal: 01, result: d9ec9be212901b802335598c5011805bad3d4ba01d809b69df5a5017809cd1b4da XMAXC: [37, 23, 3b, 2f] -conceal: 02, result: d9ec9be2129019802335598c500f805bad3d4ba01b809b69df5a5015809cd1b4da XMAXC: [33, 1f, 37, 2b] -conceal: 03, result: d9ec9be2129017802335598c500d805bad3d4ba019809b69df5a5013809cd1b4da XMAXC: [2f, 1b, 33, 27] -conceal: 04, result: d9ec9be2129015802335598c500b805bad3d4ba017809b69df5a5011809cd1b4da XMAXC: [2b, 17, 2f, 23] -conceal: 05, result: d9ec9be2129013802335598c5009805bad3d4ba015809b69df5a500f809cd1b4da XMAXC: [27, 13, 2b, 1f] -conceal: 06, result: d9ec9be2129011802335598c5007805bad3d4ba013809b69df5a500d809cd1b4da XMAXC: [23, f, 27, 1b] -conceal: 07, result: d9ec9be212900f802335598c5005805bad3d4ba011809b69df5a500b809cd1b4da XMAXC: [1f, b, 23, 17] -conceal: 08, result: d9ec9be212900d802335598c5003805bad3d4ba00f809b69df5a5009809cd1b4da XMAXC: [1b, 7, 1f, 13] -conceal: 09, result: d9ec9be212900b802335598c5001805bad3d4ba00d809b69df5a5007809cd1b4da XMAXC: [17, 3, 1b, f] -conceal: 10, result: d9ec9be2129009802335598c5000005bad3d4ba00b809b69df5a5005809cd1b4da XMAXC: [13, 0, 17, b] -conceal: 11, result: d9ec9be2129007802335598c5000005bad3d4ba009809b69df5a5003809cd1b4da XMAXC: [f, 0, 13, 7] -conceal: 12, result: d9ec9be2129005802335598c5000005bad3d4ba007809b69df5a5001809cd1b4da XMAXC: [b, 0, f, 3] -conceal: 13, result: d9ec9be2129003802335598c5000005bad3d4ba005809b69df5a5000009cd1b4da XMAXC: [7, 0, b, 0] -conceal: 14, result: d9ec9be2129001802335598c5000005bad3d4ba003809b69df5a5000009cd1b4da XMAXC: [3, 0, 7, 0] -conceal: 15, result: d9ec9be2129000002335598c5000005bad3d4ba001809b69df5a5000009cd1b4da XMAXC: [0, 0, 3, 0] -conceal: 16, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -conceal: 17, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -conceal: 18, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] -conceal: 19, result: d00000000000000000000000000000000000000000000000000000000000000000 XMAXC: [0, 0, 0, 0] +conceal: 01, result: d9ec9be212901b802335598c5011805bad3d4ba01d809b69df5a5077809cd1b4da XMAXC: [37, 23, 3b, 2f] +conceal: 02, result: d9ec9be2129019802335598c500f805bad3d4ba05b809b69df5a5055809cd1b4da XMAXC: [33, 1f, 37, 2b] +conceal: 03, result: d9ec9be2129017802335598c500d805bad3d4ba059809b69df5a5053809cd1b4da XMAXC: [2f, 1b, 33, 27] +conceal: 04, result: d9ec9be2129015802335598c506b805bad3d4ba077809b69df5a5011809cd1b4da XMAXC: [2b, 17, 2f, 23] +conceal: 05, result: d9ec9be2129013802335598c5069805bad3d4ba075809b69df5a500f809cd1b4da XMAXC: [27, 13, 2b, 1f] +conceal: 06, result: d9ec9be2129051802335598c5007805bad3d4ba053809b69df5a500d809cd1b4da XMAXC: [23, f, 27, 1b] +conceal: 07, result: d9ec9be212904f802335598c5005805bad3d4ba051809b69df5a506b809cd1b4da XMAXC: [1f, b, 23, 17] +conceal: 08, result: d9ec9be212900d802335598c5063805bad3d4ba00f809b69df5a5069809cd1b4da XMAXC: [1b, 7, 1f, 13] +conceal: 09, result: d9ec9be212900b802335598c5061805bad3d4ba04d809b69df5a5047809cd1b4da XMAXC: [17, 3, 1b, f] +conceal: 10, result: d9ec9be2129049802335598c5040005bad3d4ba04b809b69df5a5045809cd1b4da XMAXC: [13, 0, 17, b] +conceal: 11, result: d9ec9be2129047802335598c5020005bad3d4ba069809b69df5a5063809cd1b4da XMAXC: [f, 0, 13, 7] +conceal: 12, result: d9ec9be2129065802335598c5060005bad3d4ba067809b69df5a5061809cd1b4da XMAXC: [b, 0, f, 3] +conceal: 13, result: d9ec9be2129023802335598c5000005bad3d4ba005809b69df5a5000009cd1b4da XMAXC: [7, 0, b, 0] +conceal: 14, result: d9ec9be2129001802335598c5000005bad3d4ba003809b69df5a5060009cd1b4da XMAXC: [3, 0, 7, 0] +conceal: 15, result: d9ec9be2129040002335598c5000005bad3d4ba001809b69df5a5000009cd1b4da XMAXC: [0, 0, 3, 0] +conceal: 16, result: d9ec9be2129000002335598c5000005bad3d4ba040009b69df5a5020009cd1b4da XMAXC: [0, 0, 0, 0] +conceal: 17, result: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b XMAXC: [0, 0, 0, 0] +conceal: 18, result: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b XMAXC: [0, 0, 0, 0] +conceal: 19, result: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b XMAXC: [0, 0, 0, 0] => Testing FR concealment (realistic, various bad frames) Frame No. 000: @@ -318,7 +318,7 @@ * output: d9689ba5e3d260491b516adb5e4027256e27227ee0351c8e549a5c60492471971b Frame No. 019: * input: (bad) - * output: d00000000000000000000000000000000000000000000000000000000000000000 + * output: d9689ba5e3d240491b516adb5e0027256e27227e80351c8e549a5c00492471971b Frame No. 020: * input: d8e6a2e1d3d2605b1376c8d35280392451391cbc80392a71b6db8aa049238dc8ab * output: d8e6a2e1d3d2605b1376c8d35280392451391cbc80392a71b6db8aa049238dc8ab @@ -357,19 +357,19 @@ * output: d9a99361a276403b1a6ad6dcd40026e489c8e3bc40371c4dc564e2c036e28eb963 Frame No. 032: * input: (bad) - * output: d00000000000000000000000000000000000000000000000000000000000000000 + * output: d9a99361a276003b1a6ad6dcd40026e489c8e3bc00371c4dc564e2e036e28eb963 Frame No. 033: * input: (bad) - * output: d00000000000000000000000000000000000000000000000000000000000000000 + * output: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b Frame No. 034: * input: (bad) - * output: d00000000000000000000000000000000000000000000000000000000000000000 + * output: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b Frame No. 035: * input: (bad) - * output: d00000000000000000000000000000000000000000000000000000000000000000 + * output: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b Frame No. 036: * input: (bad) - * output: d00000000000000000000000000000000000000000000000000000000000000000 + * output: daa7aaa51a502038e46db91b502038e46db91b502038e46db91b502038e46db91b Frame No. 037: * input: d92c8b6d5aee4034ebb22724862047145634a5c0a038e371b8e4a880485c89dd25 * output: d92c8b6d5aee4034ebb22724862047145634a5c0a038e371b8e4a880485c89dd25 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32685 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I0200e423ca6165c1313ec9a4effc3f3047f5f032 Gerrit-Change-Number: 32685 Gerrit-PatchSet: 4 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: Generalize subscriber SIM insert API
by pespin 17 May '23

17 May '23
pespin has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/osmocom-bb/+/32751 ) Change subject: layer23: Generalize subscriber SIM insert API ...................................................................... layer23: Generalize subscriber SIM insert API With this patch, during VTY config the SIM type is selected, and the app calls a generic gsm_subscriber_insert() API which will take of internally initializing and starting whatever specific-backend setup is needed. Change-Id: I5aa34ae297ec0114e1d2355d59fdd77b43b35464 --- M src/host/layer23/include/osmocom/bb/common/subscriber.h M src/host/layer23/src/common/subscriber.c M src/host/layer23/src/common/vty.c M src/host/layer23/src/mobile/app_mobile.c M src/host/layer23/src/modem/app_modem.c 5 files changed, 81 insertions(+), 80 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/51/32751/2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32751 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I5aa34ae297ec0114e1d2355d59fdd77b43b35464 Gerrit-Change-Number: 32751 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: Move SAP init/close to be done during MS allocation/destruction
by pespin 17 May '23

17 May '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32750 ) Change subject: layer23: Move SAP init/close to be done during MS allocation/destruction ...................................................................... layer23: Move SAP init/close to be done during MS allocation/destruction Change-Id: Ic20760228668db4cb2fc6cdea4fd0470c211ce0a --- M src/host/layer23/src/common/ms.c M src/host/layer23/src/mobile/app_mobile.c 2 files changed, 19 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/50/32750/1 diff --git a/src/host/layer23/src/common/ms.c b/src/host/layer23/src/common/ms.c index f03427c..a970036 100644 --- a/src/host/layer23/src/common/ms.c +++ b/src/host/layer23/src/common/ms.c @@ -27,6 +27,12 @@ static int osmocom_ms_talloc_destructor(struct osmocom_ms *ms) { + + if (ms->sap_wq.bfd.fd > -1) { + sap_close(ms); + ms->sap_wq.bfd.fd = -1; + } + gprs_settings_fi(ms); gsm_subscr_exit(ms); gsm_sim_exit(ms); @@ -63,6 +69,10 @@ gsm_support_init(ms); gsm_settings_init(ms); gprs_settings_init(ms); + /* init SAP client before SIM card starts up */ + sap_init(ms); + /* SAP response call-back */ + ms->sap_entity.sap_rsp_cb = &gsm_subscr_sap_rsp_cb; gsm_sim_init(ms); gsm_subscr_init(ms); diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index b314c29..76f11f3 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -260,12 +260,6 @@ GSM_LCHAN_SDCCH, NULL); lapdm_channel_set_l1(&ms->lapdm_channel, l1ctl_ph_prim_cb, ms); - /* init SAP client before SIM card starts up */ - sap_init(ms); - - /* SAP response call-back */ - ms->sap_entity.sap_rsp_cb = &gsm_subscr_sap_rsp_cb; - gsm_sim_init(ms); gsm48_cc_init(ms); gsm480_ss_init(ms); @@ -448,12 +442,6 @@ layer2_close(ms); ms->l2_wq.bfd.fd = -1; } - - if (ms->sap_wq.bfd.fd > -1) { - sap_close(ms); - ms->sap_wq.bfd.fd = -1; - } - if (ms->deleting) { gsm_settings_exit(ms); script_lua_close(ms); -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32750 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ic20760228668db4cb2fc6cdea4fd0470c211ce0a Gerrit-Change-Number: 32750 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmocom-bb[master]: layer23: Generalize subscriber SIM insert API
by pespin 17 May '23

17 May '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32751 ) Change subject: layer23: Generalize subscriber SIM insert API ...................................................................... layer23: Generalize subscriber SIM insert API With this patch, during VTY config the SIM type is selected, and the app calls a generic gsm_subscriber_insert() API which will take of internally initializing and starting whatever specific-backend setup is needed. Change-Id: I5aa34ae297ec0114e1d2355d59fdd77b43b35464 --- M src/host/layer23/include/osmocom/bb/common/subscriber.h M src/host/layer23/src/common/subscriber.c M src/host/layer23/src/common/vty.c M src/host/layer23/src/mobile/app_mobile.c M src/host/layer23/src/modem/app_modem.c 5 files changed, 78 insertions(+), 80 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/51/32751/1 diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h index 8f0966e..8119103 100644 --- a/src/host/layer23/include/osmocom/bb/common/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h @@ -32,7 +32,7 @@ #define GSM_SIM_IS_READER(type) \ (type == GSM_SIM_TYPE_L1PHY || type == GSM_SIM_TYPE_SAP) -enum { +enum gsm_subscriber_sim_type { GSM_SIM_TYPE_NONE = 0, GSM_SIM_TYPE_L1PHY, GSM_SIM_TYPE_TEST, @@ -43,8 +43,8 @@ struct osmocom_ms *ms; /* status */ - uint8_t sim_type; /* type of sim */ - uint8_t sim_valid; /* sim inserted and valid */ + enum gsm_subscriber_sim_type sim_type; /* type of sim */ + bool sim_valid; /* sim inserted and valid */ enum gsm_sub_sim_ustate ustate; /* update status */ uint8_t imsi_attached; /* attached state */ @@ -98,17 +98,16 @@ int gsm_subscr_init(struct osmocom_ms *ms); int gsm_subscr_exit(struct osmocom_ms *ms); -int gsm_subscr_testcard(struct osmocom_ms *ms); +int gsm_subscr_insert(struct osmocom_ms *ms); +int gsm_subscr_remove(struct osmocom_ms *ms); + int gsm_subscr_sap_rsp_cb(struct osmocom_ms *ms, int res_code, uint8_t res_type, uint16_t param_len, const uint8_t *param_val); -int gsm_subscr_sapcard(struct osmocom_ms *ms); -int gsm_subscr_simcard(struct osmocom_ms *ms); void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2, int8_t mode); int gsm_subscr_write_loci(struct osmocom_ms *ms); int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq, uint8_t *rand, uint8_t no_sim); -int gsm_subscr_remove(struct osmocom_ms *ms); void new_sim_ustate(struct gsm_subscriber *subscr, int state); int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc, uint16_t mnc); diff --git a/src/host/layer23/src/common/subscriber.c b/src/host/layer23/src/common/subscriber.c index a5d5e8a..617ba58 100644 --- a/src/host/layer23/src/common/subscriber.c +++ b/src/host/layer23/src/common/subscriber.c @@ -37,6 +37,10 @@ * if list is changed, the result is not written back to SIM */ //#define TEST_EMPTY_FPLMN +static int gsm_subscr_insert_simcard(struct osmocom_ms *ms); +static int gsm_subscr_insert_testcard(struct osmocom_ms *ms); +static int gsm_subscr_insert_sapcard(struct osmocom_ms *ms); + static void subscr_sim_query_cb(struct osmocom_ms *ms, struct msgb *msg); static void subscr_sim_update_cb(struct osmocom_ms *ms, struct msgb *msg); static void subscr_sim_key_cb(struct osmocom_ms *ms, struct msgb *msg); @@ -136,29 +140,17 @@ */ /* Attach test card, no SIM must be currently attached */ -int gsm_subscr_testcard(struct osmocom_ms *ms) +int gsm_subscr_insert_testcard(struct osmocom_ms *ms) { struct gsm_settings *set = &ms->settings; struct gsm_subscriber *subscr = &ms->subscr; - if (subscr->sim_valid) { - LOGP(DMM, LOGL_ERROR, "Cannot insert card, until current card " - "is detached.\n"); - return -EBUSY; - } - if (!osmo_imsi_str_valid(set->test_sim.imsi)) { LOGP(DMM, LOGL_ERROR, "Wrong IMSI format\n"); return -EINVAL; } - /* reset subscriber */ - gsm_subscr_exit(ms); - gsm_subscr_init(ms); - - subscr->sim_type = GSM_SIM_TYPE_TEST; sprintf(subscr->sim_name, "test"); - subscr->sim_valid = 1; subscr->imsi_attached = set->test_sim.imsi_attached; subscr->acc_barr = set->test_sim.barr; /* we may access barred cell */ subscr->acc_class = 0xffff; /* we have any access class */ @@ -723,23 +715,11 @@ } /* Attach SIM reader, no SIM must be currently attached */ -int gsm_subscr_simcard(struct osmocom_ms *ms) +int gsm_subscr_insert_simcard(struct osmocom_ms *ms) { struct gsm_subscriber *subscr = &ms->subscr; - if (subscr->sim_valid) { - LOGP(DMM, LOGL_ERROR, "Cannot attach card, until current card " - "is detached.\n"); - return -EBUSY; - } - - /* reset subscriber */ - gsm_subscr_exit(ms); - gsm_subscr_init(ms); - - subscr->sim_type = GSM_SIM_TYPE_L1PHY; sprintf(subscr->sim_name, "sim"); - subscr->sim_valid = 1; subscr->ustate = GSM_SIM_U2_NOT_UPDATED; /* start with first index */ @@ -993,9 +973,45 @@ } /* - * detach + * generic */ +int gsm_subscr_insert(struct osmocom_ms *ms) +{ + struct gsm_settings *set = &ms->settings; + struct gsm_subscriber *subscr = &ms->subscr; + int rc; + + if (subscr->sim_valid) { + LOGP(DMM, LOGL_ERROR, "Cannot insert card, until current card is removed.\n"); + return -EBUSY; + } + + /* reset subscriber */ + gsm_subscr_exit(ms); + gsm_subscr_init(ms); + + subscr->sim_valid = true; + + switch (set->sim_type) { + case GSM_SIM_TYPE_L1PHY: + /* trigger sim card reader process */ + rc = gsm_subscr_insert_simcard(ms); + case GSM_SIM_TYPE_TEST: + rc = gsm_subscr_insert_testcard(ms); + case GSM_SIM_TYPE_SAP: + rc = gsm_subscr_insert_sapcard(ms); + default: + return -EINVAL; + } + + if (rc < 0) { + subscr->sim_valid = false; + return rc; + } + +} + static int gsm_subscr_remove_sapcard(struct osmocom_ms *ms); /* Detach card */ @@ -1223,24 +1239,12 @@ */ /* Attach SIM card over SAP */ -int gsm_subscr_sapcard(struct osmocom_ms *ms) +int gsm_subscr_insert_sapcard(struct osmocom_ms *ms) { struct gsm_subscriber *subscr = &ms->subscr; int rc; - if (subscr->sim_valid) { - LOGP(DMM, LOGL_ERROR, "Cannot insert card, until current card " - "is detached.\n"); - return -EBUSY; - } - - /* reset subscriber */ - gsm_subscr_exit(ms); - gsm_subscr_init(ms); - - subscr->sim_type = GSM_SIM_TYPE_SAP; sprintf(subscr->sim_name, "sap"); - subscr->sim_valid = 1; /* Try to connect to the SAP interface */ l23_vty_ms_notify(ms, NULL); diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c index a48eaa9..69a3dce 100644 --- a/src/host/layer23/src/common/vty.c +++ b/src/host/layer23/src/common/vty.c @@ -495,6 +495,7 @@ return CMD_WARNING; } + ms->subscr.sim_type = GSM_SIM_TYPE_TEST; set = &ms->settings; if (argc == 2) { @@ -527,7 +528,7 @@ set->test_sim.imsi_attached = attached; - rc = gsm_subscr_testcard(ms); + rc = gsm_subscr_insert(ms); if (rc < 0) { vty_out(vty, "Attach test SIM card failed: %d%s", rc, VTY_NEWLINE); return CMD_WARNING; @@ -573,7 +574,8 @@ return CMD_WARNING; } - if (gsm_subscr_sapcard(ms) != 0) + ms->subscr.sim_type = GSM_SIM_TYPE_SAP; + if (gsm_subscr_insert(ms) != 0) return CMD_WARNING; return CMD_SUCCESS; @@ -594,7 +596,8 @@ return CMD_WARNING; } - gsm_subscr_simcard(ms); + ms->subscr.sim_type = GSM_SIM_TYPE_L1PHY; + gsm_subscr_insert(ms); return CMD_SUCCESS; } diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index 76f11f3..9ce1ad2 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -139,7 +139,6 @@ void *handler_data, void *signal_data) { struct osmocom_ms *ms; - struct gsm_settings *set; struct msgb *nmsg; if (subsys != SS_L1CTL) @@ -148,7 +147,6 @@ switch (signal) { case S_L1CTL_RESET: ms = signal_data; - set = &ms->settings; /* waiting for reset after shutdown */ if (ms->shutdown == MS_SHUTDOWN_WAIT_RESET) { @@ -160,19 +158,10 @@ if (ms->started) break; - /* insert test card, if enabled */ - switch (set->sim_type) { - case GSM_SIM_TYPE_L1PHY: - /* trigger sim card reader process */ - gsm_subscr_simcard(ms); - break; - case GSM_SIM_TYPE_TEST: - gsm_subscr_testcard(ms); - break; - case GSM_SIM_TYPE_SAP: - gsm_subscr_sapcard(ms); - break; - default: + if (ms->settings.sim_type != GSM_SIM_TYPE_NONE) { + /* insert sim card */ + gsm_subscr_insert(ms); + } else { /* no SIM, trigger PLMN selection process */ nmsg = gsm322_msgb_alloc(GSM322_EVENT_SWITCH_ON); if (!nmsg) diff --git a/src/host/layer23/src/modem/app_modem.c b/src/host/layer23/src/modem/app_modem.c index da1a37f..805b5b1 100644 --- a/src/host/layer23/src/modem/app_modem.c +++ b/src/host/layer23/src/modem/app_modem.c @@ -194,7 +194,6 @@ void *handler_data, void *signal_data) { struct osmocom_ms *ms; - struct gsm_settings *set; if (subsys != SS_L1CTL) return 0; @@ -206,24 +205,14 @@ app_data.ms = ms; /* insert test card, if enabled */ - set = &ms->settings; - switch (set->sim_type) { - case GSM_SIM_TYPE_L1PHY: - /* trigger sim card reader process */ - gsm_subscr_simcard(ms); - break; - case GSM_SIM_TYPE_TEST: - gsm_subscr_testcard(ms); - break; - case GSM_SIM_TYPE_SAP: - gsm_subscr_sapcard(ms); - break; - default: + if (ms->settings.sim_type != GSM_SIM_TYPE_NONE) { + /* insert sim card */ + gsm_subscr_insert(ms); + } else { /* No SIM, trigger PLMN selection process. * FIXME: not implemented. Code in mobile needs to be * moved to common/ and reuse it here. */ - break; } ms->started = true; -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32751 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I5aa34ae297ec0114e1d2355d59fdd77b43b35464 Gerrit-Change-Number: 32751 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: subscriber: Move sap specific code inside subscriber.c
by fixeria 17 May '23

17 May '23
Attention is currently required from: pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32749 ) Change subject: layer23: subscriber: Move sap specific code inside subscriber.c ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32749 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I780f06203cd6971866d81060a5ecee8bc00782f4 Gerrit-Change-Number: 32749 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Wed, 17 May 2023 12:56:10 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: subscriber: Move sap specific code inside subscriber.c
by pespin 17 May '23

17 May '23
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32749 ) Change subject: layer23: subscriber: Move sap specific code inside subscriber.c ...................................................................... layer23: subscriber: Move sap specific code inside subscriber.c Step forward towards a generic subscriber interface. Change-Id: I780f06203cd6971866d81060a5ecee8bc00782f4 --- M src/host/layer23/include/osmocom/bb/common/subscriber.h M src/host/layer23/src/common/subscriber.c M src/host/layer23/src/common/vty.c 3 files changed, 17 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/49/32749/1 diff --git a/src/host/layer23/include/osmocom/bb/common/subscriber.h b/src/host/layer23/include/osmocom/bb/common/subscriber.h index 72f65f0..8f0966e 100644 --- a/src/host/layer23/include/osmocom/bb/common/subscriber.h +++ b/src/host/layer23/include/osmocom/bb/common/subscriber.h @@ -102,7 +102,6 @@ int gsm_subscr_sap_rsp_cb(struct osmocom_ms *ms, int res_code, uint8_t res_type, uint16_t param_len, const uint8_t *param_val); int gsm_subscr_sapcard(struct osmocom_ms *ms); -int gsm_subscr_remove_sapcard(struct osmocom_ms *ms); int gsm_subscr_simcard(struct osmocom_ms *ms); void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2, int8_t mode); diff --git a/src/host/layer23/src/common/subscriber.c b/src/host/layer23/src/common/subscriber.c index d5d0604..a5d5e8a 100644 --- a/src/host/layer23/src/common/subscriber.c +++ b/src/host/layer23/src/common/subscriber.c @@ -996,6 +996,8 @@ * detach */ +static int gsm_subscr_remove_sapcard(struct osmocom_ms *ms); + /* Detach card */ int gsm_subscr_remove(struct osmocom_ms *ms) { @@ -1006,6 +1008,9 @@ return -EINVAL; } + if (subscr->sim_type == GSM_SIM_TYPE_SAP) + gsm_subscr_remove_sapcard(ms); + /* remove card */ osmo_signal_dispatch(SS_L23_SUBSCR, S_L23_SUBSCR_SIM_DETACHED, ms); @@ -1257,7 +1262,7 @@ } /* Deattach sapcard */ -int gsm_subscr_remove_sapcard(struct osmocom_ms *ms) +static int gsm_subscr_remove_sapcard(struct osmocom_ms *ms) { return sap_close(ms); } diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c index 8da9a87..a48eaa9 100644 --- a/src/host/layer23/src/common/vty.c +++ b/src/host/layer23/src/common/vty.c @@ -613,9 +613,6 @@ return CMD_WARNING; } - if (ms->subscr.sim_type == GSM_SIM_TYPE_SAP) - gsm_subscr_remove_sapcard(ms); - gsm_subscr_remove(ms); return CMD_SUCCESS; } -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/32749 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I780f06203cd6971866d81060a5ecee8bc00782f4 Gerrit-Change-Number: 32749 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: setup.py: add missing packages for pySim-trace.py
by fixeria 17 May '23

17 May '23
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/32732 ) Change subject: setup.py: add missing packages for pySim-trace.py ...................................................................... Patch Set 1: (1 comment) Patchset: PS1: > thanks, you can see I still have limited experiences with python packaging. Neither I am experienced in this area. I just see bugs and fix them :P -- To view, visit https://gerrit.osmocom.org/c/pysim/+/32732 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I371143cb4009db46275ec7a020497b909dcc3b4e Gerrit-Change-Number: 32732 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Wed, 17 May 2023 11:25:47 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: setup.py: add missing packages for pySim-trace.py
by laforge 17 May '23

17 May '23
Attention is currently required from: fixeria. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/32732 ) Change subject: setup.py: add missing packages for pySim-trace.py ...................................................................... Patch Set 1: Code-Review+1 (1 comment) Patchset: PS1: thanks, you can see I still have limited experiences with python packaging. -- To view, visit https://gerrit.osmocom.org/c/pysim/+/32732 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I371143cb4009db46275ec7a020497b909dcc3b4e Gerrit-Change-Number: 32732 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Wed, 17 May 2023 11:23:02 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-hnbgw[master]: fix missing write-back of rnc-id
by laforge 17 May '23

17 May '23
Attention is currently required from: neels. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32716 ) Change subject: fix missing write-back of rnc-id ...................................................................... Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32716 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Ide006379b26949e34371bd316a22c130ea09da82 Gerrit-Change-Number: 32716 Gerrit-PatchSet: 4 Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Comment-Date: Wed, 17 May 2023 11:22:22 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • ...
  • 259
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.