[PATCH] osmo-bts[master]: octphy: Fix VTY commands

dexter gerrit-no-reply at lists.osmocom.org
Thu Feb 2 16:32:09 UTC 2017


Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1711

to look at the new patch set (#2).

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. This commit fixes
the problem

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
---
M src/osmo-bts-octphy/octphy_hw_api.c
M src/osmo-bts-octphy/octphy_hw_api.h
M src/osmo-bts-octphy/octphy_vty.c
3 files changed, 132 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/11/1711/2

diff --git a/src/osmo-bts-octphy/octphy_hw_api.c b/src/osmo-bts-octphy/octphy_hw_api.c
index dc23676..6666f77 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 @@
 	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 @@
 		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 @@
 
 	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 @@
 	{ 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 @@
 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 @@
 		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 @@
 
 	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 bc8ab68..78b7208 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 e134fc5..41292c0 100644
--- a/src/osmo-bts-octphy/octphy_vty.c
+++ b/src/osmo-bts-octphy/octphy_vty.c
@@ -164,6 +164,42 @@
 	return CMD_SUCCESS;
 }
 
+void show_rf_port_stats_cb(struct msgb *resp, void *data)
+{
+	struct vty *vty = (struct vty*) data;
+
+	if (sizeof(tOCTVC1_HW_MSG_RF_PORT_STATS_RSP) != msgb_l2len(resp)) {
+		vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE);
+		return;
+	}
+
+	tOCTVC1_HW_MSG_RF_PORT_STATS_RSP *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"
@@ -171,14 +207,43 @@
 {
 	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;
+
+	if (sizeof(tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP) !=
+	    msgb_l2len(resp)) {
+		vty_out(vty, "Error fetching stats!%s", VTY_NEWLINE);
+		return;
+	}
+
+	tOCTVC1_HW_MSG_CLOCK_SYNC_MGR_STATS_RSP *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,
@@ -187,13 +252,12 @@
 {
 	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);
+	cb_data.cb = show_clk_sync_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_clock_sync_stats(plink->u.octphy.hdl, &cb_data);
 	return CMD_SUCCESS;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/1711
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Iae5aa91fe2ebba7c2874eed88b15ed66e8c9cd61
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list