include/net/mctp.h
Source file repositories/reference/linux-study-clean/include/net/mctp.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/mctp.h- Extension
.h- Size
- 9743 bytes
- Lines
- 361
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/mctp.hlinux/netdevice.hnet/net_namespace.hnet/sock.h
Detected Declarations
struct mctp_hdrstruct mctp_sockstruct mctp_sk_keystruct mctp_skb_cbstruct mctp_flowstruct mctp_dststruct mctp_routestruct mctp_dststruct mctp_neighenum mctp_neigh_sourceenum mctp_phys_bindingfunction mctp_address_unicastfunction mctp_address_broadcastfunction mctp_address_nullfunction mctp_address_matches
Annotated Snippet
struct mctp_hdr {
u8 ver;
u8 dest;
u8 src;
u8 flags_seq_tag;
};
#define MCTP_VER_MIN 1
#define MCTP_VER_MAX 1
/* Definitions for ver field */
#define MCTP_HDR_VER_MASK GENMASK(3, 0)
/* Definitions for flags_seq_tag field */
#define MCTP_HDR_FLAG_SOM BIT(7)
#define MCTP_HDR_FLAG_EOM BIT(6)
#define MCTP_HDR_FLAG_TO BIT(3)
#define MCTP_HDR_FLAGS GENMASK(5, 3)
#define MCTP_HDR_SEQ_SHIFT 4
#define MCTP_HDR_SEQ_MASK GENMASK(1, 0)
#define MCTP_HDR_TAG_SHIFT 0
#define MCTP_HDR_TAG_MASK GENMASK(2, 0)
#define MCTP_INITIAL_DEFAULT_NET 1
static inline bool mctp_address_unicast(mctp_eid_t eid)
{
return eid >= 8 && eid < 255;
}
static inline bool mctp_address_broadcast(mctp_eid_t eid)
{
return eid == 255;
}
static inline bool mctp_address_null(mctp_eid_t eid)
{
return eid == 0;
}
static inline bool mctp_address_matches(mctp_eid_t match, mctp_eid_t eid)
{
return match == eid || match == MCTP_ADDR_ANY;
}
static inline struct mctp_hdr *mctp_hdr(struct sk_buff *skb)
{
return (struct mctp_hdr *)skb_network_header(skb);
}
/* socket implementation */
struct mctp_sock {
struct sock sk;
/* bind() params */
unsigned int bind_net;
mctp_eid_t bind_local_addr;
mctp_eid_t bind_peer_addr;
unsigned int bind_peer_net;
bool bind_peer_set;
__u8 bind_type;
/* sendmsg()/recvmsg() uses struct sockaddr_mctp_ext */
bool addr_ext;
/* list of mctp_sk_key, for incoming tag lookup. updates protected
* by sk->net->keys_lock
*/
struct hlist_head keys;
/* mechanism for expiring allocated keys; will release an allocated
* tag, and any netdev state for a request/response pairing
*/
struct timer_list key_expiry;
};
/* Key for matching incoming packets to sockets or reassembly contexts.
* Packets are matched on (peer EID, local EID, tag).
*
* Lifetime / locking requirements:
*
* - individual key data (ie, the struct itself) is protected by key->lock;
* changes must be made with that lock held.
*
* - the lookup fields: peer_addr, local_addr and tag are set before the
* key is added to lookup lists, and never updated.
*
* - A ref to the key must be held (throuh key->refs) if a pointer to the
* key is to be accessed after key->lock is released.
*
Annotation
- Immediate include surface: `linux/bits.h`, `linux/mctp.h`, `linux/netdevice.h`, `net/net_namespace.h`, `net/sock.h`.
- Detected declarations: `struct mctp_hdr`, `struct mctp_sock`, `struct mctp_sk_key`, `struct mctp_skb_cb`, `struct mctp_flow`, `struct mctp_dst`, `struct mctp_route`, `struct mctp_dst`, `struct mctp_neigh`, `enum mctp_neigh_source`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.