aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2013-08-29Build: Remove dependency on SVN since we don't use it anymore anywhere.achemeris/stable_threadsAlexander Chemeris1-7/+0
2013-07-16Transceiver52M: fixup for c5da660: We don't need to check for NULL with ↵Alexander Chemeris1-2/+1
delete operator.
2013-07-14CommonLibs: Adding a new ThreadsTest testsuite.Alexander Chemeris2-0/+99
It's very basic at this moment. We should add a stress-test for thread start/stop at least.
2013-07-14CommonLibs: Port InterthreadTest and SocketsTest to the new Thread API.Alexander Chemeris3-93/+137
2013-07-14Transceiver52M: Delay is no longer needed at the transceiver exit, threads ↵Alexander Chemeris1-3/+0
should shut down cleanly.
2013-07-14Transceiver52M: Port all threads to the new Thread interface.Alexander Chemeris5-101/+166
Also note that we introduced shutdown() method for Transceiver threads which implement proper shutdown of threads when they are in blocking read state. This involves using shutdown() on sockets and pushing NULL to queues. With this change we should be able to start/stop transceiver channels at arbitrary moments.
2013-07-14CommonLibs: Rewrite Threads class to be predictable during start/stop.Alexander Chemeris2-46/+329
Current implementation strictly synchronize thread startup and shutdown to make sure a thread is actually started on startThread() exit and that it's stopped on stopThread() exit (or an error is returned). I also changed the Thread class to be used as a parent class for an actual thread. This way we could provide much better logical separation between variables used by different threads. Which will (hopefully) reduce number of issues with inter-thread communications.
2013-07-14CommonLibs: Signal::wait() should return the value which ↵Alexander Chemeris2-5/+5
pthread_cond_timedwait() returns.
2013-07-14CommonLibs: Add shutdown() method to the DatagramSocket class.Alexander Chemeris2-0/+12
This method is useful to abort a blocking operations on a socket during shutdown.
2013-07-14CommonLibs: Allow NULLs to be retrieved from InterthreadQueue.Alexander Chemeris1-1/+2
We need a way to stop InterthreadQueue blocking read to be able to shutdown a thread. The easiest way to do that is to push NULL to the queue, but the original implementation will just ignore that and continue blocking. After the change the blocking read() will exit with NULL result which is perfectly fine with us. Ideally we should change all methods of InterthreadQueue to return a status value to indicate normal exits, timeouts, etc. Right now the only way to indicate an error is returning NULL, which could be a valid operation.
2013-07-14CommonLibs: DEBUG: Mark interthread classes which are not used in OsmoTRX.Alexander Chemeris1-2/+5
2013-07-14Transceiver52M: Remove unused thread mAlignRadioServiceLoopThread;Alexander Chemeris2-3/+0
2013-07-14CommonLibs: Fix compile time warnings.Alexander Chemeris1-1/+1
2013-07-14Transceiver52M: Fix crash in uhd_device destructor due to deleting ↵Alexander Chemeris1-2/+2
statically allocated memory.
2013-07-14Transceiver52M: Setup independent gain and tune elements for dual channelThomas Tsou5-51/+66
2013-07-14Transceiver52M: Disable TSC check on slot settingThomas Tsou1-1/+1
2013-07-14Transceiver52M: Disable dynamic filler table setting and fix deallocationThomas Tsou1-12/+2
2013-06-24Transceiver52M: Fix build in the new repository.Alexander Chemeris1-0/+2
2013-06-24Transceiver52M: Setup UmTRX dual carrier supportThomas Tsou12-669/+227
2013-06-24transceiver: mcbts: remove unused call in drive loopThomas Tsou1-3/+0
Inside the drive loop addRadioVector() is duplicate call that was not removed from the previous separation of the main loop and transceiver instances. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn: refactor to match upstream GSM coreThomas Tsou7-150/+174
This patch aligns the multicarrier (MC) USRP code with released GSM core changes that accommodate the MC RAD1. Primary changes are: 1. Runtime setting of number of channelizer paths 2. Matching channelizer path to ARFCN mapping of GSM core 3. Use a single clock update socket on the drive loop 4. Match transceiver data and control socket ports Setting of channelizer paths (or width) was previously fixed at compile time. In either case, channelizer width is limited by the sample rate of the device and channel spacing of the maximally decimated filterbank. Available settings are 1, 5, and 10 channels, which accommodate any number of ARFCN's in between. Also add the frequency offsets to handle the effective shift in setting RF frequency. Previous assumption was to place C0 at the center frequency, but RAD1 assumes C0 at the leftmost carrier, so adjust accordingly. The rest is general consolidation to mostly match the RAD1 interaction with GSM core. There is some loss of flexibility to run, say, multiple independent instances of OpenBTS through a single bank of channelized transceivers. But, the better compatibility and reduction in code is the appropriate tradeoff. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24uhd: fix local overflow handling of buffer readsThomas Tsou1-1/+1
This patches fixes the hypothetical bug in the read out of the intermediate sample buffer after a local overflow condition. Local overflows - occurring in the intermediate storage buffer and not the UHD transport - should never occur; the existence of a local overflow indicates a significant error elsewhere in the system. For example, if timestamps or timing offsets are ridiculously off, such errors may occur. Nonetheless, handle errors anyways by taking the modulo value of the calculated read index to stay within the buffer and avoid seg faulting. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: create transceivers based on command line argThomas Tsou1-22/+59
Move from the hard coded case of 3 transceiver instances to a command line determined value. 'M' potential channels will be compiled into the build depending on preprocessor selections in radioParams.h. The command line argument must be less M. Channels are selected starting from 0, which is centered on the RF tuning frequency. Subsequent channels are selected by shifting outward from 0 (center) in a left before right pattern. Default channel spacing is 400 kHz. The ordering for supported cases of 1, 5, and 10 path channelizers is as follows. CHAN_M = 1 { 0 } CHAN_M = 5 { 0, 1, 4, 2, 3 } CHAN_M = 10 { 0, 1, 9, 2, 8, 3, 7, 4, 6, 5} Note: Channel 5 for the 10 channel case sits on the Nyquist frequency and is therefor unusable. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24transceiver, uhd: dynamically allocate async event threadThomas Tsou1-5/+14
Similar to the previous commit titled, "multi-arfcn, trx: allocate threads on heap and fix thread release" there is the potential for a segfault on exit if the event thread is never started. As before, address the issue by initializing the Thread pointer with NULL and later allocating the object immediately prior to use. On stop or exit, allow the thread to exit by checking a condition variable. If device is stopped or never started, the same variable can be checked for state, which avoids attempts to deallocate an empty pointer. If there is a better method to shutdown / deallocate using the OpenBTS thread library, please let me know. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: attach FIFO's internally in transceiverThomas Tsou4-14/+3
The original split-transceiver abstraction did not maintain internal instances of the radio interface or drive loop. The FIFO's were attached through external calls. The control loop, however, made such an approach overly difficult, so the transceiver now maintains pointers to the aforementioned objects. In doing so, we no longer need external attachment calls to setup the FIFO's. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: fix infinite energy threshold bugThomas Tsou3-7/+11
This fixes a bug where the energy threshold may reach infinity. The transceiver energy detection threshold increase is dependent on elapsed frames and the previous false detection time. If we assume a (0,0) start time with the actual start time - randomly determined - it's possible to get very large elapsed frame counts at start. Once the threshold hits 'inf' further calculations are impossible and transceiver is locked out from use. Use the actual start time for initializing variables so we avoid this scenario. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: handle thread exiting on shutdownThomas Tsou8-23/+95
Previous approach was to allow stack unwinding to take care shutdown and thread ending, which was unpredictable and occasionally segfault. Attempt to shutdown more gracefully. There are thread cancellation points in the transceiver code using pthread_testcancel(), but the thread abstraction library does not allow direct access to the pthread variables. This prevents thread shutdown through pthread_cancel(). To get around this, use boolean status values in the receive socket service loops and main drive loop. The socket read calls will block indefinitly, so shutdown may cause the socket implementation to throw a SocketError exception. Use of timeout values with reads does not seem to work correctly or reliably, so catch the exception and ignore if it occurs on shutdown. The following error may appear as the socket is shutdown while the Transceiver is blocking on read(). DatagramSocket::read() failed: Bad file descriptor So be it; the API doesn't allow us to do any more. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: allocate threads on heap and fix thread releaseThomas Tsou4-16/+28
The underlying pthread of the Thread object isn't created until Thread::start(). If the Thread object is contructed, but not started, then the destructor will fail with a variety of unpredictable errors such as the following or double free() in certain cases. Program received signal SIGSEGV, Segmentation fault. __GI___libc_free (mem=0x3811abed3e946178) at malloc.c:2972 2972 if (chunk_is_mmapped(p)) If the Thread object is stack allocated, but start() isn't called, destructor is guaranteed to run and will fail. The previous approach was to dynamically allocate threads, but not free them, thus avoiding memory errors, but creating memory leaks. To get around this limitation, dynamically allocate Thread objects and initialize with NULL. Then allocate immediately prior to start such that pthread allocation is tied to the Thread object constructor. Deallocation can check that the Thread pointer is valid through NULL or other tracking methods. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: remove unused reset() call in drive loopThomas Tsou2-7/+1
This call is a remnant of the Transceiver / DriveLoop split. The empty call is never used. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: remove unused attach call()Thomas Tsou1-3/+1
At one point an attach() call was used to connect multiple transceivers to the radio interface. The current approach is to pass the radio interface to the transceiver instances through the constructor. Remove the unused and deprecated call. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: only deallocate radio resouces if startedThomas Tsou1-7/+10
Certain notable variables - sample buffers - are not allocated until start(), which causes a segfault if the transceiver is shutdown without the radio starting. Check that the radio is 'started' before releasing in the destructor. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24transceiver: define virtual destructor for base deviceThomas Tsou1-1/+2
Lack of an explicitly defined virtual destructor was causing the empty default interface destructor to be called, which created a memory leak at shutdown. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: add and modify transceiver main for new interfacesThomas Tsou2-5/+126
Add a transceiver main() for multi-arfcn use and modify single channel transceiver for use with updated interfaces. Setup multiTRX with 3 channels for default case. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: split transceiver to handle multiple channelsThomas Tsou6-415/+566
This patch separates the 'Transceiver' into a multi-channel I/O component and single channel component. The latter may may have multiple instances. The receive FIFO is converted to a thread-safe queue. The 'TransceiverIO' continuously drives the receive and transmit loops. In this process, bursts are driven into thread-safe FIFO's and read from the priority queues. Filler bursts are inserted if no transmit data is available. Each 'Transceiver' instance attaches to the I/O object and creates its own threads and sockets, which include blocking on the receive FIFO for the attached channel. Each instance also handles its own control loop and clock indications. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: modify radio interface for multi-channel useThomas Tsou2-49/+116
The radio interface needs to feed the device I/O buffers synchronously in order to drive the channelizer. Asynchronous channel access occurs opposite the radio interface through a bank of thread-safe FIFO's or priority queue's on receive and transmit sides respectively. Setup 'M' channels and allow only a subset to be active at a given time. When a channel is unused, there is no need to feed the particular receive FIFO or pull data from the channel priority queue. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24multi-arfcn, trx: add header wrappers for radio interfaceThomas Tsou1-1/+4
Signed-off-by: Thomas Tsou <ttsou@vt.edu>
2013-06-24Transceiver52M: Add UmTRX supportThomas Tsou1-3/+10
2013-06-24Transceiver52M: Explicitly check for USRP2 device typeThomas Tsou1-5/+8
Before, we assumed that non-B100 device was implicitly a USRP2 (inclusive of N200/N210). Make the check explicit so that any unknown device will causes an error and exit. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Use exception blocks for rate changesThomas Tsou1-5/+17
UHD will throw if something goes awry in these sensitive sections, so we should catch and shutdown gracefully. There is no recovery if we can't set rates. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Allow tolerance in UHD sample rate selectionThomas Tsou1-5/+8
We're performance floating point comparisons so allow a 10 Hz offset when UHD does not return an exact sample rate; Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Set resampling option automatically based on deviceThomas Tsou11-130/+127
Remove the built time resampling selection and link both options. Move the normal push/pullBuffer() calls back to the base class and overload them in the inherited resampling class. USRP2/N2xx devices are the only devices that require resampling so return that resampling is necessary on the device open(), which is the point at which the device type will be known. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Set sample rate from within the radio deviceThomas Tsou5-20/+41
The GSM transceiver only operates at a whole number multiple of the GSM rate and doesn't care about the actual device rate and if resampling is used. Therefore GSM specific portion of the transceiver should only need to submit the samples-per-symbol value to the device interface. Then, the device should be able to determine the appropriate sample rate (400 ksps or 270.833 ksps) and if resampling is appropriate. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Remove and rename oversampling variablesThomas Tsou3-9/+4
The transceiver only uses a single integer oversampling value, which is more simply referred to as samples-per-symbol. mRadioOversampling --> mSPS mTransceiverOversampling (removed) Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Remove periodic alignment update from UHD buildThomas Tsou3-14/+9
Periodic timing alignment should never be required for UHD devices, though the mechanism was used as a fallback mechanism should UHD not properly recover after an underrun - as may occur in old 003.003.000 based revisions. This issue is not a concern in more recent UHD releases and deprecates this code for legacy USRP1 use only. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Add device offset correction tableThomas Tsou4-28/+63
Previously, two timing correction values were used for UHD devices depending on the sample rate of 270.833e3 or 400e3 for native GSM or resampled device rate respectively. The correction values compensate for residual timing effects due to analog component delays, filters lag times, and general fudge factors. These values are device specific and over-generalized by the two value configuration. This patch adds the following struct to store these correction values by device type and sample rate - through samples-per-symbol. struct uhd_dev_offset { enum uhd_dev_type type; int sps; double offset; }; Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Add UHD device type checkingThomas Tsou5-40/+53
UHD device type was previously detected, but only categorized in terms of bus type, USB or Ethernet, and sample rate capability. With the number of supported device increasing, we can no longer easily group devices since we need to handle more and more device-specific peculiarities. Some of these factors are managed internally by the UHD driver, but other factors (e.g. timing offsets) are specific to a single device. Start by maintaining an enumerated list of relevant device types that we can use for applying device specific operations. Also rename the USB/Ethernet grouping to transmit window type because that's what it is. enum uhd_dev_type { USRP1, USRP2, B100, NUM_USRP_TYPES, }; Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Setup test case for second UmTRX channelThomas Tsou1-9/+26
Feed the second channel with the same data buffer as channel one. The two channel send maintains the same UHD interface, so we use the same metadata for both channels. Hard code the second channel RF frequency as an offset relative to first channel for now. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceiver52M: Update to UHD streamer interfaceThomas Tsou2-29/+16
This patch is long overdue and can now be merged after better understanding of timestamp stability issues. UHD tick / timespec conversions were generally used with the streamer interface, though these calls are actually independent change sets. The combination would lead to internal rounding errors and a timing drift most notably on B100 running at GSM symbol rate multiples. There are no known issues, however, with the streamer code itself. The aforementioned issue was discovered in test code only, which was never merged to mainline. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24umtrx: set timing offset and clocking frequencyThomas Tsou1-2/+2
Measured offset and set to zero based on Nokia 3120 handset. Signed-off-by: Thomas Tsou <tom@tsou.cc>
2013-06-24Transceier52M: Make error response to an unknown command on UDP command ↵Alexander Chemeris1-0/+1
interface more understandable. Previously we just repeated the last response which could confuse a command sender.