osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/31683 )


Change subject: abis_rsl: CSD: add RTP_CSD_FMT IE to CRCX/MDCX
......................................................................

abis_rsl: CSD: add RTP_CSD_FMT IE to CRCX/MDCX

Related: OS#4393
Change-Id: I4964b268124d29354e252c2ee509866ae75fab6d
---
M include/osmocom/bsc/abis_rsl.h
M include/osmocom/bsc/lchan.h
M src/osmo-bsc/abis_rsl.c
M src/osmo-bsc/lchan_rtp_fsm.c
4 files changed, 101 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/83/31683/1

diff --git a/include/osmocom/bsc/abis_rsl.h b/include/osmocom/bsc/abis_rsl.h
index ea029e6..3aea8f7 100644
--- a/include/osmocom/bsc/abis_rsl.h
+++ b/include/osmocom/bsc/abis_rsl.h
@@ -120,6 +120,9 @@
 
 int rsl_forward_layer3_info(struct gsm_lchan *lchan, const uint8_t *l3_info, 
uint8_t l3_info_len);

+int ipacc_rtp_csd_fmt_transp(const struct channel_mode_and_rate *ch_mode_rate);
+int ipacc_rtp_csd_fmt_non_transp(const struct channel_mode_and_rate 
*ch_mode_rate);
+
 int ipacc_speech_mode(enum gsm48_chan_mode tch_mode, enum gsm_chan_t type);
 void ipacc_speech_mode_set_direction(uint8_t *speech_mode, bool send);
 int ipacc_payload_type(enum gsm48_chan_mode tch_mode, enum gsm_chan_t type);
diff --git a/include/osmocom/bsc/lchan.h b/include/osmocom/bsc/lchan.h
index a1eacef..135a067 100644
--- a/include/osmocom/bsc/lchan.h
+++ b/include/osmocom/bsc/lchan.h
@@ -286,6 +286,7 @@
                uint16_t conn_id;
                uint8_t rtp_payload;
                uint8_t rtp_payload2;
