drivers/net/amt.c
Source file repositories/reference/linux-study-clean/drivers/net/amt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/amt.c- Extension
.c- Size
- 90932 bytes
- Lines
- 3453
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/skbuff.hlinux/udp.hlinux/jhash.hlinux/if_tunnel.hlinux/net.hlinux/igmp.hlinux/workqueue.hnet/flow.hnet/pkt_sched.hnet/net_namespace.hnet/ip.hnet/udp.hnet/udp_tunnel.hnet/icmp.hnet/mld.hnet/amt.huapi/linux/amt.hlinux/security.hnet/gro_cells.hnet/ipv6.hnet/if_inet6.hnet/ndisc.hnet/addrconf.hnet/ip6_route.hnet/inet_common.hnet/inet_dscp.hnet/ip6_checksum.h
Detected Declarations
function __amt_source_gc_workfunction hlist_for_each_entry_safefunction amt_source_gc_workfunction amt_addr_equalfunction amt_source_hashfunction amt_status_filterfunction amt_group_hashfunction hlist_for_each_entry_rcufunction amt_destroy_sourcefunction amt_del_groupfunction amt_source_workfunction amt_act_srcfunction amt_group_workfunction hlist_for_each_entry_safefunction changefunction amt_update_gw_statusfunction __amt_update_relay_statusfunction amt_update_relay_statusfunction amt_send_discoveryfunction amt_send_requestfunction amt_send_igmp_gqfunction amt_send_mld_gqfunction amt_send_mld_gqfunction amt_secret_workfunction amt_event_send_discoveryfunction amt_discovery_workfunction amt_event_send_requestfunction amt_req_workfunction amt_send_membership_updatefunction amt_send_multicast_datafunction amt_send_membership_queryfunction amt_dev_xmitfunction list_for_each_entry_rcufunction hlist_for_each_entry_rcufunction amt_parse_typefunction amt_clear_groupsfunction amt_tunnel_expirefunction amt_cleanup_srcsfunction hlist_for_each_entry_safefunction hlist_for_each_entry_rcufunction amt_add_srcsfunction EXCLUDEfunction hlist_for_each_entry_safefunction hlist_for_each_entry_safefunction amt_mcast_is_in_handlerfunction amt_mcast_is_ex_handlerfunction amt_mcast_to_in_handlerfunction amt_mcast_to_ex_handler
Annotated Snippet
static const struct net_device_ops amt_netdev_ops = {
.ndo_init = amt_dev_init,
.ndo_uninit = amt_dev_uninit,
.ndo_open = amt_dev_open,
.ndo_stop = amt_dev_stop,
.ndo_start_xmit = amt_dev_xmit,
};
static void amt_link_setup(struct net_device *dev)
{
dev->netdev_ops = &amt_netdev_ops;
dev->needs_free_netdev = true;
SET_NETDEV_DEVTYPE(dev, &amt_type);
dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = ETH_MAX_MTU;
dev->type = ARPHRD_NONE;
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
dev->hard_header_len = 0;
dev->addr_len = 0;
dev->priv_flags |= IFF_NO_QUEUE;
dev->lltx = true;
dev->netns_immutable = true;
dev->features |= NETIF_F_GSO_SOFTWARE;
dev->hw_features |= NETIF_F_SG | NETIF_F_HW_CSUM;
dev->hw_features |= NETIF_F_FRAGLIST | NETIF_F_RXCSUM;
dev->hw_features |= NETIF_F_GSO_SOFTWARE;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
eth_hw_addr_random(dev);
eth_zero_addr(dev->broadcast);
ether_setup(dev);
}
static const struct nla_policy amt_policy[IFLA_AMT_MAX + 1] = {
[IFLA_AMT_MODE] = { .type = NLA_U32 },
[IFLA_AMT_RELAY_PORT] = { .type = NLA_U16 },
[IFLA_AMT_GATEWAY_PORT] = { .type = NLA_U16 },
[IFLA_AMT_LINK] = { .type = NLA_U32 },
[IFLA_AMT_LOCAL_IP] = { .len = sizeof_field(struct iphdr, daddr) },
[IFLA_AMT_REMOTE_IP] = { .len = sizeof_field(struct iphdr, daddr) },
[IFLA_AMT_DISCOVERY_IP] = { .len = sizeof_field(struct iphdr, daddr) },
[IFLA_AMT_MAX_TUNNELS] = { .type = NLA_U32 },
};
static int amt_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
if (!data)
return -EINVAL;
if (!data[IFLA_AMT_LINK]) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_AMT_LINK],
"Link attribute is required");
return -EINVAL;
}
if (!data[IFLA_AMT_MODE]) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_AMT_MODE],
"Mode attribute is required");
return -EINVAL;
}
if (nla_get_u32(data[IFLA_AMT_MODE]) > AMT_MODE_MAX) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_AMT_MODE],
"Mode attribute is not valid");
return -EINVAL;
}
if (!data[IFLA_AMT_LOCAL_IP]) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_AMT_DISCOVERY_IP],
"Local attribute is required");
return -EINVAL;
}
if (!data[IFLA_AMT_DISCOVERY_IP] &&
nla_get_u32(data[IFLA_AMT_MODE]) == AMT_MODE_GATEWAY) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_AMT_LOCAL_IP],
"Discovery attribute is required");
return -EINVAL;
}
return 0;
}
static int amt_newlink(struct net_device *dev,
struct rtnl_newlink_params *params,
struct netlink_ext_ack *extack)
{
struct net *link_net = rtnl_newlink_link_net(params);
struct amt_dev *amt = netdev_priv(dev);
struct nlattr **data = params->data;
Annotation
- Immediate include surface: `linux/module.h`, `linux/skbuff.h`, `linux/udp.h`, `linux/jhash.h`, `linux/if_tunnel.h`, `linux/net.h`, `linux/igmp.h`, `linux/workqueue.h`.
- Detected declarations: `function __amt_source_gc_work`, `function hlist_for_each_entry_safe`, `function amt_source_gc_work`, `function amt_addr_equal`, `function amt_source_hash`, `function amt_status_filter`, `function amt_group_hash`, `function hlist_for_each_entry_rcu`, `function amt_destroy_source`, `function amt_del_group`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.