drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c- Extension
.c- Size
- 7939 bytes
- Lines
- 261
- 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
net/ip_tunnels.hnet/vxlan.hlib/vxlan.hen/tc_tun.h
Detected Declarations
function mlx5e_tc_tun_can_offload_vxlanfunction mlx5e_tc_tun_calc_hlen_vxlanfunction mlx5e_tc_tun_check_udp_dport_vxlanfunction mlx5e_tc_tun_parse_udp_ports_vxlanfunction mlx5e_tc_tun_init_encap_attr_vxlanfunction mlx5e_gen_ip_tunnel_header_vxlanfunction mlx5e_tc_tun_parse_vxlan_gbp_optionfunction mlx5e_tc_tun_parse_vxlanfunction mlx5e_tc_tun_encap_info_equal_vxlanfunction mlx5e_tc_tun_get_remote_ifindex
Annotated Snippet
be16_to_cpu(enc_ports.key->dst))) {
NL_SET_ERR_MSG_MOD(extack,
"Matched UDP dst port is not registered as a VXLAN port");
netdev_warn(priv->netdev,
"UDP port %d is not registered as a VXLAN port\n",
be16_to_cpu(enc_ports.key->dst));
return -EOPNOTSUPP;
}
return 0;
}
static int mlx5e_tc_tun_parse_udp_ports_vxlan(struct mlx5e_priv *priv,
struct mlx5_flow_spec *spec,
struct flow_cls_offload *f,
void *headers_c,
void *headers_v)
{
int err = 0;
err = mlx5e_tc_tun_parse_udp_ports(priv, spec, f, headers_c, headers_v);
if (err)
return err;
return mlx5e_tc_tun_check_udp_dport_vxlan(priv, f);
}
static int mlx5e_tc_tun_init_encap_attr_vxlan(struct net_device *tunnel_dev,
struct mlx5e_priv *priv,
struct mlx5e_encap_entry *e,
struct netlink_ext_ack *extack)
{
int dst_port = be16_to_cpu(e->tun_info->key.tp_dst);
e->tunnel = &vxlan_tunnel;
if (!mlx5_vxlan_lookup_port(priv->mdev->vxlan, dst_port)) {
NL_SET_ERR_MSG_MOD(extack,
"vxlan udp dport was not registered with the HW");
netdev_warn(priv->netdev,
"%d isn't an offloaded vxlan udp dport\n",
dst_port);
return -EOPNOTSUPP;
}
e->reformat_type = MLX5_REFORMAT_TYPE_L2_TO_VXLAN;
return 0;
}
static int mlx5e_gen_ip_tunnel_header_vxlan(char buf[],
__u8 *ip_proto,
struct mlx5e_encap_entry *e)
{
const struct ip_tunnel_key *tun_key = &e->tun_info->key;
__be32 tun_id = tunnel_id_to_key32(tun_key->tun_id);
struct udphdr *udp = (struct udphdr *)(buf);
const struct vxlan_metadata *md;
struct vxlanhdr *vxh;
if (test_bit(IP_TUNNEL_VXLAN_OPT_BIT, tun_key->tun_flags) &&
e->tun_info->options_len != sizeof(*md))
return -EOPNOTSUPP;
vxh = (struct vxlanhdr *)((char *)udp + sizeof(struct udphdr));
*ip_proto = IPPROTO_UDP;
udp->dest = tun_key->tp_dst;
vxh->vx_flags = VXLAN_HF_VNI;
vxh->vx_vni = vxlan_vni_field(tun_id);
if (test_bit(IP_TUNNEL_VXLAN_OPT_BIT, tun_key->tun_flags)) {
md = ip_tunnel_info_opts(e->tun_info);
vxlan_build_gbp_hdr(vxh, md);
}
return 0;
}
static int mlx5e_tc_tun_parse_vxlan_gbp_option(struct mlx5e_priv *priv,
struct mlx5_flow_spec *spec,
struct flow_cls_offload *f)
{
struct flow_rule *rule = flow_cls_offload_flow_rule(f);
struct netlink_ext_ack *extack = f->common.extack;
struct flow_match_enc_opts enc_opts;
void *misc5_c, *misc5_v;
u32 *gbp, *gbp_mask;
flow_rule_match_enc_opts(rule, &enc_opts);
if (memchr_inv(&enc_opts.mask->data, 0, sizeof(enc_opts.mask->data)) &&
!MLX5_CAP_ESW_FT_FIELD_SUPPORT_2(priv->mdev, tunnel_header_0_1)) {
Annotation
- Immediate include surface: `net/ip_tunnels.h`, `net/vxlan.h`, `lib/vxlan.h`, `en/tc_tun.h`.
- Detected declarations: `function mlx5e_tc_tun_can_offload_vxlan`, `function mlx5e_tc_tun_calc_hlen_vxlan`, `function mlx5e_tc_tun_check_udp_dport_vxlan`, `function mlx5e_tc_tun_parse_udp_ports_vxlan`, `function mlx5e_tc_tun_init_encap_attr_vxlan`, `function mlx5e_gen_ip_tunnel_header_vxlan`, `function mlx5e_tc_tun_parse_vxlan_gbp_option`, `function mlx5e_tc_tun_parse_vxlan`, `function mlx5e_tc_tun_encap_info_equal_vxlan`, `function mlx5e_tc_tun_get_remote_ifindex`.
- 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.