drivers/net/ethernet/sun/ldmvsw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sun/ldmvsw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sun/ldmvsw.c- Extension
.c- Size
- 11477 bytes
- Lines
- 479
- 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/delay.hlinux/etherdevice.hlinux/ethtool.hlinux/highmem.hlinux/if_vlan.hlinux/init.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/netdevice.hlinux/slab.hlinux/types.hlinux/icmpv6.hnet/ip.hnet/icmp.hnet/route.hasm/vio.hasm/ldc.hsunvnet_common.h
Detected Declarations
function vsw_get_drvinfofunction vsw_get_msglevelfunction vsw_set_msglevelfunction vsw_select_queuefunction vsw_start_xmitfunction vsw_set_rx_modefunction ldmvsw_openfunction vsw_poll_controllerfunction vsw_port_probefunction vsw_port_removefunction vsw_cleanupfunction vsw_initfunction vsw_exitmodule init vsw_init
Annotated Snippet
static const struct net_device_ops vsw_ops = {
.ndo_open = ldmvsw_open,
.ndo_stop = sunvnet_close_common,
.ndo_set_rx_mode = vsw_set_rx_mode,
.ndo_set_mac_address = sunvnet_set_mac_addr_common,
.ndo_validate_addr = eth_validate_addr,
.ndo_tx_timeout = sunvnet_tx_timeout_common,
.ndo_start_xmit = vsw_start_xmit,
.ndo_select_queue = vsw_select_queue,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = vsw_poll_controller,
#endif
};
static const char *local_mac_prop = "local-mac-address";
static const char *cfg_handle_prop = "cfg-handle";
static struct vnet *vsw_get_vnet(struct mdesc_handle *hp,
u64 port_node,
u64 *handle)
{
struct vnet *vp;
struct vnet *iter;
const u64 *local_mac = NULL;
const u64 *cfghandle = NULL;
u64 a;
/* Get the parent virtual-network-switch macaddr and cfghandle */
mdesc_for_each_arc(a, hp, port_node, MDESC_ARC_TYPE_BACK) {
u64 target = mdesc_arc_target(hp, a);
const char *name;
name = mdesc_get_property(hp, target, "name", NULL);
if (!name || strcmp(name, "virtual-network-switch"))
continue;
local_mac = mdesc_get_property(hp, target,
local_mac_prop, NULL);
cfghandle = mdesc_get_property(hp, target,
cfg_handle_prop, NULL);
break;
}
if (!local_mac || !cfghandle)
return ERR_PTR(-ENODEV);
/* find or create associated vnet */
vp = NULL;
mutex_lock(&vnet_list_mutex);
list_for_each_entry(iter, &vnet_list, list) {
if (iter->local_mac == *local_mac) {
vp = iter;
break;
}
}
if (!vp) {
vp = kzalloc_obj(*vp);
if (unlikely(!vp)) {
mutex_unlock(&vnet_list_mutex);
return ERR_PTR(-ENOMEM);
}
spin_lock_init(&vp->lock);
INIT_LIST_HEAD(&vp->port_list);
INIT_LIST_HEAD(&vp->list);
vp->local_mac = *local_mac;
list_add(&vp->list, &vnet_list);
}
mutex_unlock(&vnet_list_mutex);
*handle = (u64)*cfghandle;
return vp;
}
static struct net_device *vsw_alloc_netdev(u8 hwaddr[],
struct vio_dev *vdev,
u64 handle,
u64 port_id)
{
struct net_device *dev;
struct vnet_port *port;
dev = alloc_etherdev_mqs(sizeof(*port), VNET_MAX_TXQS, 1);
if (!dev)
return ERR_PTR(-ENOMEM);
dev->needed_headroom = VNET_PACKET_SKIP + 8;
dev->needed_tailroom = 8;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/highmem.h`, `linux/if_vlan.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `function vsw_get_drvinfo`, `function vsw_get_msglevel`, `function vsw_set_msglevel`, `function vsw_select_queue`, `function vsw_start_xmit`, `function vsw_set_rx_mode`, `function ldmvsw_open`, `function vsw_poll_controller`, `function vsw_port_probe`, `function vsw_port_remove`.
- 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.