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 -----
  • 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

January 2024

  • 1 participants
  • 1559 discussions
[S] Change in osmo-hnbgw[master]: Display RANAP state during 'show cnlink'
by fixeria 15 Jan '24

15 Jan '24
Attention is currently required from: laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/35568?usp=email ) Change subject: Display RANAP state during 'show cnlink' ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/35568?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: I6ab7d08fcd0631d31a12418f950c5901a93db43a Gerrit-Change-Number: 35568 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Mon, 15 Jan 2024 19:03:50 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmocom-bb[master]: mobile: store MNCC Bearer Capability in CC transaction
by pespin 15 Jan '24

15 Jan '24
Attention is currently required from: fixeria. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35578?usp=email ) Change subject: mobile: store MNCC Bearer Capability in CC transaction ...................................................................... Patch Set 1: Code-Review+1 (1 comment) File src/host/layer23/src/mobile/gsm48_cc.c: https://gerrit.osmocom.org/c/osmocom-bb/+/35578/comment/20efa62d_e7cf201a PS1, Line 187: uint32_t msg_type, struct gsm_mncc *mncc) unrelated change. -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35578?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ifc3ecf832a552c65444f49711ac836b6cd984715 Gerrit-Change-Number: 35578 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Jan 2024 18:46:42 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in osmocom-bb[master]: mobile: always check return value of tlv_parse()
by pespin 15 Jan '24

15 Jan '24
Attention is currently required from: fixeria. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35576?usp=email ) Change subject: mobile: always check return value of tlv_parse() ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35576?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Id02fc0b1af6da939cb72f327c7d2ddca484ca063 Gerrit-Change-Number: 35576 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Jan 2024 18:43:24 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmocom-bb[master]: layer23: drop unneeded forward declaration
by pespin 15 Jan '24

15 Jan '24
Attention is currently required from: fixeria. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35575?usp=email ) Change subject: layer23: drop unneeded forward declaration ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35575?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I75bd08c1a88ad75d93a519422dfb7922c37a27a3 Gerrit-Change-Number: 35575 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 15 Jan 2024 18:42:14 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[L] Change in osmocom-bb[master]: mobile: init/deinit GAPK I/O based on CC transaction events
by Jenkins Builder 15 Jan '24

15 Jan '24
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35579?usp=email ) Change subject: mobile: init/deinit GAPK I/O based on CC transaction events ...................................................................... Patch Set 1: (1 comment) File src/host/layer23/src/mobile/tch.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-13601): https://gerrit.osmocom.org/c/osmocom-bb/+/35579/comment/033142d3_6384c596 PS1, Line 122: else /* TODO: tch_recv_data() */ else is not generally useful after a break or return -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35579?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I28f87f6a6de673611aa02a24e8985aee23d4498b Gerrit-Change-Number: 35579 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Mon, 15 Jan 2024 18:39:19 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[L] Change in osmocom-bb[master]: [WIP] mobile: integrate V.110 TA & soft-UART from libosmocore
by Jenkins Builder 15 Jan '24

15 Jan '24
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35582?usp=email ) Change subject: [WIP] mobile: integrate V.110 TA & soft-UART from libosmocore ...................................................................... Patch Set 1: (2 comments) File src/host/layer23/src/mobile/tch.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-13596): https://gerrit.osmocom.org/c/osmocom-bb/+/35582/comment/c2e92626_aa6f6018 PS1, Line 171: else else is not generally useful after a break or return File src/host/layer23/src/mobile/tch_data.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-13596): https://gerrit.osmocom.org/c/osmocom-bb/+/35582/comment/31cccf2a_fa5fc9fe PS1, Line 315: #if 1 Consider removing the #if 1 and its #endif -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35582?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I7ac9c0e5010730fa4d8bc7a7a3c7ff85e11731c0 Gerrit-Change-Number: 35582 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Mon, 15 Jan 2024 18:39:03 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmocom-bb[master]: mobile: store MNCC Bearer Capability in CC transaction
by fixeria 15 Jan '24

15 Jan '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35578?usp=email ) Change subject: mobile: store MNCC Bearer Capability in CC transaction ...................................................................... mobile: store MNCC Bearer Capability in CC transaction We will need to know the current Bearer Capability of a CC transaction in the upcoming patches adding CSD support. Change-Id: Ifc3ecf832a552c65444f49711ac836b6cd984715 Related: OS#4396 --- M src/host/layer23/include/osmocom/bb/mobile/transaction.h M src/host/layer23/src/mobile/gsm48_cc.c 2 files changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/78/35578/1 diff --git a/src/host/layer23/include/osmocom/bb/mobile/transaction.h b/src/host/layer23/include/osmocom/bb/mobile/transaction.h index 103ae4e..c1e9429 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/transaction.h +++ b/src/host/layer23/include/osmocom/bb/mobile/transaction.h @@ -38,6 +38,7 @@ int T308_second; /* used to send release again */ struct osmo_timer_list timer; struct gsm_mncc msg; /* stores setup/disconnect/release message */ + struct gsm_mncc_bearer_cap *bcap; } cc; struct { /* current supp.serv. state */ diff --git a/src/host/layer23/src/mobile/gsm48_cc.c b/src/host/layer23/src/mobile/gsm48_cc.c index 523ae99..485426b 100644 --- a/src/host/layer23/src/mobile/gsm48_cc.c +++ b/src/host/layer23/src/mobile/gsm48_cc.c @@ -43,6 +43,8 @@ uint32_t callref, int location, int value); static int gsm48_cc_tx_disconnect(struct gsm_trans *trans, void *arg); static int gsm48_cc_tx_connect_ack(struct gsm_trans *trans, void *arg); +static void gsm48_cc_trans_bcap_update(struct gsm_trans *trans, + const struct gsm_mncc *mncc); /* * init @@ -182,11 +184,13 @@ /* enqueue message to application (MNCC-SAP) */ static int mncc_recvmsg(struct osmocom_ms *ms, struct gsm_trans *trans, - int msg_type, struct gsm_mncc *mncc) + uint32_t msg_type, struct gsm_mncc *mncc) { struct gsm48_cclayer *cc = &ms->cclayer; struct msgb *msg; + gsm48_cc_trans_bcap_update(trans, mncc); + if (trans) LOGP(DCC, LOGL_INFO, "(ms %s ti %x) Sending '%s' to MNCC.\n", ms->name, trans->transaction_id, @@ -370,6 +374,9 @@ { gsm48_stop_cc_timer(trans); + talloc_free(trans->cc.bcap); + trans->cc.bcap = NULL; + /* disable audio distribution */ if (trans->ms->mncc_entity.ref == trans->callref) trans->ms->mncc_entity.ref = 0; @@ -385,6 +392,16 @@ new_cc_state(trans, GSM_CSTATE_NULL); } +static void gsm48_cc_trans_bcap_update(struct gsm_trans *trans, + const struct gsm_mncc *mncc) +{ + if (~mncc->fields & MNCC_F_BEARER_CAP) + return; + if (trans->cc.bcap == NULL) + trans->cc.bcap = talloc(trans, struct gsm_mncc_bearer_cap); + memcpy(trans->cc.bcap, &mncc->bearer_cap, sizeof(mncc->bearer_cap)); +} + /* release MM connection, go NULL state, free transaction */ static int gsm48_rel_null_free(struct gsm_trans *trans) { @@ -2020,6 +2037,8 @@ } } + gsm48_cc_trans_bcap_update(trans, data); + switch (msg_type) { case GSM_TCHF_FRAME: case GSM_TCHF_FRAME_EFR: -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35578?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ifc3ecf832a552c65444f49711ac836b6cd984715 Gerrit-Change-Number: 35578 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmocom-bb[master]: mobile: rename tch_send_voice_{msg,frame}() functions
by fixeria 15 Jan '24

