Skip to content

Rename ULL functions callable from LLL context to follow ull_*_lll_* convention#18

Draft
cvinayak with Copilot wants to merge 2 commits into
mainfrom
copilot/refactor-ull-functions-lll-context
Draft

Rename ULL functions callable from LLL context to follow ull_*_lll_* convention#18
cvinayak with Copilot wants to merge 2 commits into
mainfrom
copilot/refactor-ull-functions-lll-context

Conversation

Copilot AI commented Jan 31, 2026

Copy link
Copy Markdown

ULL functions callable from LLL (ISR) context lacked consistent naming to indicate ISR-safety. Renamed 18 functions to include _lll_ infix for immediate identification.

Changes

Function naming pattern:

// Before
void ull_rx_put(memq_link_t *link, void *rx);
struct lll_event *ull_prepare_enqueue(...);
void *ull_event_done(void *param);

// After  
void ull_lll_rx_put(memq_link_t *link, void *rx);
struct lll_event *ull_prepare_lll_enqueue(...);
void *ull_event_lll_done(void *param);

Scope:

  • Prepare/Event (7): ull_prepare_enqueueull_prepare_lll_enqueue, ull_event_doneull_event_lll_done, etc.
  • RX PDU (5): ull_pdu_rx_alloc*ull_pdu_lll_rx_alloc*, ull_iso_pdu_rx_alloc*ull_iso_pdu_lll_rx_alloc*
  • RX Sched (5): ull_rx_putull_lll_rx_put, ull_rx_schedull_lll_rx_sched, ISO variants
  • TX ACK (1): ull_iso_tx_ack_dequeueull_iso_lll_tx_ack_dequeue

Files modified:

  • Declarations: ll_sw/lll.h
  • Definitions: ll_sw/ull.c (13), ll_sw/ull_iso.c (4)
  • Call sites: 15 Nordic LLL files, 4 OpenISA LLL files, 3 other ll_sw files

Stats: 25 files, 255 insertions, 255 deletions (pure rename)

Rationale

The _lll_ infix makes architectural boundaries explicit in function names, reducing risk of calling non-ISR-safe ULL functions from ISR context.

Original prompt

Refactor ULL Functions Called from LLL Context

Background

In the Zephyr Bluetooth Controller implementation, there is a clear separation between:

  • LLL (Lower Link Layer): Runs in interrupt/ISR context
  • ULL (Upper Link Layer): Runs in thread/mayfly context

Some ULL functions are designed to be called from the LLL execution context (ISR). To improve code clarity and maintainability, these functions should follow a naming convention that makes it immediately obvious they are LLL-callable: ull_<module>_lll_<function>.

Problem

Currently, many core ULL functions that are called from LLL context do NOT follow this naming convention. This makes it difficult to identify which ULL functions are safe to call from LLL/ISR context.

Functions to Refactor

The following ULL functions are called from LLL context but lack the _lll_ infix (defined in subsys/bluetooth/controller/ll_sw/lll.h):

Prepare/Event Management:

  • ull_prepare_enqueue()ull_prepare_lll_enqueue()
  • ull_prepare_dequeue_get()ull_prepare_lll_dequeue_get()
  • ull_prepare_dequeue_iter()ull_prepare_lll_dequeue_iter()
  • ull_prepare_dequeue()ull_prepare_lll_dequeue()
  • ull_event_done_extra_get()ull_event_lll_done_extra_get()
  • ull_done_extra_type_set()ull_lll_done_extra_type_set()
  • ull_event_done()ull_event_lll_done()

RX PDU Allocation:

  • ull_pdu_rx_alloc_peek()ull_pdu_lll_rx_alloc_peek()
  • ull_pdu_rx_alloc_peek_iter()ull_pdu_lll_rx_alloc_peek_iter()
  • ull_pdu_rx_alloc()ull_pdu_lll_rx_alloc()
  • ull_iso_pdu_rx_alloc_peek()ull_iso_pdu_lll_rx_alloc_peek()
  • ull_iso_pdu_rx_alloc()ull_iso_pdu_lll_rx_alloc()

RX Scheduling:

  • ull_rx_put()ull_lll_rx_put()
  • ull_rx_sched()ull_lll_rx_sched()
  • ull_rx_put_sched()ull_lll_rx_put_sched()
  • ull_iso_rx_put()ull_iso_lll_rx_put()
  • ull_iso_rx_sched()ull_iso_lll_rx_sched()

TX ACK:

  • ull_iso_tx_ack_dequeue()ull_iso_lll_tx_ack_dequeue()

Requirements

  1. Rename all identified functions to include _lll_ infix in the name
  2. Update all call sites across the codebase (primarily in subsys/bluetooth/controller/ll_sw/)
  3. Update function declarations in header files
  4. Update function definitions in source files
  5. Maintain backward compatibility where necessary (e.g., if functions are part of a stable API)
  6. Update any related documentation or comments

Files to Modify

Primary files include:

  • subsys/bluetooth/controller/ll_sw/lll.h - Function declarations
  • subsys/bluetooth/controller/ll_sw/ull.c - Function definitions
  • subsys/bluetooth/controller/ll_sw/ull_iso.c - ISO-specific functions
  • All LLL implementation files in subsys/bluetooth/controller/ll_sw/nordic/lll/ and subsys/bluetooth/controller/ll_sw/openisa/lll/
  • Any other files that call these functions

Success Criteria

  1. All ULL functions called from LLL context follow the ull_*_lll_* naming convention
  2. Code compiles without errors or warnings
  3. No functional changes - this is a pure refactoring
  4. All existing tests pass

Notes

  • This is part of a larger code quality improvement effort to make the codebase more maintainable
  • The refactoring should preserve all existing functionality
  • Focus on clarity and consistency in naming

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Renamed function declarations in lll.h (18 functions)
- Renamed function definitions in ull.c (13 functions)
- Renamed function definitions in ull_iso.c (4 functions)
- Updated all call sites across nordic/lll and openisa/lll directories
- Updated macro definitions for iso_rx_put and iso_rx_sched

All functions now follow the ull_*_lll_* naming convention.

Co-authored-by: cvinayak <6350656+cvinayak@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor ULL functions for LLL context clarity Rename ULL functions callable from LLL context to follow ull_*_lll_* convention Jan 31, 2026
Copilot AI requested a review from cvinayak January 31, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants