Commit graph

47 commits

Author SHA1 Message Date
Vincent Wan 53f408afe8 drivers: wifi: simplelink: enable IPv6 support
IPv6 support was not fully implemented in the driver and was disabled.
This commit completes the implementation and enables it when
configured.

Signed-off-by: Vincent Wan <vwan@ti.com>
2020-07-21 15:08:56 +02:00
Marcin Niestroj 967f485f38 drivers: wifi: simplelink: fix typo in logged option name
Fix typo in logged Kconfig option name that is missing in used
configuration. This one was mostly problematic for developers wanting to
find such option in source tree using grep - NET_SOCKET_OFFLOAD was not
found in Kconfig files.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-07-16 07:19:56 -05:00
Adam Porter 722a85aea2 drivers: wifi: remove dependency on NET_SOCKETS_POSIX_NAMES
This change removes references to raw POSIX types and functions,
allowing the drivers to build without NET_SOCKETS_POSIX_NAMES.

After this, the dependency between NET_SOCKETS_OFFLOAD and
NET_SOCKETS_POSIX_NAMES can be removed.

See issue #26033 for additional context

Signed-off-by: Adam Porter <porter.adam@gmail.com>
2020-06-15 16:59:36 +02: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
Carles Cufi c61faf6c55 drivers: wifi: Port the simplelink wifi to the new timeouts API
Port the code so it uses the new timeouts API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Torsten Rasmussen d7862cf776 cmake: using ${ZEPHYR_BASE} instead of $ENV{ZEPHYR_BASE}
With the introduction of ZephyrConfig.cmake all parts of CMake code
should rely on the CMake ZEPHYR_BASE variable instead of the environment
setting.

This ensures that after the first CMake invocation, then all subsequent
invocation in same build folder will use same zephyr base.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Tomasz Bursztyka 4ae72db135 net: Enable PM settings on network devices
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.

All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-03-27 14:48:30 +02:00
Robert Lubos ece552c644 drivers: wifi: simplelink: Rework offloading mechanism
Switch to `NET_SOCKET_REGISTER` mechanism over the offloaded API
registration.

Including the following fixes from the review:

* The fd returned by the socket accept call needs to be finalized,
  similar to how it is done for socket creation.

* sl_RecvFrom() in TI SimpleLink Host driver does not support NULL
  pointers for 'from' address and address length, and sl_SendTo() does
  not ignore the destination address when in connection mode, so passing
  NULL would cause a failure. These issues have been reported to TI
  (CC3X20SDK-1970, CC3X20SDK-1971).

  Let's use sl_Recv and sl_Send to implement recvfrom/sendto in the case
  of NULL addresses.

* simplelink_poll() should not process negative file descriptors in the
  fds array after sl_Selecti() returns. A negative fd value indicates
  that the entry is invalid and should be ignored.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 11:36:02 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Vincent Wan 7bcaf3696d drivers: wifi: simplelink: fixes to support CONFIG_NET_NATIVE=n
Remove unnecessary calls to net_if_ipv4_addr_add() and
net_if_ipv4_set_gw(), to prevent link errors when CONFIG_NET_NATIVE
is set to n.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-09-10 12:45:38 +03:00
Vincent Wan 0134a7de73 drivers: wifi: simplelink: fix 'log_strdup missing' error messages
Due to commit a211afb041, an error on
missing log_strdup() call is seen when running samples for CC32xx
devices that use the Wi-Fi driver. Adding log_strdup() calls to fix
this.

Fixes #18563

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-08-22 01:44:55 -05:00
Anas Nashif f156e95bbd ext: hal: make TI HAL a zephyr module
Move TI HAL to a module repository:
https://github.com/zephyrproject-rtos/hal_ti