15 Jan '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35580?usp=email ) Change subject: mobile: rename tch_send_voice_{msg,frame}() functions ...................................................................... mobile: rename tch_send_voice_{msg,frame}() functions These functions can also be used for sending data frames (CSD). Change-Id: Ib55b4405847f2efb583f3a379ff4b6929d6d6c5b Related: OS#4396 --- M src/host/layer23/include/osmocom/bb/mobile/tch.h M src/host/layer23/src/mobile/gapk_io.c M src/host/layer23/src/mobile/gsm48_cc.c M src/host/layer23/src/mobile/tch.c 4 files changed, 21 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/80/35580/1 diff --git a/src/host/layer23/include/osmocom/bb/mobile/tch.h b/src/host/layer23/include/osmocom/bb/mobile/tch.h index 0a523c0..d2cb4bc 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/tch.h +++ b/src/host/layer23/include/osmocom/bb/mobile/tch.h @@ -19,5 +19,5 @@ int tch_init(struct osmocom_ms *ms); int tch_serve_ms(struct osmocom_ms *ms); -int tch_send_voice_msg(struct osmocom_ms *ms, struct msgb *msg); -int tch_send_voice_frame(struct osmocom_ms *ms, const struct gsm_data_frame *frame); +int tch_send_msg(struct osmocom_ms *ms, struct msgb *msg); +int tch_send_mncc_frame(struct osmocom_ms *ms, const struct gsm_data_frame *frame); diff --git a/src/host/layer23/src/mobile/gapk_io.c b/src/host/layer23/src/mobile/gapk_io.c index 0c7c2e2..db232e6 100644 --- a/src/host/layer23/src/mobile/gapk_io.c +++ b/src/host/layer23/src/mobile/gapk_io.c @@ -550,7 +550,7 @@ &state->tch_ul_fb_len); /* Push a voice frame to the lower layers */ - tch_send_voice_msg(ms, tch_msg); + tch_send_msg(ms, tch_msg); work |= 1; } diff --git a/src/host/layer23/src/mobile/gsm48_cc.c b/src/host/layer23/src/mobile/gsm48_cc.c index 485426b..a09c9fa 100644 --- a/src/host/layer23/src/mobile/gsm48_cc.c +++ b/src/host/layer23/src/mobile/gsm48_cc.c @@ -2045,7 +2045,7 @@ case GSM_TCHH_FRAME: case GSM_TCH_FRAME_AMR: case GSM_BAD_FRAME: - return tch_send_voice_frame(ms, arg); + return tch_send_mncc_frame(ms, arg); case MNCC_LCHAN_MODIFY: return 0; case MNCC_FRAME_RECV: diff --git a/src/host/layer23/src/mobile/tch.c b/src/host/layer23/src/mobile/tch.c index 67195c1..7276153 100644 --- a/src/host/layer23/src/mobile/tch.c +++ b/src/host/layer23/src/mobile/tch.c @@ -86,7 +86,7 @@ /* Remove the DL info header */ msgb_pull_to_l2(msg); /* Send voice frame back */ - return tch_send_voice_msg(ms, msg); + return tch_send_msg(ms, msg); case TCH_VOICE_IOH_MNCC_SOCK: return tch_forward_mncc(ms, msg); case TCH_VOICE_IOH_GAPK: @@ -126,14 +126,14 @@ } /* Send an Uplink voice frame to the lower layers */ -int tch_send_voice_msg(struct osmocom_ms *ms, struct msgb *msg) +int tch_send_msg(struct osmocom_ms *ms, struct msgb *msg) { /* Forward to RR */ return gsm48_rr_tx_traffic(ms, msg); } -/* tch_send_voice_msg() wrapper accepting an MNCC structure */ -int tch_send_voice_frame(struct osmocom_ms *ms, const struct gsm_data_frame *frame) +/* tch_send_msg() wrapper accepting an MNCC structure */ +int tch_send_mncc_frame(struct osmocom_ms *ms, const struct gsm_data_frame *frame) { struct msgb *nmsg; int len; @@ -162,7 +162,7 @@ nmsg->l2h = msgb_put(nmsg, len); memcpy(nmsg->l2h, frame->data, len); - return tch_send_voice_msg(ms, nmsg); + return tch_send_msg(ms, nmsg); } int tch_serve_ms(struct osmocom_ms *ms) -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35580?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ib55b4405847f2efb583f3a379ff4b6929d6d6c5b Gerrit-Change-Number: 35580 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in osmocom-bb[master]: mobile: split voice specific TCH handling into its own file
by fixeria 15 Jan '24

