1. 27 Jan, 2025 40 commits
    • Robert Schmidt's avatar
      Handle tx_data.request efficiently · 10beee4f
      Robert Schmidt authored
      Avoid delays in tx_data.request handling by avoiding big malloc()s and
      copy operations. Reimplement function to (1) peek the frame/slot
      numbers, (2) decide on buffer, and (3) unpack directly into
      pre-allocated memory.
      Co-authored-by: default avatarhsum <ming-hong.hsu@eurecom.fr>
      Co-authored-by: default avatarchenyi <Yi-Quan.Chen@eurecom.fr>
      Co-authored-by: default avatarRúben Soares Silva <rsilva@allbesmart.pt>
      10beee4f
    • Rúben Soares Silva's avatar
      Provide check_nr_nfapi_p7_slot_type() · 8da4e921
      Rúben Soares Silva authored
      Some messages might arrive for the wrong slot; in those cases, the
      message has to be dropped. The next commits will make use of this
      functionality.
      8da4e921
    • Rúben Soares Silva's avatar
      Provide peek_nr_nfapi_p7_sfn_slot() for fast msg dec · d6b8fe93
      Rúben Soares Silva authored
      The next commits refactor the rx handling of messages in the PNF. To
      efficiently handle them, provide a "peek()" function that gives us the
      frame/slot for which a message is destined. This allows to decide if a
      message is on time and select a destination buffer, before unpacking it
      completely, avoiding copies.
      d6b8fe93
    • chenyi's avatar
      Fix PMI condition: avoid division by zero · 17e36029
      chenyi authored
      17e36029
    • Robert Schmidt's avatar
      nFAPI: give more time for messages to arrive, make it work · a1190f9f
      Robert Schmidt authored
      The time that a message between PNF/VNF to arrive depends mostly on the
      transport. To allow for some delays, there is a slot_ahead time, during
      which the VNF is allowed to schedule and send instructions to the PNF.
      
      This can be multiple slots; the 1ms hitherto given might typically too
      short. Increase to 10ms, to encompass a wider range of slot_ahead times.
      
      Make the corresponding log message of when old (stale) message are
      removed a bit clearer with respect to times.
      
      This is the first commit in which nFAPI works. Follow-up commits improve
      performance.
      a1190f9f
    • Robert Schmidt's avatar
      Remove usage of emulate_l1 flag at gNB · 32363cca
      Robert Schmidt authored
      The usage of this flag in the L1 is simply wrong: either, the NFAPI mode
      runs L1, or not. Correspondingly, add an assert to check this invariant.
      
      In the NR_IF_module, the correct check to do is for VNF (implying no L1,
      or "emulation of L1" [which is not true]), in which case we use
      queues.
      32363cca
    • Robert Schmidt's avatar
      L1 DLSCH: don't preallocate memory, improve log · 3fcfef90
      Robert Schmidt authored
      The L1 receives a pointer to the L1 payload to use for PDSCH generation.
      This would overwrite an existing pre-allocated pointer. Remove this
      preallocation. Instead, allocate it in the simulator (the only place
      that actively uses this buffer allocation; in nr-softmodem, it's lost by
      assigning a pointer). Allocate with an extra byte, because the payload
      (in bits) might not be a multiple of 8 bits/1 byte, so the CRC is in the
      last 3 bytes.
      
      Also, improve the log with frame/slot information if the PDSCH payload
      pointer is NULL.
      3fcfef90
    • hsum's avatar
      Refactor is_nr_p7_request_in_window function for clarity and efficiency · 195b23bd
      hsum authored
      The function now utilizes simpler variable names and logic to determine
      if a given NR P7 request falls within the timing window.
      
      The logic for determining if a request is within the timing window is as follows:
      - The function calculates the absolute difference between the current
        and received SFN slots, taking into account the possibility of
        wraparound.
      - If the absolute difference is greater than half of the maximum SFN
        slot value, it subtracts this difference from the maximum SFN slot
        value to get the actual difference.
      - The function then checks if this difference is less than or equal to
        the specified timing window. If it is, the request is considered to be
        within the window.
      
      Additionally, the commit updates the function signature to return a
      boolean value for better readability and consistency.
      
      Changes made:
      - Simplified variable names for readability
      - Improved logic for handling wraparound scenarios
      - Updated function signature to return a boolean value
      Co-authored-by: default avatarRúben Soares Silva <rsilva@allbesmart.pt>
      195b23bd
    • Robert Schmidt's avatar
      Remove huge memset that is pointless · 267be0af
      Robert Schmidt authored
      267be0af
    • Robert Schmidt's avatar
      RACH.indication: don't check time window · 7949b622
      Robert Schmidt authored
      Since commit defc97ec ("Msg2 and Msg3 at gNB: check allocation before
      committing to Msg2"), the scheduler calculate Msg2/Msg3 frame/slot
      before allocation of Msg2, and not when receiving Msg1. It also respects
      the RA response window correctly.
      
      Correspondingly, we don't need to calculate here if the RACH.indication
      is within the time window. The scheduler will do this.
      7949b622
    • Robert Schmidt's avatar
      Reduce PNF nFAPI logs · 6cdea81e
      Robert Schmidt authored
      6cdea81e
    • hsum's avatar
      Ensure equal PNF timing pace · 65bc677f
      hsum authored
      If VNF and PNF are deployed through different processes, it's crucial to
      maintain synchronization and ensure smooth operation. This commit
      addresses the need to keep the VNF slot ahead of 2 (as required for
      network deployment), while ensuring that PNFs wait appropriately to
      avoid overtaking the slot. Specifically, this involves measuring slot
      duration and implementing a wait mechanism to ensure that PNFs do not
      exceed a slot duration of 300 microseconds. This ensures proper smooth
      operation, especially in the case of RFsim.
      65bc677f
    • Robert Schmidt's avatar
      reset nFAPI message count in PNF · 10afbef4
      Robert Schmidt authored
      Reset the counters. In monolithic, this happens in the scheduler; in the
      PNF, without this change, it would trigger PDCCH again.
      Co-authored-by: default avatarhsum <ming-hong.hsu@eurecom.fr>
      10afbef4
    • Robert Schmidt's avatar
      pnf_p7_slot_ind(): don't trigger UL_tti_req twice · 50aec62b
      Robert Schmidt authored
      This is already triggered in the same function.
      50aec62b
    • Robert Schmidt's avatar
      pnf_p7_slot_ind(): avoid memleak · 63c1b3df
      Robert Schmidt authored
      63c1b3df
    • Robert Schmidt's avatar
      Refactor pnf_phy_ul_dci_req() et al. to use common code · 15b08a36
      Robert Schmidt authored
      Refactor pnf_phy_ul_dci_req(), pnf_phy_dl_tti_req(),
      pnf_phy_tx_data_req(), pnf_phy_ul_tti_req(), to use L1 functions to
      "load" L1 jobs to be executed, via L1 functions.
      15b08a36
    • Robert Schmidt's avatar
      Workaround for sched_response in PNF · a32ada76
      Robert Schmidt authored
      In monolithic, the sched_response mechanism ensures that FAPI messages
      for one slot are not overwritten by scheduler instructions for the
      following slots (i.e., it is like a memory allocation pool).
      
      The allocation happens in nr_schedule_response(), not used by the PNF.
      Hence, only deallocate when in monolithic.
      
      The PNF uses a big ring buffer over all slots in a frame to ensure the
      same.
      a32ada76
    • Robert Schmidt's avatar
    • Robert Schmidt's avatar
    • Robert Schmidt's avatar
    • Robert Schmidt's avatar
    • Robert Schmidt's avatar
      nr_schedule_response(): Separate dlsch_fill into DL_tti_req and TX_req part · 6a630f46
      Robert Schmidt authored
      FAPI sends those independently, so we cannot treat both on the arrival
      of the first one.
      6a630f46
    • Robert Schmidt's avatar
    • Robert Schmidt's avatar
    • Robert Schmidt's avatar
      PNF: don't send dummy data · 70474ad1
      Robert Schmidt authored
      If nothing is to be sent, nothing is to be done.
      70474ad1
    • Robert Schmidt's avatar
      pnf_p7_slot_ind(): needs to use TX thread time · c7e145a4
      Robert Schmidt authored
      This function applied an sf_ahead, bigger than the actual slot
      indication message sending (so a message could NEVER arrive on time!).
      Reduce to zero, because this is when it should arrive for us.
      c7e145a4
    • Robert Schmidt's avatar
      nr_slot_select() and set_tdd_config_nr(): remove useless second frame · 16ead1d0
      Robert Schmidt authored
      FAPI says these lists should be for MAX_TDD_PERIODICITY (which is maybe
      a frame, or a TDD period? but likely not two frames). Reduce to one
      frame.
      
      Also, the nFAPI code assumes one entire frame, so use that (this commit
      necessary to actually make the PNF work, otherwise, the
      packing/unpacking of the FAPI message would need to do 2 frames).
      
      Closes: #876
      16ead1d0
    • Robert Schmidt's avatar
      Use posix_memalign() for pnf_p7_t creation · 28b60eda
      Robert Schmidt authored
      Some L1 functions might get a pointer to P7 structures, and use SIMD in
      which case the memory access needs to be aligned.
      28b60eda
    • Rúben Soares Silva's avatar
    • Robert Schmidt's avatar
      Call indication regularly · e3bad16a
      Robert Schmidt authored
      Upon reception of FAPI UL messages (e.g., RACH.indication), those
      messages are put into queues, to be delivered in a single call,
      NR_UL_indication(). Call the scheduler to trigger processing in UL.
      
      Note that ideally, these queues should not exist at all, and messages
      should just be delivered asynchronously, as this would lead to less
      copying of messages. Currently, we fulfill the scheduler interface
      instead.
      
      Important! Trigger UL after having run DL scheduler and sent the
      messages, to ensure short delay between Slot.indication, and the
      response to those messages.
      e3bad16a
    • Robert Schmidt's avatar
      Call directly into scheduler from VNF, start immediately · 53172663
      Robert Schmidt authored
      The previous designs seems to do:
      
          loop {
            poll_ind_queue()
            if (msg)
              scheduler;
      
            pselect() on messages;
            handle_message {
              if slot_ind
                put_ind_queue()
            }
          }
      
      So basically, we artificially put a queue for slot indications in the
      middle, but still handle it in the same thread(!). This for some reason
      results in a big slow down if the PNF runs faster.
      
      Now, we just do pselect(), waiting for messages. We handle the slot
      indication immediately (the schedule should take some microseconds),
      then return to pselect().
      53172663
    • Robert Schmidt's avatar
      IF module slot_indication: send message in PNF · 41244607
      Robert Schmidt authored
      Use this function to implement distinct behavior for monolithic or PNF:
      
      - monolithic: run the scheduler, as normal
      - PNF: send a slot indication; the VNF will send an answer which the PNF
        will handle elsewhere.
      
      Add function declarations to make nr_ulsim compile, as NR_IF_Module.c is
      part of the MAC sources. As of now, this is necessary; I think the right
      way would be to take NR_IF_Module.c out of the MAC, and make this a
      "glue" library that sticks L1 and L2 together, in monolithic (in VNF, in
      that case, we should not link in L1, and for the PNF not the L2,
      creating separate executables... Rome was not built in one day).
      41244607
    • Robert Schmidt's avatar
      Remove unnecessary handle_nr_slot_ind() · c5a76d66
      Robert Schmidt authored
      the slot indication is sent from the tx_thread (tx_func()). Thus, we
      don't need to send it a second time.
      c5a76d66
    • Robert Schmidt's avatar
      84d92ac8
    • Robert Schmidt's avatar
      Only use refcount if monolithic · 9f80c82f
      Robert Schmidt authored
      There is a reference counting mechanism used in monolithic. It does not
      apply for the PNF.
      9f80c82f
    • Robert Schmidt's avatar
      Don't call L1 code in VNF · 9634593d
      Robert Schmidt authored
      The VNF should never call into the L1, it's L2/L3, by definition. Also,
      it's not necessary.
      9634593d
    • Robert Schmidt's avatar
      Allow to use multiple PUCCH at once · 1b44f644
      Robert Schmidt authored
      We are required to store multiple PUCCH (e.g., for multiple UEs).
      However, nr_fill_pucch() automatically freed the previously active PUCCH
      structure. Of course(!) this does not make sense.
      
      However, the problem is that init_nr_transport() allocated only one
      PUCCH structure. Also this does not make sense to me. The problem was
      that slot_ahead was 0, which logically cannot happen in this function
      (because slot_ahead is illogical, we must give the radio some time). The
      reason is that it uses if_inst->sl_ahead, which, prior to this commit,
      was not set.
      
      The init_nr_transport() function is called normally from main() through
      init_eNB_afterRU(). In this case, we initialize if_inst->sl_ahead to
      what is set in main(). In the PNF case, however, we call
      init_nr_transport() from the PNF thread, when receiving the start
      request. In the main(), we wait for this to happen, before setting
      if_inst->sl_ahead. Hence, initializing this variable (which we should
      safely be able to do) before solves the problem.
      1b44f644
    • Robert Schmidt's avatar
      No special handling for PNF for RX procedures · 84d9df50
      Robert Schmidt authored
      See also a later commit "Allow to use multiple PUCCH at once", in which
      PUCCH handling in the case of PNF is reworked.
      
      We might squash both commits.
      84d9df50
    • Rúben Soares da Silva's avatar
      Assign NFAPI_NR_CONFIG_SLOT_CONFIG_TAG tag in TLVs used for transmitting the... · a6b40ace
      Rúben Soares da Silva authored
      Assign NFAPI_NR_CONFIG_SLOT_CONFIG_TAG tag in TLVs used for transmitting the TDD Slot configuration through CONFIG.request.
      a6b40ace
    • Robert Schmidt's avatar
      Shorten the sleep · 4ceac17c
      Robert Schmidt authored
      sync_var is set in main() (which likely is wrong in that the L1 code
      sync itself, and not require the help of main()).
      4ceac17c