Skip to content

Commit e511099

Browse files
doki-nordiclstnl
authored andcommitted
Code cleanup
1 parent b219745 commit e511099

File tree

6 files changed

+281
-213
lines changed

6 files changed

+281
-213
lines changed

doc/services/ipc/ipc_service/backends/ipc_service_icmsg.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ connected through the IPC instance:
8383
memory.
8484
#. It then sends a signal to the other domain or CPU, informing that the data
8585
has been written. Sending the signal to the other domain or CPU is repeated
86-
with timeout specified by
87-
:kconfig:option:`CONFIG_IPC_SERVICE_ICMSG_BOND_NOTIFY_REPEAT_TO_MS` option.
86+
with timeout.
8887
#. When the signal from the other domain or CPU is received, the magic number
8988
is read from ``rx-region``. If it is correct, the bonding process is finished
9089
and the backend informs the application by calling

dts/bindings/ipc/zephyr,ipc-icmsg.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ properties:
2626
enum:
2727
- disable
2828
- enable
29-
- compatibility
29+
- detect
3030
default: disable
3131
description: |
3232
Select unbound() callback mode. The callback can be enabled or disabled with the
3333
"enable" and "disable" option respectively. This functionality requires session
3434
number handshake procedure on both sides, so you cannot set "enable" on one side
35-
and "disable" on the other. The "compatibility" mode detects if the remote side
35+
and "disable" on the other. The "detect" mode detects if the remote side
3636
supports handshake procedure and adjusts its behavior accordingly. The
37-
"compatibility" mode is possible only if "dcache-alignment" is at least 8 bytes.
37+
"detect" mode is possible only if "dcache-alignment" is at least 8 bytes.
3838
3939
dcache-alignment:
4040
type: int

include/zephyr/ipc/icmsg.h

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,52 @@ extern "C" {
2727
*/
2828

2929
enum icmsg_state {
30-
// TODO: rename as it was before
31-
ICMSG_STATE_UNINITIALIZED, /**< Instance is not initialized yet. Sending will fail. Opening allowed. */
32-
ICMSG_STATE_INITIALIZING_SID_DISABLED, /**< Instance is initializing - waiting for remote to acknowledge. Sending will fail. Opening allowed, session will change and remote may or may not get unbound() callback. */
33-
ICMSG_STATE_INITIALIZING_SID_ENABLED, /**< Instance is initializing - waiting for remote to acknowledge. Sending will fail. Opening allowed, session will change and remote may or may not get unbound() callback. */
34-
ICMSG_STATE_INITIALIZING_SID_COMPAT, /**< Instance is initializing - waiting for remote to acknowledge. Sending will fail. Opening allowed, session will change and remote may or may not get unbound() callback. */
35-
ICMSG_STATE_DISCONNECTED, /**< Instance was connected, but get disconnected. Sending will be silently discarded, because it there may be old sends. Opening allowed. */
36-
// Connected states must be at the end
37-
ICMSG_STATE_CONNECTED_SID_DISABLED, /**< Instance is connected. Sending will be successful. Opening allowed, session will change and remote will get unbound() callback. */
38-
ICMSG_STATE_CONNECTED_SID_ENABLED, /**< Instance is connected. Sending will be successful. Opening allowed, session will change and remote will get unbound() callback. */
30+
/** Instance is not initialized yet. In this state: sending will fail, opening allowed.
31+
*/
32+
ICMSG_STATE_OFF,
33+
34+
/** Instance is initializing without session handshake. In this state: sending will fail,
35+
* opening will fail.
36+
*/
37+
ICMSG_STATE_INITIALIZING_SID_DISABLED,
38+
39+
/** Instance is initializing with session handshake. It is waiting for remote to acknowledge
40+
* local session id. In this state: sending will fail, opening is allowed (local session id
41+
* will change, so the remote may get unbound() callback).
42+
*/
43+
ICMSG_STATE_INITIALIZING_SID_ENABLED,
44+
45+
/** Instance is initializing with detection of session handshake support on remote side.
46+
* It is waiting for remote to acknowledge local session id or to send magic bytes.
47+
* In this state: sending will fail, opening is allowed (local session id
48+
* will change, so the remote may get unbound() callback if it supports it).
49+
*/
50+
ICMSG_STATE_INITIALIZING_SID_DETECT,
51+
52+
/** Instance was closed on remote side. The unbound() callback was send on local side.
53+
* In this state: sending will be silently discarded (there may be outdated sends),
54+
* opening is allowed.
55+
*/
56+
ICMSG_STATE_DISCONNECTED,
57+
58+
/* Connected states must be at the end. */
59+
60+
/** Instance is connected without session handshake support. In this state: sending will be
61+
* successful, opening will fail.
62+
*/
63+
ICMSG_STATE_CONNECTED_SID_DISABLED,
64+
65+
/** Instance is connected with session handshake support. In this state: sending will be
66+
* successful, opening is allowed (session will change and remote will get unbound()
67+
* callback).
68+
*/
69+
ICMSG_STATE_CONNECTED_SID_ENABLED,
3970
};
4071

4172
enum icmsg_unbound_mode {
4273
ICMSG_UNBOUND_MODE_DISABLE = ICMSG_STATE_INITIALIZING_SID_DISABLED,
4374
ICMSG_UNBOUND_MODE_ENABLE = ICMSG_STATE_INITIALIZING_SID_ENABLED,
44-
ICMSG_UNBOUND_MODE_COMPATIBILITY = ICMSG_STATE_INITIALIZING_SID_COMPAT,
75+
ICMSG_UNBOUND_MODE_DETECT = ICMSG_STATE_INITIALIZING_SID_DETECT,
4576
};
4677

4778
struct icmsg_config_t {
@@ -65,11 +96,10 @@ struct icmsg_data_t {
6596
/* General */
6697
const struct icmsg_config_t *cfg;
6798
#ifdef CONFIG_MULTITHREADING
68-
struct k_work_delayable notify_work; // TODO: Not needed if no compatibility needed
6999
struct k_work mbox_work;
70100
#endif
71-
uint16_t remote_session;
72-
uint16_t local_session;
101+
uint16_t remote_sid;
102+
uint16_t local_sid;
73103
atomic_t state;
74104
};
75105

subsys/ipc/ipc_service/backends/ipc_icmsg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ static int backend_init(const struct device *instance)
6868
DT_REG_SIZE(DT_INST_PHANDLE(i, tx_region)), \
6969
DT_INST_PROP_OR(i, dcache_alignment, 0), \
7070
UNBOUND_MODE(i) != ICMSG_UNBOUND_MODE_DISABLE, \
71-
UNBOUND_MODE(i) == ICMSG_UNBOUND_MODE_COMPATIBILITY); \
71+
UNBOUND_MODE(i) == ICMSG_UNBOUND_MODE_DETECT); \
7272
PBUF_DEFINE(rx_pb_##i, \
7373
DT_REG_ADDR(DT_INST_PHANDLE(i, rx_region)), \
7474
DT_REG_SIZE(DT_INST_PHANDLE(i, rx_region)), \
7575
DT_INST_PROP_OR(i, dcache_alignment, 0), \
7676
UNBOUND_MODE(i) != ICMSG_UNBOUND_MODE_DISABLE, \
77-
UNBOUND_MODE(i) == ICMSG_UNBOUND_MODE_COMPATIBILITY); \
77+
UNBOUND_MODE(i) == ICMSG_UNBOUND_MODE_DETECT); \
7878
\
7979
static struct icmsg_data_t backend_data_##i = { \
8080
.tx_pb = &tx_pb_##i, \

