Commit graph

145 commits

Author SHA1 Message Date
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
Saravanan Sekar 0fd92b463b wifi: eswifi: Select socket before configuration
Socket selection needs to be first in the order of operation

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
2019-08-05 13:21:15 +02:00
Loic Poulain 8462f331f5 wifi: eswifi: Implement TCP listen/accept
Start es-wifi TCP server on accept.
An asynchronous (spi) message is received on client connection.
Only one connection is supported at a time.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-07-02 09:08:59 +03:00
Loic Poulain 033b267085 wifi: eswifi: Allow nested locking
In order to prevent potential deadlock in various callbacks such as
accept, recv, etc... Add support for nested eswifi locking, allowing
callee to safely access back to the eswifi methods.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-07-02 09:08:59 +03:00
Loic Poulain 50fa6bdd5e wifi: eswifi: Parse async messages
The eswifi controller can generate events via asynchronous messages
which can be polled via the 'MR\r' command. The messages will have a
Start Of Message Asynchronous [SOMA] and End Of Message Asynchronous
[EOMA] delimiters.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-07-02 09:08:59 +03: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 bd70f6f1ed cleanup: include/: move spi.h to drivers/spi.h
move spi.h to drivers/spi.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 6aa9c3a68f cleanup: include/: move gpio.h to drivers/gpio.h
move gpio.h to drivers/gpio.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
Kumar Gala a614a026b7 dts: Rename DT_.*_GPIO_* to DT_.*_GPIOS_*
Convert DT_.*_GPIO_{CONTROLLER,PIN,FLAGS} ->
	DT_.*_GPIOS_{CONTROLLER,PIN,FLAGS)

Used the following commands to make these conversions:

git grep -l DT_.*_GPIO_CONTROLLER | xargs sed -i 's/DT_\(.*\)_GPIO_CONTROLLER/DT_\1_GPIOS_CONTROLLER/g'
git grep -l DT_.*_GPIO_PIN | xargs sed -i 's/DT_\(.*\)_GPIO_PIN/DT_\1_GPIOS_PIN/g'
git grep -l DT_.*_GPIO_FLAGS | xargs sed -i 's/DT_\(.*\)_GPIO_FLAGS/DT_\1_GPIOS_FLAGS/g'

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-27 13:02:34 -05:00
Parthiban Nallathambi b7b9458ec6 wifi: eswifi: add UDP support
Add UDP support for eswifi driver. eswifi now can co-exist
with TCP and UDP functionality with 4 as max socket connection.

Tested UDP with custom DNS sample (wifi connect + DNS)

Signed-off-by: Parthiban Nallathambi <parthitce@gmail.com>
2019-06-26 23:20:22 +03:00
Kumar Gala a2693975d7 dts: Convert from DT_<COMPAT>_<INSTANCE>_<PROP> to DT_INST...
Change code from using now deprecated DT_<COMPAT>_<INSTANCE>_<PROP>
defines to using DT_INST_<INSTANCE>_<COMPAT>_<PROP>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-14 08:02:15 -05:00
Parthiban Nallathambi d0d963a85d wifi: eswifi: init net_pkt cursor after net_pkt_write
Initialize the net_pkt cursor to begining after net_pkt_write.
Without which recv_cb can't peek/get net_pkt

Signed-off-by: Parthiban Nallathambi <parthitce@gmail.com>
2019-06-14 09:59:52 +03:00
Anas Nashif 4c32258606 style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02: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
Andrew Boie 4e5c093e66 kernel: demote K_THREAD_STACK_BUFFER() to private
This macro is slated for complete removal, as it's not possible
on arches with an MPU stack guard to know the true buffer bounds
without also knowing the runtime state of its associated thread.

As removing this completely would be invasive to where we are
in the 1.14 release, demote to a private kernel Z_ API instead.
The current way that the macro is being used internally will
not cause any undue harm, we just don't want any external code
depending on it.

