drivers/net/ethernet/ibm/ibmveth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ibm/ibmveth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ibm/ibmveth.c- Extension
.c- Size
- 63406 bytes
- Lines
- 2303
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/types.hlinux/errno.hlinux/dma-mapping.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/init.hlinux/interrupt.hlinux/mm.hlinux/pm.hlinux/ethtool.hlinux/in.hlinux/ip.hlinux/ipv6.hlinux/slab.hasm/hvcall.hlinux/atomic.hasm/vio.hasm/iommu.hasm/firmware.hnet/tcp.hnet/ip6_checksum.hibmveth.hkunit/test.h
Detected Declarations
struct ibmveth_statfunction ibmveth_rxq_flagsfunction ibmveth_rxq_togglefunction ibmveth_rxq_pending_bufferfunction ibmveth_rxq_buffer_validfunction ibmveth_rxq_frame_offsetfunction ibmveth_rxq_large_packetfunction ibmveth_rxq_frame_lengthfunction ibmveth_rxq_csum_goodfunction ibmveth_real_max_tx_queuesfunction ibmveth_init_buffer_poolfunction ibmveth_alloc_buffer_poolfunction ibmveth_flush_bufferfunction ibmveth_replenish_buffer_poolfunction ibmveth_update_rx_no_bufferfunction ibmveth_replenish_taskfunction ibmveth_free_buffer_poolfunction ibmveth_remove_buffer_from_poolfunction ibmveth_rxq_harvest_bufferfunction ibmveth_free_tx_ltbfunction ibmveth_allocate_tx_ltbfunction ibmveth_register_logical_lanfunction ibmveth_openfunction ibmveth_closefunction ibmveth_resetfunction ibmveth_set_link_ksettingsfunction ibmveth_get_link_ksettingsfunction ibmveth_init_link_settingsfunction netdev_get_drvinfofunction ibmveth_fix_featuresfunction ibmveth_set_csum_offloadfunction ibmveth_set_tsofunction ibmveth_set_featuresfunction ibmveth_get_stringsfunction ibmveth_get_sset_countfunction ibmveth_get_ethtool_statsfunction ibmveth_get_channelsfunction ibmveth_set_channelsfunction ibmveth_ioctlfunction ibmveth_sendfunction ibmveth_is_packet_unsupportedfunction ibmveth_start_xmitfunction ip_hdrfunction ibmveth_rx_mss_helperfunction ibmveth_rx_csum_helperfunction pathfunction ibmveth_pollfunction ibmveth_interrupt
Annotated Snippet
static const struct net_device_ops ibmveth_netdev_ops = {
.ndo_open = ibmveth_open,
.ndo_stop = ibmveth_close,
.ndo_start_xmit = ibmveth_start_xmit,
.ndo_set_rx_mode = ibmveth_set_multicast_list,
.ndo_eth_ioctl = ibmveth_ioctl,
.ndo_change_mtu = ibmveth_change_mtu,
.ndo_fix_features = ibmveth_fix_features,
.ndo_set_features = ibmveth_set_features,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = ibmveth_set_mac_addr,
.ndo_features_check = ibmveth_features_check,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = ibmveth_poll_controller,
#endif
};
static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
{
int rc, i, mac_len;
struct net_device *netdev;
struct ibmveth_adapter *adapter;
unsigned char *mac_addr_p;
__be32 *mcastFilterSize_p;
long ret;
unsigned long ret_attr;
dev_dbg(&dev->dev, "entering ibmveth_probe for UA 0x%x\n",
dev->unit_address);
mac_addr_p = (unsigned char *)vio_get_attribute(dev, VETH_MAC_ADDR,
&mac_len);
if (!mac_addr_p) {
dev_err(&dev->dev, "Can't find VETH_MAC_ADDR attribute\n");
return -EINVAL;
}
/* Workaround for old/broken pHyp */
if (mac_len == 8)
mac_addr_p += 2;
else if (mac_len != 6) {
dev_err(&dev->dev, "VETH_MAC_ADDR attribute wrong len %d\n",
mac_len);
return -EINVAL;
}
mcastFilterSize_p = (__be32 *)vio_get_attribute(dev,
VETH_MCAST_FILTER_SIZE,
NULL);
if (!mcastFilterSize_p) {
dev_err(&dev->dev, "Can't find VETH_MCAST_FILTER_SIZE "
"attribute\n");
return -EINVAL;
}
netdev = alloc_etherdev_mqs(sizeof(struct ibmveth_adapter), IBMVETH_MAX_QUEUES, 1);
if (!netdev)
return -ENOMEM;
adapter = netdev_priv(netdev);
dev_set_drvdata(&dev->dev, netdev);
adapter->vdev = dev;
adapter->netdev = netdev;
INIT_WORK(&adapter->work, ibmveth_reset);
adapter->mcastFilterSize = be32_to_cpu(*mcastFilterSize_p);
ibmveth_init_link_settings(netdev);
netif_napi_add_weight(netdev, &adapter->napi, ibmveth_poll, 16);
netdev->irq = dev->irq;
netdev->netdev_ops = &ibmveth_netdev_ops;
netdev->ethtool_ops = &netdev_ethtool_ops;
SET_NETDEV_DEV(netdev, &dev->dev);
netdev->hw_features = NETIF_F_SG;
if (vio_get_attribute(dev, "ibm,illan-options", NULL) != NULL) {
netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_RXCSUM;
}
netdev->features |= netdev->hw_features;
ret = h_illan_attributes(adapter->vdev->unit_address, 0, 0, &ret_attr);
/* If running older firmware, TSO should not be enabled by default */
if (ret == H_SUCCESS && (ret_attr & IBMVETH_ILLAN_LRG_SND_SUPPORT) &&
!old_large_send) {
netdev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
netdev->features |= netdev->hw_features;
} else {
netdev->hw_features |= NETIF_F_TSO;
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/errno.h`, `linux/dma-mapping.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/skbuff.h`.
- Detected declarations: `struct ibmveth_stat`, `function ibmveth_rxq_flags`, `function ibmveth_rxq_toggle`, `function ibmveth_rxq_pending_buffer`, `function ibmveth_rxq_buffer_valid`, `function ibmveth_rxq_frame_offset`, `function ibmveth_rxq_large_packet`, `function ibmveth_rxq_frame_length`, `function ibmveth_rxq_csum_good`, `function ibmveth_real_max_tx_queues`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.