include/linux/ptp_classify.h
Source file repositories/reference/linux-study-clean/include/linux/ptp_classify.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/ptp_classify.h- Extension
.h- Size
- 7051 bytes
- Lines
- 244
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/unaligned.hlinux/ip.hlinux/ktime.hlinux/skbuff.hlinux/udp.hnet/checksum.h
Detected Declarations
struct clock_identitystruct port_identitystruct ptp_headerfunction versionsfunction ptp_check_diff8function checksumfunction ptp_classifier_initfunction ptp_get_msgtypefunction ptp_msg_is_syncfunction ptp_header_update_correction
Annotated Snippet
struct clock_identity {
u8 id[8];
} __packed;
struct port_identity {
struct clock_identity clock_identity;
__be16 port_number;
} __packed;
struct ptp_header {
u8 tsmt; /* transportSpecific | messageType */
u8 ver; /* reserved | versionPTP */
__be16 message_length;
u8 domain_number;
u8 reserved1;
u8 flag_field[2];
__be64 correction;
__be32 reserved2;
struct port_identity source_port_identity;
__be16 sequence_id;
u8 control;
u8 log_message_interval;
} __packed;
#if defined(CONFIG_NET_PTP_CLASSIFY)
/**
* ptp_classify_raw - classify a PTP packet
* @skb: buffer
*
* Runs a minimal BPF dissector to classify a network packet to
* determine the PTP class. In case the skb does not contain any
* PTP protocol data, PTP_CLASS_NONE will be returned, otherwise
* PTP_CLASS_V1_IPV{4,6}, PTP_CLASS_V2_IPV{4,6} or
* PTP_CLASS_V2_{L2,VLAN}, depending on the packet content.
*/
unsigned int ptp_classify_raw(const struct sk_buff *skb);
/**
* ptp_parse_header - Get pointer to the PTP v2 header
* @skb: packet buffer
* @type: type of the packet (see ptp_classify_raw())
*
* This function takes care of the VLAN, UDP, IPv4 and IPv6 headers. The length
* is checked.
*
* Note, internally skb_mac_header() is used. Make sure that the @skb is
* initialized accordingly.
*
* Return: Pointer to the ptp v2 header or NULL if not found
*/
struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type);
/**
* ptp_get_msgtype - Extract ptp message type from given header
* @hdr: ptp header
* @type: type of the packet (see ptp_classify_raw())
*
* This function returns the message type for a given ptp header. It takes care
* of the different ptp header versions (v1 or v2).
*
* Return: The message type
*/
static inline u8 ptp_get_msgtype(const struct ptp_header *hdr,
unsigned int type)
{
u8 msgtype;
if (unlikely(type & PTP_CLASS_V1)) {
/* msg type is located at the control field for ptp v1 */
msgtype = hdr->control;
} else {
msgtype = hdr->tsmt & 0x0f;
}
return msgtype;
}
/**
* ptp_check_diff8 - Computes new checksum (when altering a 64-bit field)
* @old: old field value
* @new: new field value
* @oldsum: previous checksum
*
* This function can be used to calculate a new checksum when only a single
* field is changed. Similar as ip_vs_check_diff*() in ip_vs.h.
*
* Return: Updated checksum
*/
static inline __wsum ptp_check_diff8(__be64 old, __be64 new, __wsum oldsum)
{
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/ip.h`, `linux/ktime.h`, `linux/skbuff.h`, `linux/udp.h`, `net/checksum.h`.
- Detected declarations: `struct clock_identity`, `struct port_identity`, `struct ptp_header`, `function versions`, `function ptp_check_diff8`, `function checksum`, `function ptp_classifier_init`, `function ptp_get_msgtype`, `function ptp_msg_is_sync`, `function ptp_header_update_correction`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
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.