Commit graph

215 commits

Author SHA1 Message Date
Jordan Yates
6a428f19b6 net: wifi_mgmt: make number of scan channels configurable
Make the maximum number of channels that can be manually scanned
configurable by the application. The previous value of 233 was vastly
overallocating memory as the largest band only contains 60 allocated
channels.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 09:48:16 +02:00
Kapil Bhatt
4b9f5cc455 net: l2: wifi: Change arrays to functions
The header file contains mixture of functions and static arrays.
Replacing static arrays to functions.
Initialize functions in C file.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-09-21 09:28:46 +02:00
Jordan Yates
5452665beb net: l2: wifi_mgmt: remove scan kconfig defaults
Remove the wifi_mgmt interface overriding default values with values
from kconfig. The defaults were only applied when a `params` struct was
provided by the application.

This is the case when the application is explicitly setting the options
it wants, why is the mgmt API changing these. When `params` is NULL and
thus modem defaults are requested, these defaults aren't applied. This
is the opposite behaviour from what seems reasonable.

In addition, these options are:
 * Undocumented
 * Using non-trivial string parsing functions (strtok)
 * Adding complexity to the API implementation by forcing support for
   ROM versions of command line arguments.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-20 20:21:49 +01:00
Jordan Yates
dd090f06b7 net: wifi_mgmt: change type of wifi_scan_params->chan
All WiFi channel numbers fit within a 8 bit number, as the maximum
allocated channel is 233. This halves the memory requirement.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-18 10:54:31 +01:00
Vivekananda Uppunda
450dbb15ef net: l2: wifi: Add support for W-Fi mode setting and selection
This change brings in support for setting various Wi-Fi modes and
enables a specific Wi-Fi interface to be also placed into a sniffer
operation via monitor mode and promiscuous mode. A raw TX- packet
Injection mode is also introduced

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2023-09-13 11:47:28 +02:00
Sachin D Kulkarni
85b39b8449 net: wifi: Fix crash in wifi_utils_parse_scan_ssids
wifi_utils_parse_scan_ssids could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.

Also limit the range of the CONFIG_WIFI_SCAN_SSID_FILT_MAX parameter
from 1 to 4 to avoid stack overflow due to users specifying a large
value for this parameter.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-09-12 09:24:06 +02:00
Sachin D Kulkarni
0b92327fc3 net: wifi: Fix crash in wifi_utils_parse_scan_bands
wifi_utils_parse_scan_bands could cause a crash if a constant string is
passed to it. Fix this by duplicating the input string parameter before
parsing it with strtok_r.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-09-12 09:24:06 +02:00
Andrei Emeltchenko
db7dced87c net: wifi_utils: Add missing break
Add missing break statement.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-09-01 16:37:34 +02:00
Jukka Rissanen
7d3dabf07b net: wifi: Properly namespace public APIs
The twt and ps helper functions were not namespaced (were missing
wifi_ prefix).

