fixeria has uploaded this change for review.

View Change

trxcon: deliver measurement results via the PHYIF primitives

The PHYIF implementation shall not send events to the trxcon_fsm
directly. The measurement command is sent in form of an abstract
PHYIF primitive (PHYIF_CMDT_MEASURE), so it's more logical that
the response is sent in form of a PHYIF primitive too.

Change-Id: Ie20616c288c16559d0a566979b24d57b50369fab
Related: OS#5599
---
M src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
M src/host/trxcon/src/trx_if.c
M src/host/trxcon/src/trxcon.c
3 files changed, 48 insertions(+), 7 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/28/30028/1
diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h b/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
index 037a905..ae272dd 100644
--- a/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
+++ b/src/host/trxcon/include/osmocom/bb/trxcon/phyif.h
@@ -40,12 +40,19 @@
int8_t ta; /* intentionally signed */
};

-/* param of PHYIF_CMDT_MEASURE */
+/* param of PHYIF_CMDT_MEASURE (command) */
struct phyif_cmdp_measure {
uint16_t band_arfcn_start;
uint16_t band_arfcn_stop;
};

+/* param of PHYIF_CMDT_MEASURE (response) */
+struct phyif_rspp_measure {
+ bool last;
+ uint16_t band_arfcn;
+ int dbm;
+};
+
struct phyif_cmd {
enum phyif_cmd_type type;
union {
@@ -57,6 +64,13 @@
} param;
};

+struct phyif_rsp {
+ enum phyif_cmd_type type;
+ union {
+ struct phyif_rspp_measure measure;
+ } param;
+};
+
/* BURST.req - a burst to be transmitted */
struct phyif_burst_req {
uint32_t fn;
@@ -80,4 +94,5 @@
int phyif_handle_burst_ind(void *phyif, const struct phyif_burst_ind *bi);
int phyif_handle_burst_req(void *phyif, const struct phyif_burst_req *br);
int phyif_handle_cmd(void *phyif, const struct phyif_cmd *cmd);
+int phyif_handle_rsp(void *phyif, const struct phyif_rsp *rsp);
void phyif_close(void *phyif);
diff --git a/src/host/trxcon/src/trx_if.c b/src/host/trxcon/src/trx_if.c
index 7f3ce08..4074ba8 100644
--- a/src/host/trxcon/src/trx_if.c
+++ b/src/host/trxcon/src/trx_if.c
@@ -372,7 +372,6 @@

static void trx_if_measure_rsp_cb(struct trx_instance *trx, char *resp)
{
- struct trxcon_inst *trxcon = trx->trxcon;
unsigned int freq10;
uint16_t band_arfcn;
int dbm;
@@ -391,13 +390,16 @@
return;
}

- struct trxcon_param_full_power_scan_res res = {
- .last_result = band_arfcn == trx->pm_band_arfcn_stop,
- .band_arfcn = band_arfcn,
- .dbm = dbm,
+ const struct phyif_rsp rsp = {
+ .type = PHYIF_CMDT_MEASURE,
+ .param.measure = {
+ .last = band_arfcn == trx->pm_band_arfcn_stop,
+ .band_arfcn = band_arfcn,
+ .dbm = dbm,
+ },
};

- osmo_fsm_inst_dispatch(trxcon->fi, TRXCON_EV_FULL_POWER_SCAN_RES, &res);
+ phyif_handle_rsp(trx, &rsp);

/* Schedule a next measurement */
if (band_arfcn != trx->pm_band_arfcn_stop) {
diff --git a/src/host/trxcon/src/trxcon.c b/src/host/trxcon/src/trxcon.c
index 9522a49..2ea2c40 100644
--- a/src/host/trxcon/src/trxcon.c
+++ b/src/host/trxcon/src/trxcon.c
@@ -177,6 +177,30 @@
return trx_if_handle_phyif_cmd(phyif, cmd);
}

+int phyif_handle_rsp(void *phyif, const struct phyif_rsp *rsp)
+{
+ struct trx_instance *trx = phyif;
+ struct trxcon_inst *trxcon = trx->trxcon;
+
+ switch (rsp->type) {
+ case PHYIF_CMDT_MEASURE:
+ {
+ const struct phyif_rspp_measure *meas = &rsp->param.measure;
+ struct trxcon_param_full_power_scan_res res = {
+ .last_result = meas->last,
+ .band_arfcn = meas->band_arfcn,
+ .dbm = meas->dbm,
+ };
+
+ return osmo_fsm_inst_dispatch(trxcon->fi, TRXCON_EV_FULL_POWER_SCAN_RES, &res);
+ }
+ default:
+ LOGPFSML(trxcon->fi, LOGL_ERROR,
+ "Unhandled PHYIF response (type 0x%02x)\n", rsp->type);
+ return -ENODEV;
+ }
+}
+
void phyif_close(void *phyif)
{
trx_if_close(phyif);

To view, visit change 30028. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ie20616c288c16559d0a566979b24d57b50369fab
Gerrit-Change-Number: 30028
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange