Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 1 | /* 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 Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 26 | #include "bts.h" |
| 27 | #include "gprs_ms_storage.h" |
| 28 | #include "gprs_ms.h" |
| 29 | #include "cxx_linuxlist.h" |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 30 | #include <gprs_coding_scheme.h> |
| 31 | #include <llc.h> |
| 32 | #include <pcu_l1_if.h> |
| 33 | #include <rlc.h> |
| 34 | #include <tbf.h> |
Pau Espin Pedrol | 9d1cdb1 | 2019-09-25 17:47:02 +0200 | [diff] [blame] | 35 | #include <tbf_ul.h> |
Max | 6dc90b8 | 2018-02-19 17:17:28 +0100 | [diff] [blame] | 36 | #include <pdch.h> |
Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 37 | |
| 38 | extern "C" { |
Max | d2d51ed | 2018-01-25 15:41:28 +0100 | [diff] [blame] | 39 | #include <osmocom/vty/command.h> |
| 40 | #include <osmocom/vty/logging.h> |
| 41 | #include <osmocom/vty/misc.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 42 | #include <osmocom/core/linuxlist.h> |
| 43 | #include <osmocom/core/utils.h> |
| 44 | #include <osmocom/vty/vty.h> |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 45 | #include "coding_scheme.h" |
Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 46 | } |
| 47 | |
Max | 12a0987 | 2018-02-01 16:07:33 +0100 | [diff] [blame] | 48 | static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf, bool show_ccch, bool show_pacch) |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 49 | { |
Jacob Erlbeck | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 50 | gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf); |
| 51 | gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf); |
| 52 | |
Max | 12a0987 | 2018-02-01 16:07:33 +0100 | [diff] [blame] | 53 | if (show_ccch && !(tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) |
| 54 | return; |
| 55 | |
| 56 | if (show_pacch && !(tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))) |
| 57 | return; |
| 58 | |
Minh-Quang Nguyen | 8d55563 | 2017-11-01 15:00:08 -0400 | [diff] [blame] | 59 | vty_out(vty, "TBF: TFI=%d TLLI=0x%08x (%s) TA=%u DIR=%s IMSI=%s%s", tbf->tfi(), |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 60 | tbf->tlli(), tbf->is_tlli_valid() ? "valid" : "invalid", |
Minh-Quang Nguyen | 8d55563 | 2017-11-01 15:00:08 -0400 | [diff] [blame] | 61 | tbf->ta(), |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 62 | tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL", |
| 63 | tbf->imsi(), VTY_NEWLINE); |
Max | 5441e1f | 2018-01-30 17:49:53 +0100 | [diff] [blame] | 64 | vty_out(vty, " created=%lu state=%08x [CCCH:%u, PACCH:%u] 1st_TS=%d 1st_cTS=%d ctrl_TS=%d MS_CLASS=%d/%d%s", |
| 65 | tbf->created_ts(), tbf->state_flags, |
| 66 | tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH), |
| 67 | tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH), |
| 68 | tbf->first_ts, |
Jacob Erlbeck | f2694b7 | 2016-01-26 21:46:26 +0100 | [diff] [blame] | 69 | tbf->first_common_ts, tbf->control_ts, |
| 70 | tbf->ms_class(), |
Jacob Erlbeck | 08c72fb | 2016-01-19 16:04:30 +0100 | [diff] [blame] | 71 | tbf->ms() ? tbf->ms()->egprs_ms_class() : -1, |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 72 | VTY_NEWLINE); |
| 73 | vty_out(vty, " TS_alloc="); |
| 74 | for (int i = 0; i < 8; i++) { |
Jacob Erlbeck | 81a04f7 | 2016-01-28 16:14:58 +0100 | [diff] [blame] | 75 | bool is_ctrl = tbf->is_control_ts(i); |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 76 | if (tbf->pdch[i]) |
Jacob Erlbeck | 81a04f7 | 2016-01-28 16:14:58 +0100 | [diff] [blame] | 77 | vty_out(vty, "%d%s ", i, is_ctrl ? "!" : ""); |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 78 | } |
Mrinal Mishra | d453eaa | 2016-10-26 15:41:56 +0530 | [diff] [blame] | 79 | if (tbf->trx != NULL) |
| 80 | vty_out(vty, " TRX_ID=%d", tbf->trx->trx_no); |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 81 | vty_out(vty, " CS=%s", mcs_name(tbf->current_cs())); |
Jacob Erlbeck | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 82 | |
| 83 | if (ul_tbf) { |
Max | 00fd0df | 2018-01-12 16:24:18 +0100 | [diff] [blame] | 84 | gprs_rlc_ul_window *win = ul_tbf->window(); |
Max | a4f570f | 2017-12-15 11:21:57 +0100 | [diff] [blame] | 85 | vty_out(vty, " WS=%u V(Q)=%d V(R)=%d", |
| 86 | ul_tbf->window_size(), win->v_q(), win->v_r()); |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 87 | vty_out(vty, "%s", VTY_NEWLINE); |
| 88 | vty_out(vty, " TBF Statistics:%s", VTY_NEWLINE); |
Max | a4de02d | 2019-03-13 16:35:09 +0100 | [diff] [blame] | 89 | if(GPRS == tbf->ms()->mode()) { |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 90 | vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_gprs_ctrs); |
| 91 | } else { |
| 92 | vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_egprs_ctrs); |
| 93 | } |
Jacob Erlbeck | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 94 | } |
| 95 | if (dl_tbf) { |
Max | 00fd0df | 2018-01-12 16:24:18 +0100 | [diff] [blame] | 96 | gprs_rlc_dl_window *win = dl_tbf->window(); |
Max | a4f570f | 2017-12-15 11:21:57 +0100 | [diff] [blame] | 97 | vty_out(vty, " WS=%u V(A)=%d V(S)=%d nBSN=%d%s", |
| 98 | dl_tbf->window_size(), win->v_a(), win->v_s(), win->resend_needed(), |
Jacob Erlbeck | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 99 | win->window_stalled() ? " STALLED" : ""); |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 100 | vty_out(vty, "%s", VTY_NEWLINE); |
| 101 | vty_out_rate_ctr_group(vty, " ", tbf->m_ctrs); |
Max | a4de02d | 2019-03-13 16:35:09 +0100 | [diff] [blame] | 102 | if(GPRS == tbf->ms()->mode()) { |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 103 | vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_gprs_ctrs); |
| 104 | } else { |
| 105 | vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_egprs_ctrs); |
| 106 | } |
Jacob Erlbeck | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 107 | } |
| 108 | vty_out(vty, "%s%s", VTY_NEWLINE, VTY_NEWLINE); |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 109 | } |
| 110 | |
Max | 12a0987 | 2018-02-01 16:07:33 +0100 | [diff] [blame] | 111 | int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data, bool show_ccch, bool show_pacch) |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 112 | { |
| 113 | BTS *bts = bts_data->bts; |
| 114 | LListHead<gprs_rlcmac_tbf> *ms_iter; |
| 115 | |
| 116 | vty_out(vty, "UL TBFs%s", VTY_NEWLINE); |
| 117 | llist_for_each(ms_iter, &bts->ul_tbfs()) |
Max | 12a0987 | 2018-02-01 16:07:33 +0100 | [diff] [blame] | 118 | tbf_print_vty_info(vty, ms_iter->entry(), show_ccch, show_pacch); |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 119 | |
| 120 | vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE); |
| 121 | llist_for_each(ms_iter, &bts->dl_tbfs()) |
Max | 12a0987 | 2018-02-01 16:07:33 +0100 | [diff] [blame] | 122 | tbf_print_vty_info(vty, ms_iter->entry(), show_ccch, show_pacch); |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 123 | |
| 124 | return CMD_SUCCESS; |
| 125 | } |
| 126 | |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 127 | int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data) |
| 128 | { |
| 129 | BTS *bts = bts_data->bts; |
| 130 | LListHead<GprsMs> *ms_iter; |
| 131 | |
| 132 | llist_for_each(ms_iter, &bts->ms_store().ms_list()) { |
| 133 | GprsMs *ms = ms_iter->entry(); |
| 134 | |
Max | 39eb95f | 2017-12-06 13:13:34 +0100 | [diff] [blame] | 135 | vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%s, CS-DL=%s, LLC=%zd, Cl=%d, E-Cl=%d," |
| 136 | " TBF-UL=%s, TBF-DL=%s, IMSI=%s%s", |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 137 | ms->tlli(), |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 138 | ms->ta(), mcs_name(ms->current_cs_ul()), |
| 139 | mcs_name(ms->current_cs_dl()), |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 140 | ms->llc_queue()->size(), |
Max | 39eb95f | 2017-12-06 13:13:34 +0100 | [diff] [blame] | 141 | ms->ms_class(), |
| 142 | ms->egprs_ms_class(), |
| 143 | ms->ul_tbf() ? ms->ul_tbf()->state_name() : "NA", |
| 144 | ms->dl_tbf() ? ms->dl_tbf()->state_name() : "NA", |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 145 | ms->imsi(), |
| 146 | VTY_NEWLINE); |
| 147 | } |
| 148 | return CMD_SUCCESS; |
| 149 | } |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 150 | |
| 151 | static int show_ms(struct vty *vty, GprsMs *ms) |
| 152 | { |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 153 | unsigned i; |
Jacob Erlbeck | c62216b | 2015-08-21 15:46:16 +0200 | [diff] [blame] | 154 | LListHead<gprs_rlcmac_tbf> *i_tbf; |
Jacob Erlbeck | 7c72aca | 2016-01-22 17:06:14 +0100 | [diff] [blame] | 155 | uint8_t slots; |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 156 | |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 157 | vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE); |
| 158 | vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE); |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 159 | vty_out(vty, " Coding scheme uplink: %s%s", mcs_name(ms->current_cs_ul()), |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 160 | VTY_NEWLINE); |
Max | 136ebcc | 2019-03-05 14:59:03 +0100 | [diff] [blame] | 161 | vty_out(vty, " Coding scheme downlink: %s%s", mcs_name(ms->current_cs_dl()), |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 162 | VTY_NEWLINE); |
Max | a4de02d | 2019-03-13 16:35:09 +0100 | [diff] [blame] | 163 | vty_out(vty, " Mode: %s%s", mode_name(ms->mode()), VTY_NEWLINE); |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 164 | vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE); |
Jacob Erlbeck | c3c5804 | 2015-09-28 17:55:32 +0200 | [diff] [blame] | 165 | vty_out(vty, " EGPRS MS class: %d%s", ms->egprs_ms_class(), VTY_NEWLINE); |
Jacob Erlbeck | 7c72aca | 2016-01-22 17:06:14 +0100 | [diff] [blame] | 166 | vty_out(vty, " PACCH: "); |
| 167 | slots = ms->current_pacch_slots(); |
| 168 | for (int i = 0; i < 8; i++) |
| 169 | if (slots & (1 << i)) |
| 170 | vty_out(vty, "%d ", i); |
| 171 | vty_out(vty, "%s", VTY_NEWLINE); |
Harald Welte | 63d33ad | 2016-03-30 22:08:18 +0200 | [diff] [blame] | 172 | vty_out(vty, " LLC queue length: %zd%s", ms->llc_queue()->size(), |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 173 | VTY_NEWLINE); |
Harald Welte | 63d33ad | 2016-03-30 22:08:18 +0200 | [diff] [blame] | 174 | vty_out(vty, " LLC queue octets: %zd%s", ms->llc_queue()->octets(), |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 175 | VTY_NEWLINE); |
Jacob Erlbeck | e4bcb62 | 2015-06-08 11:26:38 +0200 | [diff] [blame] | 176 | if (ms->l1_meas()->have_rssi) |
| 177 | vty_out(vty, " RSSI: %d dBm%s", |
| 178 | ms->l1_meas()->rssi, VTY_NEWLINE); |
| 179 | if (ms->l1_meas()->have_ber) |
| 180 | vty_out(vty, " Bit error rate: %d %%%s", |
| 181 | ms->l1_meas()->ber, VTY_NEWLINE); |
| 182 | if (ms->l1_meas()->have_link_qual) |
| 183 | vty_out(vty, " Link quality: %d dB%s", |
| 184 | ms->l1_meas()->link_qual, VTY_NEWLINE); |
| 185 | if (ms->l1_meas()->have_bto) |
| 186 | vty_out(vty, " Burst timing offset: %d/4 bit%s", |
| 187 | ms->l1_meas()->bto, VTY_NEWLINE); |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 188 | if (ms->l1_meas()->have_ms_rx_qual) |
Jacob Erlbeck | 04a1086 | 2015-06-12 16:01:56 +0200 | [diff] [blame] | 189 | vty_out(vty, " Downlink NACK rate: %d %%%s", |
| 190 | ms->nack_rate_dl(), VTY_NEWLINE); |
| 191 | if (ms->l1_meas()->have_ms_rx_qual) |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 192 | vty_out(vty, " MS RX quality: %d %%%s", |
| 193 | ms->l1_meas()->ms_rx_qual, VTY_NEWLINE); |
| 194 | if (ms->l1_meas()->have_ms_c_value) |
| 195 | vty_out(vty, " MS C value: %d dB%s", |
| 196 | ms->l1_meas()->ms_c_value, VTY_NEWLINE); |
| 197 | if (ms->l1_meas()->have_ms_sign_var) |
| 198 | vty_out(vty, " MS SIGN variance: %d dB%s", |
| 199 | ms->l1_meas()->ms_sign_var, VTY_NEWLINE); |
| 200 | for (i = 0; i < ARRAY_SIZE(ms->l1_meas()->ts); ++i) { |
| 201 | if (ms->l1_meas()->ts[i].have_ms_i_level) |
| 202 | vty_out(vty, " MS I level (slot %d): %d dB%s", |
| 203 | i, ms->l1_meas()->ts[i].ms_i_level, VTY_NEWLINE); |
| 204 | } |
sivasankari | da7250a | 2016-12-16 12:57:18 +0530 | [diff] [blame] | 205 | vty_out(vty, " RLC/MAC DL Control Msg: %d%s", ms->dl_ctrl_msg(), |
| 206 | VTY_NEWLINE); |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 207 | if (ms->ul_tbf()) |
| 208 | vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s", |
| 209 | ms->ul_tbf()->tfi(), |
| 210 | ms->ul_tbf()->state_name(), |
| 211 | VTY_NEWLINE); |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 212 | if (ms->dl_tbf()) { |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 213 | vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s", |
| 214 | ms->dl_tbf()->tfi(), |
| 215 | ms->dl_tbf()->state_name(), |
| 216 | VTY_NEWLINE); |
sivasankari | 5395073 | 2016-12-08 17:15:17 +0530 | [diff] [blame] | 217 | vty_out(vty, " Current DL Throughput: %d Kbps %s", |
| 218 | ms->dl_tbf()->m_bw.dl_throughput, |
| 219 | VTY_NEWLINE); |
| 220 | } |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 221 | |
Jacob Erlbeck | c62216b | 2015-08-21 15:46:16 +0200 | [diff] [blame] | 222 | llist_for_each(i_tbf, &ms->old_tbfs()) |
| 223 | vty_out(vty, " Old %-19s TFI=%d, state=%s%s", |
| 224 | i_tbf->entry()->direction == GPRS_RLCMAC_UL_TBF ? |
| 225 | "Uplink TBF:" : "Downlink TBF:", |
| 226 | i_tbf->entry()->tfi(), |
| 227 | i_tbf->entry()->state_name(), |
| 228 | VTY_NEWLINE); |
| 229 | |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 230 | return CMD_SUCCESS; |
| 231 | } |
| 232 | |
| 233 | int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 234 | uint32_t tlli) |
| 235 | { |
| 236 | BTS *bts = bts_data->bts; |
| 237 | GprsMs *ms = bts->ms_store().get_ms(tlli); |
| 238 | if (!ms) { |
| 239 | vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE); |
| 240 | return CMD_WARNING; |
| 241 | } |
| 242 | |
| 243 | return show_ms(vty, ms); |
| 244 | } |
| 245 | |
| 246 | int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 247 | const char *imsi) |
| 248 | { |
| 249 | BTS *bts = bts_data->bts; |
| 250 | GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi); |
| 251 | if (!ms) { |
| 252 | vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE); |
| 253 | return CMD_WARNING; |
| 254 | } |
| 255 | |
| 256 | return show_ms(vty, ms); |
| 257 | } |