Also change wifi_get_twt_... to more logical wifi_twt_get...
like the other twt prefixed functions and wifi_get_ps... to
wifi_ps_get... like the other ps prefixed functions.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-08-31 10:20:07 +02:00
YuLong Yao
716e3a17c1 net: wifi: shell: remove duplicate ap item
Remove two duplicate ap in wifi menu

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-08-23 16:08:51 +01:00
Sachin D Kulkarni
419ffa54a7 net: wifi: Validate scan parameters
Add defensive check to validate scan command parameters.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
2c039026eb net: wifi: Add scan command option to print help
Add a scan command option to print the help text for the scan command.
This is to facilitate ease of using the command (since now there are
many different options added to the scan command).

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
b572e8216a net: wifi: Add scan extension for specifying channels
Add scan extension to allow limiting the scanning to specific channels.
Only 20 MHz channel specifications are allowed presently.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
01e167988c net: wifi: Add scan extension for limiting scan results
Add scan extension to allow limiting the scan results to a user defined
maximum number. This parameter is intended to return results with the
best RSSI. It cannot be counted upon to limit the scan times since the
Wi-Fi chips might have to scan all the channels to find APs with the
best RSSI values across all channels.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
5c399c2d17 net: wifi: Add scan extension for filtering SSIDs
Add scan extension to scan only for specific SSIDs.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
6328fda702 net: wifi: Add scan extension for passive channel dwell times
Add scan extension to control scanning time spent on channels where
passive scanning is used.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
3c130b138f net: wifi: Add scan extension for active channel dwell times
Add scan extension to control time spent on active scan channels.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
ee6c81896d net: wifi: Added scan extension support for frequency bands
Added scan extension to support scanning individual Wi-Fi bands or
combinations thereof.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
Sachin D Kulkarni
add1d15bee net: wifi: Modify option and argument for scan type
Modify the way the scan type option is passed to the wifi scan command.
This makes it flexible to add more scan options.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
2023-08-23 16:05:08 +01:00
YuLong Yao
959e0e829d net: wifi: shell: fix parameter description error
command `wifi ap enable` not have SSID LENGTH parameter, remove it.

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-08-08 13:28:12 +00:00
Robert Lubos
30382daf88 net: wifi_shell: Add user input validation for SSID and PSK
When parsing user input for "wifi connect" and "wifi ap enable"
commands, the SSID and PSK lengths were not verified. It's better to
detect invalid connect/AP enable parameters early, so that help text can
be printed, instead of letting wifi_mgmt command to fail.

For WIFI_SECURITY_TYPE_SAE, follow the Linux convention of limiting the
size to 128 bytes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-25 14:16:17 +02:00
Chaitanya Tata
7a6288a871 net: l2: wifi: Fix printing of TWT parameters
Use the macro to print to handle for cases where shell context is NULL,
this is possible because in this net management event handler shell
context is not passed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-17 13:21:39 +00:00
Chaitanya Tata
69a144210e net: wifi: Add support to handle Wi-Fi NM's in Wi-Fi management
Check if a network interface is managed by a network manager before
falling back to offload API.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-11 14:55:30 +02:00
Chaitanya Tata
38fc560f21 net: wifi: Introduce Wi-Fi network managers
This introduces support for Wi-Fi network managers in Zephyr. The
motivation is for the Wi-Fi management layer to work with both
Network managers and offloaded Wi-Fi drivers. The device driver
decides which one to use.

network manager : Apps -> Wi-Fi Mgmt -> Network Manager -> Wi-Fi
interface

offloaded       : Apps -> Wi-Fi Mgmt -> Wi-Fi offloaded interface

Support for multiple network managers has been added, each device can
choose its own network manager and there can be mix and match:

  wlan0 - Offloaded
  wlan1 - Network manager 1
  wlan2 - Network manager 2

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-11 14:55:30 +02:00
Chaitanya Tata
a132487fec net: wifi: Move Wi-Fi ops to a separate struct
Decouple interface and Wi-Fi APIs, Wi-Fi APIs are common independent of
Wi-Fi offload or implemented natively (This is preparation for
introducing Native Wi-Fi).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-07-11 14:55:30 +02:00
Robert Lubos
e1964b8a82 net: wifi: shell: Fix unsafe pointer casts
parse_number() helper function accepts long * pointer or the output,
however in several places, an address of a variable of incompatible
type was passed to the function (for example an address of a bool
variable was cast to (long *) and provided to the function). This
could cause memory overwrites or other unexpected behaviour.

