drivers: ethernet: Introduce ETH_DRIVER_RAW_MODE option

Add a Kconfig symbol to allow building ethernet device driver without
an L2 layer.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-03-11 11:18:18 +01:00 committed by David Leach
parent 78457c0499
commit e99b5228a1
5 changed files with 36 additions and 13 deletions

View file

@ -5,12 +5,21 @@
menuconfig ETH_DRIVER
bool "Ethernet drivers"
default y
depends on NET_L2_ETHERNET
depends on NETWORKING
depends on !NET_TEST
default y if NET_L2_ETHERNET
if ETH_DRIVER
config ETH_DRIVER_RAW_MODE
bool "Ethernet driver without the MAC stack"
select NET_RAW_MODE
depends on !NET_L2_ETHERNET
help
This option enables using the drivers in a so-called "raw" mode,
i.e. without a MAC stack (the net L2 layer for ethernet will not
be built).
module = ETHERNET
module-dep = LOG
module-str = Log level for Ethernet driver
@ -74,7 +83,7 @@ endif # "Ethernet Drivers"
config ETH_INIT_PRIORITY
int "Ethernet driver init priority"
default 80
depends on NET_L2_ETHERNET
depends on NET_L2_ETHERNET || ETH_DRIVER
help
Ethernet device driver initialization priority.
Do not mess with it unless you know what you are doing.

View file

@ -3,8 +3,11 @@
# Copyright (c) 2021 IP-Logix Inc.
# SPDX-License-Identifier: Apache-2.0
menu "Ethernet PHY Drivers"
depends on NET_L2_ETHERNET
menuconfig ETH_PHY_DRIVER
bool "Ethernet PHY drivers"
default y if NET_L2_ETHERNET || ETH_DRIVER
if ETH_PHY_DRIVER
module = PHY
module-dep = LOG
@ -63,4 +66,4 @@ config PHY_MONITOR_PERIOD
periodically executed to detect and report any changes in the
PHY link status to the operating system.
endmenu # "Ethernet PHY Drivers"
endif # "Ethernet PHY Drivers"

View file

@ -153,7 +153,6 @@ config SLIP_STATISTICS
config SLIP_TAP
bool "Use TAP interface to host"
default y
select NET_L2_ETHERNET
help
In TAP the Ethernet frames are transferred over SLIP.

View file

@ -932,6 +932,7 @@ static inline bool net_eth_get_vlan_status(struct net_if *iface)
}
#endif
#if !defined(CONFIG_ETH_DRIVER_RAW_MODE)
#if defined(CONFIG_NET_VLAN)
#define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
@ -957,6 +958,17 @@ static inline bool net_eth_get_vlan_status(struct net_if *iface)
NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)
#endif /* CONFIG_NET_VLAN */
#else /* CONFIG_ETH_DRIVER_RAW_MODE */
#define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
init_fn, pm, data, config, prio, \
api, mtu) \
Z_DEVICE_STATE_DEFINE(dev_id); \
Z_DEVICE_DEFINE(node_id, dev_id, name, init_fn, pm, data, \
config, POST_KERNEL, prio, api, \
&Z_DEVICE_STATE_NAME(dev_id));
#endif /* CONFIG_ETH_DRIVER_RAW_MODE */
#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
config, prio, api, mtu) \
Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, 0, \

View file

@ -583,12 +583,6 @@ config NET_CONTEXT_RECV_PKTINFO
This way user can get extra information about the received data in the
socket.
config NET_TEST
bool "Network Testing"
help
Used for self-contained networking tests that do not require a
network device.
config NET_SLIP_TAP
bool "TAP SLIP driver"
depends on NET_QEMU_SLIP
@ -606,6 +600,12 @@ config NET_SLIP_TAP
endif # NET_RAW_MODE
config NET_TEST
bool "Network Testing"
help
Used for self-contained networking tests that do not require a
network device.
config NET_PKT_RX_COUNT
int "How many packet receives can be pending at the same time"
default 14 if NET_L2_ETHERNET