The final work to remove this (and overhaul stack specification in
general) will take place in 1.15 in the context of #14269

Fixes: #14766

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-05 16:10:02 -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
Kumar Gala c6662826b7 net/pkt: Fix a few left over cases of net_pkt_read_new
In the conversion of net_pkt_read_new to net_pkt_read, we missed
changing the function in the eth_smsc911x and eswifi_offload.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-03-20 15:26:30 -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
Tomasz Bursztyka a57e218965 net/offload: Remove useless token parameter
This parameter was removed from net_context already thus applying the
change also on net_offload API.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka d6d52ce9e5 net/pkt: Remove _new suffix to net_pkt_write functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -05:00
Tomasz Bursztyka a25f054cbd net/pkt: Remove _new suffix to net_pkt_read functions
Suffix is now useless, as these functions are now the only ones.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-03-20 10:27:14 -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
Tomasz Bursztyka 6fabbb7d14 drivers/wifi: Switch eswifi driver to new net_pkt API
Brings tiny simplifications.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:30:57 -05:00
Tomasz Bursztyka e8b0e1f35b drivers/wifi: Switch winc1500 driver to new net_pkt API
Use tx and rx pools relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-21 09:30:57 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -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
Tomasz Bursztyka 4b78a251d7 net/context: Make recv_cb providing the ip and protocol headers
If status is 0, both ip_hdr and proto_hdr will own a pointer to the
relevant IP and Protocol headers. In order to know which of ipv4/ipv6
and udp/tcp one will need to use respectively net_pkt_family(pkt) and
net_context_get_ip_proto(context).

Having access to those headers directly, many callbacks will not need
to parse the packet again no get the src/dst addresses or the src/dst
ports. This will be change after this commit.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-02-01 14:34:38 +02: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
Kumar Gala e0cd0c2b67 wifi: winc1500: Convert to new DT_<COMPAT>_<INSTANCE> defines
Convert winc1500 driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-28 10:39:59 -06:00
Kumar Gala eaafdc85fc wifi: eswifi: Use generated SPI CS define
Move to using the generated DT_INVENTEK_ESWIFI_ESWIFI0_CS_GPIO_pin and
DT_INVENTEK_ESWIFI_ESWIFI0_CS_GPIO_CONTROLLER defines and drop the
DT_ESWIFI0_CS_GPIOS_PIN & DT_INVENTEK_ESWIFI_ESWIFI0_CS_GPIO_PIN from
dts_fixup.hl

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-01-23 18:12:24 -06:00
Loic Poulain 8a7b6ffaab wifi: eswifi: Add access point offload support
The eswifi controller is capable of acting as an Access Point.
Implement ap_enable/ap_disable methods.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -05:00
Loic Poulain c893024184 drivers: wifi: eswifi: Fix mac address assignment
Use always valid mac pointer instead of a stacked local variable.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -05:00
Loic Poulain 654d93999e wifi: eswifi: Add controller at command helpers
Create eswifi_at_cmd and eswifi_at_cmd_rsp helpers, allowing to send an
at command and parse the at response. These methods return success if
the response contains the OK* string. The eswifi_at_cmd_rsp method
extracts response content/size (DATA) on success.

