ipc_service: Extend RPMsg structs and misc fixes

Extend the RPMsg structs to accommodate for the introduction of new
backends and contextually fix the ipc_rpmsg_static_vrings_mi backend
(the only user).

Rework also some comments and ipc_service glue code.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2021-11-15 15:45:43 +01:00 committed by Christopher Friedt
commit d7a40ba5d7
8 changed files with 55 additions and 12 deletions

View file

@ -46,7 +46,10 @@ struct ipc_rpmsg_ept {
struct rpmsg_endpoint ep;
/** Name of the endpoint. */
const char *name;
char name[RPMSG_NAME_SIZE];
/** Destination endpoint. */
uint32_t dest;
/** Bound flag. */
volatile bool bound;
@ -77,6 +80,9 @@ struct ipc_rpmsg_instance {
/** EPT (instance) callback. */
rpmsg_ept_cb cb;
/** Mutex for the instance. */
struct k_mutex mtx;
};
/** @brief Init an RPMsg instance.

View file

@ -136,15 +136,18 @@ int ipc_service_open_instance(const struct device *instance);
* Registers IPC endpoint onto an instance to enable communication with a
* remote device.
*
* The same function registers endpoints for both master and slave devices.
* The same function registers endpoints for both host and remote devices.
*
* @param instance Instance to register the endpoint onto.
* @param ept Endpoint object.
* @param cfg Endpoint configuration.
*
* @retval -EIO when no backend is registered.
* @retval -EINVAL when instance or endpoint configuration is invalid.
* @retval Other errno codes depending on the implementation of the backend.
* @retval -EINVAL when instance, endpoint or configuration is invalid.
* @retval -EBUSY when the instance is busy.
*
* @retval 0 on success.
* @retval other errno codes depending on the implementation of the backend.
*/
int ipc_service_register_endpoint(const struct device *instance,
struct ipc_ept *ept,
@ -156,8 +159,14 @@ int ipc_service_register_endpoint(const struct device *instance,
* @param data Pointer to the buffer to send.
* @param len Number of bytes to send.
*
* @retval -EIO when no backend is registered.
* @retval Other errno codes depending on the implementation of the backend.
* @retval -EIO when no backend is registered or send hook is missing from
* backend.
* @retval -EINVAL when instance or endpoint is invalid.
* @retval -EBADMSG when the message is invalid.
* @retval -EBUSY when the instance is busy.
*
* @retval 0 on success.
* @retval other errno codes depending on the implementation of the backend.
*/
int ipc_service_send(struct ipc_ept *ept, const void *data, size_t len);

View file

@ -44,7 +44,13 @@ struct ipc_service_backend {
* @param data Pointer to the buffer to send.
* @param len Number of bytes to send.
*
* @retval Status code.
* @retval -EINVAL when instance is invalid.
* @retval -EBADMSG when the message is invalid.
* @retval -EBUSY when the instance is busy or not ready.
*
* @retval 0 on success
* @retval other errno codes depending on the implementation of the
* backend.
*/
int (*send)(const struct device *instance, void *token,
const void *data, size_t len);
@ -55,7 +61,12 @@ struct ipc_service_backend {
* @param token Backend-specific token.
* @param cfg Endpoint configuration.
*
* @retval Status code.
* @retval -EINVAL when the endpoint configuration or instance is invalid.
* @retval -EBUSY when the instance is busy or not ready.
*
* @retval 0 on success
* @retval other errno codes depending on the implementation of the
* backend.
*/
int (*register_endpoint)(const struct device *instance,
void **token,

View file

@ -24,6 +24,9 @@ extern "C" {
/** Number of used VRING buffers. */
#define VRING_COUNT (2)
/** VRING alignment. */
#define VRING_ALIGNMENT CONFIG_IPC_SERVICE_STATIC_VRINGS_ALIGNMENT
/**
* @typedef ipc_notify_cb
* @brief Define the notify callback.