Commit graph

40 commits

Author SHA1 Message Date
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
Jukka Rissanen 38dd9bc299 net: mgmt: Refactor because of timeout overhaul
Convert to use k_timeout_t

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-09 16:07:03 +03:00
Andrew Boie 760644041c net: purge NET_STACK and other stack APIs
The current design of the network-specific stack dumping APIs
is fundamentally unsafe. You cannot properly dump stack data
without information which is only available in the thread object.

In addition, this infrastructure is unnecessary. There is already
a core shell command which dumps stack information for all
active threads.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-03-14 13:10:19 -04:00
Peter Bigot e28f330a8e coccinelle: standardize k_thread create/define calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments
to k_thread_create and K_THREAD_DEFINE to use the standard timeout
macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Jukka Rissanen 02b3826fa0 net: mgmt: Add info length to event wait API
The info parameter is difficult to use if the caller does not
get information how long the info struct is. So add info_length
parameter to net_mgmt_event_wait_on_iface() and
net_mgmt_event_wait() APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-07-01 13:50:08 -07:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.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 536dd5a71f cleanup: include/: move misc/slist.h to sys/slist.h
move misc/slist.h to sys/slist.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
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
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
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
Paul Sokolovsky cdeddee7c6 net: Set names for threads used by the network subsys/libs
Previously, these either used generic names like "workqueue" (so,
it wasn't possible to distiguish tx and rx workqueues) or didn't
set for net management thread. Here's an example of thread dump
in a typical system (using stack_analyze() call):

rx_workq (real size 4092):	unused 3696	usage 396 / 4092 (9 %)
tx_workq (real size 4092):	unused 3692	usage 400 / 4092 (9 %)
net_mgmt (real size 4092):	unused 3772	usage 320 / 4092 (7 %)
sysworkq (real size 4092):	unused 3512	usage 580 / 4092 (14 %)
idle (real size 252):	unused 64	usage 188 / 252 (74 %)
main (real size 4732):	unused 3672	usage 1060 / 4732 (22 %)

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-10-19 07:58:45 -04:00
Jukka Rissanen 2bc38a8f88 net: mgmt: Use correct printf modifier in debug print
Net event information debug print was using wrong printf modifiers.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-10-04 14:13:57 +03: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
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
Tomasz Bursztyka 93ac7ce655 net/mgmt: Move NET_EVENT_INFO_MAX_SIZE into net core's private header
First because nobody needs to know that besides net_mgmt core and
secondary to avoid possible circular dependancy on
net_mgmt.h/net_event.h.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-04-12 09:56:07 -04:00
Tomasz Bursztyka 185ff16675 net/mgmt: Remove spurious k_sem_give()
Caller of that function is the one giving the semaphore.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 15:07:00 +03:00
Tomasz Bursztyka 807f3e335b net/mgmt: Reenforce pushing events into notification list
Previous way was too lazy. Now let's match exactly for the layer and the
layer code.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 15:07:00 +03:00
Tomasz Bursztyka 059fc95099 net/mgmt: Ensure that event order is kept as FIFO
Make sure also to increase in_event if only inserting event info was
properly done.
Raising also range limit in Kconfig to a much higher value.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-26 15:07:00 +03:00
Tomasz Bursztyka f835f7f6a0 net/mgmt: Protect the event_callback list when manipulating it.
Adding a lock where relevant.

Fixes #6413

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-02 16:50:21 +01:00
Tomasz Bursztyka 7255d7bbfb net/mgmt: Fix how event_mask is handled on layer and layer code part
Exact match is the rule here.

Fixes #6413

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-03-02 16:50:21 +01:00
Ravi kumar Veeramally ebf56ed1a6 net: mgmt: Fix mgmt push event
Do not even consider the push event if CONFIG_NET_MGMT_EVENT_INFO
enabled and info length is more than NET_EVENT_INFO_MAX_SIZE.
Print error message and ignore the event.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Ravi kumar Veeramally 49894b98e4 net: Improve net management event information
Provided separate event information structs based on events. This way
user will know what kind of information will be received to that
particular event.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2018-02-02 16:50:07 +02:00
Tomasz Bursztyka 8e25695937 net/mgmt: Make event notifiers able to pass info to listeners
Adding net_mgmt_event_notify_with_info() which lets the event notifier
to pass dedicated data along with the event. The size of data that can
be passed must be limited to the biggest data passed (which will be
currently IPv6 + prefix).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-09 10:53:17 +03:00
Andrew Boie e8cede7940 net: fix references to stack buffers
The net_stack_analyze function wants to look at the stack buffer,
but it is making assumptions on where this data is that are no
longer valid. Change to use the proper APIs for referencing this.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-26 10:31:46 +03:00
Andrew Boie 65a9d2a94a kernel: make K_.*_INITIALIZER private to kernel
Upcoming memory protection features will be placing some additional
constraints on kernel objects:

- They need to reside in memory owned by the kernel and not the
application
- Certain kernel object validation schemes will require some run-time
initialization of all kernel objects before they can be used.

Per Ben these initializer macros were never intended to be public. It is
not forbidden to use them, but doing so requires care: the memory being
initialized must reside in kernel space, and extra runtime
initialization steps may need to be peformed before they are fully
usable as kernel objects. In particular, kernel subsystems or drivers
whose objects are already in kernel memory may still need to use these
macros if they define kernel objects as members of a larger data
structure.

It is intended that application developers instead use the
K_<object>_DEFINE macros, which will automatically put the object in the
right memory and add them to a section which can be iterated over at
boot to complete initiailization.

There was no K_WORK_DEFINE() macro for creating struct k_work objects,
this is now added.

k_poll_event and k_poll_signal are intended to be instatiated from
application memory and have not been changed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Andrew Boie 567c6c7683 misc: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Andrew Boie 7a0782d8ee net: use k_thread_create()
Common code in include/misc/stack.h is now used for analysis.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Kumar Gala a509441210 net: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I4ec03eb2183d59ef86ea2c20d956e5d272656837
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:30:38 -05:00
Tomasz Bursztyka 8108a608ff net/mgmt: Mask vs event should be verified part by part
It needs to check if current event matches:

- cb's layer
- cb's layer code
- cb's command

If none match, it will not raise the event.

Fixing the unit test as layer must be always != 0.

Jira: ZEP-1940

Change-Id: Iadd63e751fa6e534a10e7da9cae0f5bb5a384461
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 12:15:29 +00:00
Tomasz Bursztyka 82545373ee net/mgmt: Remove the list node before unlocking the semaphore
The caller semaphore was released too early, this can cause the caller
to re-use the data and possibly corrupt the memory, if caller yields
and is run before this management thread. Solution is to first remove
the node from the list and then unlock the semaphore.

Change-Id: I02cef53559d776f32a5959380e6b7122cd5198c5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-17 10:34:44 +02:00
Tomasz Bursztyka 1dfd399d77 net/mgmt: Remove a useless k_sem_init() and use K_SEM_DEFINE instead
Change-Id: I95ec89ad67f9d40df6773056d5af6a9df1332ca3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-17 10:34:43 +02:00
Tomasz Bursztyka d6d1b3a748 net/mgmt: Add a network interface based synchronous event listener
In case of callback based event listener, it is easy for the callback to
filter on the given interface. But in case of the synchronous call it's
not: it would need, after a failed comparison on the interface pointer
to loop by itself on the net_mgmt_event_wait() which is a little bit
heavy (reinstalling the event listener, with the semaphore and all) and
a bit of a burden for the caller itself.

Instead, net_mgmt provides a dedicated call
net_mgmt_event_wait_on_iface() which does it the right way, so the
callback and the related semaphore are destroyed if only the iface
matches the one given as parameter (besides the timeout obviously).

Change-Id: Iab05c3249586f4f4d0447eea42fdac72b8428f2e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-17 10:34:42 +02:00
Tomasz Bursztyka 35e5aa8865 net/mgmt: Add a function to wait on a event synchronously
Instead of creating a handler and a related callback structure on an
event_mask: net_mgmt_event_wait() can be used to wait synchronously on
such event_mask. The core mgmt part will seamlessly reuse the struct
net_mgmt_event_callback so the whole internal notification mechanism is
using the same code.

Change-Id: I426d782c770e75e5222aa3c5b703172b1f1f2e5e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-17 10:34:42 +02:00
Luiz Augusto von Dentz 4ab09bdead net: Convert FOR_EACH macro instances to use CONTAINER
Change-Id: I2fbdc8128bef79eac74441c84fbb80e31f6bc261
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-02-10 16:16:15 +00:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Luiz Augusto von Dentz 331c29f96c net: mgmt: Decode event fields
This decodes the event layer, code and type when debugging is enabled.

Change-Id: I23c6fb200f3287a138e46df9f472c9982898675d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-01-13 14:34:51 +00:00
Tomasz Bursztyka a1aa08c288 net: ip: Improve logging by adding a dedicated sys_log level
Let's make net stack having its own level of debugging through sys_log.
It replaces NET_DEBUG by NET_LOG_ENABLED, which is then semantically
better: someone wanting to log the errors might want that not only for
debugging.

Along with it, CONFIG_NET_LOG_GLOBAL option is added, in order to enable
all available logging in network stack. It is disabled by default but
might be found useful when warning/errors need to be logged, so it is
then unnecessary to selectively enable by hand all CONFIG_NET_DEBUG_*
options.

It is possible, locally, to override CONFIG_SYS_LOG_NET_LEVEL by setting
the level one want to NET_SYS_LOG_LEVEL. This can be useful on samples
or tests.

Change-Id: I56a8f052340bc3a932229963cc69b39912093b88
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-02 10:03:20 +01:00
Jukka Rissanen 3eaec41ab8 net: Moved net/ to subsys/net
* Moved networking code into subsys/net.
* Renamed net/yaip to net/ip at the same time.
* Fixed the tests/net to compile
* Fixed the Makefiles and Kconfig files in subsys/net
  to use the new location of the IP stack

Change-Id: Ie45d9e8cb45a93fefdf969b20a81e3b1d3c16355
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:20 +02:00
Renamed from net/yaip/net_mgmt.c (Browse further)