drivers/ethernet/eth_native_posix: Rename to eth_native_tap

Rename this driver to eth_native_tap, including renaming all its
options.
The old options remain until v4.4, but as deprecated.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2025-03-03 14:26:51 +01:00 committed by Alberto Escolar
commit 78f800642a
23 changed files with 253 additions and 180 deletions

View file

@ -17,7 +17,7 @@ if NETWORKING
config NET_L2_ETHERNET
default y if !NET_LOOPBACK && !NET_TEST
config ETH_NATIVE_POSIX
config ETH_NATIVE_TAP
default y if NET_L2_ETHERNET && ETH_DRIVER
endif # NETWORKING

View file

@ -705,7 +705,7 @@ host libC (:kconfig:option:`CONFIG_EXTERNAL_LIBC`):
Entropy, :ref:`Native posix entropy <nsim_per_entr>`, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_POSIX`, All
EEPROM, EEPROM simulator, :kconfig:option:`CONFIG_EEPROM_SIMULATOR`, All
EEPROM, EEPROM emulator, :kconfig:option:`CONFIG_EEPROM_EMULATOR`, All
Ethernet, :ref:`Eth native_posix <nsim_per_ethe>`, :kconfig:option:`CONFIG_ETH_NATIVE_POSIX`, All
Ethernet, :ref:`Eth native_tap <nsim_per_ethe>`, :kconfig:option:`CONFIG_ETH_NATIVE_TAP`, All
Flash, :ref:`Flash simulator <nsim_per_flash_simu>`, :kconfig:option:`CONFIG_FLASH_SIMULATOR`, All
Flash, :ref:`Host based flash access <native_fuse_flash>`, :kconfig:option:`CONFIG_FUSE_FS_ACCESS`, Host libC
GPIO, GPIO emulator, :kconfig:option:`CONFIG_GPIO_EMUL`, All

View file

@ -61,7 +61,7 @@ Then create a sample and enable Ethernet bridging support. In this example we cr
-DCONFIG_NATIVE_UART_AUTOATTACH_DEFAULT_CMD="\"gnome-terminal -- screen %s\"" \
-DCONFIG_NET_ETHERNET_BRIDGE=y \
-DCONFIG_NET_ETHERNET_BRIDGE_SHELL=y \
-DCONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT=2 \
-DCONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT=2 \
-DCONFIG_NET_IF_MAX_IPV6_COUNT=2 \
-DCONFIG_NET_IF_MAX_IPV4_COUNT=2
../build/echo-server/zephyr/zephyr.exe -attach_uart

View file

@ -149,7 +149,7 @@ Setting interface name from command line
****************************************
By default the Ethernet interface name used by native_sim is determined by
:kconfig:option:`CONFIG_ETH_NATIVE_POSIX_DRV_NAME`, but is also possible
:kconfig:option:`CONFIG_ETH_NATIVE_TAP_DRV_NAME`, but is also possible
to set it from the command line using ``--eth-if=<interface_name>``.
This can be useful if the application has to be
run in multiple instances and recompiling it for each instance would be

View file

@ -153,9 +153,9 @@ or if you want to use native_sim board, type this:
-DCONFIG_NET_CONFIG_MY_IPV6_ADDR=\"2001:db8:100::1\" \
-DCONFIG_NET_CONFIG_PEER_IPV6_ADDR=\"2001:db8:200::1\" \
-DCONFIG_NET_CONFIG_MY_IPV4_GW=\"203.0.113.1\" \
-DCONFIG_ETH_NATIVE_POSIX_DRV_NAME=\"zeth.1\" \
-DCONFIG_ETH_NATIVE_POSIX_MAC_ADDR=\"00:00:5e:00:53:01\" \
-DCONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=n
-DCONFIG_ETH_NATIVE_TAP_DRV_NAME=\"zeth.1\" \
-DCONFIG_ETH_NATIVE_TAP_MAC_ADDR=\"00:00:5e:00:53:01\" \
-DCONFIG_ETH_NATIVE_TAP_RANDOM_MAC=n
In terminal #5, if you are using QEMU, type this:
@ -184,9 +184,9 @@ or if you want to use native_sim board, type this:
-DCONFIG_NET_CONFIG_MY_IPV6_ADDR=\"2001:db8:200::1\" \
-DCONFIG_NET_CONFIG_PEER_IPV6_ADDR=\"2001:db8:100::1\" \
-DCONFIG_NET_CONFIG_MY_IPV4_GW=\"198.51.100.1\" \
-DCONFIG_ETH_NATIVE_POSIX_DRV_NAME=\"zeth.2\" \
-DCONFIG_ETH_NATIVE_POSIX_MAC_ADDR=\"00:00:5e:00:53:02\" \
-DCONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=n
-DCONFIG_ETH_NATIVE_TAP_DRV_NAME=\"zeth.2\" \
-DCONFIG_ETH_NATIVE_TAP_MAC_ADDR=\"00:00:5e:00:53:02\" \
-DCONFIG_ETH_NATIVE_TAP_RANDOM_MAC=n
Also if you have firewall enabled in your host, you need to allow traffic

View file

@ -55,17 +55,17 @@ endif()
zephyr_library_sources_ifdef(CONFIG_ETH_NXP_S32_GMAC eth_nxp_s32_gmac.c)
zephyr_library_sources_ifdef(CONFIG_ETH_NUMAKER eth_numaker.c)
if(CONFIG_ETH_NATIVE_POSIX)
if(CONFIG_ETH_NATIVE_TAP)
if (CONFIG_NATIVE_APPLICATION)
set(native_posix_source_files eth_native_posix.c eth_native_posix_adapt.c)
set_source_files_properties(${native_posix_source_files}
set(native_tap_source_files eth_native_tap.c eth_native_tap_adapt.c)
set_source_files_properties(${native_tap_source_files}
PROPERTIES COMPILE_DEFINITIONS
"NO_POSIX_CHEATS;_BSD_SOURCE;_DEFAULT_SOURCE"
)
zephyr_library_sources(${native_posix_source_files})
zephyr_library_sources(${native_tap_source_files})
else()
zephyr_library_sources(eth_native_posix.c)
target_sources(native_simulator INTERFACE eth_native_posix_adapt.c)
zephyr_library_sources(eth_native_tap.c)
target_sources(native_simulator INTERFACE eth_native_tap_adapt.c)
endif()
endif()

View file

@ -57,7 +57,7 @@ source "drivers/ethernet/Kconfig.sam_gmac"
source "drivers/ethernet/Kconfig.stm32_hal"
source "drivers/ethernet/Kconfig.dwmac"
source "drivers/ethernet/Kconfig.smsc911x"
source "drivers/ethernet/Kconfig.native_posix"
source "drivers/ethernet/Kconfig.native_tap"
source "drivers/ethernet/Kconfig.stellaris"
source "drivers/ethernet/Kconfig.litex"
source "drivers/ethernet/Kconfig.gecko"

View file

@ -1,86 +0,0 @@
# Native posix ethernet driver configuration options
# Copyright (c) 2018 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
menuconfig ETH_NATIVE_POSIX
bool "Native Posix Ethernet driver"
depends on ARCH_POSIX
help
Enable native posix ethernet driver. Note, this driver is run inside
a process in your host system.
if ETH_NATIVE_POSIX
config ETH_NATIVE_POSIX_INTERFACE_COUNT
int "Number of network interfaces created"
default NET_GPTP_NUM_PORTS if NET_GPTP
default PTP_NUM_PORTS if PTP
default 1
range 1 32
help
By default only one network interface is created. It is possible
to create multiple interfaces in certain use cases. For example if
multiple ports are defined in gPTP or PTP, then multiple network interfaces
must be created here.
config ETH_NATIVE_POSIX_DRV_NAME
string "Ethernet driver name"
default "zeth"
help
This option sets the driver name and name of the network interface
in your host system. If there are multiple network interfaces defined,
then this value is used as a prefix and the interface names will be
zeth0, zeth1, etc.
config ETH_NATIVE_POSIX_DEV_NAME
string "Host ethernet TUN/TAP device name"
default "/dev/net/tun"
help
This option sets the TUN/TAP device name in your host system.
config ETH_NATIVE_POSIX_PTP_CLOCK
bool "PTP clock driver support"
default y if NET_GPTP || PTP
select PTP_CLOCK
depends on NET_GPTP || PTP
help
Enable PTP clock support.
config ETH_NATIVE_POSIX_RANDOM_MAC
bool "Random MAC address"
depends on ENTROPY_GENERATOR
default y
help
Generate a random MAC address dynamically.
config ETH_NATIVE_POSIX_VLAN_TAG_STRIP
bool "Strip VLAN tag from Rx frames"
depends on NET_VLAN
help
Native posix ethernet driver will strip of VLAN tag from
Rx Ethernet frames and sets tag information in net packet
metadata.
config ETH_NATIVE_POSIX_MAC_ADDR
string "MAC address for the interface"
default ""
depends on !ETH_NATIVE_POSIX_RANDOM_MAC
help
Specify a MAC address for the ethernet interface in the form of
six hex 8-bit chars separated by colons (e.g.:
aa:33:cc:22:e2:c0). The default is an empty string, which
means the code will make 00:00:5E:00:53:XX, where XX will be
random.
config ETH_NATIVE_POSIX_RX_TIMEOUT
int "Ethernet RX timeout"
default 1 if NET_GPTP
default 50
range 1 100
help
Native posix ethernet driver repeatedly checks for new data.
Specify how long the thread sleeps between these checks if no new data
available.
endif # ETH_NATIVE_POSIX

View file

@ -0,0 +1,159 @@
# Native TAP ethernet driver configuration options
# Copyright (c) 2018 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
menuconfig ETH_NATIVE_TAP
bool "Native TAP Ethernet driver"
depends on ARCH_POSIX
select ETH_NATIVE_POSIX_BACKWARDS_COMPAT_MENU
help
Enable native_sim TAP ethernet driver. Note, this driver is run inside
a process in your host system.
if ETH_NATIVE_TAP
config ETH_NATIVE_TAP_INTERFACE_COUNT
int "Number of network interfaces created"
default ETH_NATIVE_POSIX_INTERFACE_COUNT
range 1 32
help
By default only one network interface is created. It is possible
to create multiple interfaces in certain use cases. For example if
multiple ports are defined in gPTP or PTP, then multiple network interfaces
must be created here.
config ETH_NATIVE_TAP_DRV_NAME
string "Ethernet driver name"
default ETH_NATIVE_POSIX_DRV_NAME
help
This option sets the driver name and name of the network interface
in your host system. If there are multiple network interfaces defined,
then this value is used as a prefix and the interface names will be
zeth0, zeth1, etc.
config ETH_NATIVE_TAP_DEV_NAME
string "Host ethernet TUN/TAP device name"
default ETH_NATIVE_POSIX_DEV_NAME
help
This option sets the TUN/TAP device name in your host system.
config ETH_NATIVE_TAP_PTP_CLOCK
bool "PTP clock driver support"
default ETH_NATIVE_POSIX_PTP_CLOCK
select PTP_CLOCK
depends on NET_GPTP || PTP
help
Enable PTP clock support.
config ETH_NATIVE_TAP_RANDOM_MAC
bool "Random MAC address"
depends on ENTROPY_GENERATOR
default ETH_NATIVE_POSIX_RANDOM_MAC
help
Generate a random MAC address dynamically.
config ETH_NATIVE_TAP_VLAN_TAG_STRIP
bool "Strip VLAN tag from Rx frames"
default ETH_NATIVE_POSIX_VLAN_TAG_STRIP
depends on NET_VLAN
help
Native TAP ethernet driver will strip of VLAN tag from
Rx Ethernet frames and sets tag information in net packet
metadata.
config ETH_NATIVE_TAP_MAC_ADDR
string "MAC address for the interface"
default ETH_NATIVE_POSIX_MAC_ADDR
depends on !ETH_NATIVE_TAP_RANDOM_MAC
help
Specify a MAC address for the ethernet interface in the form of
six hex 8-bit chars separated by colons (e.g.:
aa:33:cc:22:e2:c0). The default is an empty string, which
means the code will make 00:00:5E:00:53:XX, where XX will be
random.
config ETH_NATIVE_TAP_RX_TIMEOUT
int "Ethernet RX timeout"
default ETH_NATIVE_POSIX_RX_TIMEOUT
range 1 100
help
Native TAP ethernet driver repeatedly checks for new data.
Specify how long the thread sleeps between these checks if no new data
available.
endif # ETH_NATIVE_TAP
config ETH_NATIVE_POSIX
bool "Native POSIX Ethernet driver (deprecated)"
depends on ARCH_POSIX
select DEPRECATED
select ETH_NATIVE_TAP
select ETH_NATIVE_POSIX_BACKWARDS_COMPAT_MENU
help
Deprecated, use ETH_NATIVE_TAP instead
menuconfig ETH_NATIVE_POSIX_BACKWARDS_COMPAT_MENU
bool "Native POSIX Ethernet driver options (deprecated)"
depends on ARCH_POSIX
if ETH_NATIVE_POSIX_BACKWARDS_COMPAT_MENU
config ETH_NATIVE_POSIX_INTERFACE_COUNT
int "Number of network interfaces created (deprecated)"
default NET_GPTP_NUM_PORTS if NET_GPTP
default PTP_NUM_PORTS if PTP
default 1
range 1 32
help
Deprecated, use ETH_NATIVE_TAP_INTERFACE_COUNT instead
config ETH_NATIVE_POSIX_DRV_NAME
string "Ethernet driver name (deprecated)"
default "zeth"
help
Deprecated, use ETH_NATIVE_TAP_DRV_NAME instead
config ETH_NATIVE_POSIX_DEV_NAME
string "Host ethernet TUN/TAP device name (deprecated)"
default "/dev/net/tun"
help
Deprecated, use ETH_NATIVE_TAP_DEV_NAME instead
config ETH_NATIVE_POSIX_PTP_CLOCK
bool "PTP clock driver support (deprecated)"
default y if NET_GPTP || PTP
depends on NET_GPTP || PTP
help
Deprecated, use ETH_NATIVE_TAP_PTP_CLOCK instead
config ETH_NATIVE_POSIX_RANDOM_MAC
bool "Random MAC address (deprecated)"
depends on ENTROPY_GENERATOR
default y
help
Deprecated, use ETH_NATIVE_TAP_RANDOM_MAC instead
config ETH_NATIVE_POSIX_VLAN_TAG_STRIP
bool "Strip VLAN tag from Rx frames (deprecated)"
depends on NET_VLAN
help
Deprecated, use ETH_NATIVE_TAP_VLAN_TAG_STRIP instead
config ETH_NATIVE_POSIX_MAC_ADDR
string "MAC address for the interface (deprecated)"
default ""
depends on !ETH_NATIVE_POSIX_RANDOM_MAC
help
Deprecated, use ETH_NATIVE_TAP_MAC_ADDR instead
config ETH_NATIVE_POSIX_RX_TIMEOUT
int "Ethernet RX timeout (deprecated)"
default 1 if NET_GPTP
default 50
range 1 100
help
Deprecated, use ETH_NATIVE_TAP_DEV_NAME instead
endif # ETH_NATIVE_POSIX_BACKWARDS_COMPAT

View file

@ -7,11 +7,15 @@
/**
* @file
*
* Ethernet driver for native posix board. This is meant for network
* connectivity between host and Zephyr.
* TAP Ethernet driver for the native_sim board. This is meant for network
* connectivity between the host and Zephyr.
*
* Note this driver is divided in two files. This one, built in the embedded code context,
* with whichever libC is used in that context, and eth_native_tap_adapt.c built with the host
* libC.
*/
#define LOG_MODULE_NAME eth_posix
#define LOG_MODULE_NAME eth_tap
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
#include <zephyr/logging/log.h>
@ -36,7 +40,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <zephyr/net/gptp.h>
#include <zephyr/net/lldp.h>
#include "eth_native_posix_priv.h"
#include "eth_native_tap_priv.h"
#include "nsi_host_trampolines.h"
#include "eth.h"
@ -66,7 +70,7 @@ struct eth_context {
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
struct net_stats_eth stats;
#endif
#if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK)
#if defined(CONFIG_ETH_NATIVE_TAP_PTP_CLOCK)
const struct device *ptp_clock;
#endif
};
@ -78,7 +82,7 @@ static const char *if_name_cmd_opt;
CONFIG_ARCH_POSIX_RECOMMENDED_STACK_SIZE);\
static struct k_thread rx_thread_data_##x
LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, DEFINE_RX_THREAD, (;), _);
LISTIFY(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT, DEFINE_RX_THREAD, (;), _);
#if defined(CONFIG_NET_GPTP)
static bool need_timestamping(struct gptp_hdr *hdr)
@ -265,7 +269,7 @@ static void eth_rx(void *p1, void *p2, void *p3)
}
}
k_sleep(K_MSEC(CONFIG_ETH_NATIVE_POSIX_RX_TIMEOUT));
k_sleep(K_MSEC(CONFIG_ETH_NATIVE_TAP_RX_TIMEOUT));
}
}
@ -287,7 +291,7 @@ static void create_rx_handler(struct eth_context *ctx)
if (IS_ENABLED(CONFIG_THREAD_NAME)) {
char name[THREAD_MAX_NAME_LEN];
snprintk(name, sizeof(name), "eth_native_posix_rx-%s",
snprintk(name, sizeof(name), "eth_native_tap_rx-%s",
ctx->if_name);
k_thread_name_set(ctx->rx_thread, name);
}
@ -310,7 +314,7 @@ static void eth_iface_init(struct net_if *iface)
ctx->init_done = true;
#if defined(CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC)
#if defined(CONFIG_ETH_NATIVE_TAP_RANDOM_MAC)
/* 00-00-5E-00-53-xx Documentation RFC 7042 */
gen_random_mac(ctx->mac_addr, 0x00, 0x00, 0x5E);
@ -327,14 +331,14 @@ static void eth_iface_init(struct net_if *iface)
/* Difficult to configure MAC addresses any sane way if we have more
* than one network interface.
*/
BUILD_ASSERT(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT == 1,
BUILD_ASSERT(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT == 1,
"Cannot have static MAC if interface count > 1");
if (CONFIG_ETH_NATIVE_POSIX_MAC_ADDR[0] != 0) {
if (CONFIG_ETH_NATIVE_TAP_MAC_ADDR[0] != 0) {
if (net_bytes_from_str(ctx->mac_addr, sizeof(ctx->mac_addr),
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR) < 0) {
CONFIG_ETH_NATIVE_TAP_MAC_ADDR) < 0) {
LOG_ERR("Invalid MAC address %s",
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR);
CONFIG_ETH_NATIVE_TAP_MAC_ADDR);
}
}
#endif
@ -343,8 +347,8 @@ static void eth_iface_init(struct net_if *iface)
* defined in the Kconfig directly. This way there is no need to
* change the documentation etc. and break things.
*/
if (CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT == 1) {
ctx->if_name = CONFIG_ETH_NATIVE_POSIX_DRV_NAME;
if (CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT == 1) {
ctx->if_name = CONFIG_ETH_NATIVE_TAP_DRV_NAME;
}
if (if_name_cmd_opt != NULL) {
@ -356,7 +360,7 @@ static void eth_iface_init(struct net_if *iface)
net_if_set_link_addr(iface, ll_addr->addr, ll_addr->len,
NET_LINK_ETHERNET);
ctx->dev_fd = eth_iface_create(CONFIG_ETH_NATIVE_POSIX_DEV_NAME, ctx->if_name, false);
ctx->dev_fd = eth_iface_create(CONFIG_ETH_NATIVE_TAP_DEV_NAME, ctx->if_name, false);
if (ctx->dev_fd < 0) {
LOG_ERR("Cannot create %s (%d/%s)", ctx->if_name, ctx->dev_fd,
strerror(-ctx->dev_fd));
@ -366,8 +370,7 @@ static void eth_iface_init(struct net_if *iface)
}
}
static
enum ethernet_hw_caps eth_posix_native_get_capabilities(const struct device *dev)
static enum ethernet_hw_caps eth_native_tap_get_capabilities(const struct device *dev)
{
ARG_UNUSED(dev);
@ -375,10 +378,10 @@ enum ethernet_hw_caps eth_posix_native_get_capabilities(const struct device *dev
#if defined(CONFIG_NET_VLAN)
| ETHERNET_HW_VLAN
#endif
#if defined(CONFIG_ETH_NATIVE_POSIX_VLAN_TAG_STRIP)
#if defined(CONFIG_ETH_NATIVE_TAP_VLAN_TAG_STRIP)
| ETHERNET_HW_VLAN_TAG_STRIP
#endif
#if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK)
#if defined(CONFIG_ETH_NATIVE_TAP_PTP_CLOCK)
| ETHERNET_PTP
#endif
#if defined(CONFIG_NET_PROMISCUOUS_MODE)
@ -390,7 +393,7 @@ enum ethernet_hw_caps eth_posix_native_get_capabilities(const struct device *dev
;
}
#if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK)
#if defined(CONFIG_ETH_NATIVE_TAP_PTP_CLOCK)
static const struct device *eth_get_ptp_clock(const struct device *dev)
{
struct eth_context *context = dev->data;
@ -461,7 +464,7 @@ static int vlan_setup(const struct device *dev, struct net_if *iface,
static const struct ethernet_api eth_if_api = {
.iface_api.init = eth_iface_init,
.get_capabilities = eth_posix_native_get_capabilities,
.get_capabilities = eth_native_tap_get_capabilities,
.set_config = set_config,
.send = eth_send,
@ -471,36 +474,36 @@ static const struct ethernet_api eth_if_api = {
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
.get_stats = get_stats,
#endif
#if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK)
#if defined(CONFIG_ETH_NATIVE_TAP_PTP_CLOCK)
.get_ptp_clock = eth_get_ptp_clock,
#endif
};
#define DEFINE_ETH_DEV_DATA(x, _) \
static struct eth_context eth_context_data_##x = { \
.if_name = CONFIG_ETH_NATIVE_POSIX_DRV_NAME #x, \
.if_name = CONFIG_ETH_NATIVE_TAP_DRV_NAME #x, \
.rx_thread = &rx_thread_data_##x, \
.rx_stack = rx_thread_stack_##x, \
.rx_stack_size = K_KERNEL_STACK_SIZEOF(rx_thread_stack_##x), \
}
LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, DEFINE_ETH_DEV_DATA, (;), _);
LISTIFY(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT, DEFINE_ETH_DEV_DATA, (;), _);
#define DEFINE_ETH_DEVICE(x, _) \
ETH_NET_DEVICE_INIT(eth_native_posix_##x, \
CONFIG_ETH_NATIVE_POSIX_DRV_NAME #x, \
ETH_NET_DEVICE_INIT(eth_native_tap_##x, \
CONFIG_ETH_NATIVE_TAP_DRV_NAME #x, \
NULL, NULL, &eth_context_data_##x, NULL, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
&eth_if_api, \
NET_ETH_MTU)
LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, DEFINE_ETH_DEVICE, (;), _);
LISTIFY(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT, DEFINE_ETH_DEVICE, (;), _);
#if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK)
#if defined(CONFIG_ETH_NATIVE_TAP_PTP_CLOCK)
#if defined(CONFIG_NET_GPTP)
BUILD_ASSERT( \
CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT == CONFIG_NET_GPTP_NUM_PORTS, \
CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT == CONFIG_NET_GPTP_NUM_PORTS, \
"Number of network interfaces must match gPTP port count");
#endif
@ -511,10 +514,9 @@ struct ptp_context {
#define DEFINE_PTP_DEV_DATA(x, _) \
static struct ptp_context ptp_context_##x
LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, DEFINE_PTP_DEV_DATA, (;), _);
LISTIFY(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT, DEFINE_PTP_DEV_DATA, (;), _);
static int ptp_clock_set_native_posix(const struct device *clk,
struct net_ptp_time *tm)
static int ptp_clock_set_native_tap(const struct device *clk, struct net_ptp_time *tm)
{
ARG_UNUSED(clk);
ARG_UNUSED(tm);
@ -526,16 +528,14 @@ static int ptp_clock_set_native_posix(const struct device *clk,
return 0;
}
static int ptp_clock_get_native_posix(const struct device *clk,
struct net_ptp_time *tm)
static int ptp_clock_get_native_tap(const struct device *clk, struct net_ptp_time *tm)
{
ARG_UNUSED(clk);
return eth_clock_gettime(&tm->second, &tm->nanosecond);
}
static int ptp_clock_adjust_native_posix(const struct device *clk,
int increment)
static int ptp_clock_adjust_native_tap(const struct device *clk, int increment)
{
ARG_UNUSED(clk);
ARG_UNUSED(increment);
@ -547,8 +547,7 @@ static int ptp_clock_adjust_native_posix(const struct device *clk,
return 0;
}
static int ptp_clock_rate_adjust_native_posix(const struct device *clk,
double ratio)
static int ptp_clock_rate_adjust_native_tap(const struct device *clk, double ratio)
{
ARG_UNUSED(clk);
ARG_UNUSED(ratio);
@ -561,16 +560,16 @@ static int ptp_clock_rate_adjust_native_posix(const struct device *clk,
}
static DEVICE_API(ptp_clock, api) = {
.set = ptp_clock_set_native_posix,
.get = ptp_clock_get_native_posix,
.adjust = ptp_clock_adjust_native_posix,
.rate_adjust = ptp_clock_rate_adjust_native_posix,
.set = ptp_clock_set_native_tap,
.get = ptp_clock_get_native_tap,
.adjust = ptp_clock_adjust_native_tap,
.rate_adjust = ptp_clock_rate_adjust_native_tap,
};
#define PTP_INIT_FUNC(x, _) \
static int ptp_init_##x(const struct device *port) \
{ \
const struct device *const eth_dev = DEVICE_GET(eth_native_posix_##x); \
const struct device *const eth_dev = DEVICE_GET(eth_native_tap_##x); \
struct eth_context *context = eth_dev->data; \
struct ptp_context *ptp_context = port->data; \
\
@ -580,10 +579,10 @@ static DEVICE_API(ptp_clock, api) = {
return 0; \
}
LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, PTP_INIT_FUNC, (), _)
LISTIFY(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT, PTP_INIT_FUNC, (), _)
#define DEFINE_PTP_DEVICE(x, _) \
DEVICE_DEFINE(eth_native_posix_ptp_clock_##x, \
DEVICE_DEFINE(eth_native_tap_ptp_clock_##x, \
PTP_CLOCK_NAME "_" #x, \
ptp_init_##x, \
NULL, \
@ -593,13 +592,13 @@ LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, PTP_INIT_FUNC, (), _)
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
&api)
LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, DEFINE_PTP_DEVICE, (;), _);
LISTIFY(CONFIG_ETH_NATIVE_TAP_INTERFACE_COUNT, DEFINE_PTP_DEVICE, (;), _);
#endif /* CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK */
#endif /* CONFIG_ETH_NATIVE_TAP_PTP_CLOCK */
static void add_native_posix_options(void)
static void add_native_tap_options(void)
{
static struct args_struct_t eth_native_posix_options[] = {
static struct args_struct_t eth_native_tap_options[] = {
{
.is_mandatory = false,
.option = "eth-if",
@ -611,7 +610,7 @@ static void add_native_posix_options(void)
ARG_TABLE_ENDMARKER,
};
native_add_command_line_opts(eth_native_posix_options);
native_add_command_line_opts(eth_native_tap_options);
}
NATIVE_TASK(add_native_posix_options, PRE_BOOT_1, 10);
NATIVE_TASK(add_native_tap_options, PRE_BOOT_1, 10);

View file

@ -7,8 +7,9 @@
/**
* @file
*
* Routines setting up the host system. Those are placed in separate file
* because there is naming conflicts between host and zephyr network stacks.
* Routines setting up the host system. Those are placed in a separate file
* to avoid naming conflicts between host and zephyr network stacks.
* This file is built with the host libC in the native simulator runner context.
*/
/* Host include files */
@ -33,7 +34,7 @@
#include <linux/if_tun.h>
#endif
#include "eth_native_posix_priv.h"
#include "eth_native_tap_priv.h"
/* Note that we cannot create the TUN/TAP device from the setup script
* as we need to get a file descriptor to communicate with the interface.

View file

@ -5,11 +5,11 @@
*/
/** @file
* @brief Private functions for native posix ethernet driver.
* @brief Private functions for native TAP ethernet driver.
*/
#ifndef ZEPHYR_DRIVERS_ETHERNET_ETH_NATIVE_POSIX_PRIV_H_
#define ZEPHYR_DRIVERS_ETHERNET_ETH_NATIVE_POSIX_PRIV_H_
#ifndef ZEPHYR_DRIVERS_ETHERNET_ETH_NATIVE_TAP_PRIV_H_
#define ZEPHYR_DRIVERS_ETHERNET_ETH_NATIVE_TAP_PRIV_H_
int eth_iface_create(const char *dev_name, const char *if_name, bool tun_only);
int eth_iface_remove(int fd);
@ -17,4 +17,4 @@ int eth_wait_data(int fd);
int eth_clock_gettime(uint64_t *second, uint32_t *nanosecond);
int eth_promisc_mode(const char *if_name, bool enable);
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_NATIVE_POSIX_PRIV_H_ */
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_NATIVE_TAP_PRIV_H_ */

View file

@ -1,8 +1,8 @@
# Settings for native_posix ethernet driver
CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK=y
CONFIG_ETH_NATIVE_TAP_PTP_CLOCK=y
#CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=y
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR="00:00:5e:00:53:2a"
#CONFIG_ETH_NATIVE_TAP_RANDOM_MAC=y
CONFIG_ETH_NATIVE_TAP_MAC_ADDR="00:00:5e:00:53:2a"
# Assume 1 ms accuracy for native_posix simulated clock
CONFIG_NET_GPTP_CLOCK_ACCURACY_1MS=y

View file

@ -1,8 +1,8 @@
# Settings for native_posix ethernet driver
CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK=y
CONFIG_ETH_NATIVE_TAP_PTP_CLOCK=y
#CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=y
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR="00:00:5e:00:53:2a"
#CONFIG_ETH_NATIVE_TAP_RANDOM_MAC=y
CONFIG_ETH_NATIVE_TAP_MAC_ADDR="00:00:5e:00:53:2a"
# Assume 1 ms accuracy for native_posix simulated clock
CONFIG_PTP_CLOCK_ACCURACY_1MS=y

View file

@ -1,8 +1,8 @@
# Settings for native_posix ethernet driver
CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK=y
CONFIG_ETH_NATIVE_TAP_PTP_CLOCK=y
#CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=y
CONFIG_ETH_NATIVE_POSIX_MAC_ADDR="00:00:5e:00:53:2a"
#CONFIG_ETH_NATIVE_TAP_RANDOM_MAC=y
CONFIG_ETH_NATIVE_TAP_MAC_ADDR="00:00:5e:00:53:2a"
# Assume 1 ms accuracy for native_sim simulated clock
CONFIG_PTP_CLOCK_ACCURACY_1MS=y

View file

@ -1,4 +1,4 @@
CONFIG_ETH_NATIVE_POSIX=n
CONFIG_ETH_NATIVE_TAP=n
CONFIG_NET_DRIVERS=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

View file

@ -1,4 +1,4 @@
CONFIG_ETH_NATIVE_POSIX=n
CONFIG_ETH_NATIVE_TAP=n
CONFIG_NET_DRIVERS=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y

View file

@ -1,2 +1,2 @@
CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK=y
CONFIG_ETH_NATIVE_TAP_PTP_CLOCK=y
CONFIG_PTP=y

View file

@ -140,7 +140,7 @@ int eth_bridge_iface_add(struct net_if *br, struct net_if *iface)
* we do not need host promiscuous working when testing
* bridging using native-sim.
*/
if (!IS_ENABLED(CONFIG_ETH_NATIVE_POSIX)) {
if (!IS_ENABLED(CONFIG_ETH_NATIVE_TAP)) {
NET_DBG("iface %d promiscuous mode failed: %d",
net_if_get_by_iface(iface), ret);
eth_bridge_iface_remove(br, iface);

View file

@ -74,9 +74,9 @@ static struct in_addr in4addr_dst2 = { { { 192, 0, 42, 2 } } };
/* Keep track of all ethernet interfaces. For native_sim board, we need
* to increase the count as it has one extra network interface defined in
* eth_native_posix driver.
* eth_native_tap driver.
*/
static struct net_if *eth_interfaces[2 + IS_ENABLED(CONFIG_ETH_NATIVE_POSIX)];
static struct net_if *eth_interfaces[2 + IS_ENABLED(CONFIG_ETH_NATIVE_TAP)];
static bool test_failed;
static bool test_started;

View file

@ -22,7 +22,7 @@ CONFIG_ZTEST=y
CONFIG_NET_CONFIG_SETTINGS=n
CONFIG_NET_SHELL=n
CONFIG_PTP_CLOCK=y
CONFIG_ETH_NATIVE_POSIX=n
CONFIG_ETH_NATIVE_TAP=n
CONFIG_COVERAGE=n
CONFIG_TEST_USERSPACE=y
CONFIG_HEAP_MEM_POOL_SIZE=128

View file

@ -11,7 +11,7 @@ CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
# Disable native ethernet driver (using native sockets instead)
CONFIG_ETH_NATIVE_POSIX=n
CONFIG_ETH_NATIVE_TAP=n
# Use native sockets
CONFIG_NET_SOCKETS=y

View file

@ -7,7 +7,7 @@ CONFIG_NETWORKING=y
CONFIG_MODEM_MODULES=y
CONFIG_MODEM_PPP=y
CONFIG_NET_L2_PPP=y
CONFIG_ETH_NATIVE_POSIX=n
CONFIG_ETH_NATIVE_TAP=n
CONFIG_ZTEST=y