blob: d2a3641a2e116e3f52c89438c0242146f349a107 [file] [log] [blame]
Jacob Erlbeck62e96a32015-06-04 09:42:14 +02001/* pcu_vty_functions.cpp
2 *
3 * Copyright (C) 2015 by Sysmocom s.f.m.c. GmbH
4 * Author: Jacob Erlbeck <jerlbeck@sysmocom.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20/* OsmoBTS VTY interface */
21
22
23#include <stdint.h>
24#include <stdlib.h>
25#include "pcu_vty_functions.h"
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020026#include "bts.h"
27#include "gprs_ms_storage.h"
28#include "gprs_ms.h"
29#include "cxx_linuxlist.h"
Jacob Erlbeck62e96a32015-06-04 09:42:14 +020030
31extern "C" {
32# include <osmocom/vty/command.h>
33# include <osmocom/vty/logging.h>
34# include <osmocom/vty/misc.h>
35}
36
37int pcu_vty_config_write_pcu_ext(struct vty *vty)
38{
39 return CMD_SUCCESS;
40}
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020041
42int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
43{
44 BTS *bts = bts_data->bts;
45 LListHead<GprsMs> *ms_iter;
46
47 llist_for_each(ms_iter, &bts->ms_store().ms_list()) {
48 GprsMs *ms = ms_iter->entry();
49
Jacob Erlbeck159d4de2015-08-21 16:02:11 +020050 vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%d, CS-DL=%d, LLC=%d, "
51 "IMSI=%s%s",
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020052 ms->tlli(),
53 ms->ta(), ms->current_cs_ul(), ms->current_cs_dl(),
Jacob Erlbeck159d4de2015-08-21 16:02:11 +020054 ms->llc_queue()->size(),
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020055 ms->imsi(),
56 VTY_NEWLINE);
57 }
58 return CMD_SUCCESS;
59}
Jacob Erlbeck37e896d2015-06-05 16:33:33 +020060
61static int show_ms(struct vty *vty, GprsMs *ms)
62{
Jacob Erlbeck51b11512015-06-11 16:54:50 +020063 unsigned i;
Jacob Erlbeckc62216b2015-08-21 15:46:16 +020064 LListHead<gprs_rlcmac_tbf> *i_tbf;
Jacob Erlbeck51b11512015-06-11 16:54:50 +020065
Jacob Erlbeck37e896d2015-06-05 16:33:33 +020066 vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE);
67 vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE);
68 vty_out(vty, " Coding scheme uplink: CS-%d%s", ms->current_cs_ul(),
69 VTY_NEWLINE);
70 vty_out(vty, " Coding scheme downlink: CS-%d%s", ms->current_cs_dl(),
71 VTY_NEWLINE);
72 vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE);
73 vty_out(vty, " LLC queue length: %d%s", ms->llc_queue()->size(),
74 VTY_NEWLINE);
Jacob Erlbeck159d4de2015-08-21 16:02:11 +020075 vty_out(vty, " LLC queue octets: %d%s", ms->llc_queue()->octets(),
76 VTY_NEWLINE);
Jacob Erlbecke4bcb622015-06-08 11:26:38 +020077 if (ms->l1_meas()->have_rssi)
78 vty_out(vty, " RSSI: %d dBm%s",
79 ms->l1_meas()->rssi, VTY_NEWLINE);
80 if (ms->l1_meas()->have_ber)
81 vty_out(vty, " Bit error rate: %d %%%s",
82 ms->l1_meas()->ber, VTY_NEWLINE);
83 if (ms->l1_meas()->have_link_qual)
84 vty_out(vty, " Link quality: %d dB%s",
85 ms->l1_meas()->link_qual, VTY_NEWLINE);
86 if (ms->l1_meas()->have_bto)
87 vty_out(vty, " Burst timing offset: %d/4 bit%s",
88 ms->l1_meas()->bto, VTY_NEWLINE);
Jacob Erlbeck51b11512015-06-11 16:54:50 +020089 if (ms->l1_meas()->have_ms_rx_qual)
Jacob Erlbeck04a10862015-06-12 16:01:56 +020090 vty_out(vty, " Downlink NACK rate: %d %%%s",
91 ms->nack_rate_dl(), VTY_NEWLINE);
92 if (ms->l1_meas()->have_ms_rx_qual)
Jacob Erlbeck51b11512015-06-11 16:54:50 +020093 vty_out(vty, " MS RX quality: %d %%%s",
94 ms->l1_meas()->ms_rx_qual, VTY_NEWLINE);
95 if (ms->l1_meas()->have_ms_c_value)
96 vty_out(vty, " MS C value: %d dB%s",
97 ms->l1_meas()->ms_c_value, VTY_NEWLINE);
98 if (ms->l1_meas()->have_ms_sign_var)
99 vty_out(vty, " MS SIGN variance: %d dB%s",
100 ms->l1_meas()->ms_sign_var, VTY_NEWLINE);
101 for (i = 0; i < ARRAY_SIZE(ms->l1_meas()->ts); ++i) {
102 if (ms->l1_meas()->ts[i].have_ms_i_level)
103 vty_out(vty, " MS I level (slot %d): %d dB%s",
104 i, ms->l1_meas()->ts[i].ms_i_level, VTY_NEWLINE);
105 }
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200106 if (ms->ul_tbf())
107 vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s",
108 ms->ul_tbf()->tfi(),
109 ms->ul_tbf()->state_name(),
110 VTY_NEWLINE);
111 if (ms->dl_tbf())
112 vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s",
113 ms->dl_tbf()->tfi(),
114 ms->dl_tbf()->state_name(),
115 VTY_NEWLINE);
116
Jacob Erlbeckc62216b2015-08-21 15:46:16 +0200117 llist_for_each(i_tbf, &ms->old_tbfs())
118 vty_out(vty, " Old %-19s TFI=%d, state=%s%s",
119 i_tbf->entry()->direction == GPRS_RLCMAC_UL_TBF ?
120 "Uplink TBF:" : "Downlink TBF:",
121 i_tbf->entry()->tfi(),
122 i_tbf->entry()->state_name(),
123 VTY_NEWLINE);
124
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200125 return CMD_SUCCESS;
126}
127
128int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
129 uint32_t tlli)
130{
131 BTS *bts = bts_data->bts;
132 GprsMs *ms = bts->ms_store().get_ms(tlli);
133 if (!ms) {
134 vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE);
135 return CMD_WARNING;
136 }
137
138 return show_ms(vty, ms);
139}
140
141int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
142 const char *imsi)
143{
144 BTS *bts = bts_data->bts;
145 GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi);
146 if (!ms) {
147 vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE);
148 return CMD_WARNING;
149 }
150
151 return show_ms(vty, ms);
152}