drivers/net/wwan/wwan_core.c
Source file repositories/reference/linux-study-clean/drivers/net/wwan/wwan_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wwan/wwan_core.c- Extension
.c- Size
- 33851 bytes
- Lines
- 1442
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/bitmap.hlinux/err.hlinux/errno.hlinux/debugfs.hlinux/fs.hlinux/init.hlinux/idr.hlinux/kernel.hlinux/module.hlinux/poll.hlinux/skbuff.hlinux/slab.hlinux/types.hlinux/uaccess.hlinux/termios.hlinux/gnss.hlinux/wwan.hnet/rtnetlink.huapi/linux/wwan.h
Detected Declarations
struct wwan_devicestruct wwan_portfunction index_showfunction wwan_dev_destroyfunction wwan_dev_parent_matchfunction wwan_dev_name_matchfunction wwan_dev_debugfs_matchfunction wwan_put_debugfs_dirfunction exportedfunction wwan_remove_devfunction type_showfunction wwan_port_destroyfunction wwan_port_minor_matchfunction __dev_alloc_namefunction wwan_port_register_wwanfunction wwan_port_unregister_wwanfunction wwan_gnss_openfunction wwan_gnss_closefunction wwan_gnss_writefunction wwan_port_register_gnssfunction wwan_port_unregister_gnssfunction wwan_port_register_gnssfunction wwan_port_unregister_gnssfunction wwan_remove_portfunction wwan_port_rxfunction wwan_port_txonfunction wwan_port_txofffunction wwan_port_op_startfunction wwan_port_op_stopfunction wwan_port_op_txfunction is_read_blockedfunction is_write_blockedfunction wwan_wait_rxfunction wwan_wait_txfunction wwan_port_fops_openfunction wwan_port_fops_releasefunction wwan_port_fops_readfunction wwan_port_fops_writefunction wwan_port_fops_pollfunction wwan_port_fops_at_ioctlfunction wwan_port_fops_ioctlfunction wwan_rtnl_validatefunction wwan_rtnl_newlinkfunction wwan_rtnl_dellinkfunction wwan_rtnl_get_sizefunction wwan_rtnl_fill_infofunction wwan_create_default_linkfunction wwan_register_ops
Annotated Snippet
static const struct file_operations wwan_port_fops = {
.owner = THIS_MODULE,
.open = wwan_port_fops_open,
.release = wwan_port_fops_release,
.read = wwan_port_fops_read,
.write = wwan_port_fops_write,
.poll = wwan_port_fops_poll,
.unlocked_ioctl = wwan_port_fops_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = compat_ptr_ioctl,
#endif
.llseek = noop_llseek,
};
static int wwan_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
struct netlink_ext_ack *extack)
{
if (!data)
return -EINVAL;
if (!tb[IFLA_PARENT_DEV_NAME])
return -EINVAL;
if (!data[IFLA_WWAN_LINK_ID])
return -EINVAL;
return 0;
}
static const struct device_type wwan_type = { .name = "wwan" };
static struct net_device *wwan_rtnl_alloc(struct nlattr *tb[],
const char *ifname,
unsigned char name_assign_type,
unsigned int num_tx_queues,
unsigned int num_rx_queues)
{
const char *devname = nla_data(tb[IFLA_PARENT_DEV_NAME]);
struct wwan_device *wwandev = wwan_dev_get_by_name(devname);
struct net_device *dev;
unsigned int priv_size;
if (IS_ERR(wwandev))
return ERR_CAST(wwandev);
/* only supported if ops were registered (not just ports) */
if (!wwandev->ops) {
dev = ERR_PTR(-EOPNOTSUPP);
goto out;
}
priv_size = sizeof(struct wwan_netdev_priv) + wwandev->ops->priv_size;
dev = alloc_netdev_mqs(priv_size, ifname, name_assign_type,
wwandev->ops->setup, num_tx_queues, num_rx_queues);
if (dev) {
SET_NETDEV_DEV(dev, &wwandev->dev);
SET_NETDEV_DEVTYPE(dev, &wwan_type);
}
out:
/* release the reference */
put_device(&wwandev->dev);
return dev;
}
static int wwan_rtnl_newlink(struct net_device *dev,
struct rtnl_newlink_params *params,
struct netlink_ext_ack *extack)
{
struct wwan_device *wwandev = wwan_dev_get_by_parent(dev->dev.parent);
struct wwan_netdev_priv *priv = netdev_priv(dev);
struct nlattr **data = params->data;
u32 link_id;
int ret;
link_id = nla_get_u32(data[IFLA_WWAN_LINK_ID]);
if (IS_ERR(wwandev))
return PTR_ERR(wwandev);
/* shouldn't have a netdev (left) with us as parent so WARN */
if (WARN_ON(!wwandev->ops)) {
ret = -EOPNOTSUPP;
goto out;
}
priv->link_id = link_id;
if (wwandev->ops->newlink)
ret = wwandev->ops->newlink(wwandev->ops_ctxt, dev,
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/err.h`, `linux/errno.h`, `linux/debugfs.h`, `linux/fs.h`, `linux/init.h`, `linux/idr.h`, `linux/kernel.h`.
- Detected declarations: `struct wwan_device`, `struct wwan_port`, `function index_show`, `function wwan_dev_destroy`, `function wwan_dev_parent_match`, `function wwan_dev_name_match`, `function wwan_dev_debugfs_match`, `function wwan_put_debugfs_dir`, `function exported`, `function wwan_remove_dev`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.