15 Jan '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35581?usp=email ) Change subject: mobile: split voice specific TCH handling into its own file ...................................................................... mobile: split voice specific TCH handling into its own file Change-Id: Ib917d95fe77da3e60bc932cce56714d81095c7d4 Related: OS#4396 --- M src/host/layer23/src/mobile/Makefile.am M src/host/layer23/src/mobile/tch.c A src/host/layer23/src/mobile/tch_voice.c 3 files changed, 177 insertions(+), 117 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/81/35581/1 diff --git a/src/host/layer23/src/mobile/Makefile.am b/src/host/layer23/src/mobile/Makefile.am index ed2146f..0639916 100644 --- a/src/host/layer23/src/mobile/Makefile.am +++ b/src/host/layer23/src/mobile/Makefile.am @@ -31,6 +31,7 @@ mncc_sock.c \ primitives.c \ tch.c \ + tch_voice.c \ transaction.c \ vty_interface.c \ $(NULL) diff --git a/src/host/layer23/src/mobile/tch.c b/src/host/layer23/src/mobile/tch.c index 7276153..e5599dd 100644 --- a/src/host/layer23/src/mobile/tch.c +++ b/src/host/layer23/src/mobile/tch.c @@ -30,82 +30,17 @@ #include <osmocom/bb/common/logging.h> #include <osmocom/bb/common/osmocom_data.h> #include <osmocom/bb/common/ms.h> -#include <osmocom/bb/mobile/gapk_io.h> #include <osmocom/bb/mobile/mncc.h> #include <osmocom/bb/mobile/mncc_sock.h> #include <osmocom/bb/mobile/transaction.h> #include <osmocom/bb/mobile/tch.h> -/* Forward a Downlink voice frame to the external MNCC handler */ -static int tch_forward_mncc(struct osmocom_ms *ms, struct msgb *msg) -{ - struct gsm_data_frame *mncc; +int tch_voice_state_init(struct gsm_trans *trans, + struct tch_voice_state *state); +void tch_voice_state_free(struct tch_voice_state *state); - /* Drop the l1ctl_info_dl header */ - msgb_pull_to_l2(msg); - /* push mncc header in front of data */ - mncc = (struct gsm_data_frame *) - msgb_push(msg, sizeof(struct gsm_data_frame)); - mncc->callref = ms->mncc_entity.ref; - - switch (ms->rrlayer.cd_now.mode) { - case GSM48_CMODE_SPEECH_V1: - { - const uint8_t cbits = ms->rrlayer.cd_now.chan_nr >> 3; - if (cbits == ABIS_RSL_CHAN_NR_CBITS_Bm_ACCHs) - mncc->msg_type = GSM_TCHF_FRAME; - else - mncc->msg_type = GSM_TCHH_FRAME; - break; - } - case GSM48_CMODE_SPEECH_EFR: - mncc->msg_type = GSM_TCHF_FRAME_EFR; - break; - case GSM48_CMODE_SPEECH_AMR: /* TODO: no AMR support yet */ - default: - /* TODO: print error message here */ - goto exit_free; - } - - /* distribute and then free */ - if (ms->mncc_entity.sock_state && ms->mncc_entity.ref) - return mncc_sock_from_cc(ms->mncc_entity.sock_state, msg); - -exit_free: - msgb_free(msg); - return 0; -} - -/* Receive a Downlink voice frame from the lower layers */ -static int tch_recv_voice(struct osmocom_ms *ms, struct msgb *msg) -{ - struct tch_state *state = ms->tch_state; - - switch (state->voice.handler) { - case TCH_VOICE_IOH_LOOPBACK: - /* Remove the DL info header */ - msgb_pull_to_l2(msg); - /* Send voice frame back */ - return tch_send_msg(ms, msg); - case TCH_VOICE_IOH_MNCC_SOCK: - return tch_forward_mncc(ms, msg); - case TCH_VOICE_IOH_GAPK: -#ifdef WITH_GAPK_IO - /* Enqueue a frame to the DL TCH buffer */ - if (state->voice.gapk_io != NULL) - gapk_io_enqueue_dl(state->voice.gapk_io, msg); - else - msgb_free(msg); - break; -#endif - case TCH_VOICE_IOH_L1PHY: - case TCH_VOICE_IOH_NONE: - /* Drop voice frame */ - msgb_free(msg); - } - - return 0; -} +int tch_voice_recv(struct osmocom_ms *ms, struct msgb *msg); +int tch_voice_serve_ms(struct osmocom_ms *ms); /* Receive a Downlink traffic (voice/data) frame from the lower layers */ static int tch_recv_cb(struct osmocom_ms *ms, struct msgb *msg) @@ -118,7 +53,7 @@ } if (state->voice_or_data) - return tch_recv_voice(ms, msg); + return tch_voice_recv(ms, msg); else /* TODO: tch_recv_data() */ msgb_free(msg); @@ -171,52 +106,13 @@ if (state == NULL) return 0; - if (state->voice_or_data) { -#ifdef WITH_GAPK_IO - if (state->voice.handler == TCH_VOICE_IOH_GAPK) - return gapk_io_serve_ms(ms, state->voice.gapk_io); -#endif - } + if (state->voice_or_data) + tch_voice_serve_ms(ms); + /* TODO: else tch_data_serve_ms() */ return 0; } -static int tch_state_init_voice(struct osmocom_ms *ms, - struct tch_voice_state *state) -{ - const struct gsm48_rr_cd *cd = &ms->rrlayer.cd_now; - - switch (state->handler) { -#ifdef WITH_GAPK_IO - case TCH_VOICE_IOH_GAPK: - if ((cd->chan_nr & RSL_CHAN_NR_MASK) == RSL_CHAN_Bm_ACCHs) - state->gapk_io = gapk_io_state_alloc_mode_rate(ms, cd->mode, true); - else /* RSL_CHAN_Lm_ACCHs */ - state->gapk_io = gapk_io_state_alloc_mode_rate(ms, cd->mode, false); - if (state->gapk_io == NULL) - return -1; - break; -#endif - default: - break; - } - - return 0; -} - -static void tch_state_free_voice(struct tch_voice_state *state) -{ - switch (state->handler) { -#ifdef WITH_GAPK_IO - case TCH_VOICE_IOH_GAPK: - gapk_io_state_free(state->gapk_io); - break; -#endif - default: - break; - } -} - static void tch_trans_cstate_active_cb(struct gsm_trans *trans) { struct osmocom_ms *ms = trans->ms; @@ -236,7 +132,7 @@ case GSM48_CMODE_SPEECH_AMR: state->voice_or_data = true; state->voice.handler = ms->settings.tch_voice.io_handler; - if (tch_state_init_voice(ms, &state->voice) != 0) + if (tch_voice_state_init(trans, &state->voice) != 0) goto exit_free; break; case GSM48_CMODE_DATA_14k5: @@ -246,8 +142,8 @@ #if 0 state->voice_or_data = false; state->data.handler = ms->settings.tch_data.io_handler; - /* TODO: tch_state_init_data() */ - if (tch_state_init_data(ms, &state->data) != 0) + /* TODO: tch_data_state_init() */ + if (tch_data_state_init(trans, &state->data) != 0) goto exit_free; break; #endif @@ -271,7 +167,7 @@ if (state == NULL) return; if (state->voice_or_data) - tch_state_free_voice(&state->voice); + tch_voice_state_free(&state->voice); #if 0 else /* TODO: tch_state_free_data() */ tch_state_free_data(&state->data); diff --git a/src/host/layer23/src/mobile/tch_voice.c b/src/host/layer23/src/mobile/tch_voice.c new file mode 100644 index 0000000..e949347 --- /dev/null +++ b/src/host/layer23/src/mobile/tch_voice.c @@ -0,0 +1,153 @@ +/* + * (C) 2017-2018 by Vadim Yanitskiy <axilirator(a)gmail.com> + * (C) 2022-2024 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 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. + * + */ + +#include <stdint.h> +#include <errno.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/msgb.h> + +#include <osmocom/gsm/protocol/gsm_04_08.h> +#include <osmocom/gsm/protocol/gsm_08_58.h> + +#include <osmocom/bb/common/logging.h> +#include <osmocom/bb/common/osmocom_data.h> +#include <osmocom/bb/common/ms.h> +#include <osmocom/bb/mobile/gapk_io.h> +#include <osmocom/bb/mobile/mncc.h> +#include <osmocom/bb/mobile/mncc_sock.h> +#include <osmocom/bb/mobile/transaction.h> +#include <osmocom/bb/mobile/tch.h> + +/* Forward a Downlink voice frame to the external MNCC handler */ +static int tch_forward_mncc(struct osmocom_ms *ms, struct msgb *msg) +{ + struct gsm_data_frame *mncc; + + /* Drop the l1ctl_info_dl header */ + msgb_pull_to_l2(msg); + /* push mncc header in front of data */ + mncc = (struct gsm_data_frame *) + msgb_push(msg, sizeof(struct gsm_data_frame)); + mncc->callref = ms->mncc_entity.ref; + + switch (ms->rrlayer.cd_now.mode) { + case GSM48_CMODE_SPEECH_V1: + { + const uint8_t cbits = ms->rrlayer.cd_now.chan_nr >> 3; + if (cbits == ABIS_RSL_CHAN_NR_CBITS_Bm_ACCHs) + mncc->msg_type = GSM_TCHF_FRAME; + else + mncc->msg_type = GSM_TCHH_FRAME; + break; + } + case GSM48_CMODE_SPEECH_EFR: + mncc->msg_type = GSM_TCHF_FRAME_EFR; + break; + case GSM48_CMODE_SPEECH_AMR: /* TODO: no AMR support yet */ + default: + /* TODO: print error message here */ + goto exit_free; + } + + /* distribute and then free */ + if (ms->mncc_entity.sock_state && ms->mncc_entity.ref) + return mncc_sock_from_cc(ms->mncc_entity.sock_state, msg); + +exit_free: + msgb_free(msg); + return 0; +} + +int tch_voice_recv(struct osmocom_ms *ms, struct msgb *msg) +{ + struct tch_voice_state *state = &ms->tch_state->voice; + + switch (state->handler) { + case TCH_VOICE_IOH_LOOPBACK: + /* Remove the DL info header */ + msgb_pull_to_l2(msg); + /* Send voice frame back */ + return tch_send_msg(ms, msg); + case TCH_VOICE_IOH_MNCC_SOCK: + return tch_forward_mncc(ms, msg); + case TCH_VOICE_IOH_GAPK: +#ifdef WITH_GAPK_IO + /* Enqueue a frame to the DL TCH buffer */ + if (state->gapk_io != NULL) + gapk_io_enqueue_dl(state->gapk_io, msg); + else + msgb_free(msg); + break; +#endif + case TCH_VOICE_IOH_L1PHY: + case TCH_VOICE_IOH_NONE: + /* Drop voice frame */ + msgb_free(msg); + } + + return 0; +} + +int tch_voice_serve_ms(struct osmocom_ms *ms) +{ +#ifdef WITH_GAPK_IO + struct tch_voice_state *state = &ms->tch_state->voice; + + if (state->handler == TCH_VOICE_IOH_GAPK) + return gapk_io_serve_ms(ms, state->gapk_io); +#endif + + return 0; +} + +int tch_voice_state_init(struct gsm_trans *trans, struct tch_voice_state *state) +{ +#ifdef WITH_GAPK_IO + struct osmocom_ms *ms = trans->ms; + const struct gsm48_rr_cd *cd = &ms->rrlayer.cd_now; + + switch (state->handler) { + case TCH_VOICE_IOH_GAPK: + if ((cd->chan_nr & RSL_CHAN_NR_MASK) == RSL_CHAN_Bm_ACCHs) + state->gapk_io = gapk_io_state_alloc_mode_rate(ms, cd->mode, true); + else /* RSL_CHAN_Lm_ACCHs */ + state->gapk_io = gapk_io_state_alloc_mode_rate(ms, cd->mode, false); + if (state->gapk_io == NULL) + return -1; + break; + default: + break; + } +#endif + + return 0; +} + +void tch_voice_state_free(struct tch_voice_state *state) +{ + switch (state->handler) { +#ifdef WITH_GAPK_IO + case TCH_VOICE_IOH_GAPK: + gapk_io_state_free(state->gapk_io); + break; +#endif + default: + break; + } +} -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35581?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ib917d95fe77da3e60bc932cce56714d81095c7d4 Gerrit-Change-Number: 35581 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in osmocom-bb[master]: mobile: init/deinit GAPK I/O based on CC transaction events
by fixeria 15 Jan '24