Fix this, by defining a helper variable of type long, and use it with
the parse_number() function. Only after successful parsing, the value is
then assigned to the proper destination.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-07-05 11:17:42 +02:00
Ajay Parida
69fead1998 net: mgmt: Support for forced Passive scan
Default scan mode is Active. User can force the scan mode to passive
through Kconfig option or using 'passive' option from shell.
Using either of this option will override regulatory settings and
forces all scan channels to be passive only.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-29 21:05:41 +02:00
Chaitanya Tata
a71bff7f49 net: wifi: Fix power save timeout data type
This should be an unsigned integer. Also, add a comment to explain this
feature.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-27 12:17:26 +00:00
Chaitanya Tata
5aced7130d net: wifi: Use only Wi-Fi interfaces
As this is Wi-Fi shell use only Wi-Fi interfaces, if none are found
fail.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 16:12:32 +02:00
Chaitanya Tata
8042218948 net: wifi: Add a message for unsolicited TWT tear down
This is for TWT tear down by AP.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
a3ab624f5d net: wifi: Add a demarcation print
This helps see the response status and details separately.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
3be7265737 net: wifi: Fix tear down messages
TWT tear down is a synchronous call, so, once it returns the operation
is done.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
97bd70fa05 net: wifi: Disable trigger in TWT quick setup
Most AP's are not sending proper HE triggers or stopping triggers after
sometime, so, change the default to non-triggered based TWT.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Chaitanya Tata
456859a65d net: wifi: Do TWT checks only for setup
For tear down the checks doesn't make any sense, as TWT flow is already
established.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-06-26 08:35:20 +00:00
Ajay Parida
041201b0d1 net: wifi_mgmt: Reject TWT setup till IP address is configured
If a user tries to enable TWT too early in the connection, then we might
enter TWT sleep even before DHCP is completed, this can result in packet
loss as when we wakeup we cannot receive traffic and completing DHCP
itself can take multiple intervals. Though static ip address can be
assigned too. Reject TWT till Wi-Fi interface has
a valid IP address.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-17 07:56:17 -04:00
Ajay Parida
6002061efe net: wifi_mgmt: Pass address instead of value as pointer
Fix for not getting expected event information at application.
net_mgmt_event_notify_with_info() expects the address
not the value as pointer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-06-13 08:28:43 -04:00
Ajay Parida
d47021b2f9 net: shell: Fix for PS timeout param type.
Param type is set to correct type for power save timeout.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-18 15:14:31 -04:00
Krishna T
b7cabb72fa net: wifi: Fix typo in event
Wrong macro was copied, this causes the event to fail.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 11:41:43 -04:00
Krishna T
10f3ca2e1d net: wifi: Add an event for disconnect complete
This is needed for applications that rely on WPA supplicant being
in disconnected state before issue subsequent commands (e.g., issue scan
immediately after disconnect fails, until disconnect is completed).

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-16 13:21:10 +02:00
Ajay Parida
e70bb70651 net: wifi_mgmt: Support to provide raw scan data
Support to provide raw beacon and probe response data
to registered application.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-12 10:50:21 +00:00
Ravi Dondaputi
0889ceaa4e net: wifi: Display MFP info in scan results
Display MFP info in scan results.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-05-12 11:57:13 +02:00
Ajay Parida
7f9ba751e9 net: wifi_mgmt: Handle ps command error
Failure of setting ps param is handled with error string
at user/ app level.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
49e6b0c256 net: shell: Code cleanup for ps related commands
Setting ps_mode and ps_timeout related changes handled
in single power save op.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
bdef1bad78 net: wifi_mgmt: Configure ps wakeup mode
'ps_wakeup_mode' is used to set the wake up interval
to either 'dtim or 'listen_interval'. By default the
sta wakes up every dtim interval.
With 'ps_wakeup_mode' set to 'listen_interval' sta
will wake up for every listen interval period configured.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
68403669c6 net: wifi_mgmt: Configure listen interval
listen interval is the time periods the STAs may be in idle
without listening beacons.
By default STA wakes up for every DTIM period.
If listen interval based power save is used
STA uses configured listen interval period(default 10
beacon intervals) to wake up.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 15:04:00 +02:00
Ajay Parida
bdec033889 net: shell: Display TWT response details
Show TWT response parameters details.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-05-09 09:24:30 +02:00
Krishna T
2b48c92742 net: wifi: Fix TWT interval
As we are using a generic validation function for limits, due to data
type mismatch the check for TWT interval overflow and fails.