*Response format is:
\r\n[DATA]\r\nOK\r\n>
Where DATA can be arbitrary (ASCII or not).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-19 07:20:36 -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
Loic Poulain c9a9e0a4ee drivers: wifi: eswifi: Fix coverity issues
This patch fixes the following issues:
CID 190622 (#1 of 1): Out-of-bounds access (OVERRUN)
CID 190632 (#1 of 1): Out-of-bounds access (OVERRUN)
CID 190623 (#1 of 1): Unchecked return value (CHECKED_RETURN)
CID 190628 (#1 of 1): Out-of-bounds write (OVERRUN)
CID 190620 (#1 of 1): Dereference after null check (FORWARD_NULL)

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-01-08 08:01:20 -05: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
Tomasz Bursztyka e97a543e9b net/pkt: Remove parameters to "reserve" some headroom
Such parameter is not used anymore, it was defaulted to 0 previously.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Tomasz Bursztyka 0f9312cde9 drivers/wifi: Remove usage of ll_reserve
It's not used anymore by the core IP.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-12-14 14:16:37 +01:00
Kumar Gala 0fbcf03ba9 drivers: wifi: eswifi: Remove unused code
uarthost isn't used anywhere, so lets remove it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-11 09:57:13 -06:00
Kumar Gala 0c12a7b050 drivers: wifi: eswifi: Fix build issue due to -fno-common
The introduction of -fno-common caused a link error in eswifi driver due
to lack of missing extern on eswifi_bus_ops_spi.  Adding the extern
resolves the link error.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-12-11 09:57:13 -06:00
Loic Poulain c67bb6d440 wifi: eswifi: Fix/clean TCP receive
This patch adds support for blocking tcp receive (with timeout).
This patch removes dedicated socket polling thread to use common
eswifi workqueue instead.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-12-05 08:56:24 -05:00
Loic Poulain 791343bb18 wifi: eswifi: Add support for non-blocking TCP connect/send
Current implementation unconditionnaly performs blocking connect
and send. Add support for non-blocking version using eswifi workqueue.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-12-05 08:56:24 -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
Tomasz Bursztyka ee9dedd5a7 net/iface: Finally remove the send function from net_if_api
And apply that to modem driver setting that pointer to NULL.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-30 11:12:13 -08: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
Kumar Gala 77149642f6 driver: wifi: eswifi: Fix how we get SPI bus
We were hard coding the SPI bus name to "SPI_3".  Instead we should use
DT_INVENTEK_ESWIFI_ESWIFI0_BUS_NAME as its generated from the device
tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-21 16:01:13 -05:00
Kumar Gala 9f88c0d471 driver: wifi: eswifi: Use DT_ prefixed names
The driver was using the straight alias generated defines, however we
want to use DT_ prefixed defines so its clear that the values are coming
from DT.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-21 16:01:13 -05:00
Kumar Gala 9730ca1852 wifi: winc1500: Add Device Tree support
Add a dts binding for the Atmel WINC1500 WIFI chip.  Update the
quark_se_c1000_devboard to utilize this binding as well as the wifi
sample app.

We now get all the GPIOs related to the Atmel WINC1500 from the device
tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-13 14:12:18 -05:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06: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
Kumar Gala aa2bdbe322 drivers: Remove board.h include
We either don't need board.h in the driver or we should be include soc.h
instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-01 13:21:11 -04:00
Niranjhana N 9e895acf4e drivers: wifi: fix an unchecked return
Log error and return false if recv()
has not received packet in the buffer.

Signed-off-by: Niranjhana N <niranjhana.n@intel.com>
2018-10-30 14:18:28 +02:00
Loic Poulain 25120f3cc2 boards: disco_l475_iot1: Enable es-WiFi driver
Automatically enable es-WiFI driver when WIFI is enabled.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-10-29 16:38:02 +02:00
Loic Poulain 0b8fde39e4 driver: wifi: Add inventek es-WiFi driver
es-WiFi compatible modules use IWIN AT command set.
This driver is split into several layers:
- bus layer: interface to transmit AT commands (SPI, USB, UART...)
- core layer: es-WiFi module management (state, scan...)
- offload layer: TCP/IP offload operations (connect, listen...)

This driver has been tested with stm32l4 disco iot board
(disco_l475_iot1) and the wifi sample:

$ select wifi
$ scan
$ connect "CISCO" 5 password
$ select net
$ tcp connect 192.168.1.21 4242
$ tcp send HelloWorld!

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2018-10-29 16:38:02 +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
Anas Nashif c1d2930471 drivers: wifi: move to new logger
Move drivers to new logger and change samples enabling logging in
prj.conf.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-10-10 10:22:01 -04: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 42f51ef08d drivers: wifi: winc1500: Use offload_context instead of user_data.
The wifi_winc1500 driver's socket id is stored in
net_context->user_data, which may be overwritten later at
the socket layer, which also uses the net_context->user_data
field to store socket flags.

This patch introduces a dedicated offload_context field
for use by offload drivers, and updates the wifi_winc1500 offload
driver to use this field instead of user_data.

Fixes #8820

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-07-18 07:47:45 -04: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
Ulf Magnusson 21d4adef93 drivers: wifi: Kconfig: Remove redundant 'default n' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Gil Pitney 3bc77e88fb net: drivers: wifi: SimpleLink WiFi Offload Driver (wifi_mgmt only)
Initiate a SimpleLink WiFi Driver, implemented to the WiFi management
offload APIs for scan, connect, disconnect.

Also registers the DHCP-obtained IPv4 address upon connect.

This was validated on a cc3220sf_launchxl using the wifi
shell module from the Zephyr shell_module sample.

Signed-off-by: Gil Pitney <gil.pitney@linaro.org>
2018-06-15 10:01:21 -04:00
David B. Kinder 44383a394b doc: fix misspellings in Kconfig files
Found some misspellings missed during normal reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-05-23 16:57:20 -04:00
Tomasz Bursztyka ce947431e2 drivers/wifi: Move all winc1500 related code to its own directory
There will be other drivers, and mixing up all these files together will
create a mess so better having a dedicated place for winc1500, at least.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 2145503273 drivers/winc1500: Implement wifi mgmt offloaded API
Scan, connect and disconnect for now.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 5f9ccad97f drivers/wifi: Switch info level to debug level in winc1500 driver
These output are fine while debugging, but useless otherwise.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 569e70aaae drivers/wifi: Split case logic into functions in winc1500 driver
This cleans up the callback functions and isolate each part to a
relevant handler to improve readability.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 1e4ba8231d drivers/wifi: Remove useless gpio configuration call in winc1500 driver
This call is already made in nm_bus_wrapper along with SPI.
In nm_bus_wrapper however: moving the call out of #ifdefsf as it is
generic call, whatever bus would be choosen.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 8e65f6ab2a drivers/wifi: Let's go away from SPI legacy API in WINC1500
As legacy API is meant to be removed.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 0294c67349 drivers/wifi: Move configure macros to Kconfig
There is no point having undocumented and local config options when
Kconfig can be used to expose these relevantly.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka 2a1d222adc drivers/wifi: Generalize GPIO configuration for the WINC1500 driver
Previous way was cumbersome (based on an old way for cc2520 actually),
so moving towards the more recent and proper way.

This will enable anybody to actually provide gpio configuration for a
winc1500 out of any board specific location.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Dario Pennisi 9bdf1cdb0e drivers/wifi: Add winc1500 WiFi driver
Adding support for WINC1500 WiFi chip.

It introduces the wifi drivers sub-directory.

It provides a Full-MAC for 802.11 and an offloaded network stack as
well. The driver uses Atmel's winc1500 HAL.

Signed-off-by: Dario Pennisi <dario@iptronix.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Massimiliano Agneni <massimiliano.agneni@iptronix.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-05-17 10:46:26 +03:00
Tomasz Bursztyka eab3f168fd net/mgmt/wifi: Add dedicated net mgmt hooks for WiFi offload devices
Exposing connect, disconnect and scan for now.

In case the iface is an instance of a WiFi offload device, the way it
manages scanning, connecting and disconnecting will be specific to that
device (not the mgmt interface obviously). In such case the device will
have to export relevantly a dedicated bunch of function to serve the
mgmt interface in a generic way.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-12 09:56:07 -04:00
Tomasz Bursztyka 8b839b4e0c drivers/wifi: Add files skeleton for adding WiFi drivers
This will help not to collide within drivers implementations and/or
avoid dependency from one driver to another one.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-12 09:56:07 -04:00