diff --git a/.github/workflows/manifest-PR.yml b/.github/workflows/manifest-PR.yml index a871aa381de..8f834b99f72 100644 --- a/.github/workflows/manifest-PR.yml +++ b/.github/workflows/manifest-PR.yml @@ -3,7 +3,7 @@ on: pull_request_target: types: [opened, synchronize, closed] branches: - - main + - ncs-v3.1-branch jobs: @@ -15,3 +15,4 @@ jobs: with: token: ${{ secrets.NCS_GITHUB_TOKEN }} manifest-pr-title-details: ${{ github.event.pull_request.title }} + base-branch: v3.1-branch diff --git a/cmake/mcuboot.cmake b/cmake/mcuboot.cmake index d2fcf68e889..ac37b175a31 100644 --- a/cmake/mcuboot.cmake +++ b/cmake/mcuboot.cmake @@ -152,6 +152,13 @@ function(zephyr_mcuboot_tasks) set(imgtool_args --align ${write_block_size} ${imgtool_args}) endif() + # Set proper hash calculation algorithm for signing + if(CONFIG_MCUBOOT_BOOTLOADER_SIGNATURE_TYPE_PURE) + set(imgtool_args --pure ${imgtool_args}) + elseif(CONFIG_MCUBOOT_BOOTLOADER_USES_SHA512) + set(imgtool_args --sha 512 ${imgtool_args}) + endif() + # Extensionless prefix of any output file. set(output ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}) diff --git a/doc/_extensions/zephyr/kconfig/__init__.py b/doc/_extensions/zephyr/kconfig/__init__.py index 6bf828a9088..eb1903b1898 100644 --- a/doc/_extensions/zephyr/kconfig/__init__.py +++ b/doc/_extensions/zephyr/kconfig/__init__.py @@ -70,19 +70,24 @@ ZEPHYR_BASE = Path(__file__).parents[4] -def kconfig_load(app: Sphinx) -> tuple[kconfiglib.Kconfig, dict[str, str]]: +def kconfig_load(app: Sphinx) -> tuple[kconfiglib.Kconfig, kconfiglib.Kconfig, dict[str, str]]: """Load Kconfig""" with TemporaryDirectory() as td: modules = zephyr_module.parse_modules(ZEPHYR_BASE) # generate Kconfig.modules file kconfig = "" + sysbuild_kconfig = "" for module in modules: kconfig += zephyr_module.process_kconfig(module.project, module.meta) + sysbuild_kconfig += zephyr_module.process_sysbuildkconfig(module.project, module.meta) with open(Path(td) / "Kconfig.modules", "w") as f: f.write(kconfig) + with open(Path(td) / "Kconfig.sysbuild.modules", "w") as f: + f.write(sysbuild_kconfig) + # generate dummy Kconfig.dts file kconfig = "" @@ -145,6 +150,13 @@ def kconfig_load(app: Sphinx) -> tuple[kconfiglib.Kconfig, dict[str, str]]: os.environ["BOARD"] = "boards" os.environ["KCONFIG_BOARD_DIR"] = str(Path(td) / "boards") + # Sysbuild runs first + os.environ["CONFIG_"] = "SB_CONFIG_" + sysbuild_output = kconfiglib.Kconfig(ZEPHYR_BASE / "share" / "sysbuild" / "Kconfig") + + # Normal Kconfig runs second + os.environ["CONFIG_"] = "CONFIG_" + # insert external Kconfigs to the environment module_paths = dict() for module in modules: @@ -172,7 +184,7 @@ def kconfig_load(app: Sphinx) -> tuple[kconfiglib.Kconfig, dict[str, str]]: if kconfig.exists(): os.environ[f"ZEPHYR_{name_var}_KCONFIG"] = str(kconfig) - return kconfiglib.Kconfig(ZEPHYR_BASE / "Kconfig"), module_paths + return kconfiglib.Kconfig(ZEPHYR_BASE / "Kconfig"), sysbuild_output, module_paths class KconfigSearchNode(nodes.Element): @@ -332,13 +344,15 @@ def add_option(self, option): def sc_fmt(sc): + prefix = os.environ["CONFIG_"] + if isinstance(sc, kconfiglib.Symbol): if sc.nodes: - return f'CONFIG_{sc.name}' + return f'{prefix}{sc.name}' elif isinstance(sc, kconfiglib.Choice): if not sc.name: return "<choice>" - return f'<choice CONFIG_{sc.name}>' + return f'<choice {prefix}{sc.name}>' return kconfiglib.standard_sc_expr_str(sc) @@ -350,137 +364,139 @@ def kconfig_build_resources(app: Sphinx) -> None: return with progress_message("Building Kconfig database..."): - kconfig, module_paths = kconfig_load(app) + kconfig, sysbuild_kconfig, module_paths = kconfig_load(app) db = list() - for sc in sorted( - chain(kconfig.unique_defined_syms, kconfig.unique_choices), - key=lambda sc: sc.name if sc.name else "", - ): - # skip nameless symbols - if not sc.name: - continue - - # store alternative defaults (from defconfig files) - alt_defaults = list() - for node in sc.nodes: - if "defconfig" not in node.filename: + for kconfig_obj in [kconfig, sysbuild_kconfig]: + os.environ["CONFIG_"] = kconfig_obj.config_prefix + for sc in sorted( + chain(kconfig_obj.unique_defined_syms, kconfig_obj.unique_choices), + key=lambda sc: sc.name if sc.name else "", + ): + # skip nameless symbols + if not sc.name: continue - for value, cond in node.orig_defaults: - fmt = kconfiglib.expr_str(value, sc_fmt) - if cond is not sc.kconfig.y: - fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" - alt_defaults.append([fmt, node.filename]) - - # build list of symbols that select/imply the current one - # note: all reverse dependencies are ORed together, and conditionals - # (e.g. select/imply A if B) turns into A && B. So we first split - # by OR to include all entries, and we split each one by AND to just - # take the first entry. - selected_by = list() - if isinstance(sc, kconfiglib.Symbol) and sc.rev_dep != sc.kconfig.n: - for select in kconfiglib.split_expr(sc.rev_dep, kconfiglib.OR): - sym = kconfiglib.split_expr(select, kconfiglib.AND)[0] - selected_by.append(f"CONFIG_{sym.name}") - - implied_by = list() - if isinstance(sc, kconfiglib.Symbol) and sc.weak_rev_dep != sc.kconfig.n: - for select in kconfiglib.split_expr(sc.weak_rev_dep, kconfiglib.OR): - sym = kconfiglib.split_expr(select, kconfiglib.AND)[0] - implied_by.append(f"CONFIG_{sym.name}") - - # only process nodes with prompt or help - nodes = [node for node in sc.nodes if node.prompt or node.help] - - inserted_paths = list() - for node in nodes: - # avoid duplicate symbols by forcing unique paths. this can - # happen due to dependencies on 0, a trick used by some modules - path = f"{node.filename}:{node.linenr}" - if path in inserted_paths: - continue - inserted_paths.append(path) - - dependencies = None - if node.dep is not sc.kconfig.y: - dependencies = kconfiglib.expr_str(node.dep, sc_fmt) - - defaults = list() - for value, cond in node.orig_defaults: - fmt = kconfiglib.expr_str(value, sc_fmt) - if cond is not sc.kconfig.y: - fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" - defaults.append(fmt) - - selects = list() - for value, cond in node.orig_selects: - fmt = kconfiglib.expr_str(value, sc_fmt) - if cond is not sc.kconfig.y: - fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" - selects.append(fmt) - - implies = list() - for value, cond in node.orig_implies: - fmt = kconfiglib.expr_str(value, sc_fmt) - if cond is not sc.kconfig.y: - fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" - implies.append(fmt) - - ranges = list() - for min, max, cond in node.orig_ranges: - fmt = ( - f"[{kconfiglib.expr_str(min, sc_fmt)}, " - f"{kconfiglib.expr_str(max, sc_fmt)}]" + # store alternative defaults (from defconfig files) + alt_defaults = list() + for node in sc.nodes: + if "defconfig" not in str(node.filename): + continue + + for value, cond in node.orig_defaults: + fmt = kconfiglib.expr_str(value, sc_fmt) + if cond is not sc.kconfig.y: + fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" + alt_defaults.append([fmt, node.filename]) + + # build list of symbols that select/imply the current one + # note: all reverse dependencies are ORed together, and conditionals + # (e.g. select/imply A if B) turns into A && B. So we first split + # by OR to include all entries, and we split each one by AND to just + # take the first entry. + selected_by = list() + if isinstance(sc, kconfiglib.Symbol) and sc.rev_dep != sc.kconfig.n: + for select in kconfiglib.split_expr(sc.rev_dep, kconfiglib.OR): + sym = kconfiglib.split_expr(select, kconfiglib.AND)[0] + selected_by.append(f"{kconfig_obj.config_prefix}{sym.name}") + + implied_by = list() + if isinstance(sc, kconfiglib.Symbol) and sc.weak_rev_dep != sc.kconfig.n: + for select in kconfiglib.split_expr(sc.weak_rev_dep, kconfiglib.OR): + sym = kconfiglib.split_expr(select, kconfiglib.AND)[0] + implied_by.append(f"{kconfig_obj.config_prefix}{sym.name}") + + # only process nodes with prompt or help + nodes = [node for node in sc.nodes if node.prompt or node.help] + + inserted_paths = list() + for node in nodes: + # avoid duplicate symbols by forcing unique paths. this can + # happen due to dependencies on 0, a trick used by some modules + path = f"{node.filename}:{node.linenr}" + if path in inserted_paths: + continue + inserted_paths.append(path) + + dependencies = None + if node.dep is not sc.kconfig.y: + dependencies = kconfiglib.expr_str(node.dep, sc_fmt) + + defaults = list() + for value, cond in node.orig_defaults: + fmt = kconfiglib.expr_str(value, sc_fmt) + if cond is not sc.kconfig.y: + fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" + defaults.append(fmt) + + selects = list() + for value, cond in node.orig_selects: + fmt = kconfiglib.expr_str(value, sc_fmt) + if cond is not sc.kconfig.y: + fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" + selects.append(fmt) + + implies = list() + for value, cond in node.orig_implies: + fmt = kconfiglib.expr_str(value, sc_fmt) + if cond is not sc.kconfig.y: + fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" + implies.append(fmt) + + ranges = list() + for min, max, cond in node.orig_ranges: + fmt = ( + f"[{kconfiglib.expr_str(min, sc_fmt)}, " + f"{kconfiglib.expr_str(max, sc_fmt)}]" + ) + if cond is not sc.kconfig.y: + fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" + ranges.append(fmt) + + choices = list() + if isinstance(sc, kconfiglib.Choice): + for sym in sc.syms: + choices.append(kconfiglib.expr_str(sym, sc_fmt)) + + menupath = "" + iternode = node + while iternode.parent is not iternode.kconfig.top_node: + iternode = iternode.parent + if iternode.prompt: + title = iternode.prompt[0] + else: + title = kconfiglib.standard_sc_expr_str(iternode.item) + menupath = f" > {title}" + menupath + + menupath = "(Top)" + menupath + + filename = str(node.filename) + for name, path in module_paths.items(): + path += "/" + if str(node.filename).startswith(path): + filename = str(node.filename).replace(path, f"/") + break + + db.append( + { + "name": f"{kconfig_obj.config_prefix}{sc.name}", + "prompt": node.prompt[0] if node.prompt else None, + "type": kconfiglib.TYPE_TO_STR[sc.type], + "help": node.help, + "dependencies": dependencies, + "defaults": defaults, + "alt_defaults": alt_defaults, + "selects": selects, + "selected_by": selected_by, + "implies": implies, + "implied_by": implied_by, + "ranges": ranges, + "choices": choices, + "filename": filename, + "linenr": node.linenr, + "menupath": menupath, + } ) - if cond is not sc.kconfig.y: - fmt += f" if {kconfiglib.expr_str(cond, sc_fmt)}" - ranges.append(fmt) - - choices = list() - if isinstance(sc, kconfiglib.Choice): - for sym in sc.syms: - choices.append(kconfiglib.expr_str(sym, sc_fmt)) - - menupath = "" - iternode = node - while iternode.parent is not iternode.kconfig.top_node: - iternode = iternode.parent - if iternode.prompt: - title = iternode.prompt[0] - else: - title = kconfiglib.standard_sc_expr_str(iternode.item) - menupath = f" > {title}" + menupath - - menupath = "(Top)" + menupath - - filename = node.filename - for name, path in module_paths.items(): - path += "/" - if node.filename.startswith(path): - filename = node.filename.replace(path, f"/") - break - - db.append( - { - "name": f"CONFIG_{sc.name}", - "prompt": node.prompt[0] if node.prompt else None, - "type": kconfiglib.TYPE_TO_STR[sc.type], - "help": node.help, - "dependencies": dependencies, - "defaults": defaults, - "alt_defaults": alt_defaults, - "selects": selects, - "selected_by": selected_by, - "implies": implies, - "implied_by": implied_by, - "ranges": ranges, - "choices": choices, - "filename": filename, - "linenr": node.linenr, - "menupath": menupath, - } - ) app.env.kconfig_db = db # type: ignore diff --git a/doc/connectivity/networking/api/coap_server.rst b/doc/connectivity/networking/api/coap_server.rst index a2d0d1b77c1..91ae5ecde47 100644 --- a/doc/connectivity/networking/api/coap_server.rst +++ b/doc/connectivity/networking/api/coap_server.rst @@ -243,7 +243,7 @@ following example simply prints when an event occurs. #define COAP_EVENTS_SET (NET_EVENT_COAP_OBSERVER_ADDED | NET_EVENT_COAP_OBSERVER_REMOVED | \ NET_EVENT_COAP_SERVICE_STARTED | NET_EVENT_COAP_SERVICE_STOPPED) - void coap_event_handler(uint32_t mgmt_event, struct net_if *iface, + void coap_event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { switch (mgmt_event) { diff --git a/doc/connectivity/networking/api/net_mgmt.rst b/doc/connectivity/networking/api/net_mgmt.rst index 2973ee82b04..7c47a63eee2 100644 --- a/doc/connectivity/networking/api/net_mgmt.rst +++ b/doc/connectivity/networking/api/net_mgmt.rst @@ -97,7 +97,7 @@ An example follows. struct net_mgmt_event_callback ipv4_callback; void callback_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IF_xxx) { @@ -139,7 +139,7 @@ Or similarly using :c:macro:`NET_MGMT_REGISTER_EVENT_HANDLER`. #define EVENT_IFACE_SET (NET_EVENT_IF_xxx | NET_EVENT_IF_yyy) #define EVENT_IPV4_SET (NET_EVENT_IPV4_xxx | NET_EVENT_IPV4_yyy) - static void event_handler(uint32_t mgmt_event, struct net_if *iface, + static void event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { @@ -183,7 +183,7 @@ You define your handler modeled with this signature: .. code-block:: c - static int your_handler(uint32_t mgmt_event, struct net_if *iface, + static int your_handler(uint64_t mgmt_event, struct net_if *iface, void *data, size_t len); and then register it with an associated mgmt_request code: diff --git a/doc/releases/migration-guide-4.2.rst b/doc/releases/migration-guide-4.2.rst index 08a2a3d0e33..9b31f4a1634 100644 --- a/doc/releases/migration-guide-4.2.rst +++ b/doc/releases/migration-guide-4.2.rst @@ -509,6 +509,21 @@ Networking need to update their response callback implementations. To retain current behavior, simply return 0 from the callback. +* The API signature of ``net_mgmt`` event handler :c:type:`net_mgmt_event_handler_t` and + request handler :c:type:`net_mgmt_request_handler_t` has changed. The management event + type is changed from ``uint32_t`` to ``uint64_t``. The change allows event number values + to be bit masks instead of enum values. The layer code still stays as a enum value. + The :c:macro:`NET_MGMT_LAYER_CODE` and :c:macro:`NET_MGMT_GET_COMMAND` can be used to get + the layer code and management event command from the actual event value in the request or + event handlers if needed. + +* The socket options for ``net_mgmt`` type sockets cannot directly be network management + event types as those are now ``uint64_t`` and the socket option expects a normal 32 bit + integer value. Because of this, a new ``SO_NET_MGMT_ETHERNET_SET_QAV_PARAM`` + and ``SO_NET_MGMT_ETHERNET_GET_QAV_PARAM`` socket options are created that will replace + the previously used ``NET_REQUEST_ETHERNET_GET_QAV_PARAM`` and + ``NET_REQUEST_ETHERNET_GET_QAV_PARAM`` options. + OpenThread ========== diff --git a/doc/releases/release-notes-4.2.rst b/doc/releases/release-notes-4.2.rst index 00c65556880..80e0f5868de 100644 --- a/doc/releases/release-notes-4.2.rst +++ b/doc/releases/release-notes-4.2.rst @@ -111,6 +111,13 @@ Deprecated APIs and options was deprecated since Zephyr 4.0, and users were advised to migrate to alternative crypto backends. +Stable API changes in this release +================================== + +* The API signature of ``net_mgmt`` event handler :c:type:`net_mgmt_event_handler_t` + and request handler :c:type:`net_mgmt_request_handler_t` has changed. The event value + type is changed from ``uint32_t`` to ``uint64_t``. + New APIs and options ==================== diff --git a/drivers/adc/adc_nrfx_saadc.c b/drivers/adc/adc_nrfx_saadc.c index 2ba7b6efd00..7d442b482e6 100644 --- a/drivers/adc/adc_nrfx_saadc.c +++ b/drivers/adc/adc_nrfx_saadc.c @@ -13,6 +13,7 @@ #include #include #include +#include LOG_MODULE_REGISTER(adc_nrfx_saadc, CONFIG_ADC_LOG_LEVEL); @@ -97,34 +98,19 @@ BUILD_ASSERT((NRF_SAADC_AIN0 == NRF_SAADC_INPUT_AIN0) && "Definitions from nrf-adc.h do not match those from nrf_saadc.h"); #endif -#if defined(CONFIG_NRF_PLATFORM_HALTIUM) -#include -/* Haltium devices always use bounce buffers in RAM */ -static uint16_t adc_samples_buffer[SAADC_CH_NUM] DMM_MEMORY_SECTION(DT_NODELABEL(adc)); - -#define ADC_BUFFER_IN_RAM - -#endif /* defined(CONFIG_NRF_PLATFORM_HALTIUM) */ - struct driver_data { struct adc_context ctx; uint8_t single_ended_channels; - nrf_saadc_value_t *buffer; /* Pointer to the buffer with converted samples. */ uint8_t active_channel_cnt; - -#if defined(ADC_BUFFER_IN_RAM) - void *samples_buffer; + void *mem_reg; void *user_buffer; -#endif }; static struct driver_data m_data = { ADC_CONTEXT_INIT_TIMER(m_data, ctx), ADC_CONTEXT_INIT_LOCK(m_data, ctx), ADC_CONTEXT_INIT_SYNC(m_data, ctx), -#if defined(ADC_BUFFER_IN_RAM) - .samples_buffer = adc_samples_buffer, -#endif + .mem_reg = DMM_DEV_TO_REG(DT_NODELABEL(adc)), }; /* Forward declaration */ @@ -392,22 +378,29 @@ static void adc_context_start_sampling(struct adc_context *ctx) if (ret != NRFX_SUCCESS) { LOG_ERR("Cannot start sampling: 0x%08x", ret); - adc_context_complete(&m_data.ctx, -EIO); + adc_context_complete(ctx, -EIO); } } } static void adc_context_update_buffer_pointer(struct adc_context *ctx, bool repeat) { + void *samples_buffer; + if (!repeat) { -#if defined(ADC_BUFFER_IN_RAM) m_data.user_buffer = (uint16_t *)m_data.user_buffer + m_data.active_channel_cnt; -#else - nrf_saadc_value_t *buffer = (uint16_t *)m_data.buffer + m_data.active_channel_cnt; + } - nrfx_saadc_buffer_set(buffer, m_data.active_channel_cnt); -#endif + int error = dmm_buffer_in_prepare( + m_data.mem_reg, m_data.user_buffer, + NRFX_SAADC_SAMPLES_TO_BYTES(m_data.active_channel_cnt), + &samples_buffer); + if (error != 0) { + LOG_ERR("DMM buffer allocation failed err=%d", error); + adc_context_complete(ctx, -EIO); } + + nrfx_saadc_buffer_set(samples_buffer, m_data.active_channel_cnt); } static int get_resolution(const struct adc_sequence *sequence, nrf_saadc_resolution_t *resolution) @@ -502,12 +495,12 @@ static bool has_single_ended(const struct adc_sequence *sequence) return sequence->channels & m_data.single_ended_channels; } -static void correct_single_ended(const struct adc_sequence *sequence) +static void correct_single_ended(const struct adc_sequence *sequence, nrf_saadc_value_t *buffer) { uint16_t channel_bit = BIT(0); uint8_t selected_channels = sequence->channels; uint8_t single_ended_channels = m_data.single_ended_channels; - int16_t *sample = (int16_t *)m_data.buffer; + int16_t *sample = (int16_t *)buffer; while (channel_bit <= single_ended_channels) { if (channel_bit & selected_channels) { @@ -532,6 +525,7 @@ static int start_read(const struct device *dev, nrf_saadc_oversample_t oversampling; uint8_t active_channel_cnt = 0U; uint8_t channel_id = 0U; + void *samples_buffer; /* Signal an error if channel selection is invalid (no channels or * a non-existing one is selected). @@ -582,16 +576,21 @@ static int start_read(const struct device *dev, } m_data.active_channel_cnt = active_channel_cnt; -#if defined(ADC_BUFFER_IN_RAM) m_data.user_buffer = sequence->buffer; - nrfx_saadc_buffer_set(m_data.samples_buffer, active_channel_cnt); -#else + error = dmm_buffer_in_prepare(m_data.mem_reg, + m_data.user_buffer, + NRFX_SAADC_SAMPLES_TO_BYTES(active_channel_cnt), + &samples_buffer); + if (error != 0) { + LOG_ERR("DMM buffer allocation failed err=%d", error); + return error; + } + /* Buffer is filled in chunks, each chunk composed of number of samples equal to number * of active channels. Buffer pointer is advanced and reloaded after each chunk. */ - nrfx_saadc_buffer_set(sequence->buffer, active_channel_cnt); -#endif + nrfx_saadc_buffer_set(samples_buffer, active_channel_cnt); adc_context_start_read(&m_data.ctx, sequence); @@ -632,17 +631,14 @@ static void event_handler(const nrfx_saadc_evt_t *event) nrfx_err_t err; if (event->type == NRFX_SAADC_EVT_DONE) { - m_data.buffer = event->data.done.p_buffer; + dmm_buffer_in_release( + m_data.mem_reg, m_data.user_buffer, + NRFX_SAADC_SAMPLES_TO_BYTES(m_data.active_channel_cnt), + event->data.done.p_buffer); if (has_single_ended(&m_data.ctx.sequence)) { - correct_single_ended(&m_data.ctx.sequence); + correct_single_ended(&m_data.ctx.sequence, m_data.user_buffer); } - -#if defined(ADC_BUFFER_IN_RAM) - memcpy(m_data.user_buffer, m_data.samples_buffer, - NRFX_SAADC_SAMPLES_TO_BYTES(m_data.active_channel_cnt)); -#endif - adc_context_on_sampling_done(&m_data.ctx, DEVICE_DT_INST_GET(0)); } else if (event->type == NRFX_SAADC_EVT_CALIBRATEDONE) { err = nrfx_saadc_mode_trigger(); diff --git a/drivers/hwinfo/hwinfo_nrf.c b/drivers/hwinfo/hwinfo_nrf.c index f5a6ed38a20..3d3314ddf58 100644 --- a/drivers/hwinfo/hwinfo_nrf.c +++ b/drivers/hwinfo/hwinfo_nrf.c @@ -207,6 +207,15 @@ int z_impl_hwinfo_get_supported_reset_cause(uint32_t *supported) | RESET_SOFTWARE | RESET_CPU_LOCKUP | RESET_LOW_POWER_WAKE +#if NRFX_RESET_REASON_HAS_VBUS + | RESET_POR +#endif +#if NRFX_RESET_REASON_HAS_GRTC + | RESET_CLOCK +#endif +#if defined(NRFX_RESET_REASON_TAMPC_MASK) || defined(NRFX_RESET_REASON_SECTAMPER_MASK) + | RESET_SECURITY +#endif | RESET_DEBUG); return 0; diff --git a/drivers/modem/modem_cellular.c b/drivers/modem/modem_cellular.c index 1c00525b7d8..8eb87fd3608 100644 --- a/drivers/modem/modem_cellular.c +++ b/drivers/modem/modem_cellular.c @@ -1774,7 +1774,7 @@ static int modem_cellular_pm_action(const struct device *dev, enum pm_device_act } #endif /* CONFIG_PM_DEVICE */ -static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { struct modem_cellular_data *data = diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index 43f6e8e97ca..2809d8b3d60 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -49,16 +49,12 @@ #define COUNTER_SPAN (GRTC_SYSCOUNTERL_VALUE_Msk | ((uint64_t)GRTC_SYSCOUNTERH_VALUE_Msk << 32)) #define MAX_ABS_TICKS (COUNTER_SPAN / CYC_PER_TICK) -/* To allow use of CCADD we need to limit max cycles to 31 bits. */ -#define MAX_REL_CYCLES BIT_MASK(31) -#define MAX_REL_TICKS (MAX_REL_CYCLES / CYC_PER_TICK) +#define MAX_TICKS \ + (((COUNTER_SPAN / CYC_PER_TICK) > INT_MAX) ? INT_MAX : (COUNTER_SPAN / CYC_PER_TICK)) -#define LFCLK_FREQUENCY_HZ DT_PROP(LFCLK_NODE, clock_frequency) +#define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK) -/* Threshold used to determine if there is a risk of unexpected GRTC COMPARE event coming - * from previous CC value. - */ -#define LATENCY_THR_TICKS 200 +#define LFCLK_FREQUENCY_HZ DT_PROP(LFCLK_NODE, clock_frequency) #if defined(CONFIG_TEST) const int32_t z_sys_timer_irq_for_test = DT_IRQN(GRTC_NODE); @@ -66,10 +62,8 @@ const int32_t z_sys_timer_irq_for_test = DT_IRQN(GRTC_NODE); static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_context); +static struct k_spinlock lock; static uint64_t last_count; /* Time (SYSCOUNTER value) @last sys_clock_announce() */ -static uint32_t last_elapsed; -static uint64_t cc_value; /* Value that is expected to be in CC register. */ -static uint64_t expired_cc; /* Value that is expected to be in CC register. */ static atomic_t int_mask; static uint8_t ext_channels_allocated; static uint64_t grtc_start_value; @@ -152,13 +146,17 @@ static void compare_int_unlock(int32_t chan, bool key) static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_context) { ARG_UNUSED(id); - ARG_UNUSED(cc_val); ARG_UNUSED(p_context); - uint32_t dticks; + uint64_t dticks; + uint64_t now = counter(); + + if (unlikely(now < cc_val)) { + return; + } dticks = counter_sub(cc_val, last_count) / CYC_PER_TICK; - last_count += (dticks * CYC_PER_TICK); - expired_cc = cc_val; + + last_count += dticks * CYC_PER_TICK; if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) { /* protection is not needed because we are in the GRTC interrupt @@ -167,7 +165,6 @@ static void sys_clock_timeout_handler(int32_t id, uint64_t cc_val, void *p_conte system_timeout_set_abs(last_count + CYC_PER_TICK); } - last_elapsed = 0; sys_clock_announce((int32_t)dticks); } @@ -371,7 +368,6 @@ uint64_t z_nrf_grtc_timer_startup_value_get(void) int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) { nrfx_err_t err_code; - static struct k_spinlock lock; static uint8_t systemoff_channel; uint64_t now = counter(); nrfx_grtc_sleep_config_t sleep_cfg; @@ -434,12 +430,20 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) uint32_t sys_clock_cycle_get_32(void) { - return nrf_grtc_sys_counter_low_get(NRF_GRTC); + k_spinlock_key_t key = k_spin_lock(&lock); + uint32_t ret = (uint32_t)counter(); + + k_spin_unlock(&lock, key); + return ret; } uint64_t sys_clock_cycle_get_64(void) { - return counter(); + k_spinlock_key_t key = k_spin_lock(&lock); + uint64_t ret = counter(); + + k_spin_unlock(&lock, key); + return ret; } uint32_t sys_clock_elapsed(void) @@ -448,9 +452,7 @@ uint32_t sys_clock_elapsed(void) return 0; } - last_elapsed = (uint32_t)counter_sub(counter(), last_count); - - return last_elapsed / CYC_PER_TICK; + return (uint32_t)(counter_sub(counter(), last_count) / CYC_PER_TICK); } static int sys_clock_driver_init(void) @@ -491,10 +493,6 @@ static int sys_clock_driver_init(void) last_count = (counter() / CYC_PER_TICK) * CYC_PER_TICK; grtc_start_value = last_count; - expired_cc = UINT64_MAX; - nrfx_grtc_channel_callback_set(system_clock_channel_data.channel, - sys_clock_timeout_handler, NULL); - int_mask = NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK; if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) { system_timeout_set_relative(CYC_PER_TICK); @@ -553,48 +551,18 @@ void sys_clock_set_timeout(int32_t ticks, bool idle) return; } - uint32_t ch = system_clock_channel_data.channel; - - if ((cc_value == expired_cc) && (ticks < MAX_REL_TICKS)) { - uint32_t cyc = ticks * CYC_PER_TICK; - - if (cyc == 0) { - /* GRTC will expire anyway since HW ensures that past value triggers an - * event but we need to ensure to always progress the cc_value as this - * if condition expects that cc_value will change after each call to - * set_timeout function. - */ - cyc = 1; - } + ticks = (ticks == K_TICKS_FOREVER) ? MAX_TICKS : MIN(MAX_TICKS, MAX(ticks, 0)); - /* If it's the first timeout setting after previous expiration and timeout - * is short so fast method can be used which utilizes relative CC configuration. - */ - cc_value += cyc; - nrfx_grtc_syscounter_cc_rel_set(ch, cyc, NRFX_GRTC_CC_RELATIVE_COMPARE); - return; - } + uint64_t delta_time = ticks * CYC_PER_TICK; - uint64_t cyc = (uint64_t)ticks * CYC_PER_TICK; - bool safe_setting = false; - int64_t prev_cc_val = cc_value; + uint64_t target_time = counter() + delta_time; - cc_value = last_count + last_elapsed + cyc; - - /* In case of timeout abort it may happen that CC is being set to a value - * that later than previous CC. If previous CC value is not far in the - * future, there is a risk that COMPARE event will be triggered for that - * previous CC value. If there is such risk safe procedure must be applied - * which is more time consuming but ensures that there will be no spurious - * event. + /* Rounded down target_time to the tick boundary + * (but not less than one tick after the last) */ - if (prev_cc_val < cc_value) { - int64_t now = last_count + last_elapsed; - - safe_setting = (prev_cc_val - now) < LATENCY_THR_TICKS; - } + target_time = MAX((target_time - last_count)/CYC_PER_TICK, 1)*CYC_PER_TICK + last_count; - nrfx_grtc_syscounter_cc_abs_set(ch, cc_value, safe_setting); + system_timeout_set_abs(target_time); } #if defined(CONFIG_NRF_GRTC_TIMER_APP_DEFINED_INIT) diff --git a/drivers/wifi/esp32/src/esp_wifi_drv.c b/drivers/wifi/esp32/src/esp_wifi_drv.c index 305994d6a32..72c4c512717 100644 --- a/drivers/wifi/esp32/src/esp_wifi_drv.c +++ b/drivers/wifi/esp32/src/esp_wifi_drv.c @@ -77,7 +77,7 @@ struct esp32_wifi_runtime { static struct net_mgmt_event_callback esp32_dhcp_cb; -static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { diff --git a/drivers/wifi/nrf_wifi/src/fmac_main.c b/drivers/wifi/nrf_wifi/src/fmac_main.c index f2d9aa55af9..125ffd7a9a1 100644 --- a/drivers/wifi/nrf_wifi/src/fmac_main.c +++ b/drivers/wifi/nrf_wifi/src/fmac_main.c @@ -79,6 +79,8 @@ BUILD_ASSERT(CONFIG_NRF70_TX_MAX_DATA_SIZE % 4 == 0, "TX buffer size must be a multiple of 4"); BUILD_ASSERT(CONFIG_NRF70_RX_MAX_DATA_SIZE % 4 == 0, "RX buffer size must be a multiple of 4"); +BUILD_ASSERT(CONFIG_NRF70_RX_MAX_DATA_SIZE >= 400, + "RX buffer size must be at least 400 bytes"); static const unsigned char aggregation = 1; static const unsigned char max_num_tx_agg_sessions = 4; diff --git a/dts/vendor/nordic/nrf54lm20a.dtsi b/dts/vendor/nordic/nrf54lm20a.dtsi index d673ae94e50..d1e6d1b0d28 100644 --- a/dts/vendor/nordic/nrf54lm20a.dtsi +++ b/dts/vendor/nordic/nrf54lm20a.dtsi @@ -800,19 +800,19 @@ #address-cells = <1>; #size-cells = <1>; - gpregret1: gpregret1@51c { + gpregret1: gpregret1@500 { #address-cells = <1>; #size-cells = <1>; compatible = "nordic,nrf-gpregret"; - reg = <0x51c 0x1>; + reg = <0x500 0x1>; status = "disabled"; }; - gpregret2: gpregret2@520 { + gpregret2: gpregret2@504 { #address-cells = <1>; #size-cells = <1>; compatible = "nordic,nrf-gpregret"; - reg = <0x520 0x1>; + reg = <0x504 0x1>; status = "disabled"; }; }; diff --git a/include/zephyr/bluetooth/gatt.h b/include/zephyr/bluetooth/gatt.h index 3597c7c5fdb..2c7d36a6758 100644 --- a/include/zephyr/bluetooth/gatt.h +++ b/include/zephyr/bluetooth/gatt.h @@ -918,6 +918,7 @@ ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, * Read include service attribute value from local database storing the result * into buffer after encoding it. * @note Only use this with attributes which user_data is a ``bt_gatt_include``. + * The function returns EINVAL if @p attr or @p attr->user_data is NULL. * * @param conn Connection object. * @param attr Attribute to read. diff --git a/include/zephyr/bluetooth/l2cap.h b/include/zephyr/bluetooth/l2cap.h index f8781d791f0..380b52ad508 100644 --- a/include/zephyr/bluetooth/l2cap.h +++ b/include/zephyr/bluetooth/l2cap.h @@ -111,6 +111,20 @@ extern "C" { */ #define BT_L2CAP_ECRED_MIN_MPS 64 +/** @brief L2CAP maximum MTU + * + * The maximum MTU for an L2CAP Based Connection. This is the same with or without ECRED. This + * requirement is taken from text in Core 3.A.4.22 and 3.A.4.26 v6.0. + */ +#define BT_L2CAP_MAX_MTU UINT16_MAX + +/** @brief L2CAP maximum MPS + * + * The maximum MPS for an L2CAP Based Connection. This is the same with or without ECRED. This + * requirement is taken from text in Core 3.A.4.22 and 3.A.4.26 v6.0. + */ +#define BT_L2CAP_MAX_MPS 65533 + /** @brief The maximum number of channels in ECRED L2CAP signaling PDUs * * Currently, this is the maximum number of channels referred to in the diff --git a/include/zephyr/drivers/firmware/tisci/tisci.h b/include/zephyr/drivers/firmware/tisci/tisci.h index 8097d6d4405..38fc58b9121 100644 --- a/include/zephyr/drivers/firmware/tisci/tisci.h +++ b/include/zephyr/drivers/firmware/tisci/tisci.h @@ -891,44 +891,6 @@ int tisci_cmd_set_fwl_region(const struct device *dev, const struct tisci_msg_fw */ int tisci_cmd_get_fwl_region(const struct device *dev, struct tisci_msg_fwl_region *region); -/* INCLUDE_ZEPHYR_DRIVERS_TISCI_H_ */ - -/* Firewall Management Functions */ -/* ... previous firewall functions ... */ - -/** - * @brief Get firewall region configuration - * - * Retrieves the configuration of a firewall region including permissions, - * addresses, and control settings. - * - * @param dev Pointer to the TI SCI device - * @param region Pointer to store the firewall region configuration. - * The fwl_id, region, and n_permission_regs fields must be - * set before calling this function. - * - * @return 0 if successful, or an error code - */ -int tisci_cmd_get_fwl_region(const struct device *dev, struct tisci_msg_fwl_region *region); - -/* Firewall Management Functions */ -/* ... previous firewall functions ... */ - -/** - * @brief Get firewall region configuration - * - * Retrieves the configuration of a firewall region including permissions, - * addresses, and control settings. - * - * @param dev Pointer to the TI SCI device - * @param region Pointer to store the firewall region configuration. - * The fwl_id, region, and n_permission_regs fields must be - * set before calling this function. - * - * @return 0 if successful, or an error code - */ -int tisci_cmd_get_fwl_region(const struct device *dev, struct tisci_msg_fwl_region *region); - /* Firewall Management Functions */ /* ... previous firewall functions ... */ diff --git a/include/zephyr/net/coap_mgmt.h b/include/zephyr/net/coap_mgmt.h index 961ca18d1ab..0cc25a9cb18 100644 --- a/include/zephyr/net/coap_mgmt.h +++ b/include/zephyr/net/coap_mgmt.h @@ -40,13 +40,25 @@ struct coap_service; struct coap_resource; struct coap_observer; +enum { + NET_EVENT_COAP_CMD_SERVICE_STARTED_VAL, + NET_EVENT_COAP_CMD_SERVICE_STOPPED_VAL, + NET_EVENT_COAP_CMD_OBSERVER_ADDED_VAL, + NET_EVENT_COAP_CMD_OBSERVER_REMOVED_VAL, + + NET_EVENT_COAP_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_COAP_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_coap_cmd exceeds the limit"); + enum net_event_coap_cmd { /* Service events */ - NET_EVENT_COAP_CMD_SERVICE_STARTED = 1, - NET_EVENT_COAP_CMD_SERVICE_STOPPED, + NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STARTED), + NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STOPPED), /* Observer events */ - NET_EVENT_COAP_CMD_OBSERVER_ADDED, - NET_EVENT_COAP_CMD_OBSERVER_REMOVED, + NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_ADDED), + NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_REMOVED), }; /** @endcond */ diff --git a/include/zephyr/net/conn_mgr_connectivity.h b/include/zephyr/net/conn_mgr_connectivity.h index d1b0ea8106a..cb0f63fcfac 100644 --- a/include/zephyr/net/conn_mgr_connectivity.h +++ b/include/zephyr/net/conn_mgr_connectivity.h @@ -41,9 +41,19 @@ extern "C" { NET_MGMT_EVENT_BIT) #define NET_MGMT_CONN_IF_EVENT (NET_MGMT_IFACE_BIT | NET_MGMT_CONN_BASE) +enum { + NET_EVENT_CONN_CMD_IF_TIMEOUT_VAL, + NET_EVENT_CONN_CMD_IF_FATAL_ERROR_VAL, + + NET_EVENT_CONN_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_CONN_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_conn_cmd exceeds the limit"); + enum net_event_conn_cmd { - NET_EVENT_CONN_CMD_IF_TIMEOUT = 1, - NET_EVENT_CONN_CMD_IF_FATAL_ERROR, + NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_TIMEOUT), + NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_FATAL_ERROR), }; /** @endcond */ diff --git a/include/zephyr/net/ethernet_mgmt.h b/include/zephyr/net/ethernet_mgmt.h index 750e899da20..79306e9195a 100644 --- a/include/zephyr/net/ethernet_mgmt.h +++ b/include/zephyr/net/ethernet_mgmt.h @@ -188,11 +188,23 @@ struct ethernet_req_params { }; }; +enum { + NET_EVENT_ETHERNET_CMD_CARRIER_ON_VAL, + NET_EVENT_ETHERNET_CMD_CARRIER_OFF_VAL, + NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED_VAL, + NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED_VAL, + + NET_EVENT_ETHERNET_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_ETHERNET_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_ethernet_cmd exceeds the limit"); + enum net_event_ethernet_cmd { - NET_EVENT_ETHERNET_CMD_CARRIER_ON = 1, - NET_EVENT_ETHERNET_CMD_CARRIER_OFF, - NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED, - NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED, + NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_CARRIER_ON), + NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_CARRIER_OFF), + NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED), + NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED), }; #define NET_EVENT_ETHERNET_CARRIER_ON \ diff --git a/include/zephyr/net/ieee802154_mgmt.h b/include/zephyr/net/ieee802154_mgmt.h index bf20b49b720..970f8a89a9c 100644 --- a/include/zephyr/net/ieee802154_mgmt.h +++ b/include/zephyr/net/ieee802154_mgmt.h @@ -255,8 +255,17 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_IEEE802154_GET_SECURITY_SETTINGS); * @cond INTERNAL_HIDDEN */ +enum { + NET_EVENT_IEEE802154_CMD_SCAN_RESULT_VAL, + + NET_EVENT_IEEE802154_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_IEEE802154_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_ieee802154_cmd exceeds the limit"); + enum net_event_ieee802154_cmd { - NET_EVENT_IEEE802154_CMD_SCAN_RESULT = 1, + NET_MGMT_CMD(NET_EVENT_IEEE802154_CMD_SCAN_RESULT), }; /** diff --git a/include/zephyr/net/net_event.h b/include/zephyr/net/net_event.h index 0b8c995cd3e..556a78ae99e 100644 --- a/include/zephyr/net/net_event.h +++ b/include/zephyr/net/net_event.h @@ -13,6 +13,7 @@ #define ZEPHYR_INCLUDE_NET_NET_EVENT_H_ #include +#include #include #ifdef __cplusplus @@ -34,11 +35,23 @@ extern "C" { NET_MGMT_LAYER(NET_IF_LAYER) | \ NET_MGMT_LAYER_CODE(NET_IF_CORE_CODE)) +enum { + NET_EVENT_IF_CMD_DOWN_VAL, + NET_EVENT_IF_CMD_UP_VAL, + NET_EVENT_IF_CMD_ADMIN_DOWN_VAL, + NET_EVENT_IF_CMD_ADMIN_UP_VAL, + + NET_EVENT_IF_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_IF_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_if_cmd exceeds the limit"); + enum net_event_if_cmd { - NET_EVENT_IF_CMD_DOWN = 1, - NET_EVENT_IF_CMD_UP, - NET_EVENT_IF_CMD_ADMIN_DOWN, - NET_EVENT_IF_CMD_ADMIN_UP, + NET_MGMT_CMD(NET_EVENT_IF_CMD_DOWN), + NET_MGMT_CMD(NET_EVENT_IF_CMD_UP), + NET_MGMT_CMD(NET_EVENT_IF_CMD_ADMIN_DOWN), + NET_MGMT_CMD(NET_EVENT_IF_CMD_ADMIN_UP), }; /* IPv6 Events */ @@ -49,32 +62,65 @@ enum net_event_if_cmd { NET_MGMT_LAYER(NET_IPV6_LAYER) | \ NET_MGMT_LAYER_CODE(NET_IPV6_CORE_CODE)) +enum { + NET_EVENT_IPV6_CMD_ADDR_ADD_VAL, + NET_EVENT_IPV6_CMD_ADDR_DEL_VAL, + NET_EVENT_IPV6_CMD_MADDR_ADD_VAL, + NET_EVENT_IPV6_CMD_MADDR_DEL_VAL, + NET_EVENT_IPV6_CMD_PREFIX_ADD_VAL, + NET_EVENT_IPV6_CMD_PREFIX_DEL_VAL, + NET_EVENT_IPV6_CMD_MCAST_JOIN_VAL, + NET_EVENT_IPV6_CMD_MCAST_LEAVE_VAL, + NET_EVENT_IPV6_CMD_ROUTER_ADD_VAL, + NET_EVENT_IPV6_CMD_ROUTER_DEL_VAL, + NET_EVENT_IPV6_CMD_ROUTE_ADD_VAL, + NET_EVENT_IPV6_CMD_ROUTE_DEL_VAL, + NET_EVENT_IPV6_CMD_DAD_SUCCEED_VAL, + NET_EVENT_IPV6_CMD_DAD_FAILED_VAL, + NET_EVENT_IPV6_CMD_NBR_ADD_VAL, + NET_EVENT_IPV6_CMD_NBR_DEL_VAL, + NET_EVENT_IPV6_CMD_DHCP_START_VAL, + NET_EVENT_IPV6_CMD_DHCP_BOUND_VAL, + NET_EVENT_IPV6_CMD_DHCP_STOP_VAL, + NET_EVENT_IPV6_CMD_ADDR_DEPRECATED_VAL, + NET_EVENT_IPV6_CMD_PE_ENABLED_VAL, + NET_EVENT_IPV6_CMD_PE_DISABLED_VAL, + NET_EVENT_IPV6_CMD_PE_FILTER_ADD_VAL, + NET_EVENT_IPV6_CMD_PE_FILTER_DEL_VAL, + NET_EVENT_IPV6_CMD_PMTU_CHANGED_VAL, + + NET_EVENT_IPV6_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_IPV6_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_ipv6_cmd exceeds the limit"); + enum net_event_ipv6_cmd { - NET_EVENT_IPV6_CMD_ADDR_ADD = 1, - NET_EVENT_IPV6_CMD_ADDR_DEL, - NET_EVENT_IPV6_CMD_MADDR_ADD, - NET_EVENT_IPV6_CMD_MADDR_DEL, - NET_EVENT_IPV6_CMD_PREFIX_ADD, - NET_EVENT_IPV6_CMD_PREFIX_DEL, - NET_EVENT_IPV6_CMD_MCAST_JOIN, - NET_EVENT_IPV6_CMD_MCAST_LEAVE, - NET_EVENT_IPV6_CMD_ROUTER_ADD, - NET_EVENT_IPV6_CMD_ROUTER_DEL, - NET_EVENT_IPV6_CMD_ROUTE_ADD, - NET_EVENT_IPV6_CMD_ROUTE_DEL, - NET_EVENT_IPV6_CMD_DAD_SUCCEED, - NET_EVENT_IPV6_CMD_DAD_FAILED, - NET_EVENT_IPV6_CMD_NBR_ADD, - NET_EVENT_IPV6_CMD_NBR_DEL, - NET_EVENT_IPV6_CMD_DHCP_START, - NET_EVENT_IPV6_CMD_DHCP_BOUND, - NET_EVENT_IPV6_CMD_DHCP_STOP, - NET_EVENT_IPV6_CMD_ADDR_DEPRECATED, - NET_EVENT_IPV6_CMD_PE_ENABLED, - NET_EVENT_IPV6_CMD_PE_DISABLED, - NET_EVENT_IPV6_CMD_PE_FILTER_ADD, - NET_EVENT_IPV6_CMD_PE_FILTER_DEL, - NET_EVENT_IPV6_CMD_PMTU_CHANGED, + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ADDR_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ADDR_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_MADDR_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_MADDR_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PREFIX_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PREFIX_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_MCAST_JOIN), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_MCAST_LEAVE), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ROUTER_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ROUTER_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ROUTE_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ROUTE_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_DAD_SUCCEED), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_DAD_FAILED), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_NBR_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_NBR_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_DHCP_START), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_DHCP_BOUND), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_DHCP_STOP), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_ADDR_DEPRECATED), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PE_ENABLED), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PE_DISABLED), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PE_FILTER_ADD), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PE_FILTER_DEL), + NET_MGMT_CMD(NET_EVENT_IPV6_CMD_PMTU_CHANGED), }; /* IPv4 Events*/ @@ -85,22 +131,45 @@ enum net_event_ipv6_cmd { NET_MGMT_LAYER(NET_IPV4_LAYER) | \ NET_MGMT_LAYER_CODE(NET_IPV4_CORE_CODE)) +enum { + NET_EVENT_IPV4_CMD_ADDR_ADD_VAL, + NET_EVENT_IPV4_CMD_ADDR_DEL_VAL, + NET_EVENT_IPV4_CMD_MADDR_ADD_VAL, + NET_EVENT_IPV4_CMD_MADDR_DEL_VAL, + NET_EVENT_IPV4_CMD_ROUTER_ADD_VAL, + NET_EVENT_IPV4_CMD_ROUTER_DEL_VAL, + NET_EVENT_IPV4_CMD_DHCP_START_VAL, + NET_EVENT_IPV4_CMD_DHCP_BOUND_VAL, + NET_EVENT_IPV4_CMD_DHCP_STOP_VAL, + NET_EVENT_IPV4_CMD_MCAST_JOIN_VAL, + NET_EVENT_IPV4_CMD_MCAST_LEAVE_VAL, + NET_EVENT_IPV4_CMD_ACD_SUCCEED_VAL, + NET_EVENT_IPV4_CMD_ACD_FAILED_VAL, + NET_EVENT_IPV4_CMD_ACD_CONFLICT_VAL, + NET_EVENT_IPV4_CMD_PMTU_CHANGED_VAL, + + NET_EVENT_IPV4_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_IPV4_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_ipv4_cmd exceeds the limit"); + enum net_event_ipv4_cmd { - NET_EVENT_IPV4_CMD_ADDR_ADD = 1, - NET_EVENT_IPV4_CMD_ADDR_DEL, - NET_EVENT_IPV4_CMD_MADDR_ADD, - NET_EVENT_IPV4_CMD_MADDR_DEL, - NET_EVENT_IPV4_CMD_ROUTER_ADD, - NET_EVENT_IPV4_CMD_ROUTER_DEL, - NET_EVENT_IPV4_CMD_DHCP_START, - NET_EVENT_IPV4_CMD_DHCP_BOUND, - NET_EVENT_IPV4_CMD_DHCP_STOP, - NET_EVENT_IPV4_CMD_MCAST_JOIN, - NET_EVENT_IPV4_CMD_MCAST_LEAVE, - NET_EVENT_IPV4_CMD_ACD_SUCCEED, - NET_EVENT_IPV4_CMD_ACD_FAILED, - NET_EVENT_IPV4_CMD_ACD_CONFLICT, - NET_EVENT_IPV4_CMD_PMTU_CHANGED, + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ADDR_ADD), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ADDR_DEL), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_MADDR_ADD), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_MADDR_DEL), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ROUTER_ADD), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ROUTER_DEL), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_DHCP_START), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_DHCP_BOUND), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_DHCP_STOP), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_MCAST_JOIN), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_MCAST_LEAVE), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ACD_SUCCEED), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ACD_FAILED), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_ACD_CONFLICT), + NET_MGMT_CMD(NET_EVENT_IPV4_CMD_PMTU_CHANGED), }; /* L4 network events */ @@ -111,22 +180,45 @@ enum net_event_ipv4_cmd { NET_MGMT_LAYER(NET_L4_LAYER) | \ NET_MGMT_LAYER_CODE(NET_L4_CORE_CODE)) +enum { + NET_EVENT_L4_CMD_CONNECTED_VAL, + NET_EVENT_L4_CMD_DISCONNECTED_VAL, + NET_EVENT_L4_CMD_IPV4_CONNECTED_VAL, + NET_EVENT_L4_CMD_IPV4_DISCONNECTED_VAL, + NET_EVENT_L4_CMD_IPV6_CONNECTED_VAL, + NET_EVENT_L4_CMD_IPV6_DISCONNECTED_VAL, + NET_EVENT_L4_CMD_DNS_SERVER_ADD_VAL, + NET_EVENT_L4_CMD_DNS_SERVER_DEL_VAL, + NET_EVENT_L4_CMD_HOSTNAME_CHANGED_VAL, + NET_EVENT_L4_CMD_CAPTURE_STARTED_VAL, + NET_EVENT_L4_CMD_CAPTURE_STOPPED_VAL, + NET_EVENT_L4_CMD_VPN_CONNECTED_VAL, + NET_EVENT_L4_CMD_VPN_DISCONNECTED_VAL, + NET_EVENT_L4_CMD_VPN_PEER_ADD_VAL, + NET_EVENT_L4_CMD_VPN_PEER_DEL_VAL, + + NET_EVENT_L4_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_L4_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_l4_cmd exceeds the limit"); + enum net_event_l4_cmd { - NET_EVENT_L4_CMD_CONNECTED = 1, - NET_EVENT_L4_CMD_DISCONNECTED, - NET_EVENT_L4_CMD_IPV4_CONNECTED, - NET_EVENT_L4_CMD_IPV4_DISCONNECTED, - NET_EVENT_L4_CMD_IPV6_CONNECTED, - NET_EVENT_L4_CMD_IPV6_DISCONNECTED, - NET_EVENT_L4_CMD_DNS_SERVER_ADD, - NET_EVENT_L4_CMD_DNS_SERVER_DEL, - NET_EVENT_L4_CMD_HOSTNAME_CHANGED, - NET_EVENT_L4_CMD_CAPTURE_STARTED, - NET_EVENT_L4_CMD_CAPTURE_STOPPED, - NET_EVENT_L4_CMD_VPN_CONNECTED, - NET_EVENT_L4_CMD_VPN_DISCONNECTED, - NET_EVENT_L4_CMD_VPN_PEER_ADD, - NET_EVENT_L4_CMD_VPN_PEER_DEL, + NET_MGMT_CMD(NET_EVENT_L4_CMD_CONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_DISCONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_IPV4_CONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_IPV4_DISCONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_IPV6_CONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_IPV6_DISCONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_DNS_SERVER_ADD), + NET_MGMT_CMD(NET_EVENT_L4_CMD_DNS_SERVER_DEL), + NET_MGMT_CMD(NET_EVENT_L4_CMD_HOSTNAME_CHANGED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_CAPTURE_STARTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_CAPTURE_STOPPED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_VPN_CONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_VPN_DISCONNECTED), + NET_MGMT_CMD(NET_EVENT_L4_CMD_VPN_PEER_ADD), + NET_MGMT_CMD(NET_EVENT_L4_CMD_VPN_PEER_DEL), }; /** @endcond */ @@ -153,11 +245,11 @@ enum net_event_l4_cmd { /** Event emitted when an IPv6 address is removed from the system. */ #define NET_EVENT_IPV6_ADDR_DEL \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_ADDR_DEL) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_ADDR_DEL) /** Event emitted when an IPv6 multicast address is added to the system. */ #define NET_EVENT_IPV6_MADDR_ADD \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_MADDR_ADD) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_MADDR_ADD) /** Event emitted when an IPv6 multicast address is removed from the system. */ #define NET_EVENT_IPV6_MADDR_DEL \ @@ -165,19 +257,19 @@ enum net_event_l4_cmd { /** Event emitted when an IPv6 prefix is added to the system. */ #define NET_EVENT_IPV6_PREFIX_ADD \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PREFIX_ADD) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PREFIX_ADD) /** Event emitted when an IPv6 prefix is removed from the system. */ #define NET_EVENT_IPV6_PREFIX_DEL \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PREFIX_DEL) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_PREFIX_DEL) /** Event emitted when an IPv6 multicast group is joined. */ #define NET_EVENT_IPV6_MCAST_JOIN \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_MCAST_JOIN) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_MCAST_JOIN) /** Event emitted when an IPv6 multicast group is left. */ #define NET_EVENT_IPV6_MCAST_LEAVE \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_MCAST_LEAVE) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_MCAST_LEAVE) /** Event emitted when an IPv6 router is added to the system. */ #define NET_EVENT_IPV6_ROUTER_ADD \ @@ -213,15 +305,15 @@ enum net_event_l4_cmd { /** Event emitted when an IPv6 DHCP client starts. */ #define NET_EVENT_IPV6_DHCP_START \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_DHCP_START) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_DHCP_START) /** Event emitted when an IPv6 DHCP client address is bound. */ #define NET_EVENT_IPV6_DHCP_BOUND \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_DHCP_BOUND) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_DHCP_BOUND) /** Event emitted when an IPv6 DHCP client is stopped. */ #define NET_EVENT_IPV6_DHCP_STOP \ - (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_DHCP_STOP) + (NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_DHCP_STOP) /** IPv6 address is deprecated. */ #define NET_EVENT_IPV6_ADDR_DEPRECATED \ @@ -253,11 +345,11 @@ enum net_event_l4_cmd { /** Event emitted when an IPv4 address is removed from the system. */ #define NET_EVENT_IPV4_ADDR_DEL \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ADDR_DEL) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ADDR_DEL) /** Event emitted when an IPv4 multicast address is added to the system. */ #define NET_EVENT_IPV4_MADDR_ADD \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_MADDR_ADD) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_MADDR_ADD) /** Event emitted when an IPv4 multicast address is removed from the system. */ #define NET_EVENT_IPV4_MADDR_DEL \ @@ -265,31 +357,31 @@ enum net_event_l4_cmd { /** Event emitted when an IPv4 router is added to the system. */ #define NET_EVENT_IPV4_ROUTER_ADD \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ROUTER_ADD) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ROUTER_ADD) /** Event emitted when an IPv4 router is removed from the system. */ #define NET_EVENT_IPV4_ROUTER_DEL \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ROUTER_DEL) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_ROUTER_DEL) /** Event emitted when an IPv4 DHCP client is started. */ #define NET_EVENT_IPV4_DHCP_START \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_DHCP_START) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_DHCP_START) /** Event emitted when an IPv4 DHCP client address is bound. */ #define NET_EVENT_IPV4_DHCP_BOUND \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_DHCP_BOUND) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_DHCP_BOUND) /** Event emitted when an IPv4 DHCP client is stopped. */ #define NET_EVENT_IPV4_DHCP_STOP \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_DHCP_STOP) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_DHCP_STOP) /** Event emitted when an IPv4 multicast group is joined. */ #define NET_EVENT_IPV4_MCAST_JOIN \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_MCAST_JOIN) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_MCAST_JOIN) /** Event emitted when an IPv4 multicast group is left. */ #define NET_EVENT_IPV4_MCAST_LEAVE \ - (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_MCAST_LEAVE) + (NET_EVENT_IPV4_BASE | NET_EVENT_IPV4_CMD_MCAST_LEAVE) /** Event emitted when an IPv4 address conflict detection succeeds. */ #define NET_EVENT_IPV4_ACD_SUCCEED \ diff --git a/include/zephyr/net/net_mgmt.h b/include/zephyr/net/net_mgmt.h index 04e95cbb5ec..1c5f0aebeaa 100644 --- a/include/zephyr/net/net_mgmt.h +++ b/include/zephyr/net/net_mgmt.h @@ -14,7 +14,6 @@ #include #include -#include #include #ifdef __cplusplus @@ -25,7 +24,7 @@ extern "C" { * @brief Network Management * @defgroup net_mgmt Network Management * @since 1.7 - * @version 1.0.0 + * @version 2.0.0 * @ingroup networking * @{ */ @@ -36,38 +35,30 @@ struct net_if; /** * @brief NET MGMT event mask basics, normalizing parts of bit fields */ -#define NET_MGMT_EVENT_MASK 0x80000000 -#define NET_MGMT_ON_IFACE_MASK 0x40000000 -#define NET_MGMT_LAYER_MASK 0x30000000 -#define NET_MGMT_SYNC_EVENT_MASK 0x08000000 -#define NET_MGMT_LAYER_CODE_MASK 0x07FF0000 -#define NET_MGMT_COMMAND_MASK 0x0000FFFF - -#define NET_MGMT_EVENT_BIT BIT(31) -#define NET_MGMT_IFACE_BIT BIT(30) -#define NET_MGMT_SYNC_EVENT_BIT BIT(27) - -#define NET_MGMT_LAYER(_layer) (_layer << 28) -#define NET_MGMT_LAYER_CODE(_code) (_code << 16) - -#define NET_MGMT_EVENT(mgmt_request) \ - (mgmt_request & NET_MGMT_EVENT_MASK) +#define NET_MGMT_EVENT_MASK GENMASK64(63, 63) /* 0x8000000000000000 */ +#define NET_MGMT_ON_IFACE_MASK GENMASK64(62, 62) /* 0x4000000000000000 */ +#define NET_MGMT_LAYER_MASK GENMASK64(61, 60) /* 0x3000000000000000 */ +#define NET_MGMT_SYNC_EVENT_MASK GENMASK64(59, 59) /* 0x0800000000000000 */ +#define NET_MGMT_LAYER_CODE_MASK GENMASK64(58, 52) /* 0x07F0000000000000 */ +#define NET_MGMT_COMMAND_MASK GENMASK64(51, 0) /* 0x000FFFFFFFFFFFFF */ -#define NET_MGMT_ON_IFACE(mgmt_request) \ - (mgmt_request & NET_MGMT_ON_IFACE_MASK) +#define NET_MGMT_MAX_COMMANDS 52 /* TODO: figure out the value from mask */ -#define NET_MGMT_EVENT_SYNCHRONOUS(mgmt_request) \ - (mgmt_request & NET_MGMT_SYNC_EVENT_MASK) +#define NET_MGMT_EVENT_BIT BIT64(63) +#define NET_MGMT_IFACE_BIT BIT64(62) +#define NET_MGMT_SYNC_EVENT_BIT BIT64(59) -#define NET_MGMT_GET_LAYER(mgmt_request) \ - ((mgmt_request & NET_MGMT_LAYER_MASK) >> 28) +#define NET_MGMT_LAYER(_layer) FIELD_PREP(NET_MGMT_LAYER_MASK, (_layer)) +#define NET_MGMT_LAYER_CODE(_code) FIELD_PREP(NET_MGMT_LAYER_CODE_MASK, (_code)) -#define NET_MGMT_GET_LAYER_CODE(mgmt_request) \ - ((mgmt_request & NET_MGMT_LAYER_CODE_MASK) >> 16) - -#define NET_MGMT_GET_COMMAND(mgmt_request) \ - (mgmt_request & NET_MGMT_COMMAND_MASK) +#define NET_MGMT_EVENT(mgmt_request) FIELD_GET(NET_MGMT_EVENT_MASK, mgmt_request) +#define NET_MGMT_ON_IFACE(mgmt_request) FIELD_GET(NET_MGMT_ON_IFACE_MASK, mgmt_request) +#define NET_MGMT_EVENT_SYNCHRONOUS(mgmt_request) FIELD_GET(NET_MGMT_SYNC_EVENT_MASK, mgmt_request) +#define NET_MGMT_GET_LAYER(mgmt_request) FIELD_GET(NET_MGMT_LAYER_MASK, mgmt_request) +#define NET_MGMT_GET_LAYER_CODE(mgmt_request) FIELD_GET(NET_MGMT_LAYER_CODE_MASK, mgmt_request) +#define NET_MGMT_GET_COMMAND(mgmt_request) FIELD_GET(NET_MGMT_COMMAND_MASK, mgmt_request) +#define NET_MGMT_CMD(cmd) cmd = BIT64(cmd ##_VAL) /* Useful generic definitions */ #define NET_MGMT_LAYER_L2 1 @@ -102,6 +93,8 @@ enum net_mgmt_layer_code { NET_MGMT_LAYER_CODE_RESERVED = 0x7F /**< Reserved layer code for future use */ }; +#include + /** * @typedef net_mgmt_request_handler_t * @brief Signature which all Net MGMT request handler need to follow @@ -113,7 +106,7 @@ enum net_mgmt_layer_code { * NULL otherwise. * @param len Length in byte of the memory pointed by data. */ -typedef int (*net_mgmt_request_handler_t)(uint32_t mgmt_request, +typedef int (*net_mgmt_request_handler_t)(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len); @@ -134,7 +127,7 @@ typedef int (*net_mgmt_request_handler_t)(uint32_t mgmt_request, * @param _mgmt_request Management event identifier */ #define NET_MGMT_DEFINE_REQUEST_HANDLER(_mgmt_request) \ - extern int net_mgmt_##_mgmt_request(uint32_t mgmt_request, \ + extern int net_mgmt_##_mgmt_request(uint64_t mgmt_request, \ struct net_if *iface, \ void *data, size_t len) @@ -158,7 +151,7 @@ struct net_mgmt_event_callback; * if it's an event on an iface. NULL otherwise. */ typedef void (*net_mgmt_event_handler_t)(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface); /** @@ -202,11 +195,11 @@ struct net_mgmt_event_callback { * receive events from multiple layers, one must have multiple * listeners registered, one for each layer being listened. */ - uint32_t event_mask; + uint64_t event_mask; /** Internal place holder when a synchronous event wait is * successfully unlocked on a event. */ - uint32_t raised_event; + uint64_t raised_event; }; }; @@ -221,7 +214,7 @@ struct net_mgmt_event_callback { * @param info_length Length in bytes of the memory pointed by @p info. * @param user_data Data provided by the user to the handler. */ -typedef void (*net_mgmt_event_static_handler_t)(uint32_t mgmt_event, +typedef void (*net_mgmt_event_static_handler_t)(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data); @@ -230,7 +223,7 @@ typedef void (*net_mgmt_event_static_handler_t)(uint32_t mgmt_event, /* Structure for event handler registered at compile time */ struct net_mgmt_event_static_handler { - uint32_t event_mask; + uint64_t event_mask; net_mgmt_event_static_handler_t handler; void *user_data; }; @@ -267,7 +260,7 @@ struct net_mgmt_event_static_handler { static inline void net_mgmt_init_event_callback(struct net_mgmt_event_callback *cb, net_mgmt_event_handler_t handler, - uint32_t mgmt_event_mask) + uint64_t mgmt_event_mask) { __ASSERT(cb, "Callback pointer should not be NULL"); __ASSERT(handler, "Handler pointer should not be NULL"); @@ -313,7 +306,7 @@ void net_mgmt_del_event_callback(struct net_mgmt_event_callback *cb); * is not defined. */ #if defined(CONFIG_NET_MGMT_EVENT) -void net_mgmt_event_notify_with_info(uint32_t mgmt_event, struct net_if *iface, +void net_mgmt_event_notify_with_info(uint64_t mgmt_event, struct net_if *iface, const void *info, size_t length); #else #define net_mgmt_event_notify_with_info(...) @@ -326,7 +319,7 @@ void net_mgmt_event_notify_with_info(uint32_t mgmt_event, struct net_if *iface, * based on an iface. NULL otherwise. */ #if defined(CONFIG_NET_MGMT_EVENT) -static inline void net_mgmt_event_notify(uint32_t mgmt_event, +static inline void net_mgmt_event_notify(uint64_t mgmt_event, struct net_if *iface) { net_mgmt_event_notify_with_info(mgmt_event, iface, NULL, 0); @@ -356,15 +349,15 @@ static inline void net_mgmt_event_notify(uint32_t mgmt_event, * actual event. */ #ifdef CONFIG_NET_MGMT_EVENT -int net_mgmt_event_wait(uint32_t mgmt_event_mask, - uint32_t *raised_event, +int net_mgmt_event_wait(uint64_t mgmt_event_mask, + uint64_t *raised_event, struct net_if **iface, const void **info, size_t *info_length, k_timeout_t timeout); #else -static inline int net_mgmt_event_wait(uint32_t mgmt_event_mask, - uint32_t *raised_event, +static inline int net_mgmt_event_wait(uint64_t mgmt_event_mask, + uint64_t *raised_event, struct net_if **iface, const void **info, size_t *info_length, @@ -401,15 +394,15 @@ static inline int net_mgmt_event_wait(uint32_t mgmt_event_mask, */ #ifdef CONFIG_NET_MGMT_EVENT int net_mgmt_event_wait_on_iface(struct net_if *iface, - uint32_t mgmt_event_mask, - uint32_t *raised_event, + uint64_t mgmt_event_mask, + uint64_t *raised_event, const void **info, size_t *info_length, k_timeout_t timeout); #else static inline int net_mgmt_event_wait_on_iface(struct net_if *iface, - uint32_t mgmt_event_mask, - uint32_t *raised_event, + uint64_t mgmt_event_mask, + uint64_t *raised_event, const void **info, size_t *info_length, k_timeout_t timeout) diff --git a/include/zephyr/net/ppp.h b/include/zephyr/net/ppp.h index 7028e4f2d0f..82e02648380 100644 --- a/include/zephyr/net/ppp.h +++ b/include/zephyr/net/ppp.h @@ -574,11 +574,23 @@ void net_ppp_init(struct net_if *iface); NET_MGMT_LAYER_CODE(NET_PPP_CODE)) #define NET_PPP_EVENT (NET_PPP_BASE | NET_MGMT_EVENT_BIT) +enum { + NET_EVENT_PPP_CMD_CARRIER_ON_VAL, + NET_EVENT_PPP_CMD_CARRIER_OFF_VAL, + NET_EVENT_PPP_CMD_PHASE_RUNNING_VAL, + NET_EVENT_PPP_CMD_PHASE_DEAD_VAL, + + NET_EVENT_PPP_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_PPP_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_ppp_cmd exceeds the limit"); + enum net_event_ppp_cmd { - NET_EVENT_PPP_CMD_CARRIER_ON = 1, - NET_EVENT_PPP_CMD_CARRIER_OFF, - NET_EVENT_PPP_CMD_PHASE_RUNNING, - NET_EVENT_PPP_CMD_PHASE_DEAD, + NET_MGMT_CMD(NET_EVENT_PPP_CMD_CARRIER_ON), + NET_MGMT_CMD(NET_EVENT_PPP_CMD_CARRIER_OFF), + NET_MGMT_CMD(NET_EVENT_PPP_CMD_PHASE_RUNNING), + NET_MGMT_CMD(NET_EVENT_PPP_CMD_PHASE_DEAD), }; struct net_if; diff --git a/include/zephyr/net/socket_net_mgmt.h b/include/zephyr/net/socket_net_mgmt.h index 8f3c5829ad3..595a92bbad9 100644 --- a/include/zephyr/net/socket_net_mgmt.h +++ b/include/zephyr/net/socket_net_mgmt.h @@ -42,6 +42,19 @@ extern "C" { /** @endcond */ +/** + * @name Socket options for NET_MGMT sockets + * @{ + */ + +/** Set Ethernet Qav parameters */ +#define SO_NET_MGMT_ETHERNET_SET_QAV_PARAM 1 + +/** Get Ethernet Qav parameters */ +#define SO_NET_MGMT_ETHERNET_GET_QAV_PARAM 2 + +/** @} */ /* for @name */ + /** * struct sockaddr_nm - The sockaddr structure for NET_MGMT sockets * @@ -73,7 +86,7 @@ struct sockaddr_nm { uintptr_t nm_pid; /** net_mgmt mask */ - uint32_t nm_mask; + uint64_t nm_mask; }; diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 00c83a986ea..4232a88d955 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -324,44 +324,73 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_NEIGHBOR_REP_COMPLETE); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD); +/** @cond INTERNAL_HIDDEN */ + +enum { + NET_EVENT_WIFI_CMD_SCAN_RESULT_VAL, + NET_EVENT_WIFI_CMD_SCAN_DONE_VAL, + NET_EVENT_WIFI_CMD_CONNECT_RESULT_VAL, + NET_EVENT_WIFI_CMD_DISCONNECT_RESULT_VAL, + NET_EVENT_WIFI_CMD_IFACE_STATUS_VAL, + NET_EVENT_WIFI_CMD_TWT_VAL, + NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE_VAL, + NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT_VAL, + NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE_VAL, + NET_EVENT_WIFI_CMD_SIGNAL_CHANGE_VAL, + NET_EVENT_WIFI_CMD_NEIGHBOR_REP_RECEIVED_VAL, + NET_EVENT_WIFI_CMD_NEIGHBOR_REP_COMPLETE_VAL, + NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT_VAL, + NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT_VAL, + NET_EVENT_WIFI_CMD_AP_STA_CONNECTED_VAL, + NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED_VAL, + NET_EVENT_WIFI_CMD_SUPPLICANT_VAL, + + NET_EVENT_WIFI_CMD_MAX, +}; + +BUILD_ASSERT(NET_EVENT_WIFI_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_wifi_cmd exceeds the limit"); + +/** @endcond */ + /** @brief Wi-Fi management events */ enum net_event_wifi_cmd { /** Scan results available */ - NET_EVENT_WIFI_CMD_SCAN_RESULT = 1, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SCAN_RESULT), /** Scan done */ - NET_EVENT_WIFI_CMD_SCAN_DONE, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SCAN_DONE), /** Connect result */ - NET_EVENT_WIFI_CMD_CONNECT_RESULT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_CONNECT_RESULT), /** Disconnect result */ - NET_EVENT_WIFI_CMD_DISCONNECT_RESULT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_DISCONNECT_RESULT), /** Interface status */ - NET_EVENT_WIFI_CMD_IFACE_STATUS, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_IFACE_STATUS), /** TWT events */ - NET_EVENT_WIFI_CMD_TWT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_TWT), /** TWT sleep status: awake or sleeping, can be used by application * to determine if it can send data or not. */ - NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE), /** Raw scan results available */ - NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT), /** Disconnect complete */ - NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE), /** Signal change event */ - NET_EVENT_WIFI_CMD_SIGNAL_CHANGE, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SIGNAL_CHANGE), /** Neighbor Report */ - NET_EVENT_WIFI_CMD_NEIGHBOR_REP_RECEIVED, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_NEIGHBOR_REP_RECEIVED), /** Neighbor Report complete */ - NET_EVENT_WIFI_CMD_NEIGHBOR_REP_COMPLETE, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_NEIGHBOR_REP_COMPLETE), /** AP mode enable result */ - NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT), /** AP mode disable result */ - NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT), /** STA connected to AP */ - NET_EVENT_WIFI_CMD_AP_STA_CONNECTED, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_STA_CONNECTED), /** STA disconnected from AP */ - NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED), /** Supplicant specific event */ - NET_EVENT_WIFI_CMD_SUPPLICANT, + NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SUPPLICANT), }; /** Event emitted for Wi-Fi scan result */ diff --git a/modules/Kconfig.mcuboot b/modules/Kconfig.mcuboot index 694f4069b90..a95dc34b72f 100644 --- a/modules/Kconfig.mcuboot +++ b/modules/Kconfig.mcuboot @@ -293,6 +293,13 @@ config MCUBOOT_BOOTLOADER_USES_SHA512 help MCUboot has been compiled to verify images using SHA512. +config MCUBOOT_BOOTLOADER_SIGNATURE_TYPE_PURE + bool "Signature is verified over an image rather than sha of an image" + help + MCUboot has been compiled to verify images using pure signature + verification, i.e., the signature is verified over the image rather + than the SHA of the image. + config MCUBOOT_APPLICATION_FIRMWARE_UPDATER bool "Application is firmware updater image" depends on MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER diff --git a/modules/hostap/src/supp_events.h b/modules/hostap/src/supp_events.h index 09c30e7a37f..1c74af52849 100644 --- a/modules/hostap/src/supp_events.h +++ b/modules/hostap/src/supp_events.h @@ -17,14 +17,27 @@ NET_MGMT_IFACE_BIT) #define NET_MGMT_SUPPLICANT_EVENT (NET_MGMT_EVENT_BIT | NET_MGMT_SUPPLICANT_BASE) +enum { + NET_EVENT_SUPPLICANT_CMD_READY_VAL, + NET_EVENT_SUPPLICANT_CMD_NOT_READY_VAL, + NET_EVENT_SUPPLICANT_CMD_IFACE_ADDED_VAL, + NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVING_VAL, + NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVED_VAL, + NET_EVENT_SUPPLICANT_CMD_INT_EVENT_VAL, + + NET_EVENT_SUPPLICANT_CMD_MAX +}; + +BUILD_ASSERT(NET_EVENT_SUPPLICANT_CMD_MAX <= NET_MGMT_MAX_COMMANDS, + "Number of events in net_event_supplicant_cmd exceeds the limit"); + enum net_event_supplicant_cmd { - NET_EVENT_SUPPLICANT_CMD_READY = 1, - NET_EVENT_SUPPLICANT_CMD_NOT_READY, - NET_EVENT_SUPPLICANT_CMD_IFACE_ADDED, - NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVING, - NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVED, - NET_EVENT_SUPPLICANT_CMD_INT_EVENT, - NET_EVENT_WIFI_CMD_MAX + NET_MGMT_CMD(NET_EVENT_SUPPLICANT_CMD_READY), + NET_MGMT_CMD(NET_EVENT_SUPPLICANT_CMD_NOT_READY), + NET_MGMT_CMD(NET_EVENT_SUPPLICANT_CMD_IFACE_ADDED), + NET_MGMT_CMD(NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVING), + NET_MGMT_CMD(NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVED), + NET_MGMT_CMD(NET_EVENT_SUPPLICANT_CMD_INT_EVENT), }; #define NET_EVENT_SUPPLICANT_READY \ diff --git a/modules/hostap/src/supp_main.c b/modules/hostap/src/supp_main.c index 849ba834ec1..9336cb2bf74 100644 --- a/modules/hostap/src/supp_main.c +++ b/modules/hostap/src/supp_main.c @@ -485,14 +485,14 @@ static void submit_iface_work(struct supplicant_context *ctx, } #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_INF_MON static void interface_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & INTERFACE_EVENT_MASK) != mgmt_event) { return; } if (!is_wanted_interface(iface)) { - LOG_DBG("Ignoring event (0x%02x) from interface %d (%p)", + LOG_DBG("Ignoring event (0x%" PRIx64 ") from interface %d (%p)", mgmt_event, net_if_get_by_iface(iface), iface); return; } diff --git a/samples/bluetooth/beacon/sample.yaml b/samples/bluetooth/beacon/sample.yaml index 819ac3d3002..00215341924 100644 --- a/samples/bluetooth/beacon/sample.yaml +++ b/samples/bluetooth/beacon/sample.yaml @@ -10,6 +10,7 @@ tests: - nrf52dk/nrf52832 - nrf54l15dk/nrf54l15/cpuapp - ophelia4ev/nrf54l15/cpuapp + - nrf54lm20dk/nrf54lm20a/cpuapp tags: bluetooth integration_platforms: - qemu_cortex_m3 @@ -17,6 +18,7 @@ tests: - nrf52dk/nrf52832 - nrf54l15dk/nrf54l15/cpuapp - ophelia4ev/nrf54l15/cpuapp + - nrf54lm20dk/nrf54lm20a/cpuapp sample.bluetooth.beacon-coex: extra_args: - CONF_FILE="prj-coex.conf" diff --git a/samples/bluetooth/hci_uart/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay b/samples/bluetooth/hci_uart/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay new file mode 100644 index 00000000000..0388a57baec --- /dev/null +++ b/samples/bluetooth/hci_uart/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&uart20 { + compatible = "nordic,nrf-uarte"; + current-speed = <1000000>; + status = "okay"; + hw-flow-control; +}; diff --git a/samples/bluetooth/hci_uart/sample.yaml b/samples/bluetooth/hci_uart/sample.yaml index 97ad6c561b2..4dc5c6e9036 100644 --- a/samples/bluetooth/hci_uart/sample.yaml +++ b/samples/bluetooth/hci_uart/sample.yaml @@ -8,10 +8,14 @@ tests: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 - nrf21540dk/nrf52840 + - nrf54l15dk/nrf54l15/cpuapp + - nrf54lm20dk/nrf54lm20a/cpuapp integration_platforms: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 - nrf21540dk/nrf52840 + - nrf54l15dk/nrf54l15/cpuapp + - nrf54lm20dk/nrf54lm20a/cpuapp tags: - uart - bluetooth diff --git a/samples/bluetooth/mesh_provisioner/prj.conf b/samples/bluetooth/mesh_provisioner/prj.conf index 24176780516..0e5f6490ede 100644 --- a/samples/bluetooth/mesh_provisioner/prj.conf +++ b/samples/bluetooth/mesh_provisioner/prj.conf @@ -1,6 +1,10 @@ #CONFIG_INIT_STACKS=y -CONFIG_MAIN_STACK_SIZE=2048 -CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 +# Stack sizes from thread analysis + 50% margin, rounded to nearest 100 +CONFIG_MAIN_STACK_SIZE=4400 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4800 +CONFIG_BT_MESH_SETTINGS_WORKQ_STACK_SIZE=1700 +CONFIG_BT_MESH_ADV_STACK_SIZE=4000 +CONFIG_BT_RX_STACK_SIZE=3300 # The Bluetooth API should not be used from a preemptive thread: CONFIG_MAIN_THREAD_PRIORITY=-2 diff --git a/samples/bluetooth/peripheral_hr/sample.yaml b/samples/bluetooth/peripheral_hr/sample.yaml index 8b0722d169f..22bc7667461 100644 --- a/samples/bluetooth/peripheral_hr/sample.yaml +++ b/samples/bluetooth/peripheral_hr/sample.yaml @@ -15,6 +15,7 @@ tests: - nrf5340dk/nrf5340/cpuapp - nrf54l15dk/nrf54l15/cpuapp - ophelia4ev/nrf54l15/cpuapp + - nrf54lm20dk/nrf54lm20a/cpuapp integration_platforms: - qemu_cortex_m3 - nrf52_bsim @@ -25,6 +26,7 @@ tests: - nrf5340dk/nrf5340/cpuapp - nrf54l15dk/nrf54l15/cpuapp - ophelia4ev/nrf54l15/cpuapp + - nrf54lm20dk/nrf54lm20a/cpuapp tags: bluetooth sample.bluetooth.peripheral_hr.minimal: harness: bluetooth diff --git a/samples/boards/nordic/system_off/src/main.c b/samples/boards/nordic/system_off/src/main.c index d119eff87da..b4c2eeb2b1b 100644 --- a/samples/boards/nordic/system_off/src/main.c +++ b/samples/boards/nordic/system_off/src/main.c @@ -31,8 +31,17 @@ static const struct gpio_dt_spec sw0 = GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios); static const struct device *comp_dev = DEVICE_DT_GET(DT_NODELABEL(comp)); #endif -void print_reset_cause(uint32_t reset_cause) +int print_reset_cause(uint32_t reset_cause) { + int32_t ret; + uint32_t supported; + + ret = hwinfo_get_supported_reset_cause((uint32_t *) &supported); + + if (ret || !(reset_cause & supported)) { + return -ENOTSUP; + } + if (reset_cause & RESET_DEBUG) { printf("Reset by debugger.\n"); } else if (reset_cause & RESET_CLOCK) { @@ -42,6 +51,8 @@ void print_reset_cause(uint32_t reset_cause) } else { printf("Other wake up cause 0x%08X.\n", reset_cause); } + + return 0; } int main(void) @@ -57,7 +68,12 @@ int main(void) printf("\n%s system off demo\n", CONFIG_BOARD); hwinfo_get_reset_cause(&reset_cause); - print_reset_cause(reset_cause); + rc = print_reset_cause(reset_cause); + + if (rc < 0) { + printf("Reset cause not supported.\n"); + return 0; + } if (IS_ENABLED(CONFIG_APP_USE_RETAINED_MEM)) { bool retained_ok = retained_validate(); diff --git a/samples/boards/nxp/s32/netc/src/main.c b/samples/boards/nxp/s32/netc/src/main.c index 8399a7dd9b5..09e6cea9883 100644 --- a/samples/boards/nxp/s32/netc/src/main.c +++ b/samples/boards/nxp/s32/netc/src/main.c @@ -69,7 +69,7 @@ static int setup_iface(struct net_if *iface, const char *ipv6_addr, } static void iface_up_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IF_UP) { k_sem_give(&iface_up); diff --git a/samples/net/capture/src/main.c b/samples/net/capture/src/main.c index 3feafc4eb25..1b68ee30afa 100644 --- a/samples/net/capture/src/main.c +++ b/samples/net/capture/src/main.c @@ -285,7 +285,7 @@ static int init_app(void) #define EVENT_MASK (NET_EVENT_CAPTURE_STARTED | NET_EVENT_CAPTURE_STOPPED) static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(iface); ARG_UNUSED(cb); @@ -307,7 +307,7 @@ int main(void) { static struct net_mgmt_event_callback mgmt_cb; struct net_if *iface; - uint32_t event; + uint64_t event; int ret; LOG_INF("Starting network capture sample"); diff --git a/samples/net/cloud/mqtt_azure/src/main.c b/samples/net/cloud/mqtt_azure/src/main.c index 841c1fb7ebe..538461af2d1 100644 --- a/samples/net/cloud/mqtt_azure/src/main.c +++ b/samples/net/cloud/mqtt_azure/src/main.c @@ -487,7 +487,7 @@ static void abort_mqtt_connection(void) } static void l4_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & L4_EVENT_MASK) != mgmt_event) { return; diff --git a/samples/net/cloud/tagoio_http_post/src/wifi.c b/samples/net/cloud/tagoio_http_post/src/wifi.c index f9eb52b7a59..a0cd121d62b 100644 --- a/samples/net/cloud/tagoio_http_post/src/wifi.c +++ b/samples/net/cloud/tagoio_http_post/src/wifi.c @@ -26,7 +26,7 @@ static void handle_wifi_connect_result(struct net_mgmt_event_callback *cb) } static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { case NET_EVENT_WIFI_CONNECT_RESULT: diff --git a/samples/net/common/net_sample_common.c b/samples/net/common/net_sample_common.c index e1b91c91122..0b570a64feb 100644 --- a/samples/net/common/net_sample_common.c +++ b/samples/net/common/net_sample_common.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(net_samples_common, LOG_LEVEL_DBG); static struct net_mgmt_event_callback l4_cb; static K_SEM_DEFINE(network_connected, 0, 1); -static void l4_event_handler(struct net_mgmt_event_callback *cb, uint32_t event, +static void l4_event_handler(struct net_mgmt_event_callback *cb, uint64_t event, struct net_if *iface) { switch (event) { diff --git a/samples/net/dhcpv4_client/src/main.c b/samples/net/dhcpv4_client/src/main.c index 00d48949d73..72f7a17f273 100644 --- a/samples/net/dhcpv4_client/src/main.c +++ b/samples/net/dhcpv4_client/src/main.c @@ -38,7 +38,7 @@ static void start_dhcpv4_client(struct net_if *iface, void *user_data) } static void handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { int i = 0; diff --git a/samples/net/dns_resolve/src/main.c b/samples/net/dns_resolve/src/main.c index 23e5645d0b4..5302f569874 100644 --- a/samples/net/dns_resolve/src/main.c +++ b/samples/net/dns_resolve/src/main.c @@ -198,7 +198,7 @@ static void print_dhcpv4_addr(struct net_if *iface, struct net_if_addr *if_addr, } static void ipv4_addr_add_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { diff --git a/samples/net/dsa/src/main.c b/samples/net/dsa/src/main.c index 16d41af5999..a84b2cef7a9 100644 --- a/samples/net/dsa/src/main.c +++ b/samples/net/dsa/src/main.c @@ -54,7 +54,7 @@ static void dsa_iface_find_cb(struct net_if *iface, void *user_data) static struct net_mgmt_event_callback mgmt_cb; static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(iface); ARG_UNUSED(cb); diff --git a/samples/net/ipv4_autoconf/src/main.c b/samples/net/ipv4_autoconf/src/main.c index c4e93105cf7..9dd9fa53bb7 100644 --- a/samples/net/ipv4_autoconf/src/main.c +++ b/samples/net/ipv4_autoconf/src/main.c @@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(net_ipv4_autoconf_sample, LOG_LEVEL_DBG); static struct net_mgmt_event_callback mgmt_cb; static void handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { int i = 0; diff --git a/samples/net/lwm2m_client/src/lwm2m-client.c b/samples/net/lwm2m_client/src/lwm2m-client.c index 9127769ff6b..7c15f84502c 100644 --- a/samples/net/lwm2m_client/src/lwm2m-client.c +++ b/samples/net/lwm2m_client/src/lwm2m-client.c @@ -334,7 +334,7 @@ static void on_net_event_l4_connected(void) } static void l4_event_handler(struct net_mgmt_event_callback *cb, - uint32_t event, + uint64_t event, struct net_if *iface) { switch (event) { @@ -356,7 +356,7 @@ static void l4_event_handler(struct net_mgmt_event_callback *cb, } static void connectivity_event_handler(struct net_mgmt_event_callback *cb, - uint32_t event, + uint64_t event, struct net_if *iface) { if (event == NET_EVENT_CONN_IF_FATAL_ERROR) { diff --git a/samples/net/mqtt_sn_publisher/src/main.c b/samples/net/mqtt_sn_publisher/src/main.c index 65436daea4d..fddeb4c976f 100644 --- a/samples/net/mqtt_sn_publisher/src/main.c +++ b/samples/net/mqtt_sn_publisher/src/main.c @@ -30,7 +30,7 @@ K_SEM_DEFINE(run_app, 0, 1); #define EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED) -static void net_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void net_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & EVENT_MASK) != mgmt_event) { diff --git a/samples/net/secure_mqtt_sensor_actuator/src/main.c b/samples/net/secure_mqtt_sensor_actuator/src/main.c index 64993139e90..9b6872a69cf 100644 --- a/samples/net/secure_mqtt_sensor_actuator/src/main.c +++ b/samples/net/secure_mqtt_sensor_actuator/src/main.c @@ -30,7 +30,7 @@ static struct net_mgmt_event_callback net_l4_mgmt_cb; K_SEM_DEFINE(net_conn_sem, 0, 1); static void net_l4_evt_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { case NET_EVENT_L4_CONNECTED: diff --git a/samples/net/sockets/coap_download/src/main.c b/samples/net/sockets/coap_download/src/main.c index bb15551cfba..2e1ee6c59d3 100644 --- a/samples/net/sockets/coap_download/src/main.c +++ b/samples/net/sockets/coap_download/src/main.c @@ -21,7 +21,7 @@ static int64_t start_time; /* This struct contains (potentially large) TX and RX buffers, so allocate statically */ static struct coap_client client = {0}; -static void net_event_handler(uint32_t mgmt_event, struct net_if *iface, void *info, +static void net_event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { if (NET_EVENT_L4_CONNECTED == mgmt_event) { diff --git a/samples/net/sockets/coap_server/src/events.c b/samples/net/sockets/coap_server/src/events.c index 3f843fba017..8c621214a7d 100644 --- a/samples/net/sockets/coap_server/src/events.c +++ b/samples/net/sockets/coap_server/src/events.c @@ -13,7 +13,7 @@ LOG_MODULE_DECLARE(net_coap_service_sample); #define COAP_EVENTS_SET (NET_EVENT_COAP_OBSERVER_ADDED | NET_EVENT_COAP_OBSERVER_REMOVED | \ NET_EVENT_COAP_SERVICE_STARTED | NET_EVENT_COAP_SERVICE_STOPPED) -void coap_event_handler(uint32_t mgmt_event, struct net_if *iface, +void coap_event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { ARG_UNUSED(iface); diff --git a/samples/net/sockets/dumb_http_server_mt/src/main.c b/samples/net/sockets/dumb_http_server_mt/src/main.c index ed19fa96833..4c8a1021923 100644 --- a/samples/net/sockets/dumb_http_server_mt/src/main.c +++ b/samples/net/sockets/dumb_http_server_mt/src/main.c @@ -98,7 +98,7 @@ K_THREAD_DEFINE(tcp6_thread_id, STACK_SIZE, NET_EVENT_L4_DISCONNECTED) static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & EVENT_MASK) != mgmt_event) { return; diff --git a/samples/net/sockets/echo_client/src/echo-client.c b/samples/net/sockets/echo_client/src/echo-client.c index 3ca9ddc8aa0..9c451b9c3cc 100644 --- a/samples/net/sockets/echo_client/src/echo-client.c +++ b/samples/net/sockets/echo_client/src/echo-client.c @@ -229,7 +229,7 @@ static int check_our_ipv6_sockets(int sock, } static void ipv6_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { static char addr_str[INET6_ADDRSTRLEN]; @@ -297,7 +297,7 @@ static void ipv6_event_handler(struct net_mgmt_event_callback *cb, } static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & EVENT_MASK) != mgmt_event) { return; diff --git a/samples/net/sockets/echo_server/src/echo-server.c b/samples/net/sockets/echo_server/src/echo-server.c index fd6bd4f6acf..c4dc98b4004 100644 --- a/samples/net/sockets/echo_server/src/echo-server.c +++ b/samples/net/sockets/echo_server/src/echo-server.c @@ -82,7 +82,7 @@ static void stop_udp_and_tcp(void) } static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(iface); ARG_UNUSED(cb); diff --git a/samples/net/sockets/packet/src/packet.c b/samples/net/sockets/packet/src/packet.c index 3b3af25c7ab..e4354254b3e 100644 --- a/samples/net/sockets/packet/src/packet.c +++ b/samples/net/sockets/packet/src/packet.c @@ -229,7 +229,7 @@ static void send_packet(void) } static void iface_up_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IF_UP) { k_sem_give(&iface_up); diff --git a/samples/net/sockets/txtime/src/main.c b/samples/net/sockets/txtime/src/main.c index d4bc85a3f2a..870e10f8ff7 100644 --- a/samples/net/sockets/txtime/src/main.c +++ b/samples/net/sockets/txtime/src/main.c @@ -71,7 +71,7 @@ static void quit(void) } static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { static bool dhcpv4_done; diff --git a/samples/net/wifi/apsta_mode/src/main.c b/samples/net/wifi/apsta_mode/src/main.c index eb90b1c2104..aa0d0cb28cb 100644 --- a/samples/net/wifi/apsta_mode/src/main.c +++ b/samples/net/wifi/apsta_mode/src/main.c @@ -36,7 +36,7 @@ static struct wifi_connect_req_params sta_config; static struct net_mgmt_event_callback cb; -static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { diff --git a/samples/subsys/mgmt/updatehub/src/main.c b/samples/subsys/mgmt/updatehub/src/main.c index 73d64a1a694..9f9af6ae003 100644 --- a/samples/subsys/mgmt/updatehub/src/main.c +++ b/samples/subsys/mgmt/updatehub/src/main.c @@ -63,7 +63,7 @@ void start_updatehub(void) } static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & EVENT_MASK) != mgmt_event) { return; diff --git a/soc/nordic/common/uicr/gen_uicr.py b/soc/nordic/common/uicr/gen_uicr.py index 50f96eab566..5888786e928 100644 --- a/soc/nordic/common/uicr/gen_uicr.py +++ b/soc/nordic/common/uicr/gen_uicr.py @@ -17,6 +17,10 @@ from elftools.elf.elffile import ELFFile from intelhex import IntelHex +# The UICR format version produced by this script +UICR_FORMAT_VERSION_MAJOR = 2 +UICR_FORMAT_VERSION_MINOR = 0 + # Name of the ELF section containing PERIPHCONF entries. # Must match the name used in the linker script. PERIPHCONF_SECTION = "uicr_periphconf_entry" @@ -45,6 +49,14 @@ class PeriphconfEntry(c.LittleEndianStructure): PERIPHCONF_ENTRY_SIZE = c.sizeof(PeriphconfEntry) +class Version(c.LittleEndianStructure): + _pack_ = 1 + _fields_ = [ + ("MINOR", c.c_uint16), + ("MAJOR", c.c_uint16), + ] + + class Approtect(c.LittleEndianStructure): _pack_ = 1 _fields_ = [ @@ -104,7 +116,7 @@ class Mpcconf(c.LittleEndianStructure): class Uicr(c.LittleEndianStructure): _pack_ = 1 _fields_ = [ - ("VERSION", c.c_uint32), + ("VERSION", Version), ("RESERVED", c.c_uint32), ("LOCK", c.c_uint32), ("RESERVED1", c.c_uint32), @@ -171,6 +183,9 @@ def main() -> None: init_values = DISABLED_VALUE.to_bytes(4, "little") * (c.sizeof(Uicr) // 4) uicr = Uicr.from_buffer_copy(init_values) + uicr.VERSION.MAJOR = UICR_FORMAT_VERSION_MAJOR + uicr.VERSION.MINOR = UICR_FORMAT_VERSION_MINOR + kconfig_str = args.in_config.read() kconfig = parse_kconfig(kconfig_str) diff --git a/soc/nordic/nrf54h/bicr/bicr-schema.json b/soc/nordic/nrf54h/bicr/bicr-schema.json index b43b7236a6b..a43107a12b6 100644 --- a/soc/nordic/nrf54h/bicr/bicr-schema.json +++ b/soc/nordic/nrf54h/bicr/bicr-schema.json @@ -11,8 +11,8 @@ "title": "Power supply scheme", "enumNames": [ "Unconfigured (system will not boot)", - "VDDH supplied with 2.1-5.5 V and VDD regulated by the chip (inductor present)", - "Both VDD and VDDH supplied with 1.8 V (inductor present)" + "Both VDD and VDDH supplied with 1.8 V (inductor present)", + "VDDH supplied with 2.1-5.5 V and VDD regulated by the chip (inductor present)" ], "enum": [ "UNCONFIGURED", @@ -193,7 +193,7 @@ ], "enum": [ "CRYSTAL", - "ETX_SINE", + "EXT_SINE", "EXT_SQUARE" ], "default": "CRYSTAL" diff --git a/soc/nordic/validate_base_addresses.c b/soc/nordic/validate_base_addresses.c index f3c9c8bf214..7426364417f 100644 --- a/soc/nordic/validate_base_addresses.c +++ b/soc/nordic/validate_base_addresses.c @@ -73,13 +73,19 @@ #define NRF_WDT0 NRF_WDT #endif +#if !defined(NRF_POWER_GPREGRET1) && defined(NRF_POWER) #if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_SERIES_NRF52X) -#if !defined(NRF_POWER_GPREGRET1) && defined(NRF_POWER_BASE) -#define NRF_POWER_GPREGRET1 (0x51c + NRF_POWER_BASE) +#define NRF_POWER_GPREGRET1 (&NRF_POWER->GPREGRET) +#else +#define NRF_POWER_GPREGRET1 (&NRF_POWER->GPREGRET[0]) +#endif #endif -#if !defined(NRF_POWER_GPREGRET2) && defined(NRF_POWER_BASE) -#define NRF_POWER_GPREGRET2 (0x520 + NRF_POWER_BASE) +#if !defined(NRF_POWER_GPREGRET2) && defined(NRF_POWER) +#if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_SERIES_NRF52X) +#define NRF_POWER_GPREGRET2 (&NRF_POWER->GPREGRET2) +#else +#define NRF_POWER_GPREGRET2 (&NRF_POWER->GPREGRET[1]) #endif #endif @@ -367,9 +373,5 @@ CHECK_DT_REG(cpurad_wdt010, NRF_RADIOCORE_WDT010); CHECK_DT_REG(cpurad_wdt011, NRF_RADIOCORE_WDT011); CHECK_DT_REG(wdt131, NRF_WDT131); CHECK_DT_REG(wdt132, NRF_WDT132); - -/* nRF51/nRF52-specific addresses */ -#if defined(CONFIG_SOC_SERIES_NRF51X) || defined(CONFIG_SOC_SERIES_NRF52X) CHECK_DT_REG(gpregret1, NRF_POWER_GPREGRET1); CHECK_DT_REG(gpregret2, NRF_POWER_GPREGRET2); -#endif diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index 3830745417a..da1928758fd 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -633,7 +633,7 @@ config BT_ID_UNPAIR_MATCHING_BONDS config BT_ID_AUTO_SWAP_MATCHING_BONDS bool "Automatically swap conflicting entries in the Resolving List" depends on !BT_ID_UNPAIR_MATCHING_BONDS - depends on BT_PRIVACY && BT_PERIPHERAL && !BT_CENTRAL + depends on BT_SMP && BT_PERIPHERAL && !BT_CENTRAL help If this option is enabled, the Host will not add a new bond with the same peer address (or IRK) to the Resolving List if there is diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 3092801554a..be642fec9fe 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -1917,6 +1917,10 @@ ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) { + if ((attr == NULL) || (attr->user_data == NULL)) { + return -EINVAL; + } + struct bt_gatt_attr *incl = attr->user_data; uint16_t handle = bt_gatt_attr_get_handle(incl); struct bt_uuid *uuid = incl->user_data; diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 9fa5638d961..caf5424717b 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -46,6 +46,7 @@ LOG_MODULE_REGISTER(bt_l2cap, CONFIG_BT_L2CAP_LOG_LEVEL); #define CHAN_RX(_w) CONTAINER_OF(_w, struct bt_l2cap_le_chan, rx_work) #define L2CAP_LE_MIN_MTU 23 +#define L2CAP_LE_MIN_MPS 23 #define L2CAP_LE_MAX_CREDITS (BT_BUF_ACL_RX_COUNT - 1) @@ -1478,11 +1479,6 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident, LOG_DBG("psm 0x%02x scid 0x%04x mtu %u mps %u credits %u", psm, scid, mtu, mps, credits); - if (mtu < L2CAP_LE_MIN_MTU || mps < L2CAP_LE_MIN_MTU) { - LOG_ERR("Invalid LE-Conn Req params: mtu %u mps %u", mtu, mps); - return; - } - buf = l2cap_create_le_sig_pdu(BT_L2CAP_LE_CONN_RSP, ident, sizeof(*rsp)); if (!buf) { @@ -1492,6 +1488,16 @@ static void le_conn_req(struct bt_l2cap *l2cap, uint8_t ident, rsp = net_buf_add(buf, sizeof(*rsp)); (void)memset(rsp, 0, sizeof(*rsp)); + /* Validate parameters. Requirements are from Core Spec v6.0, Vol 3.A.4.22. Valid credit + * range is from 0 to UINT16_MAX, thus no credit validation is needed. + */ + if (!IN_RANGE(mtu, L2CAP_LE_MIN_MTU, BT_L2CAP_MAX_MTU) || + !IN_RANGE(mps, L2CAP_LE_MIN_MPS, BT_L2CAP_MAX_MPS)) { + LOG_ERR("Invalid le conn req params: mtu %u mps %u", mtu, mps); + result = BT_L2CAP_LE_ERR_UNACCEPT_PARAMS; + goto rsp; + } + /* Check if there is a server registered */ server = bt_l2cap_server_lookup_psm(psm); if (!server) { @@ -1577,8 +1583,12 @@ static void le_ecred_conn_req(struct bt_l2cap *l2cap, uint8_t ident, LOG_DBG("psm 0x%02x mtu %u mps %u credits %u", psm, mtu, mps, credits); - if (mtu < BT_L2CAP_ECRED_MIN_MTU || mps < BT_L2CAP_ECRED_MIN_MTU) { - LOG_ERR("Invalid ecred conn req params. mtu %u mps %u", mtu, mps); + /* Validate parameters. Requirements are from Core Spec v6.0, Vol 3.A.4.25. */ + if (!IN_RANGE(mtu, BT_L2CAP_ECRED_MIN_MTU, BT_L2CAP_MAX_MTU) || + !IN_RANGE(mps, BT_L2CAP_ECRED_MIN_MPS, BT_L2CAP_MAX_MPS) || + !IN_RANGE(credits, BT_L2CAP_ECRED_CREDITS_MIN, BT_L2CAP_ECRED_CREDITS_MAX)) { + LOG_ERR("Invalid le ecred conn req params: mtu %u mps %u credits %u", mtu, mps, + credits); result = BT_L2CAP_LE_ERR_INVALID_PARAMS; goto response; } @@ -1685,7 +1695,7 @@ static void le_ecred_reconf_req(struct bt_l2cap *l2cap, uint8_t ident, mtu = sys_le16_to_cpu(req->mtu); mps = sys_le16_to_cpu(req->mps); - if (mps < BT_L2CAP_ECRED_MIN_MTU) { + if (mps < BT_L2CAP_ECRED_MIN_MPS) { result = BT_L2CAP_RECONF_OTHER_UNACCEPT; goto response; } @@ -1981,13 +1991,24 @@ static void le_ecred_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, LOG_DBG("dcid 0x%04x", dcid); - /* If a Destination CID is 0x0000, the channel was not + /* Validate parameters before assignment. Requirements are from Core Spec + * v6.0, Vol 3.A.4.26. If a Destination CID is 0x0000, the channel was not * established. */ - if (!dcid) { + if (dcid == 0U) { bt_l2cap_chan_remove(conn, &chan->chan); bt_l2cap_chan_del(&chan->chan); continue; + } else if (!L2CAP_LE_CID_IS_DYN(dcid) || + !IN_RANGE(mtu, BT_L2CAP_ECRED_MIN_MTU, BT_L2CAP_MAX_MTU) || + !IN_RANGE(mps, BT_L2CAP_ECRED_MIN_MPS, BT_L2CAP_MAX_MPS) || + !IN_RANGE(credits, BT_L2CAP_ECRED_CREDITS_MIN, + BT_L2CAP_ECRED_CREDITS_MAX)) { + LOG_WRN("Invalid ecred conn rsp params: dcid 0x%04x mtu %u mps %u " + "credits %u. Disconnecting.", + dcid, mtu, mps, credits); + bt_conn_disconnect(conn, BT_HCI_ERR_UNACCEPT_CONN_PARAM); + return; } c = bt_l2cap_le_lookup_tx_cid(conn, dcid); @@ -2085,6 +2106,20 @@ static void le_conn_rsp(struct bt_l2cap *l2cap, uint8_t ident, switch (result) { case BT_L2CAP_LE_SUCCESS: + /* Validate parameters on successful connection. Requirements are from Core Spec + * v6.0, Vol 3.A.4.23. Valid credit range is from 0 to UINT16_MAX, thus no credit + * validation is needed. + */ + if ((!L2CAP_LE_CID_IS_DYN(dcid) || + !IN_RANGE(mtu, L2CAP_LE_MIN_MTU, BT_L2CAP_MAX_MTU) || + !IN_RANGE(mps, L2CAP_LE_MIN_MPS, BT_L2CAP_MAX_MPS))) { + LOG_WRN("Invalid conn rsp params: dcid 0x%04x mtu %u mps %u. " + "Disconnecting.", + dcid, mtu, mps); + bt_conn_disconnect(conn, BT_HCI_ERR_UNACCEPT_CONN_PARAM); + return; + } + chan->tx.cid = dcid; chan->tx.mtu = mtu; chan->tx.mps = mps; @@ -2157,6 +2192,17 @@ static void le_credits(struct bt_l2cap *l2cap, uint8_t ident, cid = sys_le16_to_cpu(ev->cid); credits = sys_le16_to_cpu(ev->credits); + if (!L2CAP_LE_CID_IS_DYN(cid)) { + LOG_WRN("Can't add credits to non-dynamic channel %p (cid 0x%04x)", &l2cap->chan, + cid); + return; + } + + if (credits == 0U) { + LOG_WRN("Ignoring zero credit packet"); + return; + } + LOG_DBG("cid 0x%04x credits %u", cid, credits); chan = bt_l2cap_le_lookup_tx_cid(conn, cid); diff --git a/subsys/bluetooth/host/l2cap_internal.h b/subsys/bluetooth/host/l2cap_internal.h index 07bd428334a..61fa7416dd5 100644 --- a/subsys/bluetooth/host/l2cap_internal.h +++ b/subsys/bluetooth/host/l2cap_internal.h @@ -125,6 +125,9 @@ struct bt_l2cap_le_credits { uint16_t credits; } __packed; +#define BT_L2CAP_ECRED_CREDITS_MIN 1 +#define BT_L2CAP_ECRED_CREDITS_MAX UINT16_MAX + #define BT_L2CAP_ECRED_CONN_REQ 0x17 struct bt_l2cap_ecred_conn_req { uint16_t psm; diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index 916bb661bb9..ff920fb0f3a 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -2555,22 +2555,35 @@ static uint8_t legacy_pairing_req(struct bt_smp *smp) static uint8_t legacy_pairing_random(struct bt_smp *smp) { struct bt_conn *conn = smp->chan.chan.conn; - uint8_t tmp[16]; + uint8_t tmp[16], cfm_i[16]; int err; LOG_DBG(""); - /* calculate confirmation */ + /* calculate LP_CONFIRM_R */ err = smp_c1(smp->tk, smp->rrnd, smp->preq, smp->prsp, &conn->le.init_addr, &conn->le.resp_addr, tmp); if (err) { return BT_SMP_ERR_UNSPECIFIED; } + /* calculate LP_CONFIRM_I */ + err = smp_c1(smp->tk, smp->prnd, smp->preq, smp->prsp, + &conn->le.init_addr, &conn->le.resp_addr, cfm_i); + if (err) { + return BT_SMP_ERR_UNSPECIFIED; + } + LOG_DBG("pcnf %s", bt_hex(smp->pcnf, 16)); - LOG_DBG("cfm %s", bt_hex(tmp, 16)); + LOG_DBG("cfm (remote) %s", bt_hex(tmp, 16)); + LOG_DBG("cfm (local) %s", bt_hex(cfm_i, 16)); - if (memcmp(smp->pcnf, tmp, sizeof(smp->pcnf))) { + /* Core Specification, Vol 3, Part H, section 2.3.5.5 (Errata ES-24491): If the computed + * LP_CONFIRM_R value is not equal to the received LP_CONFIRM_R value, or the received + * LP_CONFIRM_R value is equal to the LP_CONFIRM_I value, fail pairing. + */ + if (memcmp(smp->pcnf, tmp, sizeof(smp->pcnf)) || + !memcmp(smp->pcnf, cfm_i, sizeof(smp->pcnf))) { return BT_SMP_ERR_CONFIRM_FAILED; } @@ -4486,7 +4499,7 @@ static uint8_t smp_public_key(struct bt_smp *smp, struct net_buf *buf) } } else if (!bt_pub_key_is_valid(smp->pkey)) { LOG_WRN("Received invalid public key"); - return BT_SMP_ERR_INVALID_PARAMS; + return BT_SMP_ERR_DHKEY_CHECK_FAILED; } if (IS_ENABLED(CONFIG_BT_CENTRAL) && diff --git a/subsys/bluetooth/mesh/blob_srv.c b/subsys/bluetooth/mesh/blob_srv.c index 2d4ec561f83..c022352b040 100644 --- a/subsys/bluetooth/mesh/blob_srv.c +++ b/subsys/bluetooth/mesh/blob_srv.c @@ -151,8 +151,12 @@ static int pull_req_max(const struct bt_mesh_blob_srv *srv) BLOB_CHUNK_SDU_LEN(srv->state.xfer.chunk_size), BT_MESH_APP_SEG_SDU_MAX); - count = MIN(CONFIG_BT_MESH_BLOB_SRV_PULL_REQ_COUNT, - bt_mesh.lpn.queue_size / segments_per_chunk); + /* It is possible that the friend node cannot hold all segments per chunk. In this + * case, we should request at least 1 chunk. As requesting `0` would be invalid. + */ + count = MAX(1, MIN(CONFIG_BT_MESH_BLOB_SRV_PULL_REQ_COUNT, + bt_mesh.lpn.queue_size / segments_per_chunk)); + } #endif @@ -821,7 +825,27 @@ static int handle_info_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_c net_buf_simple_add_u8(&rsp, BLOB_BLOCK_SIZE_LOG_MIN); net_buf_simple_add_u8(&rsp, BLOB_BLOCK_SIZE_LOG_MAX); net_buf_simple_add_le16(&rsp, CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX); + +#if defined(CONFIG_BT_MESH_LOW_POWER) + /* If friendship is established, then chunk size is according to friend's queue size. + * Chunk size = (Queue size * Segment size) - (Opcode (1) - Chunk Number (2) + * - 8 byte MIC (max)) + */ + if (bt_mesh_lpn_established() && bt_mesh.lpn.queue_size > 0) { + uint16_t chunk_size = (bt_mesh.lpn.queue_size * 12) - 11; + + chunk_size = MIN(chunk_size, BLOB_RX_CHUNK_SIZE); + net_buf_simple_add_le16(&rsp, chunk_size); + if (bt_mesh.lpn.queue_size <= 2) { + LOG_WRN("FndQ too small %u", bt_mesh.lpn.queue_size); + } + } else { + net_buf_simple_add_le16(&rsp, BLOB_RX_CHUNK_SIZE); + } +#else net_buf_simple_add_le16(&rsp, BLOB_RX_CHUNK_SIZE); +#endif + net_buf_simple_add_le32(&rsp, CONFIG_BT_MESH_BLOB_SIZE_MAX); net_buf_simple_add_le16(&rsp, MTU_SIZE_MAX); net_buf_simple_add_u8(&rsp, BT_MESH_BLOB_XFER_MODE_ALL); diff --git a/subsys/logging/backends/log_backend_net.c b/subsys/logging/backends/log_backend_net.c index 11f0612724f..b0e3ca5c425 100644 --- a/subsys/logging/backends/log_backend_net.c +++ b/subsys/logging/backends/log_backend_net.c @@ -367,7 +367,7 @@ const struct log_backend *log_backend_net_get(void) } #if defined(CONFIG_LOG_BACKEND_NET_USE_CONNECTION_MANAGER) -static void l4_event_handler(uint32_t mgmt_event, struct net_if *iface, void *info, +static void l4_event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { ARG_UNUSED(iface); diff --git a/subsys/mgmt/mcumgr/transport/src/smp_udp.c b/subsys/mgmt/mcumgr/transport/src/smp_udp.c index 8067b36d6e6..e3da22e6731 100644 --- a/subsys/mgmt/mcumgr/transport/src/smp_udp.c +++ b/subsys/mgmt/mcumgr/transport/src/smp_udp.c @@ -280,7 +280,7 @@ static void smp_udp_open_iface(struct net_if *iface, void *user_data) } } -static void smp_udp_net_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void smp_udp_net_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); diff --git a/subsys/net/conn_mgr/conn_mgr_connectivity.c b/subsys/net/conn_mgr/conn_mgr_connectivity.c index 5bf8e3f58be..905b5b07d1c 100644 --- a/subsys/net/conn_mgr/conn_mgr_connectivity.c +++ b/subsys/net/conn_mgr/conn_mgr_connectivity.c @@ -315,7 +315,7 @@ static void conn_mgr_conn_handle_iface_down(struct net_if *iface) } static struct net_mgmt_event_callback conn_mgr_conn_iface_cb; -static void conn_mgr_conn_iface_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void conn_mgr_conn_iface_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & CONN_MGR_CONN_IFACE_EVENTS_MASK) != mgmt_event) { @@ -333,7 +333,7 @@ static void conn_mgr_conn_iface_handler(struct net_mgmt_event_callback *cb, uint } static struct net_mgmt_event_callback conn_mgr_conn_self_cb; -static void conn_mgr_conn_self_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void conn_mgr_conn_self_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event & CONN_MGR_CONN_SELF_EVENTS_MASK) != mgmt_event) { diff --git a/subsys/net/conn_mgr/events_handler.c b/subsys/net/conn_mgr/events_handler.c index 8f15a8b6c62..2a0c6fefc28 100644 --- a/subsys/net/conn_mgr/events_handler.c +++ b/subsys/net/conn_mgr/events_handler.c @@ -19,12 +19,12 @@ static struct net_mgmt_event_callback ipv6_events_cb; static struct net_mgmt_event_callback ipv4_events_cb; static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { int idx; - NET_DBG("%s event 0x%x received on iface %d (%p)", "Iface", mgmt_event, + NET_DBG("%s event 0x%" PRIx64 " received on iface %d (%p)", "Iface", mgmt_event, net_if_get_by_iface(iface), iface); if ((mgmt_event & CONN_MGR_IFACE_EVENTS_MASK) != mgmt_event) { @@ -55,12 +55,12 @@ static void conn_mgr_iface_events_handler(struct net_mgmt_event_callback *cb, #if defined(CONFIG_NET_IPV6) static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { int idx; - NET_DBG("%s event 0x%x received on iface %d (%p)", "IPv6", mgmt_event, + NET_DBG("%s event 0x%" PRIx64 " received on iface %d (%p)", "IPv6", mgmt_event, net_if_get_by_iface(iface), iface); if ((mgmt_event & CONN_MGR_IPV6_EVENTS_MASK) != mgmt_event) { @@ -101,7 +101,7 @@ static void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, #else static inline void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); @@ -112,12 +112,12 @@ void conn_mgr_ipv6_events_handler(struct net_mgmt_event_callback *cb, #if defined(CONFIG_NET_IPV4) static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { int idx; - NET_DBG("%s event 0x%x received on iface %d (%p)", "IPv4", mgmt_event, + NET_DBG("%s event 0x%" PRIx64 " received on iface %d (%p)", "IPv4", mgmt_event, net_if_get_by_iface(iface), iface); if ((mgmt_event & CONN_MGR_IPV4_EVENTS_MASK) != mgmt_event) { @@ -159,7 +159,7 @@ static void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb, #else static inline void conn_mgr_ipv4_events_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); diff --git a/subsys/net/ip/ipv4_autoconf.c b/subsys/net/ip/ipv4_autoconf.c index f08608f3b7e..ad399622a99 100644 --- a/subsys/net/ip/ipv4_autoconf.c +++ b/subsys/net/ip/ipv4_autoconf.c @@ -55,7 +55,7 @@ static inline void ipv4_autoconf_addr_set(struct net_if_ipv4_autoconf *ipv4auto) } static void acd_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { struct net_if_config *cfg; struct in_addr *addr; diff --git a/subsys/net/ip/ipv6_pe.c b/subsys/net/ip/ipv6_pe.c index 4379dc47e7e..bb03683db39 100644 --- a/subsys/net/ip/ipv6_pe.c +++ b/subsys/net/ip/ipv6_pe.c @@ -501,7 +501,7 @@ static void ipv6_pe_recheck_filters(bool is_denylist) #if CONFIG_NET_IPV6_PE_FILTER_PREFIX_COUNT > 0 static void send_filter_event(struct in6_addr *addr, bool is_denylist, - int event_type) + uint64_t event_type) { if (IS_ENABLED(CONFIG_NET_MGMT_EVENT_INFO)) { struct net_event_ipv6_pe_filter info; diff --git a/subsys/net/ip/net_mgmt.c b/subsys/net/ip/net_mgmt.c index 4fbc1a1b599..d48a54e5611 100644 --- a/subsys/net/ip/net_mgmt.c +++ b/subsys/net/ip/net_mgmt.c @@ -27,7 +27,7 @@ struct mgmt_event_entry { #endif /* CONFIG_NET_MGMT_EVENT_QUEUE */ size_t info_length; #endif /* CONFIG_NET_MGMT_EVENT_INFO */ - uint32_t event; + uint64_t event; struct net_if *iface; }; @@ -47,7 +47,7 @@ K_KERNEL_STACK_DEFINE(mgmt_stack, CONFIG_NET_MGMT_EVENT_STACK_SIZE); static struct k_work_q mgmt_work_q_obj; #endif -static uint32_t global_event_mask; +static uint64_t global_event_mask; static sys_slist_t event_callbacks = SYS_SLIST_STATIC_INIT(&event_callbacks); /* Forward declaration for the actual caller */ @@ -67,7 +67,7 @@ static struct k_work_q *mgmt_work_q = COND_CODE_1(CONFIG_NET_MGMT_EVENT_SYSTEM_W static void mgmt_event_work_handler(struct k_work *work); static K_WORK_DEFINE(mgmt_work, mgmt_event_work_handler); -static inline void mgmt_push_event(uint32_t mgmt_event, struct net_if *iface, +static inline void mgmt_push_event(uint64_t mgmt_event, struct net_if *iface, const void *info, size_t length) { #ifndef CONFIG_NET_MGMT_EVENT_INFO @@ -85,7 +85,7 @@ static inline void mgmt_push_event(uint32_t mgmt_event, struct net_if *iface, memcpy(new_event.info, info, length); new_event.info_length = length; } else { - NET_ERR("Event %u info length %zu > max size %zu", + NET_ERR("Event 0x%" PRIx64 " info length %zu > max size %zu", mgmt_event, length, NET_EVENT_INFO_MAX_SIZE); (void)k_mutex_unlock(&net_mgmt_event_lock); @@ -99,7 +99,7 @@ static inline void mgmt_push_event(uint32_t mgmt_event, struct net_if *iface, if (k_msgq_put(&event_msgq, &new_event, K_MSEC(CONFIG_NET_MGMT_EVENT_QUEUE_TIMEOUT)) != 0) { - NET_WARN("Failure to push event (%u), " + NET_WARN("Failure to push event (0x%" PRIx64 "), " "try increasing the 'CONFIG_NET_MGMT_EVENT_QUEUE_SIZE' " "or 'CONFIG_NET_MGMT_EVENT_QUEUE_TIMEOUT' options.", mgmt_event); @@ -128,7 +128,7 @@ static void mgmt_event_work_handler(struct k_work *work) #else -static inline void mgmt_push_event(uint32_t event, struct net_if *iface, +static inline void mgmt_push_event(uint64_t event, struct net_if *iface, const void *info, size_t length) { #ifndef CONFIG_NET_MGMT_EVENT_INFO @@ -149,7 +149,7 @@ static inline void mgmt_push_event(uint32_t event, struct net_if *iface, #endif /* CONFIG_NET_MGMT_EVENT_QUEUE */ -static inline void mgmt_add_event_mask(uint32_t event_mask) +static inline void mgmt_add_event_mask(uint64_t event_mask) { global_event_mask |= event_mask; } @@ -169,7 +169,7 @@ static inline void mgmt_rebuild_global_event_mask(void) } } -static inline bool mgmt_is_event_handled(uint32_t mgmt_event) +static inline bool mgmt_is_event_handled(uint64_t mgmt_event) { return (((NET_MGMT_GET_LAYER(mgmt_event) & NET_MGMT_GET_LAYER(global_event_mask)) == @@ -188,7 +188,7 @@ static inline void mgmt_run_slist_callbacks(const struct mgmt_event_entry * cons struct net_mgmt_event_callback *cb, *tmp; /* Readable layer code is starting from 1, thus the increment */ - NET_DBG("Event layer %u code %u cmd %u", + NET_DBG("Event layer 0x%" PRIx64 " code 0x%" PRIx64 " cmd 0x%" PRIx64, NET_MGMT_GET_LAYER(mgmt_event->event) + 1, NET_MGMT_GET_LAYER_CODE(mgmt_event->event), NET_MGMT_GET_COMMAND(mgmt_event->event)); @@ -283,8 +283,8 @@ static void mgmt_run_callbacks(const struct mgmt_event_entry * const mgmt_event) } static int mgmt_event_wait_call(struct net_if *iface, - uint32_t mgmt_event_mask, - uint32_t *raised_event, + uint64_t mgmt_event_mask, + uint64_t *raised_event, struct net_if **event_iface, const void **info, size_t *info_length, @@ -303,7 +303,7 @@ static int mgmt_event_wait_call(struct net_if *iface, sync_data.iface = iface; } - NET_DBG("Synchronous event 0x%08x wait %p", sync.event_mask, &sync); + NET_DBG("Synchronous event 0x%" PRIx64 " wait %p", sync.event_mask, &sync); net_mgmt_add_event_callback(&sync); @@ -367,12 +367,12 @@ void net_mgmt_del_event_callback(struct net_mgmt_event_callback *cb) (void)k_mutex_unlock(&net_mgmt_callback_lock); } -void net_mgmt_event_notify_with_info(uint32_t mgmt_event, struct net_if *iface, +void net_mgmt_event_notify_with_info(uint64_t mgmt_event, struct net_if *iface, const void *info, size_t length) { if (mgmt_is_event_handled(mgmt_event)) { /* Readable layer code is starting from 1, thus the increment */ - NET_DBG("Notifying Event layer %u code %u type %u", + NET_DBG("Notifying Event layer 0x%" PRIx64 " code 0x%" PRIx64 " type 0x%" PRIx64, NET_MGMT_GET_LAYER(mgmt_event) + 1, NET_MGMT_GET_LAYER_CODE(mgmt_event), NET_MGMT_GET_COMMAND(mgmt_event)); @@ -381,8 +381,8 @@ void net_mgmt_event_notify_with_info(uint32_t mgmt_event, struct net_if *iface, } } -int net_mgmt_event_wait(uint32_t mgmt_event_mask, - uint32_t *raised_event, +int net_mgmt_event_wait(uint64_t mgmt_event_mask, + uint64_t *raised_event, struct net_if **iface, const void **info, size_t *info_length, @@ -394,8 +394,8 @@ int net_mgmt_event_wait(uint32_t mgmt_event_mask, } int net_mgmt_event_wait_on_iface(struct net_if *iface, - uint32_t mgmt_event_mask, - uint32_t *raised_event, + uint64_t mgmt_event_mask, + uint64_t *raised_event, const void **info, size_t *info_length, k_timeout_t timeout) diff --git a/subsys/net/ip/net_stats.c b/subsys/net/ip/net_stats.c index 5da625faeb6..9e7d0bb6fc7 100644 --- a/subsys/net/ip/net_stats.c +++ b/subsys/net/ip/net_stats.c @@ -252,7 +252,7 @@ void net_print_statistics(void) #if defined(CONFIG_NET_STATISTICS_USER_API) -static int net_stats_get(uint32_t mgmt_request, struct net_if *iface, +static int net_stats_get(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { size_t len_chk = 0; diff --git a/subsys/net/ip/pmtu.c b/subsys/net/ip/pmtu.c index be2c3355a6b..cdd09ed0ca8 100644 --- a/subsys/net/ip/pmtu.c +++ b/subsys/net/ip/pmtu.c @@ -12,7 +12,6 @@ LOG_MODULE_REGISTER(net_pmtu, CONFIG_NET_PMTU_LOG_LEVEL); #include -#include #include #include #include "pmtu.h" diff --git a/subsys/net/l2/ethernet/arp.c b/subsys/net/l2/ethernet/arp.c index af816185fe1..d49ab054eaa 100644 --- a/subsys/net/l2/ethernet/arp.c +++ b/subsys/net/l2/ethernet/arp.c @@ -569,7 +569,7 @@ static void notify_all_ipv4_addr(struct net_if *iface) } static void iface_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); @@ -586,7 +586,7 @@ static void iface_event_handler(struct net_mgmt_event_callback *cb, } static void ipv4_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { struct in_addr *ipaddr; diff --git a/subsys/net/l2/ethernet/ethernet_mgmt.c b/subsys/net/l2/ethernet/ethernet_mgmt.c index 3f1b6735318..15efbc4f37c 100644 --- a/subsys/net/l2/ethernet/ethernet_mgmt.c +++ b/subsys/net/l2/ethernet/ethernet_mgmt.c @@ -25,7 +25,7 @@ static inline bool is_hw_caps_supported(const struct device *dev, return ((api->get_capabilities(dev) & caps) != 0); } -static int ethernet_set_config(uint32_t mgmt_request, +static int ethernet_set_config(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { @@ -255,7 +255,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_TXINJECTION_MODE, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_ETHERNET_SET_MAC_FILTER, ethernet_set_config); -static int ethernet_get_config(uint32_t mgmt_request, +static int ethernet_get_config(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { diff --git a/subsys/net/l2/ethernet/ethernet_stats.c b/subsys/net/l2/ethernet/ethernet_stats.c index ccbbd53e2f2..57d354623f6 100644 --- a/subsys/net/l2/ethernet/ethernet_stats.c +++ b/subsys/net/l2/ethernet/ethernet_stats.c @@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(net_ethernet_stats, CONFIG_NET_L2_ETHERNET_LOG_LEVEL); #if defined(CONFIG_NET_STATISTICS_USER_API) -static int eth_stats_get(uint32_t mgmt_request, struct net_if *iface, +static int eth_stats_get(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { size_t len_chk = 0; diff --git a/subsys/net/l2/ethernet/lldp/lldp.c b/subsys/net/l2/ethernet/lldp/lldp.c index 2895691d6f0..230e69eb6b8 100644 --- a/subsys/net/l2/ethernet/lldp/lldp.c +++ b/subsys/net/l2/ethernet/lldp/lldp.c @@ -234,7 +234,7 @@ static int lldp_check_iface(struct net_if *iface) return 0; } -static int lldp_start(struct net_if *iface, uint32_t mgmt_event) +static int lldp_start(struct net_if *iface, uint64_t mgmt_event) { struct ethernet_context *ctx; int ret, slot; @@ -328,7 +328,7 @@ int net_lldp_register_callback(struct net_if *iface, net_lldp_recv_cb_t recv_cb) } static void iface_event_handler(struct net_mgmt_event_callback *evt_cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { lldp_start(iface, mgmt_event); } diff --git a/subsys/net/l2/ieee802154/ieee802154_mgmt.c b/subsys/net/l2/ieee802154/ieee802154_mgmt.c index 993bcc12ae9..3c654c375b6 100644 --- a/subsys/net/l2/ieee802154/ieee802154_mgmt.c +++ b/subsys/net/l2/ieee802154/ieee802154_mgmt.c @@ -74,7 +74,7 @@ enum net_verdict ieee802154_handle_beacon(struct net_if *iface, return NET_CONTINUE; } -static int ieee802154_cancel_scan(uint32_t mgmt_request, struct net_if *iface, +static int ieee802154_cancel_scan(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { struct ieee802154_context *ctx = net_if_l2_data(iface); @@ -94,7 +94,7 @@ static int ieee802154_cancel_scan(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_CANCEL_SCAN, ieee802154_cancel_scan); -static int ieee802154_scan(uint32_t mgmt_request, struct net_if *iface, +static int ieee802154_scan(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct ieee802154_phy_supported_channels *supported_channels; @@ -437,7 +437,7 @@ enum net_verdict ieee802154_handle_mac_command(struct net_if *iface, return NET_DROP; } -static int ieee802154_associate(uint32_t mgmt_request, struct net_if *iface, +static int ieee802154_associate(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { struct ieee802154_context *ctx = net_if_l2_data(iface); @@ -631,7 +631,7 @@ static int ieee802154_associate(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_ASSOCIATE, ieee802154_associate); -static int ieee802154_disassociate(uint32_t mgmt_request, struct net_if *iface, +static int ieee802154_disassociate(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { struct ieee802154_context *ctx = net_if_l2_data(iface); @@ -706,7 +706,7 @@ static int ieee802154_disassociate(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_DISASSOCIATE, ieee802154_disassociate); -static int ieee802154_set_ack(uint32_t mgmt_request, struct net_if *iface, +static int ieee802154_set_ack(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { struct ieee802154_context *ctx = net_if_l2_data(iface); @@ -733,7 +733,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_SET_ACK, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_UNSET_ACK, ieee802154_set_ack); -static int ieee802154_set_parameters(uint32_t mgmt_request, +static int ieee802154_set_parameters(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { @@ -851,7 +851,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_SET_SHORT_ADDR, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_SET_TX_POWER, ieee802154_set_parameters); -static int ieee802154_get_parameters(uint32_t mgmt_request, +static int ieee802154_get_parameters(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { @@ -914,7 +914,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_GET_TX_POWER, #ifdef CONFIG_NET_L2_IEEE802154_SECURITY -static int ieee802154_set_security_settings(uint32_t mgmt_request, +static int ieee802154_set_security_settings(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { @@ -953,7 +953,7 @@ static int ieee802154_set_security_settings(uint32_t mgmt_request, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, ieee802154_set_security_settings); -static int ieee802154_get_security_settings(uint32_t mgmt_request, +static int ieee802154_get_security_settings(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { diff --git a/subsys/net/l2/ieee802154/ieee802154_shell.c b/subsys/net/l2/ieee802154/ieee802154_shell.c index 8a4e6ab0b6c..777e7c6e46f 100644 --- a/subsys/net/l2/ieee802154/ieee802154_shell.c +++ b/subsys/net/l2/ieee802154/ieee802154_shell.c @@ -209,7 +209,7 @@ static inline char *print_coordinator_address(char *buf, int buf_len) } static void scan_result_cb(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { char buf[64]; @@ -224,7 +224,7 @@ static int cmd_ieee802154_scan(const struct shell *sh, size_t argc, char *argv[]) { struct net_if *iface = net_if_get_ieee802154(); - uint32_t scan_type; + uint64_t scan_type; int ret = 0; if (argc < 3) { diff --git a/subsys/net/l2/openthread/openthread.c b/subsys/net/l2/openthread/openthread.c index 6ddeadf8dfc..4ed6a34162f 100644 --- a/subsys/net/l2/openthread/openthread.c +++ b/subsys/net/l2/openthread/openthread.c @@ -34,7 +34,7 @@ static struct openthread_state_changed_callback ot_l2_state_changed_cb; #ifdef CONFIG_NET_MGMT_EVENT static struct net_mgmt_event_callback ip6_addr_cb; -static void ipv6_addr_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void ipv6_addr_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { if (net_if_l2(iface) != &NET_L2_GET_NAME(OPENTHREAD)) { diff --git a/subsys/net/l2/ppp/ppp_l2.c b/subsys/net/l2/ppp/ppp_l2.c index 5521d76470e..ae573a6e7ce 100644 --- a/subsys/net/l2/ppp/ppp_l2.c +++ b/subsys/net/l2/ppp/ppp_l2.c @@ -474,7 +474,7 @@ static void tx_handler(void *p1, void *p2, void *p3) } } -static void net_ppp_mgmt_evt_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void net_ppp_mgmt_evt_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { struct ppp_context *ctx; diff --git a/subsys/net/l2/ppp/ppp_stats.c b/subsys/net/l2/ppp/ppp_stats.c index 9dafef154b3..ee831b3953d 100644 --- a/subsys/net/l2/ppp/ppp_stats.c +++ b/subsys/net/l2/ppp/ppp_stats.c @@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(net_ppp_stats, CONFIG_NET_L2_PPP_LOG_LEVEL); #if defined(CONFIG_NET_STATISTICS_USER_API) -static int ppp_stats_get(uint32_t mgmt_request, struct net_if *iface, +static int ppp_stats_get(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { size_t len_chk = 0; diff --git a/subsys/net/l2/virtual/virtual_mgmt.c b/subsys/net/l2/virtual/virtual_mgmt.c index 1210fc59083..c6187e0dd9f 100644 --- a/subsys/net/l2/virtual/virtual_mgmt.c +++ b/subsys/net/l2/virtual/virtual_mgmt.c @@ -13,7 +13,7 @@ LOG_MODULE_REGISTER(net_virtual_mgmt, CONFIG_NET_L2_VIRTUAL_LOG_LEVEL); #include #include -static int virtual_interface_set_config(uint32_t mgmt_request, +static int virtual_interface_set_config(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { @@ -89,7 +89,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_VIRTUAL_INTERFACE_SET_LINK_TYPE, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_VIRTUAL_INTERFACE_SET_PRIVATE_KEY, virtual_interface_set_config); -static int virtual_interface_get_config(uint32_t mgmt_request, +static int virtual_interface_get_config(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index 67f1f68e5a5..f16f2581374 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -371,7 +371,7 @@ static const struct wifi_mgmt_ops *const get_wifi_api(struct net_if *iface) return off_api ? off_api->wifi_mgmt_api : NULL; } -static int wifi_connect(uint32_t mgmt_request, struct net_if *iface, +static int wifi_connect(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { struct wifi_connect_req_params *params = @@ -475,7 +475,7 @@ static void scan_result_cb(struct net_if *iface, int status, #endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS_ONLY */ } -static int wifi_scan(uint32_t mgmt_request, struct net_if *iface, +static int wifi_scan(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -504,7 +504,7 @@ static int wifi_scan(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_SCAN, wifi_scan); -static int wifi_disconnect(uint32_t mgmt_request, struct net_if *iface, +static int wifi_disconnect(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -546,7 +546,7 @@ void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status) } #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_ROAMING -static int wifi_start_roaming(uint32_t mgmt_request, struct net_if *iface, +static int wifi_start_roaming(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -589,7 +589,7 @@ static int wifi_start_roaming(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_START_ROAMING, wifi_start_roaming); -static int wifi_neighbor_rep_complete(uint32_t mgmt_request, struct net_if *iface, +static int wifi_neighbor_rep_complete(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -684,7 +684,7 @@ void wifi_mgmt_raise_neighbor_rep_recv_event(struct net_if *iface, char *inbuf, } #endif -static int wifi_ap_enable(uint32_t mgmt_request, struct net_if *iface, +static int wifi_ap_enable(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { struct wifi_connect_req_params *params = @@ -705,7 +705,7 @@ static int wifi_ap_enable(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_ENABLE, wifi_ap_enable); -static int wifi_ap_disable(uint32_t mgmt_request, struct net_if *iface, +static int wifi_ap_disable(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -724,7 +724,7 @@ static int wifi_ap_disable(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_DISABLE, wifi_ap_disable); -static int wifi_ap_sta_disconnect(uint32_t mgmt_request, struct net_if *iface, +static int wifi_ap_sta_disconnect(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -752,7 +752,7 @@ static int wifi_ap_sta_disconnect(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT, wifi_ap_sta_disconnect); -static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface, +static int wifi_ap_config_params(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -790,7 +790,7 @@ static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM, wifi_ap_config_params); -static int wifi_ap_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface, +static int wifi_ap_set_rts_threshold(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -814,7 +814,7 @@ static int wifi_ap_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_RTS_THRESHOLD, wifi_ap_set_rts_threshold); -static int wifi_iface_status(uint32_t mgmt_request, struct net_if *iface, +static int wifi_iface_status(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -842,7 +842,7 @@ void wifi_mgmt_raise_iface_status_event(struct net_if *iface, } #ifdef CONFIG_NET_STATISTICS_WIFI -static int wifi_iface_stats(uint32_t mgmt_request, struct net_if *iface, +static int wifi_iface_stats(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -861,7 +861,7 @@ static int wifi_iface_stats(uint32_t mgmt_request, struct net_if *iface, } NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_WIFI, wifi_iface_stats); -static int wifi_iface_stats_reset(uint32_t mgmt_request, struct net_if *iface, +static int wifi_iface_stats_reset(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -876,7 +876,7 @@ static int wifi_iface_stats_reset(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI, wifi_iface_stats_reset); #endif /* CONFIG_NET_STATISTICS_WIFI */ -static int wifi_11k_cfg(uint32_t mgmt_request, struct net_if *iface, +static int wifi_11k_cfg(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -902,7 +902,7 @@ static int wifi_11k_cfg(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_11K_CONFIG, wifi_11k_cfg); -static int wifi_11k_neighbor_request(uint32_t mgmt_request, struct net_if *iface, +static int wifi_11k_neighbor_request(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -923,7 +923,7 @@ static int wifi_11k_neighbor_request(uint32_t mgmt_request, struct net_if *iface NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_11K_NEIGHBOR_REQUEST, wifi_11k_neighbor_request); -static int wifi_set_power_save(uint32_t mgmt_request, struct net_if *iface, +static int wifi_set_power_save(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -977,7 +977,7 @@ static int wifi_set_power_save(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_PS, wifi_set_power_save); -static int wifi_get_power_save_config(uint32_t mgmt_request, struct net_if *iface, +static int wifi_get_power_save_config(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1001,7 +1001,7 @@ static int wifi_get_power_save_config(uint32_t mgmt_request, struct net_if *ifac NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_PS_CONFIG, wifi_get_power_save_config); -static int wifi_set_twt(uint32_t mgmt_request, struct net_if *iface, +static int wifi_set_twt(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1068,7 +1068,7 @@ static int wifi_set_twt(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_TWT, wifi_set_twt); -static int wifi_set_btwt(uint32_t mgmt_request, struct net_if *iface, +static int wifi_set_btwt(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1108,7 +1108,7 @@ void wifi_mgmt_raise_twt_event(struct net_if *iface, struct wifi_twt_params *twt sizeof(struct wifi_twt_params)); } -static int wifi_reg_domain(uint32_t mgmt_request, struct net_if *iface, +static int wifi_reg_domain(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1140,7 +1140,7 @@ void wifi_mgmt_raise_twt_sleep_state(struct net_if *iface, sizeof(twt_sleep_state)); } -static int wifi_mode(uint32_t mgmt_request, struct net_if *iface, +static int wifi_mode(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1164,7 +1164,7 @@ static int wifi_mode(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_MODE, wifi_mode); -static int wifi_packet_filter(uint32_t mgmt_request, struct net_if *iface, +static int wifi_packet_filter(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1188,7 +1188,7 @@ static int wifi_packet_filter(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_PACKET_FILTER, wifi_packet_filter); -static int wifi_channel(uint32_t mgmt_request, struct net_if *iface, +static int wifi_channel(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1212,7 +1212,7 @@ static int wifi_channel(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_CHANNEL, wifi_channel); -static int wifi_get_version(uint32_t mgmt_request, struct net_if *iface, +static int wifi_get_version(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1228,7 +1228,7 @@ static int wifi_get_version(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION, wifi_get_version); -static int wifi_btm_query(uint32_t mgmt_request, struct net_if *iface, void *data, size_t len) +static int wifi_btm_query(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface); @@ -1252,7 +1252,7 @@ static int wifi_btm_query(uint32_t mgmt_request, struct net_if *iface, void *dat NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_BTM_QUERY, wifi_btm_query); -static int wifi_get_connection_params(uint32_t mgmt_request, struct net_if *iface, +static int wifi_get_connection_params(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1272,7 +1272,7 @@ static int wifi_get_connection_params(uint32_t mgmt_request, struct net_if *ifac NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_CONN_PARAMS, wifi_get_connection_params); -static int wifi_wps_config(uint32_t mgmt_request, struct net_if *iface, void *data, size_t len) +static int wifi_wps_config(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface); @@ -1291,7 +1291,7 @@ static int wifi_wps_config(uint32_t mgmt_request, struct net_if *iface, void *da NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_WPS_CONFIG, wifi_wps_config); -static int wifi_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface, +static int wifi_set_rts_threshold(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1316,7 +1316,7 @@ static int wifi_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD, wifi_set_rts_threshold); #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP -static int wifi_dpp(uint32_t mgmt_request, struct net_if *iface, +static int wifi_dpp(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1338,7 +1338,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_DPP, wifi_dpp); #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */ -static int wifi_pmksa_flush(uint32_t mgmt_request, struct net_if *iface, +static int wifi_pmksa_flush(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1357,7 +1357,7 @@ static int wifi_pmksa_flush(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_PMKSA_FLUSH, wifi_pmksa_flush); -static int wifi_get_rts_threshold(uint32_t mgmt_request, struct net_if *iface, +static int wifi_get_rts_threshold(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1382,7 +1382,7 @@ static int wifi_get_rts_threshold(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD_CONFIG, wifi_get_rts_threshold); #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE -static int wifi_set_enterprise_creds(uint32_t mgmt_request, struct net_if *iface, +static int wifi_set_enterprise_creds(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1403,7 +1403,7 @@ static int wifi_set_enterprise_creds(uint32_t mgmt_request, struct net_if *iface NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_ENTERPRISE_CREDS, wifi_set_enterprise_creds); #endif -static int wifi_set_bss_max_idle_period(uint32_t mgmt_request, struct net_if *iface, +static int wifi_set_bss_max_idle_period(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { const struct device *dev = net_if_get_device(iface); @@ -1746,7 +1746,7 @@ static int add_static_network_config(struct net_if *iface) #endif /* defined(CONFIG_WIFI_CREDENTIALS_STATIC) */ } -static int connect_stored_command(uint32_t mgmt_request, struct net_if *iface, void *data, +static int connect_stored_command(uint64_t mgmt_request, struct net_if *iface, void *data, size_t len) { int ret = 0; diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 6ef17817aa4..b23d407da64 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -518,7 +518,7 @@ static void handle_wifi_neighbor_rep_complete(struct net_mgmt_event_callback *cb #endif static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { case NET_EVENT_WIFI_CONNECT_RESULT: @@ -556,7 +556,7 @@ static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, } static void wifi_mgmt_scan_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { case NET_EVENT_WIFI_SCAN_RESULT: diff --git a/subsys/net/lib/coap/coap.c b/subsys/net/lib/coap/coap.c index b1d00a46f1d..4ba5f4d309e 100644 --- a/subsys/net/lib/coap/coap.c +++ b/subsys/net/lib/coap/coap.c @@ -1956,7 +1956,7 @@ void coap_observer_init(struct coap_observer *observer, static inline void coap_observer_raise_event(struct coap_resource *resource, struct coap_observer *observer, - uint32_t mgmt_event) + uint64_t mgmt_event) { #ifdef CONFIG_NET_MGMT_EVENT_INFO const struct net_event_coap_observer net_event = { diff --git a/subsys/net/lib/coap/coap_server.c b/subsys/net/lib/coap/coap_server.c index 6ab85ede3f1..27e4267167f 100644 --- a/subsys/net/lib/coap/coap_server.c +++ b/subsys/net/lib/coap/coap_server.c @@ -385,7 +385,7 @@ static inline bool coap_service_in_section(const struct coap_service *service) STRUCT_SECTION_END(coap_service) > service; } -static inline void coap_service_raise_event(const struct coap_service *service, uint32_t mgmt_event) +static inline void coap_service_raise_event(const struct coap_service *service, uint64_t mgmt_event) { #if defined(CONFIG_NET_MGMT_EVENT_INFO) const struct net_event_coap_service net_event = { diff --git a/subsys/net/lib/config/init.c b/subsys/net/lib/config/init.c index 56b6bc03b6c..22500fd8f84 100644 --- a/subsys/net/lib/config/init.c +++ b/subsys/net/lib/config/init.c @@ -102,7 +102,7 @@ static void print_dhcpv4_info(struct net_if *iface) static struct net_mgmt_event_callback mgmt4_cb; static void ipv4_addr_add_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IPV4_ADDR_ADD) { @@ -244,7 +244,7 @@ static struct net_mgmt_event_callback mgmt6_cb; static struct in6_addr laddr; static void ipv6_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { struct net_if_ipv6 *ipv6 = iface->config.ip.ipv6; int i; @@ -310,7 +310,7 @@ static void ipv6_event_handler(struct net_mgmt_event_callback *cb, static void setup_ipv6(struct net_if *iface, uint32_t flags) { struct net_if_addr *ifaddr; - uint32_t mask = NET_EVENT_IPV6_DAD_SUCCEED; + uint64_t mask = NET_EVENT_IPV6_DAD_SUCCEED; if (sizeof(CONFIG_NET_CONFIG_MY_IPV6_ADDR) == 1) { /* Empty address, skip setting ANY address in this case */ @@ -330,20 +330,10 @@ static void setup_ipv6(struct net_if *iface, uint32_t flags) net_mgmt_init_event_callback(&mgmt6_cb, ipv6_event_handler, mask); net_mgmt_add_event_callback(&mgmt6_cb); - /* - * check for CMD_ADDR_ADD bit here, NET_EVENT_IPV6_ADDR_ADD is - * a combination of _NET_EVENT_IPV6_BASE | NET_EVENT_IPV6_CMD_ADDR_ADD - * so it will always return != NET_EVENT_IPV6_CMD_ADDR_ADD if any other - * event is set (for instance NET_EVENT_IPV6_ROUTER_ADD) - */ - if ((mask & NET_EVENT_IPV6_CMD_ADDR_ADD) == - NET_EVENT_IPV6_CMD_ADDR_ADD) { - ifaddr = net_if_ipv6_addr_add(iface, &laddr, - NET_ADDR_MANUAL, 0); - if (!ifaddr) { - NET_ERR("Cannot add %s to interface", - CONFIG_NET_CONFIG_MY_IPV6_ADDR); - } + ifaddr = net_if_ipv6_addr_add(iface, &laddr, NET_ADDR_MANUAL, 0); + if (!ifaddr) { + NET_ERR("Cannot add %s to interface", + CONFIG_NET_CONFIG_MY_IPV6_ADDR); } exit: @@ -363,7 +353,7 @@ static void setup_ipv6(struct net_if *iface, uint32_t flags) #if defined(CONFIG_NET_NATIVE) static void iface_up_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IF_UP) { NET_INFO("Interface %d (%p) coming up", diff --git a/subsys/net/lib/config/init_clock_sntp.c b/subsys/net/lib/config/init_clock_sntp.c index dd63564f9c0..0e2b9aa1362 100644 --- a/subsys/net/lib/config/init_clock_sntp.c +++ b/subsys/net/lib/config/init_clock_sntp.c @@ -89,7 +89,7 @@ static void sntp_resync_handler(struct k_work *work) #endif /* CONFIG_NET_CONFIG_SNTP_INIT_RESYNC */ #ifdef CONFIG_NET_CONFIG_SNTP_INIT_USE_CONNECTION_MANAGER -static void l4_event_handler(uint32_t mgmt_event, struct net_if *iface, void *info, +static void l4_event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { ARG_UNUSED(iface); diff --git a/subsys/net/lib/dhcpv4/dhcpv4.c b/subsys/net/lib/dhcpv4/dhcpv4.c index 2096bf330d9..f9a20bb7dfe 100644 --- a/subsys/net/lib/dhcpv4/dhcpv4.c +++ b/subsys/net/lib/dhcpv4/dhcpv4.c @@ -1637,7 +1637,7 @@ static enum net_verdict net_dhcpv4_input(struct net_conn *conn, } static void dhcpv4_iface_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { sys_snode_t *node = NULL; @@ -1699,7 +1699,7 @@ static void dhcpv4_iface_event_handler(struct net_mgmt_event_callback *cb, #if defined(CONFIG_NET_IPV4_ACD) static void dhcpv4_acd_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { sys_snode_t *node = NULL; struct in_addr *addr; diff --git a/subsys/net/lib/dhcpv6/dhcpv6.c b/subsys/net/lib/dhcpv6/dhcpv6.c index c1282c2a6f1..88770bac66d 100644 --- a/subsys/net/lib/dhcpv6/dhcpv6.c +++ b/subsys/net/lib/dhcpv6/dhcpv6.c @@ -2200,7 +2200,7 @@ static void dhcpv6_timeout(struct k_work *work) } static void dhcpv6_iface_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { sys_snode_t *node = NULL; diff --git a/subsys/net/lib/dns/llmnr_responder.c b/subsys/net/lib/dns/llmnr_responder.c index bf330e24374..f0f1f57ff28 100644 --- a/subsys/net/lib/dns/llmnr_responder.c +++ b/subsys/net/lib/dns/llmnr_responder.c @@ -117,7 +117,7 @@ static void create_ipv4_dst_addr(struct sockaddr_in *src_addr, #endif static void llmnr_iface_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IF_UP) { #if defined(CONFIG_NET_IPV4) diff --git a/subsys/net/lib/dns/mdns_responder.c b/subsys/net/lib/dns/mdns_responder.c index 29f1c657ae1..8642364bc2b 100644 --- a/subsys/net/lib/dns/mdns_responder.c +++ b/subsys/net/lib/dns/mdns_responder.c @@ -157,7 +157,7 @@ static void mark_needs_announce(struct net_if *iface, bool needs_announce) #endif /* CONFIG_MDNS_RESPONDER_PROBE */ static void mdns_iface_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_IF_UP) { @@ -958,7 +958,7 @@ static void probing(struct k_work *work) } static void mdns_addr_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { uint32_t probe_delay = sys_rand32_get() % 250; bool probe_started = false; @@ -1110,7 +1110,7 @@ static void mdns_addr_event_handler(struct net_mgmt_event_callback *cb, } static void mdns_conn_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_L4_DISCONNECTED) { /* Clear the failed probes counter so that we can start @@ -1823,7 +1823,7 @@ static void do_init_listener(struct k_work *work) static int mdns_responder_init(void) { - uint32_t flags = NET_EVENT_IF_UP; + uint64_t flags = NET_EVENT_IF_UP; external_records = NULL; external_records_count = 0; diff --git a/subsys/net/lib/ptp/port.c b/subsys/net/lib/ptp/port.c index 24abec002c8..d3f803cb391 100644 --- a/subsys/net/lib/ptp/port.c +++ b/subsys/net/lib/ptp/port.c @@ -964,7 +964,7 @@ int port_state_update(struct ptp_port *port, enum ptp_port_event event, bool tt_ } static void port_link_monitor(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); diff --git a/subsys/net/lib/shell/events.c b/subsys/net/lib/shell/events.c index 6b27dc2e4b0..51afbc85fc9 100644 --- a/subsys/net/lib/shell/events.c +++ b/subsys/net/lib/shell/events.c @@ -44,7 +44,7 @@ static const char unknown_event_str[] = ""; struct event_msg { struct net_if *iface; size_t len; - uint32_t event; + uint64_t event; uint8_t data[MAX_EVENT_INFO_SIZE]; }; @@ -52,7 +52,7 @@ K_MSGQ_DEFINE(event_mon_msgq, sizeof(struct event_msg), CONFIG_NET_MGMT_EVENT_QUEUE_SIZE, sizeof(intptr_t)); static void event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { struct event_msg msg; int ret; @@ -563,7 +563,7 @@ static void event_mon_handler(const struct shell *sh, void *p2, void *p3) } if (desc == unknown_event_str) { - PR_INFO("EVENT: %s [%d] %s%s%s%s%s (0x%08x)\n", layer_str, + PR_INFO("EVENT: %s [%d] %s%s%s%s%s (0x%" PRIx64 ")\n", layer_str, net_if_get_by_iface(msg.iface), desc, desc2 ? " " : "", desc2 ? desc2 : "", info ? " " : "", info ? info : "", msg.event); diff --git a/subsys/net/lib/sockets/sockets_net_mgmt.c b/subsys/net/lib/sockets/sockets_net_mgmt.c index 909893e0444..dcb4194ec85 100644 --- a/subsys/net/lib/sockets/sockets_net_mgmt.c +++ b/subsys/net/lib/sockets/sockets_net_mgmt.c @@ -31,7 +31,7 @@ __net_socket struct net_mgmt_socket { uintptr_t pid; /* net_mgmt mask */ - uint32_t mask; + uint64_t mask; /* Message allocation timeout */ k_timeout_t alloc_timeout; @@ -145,7 +145,7 @@ static ssize_t znet_mgmt_recvfrom(struct net_mgmt_socket *mgmt, void *buf, { struct sockaddr_nm *nm_addr = (struct sockaddr_nm *)src_addr; k_timeout_t timeout = mgmt->wait_timeout; - uint32_t raised_event = 0; + uint64_t raised_event = 0; uint8_t *copy_to = buf; struct net_mgmt_msghdr hdr; struct net_if *iface; @@ -237,7 +237,7 @@ static int znet_mgmt_getsockopt(struct net_mgmt_socket *mgmt, int level, } if (IS_ENABLED(CONFIG_NET_L2_ETHERNET_MGMT)) { - if (optname == NET_REQUEST_ETHERNET_GET_QAV_PARAM) { + if (optname == SO_NET_MGMT_ETHERNET_GET_QAV_PARAM) { int ret; ret = net_mgmt(NET_REQUEST_ETHERNET_GET_QAV_PARAM, @@ -274,7 +274,7 @@ static int znet_mgmt_setsockopt(struct net_mgmt_socket *mgmt, int level, } if (IS_ENABLED(CONFIG_NET_L2_ETHERNET_MGMT)) { - if (optname == NET_REQUEST_ETHERNET_SET_QAV_PARAM) { + if (optname == SO_NET_MGMT_ETHERNET_SET_QAV_PARAM) { int ret; ret = net_mgmt(NET_REQUEST_ETHERNET_SET_QAV_PARAM, diff --git a/subsys/shell/backends/shell_mqtt.c b/subsys/shell/backends/shell_mqtt.c index 28bd39f4b0d..d77cbac6742 100644 --- a/subsys/shell/backends/shell_mqtt.c +++ b/subsys/shell/backends/shell_mqtt.c @@ -508,7 +508,7 @@ static void net_disconnect_handler(struct k_work *work) } /* Network connection event handler */ -static void network_evt_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void network_evt_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { struct shell_mqtt *sh = sh_mqtt; diff --git a/tests/boards/espressif/ethernet/src/main.c b/tests/boards/espressif/ethernet/src/main.c index b64bc946366..e9c397d795f 100644 --- a/tests/boards/espressif/ethernet/src/main.c +++ b/tests/boards/espressif/ethernet/src/main.c @@ -30,7 +30,7 @@ static uint8_t ntp_server[4]; static struct net_mgmt_event_callback mgmt_cb; static struct net_dhcpv4_option_callback dhcp_cb; -static void ipv4_event(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void ipv4_event(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { if ((mgmt_event != NET_EVENT_IPV4_ADDR_ADD) || diff --git a/tests/boards/espressif/wifi/src/main.c b/tests/boards/espressif/wifi/src/main.c index bbccdb9b2a9..931927ef25d 100644 --- a/tests/boards/espressif/wifi/src/main.c +++ b/tests/boards/espressif/wifi/src/main.c @@ -93,7 +93,7 @@ static void wifi_disconnect_result(struct net_mgmt_event_callback *cb) } } -static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void wifi_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { switch (mgmt_event) { diff --git a/tests/boards/nrf/qdec/boards/bl54l15_dvk_nrf54l15_common.dtsi b/tests/boards/nrf/qdec/boards/bl54l15_dvk_nrf54l15_common.dtsi index 4db67a49a5e..19ca5e83647 100644 --- a/tests/boards/nrf/qdec/boards/bl54l15_dvk_nrf54l15_common.dtsi +++ b/tests/boards/nrf/qdec/boards/bl54l15_dvk_nrf54l15_common.dtsi @@ -5,12 +5,6 @@ */ / { - aliases { - qdec0 = &qdec20; - qenca = &phase_a; - qencb = &phase_b; - }; - encoder-emulate { compatible = "gpio-leds"; @@ -22,6 +16,14 @@ gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; }; }; + + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec20>; + qenc-emul-gpios = <&phase_a &phase_b>; + }; + }; }; &pinctrl { diff --git a/tests/boards/nrf/qdec/boards/bl54l15u_dvk_nrf54l15_common.dtsi b/tests/boards/nrf/qdec/boards/bl54l15u_dvk_nrf54l15_common.dtsi index 4db67a49a5e..19ca5e83647 100644 --- a/tests/boards/nrf/qdec/boards/bl54l15u_dvk_nrf54l15_common.dtsi +++ b/tests/boards/nrf/qdec/boards/bl54l15u_dvk_nrf54l15_common.dtsi @@ -5,12 +5,6 @@ */ / { - aliases { - qdec0 = &qdec20; - qenca = &phase_a; - qencb = &phase_b; - }; - encoder-emulate { compatible = "gpio-leds"; @@ -22,6 +16,14 @@ gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; }; }; + + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec20>; + qenc-emul-gpios = <&phase_a &phase_b>; + }; + }; }; &pinctrl { diff --git a/tests/boards/nrf/qdec/boards/nrf52840dk_nrf52840.overlay b/tests/boards/nrf/qdec/boards/nrf52840dk_nrf52840.overlay index f227fb95c38..a495df07f7c 100644 --- a/tests/boards/nrf/qdec/boards/nrf52840dk_nrf52840.overlay +++ b/tests/boards/nrf/qdec/boards/nrf52840dk_nrf52840.overlay @@ -22,6 +22,13 @@ }; }; + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec0>; + qenc-emul-gpios = <&phase_a &phase_b>; + }; + }; }; &pinctrl { diff --git a/tests/boards/nrf/qdec/boards/nrf5340dk_nrf5340_cpuapp.overlay b/tests/boards/nrf/qdec/boards/nrf5340dk_nrf5340_cpuapp.overlay index ed6a5587f5b..d1f008c8193 100644 --- a/tests/boards/nrf/qdec/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/tests/boards/nrf/qdec/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -4,12 +4,6 @@ */ / { - aliases { - qdec0 = &qdec1; - qenca = &phase_a; - qencb = &phase_b; - }; - encoder-emulate { compatible = "gpio-leds"; phase_a: phase_a { @@ -21,6 +15,14 @@ gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; }; }; + + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec1>; + qenc-emul-gpios = <&phase_a &phase_b>; + }; + }; }; &pinctrl { diff --git a/tests/boards/nrf/qdec/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/boards/nrf/qdec/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 7e6da5a3458..7e43c70dac0 100644 --- a/tests/boards/nrf/qdec/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/boards/nrf/qdec/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -3,49 +3,101 @@ * SPDX-License-Identifier: Apache-2.0 */ -/ { - aliases { - qdec0 = &qdec130; - qenca = &phase_a; - qencb = &phase_b; - }; +/* Required loopbacks + * P2.08 <-> P2.09 + * P2.10 <-> P2.11 + * P1.02 <-> P1.03 + * P7.01 <-> P1.05 + */ +/ { encoder-emulate { compatible = "gpio-leds"; - phase_a: phase_a { + phase_a0: phase_a0 { gpios = <&gpio2 9 GPIO_ACTIVE_HIGH>; }; - phase_b: phase_b { + phase_b0: phase_b0 { gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>; }; + phase_a1: phase_a1 { + gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>; + }; + phase_b1: phase_b1 { + gpios = <&gpio7 1 GPIO_ACTIVE_HIGH>; + }; + }; + + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec130>; + qenc-emul-gpios = <&phase_a0 &phase_b0>; + }; + loopback1 { + qdec = <&qdec131>; + qenc-emul-gpios = <&phase_a1 &phase_b1>; + }; }; }; &pinctrl { - qdec_pinctrl: qdec_pinctrl { + qdec_130_pinctrl: qdec_130_pinctrl { group1 { psels = , ; }; }; - qdec_sleep_pinctrl: qdec_sleep_pinctrl { + qdec_130_sleep_pinctrl: qdec_130_sleep_pinctrl { group1 { psels = , ; low-power-enable; }; }; + + qdec_131_pinctrl: qdec_131_pinctrl { + group1 { + psels = , + ; + }; + }; + + qdec_131_sleep_pinctrl: qdec_131_sleep_pinctrl { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&gpio1 { + status = "okay"; }; &gpio2 { status = "okay"; }; +&gpio7 { + status = "okay"; +}; + &qdec130 { status = "okay"; - pinctrl-0 = <&qdec_pinctrl>; - pinctrl-1 = <&qdec_sleep_pinctrl>; + pinctrl-0 = <&qdec_130_pinctrl>; + pinctrl-1 = <&qdec_130_sleep_pinctrl>; + pinctrl-names = "default", "sleep"; + steps = <127>; + led-pre = <500>; + zephyr,pm-device-runtime-auto; +}; + +&qdec131 { + status = "okay"; + pinctrl-0 = <&qdec_131_pinctrl>; + pinctrl-1 = <&qdec_131_sleep_pinctrl>; pinctrl-names = "default", "sleep"; steps = <127>; led-pre = <500>; diff --git a/tests/boards/nrf/qdec/boards/nrf54l15dk_nrf54l15_common.dtsi b/tests/boards/nrf/qdec/boards/nrf54l15dk_nrf54l15_common.dtsi index 3fa426569b8..f2729414652 100644 --- a/tests/boards/nrf/qdec/boards/nrf54l15dk_nrf54l15_common.dtsi +++ b/tests/boards/nrf/qdec/boards/nrf54l15dk_nrf54l15_common.dtsi @@ -3,49 +3,97 @@ * SPDX-License-Identifier: Apache-2.0 */ -/ { - aliases { - qdec0 = &qdec20; - qenca = &phase_a; - qencb = &phase_b; - }; +/* Required loopbacks + * P1.8 <-> P1.9 + * P1.10 <-> P1.11 + * P1.12 <-> P1.13 + * P1.14 <-> P2.10 + */ +/ { encoder-emulate { compatible = "gpio-leds"; - phase_a: phase_a { + phase_a0: phase_a0 { gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>; }; - phase_b: phase_b { + phase_b0: phase_b0 { gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>; }; + phase_a1: phase_a1 { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + }; + phase_b1: phase_b1 { + gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>; + }; + }; + + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec20>; + qenc-emul-gpios = <&phase_a0 &phase_b0>; + }; + loopback1 { + qdec = <&qdec21>; + qenc-emul-gpios = <&phase_a1 &phase_b1>; + }; }; }; &pinctrl { - qdec_pinctrl: qdec_pinctrl { + qdec_20_pinctrl: qdec_20_pinctrl { group1 { psels = , ; }; }; - qdec_sleep_pinctrl: qdec_sleep_pinctrl { + qdec_20_sleep_pinctrl: qdec_20_sleep_pinctrl { group1 { psels = , ; low-power-enable; }; }; + + qdec_21_pinctrl: qdec_21_pinctrl { + group1 { + psels = , + ; + }; + }; + + qdec_21_sleep_pinctrl: qdec_21_sleep_pinctrl { + group1 { + psels = , + ; + low-power-enable; + }; + }; }; &gpio1 { status = "okay"; }; +&gpio2 { + status = "okay"; +}; + &qdec20 { status = "okay"; - pinctrl-0 = <&qdec_pinctrl>; - pinctrl-1 = <&qdec_sleep_pinctrl>; + pinctrl-0 = <&qdec_20_pinctrl>; + pinctrl-1 = <&qdec_20_sleep_pinctrl>; + pinctrl-names = "default", "sleep"; + steps = <127>; + led-pre = <500>; + zephyr,pm-device-runtime-auto; +}; + +&qdec21 { + status = "okay"; + pinctrl-0 = <&qdec_21_pinctrl>; + pinctrl-1 = <&qdec_21_sleep_pinctrl>; pinctrl-names = "default", "sleep"; steps = <127>; led-pre = <500>; diff --git a/tests/boards/nrf/qdec/boards/nrf54lm20dk_nrf54lm20_common.dtsi b/tests/boards/nrf/qdec/boards/nrf54lm20dk_nrf54lm20_common.dtsi index 84e7b1dbc30..6f8f3a18431 100644 --- a/tests/boards/nrf/qdec/boards/nrf54lm20dk_nrf54lm20_common.dtsi +++ b/tests/boards/nrf/qdec/boards/nrf54lm20dk_nrf54lm20_common.dtsi @@ -11,12 +11,6 @@ */ / { - aliases { - qdec0 = &qdec20; - qenca = &phase_a; - qencb = &phase_b; - }; - encoder-emulate { compatible = "gpio-leds"; phase_a: phase_a { @@ -26,6 +20,14 @@ gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>; }; }; + + qdec_loopbacks: loopbacks { + compatible = "test-qdec-loopbacks"; + loopback0 { + qdec = <&qdec20>; + qenc-emul-gpios = <&phase_a &phase_b>; + }; + }; }; &pinctrl { diff --git a/tests/boards/nrf/qdec/dts/bindings/test-qdec-loopback.yaml b/tests/boards/nrf/qdec/dts/bindings/test-qdec-loopback.yaml new file mode 100644 index 00000000000..e03b2ff3bc3 --- /dev/null +++ b/tests/boards/nrf/qdec/dts/bindings/test-qdec-loopback.yaml @@ -0,0 +1,20 @@ +description: | + Binding describing loopbacks required to run tests/boards/nrf/qdec test in Zephyr. + +compatible: "test-qdec-loopbacks" + +child-binding: + description: | + Binding describing a single loopback pair consisting of a QDEC device and two "gpio-leds" pins + working as a quadrature encoder for the test. + properties: + qdec: + type: phandle + required: true + description: Node of the QDEC device used to capture quadrature signal in the loopback. + qenc-emul-gpios: + type: phandles + required: true + description: | + Children nodes of "gpio-leds" compatible used to generate quadrature signal. The first + phandles outputs phase A signal, the second one outputs phase B signal. diff --git a/tests/boards/nrf/qdec/src/main.c b/tests/boards/nrf/qdec/src/main.c index d87feb22f42..9d138d325fb 100644 --- a/tests/boards/nrf/qdec/src/main.c +++ b/tests/boards/nrf/qdec/src/main.c @@ -11,20 +11,45 @@ #include #include +/** + * Structure grouping gpio pins used for QENC emulation connected with a QDEC device + * with a loopback. + */ +struct qdec_qenc_loopback { + struct gpio_dt_spec qenc_phase_a; + struct gpio_dt_spec qenc_phase_b; + + const struct device *qdec; + uint32_t qdec_config_step; +}; + static K_SEM_DEFINE(sem, 0, 1); -static const struct gpio_dt_spec phase_a = GPIO_DT_SPEC_GET(DT_ALIAS(qenca), gpios); -static const struct gpio_dt_spec phase_b = GPIO_DT_SPEC_GET(DT_ALIAS(qencb), gpios); -static const struct device *const qdec_dev = DEVICE_DT_GET(DT_ALIAS(qdec0)); -static const uint32_t qdec_config_step = DT_PROP(DT_ALIAS(qdec0), steps); + +#define GET_QDEC_QENC_LOOPBACK(x) \ + { \ + .qenc_phase_a = GPIO_DT_SPEC_GET(DT_PHANDLE_BY_IDX(x, qenc_emul_gpios, 0), gpios), \ + .qenc_phase_b = GPIO_DT_SPEC_GET(DT_PHANDLE_BY_IDX(x, qenc_emul_gpios, 1), gpios), \ + .qdec = DEVICE_DT_GET(DT_PHANDLE(x, qdec)), \ + .qdec_config_step = DT_PROP_BY_PHANDLE(x, qdec, steps) \ + } + + +struct qdec_qenc_loopback loopbacks[] = { + DT_FOREACH_CHILD_SEP(DT_NODELABEL(qdec_loopbacks), GET_QDEC_QENC_LOOPBACK, (,)) +}; + +#define TESTED_QDEC_COUNT ARRAY_SIZE(loopbacks) + static struct sensor_trigger qdec_trigger = {.type = SENSOR_TRIG_DATA_READY, .chan = SENSOR_CHAN_ROTATION}; + static bool toggle_a = true; +static struct qdec_qenc_loopback *loopback_currently_under_test; static void qdec_trigger_handler(const struct device *dev, const struct sensor_trigger *trigger) { zassert_not_null(dev); zassert_not_null(trigger); - zassert_equal_ptr(dev, qdec_dev); /* trigger should be stored as a pointer in a driver * thus this address should match */ @@ -36,9 +61,9 @@ static void qdec_trigger_handler(const struct device *dev, const struct sensor_t static void qenc_emulate_work_handler(struct k_work *work) { if (toggle_a) { - gpio_pin_toggle_dt(&phase_a); + gpio_pin_toggle_dt(&loopback_currently_under_test->qenc_phase_a); } else { - gpio_pin_toggle_dt(&phase_b); + gpio_pin_toggle_dt(&loopback_currently_under_test->qenc_phase_b); } toggle_a = !toggle_a; } @@ -71,43 +96,46 @@ static void qenc_emulate_setup_pin(const struct gpio_dt_spec *gpio_dt) zassert_true(rc == 0, "%s: pin configure failed: %d", gpio_dt->port->name, rc); } -static void qenc_emulate_start(k_timeout_t period, bool forward) +static void qenc_emulate_start(struct qdec_qenc_loopback *loopback, k_timeout_t period, + bool forward) { - qenc_emulate_reset_pin(&phase_a); - qenc_emulate_reset_pin(&phase_b); + qenc_emulate_reset_pin(&loopback->qenc_phase_a); + qenc_emulate_reset_pin(&loopback->qenc_phase_b); toggle_a = !forward; - + loopback_currently_under_test = loopback; k_timer_start(&qenc_emulate_timer, period, period); } static void qenc_emulate_stop(void) { - k_timer_stop(&qenc_emulate_timer); - - qenc_emulate_reset_pin(&phase_a); - qenc_emulate_reset_pin(&phase_b); + if (loopback_currently_under_test) { + k_timer_stop(&qenc_emulate_timer); + qenc_emulate_reset_pin(&loopback_currently_under_test->qenc_phase_a); + qenc_emulate_reset_pin(&loopback_currently_under_test->qenc_phase_b); + } } -static void qenc_emulate_verify_reading(int emulator_period_ms, int emulation_duration_ms, - bool forward, bool overflow_expected) +static void qenc_emulate_verify_reading(struct qdec_qenc_loopback *loopback, + int emulator_period_ms, int emulation_duration_ms, bool forward, + bool overflow_expected) { int rc; struct sensor_value val = {0}; int32_t expected_steps = emulation_duration_ms / emulator_period_ms; - int32_t expected_reading = 360 * expected_steps / qdec_config_step; - int32_t delta = expected_reading / 5; + int32_t expected_reading = 360 * expected_steps / loopback->qdec_config_step; + int32_t delta = expected_reading / 4; if (!forward) { expected_reading *= -1; } - qenc_emulate_start(K_MSEC(emulator_period_ms), forward); + qenc_emulate_start(loopback, K_MSEC(emulator_period_ms), forward); - /* wait for some readings*/ + /* wait for some readings */ k_msleep(emulation_duration_ms); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(loopback->qdec); if (!overflow_expected) { zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); @@ -115,9 +143,11 @@ static void qenc_emulate_verify_reading(int emulator_period_ms, int emulation_du zassert_true(rc == -EOVERFLOW, "Failed to detect overflow"); } - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val); + rc = sensor_channel_get(loopback->qdec, SENSOR_CHAN_ROTATION, &val); zassert_true(rc == 0, "Failed to get sample (%d)", rc); + TC_PRINT("Expected reading: %d, actual value: %d, delta: %d\n", + expected_reading, val.val1, delta); if (!overflow_expected) { zassert_within(val.val1, expected_reading, delta, "Expected reading: %d, but got: %d", expected_reading, val.val1); @@ -128,35 +158,31 @@ static void qenc_emulate_verify_reading(int emulator_period_ms, int emulation_du /* wait and get readings to clear state */ k_msleep(100); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(loopback->qdec); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val); + rc = sensor_channel_get(loopback->qdec, SENSOR_CHAN_ROTATION, &val); zassert_true(rc == 0, "Failed to get sample (%d)", rc); } -/** - * @brief sensor_trigger_set test disable trigger - * - * Confirm trigger happens after set and stops after being disabled - * - */ -ZTEST(qdec_sensor, test_sensor_trigger_set_and_disable) +static void sensor_trigger_set_and_disable(struct qdec_qenc_loopback *loopback) { int rc; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(loopback->qdec); } + k_sem_give(&sem); + qdec_trigger.type = SENSOR_TRIG_DATA_READY; qdec_trigger.chan = SENSOR_CHAN_ALL; - rc = sensor_trigger_set(qdec_dev, &qdec_trigger, qdec_trigger_handler); + rc = sensor_trigger_set(loopback->qdec, &qdec_trigger, qdec_trigger_handler); zassume_true(rc != -ENOSYS, "sensor_trigger_set not supported"); zassert_true(rc == 0, "sensor_trigger_set failed: %d", rc); - qenc_emulate_start(K_MSEC(10), true); + qenc_emulate_start(loopback, K_MSEC(10), true); /* emulation working, handler should be called */ rc = k_sem_take(&sem, K_MSEC(200)); @@ -168,7 +194,7 @@ ZTEST(qdec_sensor, test_sensor_trigger_set_and_disable) rc = k_sem_take(&sem, K_MSEC(200)); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(loopback->qdec); } /* there should be no triggers now*/ @@ -176,199 +202,238 @@ ZTEST(qdec_sensor, test_sensor_trigger_set_and_disable) zassert_true(rc == -EAGAIN, "qdec handler should not be triggered (%d)", rc); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(loopback->qdec); } /* register empty trigger - disable trigger */ - rc = sensor_trigger_set(qdec_dev, &qdec_trigger, NULL); + rc = sensor_trigger_set(loopback->qdec, &qdec_trigger, NULL); zassert_true(rc == 0, "sensor_trigger_set failed: %d", rc); - qenc_emulate_start(K_MSEC(10), true); + qenc_emulate_start(loopback, K_MSEC(10), true); /* emulation working, but handler not set, thus should not be called */ rc = k_sem_take(&sem, K_MSEC(200)); zassert_true(rc == -EAGAIN, "qdec handler should not be triggered (%d)", rc); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(loopback->qdec); } } /** - * @brief sensor_trigger_set test + * @brief sensor_trigger_set test disable trigger * - * Confirm trigger happens after set + * Confirm trigger happens after set and stops after being disabled * */ -ZTEST(qdec_sensor, test_sensor_trigger_set) +ZTEST(qdec_sensor, test_sensor_trigger_set_and_disable) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_trigger_set_and_disable(&loopbacks[i]); + } +} + +static void sensor_trigger_set_test(struct qdec_qenc_loopback *loopback) { int rc; struct sensor_value val = {0}; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(loopback->qdec); } qdec_trigger.type = SENSOR_TRIG_DATA_READY; qdec_trigger.chan = SENSOR_CHAN_ROTATION; - rc = sensor_trigger_set(qdec_dev, &qdec_trigger, qdec_trigger_handler); + rc = sensor_trigger_set(loopback->qdec, &qdec_trigger, qdec_trigger_handler); zassume_true(rc != -ENOSYS, "sensor_trigger_set not supported"); zassert_true(rc == 0, "sensor_trigger_set failed: %d", rc); - qenc_emulate_start(K_MSEC(10), true); + qenc_emulate_start(loopback, K_MSEC(10), true); /* emulation working now */ rc = k_sem_take(&sem, K_MSEC(200)); zassert_true(rc == 0, "qdec handler should be triggered (%d)", rc); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(loopback->qdec); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val); + rc = sensor_channel_get(loopback->qdec, SENSOR_CHAN_ROTATION, &val); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); TC_PRINT("QDEC reading: %d\n", val.val1); zassert_true(val.val1 != 0, "No readings from QDEC"); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(loopback->qdec); } + + qenc_emulate_stop(); + /* emulation not working, but there may be old trigger which needs to be cleaned up */ + rc = k_sem_take(&sem, K_MSEC(200)); } /** - * @brief sensor_trigger_set test negative + * @brief sensor_trigger_set test * - * Confirm setting trigger with invalid data does not work + * Confirm trigger happens after set * */ -ZTEST(qdec_sensor, test_sensor_trigger_set_negative) +ZTEST(qdec_sensor, test_sensor_trigger_set) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_trigger_set_test(&loopbacks[i]); + } +} + +static void sensor_trigger_set_negative(struct qdec_qenc_loopback *loopback) { int rc; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(loopback->qdec); } - rc = sensor_trigger_set(qdec_dev, &qdec_trigger, qdec_trigger_handler); + rc = sensor_trigger_set(loopback->qdec, &qdec_trigger, qdec_trigger_handler); zassume_true(rc != -ENOSYS, "sensor_trigger_set not supported"); qdec_trigger.type = SENSOR_TRIG_MAX; qdec_trigger.chan = SENSOR_CHAN_ROTATION; - rc = sensor_trigger_set(qdec_dev, &qdec_trigger, qdec_trigger_handler); + rc = sensor_trigger_set(loopback->qdec, &qdec_trigger, qdec_trigger_handler); zassume_true(rc < 0, "sensor_trigger_set should fail due to invalid trigger type"); qdec_trigger.type = SENSOR_TRIG_DATA_READY; qdec_trigger.chan = SENSOR_CHAN_MAX; - rc = sensor_trigger_set(qdec_dev, &qdec_trigger, qdec_trigger_handler); + rc = sensor_trigger_set(loopback->qdec, &qdec_trigger, qdec_trigger_handler); zassume_true(rc < 0, "sensor_trigger_set should fail due to invalid channel"); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(loopback->qdec); } } /** - * @brief QDEC readings tests + * @brief sensor_trigger_set test negative * - * Valid reading from QDEC base on simulated signal + * Confirm setting trigger with invalid data does not work * */ -ZTEST(qdec_sensor, test_qdec_readings) +ZTEST(qdec_sensor, test_sensor_trigger_set_negative) { - if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); - } - - qenc_emulate_verify_reading(10, 100, true, false); - qenc_emulate_verify_reading(2, 500, true, false); - qenc_emulate_verify_reading(10, 200, false, false); - qenc_emulate_verify_reading(1, 1000, false, true); - qenc_emulate_verify_reading(1, 1000, true, true); - - if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_trigger_set_negative(&loopbacks[i]); } } /** - * @brief sensor_channel_get test with no emulation + * @brief QDEC readings tests * - * Confirm getting empty reading from QDEC + * Valid reading from QDEC base on simulated signal * */ -ZTEST(qdec_sensor, test_sensor_channel_get_empty) +ZTEST(qdec_sensor, test_qdec_readings) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { + pm_device_runtime_get(loopbacks[i].qdec); + } + + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + qenc_emulate_verify_reading(&loopbacks[i], 10, 100, true, false); + qenc_emulate_verify_reading(&loopbacks[i], 2, 500, true, false); + qenc_emulate_verify_reading(&loopbacks[i], 10, 200, false, false); + qenc_emulate_verify_reading(&loopbacks[i], 1, 1000, false, true); + qenc_emulate_verify_reading(&loopbacks[i], 1, 1000, true, true); + + if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { + pm_device_runtime_put(loopbacks[i].qdec); + } + } +} + +static void sensor_channel_get_empty(const struct device *const dev) { int rc; struct sensor_value val = {0}; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(dev); } /* wait for potential new readings */ k_msleep(100); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(dev); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); /* get readings but ignore them, as they may include reading from time * when emulation was still working (i.e. during previous test) */ - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val); + rc = sensor_channel_get(dev, SENSOR_CHAN_ROTATION, &val); zassert_true(rc == 0, "Failed to get sample (%d)", rc); /* wait for potential new readings */ k_msleep(100); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(dev); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); /* emulation was not working, expect no readings */ - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val); + rc = sensor_channel_get(dev, SENSOR_CHAN_ROTATION, &val); zassert_true(rc == 0, "Failed to get sample (%d)", rc); zassert_true(val.val1 == 0, "Expected no readings but got: %d", val.val1); zassert_true(val.val2 == 0, "Expected no readings but got: %d", val.val2); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(dev); } } /** - * @brief sensor_channel_get test with emulation + * @brief sensor_channel_get test with no emulation * - * Confirm getting readings from QDEC + * Confirm getting empty reading from QDEC * */ -ZTEST(qdec_sensor, test_sensor_channel_get) +ZTEST(qdec_sensor, test_sensor_channel_get_empty) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_channel_get_empty(loopbacks[i].qdec); + } +} + +static void sensor_channel_get_test(struct qdec_qenc_loopback *loopback) { int rc; struct sensor_value val_first = {0}; struct sensor_value val_second = {0}; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(loopback->qdec); } - qenc_emulate_start(K_MSEC(10), true); + qenc_emulate_start(loopback, K_MSEC(10), true); /* wait for some readings*/ k_msleep(100); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(loopback->qdec); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val_first); + rc = sensor_channel_get(loopback->qdec, SENSOR_CHAN_ROTATION, &val_first); zassert_true(rc == 0, "Failed to get sample (%d)", rc); zassert_true(val_first.val1 != 0, "No readings from QDEC"); /* wait for more readings*/ k_msleep(200); - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_ROTATION, &val_second); + rc = sensor_channel_get(loopback->qdec, SENSOR_CHAN_ROTATION, &val_second); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); zassert_true(val_second.val1 != 0, "No readings from QDEC"); @@ -386,81 +451,111 @@ ZTEST(qdec_sensor, test_sensor_channel_get) val_second.val2); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(loopback->qdec); } } /** - * @brief sensor_channel_get test negative + * @brief sensor_channel_get test with emulation * - * Confirm getting readings from QDEC with invalid channel + * Confirm getting readings from QDEC * */ -ZTEST(qdec_sensor, test_sensor_channel_get_negative) +ZTEST(qdec_sensor, test_sensor_channel_get) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_channel_get_test(&loopbacks[i]); + } +} + +static void sensor_channel_get_negative(struct qdec_qenc_loopback *loopback) { int rc; struct sensor_value val = {0}; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(loopback->qdec); } - qenc_emulate_start(K_MSEC(10), true); + qenc_emulate_start(loopback, K_MSEC(10), true); /* wait for some readings*/ k_msleep(100); - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(loopback->qdec); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); - rc = sensor_channel_get(qdec_dev, SENSOR_CHAN_MAX, &val); + rc = sensor_channel_get(loopback->qdec, SENSOR_CHAN_MAX, &val); zassert_true(rc < 0, "Should failed to get sample (%d)", rc); zassert_true(val.val1 == 0, "Some readings from QDEC: %d", val.val1); zassert_true(val.val2 == 0, "Some readings from QDEC: %d", val.val2); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(loopback->qdec); } } /** - * @brief sensor_sample_fetch(_chan) test + * @brief sensor_channel_get test negative * - * Confirm fetching work with QDEC specific channel - rotation + * Confirm getting readings from QDEC with invalid channel * */ -ZTEST(qdec_sensor, test_sensor_sample_fetch) +ZTEST(qdec_sensor, test_sensor_channel_get_negative) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_channel_get_negative(&loopbacks[i]); + } +} + +static void sensor_sample_fetch_test(const struct device *const dev) { int rc; if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_get(qdec_dev); + pm_device_runtime_get(dev); } - rc = sensor_sample_fetch(qdec_dev); + rc = sensor_sample_fetch(dev); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); - rc = sensor_sample_fetch_chan(qdec_dev, SENSOR_CHAN_ROTATION); + rc = sensor_sample_fetch_chan(dev, SENSOR_CHAN_ROTATION); zassert_true(rc == 0, "Failed to fetch sample (%d)", rc); - rc = sensor_sample_fetch_chan(qdec_dev, SENSOR_CHAN_MAX); + rc = sensor_sample_fetch_chan(dev, SENSOR_CHAN_MAX); zassert_true(rc < 0, "Should fail to fetch sample from invalid channel (%d)", rc); if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { - pm_device_runtime_put(qdec_dev); + pm_device_runtime_put(dev); } } -static void *setup(void) +/** + * @brief sensor_sample_fetch(_chan) test + * + * Confirm fetching work with QDEC specific channel - rotation + * + */ +ZTEST(qdec_sensor, test_sensor_sample_fetch) { - int rc; + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + TC_PRINT("Testing QDEC index %d, address: %p\n", i, loopbacks[i].qdec); + sensor_sample_fetch_test(loopbacks[i].qdec); + } +} - rc = device_is_ready(qdec_dev); - zassert_true(rc, "QDEC device not ready: %d", rc); +static void *setup(void) +{ + for (size_t i = 0; i < TESTED_QDEC_COUNT; i++) { + int rc = device_is_ready(loopbacks[i].qdec); - qenc_emulate_setup_pin(&phase_a); - qenc_emulate_setup_pin(&phase_b); + zassert_true(rc, "QDEC index %d not ready: %d", i, rc); + qenc_emulate_setup_pin(&loopbacks[i].qenc_phase_a); + qenc_emulate_setup_pin(&loopbacks[i].qenc_phase_b); + } return NULL; } diff --git a/tests/bsim/bluetooth/host/l2cap/many_conns/src/main.c b/tests/bsim/bluetooth/host/l2cap/many_conns/src/main.c index ff9f3030d1e..a4f45bc1890 100644 --- a/tests/bsim/bluetooth/host/l2cap/many_conns/src/main.c +++ b/tests/bsim/bluetooth/host/l2cap/many_conns/src/main.c @@ -29,7 +29,7 @@ DEFINE_FLAG_STATIC(flag_l2cap_connected); #define NUM_PERIPHERALS CONFIG_BT_MAX_CONN #define L2CAP_CHANS NUM_PERIPHERALS #define SDU_NUM 1 -#define SDU_LEN 10 +#define SDU_LEN 23 /* Only one SDU per link will be transmitted */ NET_BUF_POOL_DEFINE(sdu_tx_pool, diff --git a/tests/net/conn_mgr_conn/src/main.c b/tests/net/conn_mgr_conn/src/main.c index b66e246b12d..940d142b8db 100644 --- a/tests/net/conn_mgr_conn/src/main.c +++ b/tests/net/conn_mgr_conn/src/main.c @@ -95,7 +95,7 @@ static struct event_stats { struct net_mgmt_event_callback conn_mgr_conn_callback; static void conn_mgr_conn_handler(struct net_mgmt_event_callback *cb, - uint32_t event, struct net_if *iface) + uint64_t event, struct net_if *iface) { k_mutex_lock(&event_mutex, K_FOREVER); diff --git a/tests/net/conn_mgr_monitor/src/main.c b/tests/net/conn_mgr_monitor/src/main.c index cd8242c10d1..e1e1cd67081 100644 --- a/tests/net/conn_mgr_monitor/src/main.c +++ b/tests/net/conn_mgr_monitor/src/main.c @@ -38,12 +38,12 @@ #define DAD_WAIT_TIME EVENT_WAIT_TIME #endif -#define TEST_EXPECT_L4_CONNECTED BIT(NET_EVENT_L4_CMD_CONNECTED) -#define TEST_EXPECT_L4_DISCONNECTED BIT(NET_EVENT_L4_CMD_DISCONNECTED) -#define TEST_EXPECT_L4_IPV6_CONNECTED BIT(NET_EVENT_L4_CMD_IPV6_CONNECTED) -#define TEST_EXPECT_L4_IPV6_DISCONNECTED BIT(NET_EVENT_L4_CMD_IPV6_DISCONNECTED) -#define TEST_EXPECT_L4_IPV4_CONNECTED BIT(NET_EVENT_L4_CMD_IPV4_CONNECTED) -#define TEST_EXPECT_L4_IPV4_DISCONNECTED BIT(NET_EVENT_L4_CMD_IPV4_DISCONNECTED) +#define TEST_EXPECT_L4_CONNECTED NET_EVENT_L4_CMD_CONNECTED +#define TEST_EXPECT_L4_DISCONNECTED NET_EVENT_L4_CMD_DISCONNECTED +#define TEST_EXPECT_L4_IPV6_CONNECTED NET_EVENT_L4_CMD_IPV6_CONNECTED +#define TEST_EXPECT_L4_IPV6_DISCONNECTED NET_EVENT_L4_CMD_IPV6_DISCONNECTED +#define TEST_EXPECT_L4_IPV4_CONNECTED NET_EVENT_L4_CMD_IPV4_CONNECTED +#define TEST_EXPECT_L4_IPV4_DISCONNECTED NET_EVENT_L4_CMD_IPV4_DISCONNECTED #define TEST_EXPECT_CLEAR(event) (global_stats.expected_events &= ~event) @@ -162,7 +162,7 @@ static struct test_stats get_reset_stats(void) /* Callback hooks */ struct net_mgmt_event_callback l4_callback; -void l4_handler(struct net_mgmt_event_callback *cb, uint32_t event, struct net_if *iface) +void l4_handler(struct net_mgmt_event_callback *cb, uint64_t event, struct net_if *iface) { if (event == NET_EVENT_L4_CONNECTED) { k_mutex_lock(&stats_mutex, K_FOREVER); @@ -187,7 +187,7 @@ void l4_handler(struct net_mgmt_event_callback *cb, uint32_t event, struct net_i struct net_mgmt_event_callback conn_callback; -void conn_handler(struct net_mgmt_event_callback *cb, uint32_t event, struct net_if *iface) +void conn_handler(struct net_mgmt_event_callback *cb, uint64_t event, struct net_if *iface) { if (event == NET_EVENT_L4_IPV6_CONNECTED) { k_mutex_lock(&stats_mutex, K_FOREVER); @@ -224,7 +224,7 @@ void conn_handler(struct net_mgmt_event_callback *cb, uint32_t event, struct net } } -static void wait_for_events(uint32_t event_mask, k_timeout_t timeout) +static void wait_for_events(uint64_t event_mask, k_timeout_t timeout) { k_mutex_lock(&stats_mutex, K_FOREVER); k_sem_reset(&event_sem); diff --git a/tests/net/conn_mgr_nsos/src/main.c b/tests/net/conn_mgr_nsos/src/main.c index 41c4273f262..d4e014accff 100644 --- a/tests/net/conn_mgr_nsos/src/main.c +++ b/tests/net/conn_mgr_nsos/src/main.c @@ -15,7 +15,7 @@ K_SEM_DEFINE(l4_connected, 0, 1); K_SEM_DEFINE(l4_disconnected, 0, 1); -static void l4_event_handler(struct net_mgmt_event_callback *cb, uint32_t event, +static void l4_event_handler(struct net_mgmt_event_callback *cb, uint64_t event, struct net_if *iface) { switch (event) { diff --git a/tests/net/dhcpv4/client/prj.conf b/tests/net/dhcpv4/client/prj.conf index 5b126f90a14..5ac77585482 100644 --- a/tests/net/dhcpv4/client/prj.conf +++ b/tests/net/dhcpv4/client/prj.conf @@ -20,6 +20,7 @@ CONFIG_NET_MGMT_EVENT=y CONFIG_NET_MGMT_EVENT_INFO=y CONFIG_DNS_RESOLVER=y +CONFIG_DNS_RESOLVER_MAX_SERVERS=3 # Turn off UDP checksum checking as the test fails otherwise. CONFIG_NET_UDP_CHECKSUM=n @@ -31,3 +32,5 @@ CONFIG_NET_DHCPV4_INITIAL_DELAY_MAX=2 CONFIG_NET_DHCPV4_LOG_LEVEL_DBG=y CONFIG_LOG_BUFFER_SIZE=8192 + +CONFIG_ZVFS_POLL_MAX=5 diff --git a/tests/net/dhcpv4/client/src/main.c b/tests/net/dhcpv4/client/src/main.c index 654a98d2cbe..7c87ab4d478 100644 --- a/tests/net/dhcpv4/client/src/main.c +++ b/tests/net/dhcpv4/client/src/main.c @@ -493,7 +493,7 @@ static struct net_dhcpv4_option_callback opt_vs_invalid_cb; static int event_count; static void receiver_cb(struct net_mgmt_event_callback *cb, - uint32_t nm_event, struct net_if *iface) + uint64_t nm_event, struct net_if *iface) { if (nm_event != NET_EVENT_IPV4_ADDR_ADD && nm_event != NET_EVENT_DNS_SERVER_ADD && @@ -694,7 +694,7 @@ ZTEST(dhcpv4_tests, test_dhcp) #elif defined(CONFIG_NET_DHCPV4_OPTION_CALLBACKS) while (event_count < 10) { #elif defined(CONFIG_NET_DHCPV4_OPTION_PRINT_IGNORED) - while (event_count < 2) { + while (event_count < 1) { #else while (event_count < 5) { #endif diff --git a/tests/net/dhcpv6/src/main.c b/tests/net/dhcpv6/src/main.c index c5046a2746a..b1375383c67 100644 --- a/tests/net/dhcpv6/src/main.c +++ b/tests/net/dhcpv6/src/main.c @@ -178,7 +178,7 @@ static struct net_pkt *test_dhcpv6_create_message( return NULL; } -static void evt_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void evt_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); diff --git a/tests/net/hostname/src/main.c b/tests/net/hostname/src/main.c index bfc2fd926f8..b5c0664d2ef 100644 --- a/tests/net/hostname/src/main.c +++ b/tests/net/hostname/src/main.c @@ -101,7 +101,7 @@ static void net_iface_init(struct net_if *iface) #ifdef CONFIG_NET_MGMT_EVENT static void hostname_changed(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_HOSTNAME_CHANGED) { #ifdef CONFIG_NET_MGMT_EVENT_INFO diff --git a/tests/net/ieee802154/l2/src/ieee802154_shell_test.c b/tests/net/ieee802154/l2/src/ieee802154_shell_test.c index 0281b699edb..5964025e023 100644 --- a/tests/net/ieee802154/l2/src/ieee802154_shell_test.c +++ b/tests/net/ieee802154/l2/src/ieee802154_shell_test.c @@ -50,7 +50,7 @@ static bool expected_association_permitted_bit; #define EXPECTED_PAYLOAD_DATA EXPECTED_ENDDEVICE_EXT_ADDR_LE #define EXPECTED_PAYLOAD_LEN 8 -static void scan_result_cb(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, +static void scan_result_cb(struct net_mgmt_event_callback *cb, uint64_t mgmt_event, struct net_if *iface) { struct ieee802154_context *ctx = net_if_l2_data(iface); diff --git a/tests/net/igmp/src/main.c b/tests/net/igmp/src/main.c index 7878c5953eb..e2f201dd4ee 100644 --- a/tests/net/igmp/src/main.c +++ b/tests/net/igmp/src/main.c @@ -227,7 +227,7 @@ NET_DEVICE_INIT(net_test_igmp, "net_test_igmp", 127); static void group_joined(struct net_mgmt_event_callback *cb, - uint32_t nm_event, struct net_if *iface) + uint64_t nm_event, struct net_if *iface) { if (nm_event != NET_EVENT_IPV4_MCAST_JOIN) { /* Spurious callback. */ @@ -240,7 +240,7 @@ static void group_joined(struct net_mgmt_event_callback *cb, } static void group_left(struct net_mgmt_event_callback *cb, - uint32_t nm_event, struct net_if *iface) + uint64_t nm_event, struct net_if *iface) { if (nm_event != NET_EVENT_IPV4_MCAST_LEAVE) { /* Spurious callback. */ @@ -253,7 +253,7 @@ static void group_left(struct net_mgmt_event_callback *cb, } static struct mgmt_events { - uint32_t event; + uint64_t event; net_mgmt_event_handler_t handler; struct net_mgmt_event_callback cb; } mgmt_events[] = { diff --git a/tests/net/lib/dns_addremove/src/main.c b/tests/net/lib/dns_addremove/src/main.c index 1b6f55efd73..f8f9fdc1c80 100644 --- a/tests/net/lib/dns_addremove/src/main.c +++ b/tests/net/lib/dns_addremove/src/main.c @@ -139,7 +139,7 @@ NET_DEVICE_INIT_INSTANCE(net_iface1_test, 127); static void dns_evt_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { if (mgmt_event == NET_EVENT_DNS_SERVER_ADD) { k_sem_give(&dns_added); diff --git a/tests/net/mgmt/src/mgmt.c b/tests/net/mgmt/src/mgmt.c index 004b60adb97..288dcc353b2 100644 --- a/tests/net/mgmt/src/mgmt.c +++ b/tests/net/mgmt/src/mgmt.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_MGMT_EVENT_LOG_LEVEL); MAX(sizeof(TEST_INFO_STRING), sizeof(struct in6_addr)) /* Notifier infra */ -static uint32_t event2throw; +static uint64_t event2throw; static uint32_t throw_times; static uint32_t throw_sleep; static bool with_info; @@ -38,7 +38,7 @@ static struct k_thread thrower_thread_data; static struct k_sem thrower_lock; /* Receiver infra */ -static uint32_t rx_event; +static uint64_t rx_event; static uint32_t rx_calls; static size_t info_length_in_test; static struct net_mgmt_event_callback rx_cb; @@ -49,7 +49,7 @@ static struct in6_addr addr6 = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, static char info_data[TEST_MGMT_EVENT_INFO_SIZE]; -static int test_mgmt_request(uint32_t mgmt_request, +static int test_mgmt_request(uint64_t mgmt_request, struct net_if *iface, void *data, uint32_t len) { uint32_t *test_data = data; @@ -67,14 +67,14 @@ static int test_mgmt_request(uint32_t mgmt_request, NET_MGMT_REGISTER_REQUEST_HANDLER(TEST_MGMT_REQUEST, test_mgmt_request); -static void test_mgmt_event_handler(uint32_t mgmt_event, struct net_if *iface, void *info, +static void test_mgmt_event_handler(uint64_t mgmt_event, struct net_if *iface, void *info, size_t info_length, void *user_data) { if (!with_static) { return; } - TC_PRINT("\t\tReceived static event 0x%08X\n", mgmt_event); + TC_PRINT("\t\tReceived static event 0x%" PRIx64 "\n", mgmt_event); ARG_UNUSED(user_data); @@ -144,7 +144,7 @@ static void thrower_thread(void *p1, void *p2, void *p3) while (1) { k_sem_take(&thrower_lock, K_FOREVER); - TC_PRINT("\tThrowing event 0x%08X %u times\n", + TC_PRINT("\tThrowing event 0x%" PRIx64 " %u times\n", event2throw, throw_times); for (; throw_times; throw_times--) { @@ -168,9 +168,9 @@ static void thrower_thread(void *p1, void *p2, void *p3) } static void receiver_cb(struct net_mgmt_event_callback *cb, - uint32_t nm_event, struct net_if *iface) + uint64_t nm_event, struct net_if *iface) { - TC_PRINT("\t\tReceived event 0x%08X\n", nm_event); + TC_PRINT("\t\tReceived event 0x%" PRIx64 "\n", nm_event); if (with_info && cb->info) { if (cb->info_length != info_length_in_test) { @@ -208,14 +208,15 @@ static int sending_event(uint32_t times, bool receiver, bool info) k_msleep(THREAD_SLEEP); if (receiver) { - TC_PRINT("\tReceived 0x%08X %u times\n", + TC_PRINT("\tReceived 0x%" PRIx64 " %u times\n", rx_event, rx_calls); zassert_equal(rx_event, event2throw, "rx_event check failed"); zassert_equal(rx_calls, times, "rx_calls check failed"); net_mgmt_del_event_callback(&rx_cb); - rx_event = rx_calls = 0U; + rx_event = 0ULL; + rx_calls = 0U; } return TC_PASS; @@ -233,7 +234,7 @@ static int test_sending_event_info(uint32_t times, bool receiver) static int test_synchronous_event_listener(uint32_t times, bool on_iface) { - uint32_t event_mask; + uint64_t event_mask; int ret; TC_PRINT("- Synchronous event listener %s\n", @@ -283,13 +284,14 @@ static int test_static_event_listener(uint32_t times, bool info) /* Let the network stack to proceed */ k_msleep(THREAD_SLEEP); - TC_PRINT("\tReceived 0x%08X %u times\n", + TC_PRINT("\tReceived 0x%" PRIx64 " %u times\n", rx_event, rx_calls); zassert_equal(rx_event, event2throw, "rx_event check failed"); zassert_equal(rx_calls, times, "rx_calls check failed"); - rx_event = rx_calls = 0U; + rx_event = 0ULL; + rx_calls = 0U; with_static = false; return TC_PASS; @@ -297,12 +299,12 @@ static int test_static_event_listener(uint32_t times, bool info) static void initialize_event_tests(void) { - event2throw = 0U; + event2throw = 0ULL; throw_times = 0U; throw_sleep = 0; with_info = false; - rx_event = 0U; + rx_event = 0ULL; rx_calls = 0U; k_sem_init(&thrower_lock, 0, UINT_MAX); @@ -318,9 +320,9 @@ static void initialize_event_tests(void) NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); } -static int test_core_event(uint32_t event, bool (*func)(void)) +static int test_core_event(uint64_t event, bool (*func)(void)) { - TC_PRINT("- Triggering core event: 0x%08X\n", event); + TC_PRINT("- Triggering core event: 0x%" PRIx64 "\n", event); info_length_in_test = sizeof(struct in6_addr); memcpy(info_data, &addr6, sizeof(addr6)); @@ -336,10 +338,11 @@ static int test_core_event(uint32_t event, bool (*func)(void)) zassert_true(rx_calls > 0 && rx_calls != -1, "rx_calls empty"); zassert_equal(rx_event, event, "rx_event check failed, " - "0x%08x vs 0x%08x", rx_event, event); + "0x%" PRIx64 " vs 0x%" PRIx64, rx_event, event); net_mgmt_del_event_callback(&rx_cb); - rx_event = rx_calls = 0U; + rx_event = 0ULL; + rx_calls = 0U; return TC_PASS; } @@ -426,7 +429,7 @@ ZTEST(mgmt_fn_test_suite, test_mgmt) static K_SEM_DEFINE(wait_for_event_processing, 0, 1); static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, struct net_if *iface) + uint64_t mgmt_event, struct net_if *iface) { static int cb_call_count; diff --git a/tests/net/mld/src/main.c b/tests/net/mld/src/main.c index 1c95fe5409d..0036b5853af 100644 --- a/tests/net/mld/src/main.c +++ b/tests/net/mld/src/main.c @@ -238,7 +238,7 @@ static void test_iface_carrier_off_on(void) } static void group_joined(struct net_mgmt_event_callback *cb, - uint32_t nm_event, struct net_if *iface) + uint64_t nm_event, struct net_if *iface) { if (nm_event != NET_EVENT_IPV6_MCAST_JOIN) { /* Spurious callback. */ @@ -254,7 +254,7 @@ static void group_joined(struct net_mgmt_event_callback *cb, } static void group_left(struct net_mgmt_event_callback *cb, - uint32_t nm_event, struct net_if *iface) + uint64_t nm_event, struct net_if *iface) { if (nm_event != NET_EVENT_IPV6_MCAST_LEAVE) { /* Spurious callback. */ @@ -270,7 +270,7 @@ static void group_left(struct net_mgmt_event_callback *cb, } static struct mgmt_events { - uint32_t event; + uint64_t event; net_mgmt_event_handler_t handler; struct net_mgmt_event_callback cb; } mgmt_events[] = { diff --git a/tests/net/pmtu/src/main.c b/tests/net/pmtu/src/main.c index 54d225a259e..d744a4415f4 100644 --- a/tests/net/pmtu/src/main.c +++ b/tests/net/pmtu/src/main.c @@ -103,7 +103,7 @@ static K_SEM_DEFINE(wait_pmtu_changed, 0, UINT_MAX); static bool is_pmtu_changed; static void ipv6_pmtu_changed(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); @@ -123,7 +123,7 @@ static void ipv6_pmtu_changed(struct net_mgmt_event_callback *cb, } static void ipv4_pmtu_changed(struct net_mgmt_event_callback *cb, - uint32_t mgmt_event, + uint64_t mgmt_event, struct net_if *iface) { ARG_UNUSED(cb); @@ -143,7 +143,7 @@ static void ipv4_pmtu_changed(struct net_mgmt_event_callback *cb, } static struct mgmt_events { - uint32_t event; + uint64_t event; net_mgmt_event_handler_t handler; struct net_mgmt_event_callback cb; } mgmt_events[] = { diff --git a/tests/net/socket/net_mgmt/src/main.c b/tests/net/socket/net_mgmt/src/main.c index a5d6ead4679..89901beda7b 100644 --- a/tests/net/socket/net_mgmt/src/main.c +++ b/tests/net/socket/net_mgmt/src/main.c @@ -20,6 +20,19 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL); #define STACK_SIZE 1024 #define THREAD_PRIORITY K_PRIO_COOP(8) +/* Use a base value for socket options that are not implemented. + * This is used to check if the socket option is implemented or not. + */ +#define NOT_IMPLEMENTED_SOCKET_OPTION_BASE (INT32_MAX - 1000) + +#if !defined(SO_NET_MGMT_ETHERNET_GET_PRIORITY_QUEUES_NUM) +#define SO_NET_MGMT_ETHERNET_GET_PRIORITY_QUEUES_NUM (NOT_IMPLEMENTED_SOCKET_OPTION_BASE + 1) +#endif /* !defined(SO_NET_MGMT_ETHERNET_GET_PRIORITY_QUEUES_NUM) */ + +#if !defined(SO_NET_MGMT_ETHERNET_SET_MAC_ADDRESS) +#define SO_NET_MGMT_ETHERNET_SET_MAC_ADDRESS (NOT_IMPLEMENTED_SOCKET_OPTION_BASE + 2) +#endif /* !defined(SO_NET_MGMT_ETHERNET_SET_MAC_ADDRESS) */ + static struct net_if *default_iface; static ZTEST_BMEM int fd; @@ -502,7 +515,7 @@ static void test_ethernet_set_qav(void) params.qav_param.enabled = true; ret = zsock_setsockopt(fd, SOL_NET_MGMT_RAW, - NET_REQUEST_ETHERNET_SET_QAV_PARAM, + SO_NET_MGMT_ETHERNET_SET_QAV_PARAM, ¶ms, sizeof(params)); zassert_equal(ret, 0, "Cannot set Qav parameters"); } @@ -529,7 +542,7 @@ static void test_ethernet_get_qav(void) params.qav_param.type = ETHERNET_QAV_PARAM_TYPE_STATUS; ret = zsock_getsockopt(fd, SOL_NET_MGMT_RAW, - NET_REQUEST_ETHERNET_GET_QAV_PARAM, + SO_NET_MGMT_ETHERNET_GET_QAV_PARAM, ¶ms, &optlen); zassert_equal(ret, 0, "Cannot get Qav parameters (%d)", ret); zassert_equal(optlen, sizeof(params), "Invalid optlen (%d)", optlen); @@ -556,7 +569,7 @@ static void test_ethernet_get_unknown_option(void) memset(¶ms, 0, sizeof(params)); ret = zsock_getsockopt(fd, SOL_NET_MGMT_RAW, - NET_REQUEST_ETHERNET_GET_PRIORITY_QUEUES_NUM, + SO_NET_MGMT_ETHERNET_GET_PRIORITY_QUEUES_NUM, ¶ms, &optlen); zassert_equal(ret, -1, "Could get prio queue parameters (%d)", errno); zassert_equal(errno, EINVAL, "prio queue get parameters"); @@ -581,7 +594,7 @@ static void test_ethernet_set_unknown_option(void) memset(¶ms, 0, sizeof(params)); ret = zsock_setsockopt(fd, SOL_NET_MGMT_RAW, - NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, + SO_NET_MGMT_ETHERNET_SET_MAC_ADDRESS, ¶ms, optlen); zassert_equal(ret, -1, "Could set promisc_mode parameters (%d)", errno); zassert_equal(errno, EINVAL, "promisc_mode set parameters"); diff --git a/west.yml b/west.yml index 41fa45c8693..853d84113a6 100644 --- a/west.yml +++ b/west.yml @@ -325,7 +325,7 @@ manifest: groups: - tools - name: nrf_hw_models - revision: 968d55ff22579080466bf2f482596dd6e35361c6 + revision: 8b6001d6bdd9e2c8bb858fdb26f696f6d5f73db5 path: modules/bsim_hw_models/nrf_hw_models - name: nrf_wifi revision: 787eea1a3c8dd13c86214e204a919e6f9bcebf91