Fix the data type and accordingly the maximum value in the help.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-05-09 16:24:10 +09:00
Ajay Parida
a004a85ccf net: shell: Check connection & capabilities in any TWT operation
Connection status & AP capabilities checked before any TWT operation
is initiated.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-27 09:52:00 +02:00
Ajay Parida
5c023fbbb9 net: wifi_shell: Updated TWT flow id range
TWT flow id is of 3 bit value(maximum mnumber of flows
supported is 8). Flow id range limited to 0 to 7.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-04-25 12:21:35 +02:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Krishna T
1e6e20f667 net: wifi: Log failure reason for AP mode
In case AP mode is not supported log the failure reason clearly.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-04-07 13:35:28 +02:00
Krishna T
5e6c733006 net: wifi: Use a macro for TWT wake interval
Remove the magic number 255, esp. now that we support 262.144ms.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Krishna T
65aae9cbfb net: wifi: Use micro seconds for precision for TWT intervals
In order to take granular input use micro seconds as input for TWT
intervals, this helps us in providing inputs such as 65.28ms without the
need of using floating points.

This also expands the TWT wake interval range to 262.144ms, earlier as
we want to use uint8, limited to 256ms.

Also, remove the units from the variable names, this is unnecessary and
also avoids doing breaking changes.

Update release notes as this is a breaking change, both type and
variable names are changed.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-03-20 09:53:02 +01:00
Ajay Parida
43bd60a13a net: wifi_mgmt: Send TWT sleep status event to app
Send TWT sleep status(sleep/awake) event to the apps registered
for event.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-14 10:49:30 +01:00
Ajay Parida
ce4a809751 net: wifi_mgmt: Updated TWT setup response status
Display message updated for TWT setup response.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-08 15:33:30 +01:00
Ajay Parida
55ed46ff6d net: wifi_mgmt: Updated TWT setup response status
Updated TWT setup response status. Removed un-necessary
error strings, enum and values updated as per f/w.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-03-03 12:43:43 +01:00
Krishna T
50c1f857e0 net: l2: wifi: Log packet errors
Log packet errors, this is handy for debugging.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-02-24 11:49:41 +01:00
Ajay Parida
c69731a281 net: wifi_mgmt: Display TWT setup response status
Display the TWT setup response status.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-02-21 10:58:40 +01:00
Ravi Dondaputi
1c547580e4 wifi: shell: Print beacon interval and DTIM period
Print beacon interval and DTIM period as part of Wi-Fi
status output.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2023-02-20 09:46:34 +01:00
Ajay Parida
ba39235275 net: wifi_mgmt: Add support for power save timeout configuration
Add support for configuring power save timeout in Wi-Fi chipsets.
Changes to configure power save inactivity timer.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-23 10:08:01 +00:00
Ajay Parida
057e2fc59c net: wifi_shell: Display correct power save status
Display power save status correctly.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2023-01-19 13:48:24 +01:00
Krishna T
fadb1fd168 net: wifi: Add support for regulatory domain configuration
Wi-Fi bands are regulated by a governing body depending on operating
country, add support for the user to provide a country of operation as a
hint to the Wi-Fi chipset.

Ideally if the chipset supports this is all handled internally, in that
case "get" is useful but for testing and other usecases add a "set" as
well, similar to "iw reg set" or "country_code=" configuration in
hostapd/wpa_supplicant in Linux world.

This add a new offload API operation "reg_domain" that can be used to
either get or set the regulatory information.

The validation is left to the underlying chipset, shell only does basic
validation, (XY/00).

This is just a regulatory hint to the chipset, there could be other
regulatory hints e.g., beacon that can override this configuration, so,
an additional option to force this setting despite other hints is also
given for testing purposes.