managed by west.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-08-21 12:46:39 -05:00
Jukka Rissanen 5c05ef5101 net: Move include files outside of extern "C" block
This is related to findings in #17997 and changes network related
header files to have include files outside of extern "C" { } block.

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-08-06 14:46:36 +03:00
Vincent Wan 252ab55923 drivers: wifi: simplelink: Add static IP address support
Change the SimpleLink wifi driver to use static IP address instead of
DHCP when it is set by NET_CONFIG_MY_IPV4_ADDR. We also support setting
gateway and netmask via NET_CONFIG_MY_IPV4_GW and
NET_CONFIG_MY_IPV4_NETMASK.

This feature is tested out-of-tree against the echo sample after
modifying its prj.conf file to set the static IP address:

CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.191"

and after commenting out these lines in its board-specific config
file for cc3220sf_launchxl:

so that the NET_CONFIG_SETTINGS are not overridden.

The wifi sample is also verified to run correctly after running the
echo sample.

Fixes #14588

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-05-10 22:42:16 +03:00
David B. Kinder c5112327a7 doc: fix mentions of Wi-Fi trademark name
The approved trademark name is Wi-Fi so update references to WiFi and
other spellings to Wi-Fi in documentation and Kconfig help strings.
(Note that use of spelling variatios of "wifi" in module names, CONFIG
names, link names and such are untouched.)

https://www.wi-fi.org/

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-05-06 20:10:59 -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 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

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
Vincent Wan a69955701d drivers: wifi: simplelink: Implement fcntl to set/get non-blocking mode
This commit implements fcntl() in the SimpleLink Wifi driver to set and
get the non-blocking mode on a socket.

Fixes #11891.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-20 11:36:18 -05:00
Vincent Wan 017446ba20 drivers: wifi: simplelink: Return success when TLS_PEER_VERIFY is set
mqtt_client_tls_connect() calls setsockopt() to set the TLS_PEER_VERIFY
option to require verfication. To enable mqtt, we need to return
success at a minimum when this option is set to 2.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-13 12:06:38 -05:00
Vincent Wan 7816827468 drivers: wifi: simplelink: Fix error handling
The driver is not returning correct error codes when error occurs.
The error handling function is expecting negative input values, but
that is not true for BSD error codes. So I am taking an approach
where I use a function to convert SimpleLink error codes to BSD
error codes, and call slcb_setErrno() to set the errno independently.

Fixes #12745

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-13 12:06:38 -05:00
Ulf Magnusson 3de2de89e0 kconfig: drivers: wifi: Remove redundant WIFI deps.
These symbols appear within an 'if WIFI' (in drivers/wifi/Kconfig).

'if FOO' is just shorthand for adding 'depends on FOO' to each item
within the 'if'. Dependencies on menus work similarly. There are no
"conditional includes" in Kconfig, so 'if FOO' has no special meaning
around a source. Conditional includes wouldn't be possible, because an
if condition could include (directly or indirectly) forward references
to symbols not defined yet.

Tip: When adding a symbol, check its dependencies in the menuconfig
('ninja menuconfig', then / to jump to the symbol). The menuconfig also
shows how the file with the symbol got included, so if you see
duplicated dependencies, it's easy to hunt down where they come from.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-09 09:49:26 -05:00
Vincent Wan 2e15b0f611 drivers: wifi: simplelink: Use TI SimpleLink SDK 2.40
This commit updates the wifi driver to use the new TI SimpleLink SDK.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-05 11:37:10 -05:00
Vincent Wan 5c4a2193cd drivers: wifi: simplelink: Remove SO_REUSEADDR and TCP_NODELAY
The SimpleLink driver has been defining these macros for its local use.
Given these have been defined in a recent commit in Zephyr
(9c86dbfd8e), we should now avoid
redefining them to prevent build errors.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-03-02 12:21:21 -05:00
Vincent Wan 581cfdb754 drivers: wifi: simplelink: Translate socket family/type/protocol values
In the SimpleLink wifi driver, the socket family value needs to be
converted to the SL_* equivalent to be understood by the SimpleLink
API, instead of being passed straight in.

