(WIP) host/layer23: introduce an application to dump L1CTL PHY info

Change-Id: Ib89f45b5c8612ed6c9a8dedb7d3b7aa712c17feb
This commit is contained in:
Vadim Yanitskiy 2018-11-21 10:54:48 +07:00
parent 5e9786bde9
commit 1c84127b19
6 changed files with 205 additions and 1 deletions

View File

@ -34,3 +34,4 @@ src/misc/cbch_sniff
src/misc/ccch_scan
src/misc/layer23
src/mobile/mobile
src/misc/phy_info

View File

@ -54,6 +54,9 @@ int l1ctl_tx_tch_mode_req(struct osmocom_ms *ms, uint8_t tch_mode,
/* Transmit ECHO_REQ */
int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len);
/* Transmit info / features negotiation request */
int l1ctl_tx_nego_req(struct osmocom_ms *ms);
/* Transmit L1CTL_RESET_REQ */
int l1ctl_tx_reset_req(struct osmocom_ms *ms, uint8_t type);

View File

@ -1,6 +1,7 @@
#ifndef osmocom_data_h
#define osmocom_data_h
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/core/write_queue.h>
@ -86,6 +87,9 @@ struct osmocom_ms {
struct osmomncc_entity mncc_entity;
struct llist_head trans_list;
/* PHY info / features */
struct msgb *phy_info;
void *lua_state;
int lua_cb_ref;
char *lua_script;
@ -106,6 +110,7 @@ enum osmobb_l1ctl_sig {
S_L1CTL_TCH_MODE_CONF,
S_L1CTL_LOSS_IND,
S_L1CTL_NEIGH_PM_IND,
S_L1CTL_NEGO_IND,
};
enum osmobb_global_sig {

View File

@ -612,6 +612,19 @@ int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len)
return osmo_send_l1(ms, msg);
}
int l1ctl_tx_nego_req(struct osmocom_ms *ms)
{
struct msgb *msg;
msg = osmo_l1_alloc(L1CTL_PHY_NEGO_REQ);
if (!msg)
return -ENOMEM;
/* TODO: the host side might also indicate some info... */
return osmo_send_l1(ms, msg);
}
int l1ctl_tx_sim_req(struct osmocom_ms *ms, uint8_t *data, uint16_t length)
{
struct msgb *msg;
@ -884,6 +897,28 @@ static int rx_l1_neigh_pm_ind(struct osmocom_ms *ms, struct msgb *msg)
return 0;
}
/* Receive L1CTL_PHY_NEGO_IND */
static int rx_l1_nego_ind(struct osmocom_ms *ms, struct msgb *msg)
{
struct l1ctl_phy_nego_ind *hdr;
/* If we already have PHY info, free it */
if (ms->phy_info)
msgb_free(ms->phy_info);
/* Store the received information */
ms->phy_info = msg;
/* Correct the header */
hdr = (struct l1ctl_phy_nego_ind *) msg->l1h;
hdr->len = ntohs(hdr->len);
/* Notify everybody about this great event */
osmo_signal_dispatch(SS_L1CTL, S_L1CTL_NEGO_IND, ms);
return 0;
}
/* Receive incoming data from L1 using L1CTL format */
int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg)
{
@ -952,6 +987,9 @@ int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg)
case L1CTL_TRAFFIC_CONF:
msgb_free(msg);
break;
case L1CTL_PHY_NEGO_IND:
rc = rx_l1_nego_ind(ms, msg);
break;
default:
LOGP(DL1C, LOGL_ERROR, "Unknown MSG: %u\n", hdr->msg_type);
msgb_free(msg);

View File

@ -2,7 +2,7 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBGPS_CFLAGS)
LDADD = ../common/liblayer23.a $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS) $(LIBGPS_LIBS)
bin_PROGRAMS = bcch_scan ccch_scan echo_test cell_log cbch_sniff
bin_PROGRAMS = bcch_scan ccch_scan echo_test cell_log cbch_sniff phy_info
bcch_scan_SOURCES = ../common/main.c app_bcch_scan.c bcch_scan.c
ccch_scan_SOURCES = ../common/main.c app_ccch_scan.c rslms.c
@ -11,3 +11,4 @@ cell_log_LDADD = $(LDADD) -lm
cell_log_SOURCES = ../common/main.c app_cell_log.c cell_log.c \
../../../gsmmap/geo.c
cbch_sniff_SOURCES = ../common/main.c app_cbch_sniff.c
phy_info_SOURCES = ../common/main.c app_phy_info.c

View File

@ -0,0 +1,156 @@
/*
* PHY info / features negotiation test
*
* (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 <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/negotiation.h>
#include <osmocom/core/signal.h>
#include <osmocom/core/msgb.h>
#include <osmocom/bb/common/osmocom_data.h>
#include <osmocom/bb/common/l23_app.h>
#include <osmocom/bb/common/l1ctl.h>
#include <l1ctl_proto.h>
extern int quit;
static struct value_string fdesc[] = {
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BAND_400),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BAND_850),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BAND_900),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BAND_DCS),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BAND_PCS),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CODEC_HR),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CODEC_FR),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CODEC_EFR),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CODEC_HR_AMR),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CODEC_FR_AMR),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CHAN_XCCH),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CHAN_TCHF),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CHAN_TCHH),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CHAN_CBCH),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_CHAN_PTCH),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_1),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_2),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_3),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_4),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_5),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_6),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_A5_7),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_TX),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_FH),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_PM),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_NEIGH_PM),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_SIM),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_MEAS_REP),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BURST_TRX),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_BURST_IND),
OSMO_VALUE_STRING(L1CTL_PHY_FEATURE_TRAFFIC),
{ 0, NULL }
};
static void parse_nego_info(struct msgb *msg)
{
struct l1ctl_phy_nego_ind *hdr;
const uint8_t *features;
size_t features_len;
const char *info;
bool present;
int i;
hdr = (struct l1ctl_phy_nego_ind *) msg->l1h;
info = osmo_nego_get_info(hdr->data, hdr->len, L1CTL_PHY_INFO_NAME);
printf("[i] PHY name: %s\n", info);
features = (uint8_t *) osmo_nego_get_info(hdr->data, hdr->len,
L1CTL_PHY_INFO_FEATURES);
if (!features) {
printf("[!] PHY features: none\n");
quit = 1;
return;
}
/* HACK, modify the API */
features_len = msg->tail - features;
for (i = 0; i < _L1CTL_PHY_FEATURE_MAX; i++) {
present = osmo_nego_check_feature(features, features_len, i);
if (present)
printf("[i] PHY feature: %s\n", get_value_string(fdesc, i));
}
/* We are done */
quit = 1;
}
static int signal_cb(unsigned int subsys, unsigned int signal,
void *handler_data, void *signal_data)
{
struct osmocom_ms *ms = (struct osmocom_ms *) signal_data;
/* FIXME: ignore other signals? */
if (subsys != SS_L1CTL)
return 0;
switch (signal) {
case S_L1CTL_RESET:
printf("RESET received, requesting info negotiation again...\n");
l1ctl_tx_nego_req(ms);
break;
case S_L1CTL_NEGO_IND:
printf("Received negotiation response, parsing...\n\n");
parse_nego_info(ms->phy_info);
}
return 0;
}
int l23_app_init(struct osmocom_ms *ms)
{
/* Register L1CTL handler */
osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
/* Send negotiation request and wait for response */
printf("Sending negotiation request...\n");
l1ctl_tx_nego_req(ms);
return 0;
}
static struct l23_app_info info = {
.copyright = "(C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>\n",
};
struct l23_app_info *l23_app_info()
{
return &info;
}