Skip to content

Pull GARP TX support #2748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: v3.5.99-ncs1-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
787d918
[nrf fromtree] net: arp: Add support for gratuitous ARP transmission
rlubos May 15, 2023
028af1e
[nrf fromtree] tests: net: all: Make sure gratuitous ARP transmission…
rlubos Apr 24, 2024
eb76ae6
[nrf fromtree] net: ipv4: Make netmask IPv4 address specific
jukkar Jan 31, 2024
dc71e8d
[nrf fromtree] net: ipv4: Deprecate the old netmask set/get routines
jukkar Feb 1, 2024
e66fc07
[nrf fromtree] net: dhcpv4: Network interface netmask was set too early
jukkar Mar 6, 2024
620e8d0
[nrf fromtree] wifi: esp_at: compile without `NET_NATIVE_IPV4`
Jan 15, 2024
a68f33e
[nrf fromtree] drivers: Change drivers to support new IPv4 netmask se…
jukkar Feb 2, 2024
0f63f85
[nrf fromtree] net: l2: ethernet: Fix error handling after ARP prepare
rlubos Nov 30, 2023
dfaba89
[nrf fromtree] net: ethernet: Register multicast monitor for MAC filt…
pdgendt Feb 23, 2024
828b36e
[nrf fromtree] drivers: ethernet: Disable drivers if tests are enabled
jukkar Feb 7, 2024
e602353
[nrf fromtree] include: net: ethernet: Add ETH_NET_DEVICE_INIT_INSTANCE
pdgendt Mar 11, 2024
a2514b0
[nrf fromtree] net: context: Add support for setting receive pktinfo …
jukkar Nov 22, 2023
cf483a3
[nrf fromtree] drivers: ethernet: Introduce ETH_DRIVER_RAW_MODE option
pdgendt Mar 11, 2024
3864ded
[nrf fromtree] net: ethernet: VLAN overhaul and refactoring
jukkar Mar 17, 2024
35b66b3
[nrf fromtree] tests: net: vlan: Update because of VLAN changes
jukkar Mar 19, 2024
99aa25e
[nrf fromtree] net: vlan: Fix net_eth_get_vlan_tag() to check correct…
jukkar Apr 10, 2024
f8773e2
[nrf fromtree] net: vlan: Add a function to check if interface is VLA…
jukkar Apr 25, 2024
b47daca
[nrf fromtree] samples: net: Change samples to support new IPv4 netma…
jukkar Feb 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions drivers/ethernet/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +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
Expand Down Expand Up @@ -71,7 +81,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.
Expand Down
9 changes: 6 additions & 3 deletions drivers/ethernet/phy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,4 +57,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"
4 changes: 3 additions & 1 deletion drivers/modem/hl7800.c
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,9 @@ static bool on_cmd_atcmdinfo_ipaddr(struct net_buf **buf, uint16_t len)
LOG_ERR("Cannot set iface IPv4 addr");
}

net_if_ipv4_set_netmask(iface_ctx.iface, &iface_ctx.subnet);
net_if_ipv4_set_netmask_by_addr(iface_ctx.iface,
&new_ipv4_addr,
&iface_ctx.subnet);
net_if_ipv4_set_gw(iface_ctx.iface, &iface_ctx.gateway);
#endif
/* store the new IP addr */
Expand Down
1 change: 0 additions & 1 deletion drivers/net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,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.

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void loopback_init(struct net_if *iface)
LOG_ERR("Failed to register IPv4 loopback address");
}

net_if_ipv4_set_netmask(iface, &netmask);
net_if_ipv4_set_netmask_by_addr(iface, &ipv4_loopback, &netmask);
}

if (IS_ENABLED(CONFIG_NET_IPV6)) {
Expand Down
10 changes: 8 additions & 2 deletions drivers/wifi/esp_at/esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ static void esp_mgmt_disconnect_work(struct k_work *work)
esp_flags_clear(dev, EDF_STA_CONNECTED);
esp_mode_switch_submit_if_needed(dev);

#if defined(CONFIG_NET_NATIVE_IPV4)
net_if_ipv4_addr_rm(dev->net_iface, &dev->ip);
#endif
net_if_dormant_on(dev->net_iface);
wifi_mgmt_raise_disconnect_result_event(dev->net_iface, 0);
}
Expand Down Expand Up @@ -509,14 +511,16 @@ static void esp_ip_addr_work(struct k_work *work)
return;
}

#if defined(CONFIG_NET_NATIVE_IPV4)
/* update interface addresses */
net_if_ipv4_set_gw(dev->net_iface, &dev->gw);
net_if_ipv4_set_netmask(dev->net_iface, &dev->nm);
#if defined(CONFIG_WIFI_ESP_AT_IP_STATIC)
net_if_ipv4_addr_add(dev->net_iface, &dev->ip, NET_ADDR_MANUAL, 0);
#else
net_if_ipv4_addr_add(dev->net_iface, &dev->ip, NET_ADDR_DHCP, 0);
#endif
net_if_ipv4_set_gw(dev->net_iface, &dev->gw);
net_if_ipv4_set_netmask_by_addr(dev->net_iface, &dev->ip, &dev->nm);
#endif