15 Jan '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/35579?usp=email ) Change subject: mobile: init/deinit GAPK I/O based on CC transaction events ...................................................................... mobile: init/deinit GAPK I/O based on CC transaction events Change-Id: I28f87f6a6de673611aa02a24e8985aee23d4498b Related: OS#4396 --- M src/host/layer23/include/osmocom/bb/common/ms.h M src/host/layer23/include/osmocom/bb/mobile/gapk_io.h M src/host/layer23/include/osmocom/bb/mobile/tch.h M src/host/layer23/src/mobile/app_mobile.c M src/host/layer23/src/mobile/gapk_io.c M src/host/layer23/src/mobile/gsm48_rr.c M src/host/layer23/src/mobile/tch.c 7 files changed, 299 insertions(+), 157 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/79/35579/1 diff --git a/src/host/layer23/include/osmocom/bb/common/ms.h b/src/host/layer23/include/osmocom/bb/common/ms.h index f08e977..0b3e13c 100644 --- a/src/host/layer23/include/osmocom/bb/common/ms.h +++ b/src/host/layer23/include/osmocom/bb/common/ms.h @@ -103,8 +103,7 @@ struct osmobb_ms_gmm_layer gmmlayer; struct osmo_fsm_inst *grr_fi; - /* Audio I/O */ - struct gapk_io_state *gapk_io; + struct tch_state *tch_state; void *lua_state; int lua_cb_ref; diff --git a/src/host/layer23/include/osmocom/bb/mobile/gapk_io.h b/src/host/layer23/include/osmocom/bb/mobile/gapk_io.h index 3a02e64..b9f1bc5 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/gapk_io.h +++ b/src/host/layer23/include/osmocom/bb/mobile/gapk_io.h @@ -3,6 +3,7 @@ #ifdef WITH_GAPK_IO #include <stdint.h> +#include <stdbool.h> #include <osmocom/gapk/procqueue.h> #include <osmocom/gapk/codecs.h> @@ -31,13 +32,16 @@ unsigned int tch_ul_fb_len; }; -void gapk_io_init(void); - -int gapk_io_init_ms(struct osmocom_ms *ms, enum osmo_gapk_codec_type codec); -int gapk_io_init_ms_chan(struct osmocom_ms *ms, uint8_t ch_type, uint8_t ch_mode); -int gapk_io_clean_up_ms(struct osmocom_ms *ms); +struct gapk_io_state * +gapk_io_state_alloc(struct osmocom_ms *ms, + enum osmo_gapk_codec_type codec); +struct gapk_io_state * +gapk_io_state_alloc_mode_rate(struct osmocom_ms *ms, + enum gsm48_chan_mode ch_mode, + bool full_rate); +void gapk_io_state_free(struct gapk_io_state *state); void gapk_io_enqueue_dl(struct gapk_io_state *state, struct msgb *msg); -int gapk_io_serve_ms(struct osmocom_ms *ms); +int gapk_io_serve_ms(struct osmocom_ms *ms, struct gapk_io_state *state); #endif /* WITH_GAPK_IO */ diff --git a/src/host/layer23/include/osmocom/bb/mobile/tch.h b/src/host/layer23/include/osmocom/bb/mobile/tch.h index 0e81769..0a523c0 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/tch.h +++ b/src/host/layer23/include/osmocom/bb/mobile/tch.h @@ -4,6 +4,20 @@ struct gsm_data_frame; struct msgb; +struct tch_state { + bool voice_or_data; /* voice (true) or data (false) */ + union { + struct tch_voice_state { + enum tch_voice_io_handler handler; + struct gapk_io_state *gapk_io; + } voice; + struct tch_data_state { + enum tch_data_io_handler handler; + } data; + }; +}; + int tch_init(struct osmocom_ms *ms); +int tch_serve_ms(struct osmocom_ms *ms); int tch_send_voice_msg(struct osmocom_ms *ms, struct msgb *msg); int tch_send_voice_frame(struct osmocom_ms *ms, const struct gsm_data_frame *frame); diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c index e2ef56a..453990e 100644 --- a/src/host/layer23/src/mobile/app_mobile.c +++ b/src/host/layer23/src/mobile/app_mobile.c @@ -42,7 +42,6 @@ #include <osmocom/bb/mobile/app_mobile.h> #include <osmocom/bb/mobile/mncc.h> #include <osmocom/bb/mobile/tch.h> -#include <osmocom/bb/mobile/gapk_io.h> #include <osmocom/bb/mobile/primitives.h> #include <osmocom/vty/vty.h> @@ -82,10 +81,7 @@ w |= gsm322_cs_dequeue(ms); w |= gsm_sim_job_dequeue(ms); w |= mncc_dequeue(ms); -#ifdef WITH_GAPK_IO - if (ms->gapk_io != NULL) - w |= gapk_io_serve_ms(ms); -#endif + w |= tch_serve_ms(ms); if (w) work = 1; } while (w); @@ -200,12 +196,6 @@ return -EBUSY; } -#ifdef WITH_GAPK_IO - /* Clean up GAPK state, if preset */ - if (ms->gapk_io != NULL) - gapk_io_clean_up_ms(ms); -#endif - gsm322_exit(ms); gsm48_mm_exit(ms); gsm48_rr_exit(ms); @@ -494,11 +484,6 @@ l23_app_exit = _mobile_app_exit; osmo_gps_init(); -#ifdef WITH_GAPK_IO - /* Init GAPK audio I/O */ - gapk_io_init(); -#endif - osmo_signal_register_handler(SS_GLOBAL, &global_signal_cb, NULL); osmo_signal_register_handler(SS_L1CTL, &mobile_signal_cb, NULL); osmo_signal_register_handler(SS_L1CTL, &gsm322_l1_signal, NULL); diff --git a/src/host/layer23/src/mobile/gapk_io.c b/src/host/layer23/src/mobile/gapk_io.c index d6b84a5..0c7c2e2 100644 --- a/src/host/layer23/src/mobile/gapk_io.c +++ b/src/host/layer23/src/mobile/gapk_io.c @@ -167,7 +167,7 @@ * convert an encoder specific format * to a PHY specific format. */ -static int prepare_audio_source(struct gapk_io_state *gapk_io, +static int prepare_audio_source(struct gapk_io_state *state, const char *alsa_input_dev) { struct osmo_gapk_pq *pq; @@ -187,22 +187,22 @@ goto error; /* Frame encoder */ - rc = osmo_gapk_pq_queue_codec(pq, gapk_io->codec_desc, 1); + rc = osmo_gapk_pq_queue_codec(pq, state->codec_desc, 1); if (rc) goto error; /* Encoder specific format -> canonical */ - rc = pq_queue_codec_fmt_conv(pq, gapk_io->codec_desc, true); + rc = pq_queue_codec_fmt_conv(pq, state->codec_desc, true); if (rc) goto error; /* Canonical -> PHY specific format */ - rc = osmo_gapk_pq_queue_fmt_convert(pq, gapk_io->phy_fmt_desc, 1); + rc = osmo_gapk_pq_queue_fmt_convert(pq, state->phy_fmt_desc, 1); if (rc) goto error; /* TCH frame buffer sink */ - rc = pq_queue_tch_fb(pq, gapk_io, false); + rc = pq_queue_tch_fb(pq, state, false); if (rc) goto error; @@ -217,7 +217,7 @@ goto error; /* Save pointer within MS GAPK state */ - gapk_io->pq_source = pq; + state->pq_source = pq; /* Describe prepared chain */ pq_desc = osmo_gapk_pq_describe(pq); @@ -244,7 +244,7 @@ * A ECU (Error Concealment Unit) block is optionally * added if implemented for a given codec. */ -static int prepare_audio_sink(struct gapk_io_state *gapk_io, +static int prepare_audio_sink(struct gapk_io_state *state, const char *alsa_output_dev) { struct osmo_gapk_pq *pq; @@ -259,25 +259,25 @@ return -ENOMEM; /* TCH frame buffer source */ - rc = pq_queue_tch_fb(pq, gapk_io, true); + rc = pq_queue_tch_fb(pq, state, true); if (rc) goto error; /* PHY specific format -> canonical */ - rc = osmo_gapk_pq_queue_fmt_convert(pq, gapk_io->phy_fmt_desc, 0); + rc = osmo_gapk_pq_queue_fmt_convert(pq, state->phy_fmt_desc, 0); if (rc) goto error; /* Optional ECU (Error Concealment Unit) */ - osmo_gapk_pq_queue_ecu(pq, gapk_io->codec_desc); + osmo_gapk_pq_queue_ecu(pq, state->codec_desc); /* Canonical -> decoder specific format */ - rc = pq_queue_codec_fmt_conv(pq, gapk_io->codec_desc, false); + rc = pq_queue_codec_fmt_conv(pq, state->codec_desc, false); if (rc) goto error; /* Frame decoder */ - rc = osmo_gapk_pq_queue_codec(pq, gapk_io->codec_desc, 0); + rc = osmo_gapk_pq_queue_codec(pq, state->codec_desc, 0); if (rc) goto error; @@ -297,7 +297,7 @@ goto error; /* Save pointer within MS GAPK state */ - gapk_io->pq_sink = pq; + state->pq_sink = pq; /* Describe prepared chain */ pq_desc = osmo_gapk_pq_describe(pq); @@ -316,29 +316,26 @@ * processing queues (chains), and deallocates the memory. * Should be called when a voice call is finished... */ -int gapk_io_clean_up_ms(struct osmocom_ms *ms) +void gapk_io_state_free(struct gapk_io_state *state) { struct msgb *msg; - if (ms->gapk_io == NULL) - return 0; + if (state == NULL) + return; /* Flush TCH frame I/O buffers */ - while ((msg = msgb_dequeue(&ms->gapk_io->tch_dl_fb))) + while ((msg = msgb_dequeue(&state->tch_dl_fb))) msgb_free(msg); - while ((msg = msgb_dequeue(&ms->gapk_io->tch_ul_fb))) + while ((msg = msgb_dequeue(&state->tch_ul_fb))) msgb_free(msg); /* Destroy both audio I/O chains */ - if (ms->gapk_io->pq_source) - osmo_gapk_pq_destroy(ms->gapk_io->pq_source); - if (ms->gapk_io->pq_sink) - osmo_gapk_pq_destroy(ms->gapk_io->pq_sink); + if (state->pq_source != NULL) + osmo_gapk_pq_destroy(state->pq_source); + if (state->pq_sink != NULL) + osmo_gapk_pq_destroy(state->pq_sink); - talloc_free(ms->gapk_io); - ms->gapk_io = NULL; - - return 0; + talloc_free(state); } /** @@ -386,31 +383,31 @@ * and prepares both processing queues (chains). * Should be called when a voice call is initiated... */ -int gapk_io_init_ms(struct osmocom_ms *ms, enum osmo_gapk_codec_type codec) +struct gapk_io_state * +gapk_io_state_alloc(struct osmocom_ms *ms, + enum osmo_gapk_codec_type codec) { const struct osmo_gapk_format_desc *phy_fmt_desc; const struct osmo_gapk_codec_desc *codec_desc; - struct gsm_settings *set = &ms->settings; + const struct gsm_settings *set = &ms->settings; enum osmo_gapk_format_type phy_fmt; - struct gapk_io_state *gapk_io; + struct gapk_io_state *state; int rc = 0; LOGP(DGAPK, LOGL_NOTICE, "Initialize GAPK I/O\n"); - OSMO_ASSERT(ms->gapk_io == NULL); - /* Make sure that the chosen codec has description */ codec_desc = osmo_gapk_codec_get_from_type(codec); if (codec_desc == NULL) { LOGP(DGAPK, LOGL_ERROR, "Invalid codec type 0x%02x\n", codec); - return -EINVAL; + return NULL; } /* Make sure that the chosen codec is supported */ if (codec_desc->codec_encode == NULL || codec_desc->codec_decode == NULL) { LOGP(DGAPK, LOGL_ERROR, "Codec '%s' is not supported by GAPK\n", codec_desc->name); - return -ENOTSUP; + return NULL; } switch (set->tch_voice.io_format) { @@ -423,36 +420,36 @@ default: LOGP(DGAPK, LOGL_ERROR, "Unhandled I/O format %s\n", tch_voice_io_format_name(set->tch_voice.io_format)); - return -ENOTSUP; + return NULL; } phy_fmt_desc = osmo_gapk_fmt_get_from_type(phy_fmt); if (phy_fmt_desc == NULL) { LOGP(DGAPK, LOGL_ERROR, "Failed to pick the PHY specific " "frame format for codec '%s'\n", codec_desc->name); - return -EINVAL; + return NULL; } - gapk_io = talloc_zero(ms, struct gapk_io_state); - if (gapk_io == NULL) { + state = talloc_zero(ms->tch_state, struct gapk_io_state); + if (state == NULL) { LOGP(DGAPK, LOGL_ERROR, "Failed to allocate memory\n"); - return -ENOMEM; + return NULL; } /* Init TCH frame I/O buffers */ - INIT_LLIST_HEAD(&gapk_io->tch_dl_fb); - INIT_LLIST_HEAD(&gapk_io->tch_ul_fb); + INIT_LLIST_HEAD(&state->tch_dl_fb); + INIT_LLIST_HEAD(&state->tch_ul_fb); /* Store the codec / format description */ - gapk_io->codec_desc = codec_desc; - gapk_io->phy_fmt_desc = phy_fmt_desc; + state->codec_desc = codec_desc; + state->phy_fmt_desc = phy_fmt_desc; /* Use gapk_io_state as talloc context for both chains */ - osmo_gapk_set_talloc_ctx(gapk_io); + osmo_gapk_set_talloc_ctx(state); /* Prepare both source and sink chains */ - rc |= prepare_audio_source(gapk_io, set->tch_voice.alsa_input_dev); - rc |= prepare_audio_sink(gapk_io, set->tch_voice.alsa_output_dev); + rc |= prepare_audio_source(state, set->tch_voice.alsa_input_dev); + rc |= prepare_audio_sink(state, set->tch_voice.alsa_output_dev); /* Fall back to ms instance */ osmo_gapk_set_talloc_ctx(ms); @@ -460,85 +457,50 @@ /* If at lease one chain constructor failed */ if (rc) { /* Destroy both audio I/O chains */ - if (gapk_io->pq_source) - osmo_gapk_pq_destroy(gapk_io->pq_source); - if (gapk_io->pq_sink) - osmo_gapk_pq_destroy(gapk_io->pq_sink); + if (state->pq_source != NULL) + osmo_gapk_pq_destroy(state->pq_source); + if (state->pq_sink != NULL) + osmo_gapk_pq_destroy(state->pq_sink); /* Release the memory and return */ - talloc_free(gapk_io); + talloc_free(state); LOGP(DGAPK, LOGL_ERROR, "Failed to initialize GAPK I/O\n"); - return rc; + return NULL; } - /* Init pointers */ - ms->gapk_io = gapk_io; - LOGP(DGAPK, LOGL_NOTICE, "GAPK I/O initialized for MS '%s', codec '%s'\n", ms->name, codec_desc->name); - return 0; + return state; } -/** - * Wrapper around gapk_io_init_ms(), that maps both - * given GSM 04.08 channel type (HR/FR) and channel - * mode to a codec from 'osmo_gapk_codec_type' enum, - * checks if a mapped codec is supported by GAPK, - * and finally calls the wrapped function. - */ -int gapk_io_init_ms_chan(struct osmocom_ms *ms, - uint8_t ch_type, uint8_t ch_mode) +/* gapk_io_init_ms() wrapper, selecting a codec based on channel mode and rate */ +struct gapk_io_state * +gapk_io_state_alloc_mode_rate(struct osmocom_ms *ms, + enum gsm48_chan_mode ch_mode, + bool full_rate) { enum osmo_gapk_codec_type codec; - /* Map GSM 04.08 channel mode to GAPK codec type */ switch (ch_mode) { case GSM48_CMODE_SPEECH_V1: /* FR or HR */ - if (ch_type == RSL_CHAN_Bm_ACCHs) - codec = CODEC_FR; - else - codec = CODEC_HR; + codec = full_rate ? CODEC_FR : CODEC_HR; break; - case GSM48_CMODE_SPEECH_EFR: codec = CODEC_EFR; break; - case GSM48_CMODE_SPEECH_AMR: codec = CODEC_AMR; break; - - /* Signalling or CSD, do nothing */ - case GSM48_CMODE_DATA_14k5: - case GSM48_CMODE_DATA_12k0: - case GSM48_CMODE_DATA_6k0: - case GSM48_CMODE_DATA_3k6: - case GSM48_CMODE_SIGN: - return 0; default: LOGP(DGAPK, LOGL_ERROR, "Unhandled channel mode 0x%02x (%s)\n", ch_mode, get_value_string(gsm48_chan_mode_names, ch_mode)); - return -EINVAL; + return NULL; } - return gapk_io_init_ms(ms, codec); -} - -/** - * Performs basic initialization of GAPK library, - * setting the talloc root context and a logging category. - * Should be called during the application initialization... - */ -void gapk_io_init(void) -{ - /* Init logging subsystem */ - osmo_gapk_log_init(DGAPK); - - /* Make RAWPCM format info easy to access */ - rawpcm_fmt = osmo_gapk_fmt_get_from_type(FMT_RAWPCM_S16LE); + return gapk_io_state_alloc(ms, codec); } void gapk_io_enqueue_dl(struct gapk_io_state *state, struct msgb *msg) @@ -554,16 +516,15 @@ } /* Serves both UL/DL TCH frame I/O buffers */ -int gapk_io_serve_ms(struct osmocom_ms *ms) +int gapk_io_serve_ms(struct osmocom_ms *ms, struct gapk_io_state *state) { - struct gapk_io_state *gapk_io = ms->gapk_io; int work = 0; /** * Make sure we have at least two DL frames * to prevent discontinuous playback. */ - if (gapk_io->tch_dl_fb_len < 2) + if (state->tch_dl_fb_len < 2) return 0; /** @@ -571,22 +532,22 @@ * in DL buffer, put silence frames using the upcoming * ECU (Error Concealment Unit) of libosmocodec. */ - while (!llist_empty(&gapk_io->tch_dl_fb)) { + while (!llist_empty(&state->tch_dl_fb)) { /* Decode and play a received DL TCH frame */ - osmo_gapk_pq_execute(gapk_io->pq_sink); + osmo_gapk_pq_execute(state->pq_sink); /* Record and encode an UL TCH frame back */ - osmo_gapk_pq_execute(gapk_io->pq_source); + osmo_gapk_pq_execute(state->pq_source); work |= 1; } - while (!llist_empty(&gapk_io->tch_ul_fb)) { + while (!llist_empty(&state->tch_ul_fb)) { struct msgb *tch_msg; /* Obtain one TCH frame from the UL buffer */ - tch_msg = msgb_dequeue_count(&gapk_io->tch_ul_fb, - &gapk_io->tch_ul_fb_len); + tch_msg = msgb_dequeue_count(&state->tch_ul_fb, + &state->tch_ul_fb_len); /* Push a voice frame to the lower layers */ tch_send_voice_msg(ms, tch_msg); @@ -596,3 +557,16 @@ return work; } + +/** + * Performs basic initialization of GAPK library, + * setting the talloc root context and a logging category. + */ +static __attribute__((constructor)) void gapk_io_init(void) +{ + /* Init logging subsystem */ + osmo_gapk_log_init(DGAPK); + + /* Make RAWPCM format info easy to access */ + rawpcm_fmt = osmo_gapk_fmt_get_from_type(FMT_RAWPCM_S16LE); +} diff --git a/src/host/layer23/src/mobile/gsm48_rr.c b/src/host/layer23/src/mobile/gsm48_rr.c index 46a143c..4d879d6 100644 --- a/src/host/layer23/src/mobile/gsm48_rr.c +++ b/src/host/layer23/src/mobile/gsm48_rr.c @@ -125,7 +125,6 @@ #include <osmocom/bb/common/utils.h> #include <osmocom/bb/common/settings.h> -#include <osmocom/bb/mobile/gapk_io.h> #include <osmocom/bb/mobile/vty.h> #include <osmocom/bb/mobile/gsm48_rr.h> @@ -515,10 +514,6 @@ memset(&rr->cd_now, 0, sizeof(rr->cd_now)); /* reset ciphering */ rr->cipher_on = 0; -#ifdef WITH_GAPK_IO - /* clean-up GAPK state */ - gapk_io_clean_up_ms(rr->ms); -#endif /* reset audio mode */ /* tell cell selection process to return to idle mode * NOTE: this must be sent unbuffered, because it will @@ -573,10 +568,6 @@ gsm48_rr_render_ma(ms, &rr->cd_now, ma, &ma_len); /* activate channel */ gsm48_rr_activate_channel(ms, &rr->cd_now, ma, ma_len); -#ifdef WITH_GAPK_IO - /* clean-up GAPK state */ - gapk_io_clean_up_ms(rr->ms); -#endif return; } } @@ -4432,15 +4423,6 @@ && ch_type != RSL_CHAN_Lm_ACCHs) return -ENOTSUP; -#ifdef WITH_GAPK_IO - /* Poke GAPK audio back-end, if it is chosen */ - if (ms->settings.tch_voice.io_handler == TCH_VOICE_IOH_GAPK) { - int rc = gapk_io_init_ms_chan(ms, ch_type, mode); - if (rc) - return rc; - } -#endif - /* Apply indicated channel mode */ LOGP(DRR, LOGL_INFO, "setting TCH mode to %s, audio mode to %d, tch flags to %d\n", get_value_string(gsm48_chan_mode_names, mode), rr->audio_mode, tch_flags); @@ -4984,12 +4966,6 @@ if (cause) return gsm48_rr_tx_ass_fail(ms, cause, RSL_MT_DATA_REQ); -#ifdef WITH_GAPK_IO - /* Poke GAPK audio back-end, if it is chosen */ - if (ms->settings.tch_voice.io_handler == TCH_VOICE_IOH_GAPK) - gapk_io_init_ms_chan(ms, ch_type, cda->mode); -#endif - #ifdef TEST_FREQUENCY_MOD LOGP(DRR, LOGL_INFO, " TESTING: frequency modify ASS.CMD\n"); before_time = 1; diff --git a/src/host/layer23/src/mobile/tch.c b/src/host/layer23/src/mobile/tch.c index f6530fb..67195c1 100644 --- a/src/host/layer23/src/mobile/tch.c +++ b/src/host/layer23/src/mobile/tch.c @@ -1,7 +1,7 @@ /* * (C) 2010 by Andreas Eversberg <jolly(a)eversberg.eu> * (C) 2017-2018 by Vadim Yanitskiy <axilirator(a)gmail.com> - * (C) 2022 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * (C) 2022-2024 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> * * All Rights Reserved * @@ -21,8 +21,10 @@ #include <errno.h> #include <osmocom/core/msgb.h> +#include <osmocom/core/signal.h> #include <osmocom/codec/codec.h> +#include <osmocom/gsm/protocol/gsm_04_08.h> #include <osmocom/gsm/protocol/gsm_08_58.h> #include <osmocom/bb/common/logging.h> @@ -31,6 +33,7 @@ #include <osmocom/bb/mobile/gapk_io.h> #include <osmocom/bb/mobile/mncc.h> #include <osmocom/bb/mobile/mncc_sock.h> +#include <osmocom/bb/mobile/transaction.h> #include <osmocom/bb/mobile/tch.h> /* Forward a Downlink voice frame to the external MNCC handler */ @@ -76,7 +79,9 @@ /* Receive a Downlink voice frame from the lower layers */ static int tch_recv_voice(struct osmocom_ms *ms, struct msgb *msg) { - switch (ms->settings.tch_voice.io_handler) { + struct tch_state *state = ms->tch_state; + + switch (state->voice.handler) { case TCH_VOICE_IOH_LOOPBACK: /* Remove the DL info header */ msgb_pull_to_l2(msg); @@ -87,8 +92,8 @@ case TCH_VOICE_IOH_GAPK: #ifdef WITH_GAPK_IO /* Enqueue a frame to the DL TCH buffer */ - if (ms->gapk_io != NULL) - gapk_io_enqueue_dl(ms->gapk_io, msg); + if (state->voice.gapk_io != NULL) + gapk_io_enqueue_dl(state->voice.gapk_io, msg); else msgb_free(msg); break; @@ -102,6 +107,24 @@ return 0; } +/* Receive a Downlink traffic (voice/data) frame from the lower layers */ +static int tch_recv_cb(struct osmocom_ms *ms, struct msgb *msg) +{ + struct tch_state *state = ms->tch_state; + + if (state == NULL) { + msgb_free(msg); + return 0; + } + + if (state->voice_or_data) + return tch_recv_voice(ms, msg); + else /* TODO: tch_recv_data() */ + msgb_free(msg); + + return 0; +} + /* Send an Uplink voice frame to the lower layers */ int tch_send_voice_msg(struct osmocom_ms *ms, struct msgb *msg) { @@ -142,10 +165,167 @@ return tch_send_voice_msg(ms, nmsg); } +int tch_serve_ms(struct osmocom_ms *ms) +{ + struct tch_state *state = ms->tch_state; + + if (state == NULL) + return 0; + if (state->voice_or_data) { +#ifdef WITH_GAPK_IO + if (state->voice.handler == TCH_VOICE_IOH_GAPK) + return gapk_io_serve_ms(ms, state->voice.gapk_io); +#endif + } + + return 0; +} + +static int tch_state_init_voice(struct osmocom_ms *ms, + struct tch_voice_state *state) +{ + const struct gsm48_rr_cd *cd = &ms->rrlayer.cd_now; + + switch (state->handler) { +#ifdef WITH_GAPK_IO + case TCH_VOICE_IOH_GAPK: + if ((cd->chan_nr & RSL_CHAN_NR_MASK) == RSL_CHAN_Bm_ACCHs) + state->gapk_io = gapk_io_state_alloc_mode_rate(ms, cd->mode, true); + else /* RSL_CHAN_Lm_ACCHs */ + state->gapk_io = gapk_io_state_alloc_mode_rate(ms, cd->mode, false); + if (state->gapk_io == NULL) + return -1; + break; +#endif + default: + break; + } + + return 0; +} + +static void tch_state_free_voice(struct tch_voice_state *state) +{ + switch (state->handler) { +#ifdef WITH_GAPK_IO + case TCH_VOICE_IOH_GAPK: + gapk_io_state_free(state->gapk_io); + break; +#endif + default: + break; + } +} + +static void tch_trans_cstate_active_cb(struct gsm_trans *trans) +{ + struct osmocom_ms *ms = trans->ms; + struct tch_state *state; + enum gsm48_chan_mode ch_mode; + + if (ms->tch_state != NULL) + return; /* TODO: handle modify? */ + + state = talloc_zero(ms, struct tch_state); + OSMO_ASSERT(state != NULL); + + ch_mode = ms->rrlayer.cd_now.mode; + switch (ch_mode) { + case GSM48_CMODE_SPEECH_V1: + case GSM48_CMODE_SPEECH_EFR: + case GSM48_CMODE_SPEECH_AMR: + state->voice_or_data = true; + state->voice.handler = ms->settings.tch_voice.io_handler; + if (tch_state_init_voice(ms, &state->voice) != 0) + goto exit_free; + break; + case GSM48_CMODE_DATA_14k5: + case GSM48_CMODE_DATA_12k0: + case GSM48_CMODE_DATA_6k0: + case GSM48_CMODE_DATA_3k6: +#if 0 + state->voice_or_data = false; + state->data.handler = ms->settings.tch_data.io_handler; + /* TODO: tch_state_init_data() */ + if (tch_state_init_data(ms, &state->data) != 0) + goto exit_free; + break; +#endif + case GSM48_CMODE_SIGN: + default: + LOGP(DL1C, LOGL_ERROR, "Unhandled channel mode %s\n", + get_value_string(gsm48_chan_mode_names, ch_mode)); +exit_free: + talloc_free(state); + return; + } + + ms->tch_state = state; +} + +static void tch_trans_free_cb(struct gsm_trans *trans) +{ + struct osmocom_ms *ms = trans->ms; + struct tch_state *state = ms->tch_state; + + if (state == NULL) + return; + if (state->voice_or_data) + tch_state_free_voice(&state->voice); +#if 0 + else /* TODO: tch_state_free_data() */ + tch_state_free_data(&state->data); +#endif + + talloc_free(state); + ms->tch_state = NULL; +} + +static void tch_trans_state_chg_cb(struct gsm_trans *trans) +{ + switch (trans->cc.state) { + case GSM_CSTATE_ACTIVE: + tch_trans_cstate_active_cb(trans); + break; + case GSM_CSTATE_NULL: + tch_trans_free_cb(trans); + break; + } +} + +/* a call-back for CC (Call Control) transaction related events */ +static int tch_trans_signal_cb(unsigned int subsys, unsigned int signal, + void *handler_data, void *signal_data) +{ + struct gsm_trans *trans = signal_data; + + OSMO_ASSERT(subsys == SS_L23_TRANS); + OSMO_ASSERT(trans != NULL); + + /* we only care about CC transactions here */ + if (trans->protocol != GSM48_PDISC_CC) + return 0; + + switch ((enum osmobb_l23_trans_sig)signal) { + case S_L23_CC_TRANS_ALLOC: + break; + case S_L23_CC_TRANS_FREE: + tch_trans_free_cb(trans); + break; + case S_L23_CC_TRANS_STATE_CHG: + tch_trans_state_chg_cb(trans); + break; + } + + return 0; +} + /* Initialize the TCH router */ int tch_init(struct osmocom_ms *ms) { - ms->l1_entity.l1_traffic_ind = tch_recv_voice; + ms->l1_entity.l1_traffic_ind = &tch_recv_cb; + + osmo_signal_register_handler(SS_L23_TRANS, &tch_trans_signal_cb, ms); return 0; } -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/35579?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: I28f87f6a6de673611aa02a24e8985aee23d4498b Gerrit-Change-Number: 35579 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • ...
  • 156
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.