diff --git a/include/net/net_if.h b/include/net/net_if.h
index 74784561fa2..052c35d9c1b 100644
--- a/include/net/net_if.h
+++ b/include/net/net_if.h
@@ -2211,6 +2211,15 @@ struct net_if_api {
/* Network device initialization macros */
+#define Z_NET_DEVICE_INIT(node_id, dev_name, drv_name, init_fn, \
+ pm_control_fn, data, cfg, prio, api, l2, \
+ l2_ctx_type, mtu) \
+ Z_DEVICE_DEFINE(node_id, dev_name, drv_name, init_fn, \
+ pm_control_fn, data, \
+ cfg, POST_KERNEL, prio, api); \
+ NET_L2_DATA_INIT(dev_name, 0, l2_ctx_type); \
+ NET_IF_INIT(dev_name, 0, l2, mtu, NET_IF_MAX_CONFIGS)
+
/**
* @def NET_DEVICE_INIT
*
@@ -2235,10 +2244,58 @@ struct net_if_api {
#define NET_DEVICE_INIT(dev_name, drv_name, init_fn, pm_control_fn, \
data, cfg, prio, api, l2, \
l2_ctx_type, mtu) \
- DEVICE_DEFINE(dev_name, drv_name, init_fn, pm_control_fn, data, \
- cfg, POST_KERNEL, prio, api); \
- NET_L2_DATA_INIT(dev_name, 0, l2_ctx_type); \
- NET_IF_INIT(dev_name, 0, l2, mtu, NET_IF_MAX_CONFIGS)
+ Z_NET_DEVICE_INIT(DT_INVALID_NODE, dev_name, drv_name, init_fn, \
+ pm_control_fn, data, cfg, prio, api, l2, \
+ l2_ctx_type, mtu)
+
+/**
+ * @def NET_DEVICE_DT_DEFINE
+ *
+ * @brief Like NET_DEVICE_INIT but taking metadata from a devicetree node.
+ * Create a network interface and bind it to network device.
+ *
+ * @param node_id The devicetree node identifier.
+ * @param init_fn Address to the init function of the driver.
+ * @param pm_control_fn Pointer to device_pm_control function.
+ * Can be empty function (device_pm_control_nop) if not implemented.
+ * @param data Pointer to the device's private data.
+ * @param cfg The address to the structure containing the
+ * configuration information for this instance of the driver.
+ * @param prio The initialization level at which configuration occurs.
+ * @param api Provides an initial pointer to the API function struct
+ * used by the driver. Can be NULL.
+ * @param l2 Network L2 layer for this network interface.
+ * @param l2_ctx_type Type of L2 context data.
+ * @param mtu Maximum transfer unit in bytes for this network interface.
+ */
+#define NET_DEVICE_DT_DEFINE(node_id, init_fn, pm_control_fn, data, cfg, \
+ prio, api, l2, l2_ctx_type, mtu) \
+ Z_NET_DEVICE_INIT(node_id, node_id, DT_LABEL(node_id), init_fn, \
+ pm_control_fn, data, cfg, prio, api, l2, \
+ l2_ctx_type, mtu)
+
+/**
+ * @def NET_DEVICE_DT_INST_DEFINE
+ *
+ * @brief Like NET_DEVICE_DT_DEFINE for an instance of a DT_DRV_COMPAT compatible
+ *
+ * @param inst instance number. This is replaced by
+ * DT_DRV_COMPAT(inst) in the call to NET_DEVICE_DT_DEFINE.
+ *
+ * @param ... other parameters as expected by NET_DEVICE_DT_DEFINE.
+ */
+#define NET_DEVICE_DT_INST_DEFINE(inst, ...) \
+ NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
+
+#define Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_name, drv_name, \
+ instance, init_fn, pm_control_fn, \
+ data, cfg, prio, api, l2, \
+ l2_ctx_type, mtu) \
+ Z_DEVICE_DEFINE(node_id, dev_name, drv_name, init_fn, \
+ pm_control_fn, data, cfg, POST_KERNEL, \
+ prio, api); \
+ NET_L2_DATA_INIT(dev_name, instance, l2_ctx_type); \
+ NET_IF_INIT(dev_name, instance, l2, mtu, NET_IF_MAX_CONFIGS)
/**
* @def NET_DEVICE_INIT_INSTANCE
@@ -2268,10 +2325,63 @@ struct net_if_api {
#define NET_DEVICE_INIT_INSTANCE(dev_name, drv_name, instance, init_fn, \
pm_control_fn, data, cfg, prio, \
api, l2, l2_ctx_type, mtu) \
- DEVICE_DEFINE(dev_name, drv_name, init_fn, pm_control_fn, data, \
- cfg, POST_KERNEL, prio, api); \
- NET_L2_DATA_INIT(dev_name, instance, l2_ctx_type); \
- NET_IF_INIT(dev_name, instance, l2, mtu, NET_IF_MAX_CONFIGS)
+ Z_NET_DEVICE_INIT_INSTANCE(DT_INVALID_NODE, dev_name, drv_name, \
+ instance, init_fn, pm_control_fn, \
+ data, cfg, prio, api, l2, \
+ l2_ctx_type, mtu)
+
+/**
+ * @def NET_DEVICE_DT_DEFINE_INSTANCE
+ *
+ * @brief Like NET_DEVICE_OFFLOAD_INIT but taking metadata from a devicetree.
+ * Create multiple network interfaces and bind them to network device.
+ * If your network device needs more than one instance of a network interface,
+ * use this macro below and provide a different instance suffix each time
+ * (0, 1, 2, ... or a, b, c ... whatever works for you)
+ *
+ * @param node_id The devicetree node identifier.
+ * @param instance Instance identifier.
+ * @param init_fn Address to the init function of the driver.
+ * @param pm_control_fn Pointer to device_pm_control function.
+ * Can be empty function (device_pm_control_nop) if not implemented.
+ * @param data Pointer to the device's private data.
+ * @param cfg The address to the structure containing the
+ * configuration information for this instance of the driver.
+ * @param prio The initialization level at which configuration occurs.
+ * @param api Provides an initial pointer to the API function struct
+ * used by the driver. Can be NULL.
+ * @param l2 Network L2 layer for this network interface.
+ * @param l2_ctx_type Type of L2 context data.
+ * @param mtu Maximum transfer unit in bytes for this network interface.
+ */
+#define NET_DEVICE_DT_DEFINE_INSTANCE(node_id, instance, init_fn, \
+ pm_control_fn, data, cfg, prio, \
+ api, l2, l2_ctx_type, mtu) \
+ Z_NET_DEVICE_INIT_INSTANCE(node_id, node_id, DT_LABEL(node_id), \
+ instance, init_fn, pm_control_fn, \
+ data, cfg, prio, api, l2, \
+ l2_ctx_type, mtu)
+
+/**
+ * @def NET_DEVICE_DT_INST_DEFINE_INSTANCE
+ *
+ * @brief Like NET_DEVICE_DT_DEFINE_INSTANCE for an instance of a DT_DRV_COMPAT
+ * compatible
+ *
+ * @param inst instance number. This is replaced by
+ * DT_DRV_COMPAT(inst) in the call to NET_DEVICE_DT_DEFINE_INSTANCE.
+ *
+ * @param ... other parameters as expected by NET_DEVICE_DT_DEFINE_INSTANCE.
+ */
+#define NET_DEVICE_DT_INST_DEFINE_INSTANCE(inst, ...) \
+ NET_DEVICE_DT_DEFINE_INSTANCE(DT_DRV_INST(inst), __VA_ARGS__)
+
+#define Z_NET_DEVICE_OFFLOAD_INIT(node_id, dev_name, drv_name, init_fn, \
+ pm_control_fn, data, cfg, prio, \
+ api, mtu) \
+ Z_DEVICE_DEFINE(node_id, dev_name, drv_name, init_fn, \
+ pm_control_fn, data, cfg, POST_KERNEL, prio, api);\
+ NET_IF_OFFLOAD_INIT(dev_name, 0, mtu)
/**
* @def NET_DEVICE_OFFLOAD_INIT
@@ -2295,11 +2405,50 @@ struct net_if_api {
* @param mtu Maximum transfer unit in bytes for this network interface.
*/
#define NET_DEVICE_OFFLOAD_INIT(dev_name, drv_name, init_fn, \
- pm_control_fn, data, cfg, prio, \
- api, mtu) \
- DEVICE_DEFINE(dev_name, drv_name, init_fn, pm_control_fn, data, \
- cfg, POST_KERNEL, prio, api); \
- NET_IF_OFFLOAD_INIT(dev_name, 0, mtu)
+ pm_control_fn, data, cfg, prio, api, mtu)\
+ Z_NET_DEVICE_OFFLOAD_INIT(DT_INVALID_NODE, dev_name, drv_name, \
+ init_fn, pm_control_fn, data, cfg, prio,\
+ api, mtu)
+
+/**
+ * @def NET_DEVICE_DT_OFFLOAD_DEFINE
+ *
+ * @brief Like NET_DEVICE_OFFLOAD_INIT but taking metadata from a devicetree
+ * node. Create a offloaded network interface and bind it to network device.
+ * The offloaded network interface is implemented by a device vendor HAL or
+ * similar.
+ *
+ * @param node_id The devicetree node identifier.
+ * @param init_fn Address to the init function of the driver.
+ * @param pm_control_fn Pointer to device_pm_control function.
+ * Can be empty function (device_pm_control_nop) if not implemented.
+ * @param data Pointer to the device's private data.
+ * @param cfg The address to the structure containing the
+ * configuration information for this instance of the driver.
+ * @param prio The initialization level at which configuration occurs.
+ * @param api Provides an initial pointer to the API function struct
+ * used by the driver. Can be NULL.
+ * @param mtu Maximum transfer unit in bytes for this network interface.
+ */
+#define NET_DEVICE_DT_OFFLOAD_DEFINE(node_id, init_fn, pm_control_fn, \
+ data, cfg, prio, api, mtu) \
+ Z_NET_DEVICE_OFFLOAD_INIT(node_id, node_id, DT_LABEL(node_id), \
+ init_fn, pm_control_fn, data, cfg, \
+ prio, api, mtu)
+
+/**
+ * @def NET_DEVICE_DT_INST_OFFLOAD_DEFINE
+ *
+ * @brief Like NET_DEVICE_DT_OFFLOAD_DEFINE for an instance of a DT_DRV_COMPAT
+ * compatible
+ *
+ * @param inst instance number. This is replaced by
+ * DT_DRV_COMPAT(inst) in the call to NET_DEVICE_DT_OFFLOAD_DEFINE.
+ *
+ * @param ... other parameters as expected by NET_DEVICE_DT_OFFLOAD_DEFINE.
+ */
+#define NET_DEVICE_DT_INST_OFFLOAD_DEFINE(inst, ...) \
+ NET_DEVICE_DT_OFFLOAD_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
#ifdef __cplusplus
}