# Ethernet bridge configuration options

# Copyright 2025 NXP
# SPDX-License-Identifier: Apache-2.0

menuconfig NET_ETHERNET_BRIDGE
	bool "Ethernet Bridging support"
	select NET_PROMISCUOUS_MODE
	select NET_L2_VIRTUAL
	help
	  Enables Ethernet bridging where packets can be transparently
	  forwarded across interfaces registered to a bridge.

if NET_ETHERNET_BRIDGE

config NET_ETHERNET_BRIDGE_COUNT
	int "Max number of bridge interfaces"
	default 1
	range 1 16
	help
	  How many bridge interfaces are created. Each interface can bridge
	  two or more Ethernet interfaces.

config NET_ETHERNET_BRIDGE_ETH_INTERFACE_COUNT
	int "Max number of Ethernet interfaces bridged together"
	default 2
	range 2 32
	help
	  How many Ethernet interfaces can be bridged together per each
	  bridge interface.

choice NET_ETHERNET_BRIDGE_MAC
	prompt "Bridge interface MAC address source"
	default NET_ETHERNET_BRIDGE_RANDOM_MAC
	help
	  Select how the MAC (link) address of a bridge interface is assigned.
	  A bridge interface can own an IP address and terminate/originate
	  traffic of its own, so it needs a MAC address. For a fully custom
	  address the application can instead call net_if_set_link_addr() on the
	  bridge interface while it is down (bridge interfaces do not auto-start).

config NET_ETHERNET_BRIDGE_RANDOM_MAC
	bool "Random MAC address"
	help
	  Assign a random locally administered MAC address to each bridge
	  interface. A new address is generated on every boot, so peers'
	  ARP/neighbor caches for the bridge become stale across reboots.

config NET_ETHERNET_BRIDGE_UNIQUE_MAC
	bool "Stable MAC address derived from the device ID"
	depends on HWINFO
	help
	  Derive a stable locally administered MAC address from the hardware
	  device ID. The same address is used across reboots so peers' caches
	  stay valid. The bridge index is mixed in so multiple bridge interfaces
	  get distinct addresses. Falls back to a random address when no device
	  ID is available.

config NET_ETHERNET_BRIDGE_PREFIX_MAC
	bool "Stable MAC address from configured prefix"
	help
	  Assign a stable MAC address by appending the bridge index to a
	  configured five-octet MAC address prefix. The resulting address is the
	  same across reboots so peers' caches stay valid.

endchoice

config NET_ETHERNET_BRIDGE_MAC_PREFIX
	string "Bridge MAC address prefix"
	depends on NET_ETHERNET_BRIDGE_PREFIX_MAC
	default "02:00:00:00:00"
	help
	  Five-octet colon-separated MAC address prefix used for bridge
	  interfaces. The bridge index is used as the final octet, so bridge0
	  with prefix "02:00:00:00:00" gets "02:00:00:00:00:00" and bridge1
	  gets "02:00:00:00:00:01".

config NET_ETHERNET_BRIDGE_TXRX_DEBUG
	bool "Debug received and sent packets in bridge"
	depends on NET_L2_ETHERNET_LOG_LEVEL_DBG
	help
	  Enables printing of received and sent network packets.
	  This can produce lot of output so it is disabled by default.

config NET_ETHERNET_BRIDGE_SHELL
	bool "Ethernet Bridging management shell"
	select NET_SHELL
	help
	  Enables shell utility to manage bridge configuration interactively.

config NET_ETHERNET_BRIDGE_FDB
	bool "FDB (Forwarding database) table support"
	help
	  Enables FDB (Forwarding database) table support.

config NET_ETHERNET_BRIDGE_FDB_MAX_ENTRIES
	int "Max number of FDB (Forwarding database) entries"
	depends on NET_ETHERNET_BRIDGE_FDB
	default 32
	range 1 $(UINT16_MAX)
	help
	  How many FDB (Forwarding database) entries supported.

module = NET_ETHERNET_BRIDGE
module-dep = NET_LOG
module-str = Log level for Ethernet Bridging
module-help = Enables Ethernet Bridge code to output debug messages.
source "subsys/net/Kconfig.template.log_config.net"

endif # NET_ETHERNET_BRIDGE
