Skip to content

Commit cfe0a68

Browse files
JordanYatesjhedberg
authored andcommitted
net: net_if: add NET_IF_DECLARE
Add a helper macro to declare a network interface, enabling the use of `NET_IF_GET` in the driver before the call to `NET_DEVICE_OFFLOAD_INIT` or `NET_DEVICE_INIT`. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 8d09755 commit cfe0a68

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/zephyr/net/net_if.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,6 +3495,16 @@ extern int net_stats_prometheus_scrape(struct prometheus_collector *collector,
34953495

34963496
/* Network device initialization macros */
34973497

3498+
/**
3499+
* @brief Forward declaration of a network interface
3500+
*
3501+
* Enables to use of `NET_IF_GET` above the instantiation macro.
3502+
*
3503+
* @param dev_id Device ID provided to `NET_IF_INIT` or `NET_IF_OFFLOAD_INIT`
3504+
*/
3505+
#define NET_IF_DECLARE(dev_id, inst) \
3506+
static struct net_if NET_IF_GET_NAME(dev_id, inst)[NET_IF_MAX_CONFIGS]
3507+
34983508
#define Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
34993509
init_fn, pm, data, config, prio, \
35003510
api, l2, l2_ctx_type, mtu) \

0 commit comments

Comments
 (0)