aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-octphy
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-01-30 19:07:03 +0100
committerHarald Welte <laforge@gnumonks.org>2017-02-22 10:09:32 +0000
commit758522947f2937a1d17b6c3988b03abc80bd0051 (patch)
tree7005535cee72639a8bdebbe62ab568a9ae94f435 /src/osmo-bts-octphy
parent64d16028eb7d38bb442591c6c0224ae28eb3e2be (diff)
octphy: Fix VTY commands
The VTY commands show phy 0 rf-port-stats and show phy 0 clk-sync-stats do not output their results on the VTY console. If one of those commands is entered the user is prompted to view the logtext, which is an uncomfortable solution. This commit adds the missing functionality to print the information in the VTY as well. octphy_hw_api.c contains two value_string structs (radio_std_vals and clocksync_state_vals) which are now exported in octphy_hw_api.h in order to access them from octphy_vty.c Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61
Diffstat (limited to 'src/osmo-bts-octphy')
-rw-r--r--src/osmo-bts-octphy/octphy_hw_api.c51
-rw-r--r--src/osmo-bts-octphy/octphy_hw_api.h44
-rw-r--r--src/osmo-bts-octphy/octphy_vty.c89
3 files changed, 139 insertions, 45 deletions
diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c
index dc23676c..6666f77c 100644
--- a/src/osmo-bts-octphy/octphy_hw_api.c
+++ b/src/osmo-bts-octphy/octphy_hw_api.c
@@ -29,6 +29,7 @@
#include "l1_if.h"
#include "l1_oml.h"
#include "l1_utils.h"
+#include "octphy_hw_api.h"
#include <octphy/octvc1/octvc1_rc2string.h>
#include <octphy/octvc1/hw/octvc1_hw_api.h>
@@ -105,18 +106,12 @@ int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index)
return l1if_req_compl(fl1h, msg, rf_port_info_compl_cb, NULL);
}
-static const struct value_string radio_std_vals[] = {
- { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" },
- { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" },
- { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" },
- { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" },
- { 0, NULL }
-};
-
/* Chapter 12.10 */
static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp,
void *data)
{
+ struct octphy_hw_get_cb_data *get_cb_data;
+
tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr =
(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) resp->l2h;
@@ -136,12 +131,16 @@ static int rf_port_stats_compl_cb(struct octphy_hdl *fl1, struct msgb *resp,
psr->TxStats.ulTxAveragePeriodUs,
psr->TxStats.ulFrequencyKhz);
+ get_cb_data = (struct octphy_hw_get_cb_data*) data;
+ get_cb_data->cb(resp,get_cb_data->data);
+
msgb_free(resp);
return 0;
}
/* Chapter 12.10 */
-int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index)
+int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index,
+ struct octphy_hw_get_cb_data *cb_data)
{
struct msgb *msg = l1p_msgb_alloc();
tOCTVC1_HW_MSG_RF_PORT_STATS_CMD *psc;
@@ -156,7 +155,7 @@ int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index)
mOCTVC1_HW_MSG_RF_PORT_STATS_CMD_SWAP(psc);
- return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, NULL);
+ return l1if_req_compl(fl1h, msg, rf_port_stats_compl_cb, cb_data);
}
static const struct value_string rx_gain_mode_vals[] = {
@@ -276,28 +275,6 @@ static const struct value_string clocksync_source_state_vals[] = {
{ 0, NULL }
};
-static const struct value_string clocksync_state_vals[] = {
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE,
- "Uninitialized" },
-/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to
- * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef
- * statement ensures that older headers still work. */
-#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" },
-#else
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" },
-#endif
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK,
- "No External Clock" },
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" },
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" },
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" },
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" },
- { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK,
- "Loss of Ext Clock" },
- { 0, NULL }
-};
-
/* Chapter 12.15 */
static int get_clock_sync_compl_cb(struct octphy_hdl *fl1, struct msgb *resp,
void *data)
@@ -336,6 +313,8 @@ int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h)
static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp,
void *data)
{
+ struct octphy_hw_get_cb_data *get_cb_data;
+
tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr =
(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) resp->l2h;
@@ -349,12 +328,16 @@ static int get_clock_sync_stats_cb(struct octphy_hdl *fl1, struct msgb *resp,
csr->ulPllFractionalFreqHz, csr->ulSlipCnt,
csr->ulSyncLosseCnt, csr->ulSourceState, csr->ulDacValue);
+ get_cb_data = (struct octphy_hw_get_cb_data*) data;
+ get_cb_data->cb(resp,get_cb_data->data);
+
msgb_free(resp);
return 0;
}
/* Chapter 12.16 */
-int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h)
+int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h,
+ struct octphy_hw_get_cb_data *cb_data)
{
struct msgb *msg = l1p_msgb_alloc();
tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD *csc;
@@ -366,6 +349,6 @@ int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h)
mOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_CMD_SWAP(csc);
- return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, NULL);
+ return l1if_req_compl(fl1h, msg, get_clock_sync_stats_cb, cb_data);
}
diff --git a/src/osmo-bts-octphy/octphy_hw_api.h b/src/osmo-bts-octphy/octphy_hw_api.h
index bc8ab68d..78b72086 100644
--- a/src/osmo-bts-octphy/octphy_hw_api.h
+++ b/src/osmo-bts-octphy/octphy_hw_api.h
@@ -2,13 +2,53 @@
#include <stdint.h>
#include "l1_if.h"
+#include <octphy/octvc1/hw/octvc1_hw_api.h>
+
+static const struct value_string radio_std_vals[] = {
+ { cOCTVC1_RADIO_STANDARD_ENUM_GSM, "GSM" },
+ { cOCTVC1_RADIO_STANDARD_ENUM_UMTS, "UMTS" },
+ { cOCTVC1_RADIO_STANDARD_ENUM_LTE, "LTE" },
+ { cOCTVC1_RADIO_STANDARD_ENUM_INVALID, "INVALID" },
+ { 0, NULL }
+};
+
+static const struct value_string clocksync_state_vals[] = {
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNINITIALIZE,
+ "Uninitialized" },
+/* Note: Octasic renamed cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED to
+ * cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE. The following ifdef
+ * statement ensures that older headers still work. */
+#ifdef cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNUSED, "Unused" },
+#else
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_IDLE, "Idle" },
+#endif
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_NO_EXT_CLOCK,
+ "No External Clock" },
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOCKED, "Locked" },
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_UNLOCKED,"Unlocked" },
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_ERROR, "Error" },
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_DISABLE, "Disabled" },
+ { cOCTVC1_HW_CLOCK_SYNC_MGR_STATE_ENUM_LOSS_EXT_CLOCK,
+ "Loss of Ext Clock" },
+ { 0, NULL }
+};
+
+typedef void octphy_hw_get_cb(struct msgb *resp, void *data);
+
+struct octphy_hw_get_cb_data {
+ octphy_hw_get_cb* cb;
+ void *data;
+};
int octphy_hw_get_pcb_info(struct octphy_hdl *fl1h);
int octphy_hw_get_rf_port_info(struct octphy_hdl *fl1h, uint32_t index);
-int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index);
+int octphy_hw_get_rf_port_stats(struct octphy_hdl *fl1h, uint32_t index,
+ struct octphy_hw_get_cb_data *cb_data);
int octphy_hw_get_rf_ant_rx_config(struct octphy_hdl *fl1h, uint32_t port_idx,
uint32_t ant_idx);
int octphy_hw_get_rf_ant_tx_config(struct octphy_hdl *fl1h, uint32_t port_idx,
uint32_t ant_idx);
int octphy_hw_get_clock_sync_info(struct octphy_hdl *fl1h);
-int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h);
+int octphy_hw_get_clock_sync_stats(struct octphy_hdl *fl1h,
+ struct octphy_hw_get_cb_data *cb_data);
diff --git a/src/osmo-bts-octphy/octphy_vty.c b/src/osmo-bts-octphy/octphy_vty.c
index abfac1ed..bc4acd65 100644
--- a/src/osmo-bts-octphy/octphy_vty.c
+++ b/src/osmo-bts-octphy/octphy_vty.c
@@ -159,6 +159,45 @@ DEFUN(cfg_phy_tx_atten_db, cfg_phy_tx_atten_db_cmd,
return CMD_SUCCESS;
}
+void show_rf_port_stats_cb(struct msgb *resp, void *data)
+{
+ struct vty *vty = (struct vty*) data;
+ tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *psr;
+
+ if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) {
+ vty_out(vty,
+ "invalid msgb size (%d bytes, expected %zu bytes)%s",
+ msgb_l2len(resp),
+ sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP), VTY_NEWLINE);
+ return;
+ }
+
+ psr = (tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *) msgb_l2(resp);
+
+ vty_out(vty, "%s", VTY_NEWLINE);
+ vty_out(vty, "RF-PORT-STATS:%s", VTY_NEWLINE);
+ vty_out(vty, "Idx=%d%s", psr->ulPortIndex, VTY_NEWLINE);
+ vty_out(vty, "RadioStandard=%s%s",
+ get_value_string(radio_std_vals, psr->ulRadioStandard),
+ VTY_NEWLINE);
+ vty_out(vty, "Rx Bytes=%u%s", psr->RxStats.ulRxByteCnt, VTY_NEWLINE);
+ vty_out(vty, "Rx Overflow=%u%s", psr->RxStats.ulRxOverflowCnt,
+ VTY_NEWLINE);
+ vty_out(vty, "Rx AvgBps=%u%s", psr->RxStats.ulRxAverageBytePerSecond,
+ VTY_NEWLINE);
+ vty_out(vty, "Rx Period=%u%s", psr->RxStats.ulRxAveragePeriodUs,
+ VTY_NEWLINE);
+ vty_out(vty, "Rx Freq=%u%s", psr->RxStats.ulFrequencyKhz, VTY_NEWLINE);
+ vty_out(vty, "Tx Bytes=%u%s", psr->TxStats.ulTxByteCnt, VTY_NEWLINE);
+ vty_out(vty, "Tx Underflow=%u%s", psr->TxStats.ulTxUnderflowCnt,
+ VTY_NEWLINE);
+ vty_out(vty, "Tx AvgBps=%u%s", psr->TxStats.ulTxAverageBytePerSecond,
+ VTY_NEWLINE);
+ vty_out(vty, "Tx Period=%u%s", psr->TxStats.ulTxAveragePeriodUs,
+ VTY_NEWLINE);
+ vty_out(vty, "Tx Freq=%u%s", psr->TxStats.ulFrequencyKhz, VTY_NEWLINE);
+}
+
DEFUN(show_rf_port_stats, show_rf_port_stats_cmd,
"show phy <0-255> rf-port-stats <0-1>",
"Show statistics for the RF Port\n"
@@ -166,29 +205,61 @@ DEFUN(show_rf_port_stats, show_rf_port_stats_cmd,
{
int phy_nr = atoi(argv[0]);
struct phy_link *plink = phy_link_by_num(phy_nr);
+ static struct octphy_hw_get_cb_data cb_data;
- octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]));
+ cb_data.cb = show_rf_port_stats_cb;
+ cb_data.data = vty;
- /* FIXME: Actually print to VTY, not just log */
- vty_out(vty, "Please check the log file for the response%s",
- VTY_NEWLINE);
+ octphy_hw_get_rf_port_stats(plink->u.octphy.hdl, atoi(argv[1]),
+ &cb_data);
return CMD_SUCCESS;
}
+void show_clk_sync_stats_cb(struct msgb *resp, void *data)
+{
+ struct vty *vty = (struct vty*) data;
+ tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *csr;
+
+ if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) !=
+ msgb_l2len(resp)) {
+ vty_out(vty,
+ "invalid msgb size (%d bytes, expected %zu bytes)%s",
+ msgb_l2len(resp),
+ sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP),
+ VTY_NEWLINE);
+ return;
+ }
+
+ csr = (tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *) msgb_l2(resp);
+
+ vty_out(vty, "%s", VTY_NEWLINE);
+ vty_out(vty, "CLOCK-SYNC-MGR-STATS:%s", VTY_NEWLINE);
+ vty_out(vty, "State=%s%s",
+ get_value_string(clocksync_state_vals, csr->ulState),
+ VTY_NEWLINE);
+ vty_out(vty, "ClockError=%d%s", csr->lClockError, VTY_NEWLINE);
+ vty_out(vty, "DroppedCycles=%d%s", csr->lDroppedCycles, VTY_NEWLINE);
+ vty_out(vty, "PllFreqHz=%u%s", csr->ulPllFreqHz, VTY_NEWLINE);
+ vty_out(vty, "PllFract=%u%s", csr->ulPllFractionalFreqHz, VTY_NEWLINE);
+ vty_out(vty, "SlipCnt=%u%s", csr->ulSlipCnt, VTY_NEWLINE);
+ vty_out(vty, "SyncLosses=%u%s", csr->ulSyncLosseCnt, VTY_NEWLINE);
+ vty_out(vty, "SourceState=%u%s", csr->ulSourceState, VTY_NEWLINE);
+ vty_out(vty, "DacValue=%u%s", csr->ulDacValue, VTY_NEWLINE);
+}
+
DEFUN(show_clk_sync_stats, show_clk_sync_stats_cmd,
"show phy <0-255> clk-sync-stats",
"Obtain statistics for the Clock Sync Manager\n")
{
int phy_nr = atoi(argv[0]);
struct phy_link *plink = phy_link_by_num(phy_nr);
+ static struct octphy_hw_get_cb_data cb_data;
- octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl);
-
- /* FIXME: Actually print to VTY, not just log */
- vty_out(vty, "Please check the log file for the response%s",
- VTY_NEWLINE);
+ cb_data.cb = show_clk_sync_stats_cb;
+ cb_data.data = vty;
+ octphy_hw_get_clock_sync_stats(plink->u.octphy.hdl, &cb_data);
return CMD_SUCCESS;
}