Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Commit 78a7a3c

Browse files
committed
radio: event notifier interface renaming and type simplification
1 parent a9ac222 commit 78a7a3c

36 files changed

Lines changed: 273 additions & 314 deletions

apps/examples/radio/radio_notifier_sample.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace srsran {
1717

18-
class radio_notifier_spy : public radio_notification_handler
18+
class radio_notifier_spy : public radio_event_notifier
1919
{
2020
private:
2121
srslog::basic_logger& logger;
@@ -38,44 +38,44 @@ class radio_notifier_spy : public radio_notification_handler
3838
void on_radio_rt_event(const event_description& description) override
3939
{
4040
logger.warning("stream_id={} channel_id={} source={} type={}",
41-
description.stream_id == UNKNOWN_ID ? "na" : std::to_string(description.stream_id),
42-
description.channel_id == UNKNOWN_ID ? "na" : std::to_string(description.channel_id),
43-
description.source.to_string(),
44-
description.type.to_string());
41+
description.stream_id.has_value() ? fmt::to_string(*description.stream_id) : "na",
42+
description.channel_id.has_value() ? fmt::to_string(*description.channel_id) : "na",
43+
to_string(description.source),
44+
to_string(description.type));
4545
switch (description.type) {
46-
case event_type::UNDEFINED:
46+
case radio_event_type::UNDEFINED:
4747
// Ignore.
4848
break;
49-
case event_type::LATE:
50-
if (description.source == event_source::TRANSMIT) {
49+
case radio_event_type::LATE:
50+
if (description.source == radio_event_source::TRANSMIT) {
5151
count_tx_late++;
5252
} else {
5353
count_rx_late++;
5454
}
5555
break;
56-
case event_type::UNDERFLOW:
57-
if (description.source == event_source::TRANSMIT) {
56+
case radio_event_type::UNDERFLOW:
57+
if (description.source == radio_event_source::TRANSMIT) {
5858
count_tx_underflow++;
5959
} else {
6060
count_rx_underflow++;
6161
}
6262
break;
63-
case event_type::OVERFLOW:
64-
if (description.source == event_source::TRANSMIT) {
63+
case radio_event_type::OVERFLOW:
64+
if (description.source == radio_event_source::TRANSMIT) {
6565
count_tx_overflow++;
6666
} else {
6767
count_rx_overflow++;
6868
}
6969
break;
70-
case event_type::OTHER:
71-
if (description.source == event_source::TRANSMIT) {
70+
case radio_event_type::OTHER:
71+
if (description.source == radio_event_source::TRANSMIT) {
7272
count_tx_other++;
7373
} else {
7474
count_rx_other++;
7575
}
7676
break;
77-
case event_type::START_OF_BURST:
78-
case event_type::END_OF_BURST:
77+
case radio_event_type::START_OF_BURST:
78+
case radio_event_type::END_OF_BURST:
7979
// Ignore cases.
8080
break;
8181
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
*
3+
* Copyright 2021-2025 Software Radio Systems Limited
4+
*
5+
* By using this file, you agree to the terms and conditions set
6+
* forth in the LICENSE file which can be found at the top level of
7+
* the distribution.
8+
*
9+
*/
10+
11+
#pragma once
12+
13+
#include "srsran/radio/radio_base.h"
14+
#include <cstdint>
15+
#include <optional>
16+
17+
namespace srsran {
18+
19+
/// Radio event sources.
20+
enum class radio_event_source {
21+
/// Default event value meaning it is not set.
22+
UNDEFINED = 0,
23+
/// The event is from a receiver chain.
24+
RECEIVE,
25+
/// The event is from a transmit chain.
26+
TRANSMIT,
27+
/// The event cause is not listed from the above chain.
28+
OTHER
29+
};
30+
31+
/// Translate an event_source to a string.
32+
inline const char* to_string(radio_event_source value)
33+
{
34+
switch (value) {
35+
case radio_event_source::UNDEFINED:
36+
return "undefined";
37+
case radio_event_source::RECEIVE:
38+
return "rx";
39+
case radio_event_source::TRANSMIT:
40+
return "tx";
41+
case radio_event_source::OTHER:
42+
return "other";
43+
}
44+
return "";
45+
}
46+
47+
/// Radio event types.
48+
enum class radio_event_type {
49+
/// Default event value meaning it is not set.
50+
UNDEFINED = 0,
51+
/// Indicates an start of a burst.
52+
START_OF_BURST,
53+
/// Indicates the end of a burst.
54+
END_OF_BURST,
55+
/// The transmit data arrives late to the baseband unit.
56+
LATE,
57+
/// The transmit data is not generated fast enough.
58+
UNDERFLOW,
59+
/// The receive buffers are not read fast enough.
60+
OVERFLOW,
61+
/// The event cause is not listed from the above causes.
62+
OTHER
63+
};
64+
65+
/// Translate an event_type to a string.
66+
inline const char* to_string(radio_event_type value)
67+
{
68+
switch (value) {
69+
case radio_event_type::UNDEFINED:
70+
return "undefined";
71+
case radio_event_type::START_OF_BURST:
72+
return "start-of-burst";
73+
case radio_event_type::END_OF_BURST:
74+
return "end-of-burst";
75+
case radio_event_type::LATE:
76+
return "late";
77+
case radio_event_type::UNDERFLOW:
78+
return "underflow";
79+
case radio_event_type::OVERFLOW:
80+
return "overflow";
81+
case radio_event_type::OTHER:
82+
return "other";
83+
}
84+
return "";
85+
}
86+
87+
/// \brief Describes a baseband unit event notifier interface.
88+
///
89+
/// This class describes an interface used by the baseband unit to notify events related with its operation.
90+
class radio_event_notifier : public radio_base
91+
{
92+
public:
93+
/// Describes a radio notification.
94+
struct event_description {
95+
/// Indicates the stream identifier that triggered the event if it is available.
96+
std::optional<unsigned> stream_id;
97+
/// Indicates the channel identifier that triggered the event if it is available.
98+
std::optional<unsigned> channel_id;
99+
/// Indicates the source of the event.
100+
radio_event_source source = radio_event_source::UNDEFINED;
101+
/// Indicates the event type.
102+
radio_event_type type = radio_event_type::UNDEFINED;
103+
/// Indicates the timestamp of this event if it is available.
104+
std::optional<uint64_t> timestamp;
105+
};
106+
107+
/// Notifies a new event that affected the real-time operation of the radio.
108+
virtual void on_radio_rt_event(const event_description& description) = 0;
109+
};
110+
111+
} // namespace srsran

include/srsran/radio/radio_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class radio_factory : public radio_base
3131
/// \return The ownership to a radio session if the session was successfully created.
3232
virtual std::unique_ptr<radio_session> create(const radio_configuration::radio& config,
3333
task_executor& async_task_executor,
34-
radio_notification_handler& notifier) = 0;
34+
radio_event_notifier& notifier) = 0;
3535
};
3636

3737
/// \brief Dynamic library radio factory creation entry point.

include/srsran/radio/radio_notification_handler.h

Lines changed: 0 additions & 146 deletions
This file was deleted.

include/srsran/radio/radio_session.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "srsran/gateways/baseband/baseband_gateway.h"
1414
#include "srsran/gateways/baseband/baseband_gateway_timestamp.h"
1515
#include "srsran/radio/radio_configuration.h"
16+
#include "srsran/radio/radio_event_notifier.h"
1617
#include "srsran/radio/radio_management_plane.h"
17-
#include "srsran/radio/radio_notification_handler.h"
1818

1919
namespace srsran {
2020

lib/radio/plugin_radio_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class radio_factory_dynamic_wrapper : public radio_factory
8787
// See interface for documentation.
8888
std::unique_ptr<radio_session> create(const radio_configuration::radio& config,
8989
task_executor& async_task_executor,
90-
radio_notification_handler& notifier) override
90+
radio_event_notifier& notifier) override
9191
{
9292
// Create base radio using the loaded factory.
9393
std::unique_ptr<radio_session> radio = factory->create(config, async_task_executor, notifier);

lib/radio/uhd/radio_uhd_baseband_gateway.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class radio_uhd_baseband_gateway : public baseband_gateway
2525
public:
2626
radio_uhd_baseband_gateway(radio_uhd_device& device,
2727
task_executor& async_executor,
28-
radio_notification_handler& notifier,
28+
radio_event_notifier& notifier,
2929
const radio_uhd_tx_stream::stream_description& tx_stream_config,
3030
const radio_uhd_rx_stream::stream_description& rx_stream_config) :
3131
tx_stream(device.create_tx_stream(async_executor, notifier, tx_stream_config)),

lib/radio/uhd/radio_uhd_device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class radio_uhd_device : public uhd_exception_handler
338338
}
339339

340340
std::unique_ptr<radio_uhd_tx_stream> create_tx_stream(task_executor& async_executor,
341-
radio_notification_handler& notifier,
341+
radio_event_notifier& notifier,
342342
const radio_uhd_tx_stream::stream_description& description)
343343
{
344344
std::unique_ptr<radio_uhd_tx_stream> stream =
@@ -351,7 +351,7 @@ class radio_uhd_device : public uhd_exception_handler
351351
return nullptr;
352352
}
353353

354-
std::unique_ptr<radio_uhd_rx_stream> create_rx_stream(radio_notification_handler& notifier,
354+
std::unique_ptr<radio_uhd_rx_stream> create_rx_stream(radio_event_notifier& notifier,
355355
const radio_uhd_rx_stream::stream_description& description)
356356
{
357357
std::unique_ptr<radio_uhd_rx_stream> stream = std::make_unique<radio_uhd_rx_stream>(usrp, description, notifier);

0 commit comments

Comments
 (0)