drivers/net/slip/slip.c
Source file repositories/reference/linux-study-clean/drivers/net/slip/slip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/slip/slip.c- Extension
.c- Size
- 34038 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.
- 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/compat.hlinux/module.hlinux/moduleparam.hlinux/uaccess.hlinux/bitops.hlinux/sched/signal.hlinux/string.hlinux/mm.hlinux/interrupt.hlinux/in.hlinux/tty.hlinux/errno.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/rtnetlink.hlinux/if_arp.hlinux/if_slip.hlinux/delay.hlinux/init.hlinux/slab.hlinux/workqueue.hslip.hlinux/ip.hlinux/tcp.hnet/slhc_vj.h
Detected Declarations
function sl_alloc_bufsfunction sl_free_bufsfunction sl_realloc_bufsfunction sl_lockfunction sl_unlockfunction sl_bumpfunction sl_encapsfunction slip_transmitfunction slip_write_wakeupfunction sl_tx_timeoutfunction sl_xmitfunction sl_closefunction sl_openfunction sl_change_mtufunction sl_get_stats64function sl_initfunction sl_uninitfunction sl_free_netdevfunction sl_setupfunction slip_receive_buffunction sl_syncfunction slip_openfunction slip_closefunction slip_hangupfunction slip_escfunction slip_unescfunction slip_esc6function slip_unesc6function slip_ioctlfunction sl_siocdevprivatefunction slip_initfunction slip_exitfunction sl_outfillfunction sl_keepalivemodule init slip_init
Annotated Snippet
static const struct net_device_ops sl_netdev_ops = {
.ndo_init = sl_init,
.ndo_uninit = sl_uninit,
.ndo_open = sl_open,
.ndo_stop = sl_close,
.ndo_start_xmit = sl_xmit,
.ndo_get_stats64 = sl_get_stats64,
.ndo_change_mtu = sl_change_mtu,
.ndo_tx_timeout = sl_tx_timeout,
#ifdef CONFIG_SLIP_SMART
.ndo_siocdevprivate = sl_siocdevprivate,
#endif
};
static void sl_setup(struct net_device *dev)
{
dev->netdev_ops = &sl_netdev_ops;
dev->needs_free_netdev = true;
dev->priv_destructor = sl_free_netdev;
dev->hard_header_len = 0;
dev->addr_len = 0;
dev->tx_queue_len = 10;
/* MTU range: 68 - 65534 */
dev->min_mtu = 68;
dev->max_mtu = 65534;
/* New-style flags. */
dev->flags = IFF_NOARP|IFF_POINTOPOINT|IFF_MULTICAST;
}
/******************************************
Routines looking at TTY side.
******************************************/
/*
* Handle the 'receiver data ready' interrupt.
* This function is called by the 'tty_io' module in the kernel when
* a block of SLIP data has been received, which can now be decapsulated
* and sent on to some IP layer for further processing. This will not
* be re-entered while running but other ldisc functions may be called
* in parallel
*/
static void slip_receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp,
size_t count)
{
struct slip *sl = tty->disc_data;
if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
return;
/* Read the characters out of the buffer */
while (count--) {
if (fp && *fp++) {
if (!test_and_set_bit(SLF_ERROR, &sl->flags))
sl->dev->stats.rx_errors++;
cp++;
continue;
}
#ifdef CONFIG_SLIP_MODE_SLIP6
if (sl->mode & SL_MODE_SLIP6)
slip_unesc6(sl, *cp++);
else
#endif
slip_unesc(sl, *cp++);
}
}
/************************************
* slip_open helper routines.
************************************/
/* Collect hanged up channels */
static void sl_sync(void)
{
int i;
struct net_device *dev;
struct slip *sl;
for (i = 0; i < slip_maxdev; i++) {
dev = slip_devs[i];
if (dev == NULL)
break;
sl = netdev_priv(dev);
if (sl->tty || sl->leased)
Annotation
- Immediate include surface: `linux/compat.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/uaccess.h`, `linux/bitops.h`, `linux/sched/signal.h`, `linux/string.h`, `linux/mm.h`.
- Detected declarations: `function sl_alloc_bufs`, `function sl_free_bufs`, `function sl_realloc_bufs`, `function sl_lock`, `function sl_unlock`, `function sl_bump`, `function sl_encaps`, `function slip_transmit`, `function slip_write_wakeup`, `function sl_tx_timeout`.
- 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.
- 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.