Change in osmo-trx[master]: radioInterfaceMulti: Fail to tune on freq not following multi-arfcn r...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Jan 7 22:25:02 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-trx/+/16668 )

Change subject: radioInterfaceMulti: Fail to tune on freq not following multi-arfcn restrictions
......................................................................

radioInterfaceMulti: Fail to tune on freq not following multi-arfcn restrictions

multi-arfcn feature uses a hardcoded disposition of logical channels on
a physical channel. Logical channels in the phisical channel are
separated by MCBTS_SPACING Hz, that is 4 GSM ARFCNs.

As a result, multi-arfcn restricts the TRX ARFCN setup to the following:
ARFCN(TRX0)=N, ARFCN(TRX1)=N+1*4, ARFCN(TRX2)=N+2*4, ...

Let's make sure radioInterfaceMulti verifies the requested Rx/Tx
frequencies for each logical channel over TRXC match the restriction
explained above. It will check freq going to be set is indeed separated
by MCBTS_SPACING from already set channels, making sure the ARFCN series
is consistent.

Otherwise, before this patch, one could set in osmo-bsc:
ARFCN(TRX0)=N, ARFCN(TRX1)=N+2

and osmo-trx would silently ack the related Rx/TxTUNE TRXC commands, but
actually still transmit on ARFCN N+4 instead. As a result, in this
scenario TRX!=0 were unusable with multi-arfcn.

Related: OS#4207
Change-Id: I2f3d66a611d3a489b3e4d9431994f4ec77b4460f
---
M Transceiver52M/radioInterface.h
M Transceiver52M/radioInterfaceMulti.cpp
2 files changed, 59 insertions(+), 22 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h
index d9fa414..c75a983 100644
--- a/Transceiver52M/radioInterface.h
+++ b/Transceiver52M/radioInterface.h
@@ -156,16 +156,24 @@
   void close();
 };
 
+struct freq_cfg_state {
+  bool set;
+  double freq_hz;
+};
+
 class RadioInterfaceMulti : public RadioInterface {
 private:
   bool pushBuffer();
   int pullBuffer();
+  bool verify_arfcn_consistency(double freq, size_t chan, bool tx);
   virtual double setTxGain(double dB, size_t chan);
 
   signalVector *outerSendBuffer;
   signalVector *outerRecvBuffer;
   std::vector<signalVector *> history;
   std::vector<bool> active;
+  std::vector<struct freq_cfg_state> rx_freq_state;
+  std::vector<struct freq_cfg_state> tx_freq_state;
 
   Resampler *dnsampler;
   Resampler *upsampler;
diff --git a/Transceiver52M/radioInterfaceMulti.cpp b/Transceiver52M/radioInterfaceMulti.cpp
index 668305c..a0c24b5 100644
--- a/Transceiver52M/radioInterfaceMulti.cpp
+++ b/Transceiver52M/radioInterfaceMulti.cpp
@@ -73,6 +73,8 @@
 	powerScaling.resize(0);
 	history.resize(0);
 	active.resize(0);
+	rx_freq_state.resize(0);
+	tx_freq_state.resize(0);
 
 	RadioInterface::close();
 }
@@ -148,6 +150,8 @@
 	mReceiveFIFO.resize(mChans);
 	powerScaling.resize(mChans);
 	history.resize(mChans);
+	rx_freq_state.resize(mChans);
+	tx_freq_state.resize(mChans);
 	active.resize(MCHANS, false);
 
 	inchunk = RESAMP_INRATE * 4;
@@ -362,42 +366,67 @@
 	return fabs(a - b) < FREQ_DELTA_LIMIT ? true : false;
 }
 
+bool RadioInterfaceMulti::verify_arfcn_consistency(double freq, size_t chan, bool tx)
+{
+	double freq_i;
+	std::string str_dir = tx ? "Tx" : "Rx";
+	std::vector<struct freq_cfg_state> &v = tx ? tx_freq_state : rx_freq_state;
+
+	for (size_t i = 0; i < mChans; i++) {
+		if (i == chan)
+			continue;
+		if (!v[i].set)
+			continue;
+
+		freq_i = v[i].freq_hz + (double) ((int)chan - (int)i) * MCBTS_SPACING;
+		if (!fltcmp(freq, freq_i)) {
+			LOGCHAN(chan, DMAIN, ERROR)
+				<< "Setting " << str_dir << " frequency " << freq
+				<< " is incompatible: already configured channel "
+				<< i << " uses frequency " << v[i].freq_hz
+				<< " (expected " << freq_i << ")";
+			return false;
+		}
+	}
+	v[chan].set = true;
+	v[chan].freq_hz = freq;
+	return true;
+}
+
 bool RadioInterfaceMulti::tuneTx(double freq, size_t chan)
 {
-  if (chan >= mChans)
-    return false;
+	double shift;
 
-  double shift = (double) getFreqShift(mChans);
+	if (chan >= mChans)
+		return false;
 
-  if (!chan)
-    return mDevice->setTxFreq(freq + shift * MCBTS_SPACING);
+	if (!verify_arfcn_consistency(freq, chan, true))
+		return false;
 
-  double center = mDevice->getTxFreq();
-  if (!fltcmp(freq, center + (double) (chan - shift) * MCBTS_SPACING)) {
-    LOG(NOTICE) << "Channel " << chan << " RF Tx frequency offset is "
-                << freq / 1e6 << " MHz";
-  }
+	if (chan == 0) {
+		shift = (double) getFreqShift(mChans);
+		return mDevice->setTxFreq(freq + shift * MCBTS_SPACING);
+	}
 
-  return true;
+	return true;
 }
 
 bool RadioInterfaceMulti::tuneRx(double freq, size_t chan)
 {
-  if (chan >= mChans)
-    return false;
+	double shift;
 
-  double shift = (double) getFreqShift(mChans);
+	if (chan >= mChans)
+		return false;
 
-  if (!chan)
-    return mDevice->setRxFreq(freq + shift * MCBTS_SPACING);
+	if (!verify_arfcn_consistency(freq, chan, false))
+		return false;
 
-  double center = mDevice->getRxFreq();
-  if (!fltcmp(freq, center + (double) (chan - shift) * MCBTS_SPACING)) {
-    LOG(NOTICE) << "Channel " << chan << " RF Rx frequency offset is "
-                << freq / 1e6 << " MHz";
-  }
+	if (chan == 0) {
+		shift = (double) getFreqShift(mChans);
+		return mDevice->setRxFreq(freq + shift * MCBTS_SPACING);
+	}
 
-  return true;
+	return true;
 }
 
 double RadioInterfaceMulti::setRxGain(double db, size_t chan)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/16668
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I2f3d66a611d3a489b3e4d9431994f4ec77b4460f
Gerrit-Change-Number: 16668
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
Gerrit-Reviewer: ttsou <tom at tsou.cc>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200107/646ce535/attachment.htm>


More information about the gerrit-log mailing list