This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/206 Move TCH code to common subdir * move code from gen_empty_tch_msg() which is common to sysmobts and litecell into separate file under common/ directory * introduce bts-specific function for getting payload address, setting payload type and size This makes introducing and testing DTXd support on both platforms much easier. Change-Id: Ia0d4d0f9848fc2ab54f975a3b6d1815fbcdf78a7 Related: OS#1563 --- M src/common/Makefile.am A src/common/tch.c M src/osmo-bts-litecell15/tch.c M src/osmo-bts-sysmo/tch.c 4 files changed, 159 insertions(+), 97 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/06/206/1 diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 8df6513..5c84ade 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -4,7 +4,7 @@ noinst_LIBRARIES = libbts.a libl1sched.a libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \ - rsl.c vty.c paging.c measurement.c amr.c lchan.c \ + rsl.c vty.c paging.c measurement.c amr.c tch.c lchan.c \ load_indication.c pcu_sock.c handover.c msg_utils.c \ load_indication.c pcu_sock.c handover.c msg_utils.c \ tx_power.c bts_ctrl_commands.c bts_ctrl_lookup.c \ diff --git a/src/common/tch.c b/src/common/tch.c new file mode 100644 index 0000000..794f941 --- /dev/null +++ b/src/common/tch.c @@ -0,0 +1,67 @@ +/* OsmoBTS common TCH code */ + +/* (C) 2016 by sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <osmo-bts/gsm_data.h> + +extern struct msgb *l1p_msgb_alloc(void); +extern uint8_t *get_payload_addr(struct msgb *msg); +extern void set_payload_type(struct msgb *msg, struct gsm_lchan *lchan); +extern void set_payload_size(struct msgb *msg, uint8_t size); + +struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan) +{ + struct msgb *msg; + uint8_t *l1_payload; + + msg = l1p_msgb_alloc(); + if (!msg) + return NULL; + + l1_payload = get_payload_addr(msg); + + switch (lchan->tch_mode) { + case GSM48_CMODE_SPEECH_AMR: + set_payload_type(msg, lchan); + if (lchan->tch.last_sid.len) { + memcpy(l1_payload, lchan->tch.last_sid.buf, + lchan->tch.last_sid.len); + set_payload_size(msg, lchan->tch.last_sid.len + 1); + } else { + /* FIXME: decide if we should send SPEECH_BAD or + * SID_BAD */ +#if 0 + *payload_type = GsmL1_TchPlType_Amr_SidBad; + memset(l1_payload, 0xFF, 5); + msu_param->u8Size = 5 + 3; +#else + /* send an all-zero SID */ + set_payload_size(msg, 8); +#endif + } + break; + default: + msgb_free(msg); + msg = NULL; + break; + } + + return msg; +} diff --git a/src/osmo-bts-litecell15/tch.c b/src/osmo-bts-litecell15/tch.c index a11911c..d09264a 100644 --- a/src/osmo-bts-litecell15/tch.c +++ b/src/osmo-bts-litecell15/tch.c @@ -100,6 +100,52 @@ #define GSM_HR_BYTES 14 /* TS 101318 Chapter 5.2: 112 bits, no sig */ #define GSM_EFR_BYTES 31 /* TS 101318 Chapter 5.3: 244 bits + 4bit sig */ +void set_payload_size(struct msgb *msg, uint8_t size) +{ + GsmL1_Prim_t *l1p; + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + + l1p = msgb_l1prim(msg); + data_req = &l1p->u.phDataReq; + msu_param = &data_req->msgUnitParam; + msu_param->u8Size = size; +} + +void set_payload_type(struct msgb *msg, struct gsm_lchan *lchan) +{ + GsmL1_Prim_t *l1p; + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + uint8_t *payload_type; + + l1p = msgb_l1prim(msg); + data_req = &l1p->u.phDataReq; + msu_param = &data_req->msgUnitParam; + payload_type = &msu_param->u8Buffer[0]; + + switch (lchan->tch_mode) { + case GSM48_CMODE_SPEECH_AMR: + *payload_type = GsmL1_TchPlType_Amr; + break; + default: + return; + } +} + +uint8_t *get_payload_addr(struct msgb *msg) +{ + GsmL1_Prim_t *l1p; + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + + l1p = msgb_l1prim(msg); + data_req = &l1p->u.phDataReq; + msu_param = &data_req->msgUnitParam; + + return &msu_param->u8Buffer[1]; +} + static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len) { struct msgb *msg; @@ -483,52 +529,4 @@ gsm_lchan_name(lchan), get_value_string(lc15bts_tch_pl_names, payload_type)); return -EINVAL; -} - -struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan) -{ - struct msgb *msg; - GsmL1_Prim_t *l1p; - GsmL1_PhDataReq_t *data_req; - GsmL1_MsgUnitParam_t *msu_param; - uint8_t *payload_type; - uint8_t *l1_payload; - - msg = l1p_msgb_alloc(); - if (!msg) - return NULL; - - l1p = msgb_l1prim(msg); - data_req = &l1p->u.phDataReq; - msu_param = &data_req->msgUnitParam; - payload_type = &msu_param->u8Buffer[0]; - l1_payload = &msu_param->u8Buffer[1]; - - switch (lchan->tch_mode) { - case GSM48_CMODE_SPEECH_AMR: - *payload_type = GsmL1_TchPlType_Amr; - if (lchan->tch.last_sid.len) { - memcpy(l1_payload, lchan->tch.last_sid.buf, - lchan->tch.last_sid.len); - msu_param->u8Size = lchan->tch.last_sid.len+1; - } else { - /* FIXME: decide if we should send SPEECH_BAD or - * SID_BAD */ -#if 0 - *payload_type = GsmL1_TchPlType_Amr_SidBad; - memset(l1_payload, 0xFF, 5); - msu_param->u8Size = 5 + 3; -#else - /* send an all-zero SID */ - msu_param->u8Size = 8; -#endif - } - break; - default: - msgb_free(msg); - msg = NULL; - break; - } - - return msg; } diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c index e08d8a6..13f9ec6 100644 --- a/src/osmo-bts-sysmo/tch.c +++ b/src/osmo-bts-sysmo/tch.c @@ -89,6 +89,51 @@ out[i] = (in[i] & 0xF) << 4; } +void set_payload_size(struct msgb *msg, uint8_t size) +{ + GsmL1_Prim_t *l1p; + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + + l1p = msgb_l1prim(msg); + data_req = &l1p->u.phDataReq; + msu_param = &data_req->msgUnitParam; + msu_param->u8Size = size; +} + +void set_payload_type(struct msgb *msg, struct gsm_lchan *lchan) +{ + GsmL1_Prim_t *l1p; + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + uint8_t *payload_type; + + l1p = msgb_l1prim(msg); + data_req = &l1p->u.phDataReq; + msu_param = &data_req->msgUnitParam; + payload_type = &msu_param->u8Buffer[0]; + + switch (lchan->tch_mode) { + case GSM48_CMODE_SPEECH_AMR: + *payload_type = GsmL1_TchPlType_Amr; + break; + default: + return; + } +} + +uint8_t *get_payload_addr(struct msgb *msg) +{ + GsmL1_Prim_t *l1p; + GsmL1_PhDataReq_t *data_req; + GsmL1_MsgUnitParam_t *msu_param; + + l1p = msgb_l1prim(msg); + data_req = &l1p->u.phDataReq; + msu_param = &data_req->msgUnitParam; + + return &msu_param->u8Buffer[1]; +} static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len) { @@ -579,52 +624,4 @@ gsm_lchan_name(lchan), get_value_string(femtobts_tch_pl_names, payload_type)); return -EINVAL; -} - -struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan) -{ - struct msgb *msg; - GsmL1_Prim_t *l1p; - GsmL1_PhDataReq_t *data_req; - GsmL1_MsgUnitParam_t *msu_param; - uint8_t *payload_type; - uint8_t *l1_payload; - - msg = l1p_msgb_alloc(); - if (!msg) - return NULL; - - l1p = msgb_l1prim(msg); - data_req = &l1p->u.phDataReq; - msu_param = &data_req->msgUnitParam; - payload_type = &msu_param->u8Buffer[0]; - l1_payload = &msu_param->u8Buffer[1]; - - switch (lchan->tch_mode) { - case GSM48_CMODE_SPEECH_AMR: - *payload_type = GsmL1_TchPlType_Amr; - if (lchan->tch.last_sid.len) { - memcpy(l1_payload, lchan->tch.last_sid.buf, - lchan->tch.last_sid.len); - msu_param->u8Size = lchan->tch.last_sid.len+1; - } else { - /* FIXME: decide if we should send SPEECH_BAD or - * SID_BAD */ -#if 0 - *payload_type = GsmL1_TchPlType_Amr_SidBad; - memset(l1_payload, 0xFF, 5); - msu_param->u8Size = 5 + 3; -#else - /* send an all-zero SID */ - msu_param->u8Size = 8; -#endif - } - break; - default: - msgb_free(msg); - msg = NULL; - break; - } - - return msg; } -- To view, visit https://gerrit.osmocom.org/206 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia0d4d0f9848fc2ab54f975a3b6d1815fbcdf78a7 Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de>