subsys/ipc/ipc_service/lib/Kconfig.icmsg

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ config IPC_SERVICE_ICMSG_SHMEM_ACCESS_TO_MS
2121
Maximum time to wait, in milliseconds, for access to send data with
2222
backends basing on icmsg library. This time should be relatively low.
2323

24-
config IPC_SERVICE_ICMSG_BOND_NOTIFY_REPEAT_TO_MS
25-
int "Bond notification timeout in miliseconds"
26-
range 1 100
27-
default 1
28-
help
29-
Time to wait for remote bonding notification before the
30-
notification is repeated.
31-
3224
config IPC_SERVICE_BACKEND_ICMSG_WQ_ENABLE
3325
bool "Use dedicated workqueue"
3426
depends on MULTITHREADING
@@ -68,6 +60,33 @@ config IPC_SERVICE_BACKEND_ICMSG_WQ_PRIORITY
6860

6961
endif
7062

63+
config IPC_SERVICE_ICMSG_UNBOUND_ENABLED_ALLOWED
64+
bool "Instance is allowed to set unbound to enabled"
65+
default y
66+
help
67+
Controls whether the "enabled" value of the "unbound"
68+
property is allowed to be set in any of the ICMsg instances. You
69+
can set this option to "n", if you want to reduce code size and
70+
no instance of ICMsg is using unbound functionality.
71+
72+
config IPC_SERVICE_ICMSG_UNBOUND_DISABLED_ALLOWED
73+
bool "Instance is allowed to set unbound to disabled"
74+
default y
75+
help
76+
Controls whether the "disabled" value of the "unbound"
77+
property is allowed to be set in any of the ICMsg instances. You
78+
can set this option to "n", if you want to reduce code size and
79+
all instances of ICMsg are using unbound functionality.
80+
81+
config IPC_SERVICE_ICMSG_UNBOUND_DETECT_ALLOWED
82+
bool "Instance is allowed to set unbound to detect"
83+
default y
84+
help
85+
Controls whether the "detect" value of the "unbound"
86+
property is allowed to be set in any of the ICMsg instances. You
87+
can set this option to "n", if you want to reduce code size and
88+
all instances of ICMsg are using unbound detection functionality.
89+
7190
# The Icmsg library in its simplicity requires the system workqueue to execute
7291
# at a cooperative priority.
7392
config SYSTEM_WORKQUEUE_PRIORITY

0 commit comments

Comments
 (0)