@@ -1257,6 +1257,79 @@ static inline bool net_eth_is_vlan_interface(struct net_if *iface)
12571257#define ETH_NET_DEVICE_DT_INST_DEFINE (inst , ...) \
12581258 ETH_NET_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
12591259
1260+
1261+ #if !defined(CONFIG_ETH_DRIVER_RAW_MODE )
1262+
1263+ #define Z_ETH_NET_DEVICE_INSTANCE_SFX (ident , sfx , init_fn , pm , data , \
1264+ config , api , mtu ) \
1265+ Z_NET_DEVICE_INSTANCE_SFX(ident, sfx, init_fn, pm, data, \
1266+ config, api, ETHERNET_L2, \
1267+ NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)
1268+
1269+ #else /* CONFIG_ETH_DRIVER_RAW_MODE */
1270+
1271+ #define Z_ETH_NET_DEVICE_INSTANCE_SFX (ident , sfx , init_fn , pm , data , \
1272+ config , api , mtu ) \
1273+ DEVICE_INSTANCE(ident, init_fn, pm, data, config, \
1274+ POST_KERNEL, api);
1275+
1276+ #endif /* CONFIG_ETH_DRIVER_RAW_MODE */
1277+
1278+ /**
1279+ * @brief Create an Ethernet network interface and bind it to network device.
1280+ *
1281+ * @param ident Either a devicetree node identifier or a plain unique token
1282+ * @param init_fn Address to the init function of the driver.
1283+ * @param pm Reference to struct pm_device associated with the device.
1284+ * (optional).
1285+ * @param data Pointer to the device's private data.
1286+ * @param config The address to the structure containing the
1287+ * configuration information for this instance of the driver.
1288+ * @param api Provides an initial pointer to the API function struct
1289+ * used by the driver. Can be NULL.
1290+ * @param mtu Maximum transfer unit in bytes for this network interface.
1291+ */
1292+ #define ETH_NET_DEVICE_INSTANCE (ident , init_fn , pm , data , config , \
1293+ api , mtu ) \
1294+ Z_ETH_NET_DEVICE_INSTANCE_SFX(ident, 0, init_fn, pm, data, \
1295+ config, api, mtu)
1296+
1297+ /**
1298+ * @brief Like ETH_NET_DEVICE_INSTANCE for an instance of a DT_DRV_COMPAT
1299+ * compatible
1300+ *
1301+ * @param inst instance number. This is replaced by
1302+ * <tt>DT_DRV_COMPAT(inst)</tt> in the call to ETH_NET_DEVICE_INSTANCE.
1303+ *
1304+ * @param ... other parameters as expected by ETH_NET_DEVICE_INSTANCE.
1305+ */
1306+ #define ETH_NET_DEVICE_INSTANCE_FROM_DT_INST (inst , ...) \
1307+ ETH_NET_DEVICE_INSTANCE(DT_DRV_INST(inst), __VA_ARGS__)
1308+
1309+ /**
1310+ * @brief Create multiple Ethernet network interfaces and bind them to network
1311+ * devices.
1312+ * If your network device needs more than one instance of a network interface,
1313+ * use this macro below and provide a different instance suffix each time
1314+ * (0, 1, 2, ... or a, b, c ... whatever works for you)
1315+ *
1316+ * @param ident Either a devicetree node identifier or a plain unique token
1317+ * @param sfx Instance suffix for differentiation.
1318+ * @param init_fn Address to the init function of the driver.
1319+ * @param pm Reference to struct pm_device associated with the device.
1320+ * (optional).
1321+ * @param data Pointer to the device's private data.
1322+ * @param config The address to the structure containing the
1323+ * configuration information for this instance of the driver.
1324+ * @param api Provides an initial pointer to the API function struct
1325+ * used by the driver. Can be NULL.
1326+ * @param mtu Maximum transfer unit in bytes for this network interface.
1327+ */
1328+ #define ETH_NET_DEVICE_INSTANCE_MULTI (ident , sfx , init_fn , \
1329+ pm , data , config , api , mtu ) \
1330+ Z_ETH_NET_DEVICE_INSTANCE_SFX(ident, sfx, init_fn, pm, data, \
1331+ config, api, mtu)
1332+
12601333/**
12611334 * @brief Inform ethernet L2 driver that ethernet carrier is detected.
12621335 * This happens when cable is connected.
0 commit comments