drivers/net/rionet.c
Source file repositories/reference/linux-study-clean/drivers/net/rionet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/rionet.c- Extension
.c- Size
- 18750 bytes
- Lines
- 749
- 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/kernel.hlinux/dma-mapping.hlinux/delay.hlinux/rio.hlinux/rio_drv.hlinux/slab.hlinux/rio_ids.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/crc32.hlinux/ethtool.hlinux/reboot.h
Detected Declarations
struct rionet_privatestruct rionet_peerstruct rionet_netfunction rionet_rx_cleanfunction rionet_rx_fillfunction rionet_queue_tx_msgfunction rionet_start_xmitfunction rionet_dbell_eventfunction list_for_each_entryfunction rionet_inb_msg_eventfunction rionet_outb_msg_eventfunction rionet_openfunction rionet_closefunction rionet_remove_devfunction rionet_get_drvinfofunction rionet_get_msglevelfunction rionet_set_msglevelfunction rionet_setup_netdevfunction rionet_add_devfunction netdevfunction rionet_shutdownfunction list_for_each_entryfunction rionet_remove_mportfunction rionet_initfunction rionet_exit
Annotated Snippet
static const struct net_device_ops rionet_netdev_ops = {
.ndo_open = rionet_open,
.ndo_stop = rionet_close,
.ndo_start_xmit = rionet_start_xmit,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};
static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev)
{
int rc = 0;
struct rionet_private *rnet;
u8 addr[ETH_ALEN];
u16 device_id;
const size_t rionet_active_bytes = sizeof(void *) *
RIO_MAX_ROUTE_ENTRIES(mport->sys_size);
nets[mport->id].active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
get_order(rionet_active_bytes));
if (!nets[mport->id].active) {
rc = -ENOMEM;
goto out;
}
memset((void *)nets[mport->id].active, 0, rionet_active_bytes);
/* Set up private area */
rnet = netdev_priv(ndev);
rnet->mport = mport;
rnet->open = false;
/* Set the default MAC address */
device_id = rio_local_get_device_id(mport);
addr[0] = 0x00;
addr[1] = 0x01;
addr[2] = 0x00;
addr[3] = 0x01;
addr[4] = device_id >> 8;
addr[5] = device_id & 0xff;
eth_hw_addr_set(ndev, addr);
ndev->netdev_ops = &rionet_netdev_ops;
ndev->mtu = RIONET_MAX_MTU;
/* MTU range: 68 - 4082 */
ndev->min_mtu = ETH_MIN_MTU;
ndev->max_mtu = RIONET_MAX_MTU;
ndev->lltx = true;
SET_NETDEV_DEV(ndev, &mport->dev);
ndev->ethtool_ops = &rionet_ethtool_ops;
spin_lock_init(&rnet->lock);
spin_lock_init(&rnet->tx_lock);
rnet->msg_enable = RIONET_DEFAULT_MSGLEVEL;
rc = register_netdev(ndev);
if (rc != 0) {
free_pages((unsigned long)nets[mport->id].active,
get_order(rionet_active_bytes));
goto out;
}
printk(KERN_INFO "%s: %s %s Version %s, MAC %pM, %s\n",
ndev->name,
DRV_NAME,
DRV_DESC,
DRV_VERSION,
ndev->dev_addr,
mport->name);
out:
return rc;
}
static int rionet_add_dev(struct device *dev, struct subsys_interface *sif)
{
int rc = -ENODEV;
u32 lsrc_ops, ldst_ops;
struct rionet_peer *peer;
struct net_device *ndev = NULL;
struct rio_dev *rdev = to_rio_dev(dev);
unsigned char netid = rdev->net->hport->id;
if (netid >= RIONET_MAX_NETS)
return rc;
/*
* If first time through this net, make sure local device is rionet
* capable and setup netdev (this step will be skipped in later probes
* on the same net).
*/
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/dma-mapping.h`, `linux/delay.h`, `linux/rio.h`, `linux/rio_drv.h`, `linux/slab.h`, `linux/rio_ids.h`.
- Detected declarations: `struct rionet_private`, `struct rionet_peer`, `struct rionet_net`, `function rionet_rx_clean`, `function rionet_rx_fill`, `function rionet_queue_tx_msg`, `function rionet_start_xmit`, `function rionet_dbell_event`, `function list_for_each_entry`, `function rionet_inb_msg_event`.
- 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.