Commit graph

36 commits

Author SHA1 Message Date
Piotr Koziar e66b382639 ipc: fix return code of icbmsg backend send operation.
This commit fixes the issue where a serialization
error was reported after properly sending a data with 'icbmsg' backend.

The icbmsg send function's return code is set to
the sent data's len as in other backends.
The related docs were fixed and updated.

Signed-off-by: Piotr Koziar <piotr.koziar@nordicsemi.no>
2024-06-10 15:00:01 +03:00
Gerard Marull-Paretas 80cc7d1ee5 drivers: mbox: update MBOX consumers to the new API
Update all usages of the MBOX API to the latest API changes (to be
squashed for bisectability).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-03-07 14:32:57 +00:00
Daniel Leung 6bb46c7fe7 ipc: pbuf: fix incorrect doxygen group
The ipc/pbuf was tagged as kernel API, which is not correct.
As this is for IPC, move it under IPC doxygen group and also
give it its own subgroup. So now the packed buffer API appears
under IPC in API doc.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-11-15 14:18:14 +00:00
Dominik Kilian 28df44946f ipc: add dynamically allocated buffers to icmsg
The icmsg and icmsg_me backends has limitations in context of
concurrent access to single instance. Some limitations are:
* sending by more thread at the same time may cause -EBUSY
* allocating TX buffer will cause errors in other threads that want
  to allocate before first thread sent the message,
* during no-copy receive, when RX buffer is on hold receiving is
  totally blocked.
This backend resolves those limitations by adding dynamically allocated
buffers on shared memory next to ICmsg circular buffer. The data is
passed using those buffers, so concurrency is not a problem. The ICmsg
is used only to pass short 2-byte messages containing references to
those buffers. The backend also supports multiple endpoint.
The ipc/icmsg_me sample was modified to support this backend.

Signed-off-by: Dominik Kilian <Dominik.Kilian@nordicsemi.no>
2023-11-13 11:11:43 +01:00
Emil Obalski eb4fc3f083 ipc: backends: Port IcMsg based backends to use pbuf
Replace spsc_pbuf with pbuf implementation dedicated to
be used by IcMsg based backends.
The pbuf is written on top of simple read/write semantics
with minimal footprint and code complexity

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:18:37 +00:00
Emil Obalski 380f83bab1 ipc: Add pbuf implementation
This adds implementation of secure packed buffer.
Secure packed buffer is added with intention to be used
in icmsg backed backends.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:18:37 +00:00
Emil Obalski f93243b68f ipc: Remove nocopy feature from icmsg_me backend
Remove nocopy feature from icmsg_me backend.
The backend is not meant to be used to send big
data chunks thus no-copy feature is removed.
If one wants to use no-copy it is recommended
to use icmsg_me only for control messages while
allocator will shall be written seperately.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-11-09 10:18:37 +00:00
Carlo Caione 9752cbe045 ipc_service: open-amp: Align VRINGs
This patchset is doing three things:

1. It is fixing the bogus algorithm to find the optimal number of
   descriptors for a given memory size.

2. It is changing values for VDEV_STATUS_SIZE and
   IPC_SERVICE_STATIC_VRINGS_ALIGNMENT to better align to a usual cache
   line size.

3. RX/TX VRINGs are now correctly aligned to MEM_ALIGNMENT (and cache
   line alignment).

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-18 11:04:46 +00:00
Kamil Gawor 82bff62276 ipc: icmsg: Align naming for buffers
This remanes send_buffer to tx_buffer to be
consistent with Rx buffer naming and with
mbox naming.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2023-06-21 15:56:02 +02:00
Kamil Gawor b7f14ee94f ipc: icmsg: Improve packets reception
This improves packet reception and fix an issue
where packets bigger than internal Rx buffer
were silently dropped. In current solution
local data coping for reception is not needed.
User gets direct pointer to shared memory which
allow to efficient receive as much data as was sent.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2023-06-21 15:56:02 +02:00
Gerard Marull-Paretas 248137169a doc: doxygen: add some subsystems to os_services group
Add the following root Doxygen modules under the umbrella of "OS
Services" Doxygen group:

- Cache
- File system
- IPC
- RTIO
- CRC
- Iterable sections
- ZBus
- Task watchdog
- Shell
- Semihosting
- Logging
- System init

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-31 14:39:29 -04:00
Emil Obalski 169d8fafdc ipc: icmsg: Add mutual exclussion access to shmem
If the icmsg backend is sending the data from many
contexts, the send buffer must be accessed only by one
context at a time. Ensure that by adding mutex when
sending.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Emil Obalski 52e203f800 ipc: Remove internal API for clearing shared memory
Clearing of shared memory by one side of the communication
is no longer required after
commit 0620cb1fe1
("ipc: ipc_service: icmsg: Increase reliability of bonding")
was merged.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-29 12:24:17 +02:00
Pawel Osypiuk 4b7f156403 IPC: rpmsg: Changed method of checking bounded endpoints
Initially that was checked by presence of name and now is changed
to check the flag.

Signed-off-by: Pawel Osypiuk <pawelosyp@gmail.com>
2023-04-24 15:45:09 +02:00
Emil Obalski 5143db540c ipc: Fix icmsg deregister functionality
This change fixes the deregister functionality for
icmsg backend. There are two changes:

Memory access layer was not initialized properly
when the endpoint was registered again. This lead to
memory fault when attepmt to write to the buffer was
done.

Mbox driver was initialized before memory access layer
was initialized. This could lead to race condition
where immediately after the mbox driver was initialized,
the receiving work is scheduled due to pending interrupt.
In that case an attempt to read from garbage address will
occur.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2023-04-03 11:29:08 +02:00
Hubert Miś 2c3863160d ipc: multi-endpoint icmsg cleanup
The multi-endpoint backend of the ipc_service subsystem contains two
roles with separated implementations: initiator and follower. There
was many code duplications for both roles. This patch introduces a new
IPC library: icmsg_me containing common code extracted from both roles
and encapsulating access to common data fields.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2023-02-23 10:46:25 +01:00
Hubert Miś 3a1c9bce6e ipc: icmsg: send nocopy feature
Add a nocopy feature for sending message through the icmsg IPC library.

Also eliminate data races if multiple threads are using the
same ipc instance and are trying to send a message simultaneously.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś 5b023df67f ipc: icmsg: rx nocopy feature
This patch adds an optional nocopy feature for RX message to the icmsg
IPC library. The nocopy feature can be enabled using project
configuration.

If this feature is not used by icmsg users it is recommended to disable it
to reduce memory usage and improve run-time performance.

Signed-off-by: Hubert Miś <hubert.mis@gmail.com>
2022-12-22 11:07:44 +01:00
Hubert Miś 4a79754dd5 ipc: icmsg capability to clear rx buffer headers
On system startup icmsg headers space must be cleared before
cores start handshake procedure. The simplest way to enforce
it is to clear memory by the core responsible by enabling
the remote core, before the remote core is enabled and before
the handshake is started.

This patch ensures that nRF53 APP core clears both TX and RX
memory for icmsg before it starts NET core.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-12-22 11:07:44 +01:00
Radoslaw Koppel 0620cb1fe1 ipc: ipc_service: icmsg: Increase reliability of bonding
This commit changes the way bonding between endpoints is processed.
There is no blind attempt to read the buffer without mbox notification.
On second side the notification is repeated multiple times until valid
bonding is detected.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2022-11-23 11:34:04 +01:00
Hubert Miś 6f450fdf18 ipc: separate icmsg core from ipc_service backend
icmsg library was implemented as a ipc_service backend. It is a simple
library with minimal feature set. To preserve its simplicity while
adding more features it is useful to introduce separated ipc_service
backends with added features. To reuse most of the icmsg code for the
simplest backend and other including more features, the core of icmsg
is separated from the simplest ipc_service to an icmsg module which
can be used by multiple backends.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2022-11-09 10:41:43 +01:00
Emil Obalski 2e9992f3c8 doc: Add IPC service documentation
Adding IPC service documentation for ICMSg backend.