While not strictly necessary, we are doing the same for socket type
and protocol values to future-proof ourselves in case similar changes
happen to the values defined for these in Zephyr header files.

Fixes #13203

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-02-13 06:48:40 -06:00
Vincent Wan 11b4b6f660 drivers: wifi: simplelink: Add handling for unknown root CA
Error code SL_ERROR_BSD_ESECUNKNOWNROOTCA is returned from sl_Connect()
when the root CA used is not part of the certificate catalog on the
network processor. We should warn the users about this and continue on,
given the connection is successful.

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-01-31 06:36:08 -05:00
Vincent Wan f1619beab9 drivers: wifi: simplelink: socket() should return non-zero fds
simplelink_socket() is not returning non-zero socket file descriptors
when it succeeds. This leads to socket() to always return socket fd 0,
even when the network processor returns a non-zero fd.

This commit fixes simplelink_socket() to return the correct socket fd
when it succeeds in getting one from the network processor.

Fixes #12650

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2019-01-31 06:36:08 -05:00
Robert Lubos 0b93c68f79 net: sockets: Add fcntl to socket offloading API
Offload fcntl calls through socket offloading API.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-01-18 17:25:01 +02:00
Gil Pitney 7f956a9353 drivers: wifi: simplelink: add timeout for fast connect feature
The SimpleLink wifi driver enables the Fast Connect method of
WiFi provisioning, which allows the network coprocessor to
reconnect to a previously connected Access Point (AP) on
startup.

Previously, if Fast Connect failed to connect, any network
socket applications would inevitably fail, as there would have
been no wifi connection.

This patch adds a configurable timeout for the Fast Connect
feature, after which timeout, an error is logged informing
the user to manually reconnect to an AP.

Reconnection is typically accomplished by separately running the
wifi sample shell program.

Fixes: #11889

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2019-01-18 12:32:59 +02:00
Vincent Wan 0f64ec5c31 drivers: wifi: simplelink: Fix strings used in assertions
Samples for cc3220sf_launchxl where assertions are enabled
(e.g. http_get) fail to build because some of the strings used in the
simplelink wifi driver have parentheses around them. This breaks the
current implementation of the __ASSERT macro. This commit removes
the parentheses, which are unnecessary.

http_get has been verified to build after this change.

Fixes #12192

Signed-off-by: Vincent Wan <vincent.wan@linaro.org>
2018-12-26 09:42:29 -05:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
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 c51cf1e463 drivers: wifi: simplelink: Implement setsockopt() for TLS offload
Implements setsockopt() for the socket offload driver
to process the TLS tags sent in via the Zephyr setsockopt() API,
when CONFIG_NET_SOCKETS_SOCKOPT_TLS is chosen.
For each tag, the credential filenames are retrieved and
set via SimpleLink's sl_SetSockOpt() API.

Also, creates a new KConfig option for TLS_CREDENTIAL_FILENAMES.
This new option is used by apps/protocols to add TLS credentials
via filenames referring to the actual content stored on a secure
file system or flash.

Handles the IPPROTO_TLS_* socket protocol families in the
socket() offloaded API.

This was validated on the cc3220sf_launchxl with the http_get sockets
sample, with the globalsign_r2.der file loaded to secure flash via
the TI Uniflash tool, and using the TI Catalog of known good
root CA's.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-11-23 09:16:21 -05:00
Gil Pitney 508c941d32 drivers: wifi: simplelink: fix Coverity issue in getaddrinfo()
Check for case where host == NULL but service != NULL
could have resulted later in a NULL dereference.

Coverity-CID: 189516
Fixes #11090

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-11-08 23:23:23 +02:00
Sebastian Bøe 1422a20093 drivers: wifi: Don't include ti/drivers/net/wifi/bsd from simplelink
Adding 'bsd' to the include path causes problems when gnuarmemb is
used. The wrong errno.h will be used in the build, causing unresolved
references to ENOTSUP.

