(WIP) host/trxcon: add L1CTL PHY description and features

Change-Id: I175dc4858e3760e4e60f66658354a9d68d5231c7
This commit is contained in:
Vadim Yanitskiy 2018-11-21 10:52:06 +07:00
parent c050ef43b2
commit 5e9786bde9
3 changed files with 129 additions and 1 deletions

View File

@ -27,6 +27,7 @@ trxcon_SOURCES = \
trx_if.c \
logging.c \
trxcon.c \
phy_info.c \
$(NULL)
# Scheduler

View File

@ -3,7 +3,7 @@
* GSM L1 control interface handlers
*
* (C) 2014 by Sylvain Munaut <tnt@246tNt.com>
* (C) 2016-2017 by Vadim Yanitskiy <axilirator@gmail.com>
* (C) 2016-2018 by Vadim Yanitskiy <axilirator@gmail.com>
*
* All Rights Reserved
*
@ -778,6 +778,39 @@ exit:
return rc;
}
/* Forward-declaration of the actual implementation */
int trxcon_compose_phy_info(struct msgb *msg);
static int l1ctl_rx_nego_req(struct l1ctl_link *l1l, struct msgb *msg)
{
struct msgb *info_msg;
int rc;
LOGP(DL1C, LOGL_NOTICE, "PHY info / features negotiation\n");
/**
* In the future the higher layers may also send some
* information within negotiation request, so we don't
* abuse this message (by changing its type),
* and allocate a new one.
*/
msgb_free(msg);
info_msg = l1ctl_alloc_msg(L1CTL_PHY_NEGO_IND);
if (info_msg == NULL)
return -ENOMEM;
rc = trxcon_compose_phy_info(info_msg);
if (rc)
goto exit_free;
return l1ctl_link_send(l1l, info_msg);
exit_free:
msgb_free(info_msg);
return rc;
}
int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg)
{
struct l1ctl_hdr *l1h;
@ -812,6 +845,8 @@ int l1ctl_rx_cb(struct l1ctl_link *l1l, struct msgb *msg)
return l1ctl_rx_tch_mode_req(l1l, msg);
case L1CTL_CRYPTO_REQ:
return l1ctl_rx_crypto_req(l1l, msg);
case L1CTL_PHY_NEGO_REQ:
return l1ctl_rx_nego_req(l1l, msg);
/* Not (yet) handled messages */
case L1CTL_NEIGH_PM_REQ:

View File

@ -0,0 +1,92 @@
/*
* L1CTL PHY info / features negotiation
*
* (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
*
* 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.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <errno.h>
#include <stdint.h>
#include <arpa/inet.h>
#include <osmocom/core/negotiation.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
#include "l1ctl_proto.h"
static const struct value_string phy_info[] = {
{L1CTL_PHY_INFO_NAME, "trxcon"},
{ 0, NULL }
};
int trxcon_compose_phy_info(struct msgb *msg)
{
struct l1ctl_phy_nego_ind *hdr;
uint8_t *features_tlv;
int rc;
/* Header first */
hdr = (struct l1ctl_phy_nego_ind *) msgb_put(msg, sizeof(*hdr));
if (!hdr)
return -ENOMEM;
/* Encode basic PHY info */
rc = osmo_nego_enc_info(msg, phy_info);
if (rc < (ARRAY_SIZE(phy_info) - 1))
return -EINVAL;
/* PHY features TLV, length will be set latter */
features_tlv = msgb_put(msg, 2);
if (!features_tlv)
return -ENOMEM;
/* Frequency band support */
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_BAND_400);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_BAND_850);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_BAND_900);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_BAND_DCS);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_BAND_PCS);
/* Channel coding support */
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_CHAN_XCCH);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_CHAN_TCHF);
/* Voice codecs support */
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_CODEC_FR);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_CODEC_EFR);
/* A5/X ciphering support */
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_A5_1);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_A5_2);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_A5_3);
/* Other features */
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_TX);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_PM);
osmo_nego_add_feature(msg, L1CTL_PHY_FEATURE_TRAFFIC);
/* Finally, compute the length fields */
features_tlv[0] = L1CTL_PHY_INFO_FEATURES;
features_tlv[1] = msg->tail - features_tlv - 2;
hdr->len = htons(msg->tail - hdr->data);
return 0;
}