From 2ee4716091fbcc7364a64a3eb7cf5e4d3d978b63 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Mon, 11 Mar 2024 15:14:05 +0100 Subject: [PATCH] drivers: ethernet: Build ethernet drivers with ETH_DRIVER_RAW_MODE Allow building ethernet drivers without NET_L2_ETHERNET config symbol. Signed-off-by: Pieter De Gendt --- drivers/CMakeLists.txt | 2 +- drivers/ethernet/CMakeLists.txt | 5 ++++ drivers/ethernet/eth_raw.c | 48 +++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 drivers/ethernet/eth_raw.c diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index f0236ef653a..e1dbab7e1a2 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -35,6 +35,7 @@ add_subdirectory_ifdef(CONFIG_EDAC edac) add_subdirectory_ifdef(CONFIG_EEPROM eeprom) add_subdirectory_ifdef(CONFIG_ENTROPY_GENERATOR entropy) add_subdirectory_ifdef(CONFIG_ESPI espi) +add_subdirectory_ifdef(CONFIG_ETH_DRIVER ethernet) add_subdirectory_ifdef(CONFIG_FLASH flash) add_subdirectory_ifdef(CONFIG_FPGA fpga) add_subdirectory_ifdef(CONFIG_FUEL_GAUGE fuel_gauge) @@ -61,7 +62,6 @@ add_subdirectory_ifdef(CONFIG_MIPI_DSI mipi_dsi) add_subdirectory_ifdef(CONFIG_MM_DRV mm) add_subdirectory_ifdef(CONFIG_MODEM modem) add_subdirectory_ifdef(CONFIG_NET_DRIVERS net) -add_subdirectory_ifdef(CONFIG_NET_L2_ETHERNET ethernet) add_subdirectory_ifdef(CONFIG_PECI peci) add_subdirectory_ifdef(CONFIG_PINCTRL pinctrl) add_subdirectory_ifdef(CONFIG_PM_CPU_OPS pm_cpu_ops) diff --git a/drivers/ethernet/CMakeLists.txt b/drivers/ethernet/CMakeLists.txt index def0c5bf186..fcc43cf77f7 100644 --- a/drivers/ethernet/CMakeLists.txt +++ b/drivers/ethernet/CMakeLists.txt @@ -2,6 +2,11 @@ zephyr_library() zephyr_library_property(ALLOW_EMPTY TRUE) +zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/l2) + +zephyr_library_sources_ifdef(CONFIG_ETH_DRIVER_RAW_MODE + eth_raw.c + ) zephyr_library_sources_ifdef(CONFIG_ETH_GECKO eth_gecko.c diff --git a/drivers/ethernet/eth_raw.c b/drivers/ethernet/eth_raw.c new file mode 100644 index 00000000000..69ab3b528f7 --- /dev/null +++ b/drivers/ethernet/eth_raw.c @@ -0,0 +1,48 @@ +/** + * @file + * @brief Ethernet Driver raw mode + * + * This file contains a collection of functions called from the ethernet drivers + * to the missing upper layer. + */ + +/* + * Copyright 2024 Basalte bv + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +__weak void ethernet_init(struct net_if *iface) +{ + ARG_UNUSED(iface); +} + +__weak void net_eth_carrier_on(struct net_if *iface) +{ + ARG_UNUSED(iface); +} + +__weak void net_eth_carrier_off(struct net_if *iface) +{ + ARG_UNUSED(iface); +} + +__weak int net_recv_data(struct net_if *iface, struct net_pkt *pkt) +{ + ARG_UNUSED(iface); + ARG_UNUSED(pkt); + + return -ENOTSUP; +} + +__weak void net_if_carrier_on(struct net_if *iface) +{ + ARG_UNUSED(iface); +} + +__weak void net_if_carrier_off(struct net_if *iface) +{ + ARG_UNUSED(iface); +}