See PR #10554 for more details.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-10-16 12:11:48 -05:00
Gil Pitney 1022b85c0f drivers: wifi: simplelink: Implement offloaded getaddrinfo()
This offloads the getaddrinfo() socket operation to the
simplelink WiFi driver, via a socket_offload hook.

This was validated using http_get on cc3220sf_launchxl.

Also implements freeaddrinfo().

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-12 13:06:53 +03:00
Gil Pitney 0633a1c294 drivers: wifi: simplelink: More fixes after logging update
Previously, '\n' in LOG_DBG statements were added to
improve readability, by ensuring IP address weren't printed
across typical console terminal line boundaries.

But with the logging updates, '\n' is no longer
getting automatically expanded to \r\n, and a new timestamp
is automatically added, throwing off attempts at alignment.

This patch finally just removes the '\n''s from the log messages,
and cuts a few longer messages into separate messages.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-11 15:51:57 +03:00
Gil Pitney c2cdbbafd7 net: sockets: Get socket offload to build after net logging overhaul.
Also, defines one LOG_MODULE_NAME for the simplelink WiFi driver, and
uses the same name for all files in this driver (module).

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-11 15:51:57 +03:00
Gil Pitney 7520bb21bc drivers: wifi: simplelink: Move NWP configuration to iface_init
Previously, the NWP (Network Coprocessor) was configured during
simplelink_init().

Since the SimpleLink "FastConnect" feature was added,
meaning an automatic reconnect can occur at this time, this
results in early callbacks into the network stack
before it was fully initialized, resulting in a NULL iface
ptr being sent in as argument.

Now, for safety, the NWP startup is moved later to iface_init,
where it more logically belongs.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-11 14:32:48 +03:00
Jukka Rissanen 69eeddd8a9 drivers: wifi: Convert to use new logging
Convert the wifi drivers to use the new logging system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-05 10:08:32 -04:00
Gil Pitney be64964f1e driver: wifi: simplelink: Fix socket offload after s_addr cleanup
The commit 8592501828
("net: Remove s_addr/s6_addr defines from in_addr/in6_addr")

did a (welcomed) removal of a #define s_addr for which the SimpleLink
SDK was checking, breaking the socket_offload driver build.

This patch fixes the driver to work with this new, better
s_addr symbol definition.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-10-04 07:42:12 -05:00
Joakim Andre Tønnesen d6e0fdca8c net: sockets: Add getaddrinfo and freeaddrinfo to socket offloading
Adds getaddrinfo and freeaddrinfo to the offloaded API.

Signed-off-by: Joakim Andre Tønnesen <joakim.tonnesen@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2018-10-02 11:11:15 +03:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin da49f2e440 coccicnelle: Ignore return of memset
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.

The only directory excluded directory was ext/* since it contains
only imported code.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-14 16:55:37 -04:00
Gil Pitney 71182cb294 driver: wifi: simplelink: Register socket offload operations.
If the SimpleLink WiFi driver is configured, and socket offload
enabled, this revectors the Zephyr BSD socket APIs to the SimpleLink
WiFi host driver BSD socket APIs, providing a
direct offload of the TCP/IP stack to the CC3220SF network
coprocessor.

Fixes #3706

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-09-11 18:42:34 +03:00
Gil Pitney e189f59031 drivers: wifi: simplelink: enable Fast Connect policy
This enables the cc3220sf_launchxl to automatically
reconnect to the last good known access point (AP).

This method avoids the need to:
- perform a wifi scan for access points on bootup (saving power);
- include hard-coded SSID/passwords in the wifi application.
- include the wifi shell in the wifi application.
- rely on more complex provisioning methods;

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-07-26 13:57:34 +03:00
Gil Pitney c90170c5c5 drivers: wifi: simplelink: move files into a dedicated subdir
Place simplelink driver files into a subdirectory on par with
winc1500 subdirectory, to effect a better file organization.

No functional change in this patch.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-07-12 19:17:45 -05:00