drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c- Extension
.c- Size
- 13573 bytes
- Lines
- 476
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hlinux/netlink.hlinux/random.hnet/vxlan.hreg.hspectrum.hspectrum_nve.h
Detected Declarations
function mlxsw_sp_nve_vxlan_ipv4_flags_checkfunction mlxsw_sp_nve_vxlan_ipv6_flags_checkfunction mlxsw_sp_nve_vxlan_can_offloadfunction mlxsw_sp1_nve_vxlan_can_offloadfunction mlxsw_sp_nve_vxlan_ul_proto_sip_configfunction mlxsw_sp_nve_vxlan_configfunction mlxsw_sp_nve_vxlan_config_preparefunction mlxsw_sp1_nve_vxlan_config_setfunction mlxsw_sp1_nve_vxlan_config_clearfunction mlxsw_sp1_nve_vxlan_rtdp_setfunction mlxsw_sp1_nve_vxlan_initfunction mlxsw_sp1_nve_vxlan_finifunction mlxsw_sp_nve_vxlan_fdb_replayfunction mlxsw_sp_nve_vxlan_clear_offloadfunction mlxsw_sp2_nve_vxlan_learning_setfunction mlxsw_sp2_nve_decap_ethertype_setfunction mlxsw_sp2_nve_vxlan_config_setfunction mlxsw_sp2_nve_vxlan_config_clearfunction mlxsw_sp2_nve_vxlan_rtdp_setfunction mlxsw_sp2_nve_vxlan_initfunction mlxsw_sp2_nve_vxlan_fini
Annotated Snippet
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/random.h>
#include <net/vxlan.h>
#include "reg.h"
#include "spectrum.h"
#include "spectrum_nve.h"
#define MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \
VXLAN_F_LEARN | \
VXLAN_F_LOCALBYPASS)
#define MLXSW_SP_NVE_VXLAN_IPV6_SUPPORTED_FLAGS (VXLAN_F_IPV6 | \
VXLAN_F_UDP_ZERO_CSUM6_TX | \
VXLAN_F_UDP_ZERO_CSUM6_RX | \
VXLAN_F_LOCALBYPASS)
static bool mlxsw_sp_nve_vxlan_ipv4_flags_check(const struct vxlan_config *cfg,
struct netlink_ext_ack *extack)
{
if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM_TX)) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for TX");
return false;
}
if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag");
return false;
}
return true;
}
static bool mlxsw_sp_nve_vxlan_ipv6_flags_check(const struct vxlan_config *cfg,
struct netlink_ext_ack *extack)
{
if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM6_TX)) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for TX");
return false;
}
if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM6_RX)) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for RX");
return false;
}
if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_IPV6_SUPPORTED_FLAGS) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag");
return false;
}
return true;
}
static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve,
const struct mlxsw_sp_nve_params *params,
struct netlink_ext_ack *extack)
{
struct vxlan_dev *vxlan = netdev_priv(params->dev);
struct vxlan_config *cfg = &vxlan->cfg;
if (vxlan_addr_multicast(&cfg->remote_ip)) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Multicast destination IP is not supported");
return false;
}
if (vxlan_addr_any(&cfg->saddr)) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Source address must be specified");
return false;
}
if (cfg->remote_ifindex) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Local interface is not supported");
return false;
}
if (cfg->port_min || cfg->port_max) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: Only default UDP source port range is supported");
return false;
}
if (cfg->tos != 1) {
NL_SET_ERR_MSG_MOD(extack, "VxLAN: TOS must be configured to inherit");
return false;
}
if (cfg->flags & VXLAN_F_TTL_INHERIT) {
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/netlink.h`, `linux/random.h`, `net/vxlan.h`, `reg.h`, `spectrum.h`, `spectrum_nve.h`.
- Detected declarations: `function mlxsw_sp_nve_vxlan_ipv4_flags_check`, `function mlxsw_sp_nve_vxlan_ipv6_flags_check`, `function mlxsw_sp_nve_vxlan_can_offload`, `function mlxsw_sp1_nve_vxlan_can_offload`, `function mlxsw_sp_nve_vxlan_ul_proto_sip_config`, `function mlxsw_sp_nve_vxlan_config`, `function mlxsw_sp_nve_vxlan_config_prepare`, `function mlxsw_sp1_nve_vxlan_config_set`, `function mlxsw_sp1_nve_vxlan_config_clear`, `function mlxsw_sp1_nve_vxlan_rtdp_set`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.