Skip to content

Commit ccd9023

Browse files
xavierarteagacodebot
authored andcommitted
phy: use variant in upper PHY for PUSCH and PUCCH PDUs
1 parent 9e32d74 commit ccd9023

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

include/srsran/phy/upper/uplink_slot_pdu_repository.h

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,15 @@
1010

1111
#pragma once
1212

13+
#include "srsran/adt/variant.h"
1314
#include "srsran/phy/upper/uplink_processor.h"
1415
#include "srsran/ran/slot_pdu_capacity_constants.h"
1516
#include <vector>
1617

1718
namespace srsran {
1819

1920
/// Defines an entry of the uplink slot PDU repository.
20-
struct uplink_slot_pdu_entry {
21-
/// Labels for the supported PDU types.
22-
enum class pdu_type { PUSCH, PUCCH };
23-
24-
/// PDU type.
25-
pdu_type type;
26-
// :TODO: convert this to variant.
27-
/// PUSCH PDU.
28-
uplink_processor::pusch_pdu pusch;
29-
/// PUCCH PDU.
30-
uplink_processor::pucch_pdu pucch;
31-
};
21+
using uplink_slot_pdu_entry = variant<uplink_processor::pusch_pdu, uplink_processor::pucch_pdu>;
3222

3323
/// \brief Uplink slot PDU repository.
3424
///
@@ -47,23 +37,13 @@ class uplink_slot_pdu_repository
4737
/// Adds the given PUSCH PDU to the repository at the given slot.
4838
void add_pusch_pdu(slot_point slot, const uplink_processor::pusch_pdu& pdu)
4939
{
50-
uplink_slot_pdu_entry entry;
51-
entry.type = uplink_slot_pdu_entry::pdu_type::PUSCH;
52-
entry.pusch = pdu;
53-
entry.pucch = {};
54-
55-
repository[slot.to_uint() % nof_slots].push_back(entry);
40+
repository[slot.to_uint() % nof_slots].push_back(pdu);
5641
}
5742

5843
/// Adds the given PUCCH PDU to the repository at the given slot.
5944
void add_pucch_pdu(slot_point slot, const uplink_processor::pucch_pdu& pdu)
6045
{
61-
uplink_slot_pdu_entry entry;
62-
entry.type = uplink_slot_pdu_entry::pdu_type::PUCCH;
63-
entry.pucch = pdu;
64-
entry.pusch = {};
65-
66-
repository[slot.to_uint() % nof_slots].push_back(entry);
46+
repository[slot.to_uint() % nof_slots].push_back(pdu);
6747
}
6848

6949
/// Clears the given slot of the registry.

lib/phy/upper/upper_phy_rx_symbol_handler_impl.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ void upper_phy_rx_symbol_handler_impl::handle_rx_symbol(const upper_phy_rx_symbo
6666
}
6767

6868
const uplink_slot_pdu_entry& first_entry = pdus.front();
69-
unsigned nof_symbols =
70-
get_nsymb_per_slot((first_entry.type == uplink_slot_pdu_entry::pdu_type::PUSCH) ? first_entry.pusch.pdu.cp
71-
: get_cp(first_entry.pucch));
69+
unsigned nof_symbols = 0;
70+
if (variant_holds_alternative<uplink_processor::pusch_pdu>(first_entry)) {
71+
const uplink_processor::pusch_pdu& pdu = variant_get<uplink_processor::pusch_pdu>(first_entry);
72+
nof_symbols = get_nsymb_per_slot(pdu.pdu.cp);
73+
} else {
74+
const uplink_processor::pucch_pdu& pdu = variant_get<uplink_processor::pucch_pdu>(first_entry);
75+
nof_symbols = get_nsymb_per_slot(get_cp(pdu));
76+
}
7277
unsigned last_symbol_id = nof_symbols - 1U;
7378

7479
// Process the PDUs when all symbols of the slot have been received.
@@ -81,13 +86,12 @@ void upper_phy_rx_symbol_handler_impl::handle_rx_symbol(const upper_phy_rx_symbo
8186

8287
// Process all the PDUs from the pool.
8388
for (const auto& pdu : pdus) {
84-
switch (pdu.type) {
85-
case uplink_slot_pdu_entry::pdu_type::PUSCH:
86-
process_pusch(pdu.pusch, ul_processor, grid, context.slot);
87-
break;
88-
case uplink_slot_pdu_entry::pdu_type::PUCCH:
89-
ul_processor.process_pucch(rx_results_notifier, grid, pdu.pucch);
90-
break;
89+
if (variant_holds_alternative<uplink_processor::pusch_pdu>(pdu)) {
90+
const uplink_processor::pusch_pdu& pusch_pdu = variant_get<uplink_processor::pusch_pdu>(pdu);
91+
process_pusch(pusch_pdu, ul_processor, grid, context.slot);
92+
} else if (variant_holds_alternative<uplink_processor::pucch_pdu>(pdu)) {
93+
const uplink_processor::pucch_pdu& pucch_pdu = variant_get<uplink_processor::pucch_pdu>(pdu);
94+
ul_processor.process_pucch(rx_results_notifier, grid, pucch_pdu);
9195
}
9296
}
9397
}

0 commit comments

Comments
 (0)