FYI, the standard database used is [1].

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Krishna T
324a45568a net: wifi: Fix unnecessary intermediate variable
Directly return the function return value.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-13 13:37:14 +00:00
Krishna T
d796f23e0e net: wifi_mgmt: Add support for power save configuration
Add support for configuring power-save in Wi-Fi chipsets, supports
Legacy, WMM and TWT.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
Krishna T
3f4597d0c9 net: l2: wifi: Arrange commands in alphabetical order
This helps find the command needed easily.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2023-01-10 09:52:11 +01:00
Krishna T
9b02f91f80 net: wifi: Fix MFP when security type is not given
When security type is not given but instead MFP is given, MFP setting
will be considered as security type, this is because both are optional
and no way to distinguish them easily.

Make security type mandatory for MFP selection, this way we either
assume defaults for both security type and MFP or explicitly ask user
for both. Reword the help text to reflect this.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-10-26 12:00:11 +02:00
Gaël PORTAY
6dedea7c16 wifi: shell: Move closing bracket after type enumeration
This fixes the output below by moving the closing bracket to "<Security
type (optional: valid only for secure SSIDs)>" after the enumeration of
security types "0:None, 1:PSK, 2:PSK-256, 3:SAE".

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP
	               "<SSID>"
	               <channel number (optional), 0 means all>
	               <PSK (optional: valid only for secure SSIDs)>
	               <Security type (optional: valid only for secure SSIDs)>
	                                              v----------------------^
	               0:None, 1:PSK, 2:PSK-256, 3:SAE
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
f7dfae5730 wifi: shell: Indent second parameter to new line
Return to line after the first parameter to:
- have the second parameter in a single line (not splitted) and
- start every parameters from a brand new line (easier to read)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
ff077aafe9 wifi: shell: Add missing bracket
This fixes the output below by adding the missing closing bracket to
"<MFP (optional): 0:Disable, 1:Optional, 2:Required":

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP
	               "<SSID>"
	               <channel number (optional), 0 means all>
	               <PSK (optional: valid only for secure SSIDs)>
	               <Security type (optional: valid only for secure SSIDs)>
	               0:None, 1:PSK, 2:PSK-256, 3:SAE
	               <MFP (optional): 0:Disable, 1:Optional, 2:Required
	               ^-------------------------------------------------^
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Gaël PORTAY
b177911a4d wifi: shell: Add missing end of line
This fixes the output below by returning to line after "Connect to a
Wi-Fi AP":

Fixes:

	uart:~$ wifi
	wifi - Wi-Fi commands
	Subcommands:
	  connect     :Connect to a Wi-Fi AP"<SSID>"
	                                    ^------^
	               <channel number (optional), 0 means all>
	               (...)

Signed-off-by: Gaël PORTAY <gael.portay@gmail.com>
2022-10-14 09:55:18 +02:00
Krishna T
d2b196978f net: l2: wifi: Fix channel length check
To allow 5GHz (and 6GHz) channels, use 3 digits check.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-26 18:41:40 +02:00
Krishna T
97ee180c72 wifi: shell: Fix network switching issue
When switching from a secure network to open network, the previous
parameters are not reset which causes the open connection to fail.

Remove the unnecessary "static" storage and reset to zero for params.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-21 08:58:37 +00:00
Krishna T
79f864028d net: l2: wifi: Log band from the scan result
Along with channel, also log the Wi-Fi band from the scan result.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-15 16:34:30 +00:00
Gerard Marull-Paretas
79e6b0e0f6 includes: prefer <zephyr/kernel.h> over <zephyr/zephyr.h>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.

The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.

NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-09-05 16:31:47 +02:00
Krishna T
34db41d934 net: l2: wifi: Improve help
* Fix newlines
* Improve text

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-02 11:07:07 +00:00
Krishna T
d6448aeb49 net: l2: wifi: Use proper Wi-Fi terminology for MAC
MAC address is generic, in context of scan it should be called BSSID.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-02 11:07:07 +00:00
Krishna T
870fcb3aa4 net: l2: wifi: Fix the width for security
The longest security string is 15 (WPA2-PSK-SHA256), so, use that width
for alignment.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-09-02 11:07:07 +00:00
Krishna T
2a9b06b7c6 wifi_mgmt: Fix checkpatch warnings
Checkpatch says "else after return is not useful".

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
e2db4e690e wifi_shell: Fix the duplicate tag CI warning
Newly introduced Coverity scan throws a warning about duplicate tag as
per MISRA coding standards, so, use a unique tag name in the existing
code for "shell".

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
bcf7585429 wifi_shell: Rename Wifi to Wi-Fi
This is the standard.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
0f126a7adb wifi_mgmt: Add new API for Wi-Fi statistics
Networking statistics framework is used to define handler and the data
structure, Wi-Fi management layer implements the handler and also adds a
new offload API to get statistics from the Wi-Fi driver.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
1ecca68886 wifi_shell: Add new security methods
Add PSK_256, SAE and MFP settings.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
b5b11bbff0 wifi_mgmt: Add new API for Wi-Fi status
A new net_mgmt command and event are added for interface status,
depending on the implementation the status can be returned when polled
or an unsolicited event can be send by driver whenever there is a change
in status.

This is planned to be implemented only by upcoming wpa_supplicant,
offload implementation is left for driver developers.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Krishna T
0e5c900400 wifi_mgmt: Implement checks for new security types
Extend checks for PSK-256 and SAE.

Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
2022-08-31 21:49:47 +00:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Jani Hirsimäki
e913fda436 net: l2: wifi_shell: mac address in scanning results
Showing mac address in scanning results.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2021-10-07 10:55:37 +02:00
Jakub Rzeszutko
005103739c shell: examples cleanup
Remove obsolete include of the shell_uart.h file.
It is sufficient to include the shell.h file.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-09-29 10:48:47 +02:00
Tomasz Bursztyka
e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka
98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Marcin Niestroj
747f20720a net: wifi: shell: store shell in context before scan
Right now shell pointer is not assigned before doing a scan, so scan
results are printed using printk(). Save shell instance in context, so
results are printed using shell_fprintf(), thus better aligned in the
console output.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-06-08 21:37:33 +03:00
Kumar Gala
a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marcin Niestroj
29cb9271ed net: wifi: fix log message printing ssid and psk
The following logs show up when trying to connect:

  uart:~$ wifi connect xxxxxx xxxxxxxxxx
  Connection requested
  <dbg> net_wifi_mgmt.wifi_connect: (0x20000500): xxxxxx 6 255 1 \
                xxxxxxxxxx 10
  <err> log: argument 6 in source net_wifi_mgmt log message \
                "%s: (%p): %s %u %u %u %s %u" missinglog_strdup().
  <err> log: argument 2 in source net_wifi_mgmt log message \
                "%s: (%p): %s %u %u %u %s %u" missinglog_strdup().
  Connected
  uart:~$

Fix that by using LOG_HEXDUMP_DBG() to print SSID and PSK.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-04-07 15:00:55 +03:00
Marcin Niestroj
f5edc6db8f net: wifi: shell: drop explicit length parameter
Calculate length based on provided SSID string, so user does not have to
provide length explicitly over shell.

This patch also removes requirement of minimum 3 characters SSID, as
the shortest SSID can be even 1 character.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-03-10 14:37:57 +02:00
Anas Nashif
9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif
3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt
4aa48833d8 subsystems: Rename reserved function names
Rename reserved function names in the subsys/ subdirectory except
for static _mod_pub_set and _mod_unbind functions in bluetooth mesh
cfg_srv.c which clash with the similarly named global functions.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt
24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Krzysztof Chruscinski
3605e48c44 shell: Modify subcommands to use SHELL_STATIC_SUBCMD_SET_CREATE
It is planned to deprecate SHELL_CREATE_STATIC_SUBCMD_SET macro
which is replaced by SHELL_STATIC_SUBCMD_SET_CREATE.

