Skip to content

Commit 5a9a39c

Browse files
jukkarkartben
authored andcommitted
net: mgmt: Convert the mgmt API to use 64-bit masks
Instead of using 32 bit enum values for event numbers, convert the code to use 64 bit long bit fields. This means that the user API is changed to use 64 bit event values instead of 32 bit event values. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent f51a892 commit 5a9a39c

File tree

83 files changed

+546
-370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+546
-370
lines changed

doc/connectivity/networking/api/coap_server.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ following example simply prints when an event occurs.
242242
#define COAP_EVENTS_SET (NET_EVENT_COAP_OBSERVER_ADDED | NET_EVENT_COAP_OBSERVER_REMOVED | \
243243
NET_EVENT_COAP_SERVICE_STARTED | NET_EVENT_COAP_SERVICE_STOPPED)
244244
245-
void coap_event_handler(uint32_t mgmt_event, struct net_if *iface,
245+
void coap_event_handler(uint64_t mgmt_event, struct net_if *iface,
246246
void *info, size_t info_length, void *user_data)
247247
{
248248
switch (mgmt_event) {

doc/connectivity/networking/api/net_mgmt.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ An example follows.
9797
struct net_mgmt_event_callback ipv4_callback;
9898
9999
void callback_handler(struct net_mgmt_event_callback *cb,
100-
uint32_t mgmt_event,
100+
uint64_t mgmt_event,
101101
struct net_if *iface)
102102
{
103103
if (mgmt_event == NET_EVENT_IF_xxx) {
@@ -139,7 +139,7 @@ Or similarly using :c:macro:`NET_MGMT_REGISTER_EVENT_HANDLER`.
139139
#define EVENT_IFACE_SET (NET_EVENT_IF_xxx | NET_EVENT_IF_yyy)
140140
#define EVENT_IPV4_SET (NET_EVENT_IPV4_xxx | NET_EVENT_IPV4_yyy)
141141
142-
static void event_handler(uint32_t mgmt_event, struct net_if *iface,
142+
static void event_handler(uint64_t mgmt_event, struct net_if *iface,
143143
void *info, size_t info_length,
144144
void *user_data)
145145
{
@@ -183,7 +183,7 @@ You define your handler modeled with this signature:
183183

184184
.. code-block:: c
185185
186-
static int your_handler(uint32_t mgmt_event, struct net_if *iface,
186+
static int your_handler(uint64_t mgmt_event, struct net_if *iface,
187187
void *data, size_t len);
188188
189189
and then register it with an associated mgmt_request code:

drivers/modem/modem_cellular.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ static int modem_cellular_pm_action(const struct device *dev, enum pm_device_act
17741774
}
17751775
#endif /* CONFIG_PM_DEVICE */
17761776

1777-
static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event,
1777+
static void net_mgmt_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event,
17781778
struct net_if *iface)
17791779
{
17801780
struct modem_cellular_data *data =

drivers/wifi/esp32/src/esp_wifi_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct esp32_wifi_runtime {
7777

7878
static struct net_mgmt_event_callback esp32_dhcp_cb;
7979

80-
static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event,
80+
static void wifi_event_handler(struct net_mgmt_event_callback *cb, uint64_t mgmt_event,
8181
struct net_if *iface)
8282
{
8383
switch (mgmt_event) {

include/zephyr/net/coap_mgmt.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,25 @@ struct coap_service;
4040
struct coap_resource;
4141
struct coap_observer;
4242

43+
enum {
44+
NET_EVENT_COAP_CMD_SERVICE_STARTED_VAL,
45+
NET_EVENT_COAP_CMD_SERVICE_STOPPED_VAL,
46+
NET_EVENT_COAP_CMD_OBSERVER_ADDED_VAL,
47+
NET_EVENT_COAP_CMD_OBSERVER_REMOVED_VAL,
48+
49+
NET_EVENT_COAP_CMD_MAX
50+
};
51+
52+
BUILD_ASSERT(NET_EVENT_COAP_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
53+
"Number of events in net_event_coap_cmd exceeds the limit");
54+
4355
enum net_event_coap_cmd {
4456
/* Service events */
45-
NET_EVENT_COAP_CMD_SERVICE_STARTED = 1,
46-
NET_EVENT_COAP_CMD_SERVICE_STOPPED,
57+
NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STARTED),
58+
NET_MGMT_CMD(NET_EVENT_COAP_CMD_SERVICE_STOPPED),
4759
/* Observer events */
48-
NET_EVENT_COAP_CMD_OBSERVER_ADDED,
49-
NET_EVENT_COAP_CMD_OBSERVER_REMOVED,
60+
NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_ADDED),
61+
NET_MGMT_CMD(NET_EVENT_COAP_CMD_OBSERVER_REMOVED),
5062
};
5163

5264
/** @endcond */

include/zephyr/net/conn_mgr_connectivity.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,19 @@ extern "C" {
4141
NET_MGMT_EVENT_BIT)
4242
#define NET_MGMT_CONN_IF_EVENT (NET_MGMT_IFACE_BIT | NET_MGMT_CONN_BASE)
4343

44+
enum {
45+
NET_EVENT_CONN_CMD_IF_TIMEOUT_VAL,
46+
NET_EVENT_CONN_CMD_IF_FATAL_ERROR_VAL,
47+
48+
NET_EVENT_CONN_CMD_MAX
49+
};
50+
51+
BUILD_ASSERT(NET_EVENT_CONN_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
52+
"Number of events in net_event_conn_cmd exceeds the limit");
53+
4454
enum net_event_conn_cmd {
45-
NET_EVENT_CONN_CMD_IF_TIMEOUT = 1,
46-
NET_EVENT_CONN_CMD_IF_FATAL_ERROR,
55+
NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_TIMEOUT),
56+
NET_MGMT_CMD(NET_EVENT_CONN_CMD_IF_FATAL_ERROR),
4757
};
4858

4959
/** @endcond */

include/zephyr/net/ethernet_mgmt.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,23 @@ struct ethernet_req_params {
162162
};
163163
};
164164

165+
enum {
166+
NET_EVENT_ETHERNET_CMD_CARRIER_ON_VAL,
167+
NET_EVENT_ETHERNET_CMD_CARRIER_OFF_VAL,
168+
NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED_VAL,
169+
NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED_VAL,
170+
171+
NET_EVENT_ETHERNET_CMD_MAX
172+
};
173+
174+
BUILD_ASSERT(NET_EVENT_ETHERNET_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
175+
"Number of events in net_event_ethernet_cmd exceeds the limit");
176+
165177
enum net_event_ethernet_cmd {
166-
NET_EVENT_ETHERNET_CMD_CARRIER_ON = 1,
167-
NET_EVENT_ETHERNET_CMD_CARRIER_OFF,
168-
NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED,
169-
NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED,
178+
NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_CARRIER_ON),
179+
NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_CARRIER_OFF),
180+
NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_VLAN_TAG_ENABLED),
181+
NET_MGMT_CMD(NET_EVENT_ETHERNET_CMD_VLAN_TAG_DISABLED),
170182
};
171183

172184
#define NET_EVENT_ETHERNET_CARRIER_ON \

include/zephyr/net/ieee802154_mgmt.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,17 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_IEEE802154_GET_SECURITY_SETTINGS);
255255
* @cond INTERNAL_HIDDEN
256256
*/
257257

258+
enum {
259+
NET_EVENT_IEEE802154_CMD_SCAN_RESULT_VAL,
260+
261+
NET_EVENT_IEEE802154_CMD_MAX
262+
};
263+
264+
BUILD_ASSERT(NET_EVENT_IEEE802154_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
265+
"Number of events in net_event_ieee802154_cmd exceeds the limit");
266+
258267
enum net_event_ieee802154_cmd {
259-
NET_EVENT_IEEE802154_CMD_SCAN_RESULT = 1,
268+
NET_MGMT_CMD(NET_EVENT_IEEE802154_CMD_SCAN_RESULT),
260269
};
261270

262271
/**

0 commit comments

Comments
 (0)