if (IS_ENABLED(CONFIG_WIFI_ESP_AT_DNS_USE)) {
ret = esp_cmd_send(dev, dns_cmds, ARRAY_SIZE(dns_cmds),
Expand Down Expand Up @@ -761,7 +765,9 @@ MODEM_CMD_DEFINE(on_cmd_ready)
dev->flags = 0;
dev->mode = 0;

#if defined(CONFIG_NET_NATIVE_IPV4)
net_if_ipv4_addr_rm(dev->net_iface, &dev->ip);
#endif
k_work_submit_to_queue(&dev->workq, &dev->init_work);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/wifi/eswifi/eswifi_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ static int eswifi_mgmt_ap_enable(const struct device *dev,

/* Set IP Address */
for (i = 0; ipv4 && i < NET_IF_MAX_IPV4_ADDR; i++) {
if (ipv4->unicast[i].is_used) {
unicast = &ipv4->unicast[i];
if (ipv4->unicast[i].ipv4.is_used) {
unicast = &ipv4->unicast[i].ipv4;
break;
}
}
Expand Down
152 changes: 116 additions & 36 deletions include/zephyr/net/ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,17 +592,6 @@ struct ethernet_context {
*/
atomic_t flags;

#if defined(CONFIG_NET_VLAN)
struct ethernet_vlan vlan[NET_VLAN_MAX_COUNT];

/** Array that will help when checking if VLAN is enabled for
* some specific network interface. Requires that VLAN count
* NET_VLAN_MAX_COUNT is not smaller than the actual number
* of network interfaces.
*/
ATOMIC_DEFINE(interfaces, NET_VLAN_MAX_COUNT);
#endif

#if defined(CONFIG_NET_ETHERNET_BRIDGE)
struct eth_bridge_iface_context bridge;
#endif
Expand Down Expand Up @@ -651,14 +640,6 @@ struct ethernet_context {
dsa_send_t dsa_send;
#endif

#if defined(CONFIG_NET_VLAN)
/** Flag that tells whether how many VLAN tags are enabled for this
* context. The same information can be dug from the vlan array but
* this saves some time in RX path.
*/
int8_t vlan_enabled;
#endif

/** Is network carrier up */
bool is_net_carrier_up : 1;

Expand Down Expand Up @@ -839,6 +820,9 @@ int net_eth_vlan_enable(struct net_if *iface, uint16_t tag);
#else
static inline int net_eth_vlan_enable(struct net_if *iface, uint16_t tag)
{
ARG_UNUSED(iface);
ARG_UNUSED(tag);

return -EINVAL;
}
#endif
Expand All @@ -856,14 +840,20 @@ int net_eth_vlan_disable(struct net_if *iface, uint16_t tag);
#else
static inline int net_eth_vlan_disable(struct net_if *iface, uint16_t tag)
{
ARG_UNUSED(iface);
ARG_UNUSED(tag);

return -EINVAL;
}
#endif

/**
* @brief Return VLAN tag specified to network interface
* @brief Return VLAN tag specified to network interface.
*
* @param iface Network interface.
* Note that the interface parameter must be the VLAN interface,
* and not the Ethernet one.
*
* @param iface VLAN network interface.
*
* @return VLAN tag for this interface or NET_VLAN_TAG_UNSPEC if VLAN
* is not configured for that interface.
Expand All @@ -873,15 +863,16 @@ uint16_t net_eth_get_vlan_tag(struct net_if *iface);
#else
static inline uint16_t net_eth_get_vlan_tag(struct net_if *iface)
{
ARG_UNUSED(iface);

return NET_VLAN_TAG_UNSPEC;
}
#endif

/**
* @brief Return network interface related to this VLAN tag
*
* @param iface Master network interface. This is used to get the
* pointer to ethernet L2 context
* @param iface Main network interface (not the VLAN one).
* @param tag VLAN tag
*
* @return Network interface related to this tag or NULL if no such interface
Expand All @@ -893,17 +884,46 @@ struct net_if *net_eth_get_vlan_iface(struct net_if *iface, uint16_t tag);
static inline
struct net_if *net_eth_get_vlan_iface(struct net_if *iface, uint16_t tag)
{
ARG_UNUSED(iface);
ARG_UNUSED(tag);

return NULL;
}
#endif

/**
* @brief Return main network interface that is attached to this VLAN tag.
*
* @param iface VLAN network interface. This is used to get the
* pointer to ethernet L2 context
*
* @return Network interface related to this tag or NULL if no such interface
* exists.
*/
#if defined(CONFIG_NET_VLAN)
struct net_if *net_eth_get_vlan_main(struct net_if *iface);
#else
static inline
struct net_if *net_eth_get_vlan_main(struct net_if *iface)
{
ARG_UNUSED(iface);

return NULL;
}
#endif

/**
* @brief Check if VLAN is enabled for a specific network interface.
* @brief Check if there are any VLAN interfaces enabled to this specific
* Ethernet network interface.
*
* Note that the iface must be the actual Ethernet interface and not the
* virtual VLAN interface.
*
* @param ctx Ethernet context
* @param iface Network interface
* @param iface Ethernet network interface
*
* @return True if VLAN is enabled for this network interface, false if not.
* @return True if there are enabled VLANs for this network interface,
* false if not.
*/
#if defined(CONFIG_NET_VLAN)
bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
Expand All @@ -912,6 +932,9 @@ bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
static inline bool net_eth_is_vlan_enabled(struct ethernet_context *ctx,
struct net_if *iface)
{
ARG_UNUSED(ctx);
ARG_UNUSED(iface);

return false;
}
#endif
Expand All @@ -928,28 +951,57 @@ bool net_eth_get_vlan_status(struct net_if *iface);
#else
static inline bool net_eth_get_vlan_status(struct net_if *iface)
{
ARG_UNUSED(iface);

return false;
}
#endif

/**
* @brief Check if the given interface is a VLAN interface.
*
* @param iface Network interface
*
* @return True if this network interface is VLAN one, false if not.
*/
#if defined(CONFIG_NET_VLAN)
#define Z_ETH_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
config, prio, api, mtu) \
bool net_eth_is_vlan_interface(struct net_if *iface);
#else
static inline bool net_eth_is_vlan_interface(struct net_if *iface)
{
ARG_UNUSED(iface);

return false;
}
#endif

#if !defined(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_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \
init_fn, pm, data, config, prio, \
api, ETHERNET_L2, \
NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)

#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)); \
NET_L2_DATA_INIT(dev_id, 0, NET_L2_GET_CTX_TYPE(ETHERNET_L2)); \
NET_IF_INIT(dev_id, 0, ETHERNET_L2, mtu, NET_VLAN_MAX_COUNT)
&Z_DEVICE_STATE_NAME(dev_id));

#else /* CONFIG_NET_VLAN */
#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_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
config, prio, api, ETHERNET_L2, \
NET_L2_GET_CTX_TYPE(ETHERNET_L2), mtu)
#endif /* CONFIG_NET_VLAN */
Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, 0, \
init_fn, pm, data, config, prio, \
api, mtu)

/**
* @brief Create an Ethernet network interface and bind it to network device.
Expand All @@ -973,6 +1025,34 @@ static inline bool net_eth_get_vlan_status(struct net_if *iface)
Z_ETH_NET_DEVICE_INIT(DT_INVALID_NODE, dev_id, name, init_fn, \
pm, data, config, prio, api, mtu)

/**
* @brief Create multiple Ethernet network interfaces and bind them to network
* devices.
* If your network device needs more than one instance of a network interface,
* use this macro below and provide a different instance suffix each time
* (0, 1, 2, ... or a, b, c ... whatever works for you)
*
* @param dev_id Network device id.
* @param name The name this instance of the driver exposes to
* the system.
* @param instance Instance identifier.
* @param init_fn Address to the init function of the driver.
* @param pm Reference to struct pm_device associated with the device.
* (optional).
* @param data Pointer to the device's private data.
* @param config The address to the structure containing the
* configuration information for this instance of the driver.
* @param prio The initialization level at which configuration occurs.
* @param api Provides an initial pointer to the API function struct
* used by the driver. Can be NULL.
* @param mtu Maximum transfer unit in bytes for this network interface.
*/
#define ETH_NET_DEVICE_INIT_INSTANCE(dev_id, name, instance, init_fn, \
pm, data, config, prio, api, mtu) \
Z_ETH_NET_DEVICE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, name, \
instance, init_fn, pm, data, \
config, prio, api, mtu)

/**
* @brief Like ETH_NET_DEVICE_INIT but taking metadata from a devicetree.
* Create an Ethernet network interface and bind it to network device.
Expand Down
4 changes: 4 additions & 0 deletions include/zephyr/net/net_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ __net_socket struct net_context {
#endif
#if defined(CONFIG_NET_IPV4_MAPPING_TO_IPV6)
bool ipv6_v6only;
#endif
#if defined(CONFIG_NET_CONTEXT_RECV_PKTINFO)
bool recv_pktinfo;
#endif
} options;

Expand Down Expand Up @@ -1102,6 +1105,7 @@ enum net_context_option {
NET_OPT_REUSEADDR = 9,
NET_OPT_REUSEPORT = 10,
NET_OPT_IPV6_V6ONLY = 11,
NET_OPT_RECV_PKTINFO = 12,
};

/**
Expand Down
Loading
Loading