Signed-off-by: Emil Obalski <Emil.Obalski@nordicsemi.no>
2022-11-04 11:51:54 +01:00
Gerard Marull-Paretas 6a0f554ffa include: add missing kernel.h include
Some files make use of Kernel APIs without including kernel.h, fix this
problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-11 18:05:17 +02:00
Jackson Cooper-Driver 23c9f7b215 ipc_service: Add ipc_service_close_instance function
This function allows the application to close an ipc_service instance.
It is intended for use when the remote agent it is communicating with
has gone down and allows for cleanup.
It first checks that the endpoints have been separately deregistered
with the instance using the deregister_endpoint function before
calling into previously added functions in ipc_static_vrings.c
and ipc_rpmsg.c to close those instances.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Jackson Cooper-Driver e69d131bc5 ipc_service: Adding ipc_static_vrings_deinit function
This function deinitialises the static vrings used by the ipc_service
instance. It acheieves this by tearing down the initialised
virtqueues before closing the various aspects of libmetal which
are in use.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Jackson Cooper-Driver f16a19c33f ipc_service: Add ipc_rpmsg_deinit function
This function does the opposite of the ipc_rpmsg_init function and
allows the rpmsg instance to be torndown in the case that the application
wishes to do so. It is intended to be used by the ipc_service subsystem.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-10-03 10:08:44 +02:00
Anas Nashif a8a69559cd doc: doxygen: move all IPC APIs under one group
Group all related APIs under one parent group.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-09-07 10:36:25 +02:00
Jackson Cooper-Driver 09cb88edcf ipc_service: Add ipc_service_deregister_endpoint function
In the case that an endpoint goes down, it needs to be deregistered
from the ipc_service for cleanup. This function deregisters the endpoint
from the ipc_rpmsg instance and sets the endpoint to zero.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-08-18 12:32:21 +02:00
Jackson Cooper-Driver f06c06de07 ipc_service: Add endpoint registered check
Currently, it is possible to call various ipc_service functions
which take in an endpoint pointer (such as send, get_tx_buffer)
with an endpoint which has not been registered with the instance.
This leads to dereferencing a NULL pointer when the function tries
to access the api field of ept->instance.
This patch adds in multiple checks to ensure that the endpoint is
registered before continuing, one in the frontend, when ensures
that the ept->instance pointer is not NULL and one in the backend
which checks the value of the token pointer. If either of these fail,
we return -ENOENT.

Signed-off-by: Jackson Cooper-Driver <jackson.cooper---driver@amd.com>
2022-07-14 10:29:42 +02:00
Krzysztof Chruscinski 2f189e39a5 lib: os: Rename icmsg_buf to spsc_pbuf
Move icmsg_buf to lib/os and rename to spsc_pbuf (Single Producer
Single Consumer Packet Buffer). It is a generic module and initially
was created as internal module for ipc service.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-07 19:04:35 +02:00
Carlo Caione 01305942f6 ipc: static_vrings: Support DT-defined buffer size
Recently OpenAMP introduced the possibility to set the sizes for TX and
RX buffers per created instance. Expose this also to Zephyr users by
using a DT property "zephyr,buffer-size".

For the sake of simplicity use the same DT property to set the buffer
size for both TX and RX buffers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-06-05 14:46:18 +02:00
Carlo Caione 11f0bb9d1a ipc: static_vrings: Add -ENOMEM case
Sometimes it is important to know when the backend fails to send out
data because no memory / buffers are available. Return -ENOMEM in that
case.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-16 16:56:33 +02:00
Gerard Marull-Paretas fb9b3bcd93 include: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all includes within
include directory 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-06 20:03:00 +02:00
Carlo Caione 55dc21ffb9 openamp: Bump to v2022.04.0
Bump OpenAMP to v2022.04.0 and fix Zephyr terminology linked to OpenAMP.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-05-02 08:44:17 -05:00
Yuval Peress 9d58ea8470 include: update references to <device.h>
Use prefix zephyr/ for device.h includes

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-21 07:40:54 -05:00
Yuval Peress 53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00