+               uint8_t rtp_csd_fmt;
                uint8_t speech_mode;

                /* info we need to postpone the AoIP
diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c
index ad1dc7c..63814f4 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -2582,6 +2582,63 @@
        return rc;
 }

+/* Return an ip.access RTP CSD FMT value (uint8_t) or negative on error. */
+int ipacc_rtp_csd_fmt_transp(const struct channel_mode_and_rate *ch_mode_rate)
+{
+       uint8_t ret = RSL_IPAC_RTP_CSD_TRAU_BTS;
+
+       switch (ch_mode_rate->data_rate.t) {
+       case RSL_CMOD_CSD_T_32k0:
+       case RSL_CMOD_CSD_T_29k0:
+               ret |= RSL_IPAC_RTP_CSD_IR_32k << 5;
+               break;
+       case RSL_CMOD_CSD_T_14k4:
+       case RSL_CMOD_CSD_T_9k6:
+               ret |= RSL_IPAC_RTP_CSD_IR_16k << 5;
+               break;
+       case RSL_CMOD_CSD_T_4k8:
+       case RSL_CMOD_CSD_T_2k4:
+       case RSL_CMOD_CSD_T_1k2:
+       case RSL_CMOD_CSD_T_600:
+       case RSL_CMOD_CSD_T_1200_75:
+               ret |= RSL_IPAC_RTP_CSD_IR_8k << 5;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return ret;
+}
+
+/* Return an ip.access RTP CSD FMT value (uint8_t) or negative on error. */
+int ipacc_rtp_csd_fmt_non_transp(const struct channel_mode_and_rate 
*ch_mode_rate)
+{
+       uint8_t ret = RSL_IPAC_RTP_CSD_TRAU_BTS;
+
+       switch (ch_mode_rate->data_rate.nt) {
+       case RSL_CMOD_CSD_NTA_43k5_14k5:
+       case RSL_CMOD_CSD_NTA_43k5_29k0:
+       case RSL_CMOD_CSD_NTA_14k5_43k5:
+       case RSL_CMOD_CSD_NTA_29k0_43k5:
+       case RSL_CMOD_CSD_NT_43k5:
+               ret |= RSL_IPAC_RTP_CSD_IR_64k << 5;
+       case RSL_CMOD_CSD_NTA_29k0_14k5:
+       case RSL_CMOD_CSD_NTA_14k5_29k0:
+       case RSL_CMOD_CSD_NT_28k8:
+               ret |= RSL_IPAC_RTP_CSD_IR_32k << 5;
+       case RSL_CMOD_CSD_NT_14k5:
+       case RSL_CMOD_CSD_NT_12k0:
+               ret |= RSL_IPAC_RTP_CSD_IR_16k << 5;
+       case RSL_CMOD_CSD_NT_6k0:
+               ret |= RSL_IPAC_RTP_CSD_IR_8k << 5;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return ret;
+}
+
 /* Return an ip.access BTS speech mode value (uint8_t) or negative on error. */
 int ipacc_speech_mode(enum gsm48_chan_mode tch_mode, enum gsm_chan_t type)
 {
@@ -2755,9 +2812,11 @@
        dh->chan_nr = chan_nr;

        if (lchan->current_ch_indctr == GSM0808_CHAN_DATA) {
+               msgb_tv_put(msg, RSL_IE_IPAC_RTP_CSD_FMT, 
lchan->abis_ip.rtp_csd_fmt);
+
                LOG_LCHAN(lchan, LOGL_DEBUG,
-                         "Sending IPACC CRCX to BTS: RTP_PAYLOAD=%d (CSD) 
osmux_use=%d osmux_loc_cid=%d\n",
-                         lchan->abis_ip.rtp_payload,
+                         "Sending IPACC CRCX to BTS: rtp_csd_fmt=0x%02x 
RTP_PAYLOAD=%d (CSD) osmux_use=%d osmux_loc_cid=%d\n",
+                         lchan->abis_ip.rtp_csd_fmt, 
lchan->abis_ip.rtp_payload,
                          lchan->abis_ip.osmux.use, 
lchan->abis_ip.osmux.local_cid);
        } else {
                /* 0x1- == receive-only, 0x-1 == EFR codec */
@@ -2806,8 +2865,12 @@
        att_ip = (uint32_t *)msgb_put(msg, sizeof(uint32_t));
        *att_ip = htonl(dest_ip);
        msgb_tv16_put(msg, RSL_IE_IPAC_REMOTE_PORT, dest_port);
-       if (lchan->current_ch_indctr == GSM0808_CHAN_SPEECH)
+
+       if (lchan->current_ch_indctr == GSM0808_CHAN_DATA)
+               msgb_tv_put(msg, RSL_IE_IPAC_RTP_CSD_FMT, 
lchan->abis_ip.rtp_csd_fmt);
+       else
                msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, 
lchan->abis_ip.speech_mode);
+
        msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
        if (lchan->abis_ip.rtp_payload2)
                msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD2, 
lchan->abis_ip.rtp_payload2);
@@ -2832,12 +2895,13 @@

        if (lchan->current_ch_indctr == GSM0808_CHAN_DATA)
                LOG_LCHAN(lchan, LOGL_DEBUG, "Sending IPACC MDCX to BTS:"
-                         " %s:%u rtp_payload=%u (CSD) rtp_payload2=%u 
conn_id=%u\n",
+                         " %s:%u rtp_payload=%u (CSD) rtp_payload2=%u 
conn_id=%u rtp_csd_fmt=0x%02x\n",
                          ip_to_a(lchan->abis_ip.connect_ip),
                          lchan->abis_ip.connect_port,
                          lchan->abis_ip.rtp_payload,
                          lchan->abis_ip.rtp_payload2,
-                         lchan->abis_ip.conn_id);
+                         lchan->abis_ip.conn_id,
+                         lchan->abis_ip.rtp_csd_fmt);
        else
                LOG_LCHAN(lchan, LOGL_DEBUG, "Sending IPACC MDCX to BTS:"
                          " %s:%u rtp_payload=%u rtp_payload2=%u conn_id=%u 
speech_mode=0x%02x\n",
diff --git a/src/osmo-bsc/lchan_rtp_fsm.c b/src/osmo-bsc/lchan_rtp_fsm.c
index c5dab49..2c6ed4a 100644
--- a/src/osmo-bsc/lchan_rtp_fsm.c
+++ b/src/osmo-bsc/lchan_rtp_fsm.c
@@ -307,7 +307,24 @@
                return;
        }

-       if (lchan->current_ch_indctr == GSM0808_CHAN_SPEECH) {
+       if (lchan->current_ch_indctr == GSM0808_CHAN_DATA) {
+               if (lchan->activate.ch_mode_rate.data_transparent) {
+                       val = 
ipacc_rtp_csd_fmt_transp(&lchan->activate.ch_mode_rate);
+                       if (val < 0) {
+                               lchan_rtp_fail("Cannot determine Abis/IP RTP 
CSD format for rsl_cmod_csd_t=%d",
+                                              
lchan->activate.ch_mode_rate.data_rate.t);
+                               return;
+                       }
+               } else {
+                       val = 
ipacc_rtp_csd_fmt_non_transp(&lchan->activate.ch_mode_rate);
+                       if (val < 0) {
+                               lchan_rtp_fail("Cannot determine Abis/IP RTP 
CSD format for rsl_cmod_csd_nt=%d",
+                                              
lchan->activate.ch_mode_rate.data_rate.nt);
+                               return;
+                       }
+               }
+               lchan->abis_ip.rtp_csd_fmt = val;
+       } else {
                val = ipacc_speech_mode(lchan->activate.ch_mode_rate.chan_mode, 
lchan->type);
                if (val < 0) {
                        lchan_rtp_fail("Cannot determine Abis/IP speech mode 
for tch_mode=%s type=%s",

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/31683
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I4964b268124d29354e252c2ee509866ae75fab6d
Gerrit-Change-Number: 31683
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>
Gerrit-MessageType: newchange

Reply via email to