drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_ipip.c
Extension
.c
Size
19776 bytes
Lines
643
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */

#include <net/ip_tunnels.h>
#include <net/ip6_tunnel.h>
#include <net/inet_ecn.h>

#include "spectrum_ipip.h"
#include "reg.h"

struct ip_tunnel_parm_kern
mlxsw_sp_ipip_netdev_parms4(const struct net_device *ol_dev)
{
	struct ip_tunnel *tun = netdev_priv(ol_dev);

	return tun->parms;
}

struct __ip6_tnl_parm
mlxsw_sp_ipip_netdev_parms6(const struct net_device *ol_dev)
{
	struct ip6_tnl *tun = netdev_priv(ol_dev);

	return tun->parms;
}

static bool
mlxsw_sp_ipip_parms4_has_ikey(const struct ip_tunnel_parm_kern *parms)
{
	return test_bit(IP_TUNNEL_KEY_BIT, parms->i_flags);
}

static bool mlxsw_sp_ipip_parms6_has_ikey(const struct __ip6_tnl_parm *parms)
{
	return test_bit(IP_TUNNEL_KEY_BIT, parms->i_flags);
}

static bool
mlxsw_sp_ipip_parms4_has_okey(const struct ip_tunnel_parm_kern *parms)
{
	return test_bit(IP_TUNNEL_KEY_BIT, parms->o_flags);
}

static bool mlxsw_sp_ipip_parms6_has_okey(const struct __ip6_tnl_parm *parms)
{
	return test_bit(IP_TUNNEL_KEY_BIT, parms->o_flags);
}

static u32 mlxsw_sp_ipip_parms4_ikey(const struct ip_tunnel_parm_kern *parms)
{
	return mlxsw_sp_ipip_parms4_has_ikey(parms) ?
		be32_to_cpu(parms->i_key) : 0;
}

static u32 mlxsw_sp_ipip_parms6_ikey(const struct __ip6_tnl_parm *parms)
{
	return mlxsw_sp_ipip_parms6_has_ikey(parms) ?
		be32_to_cpu(parms->i_key) : 0;
}

static u32 mlxsw_sp_ipip_parms4_okey(const struct ip_tunnel_parm_kern *parms)
{
	return mlxsw_sp_ipip_parms4_has_okey(parms) ?
		be32_to_cpu(parms->o_key) : 0;
}

static u32 mlxsw_sp_ipip_parms6_okey(const struct __ip6_tnl_parm *parms)
{
	return mlxsw_sp_ipip_parms6_has_okey(parms) ?
		be32_to_cpu(parms->o_key) : 0;
}

static union mlxsw_sp_l3addr
mlxsw_sp_ipip_parms4_saddr(const struct ip_tunnel_parm_kern *parms)
{
	return (union mlxsw_sp_l3addr) { .addr4 = parms->iph.saddr };
}

static union mlxsw_sp_l3addr
mlxsw_sp_ipip_parms6_saddr(const struct __ip6_tnl_parm *parms)
{
	return (union mlxsw_sp_l3addr) { .addr6 = parms->laddr };
}

static union mlxsw_sp_l3addr
mlxsw_sp_ipip_parms4_daddr(const struct ip_tunnel_parm_kern *parms)
{
	return (union mlxsw_sp_l3addr) { .addr4 = parms->iph.daddr };
}

Annotation

Implementation Notes