drivers/net/ppp/ppp_generic.c
Source file repositories/reference/linux-study-clean/drivers/net/ppp/ppp_generic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ppp/ppp_generic.c- Extension
.c- Size
- 88711 bytes
- Lines
- 3656
- 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/module.hlinux/kernel.hlinux/sched/signal.hlinux/kmod.hlinux/init.hlinux/list.hlinux/idr.hlinux/netdevice.hlinux/poll.hlinux/ppp_defs.hlinux/filter.hlinux/ppp-ioctl.hlinux/ppp_channel.hlinux/ppp-comp.hlinux/skbuff.hlinux/rculist.hlinux/rtnetlink.hlinux/if_arp.hlinux/ip.hlinux/tcp.hlinux/spinlock.hlinux/rwsem.hlinux/stddef.hlinux/device.hlinux/mutex.hlinux/slab.hlinux/file.hlinux/unaligned.hnet/netdev_lock.hnet/slhc_vj.hlinux/atomic.hlinux/refcount.h
Detected Declarations
struct ppp_filestruct ppp_xmit_recursionstruct pppstruct channelstruct ppp_configstruct ppp_netstruct sock_fprog32struct ppp_option_data32struct ppp_mp_skb_parmstruct compressor_entryfunction proto_to_npindexfunction ethertype_to_npindexfunction ppp_openfunction ppp_releasefunction ppp_readfunction ppp_check_packetfunction ppp_writefunction ppp_pollfunction ppp_bridge_channelsfunction rcu_dereference_protectedfunction rcu_dereference_protectedfunction ppp_unbridge_channelsfunction ppp_ioctlfunction ppp_compat_ioctlfunction ppp_unattached_ioctlfunction ppp_init_netfunction ppp_exit_rtnl_netfunction ppp_exit_netfunction ppp_unit_registerfunction ppp_dev_configurefunction ppp_nl_validatefunction ppp_nl_newlinkfunction ppp_nl_dellinkfunction ppp_nl_get_sizefunction ppp_nl_fill_infofunction timefunction ppp_start_xmitfunction ppp_net_siocdevprivatefunction ppp_get_stats64function ppp_dev_initfunction ppp_dev_uninitfunction ppp_dev_priv_destructorfunction ppp_fill_forward_pathfunction ppp_setupfunction ppp_xmit_flushfunction __ppp_xmit_processfunction ppp_xmit_processfunction pad_compress_skb
Annotated Snippet
static const struct net_device_ops ppp_netdev_ops;
static const struct class ppp_class = {
.name = "ppp",
};
/* per net-namespace data */
static inline struct ppp_net *ppp_pernet(struct net *net)
{
return net_generic(net, ppp_net_id);
}
/* Translates a PPP protocol number to a NP index (NP == network protocol) */
static inline int proto_to_npindex(int proto)
{
switch (proto) {
case PPP_IP:
return NP_IP;
case PPP_IPV6:
return NP_IPV6;
case PPP_IPX:
return NP_IPX;
case PPP_AT:
return NP_AT;
case PPP_MPLS_UC:
return NP_MPLS_UC;
case PPP_MPLS_MC:
return NP_MPLS_MC;
}
return -EINVAL;
}
/* Translates an NP index into a PPP protocol number */
static const int npindex_to_proto[NUM_NP] = {
PPP_IP,
PPP_IPV6,
PPP_IPX,
PPP_AT,
PPP_MPLS_UC,
PPP_MPLS_MC,
};
/* Translates an ethertype into an NP index */
static inline int ethertype_to_npindex(int ethertype)
{
switch (ethertype) {
case ETH_P_IP:
return NP_IP;
case ETH_P_IPV6:
return NP_IPV6;
case ETH_P_IPX:
return NP_IPX;
case ETH_P_PPPTALK:
case ETH_P_ATALK:
return NP_AT;
case ETH_P_MPLS_UC:
return NP_MPLS_UC;
case ETH_P_MPLS_MC:
return NP_MPLS_MC;
}
return -1;
}
/* Translates an NP index into an ethertype */
static const int npindex_to_ethertype[NUM_NP] = {
ETH_P_IP,
ETH_P_IPV6,
ETH_P_IPX,
ETH_P_PPPTALK,
ETH_P_MPLS_UC,
ETH_P_MPLS_MC,
};
/*
* Locking shorthand.
*/
#define ppp_xmit_lock(ppp) spin_lock_bh(&(ppp)->wlock)
#define ppp_xmit_unlock(ppp) spin_unlock_bh(&(ppp)->wlock)
#define ppp_recv_lock(ppp) spin_lock_bh(&(ppp)->rlock)
#define ppp_recv_unlock(ppp) spin_unlock_bh(&(ppp)->rlock)
#define ppp_lock(ppp) do { ppp_xmit_lock(ppp); \
ppp_recv_lock(ppp); } while (0)
#define ppp_unlock(ppp) do { ppp_recv_unlock(ppp); \
ppp_xmit_unlock(ppp); } while (0)
/*
* /dev/ppp device routines.
* The /dev/ppp device is used by pppd to control the ppp unit.
* It supports the read, write, ioctl and poll functions.
* Open instances of /dev/ppp can be in one of three states:
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/kmod.h`, `linux/init.h`, `linux/list.h`, `linux/idr.h`, `linux/netdevice.h`.
- Detected declarations: `struct ppp_file`, `struct ppp_xmit_recursion`, `struct ppp`, `struct channel`, `struct ppp_config`, `struct ppp_net`, `struct sock_fprog32`, `struct ppp_option_data32`, `struct ppp_mp_skb_parm`, `struct compressor_entry`.
- 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.