Additionally, removed irrelevant comments about alphabetical
ordering which is no longer needed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-20 07:31:35 -05:00
Loic Poulain
192733c096 net: wifi: Add Access Point mode interface
Add access point mode disable/enable to wifi mgmt/offload.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -05:00
Loic Poulain
d9365dff92 net: wifi: shell: Add access point commands
Expose access point disable/enable commands.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -05:00
Jukka Rissanen
86689030e8 net: Clarify logging in networking code
Remove network specific default and max log level setting
and start to use the zephyr logging values for those.

Remove LOG_MODULE_REGISTER() from net_core.h and place the
calls into .c files. This is done in order to avoid weird
compiler errors in some cases and to make the code look similar
as other subsystems.

Fixes #11343
Fixes #11659

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-12-07 12:00:04 +02:00
Jakub Rzeszutko
b928b71756 shell: rename shell_help_print function
Function printing help has been renamed to shell_help.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko
e0be6a10b3 shell: printing command's help by shell engine
Removed printing command help from help handler. It is now
realized by the shell engine. This change saves a lot of flash
but still allows to print help in command handler with function
shell_help_print.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko
5451ff2848 shell: remove "options" concept
Removing help "options" from shell API.

Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.

Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.

And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Patrik Flykt
b97db52de7 misra-c: Add 'U' to unsigned variable assignments in subsys/
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Gil Pitney
621ec506e2 net: wifi: Update connect cmd to deal with new shell quoted args
Previously, the wifi shell needed to remove the quotes from the
SSID parameter, passed in by the underlying shell.

The new shell is now able to parse quoted strings as arguments,
so this adjustment can be removed.

Otherwise, it results in a failure to connect to an AP, as the first
character of the SSID name is stripped off.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-25 20:46:38 +03:00
Jukka Rissanen
8f76169190 net: wifi: Make sure shell is valid before trying to print to it
It is possible that connect callback is called when shell is not
yet set. Make sure to check this and fallback to use printk() if
shell_printf() cannot be used.

Fixes #10617

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-19 16:16:48 -04:00
Jukka Rissanen
1d72af0393 net: wifi: Fix connect command parameter checks in shell
The connect command parameters were not checked properly if
user decided to supply only mandatory parameters.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-19 16:16:48 -04:00
Jukka Rissanen
dab9030ab9 net: wifi: Check offloading pointers before accessing them
If the device does not support wifi offloading, then return -ENOTSUP
so that wifi support can be enabled for testing purposes even if
the actual device does not have wifi support. This is happens for
example in qemu which does not support wifi offloading.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-19 16:16:48 -04:00
Jukka Rissanen
681ff12379 net: wifi: Convert wifi shell to use new shell
Use new shell instead of the legacy one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-15 11:14:02 +03:00
Dong Xiang
026f06efeb net: l2: update wifi mgmt to adapt non-offload wifi chip.
The wifi mgmt does only support TCP/IP offload wifi chip,
while non-offload wifi chip can not scan/connect to AP.

Signed-off-by: Dong Xiang <dong.xiang@unisoc.com>
2018-10-10 11:38:04 +03:00
Jukka Rissanen
7138e34d31 net: wifi: Removing SYS_LOG_DBG as that is no longer used
The wifi management interface was still using one SYS_LOG_DBG
macro call, replacing that with NET_DBG.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-05 10:08:32 -04:00
Jukka Rissanen
a76814bfb6 net: Convert core IP stack to use log levels
Instead of one global log level option and one on/off boolean
config option / module, this commit creates one log level option
for each module. This simplifies the logging as it is now possible
to enable different level of debugging output for each network
module individually.

The commit also converts the code to use the new logger
instead of the old sys_log.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03:00
Krzysztof Chruscinski
527256501f shell: Rename shell to legacy_shell
New shell implementation is on the way. For now old one and all
references are kept to be gradually replaced by new shell.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Jukka Rissanen
21a27e8807 net: l2: Move individual L2 to dedicated directories
No need to keep technologies in main L2 directory so for consistency
create a directory for each of them and place each L2 component to
relevant L2 directory.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-07-30 09:02:02 -04:00