Commit graph

1151 commits

Author SHA1 Message Date
Jukka Rissanen
5a9a39caf3 net: mgmt: Convert the mgmt API to use 64-bit masks
Instead of using 32 bit enum values for event numbers, convert
the code to use 64 bit long bit fields. This means that the
user API is changed to use 64 bit event values instead of 32
bit event values.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 10:54:44 +02:00
Pieter De Gendt
b3316fc4fd net: l2: wifi: shell: Fix passphrase long opt help text
A passphrase needs to be passed with --passphrase instead of --psk.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-17 17:47:11 +02:00
Jukka Rissanen
8704b3add7 net: ppp: Bind DNS to device ppp network interface
Make sure received DNS server information is bound to the
ppp network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Keith Packard
97f96afbd7 linker_script: Remove all SUBALIGN usage for iterable sections
SUBALIGN forces alignment to the specified value, even if the object
requires stricter alignment. This causes mis-aligned access when accessing
the resulting value.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-17 16:06:21 +02:00
Robert Lubos
86244a9c54 net: stats: Make byte counters 64-bit
In high throughput tests it's fairly easy to overflow the current 32-bit
byte counters in net statistics (it's just over 4 GB of data).
Therefore, make the byte counters 64-bit to prevent overflows.
Rearrange some fields to avoid padding.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-06-12 09:36:38 -07:00
Maochen Wang
d4648a6767 net: l2: wifi: fix invalid option error when use -i
For 'wifi connect' or 'wifi ap enable' CMD, there is 'invalid option'
error log when input '-i' parameter. Parsing '-i' can fix this issue.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-06-12 10:24:36 +02:00
Maochen Wang
5bcaf33d79 net: l2: wifi: fix dpp btstrap_gen CMD failure
Input 'wifi dpp btstrap_gen ...' cmd or 'wifi dpp ap_qr_code ...',
the console shows 'wrong parameter count'. Fix the typo of 'wifi
dpp btstrap_gen' and 'wifi dpp ap_qr_code' CMD's parameter count.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-06-12 10:24:36 +02:00
Fin Maaß
ed4d421ace drivers: ethernet: remove phy related configs from eth config
remove phy related configs from eth config.
phy related configs chould go directly into the phy.
Most ethernet drivers didn't support the now removed
functions yet. Users should instead use `phy_configure_link()`
together with the `net_eth_get_phy()` function.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-06-11 10:17:37 -07:00
Arunmani Alagarsamy
0faba15717 net: l2: wifi: Fix mode change issue in Wi-Fi shell
The help message for the wifi mode -s command indicates it sets
the Wi-Fi mode to station. However, the Zephyr Wi-Fi shell subsystem
was incorrectly using a get operation instead of set.

This commit corrects the behavior to properly set the Wi-Fi mode,
aligning the implementation with the help message.

Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
2025-06-10 08:51:15 +02:00
Qiankun Li
f31a411770 drivers: wifi: nxp: Modify shim driver to support btwt changes.
Align struct wlan_btwt_config_t in shim driver
with nxp wifi driver.

Signed-off-by: Qiankun Li <qiankun.li@nxp.com>
2025-06-10 08:47:25 +02:00
Qiankun Li
448b787c82 net: l2: wifi: Modify btwt_setup usage.
Soft ap supports WIFI_BTWT_AGREEMENT_MAX BTWT sessions.
The BTWT parameters for each session can be different.

The current usage can only set one set of parameters.
All sessions follow this set of parameters.

Add enhance code to support setting different
BTWT parameters for every sessions.

Usage:
wifi twt btwt_setup <sta_wait> <offset>
<twtli> <session_num>
<id0> <mantissa0> <exponent0> <nominal_wake0>
<id1> <mantissa1> <exponent1> <nominal_wake1>
<idx> <mantissax> <exponentx> <nominal_wakex>
The total number of '0, 1, ..., x' is session_num

For example:
wifi twt btwt_setup 0 0 0 2 0 112 10 128 1 32 10 64

Signed-off-by: Qiankun Li <qiankun.li@nxp.com>
2025-06-10 08:47:25 +02:00
Chen Tao
b513e08271 net: wifi: fix the bug by non-wifi network call
Added network type check to fix the system crash caused by non-wifi
network card calling wifi api interface

Company:BSH Crop
Signed-off-by: Chen Tao <ct05342@163.com>
2025-05-27 11:51:23 +02:00
Maochen Wang
804e6a22ce net: l2: wifi:fix the parameter count error when start SAP
During previous commit of adding interface arg, wrongly change the
parameter count of 'wifi ap enable' to a small one. Change the value
to 47 can fix this issue and match the need of adding interface arg.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-05-22 17:03:39 +02:00
Chaitanya Tata
3611d5eeaf net: l2: wifi: Add interface arg for all commands
In order to support working with multiple VIFs (e.g., STA + AP) add
interface as an option for all commands.

The interface can belong to same chipset or different (hypothetical).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-05-21 12:34:22 +02:00
Markus Lassila
93c3975fe6 net: l2: ppp: Terminate connection with dormant
When PPP net_if is changed to dormant, the PPP connection
is terminated asynchronously. This is used so that the driver
can terminate the PPP connection gracefully.

Note: net_if_down() is not used as it would require synchronous
operation which would block the system workqueue thus causing
deadlock.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2025-05-14 14:10:21 +02:00
Robert Lubos
be46c94e3e net: l2: openthread: Fix error logs on adding already present address
Error checking of otIp6AddUnicastAddress() and
otIp6SubscribeMulticastAddress() was added recently, however it wasn't
taken into account that those APIs return an error on attempt to
register an IPv6 address that is already present on the OT interface.
Therefore, add more specific error checks, to return silently in case
address was already present.

As those two APIs are not very consistent, and otIp6AddUnicastAddress()
returns OT_ERROR_INVALID_ARGS in such cases, add an extra check if the
address is already present before attempting to register the address.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-13 16:23:37 +02:00
Vytautas Virvičius
9a409d6b00 net: l2: ppp: Explicitly negotiate ACCM
Many cellular modems attempt to negotiate an ACCM value of 0x00000000.
While the PPP driver rejects this by default, it does not propose an
alternative. As a result, some modems default to using 0x00000000 after
LCP negotiation. Because the PPP driver expects all control characters
to be escaped, this causes issues during decoding. This change
negotiates an ACCM value of 0xffffffff to ensure compatibility with such
modems.

Signed-off-by: Vytautas Virvičius <vytautas@virvicius.dev>
2025-05-09 08:23:16 +02:00
Arkadiusz Balys
596844a2cb openthread: Move OpenThread implementation from net to modules
Move OpenThread-related code from
zephyr/subsys/net/l2/openthread/openthread.c to
zephyr/modules/openthread/platform/openthread.c.

The primary goal of this refactor is to enable the use
of OpenThread as an independent module, without the necessity
of Zephyr's networking layer.

This change is particularly beneficial for simple applications
that have their own implementation of the IEEE802.15.4 driver
and do not require a networking layer. These applications can
now disable Zephyr's L2 and IEEE802.15.4 shim layers and
directly use the OpenThread module, saving valuable kilobytes
of memory.

In this approach if the CONFIG_NET_L2_OPENTHREAD
Kconfig option is set, Zephyr's L2 and IEEE802.15.4 layers
will be used, and everything will function as before.
The main difference is the Zephyr's L2 layer now uses
the OpenThread module, no longer implementing it.

While most of the functions in include/net/openthread.h
have been deprecated, they are still available for use to
maintain backwards compatibility.

Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2025-05-05 14:25:13 +02:00
Yangbo Lu
f8b450d6a5 net: gptp: adjust only frequency for continuous synchronization
Current clock synchronization was always stepping clock. This was
causing large offset, and discontiguous ptp hardware clock time.
For TSN hardware, discontiguous ptp hardware clock time was not
able to be used for other TSN protocols.

This patch is to convert to frequency adjustment with a basic
PI control algorithm.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-05-02 09:17:12 +02:00
Fin Maaß
3a195a08da drivers: net: ethernet: change ETHERNET_LINK_*BASE_T
change ETHERNET_LINK_*BASE_T to ETHERNET_LINK_*BASE.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-04-28 09:22:09 +01:00
Emil Lindqvist
500c67fa18 wifi: fix -Wignored-qualifiers warning
Including wifi.h with -Wignored-qualifiers warning enabled gives
a warning. Fix this warning

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2025-04-25 18:58:25 +02:00
Jordan Yates
3772c719e0 net: l2: ethernet: ethernet_ll_prepare_on_ipv4 handling
Shift the error handling for `ethernet_ll_prepare_on_ipv4` out into
`ethernet_send`, since that is the function that needs to handle the
various result types of the ARP process.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-24 22:58:51 +02:00
Jordan Yates
029f542bb4 net: l2: ethernet: arp: unref pkt if queue add fails
Make it clearer that the `net_buf_ref` is for `k_queue_unique_append`,
and reverse the reference if the queue add fails.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-24 22:58:51 +02:00
Jordan Yates
d283130b68 net: l2: ethernet: arp: explicit error codes
Update `net_arp_prepare` to return a return code instead of a pointer,
so that the various results of the function can be differentiated.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-24 22:58:51 +02:00
Jukka Rissanen
0e5df7a67b net: vlan: Avoid printf modifier issue with size_t variable
Change the printf modifier to %zd for size_t variable printout
to avoid compiler warning.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-24 20:27:58 +02:00
Yangbo Lu
f0b1cb578f net: dsa: introduce new DSA framework
The new DSA framework purpose and changes are as below.

- Aligned to Linux DSA framework which has been already mature framework
  for many years, For now in zephyr, the DSA components were splited
  as: switch, port, master(not need driver file for now), slave, and tag.
  Seperated drivers were used for maintaining and developing new
  features.

- The unified dts bindings (aligned to linux) were supported. The port
  driver would parse DTS to decide the port type (master port, slave
  port, or cpu port) to set up the switch. All the ports registered as
  standard ethernet devices. (dsa port and dsa switch tree was not
  supported.)

- How to add DSA device driver based on the framework? All the device
  driver needing to do is providing dsa_spi implementation and private
  data, and calling below initialization.

    DSA_INIT_INSTANCE(n, _dapi, data)

- For switch tag case, recv/xmit helpers in dsa_api could be used for
  taging/untagging. No modified ethernet drivers.
  For no-tag type case, ethernet driver of master port should support
  packet injection/extraction for slave ports leaving NULL recv/xmit.

The dsa_nxp_imx_netc.c driver will be the first example of the new DSA
framework.

The future work for DSA will be supporting bridge for ports. We may align
Linux to give users two options to use DSA device:

- Standalone mode: the switch ports work as regular ethernet ports.

- Bridge mode: switch mode with virtual bridge device which could be
  assigned IP address.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-04-24 01:26:46 +02:00
Yangbo Lu
b22db75cec include: ethernet: rename dsa master/slave to conduit/user
Renamed dsa master/slave to conduit/user for capabilities.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-04-24 01:26:46 +02:00
Yangbo Lu
018a718e12 net: dsa: make current DSA core driver obsolete
Current DSA TX/RX way was hard-coded in ethernet devices driver
with ETH_DSA_SUPPORT and NET_DSA.
This patch is to make such way obsolete, as we actually will support
a better DSA framework to handle this in NET/DSA core driver.
To make legacy devices not affected, below options are used instead.

- ETH_DSA_SUPPORT_DEPRECATED
- NET_DSA_DEPRECATED

Once the legacy devices are converted to new DSA framework, this code
could be removed.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-04-24 01:26:46 +02:00
Arkadiusz Balys
66e78e05d3 openthread: Separate OpenThread Kconfigs from L2 layer
Moved OpenThread-related Kconfigs from L2 layer to
modules/openthread. All of those configs were not strictly related
to the L2 layer, so they fits better to OpenThread module.
This operation allows using OpenThread Kconfigs even if L2 layer is
disabled.

Enabling NET_L2_OPENTHREAD also configures those configs by
selecting the OPENTHREAD kconfig, so there is no change regarding
backwards compatibility. The only change is that the Kconfigs
related to Thread were moved to the modules space, so their
location in the menuconfig also changed.

Once it is done, a choice for setting different L2 implementations
seems to be redundant.

Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2025-04-23 17:54:58 +02:00
Chaitanya Tata
eb1a13eda7 samples: net: wifi: Add two variants of certs
RSA3K based certs are not supported on all platforms, so, keep both
variants, rsa2k (the older certs but with longer expiry 9999 days) and
rsa3k (latest ones) and we can have more variants in this folders.

Also, add a cmake variable to override the path with default as rsa3k.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-04-17 17:22:58 +02:00
Chaitanya Tata
9b68218e9a net: l2: wifi: Make build time certs as optional
Certificates usage depends on STA/AP mode, but we don't have that
information at a build time, so, make all certs as optional and if a
file isn't found then generate an empty header so that corresponding C
code will be built.

Any missing mandatory certificates will be validated before connection
and connection is failed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-04-17 17:22:58 +02:00
Chaitanya Tata
b2e7d7fc0c net: l2: wifi: Add support for run-time certificates
Using TLS credentials library add support for run-time certificates where
the installed certs are retrieved from the credential store (as of now
only volatile backend is tested).

This helps in production environments.

Implements #79564.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-04-17 17:22:58 +02:00
Jukka Rissanen
bd3ce84d91 net: virtual: Hook into packet filter processing
Make sure that we check possible network packet filtering status
before accepting the packet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Eric Ackermann
421a7047e5 net: gPTP: Fix pointer type in gptp_add_port
The number of ports in gptp_domain.default_ds.nb_ports is a uint8_t.
A pointer to it is passed to gptp_add_port.
However, in this method, the pointer is cast to an int pointer.
The C compiler generates an int-size store for this.
In addition to potentially overwriting adjacent attributes, on platforms
such as RISC-V that do not support unaligned accesses, this causes an
exception on access.
This commit casts nb_ports to the correct type, uint8_t.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2025-04-15 19:10:04 +02:00
Robert Lubos
ab448a88db net: openthread: Fix ignored return values in OT utils
Do not ignore return values of OT functions registering IPv6 addresses.
As this is called from the net_mgmt callback context, which returns
void, there's not much that can be done, other than logging the error.

To simplify the logging code and avoid the need to use extra buffer,
use net_sprint_ipv6_addr() networking utility function within the log
message to convert binary address to string.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-11 14:53:59 +02:00
Nitin Pandey
0259bf56c8 driver: wifi: siwx91x: Add check for SAE password
- Modified conditions in WIFI_CONNECT()
  function to reject SAE password and
  PSK based on length parameter

Signed-off-by: Nitin Pandey <nitin.pandey@silabs.com>
2025-04-09 19:32:26 +02:00
Triveni Danda
b3ea4f8d5c net: Fix Kconfig check for enterprise mode
Fix the kconfig check for enterprise crypto support in AP mode.
Also, remove the unnecessary Hostapd enterprise crypto check in
credentials code.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-04-09 12:37:29 +02:00
Robert Lubos
3449e224b4 net: openthread: Add missing error checks
Some OpenThread functions were called without verifying the return
value, which not only is not the best practice, but also could lead to
build warnings with llvm. This commit fixes it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-08 16:12:17 +02:00
Yakun Xu
eddb1af9aa openthread: map Thread network interface state
The current mapping gets the network interface into dormant state when
Thread is not attached. While the node is not capable of doing multi-hop
communication when it's not attached, it should be able to do link-local
communication. This commit changes the mapping to look at OpenThread's
own network interface state instead without further checking Thread's
device role, so that link-local communication is supported when a node
in detached state.

Signed-off-by: Yakun Xu <xyk@google.com>
2025-04-04 12:06:59 +02:00
Jack Chistyakov
dd6adc7cad net: virtual: Clear multicast bit when generating link address
The least significant bit of the first octet of a MAC address is a
unicast/multicast bit. The bit should be cleared when generating a
random link address for a virtual interface. Any frames from such
interface/address will be dropped by the network as invalid if
the multicast bit is set.

Signed-off-by: Jack Chistyakov <jack.chistyakov@outlook.com>
2025-04-01 11:53:02 +02:00
Kapil Bhatt
6f9dbbd54f wifi: utils: Fix crash for scan
The check for index out of bound is missing, It turns into a crash
for input channel more than WIFI_MGMT_SCAN_CHAN_MAX_MANUAL.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-03-31 14:33:22 +02:00
Jukka Rissanen
525b8e58a2 net: l2: virtual: Add support for VPN public/private key set/get
Add support for getting public address and setting private
key for the virtual interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Triveni Danda
589333e4d9 wifi: shell: Add support for EAP-TLS method
Add support to read identity and private key password if
configured in Enterprise mode.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-03-28 16:10:36 +01:00
Cla Mattia Galliard
72fcca0304 net: virtual: Fix compiler warnings related to interface name
Fix compiler warning by adjusting the number of chars copied to the
destination. Compiler does not like if the destination size of the
`strncpy`-operation is the same as the number of characters written. Even
though it is not a bug in this case. Only copying size-1 characters fixes
the warning and exhibits the same behavior.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-27 21:33:40 +01:00
Jukka Rissanen
2e3f564a95 wifi: shell: Allow setting band to 0 in connect
The help text for connect says

[-b, --band] 0: any band (2:2.4GHz, 5:5GHz, 6:6GHz]

but it disallows setting band to 0. Change this and allow
band 0 option when doing normal connect. Disallow setting
the band 0 when enabling AP mode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 16:22:01 +01:00
Jukka Rissanen
a8da7d652f wifi: shell: Map negative status code to valid status codes
The negative status code is actually the errno which we might
get returned from lower levels. For example if user sets -t
(timeout) option, the -ETIMEDOUT might be returned. In this case
map the errno value to connection timeout status value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 16:22:01 +01:00
Jukka Rissanen
92da8cb69f wifi: shell: Return text description of connection error
If "wifi connect" fails, tell user why in textual format.
This helps debugging connectivity issues.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 16:22:01 +01:00
Jukka Rissanen
82b43d50ea net: l2: dummy: Update sent statistics
Update dummy interface sent statistics as that was missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 14:18:25 +01:00
Jukka Rissanen
5076f5eee0 net: l2: virtual: Handle the packet if no attached interfaces
If there are no virtual interfaces attached to this virtual
interface, check if there is a RX handler for this virtual
interface and pass data to it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 14:18:25 +01:00
Robert Lubos
20faa0e114 net: l2: ppp: Make PPP L2 work with packet sockets
Currently, the L2 PPP won't work with AF_PACKET socket family as it only
supports packets from AF_INET/AF_INET6 families. Because of this, it's
not possible to use AF_PACKET RAW or DGRAm sockets with PPP interfaces,
as the packets they generate have family field set to AF_PACKET.

Fix this, by verifying the LL protocol field in the PPP L2 before
passing the packet the respective PPP driver. If the AF_PACKET packet is
received, and the protocol field is set to IP/IPv6, update the packet
family to AF_INET/AF_INET6 accordingly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-18 16:45:53 +01:00