net/802/mrp.c
Source file repositories/reference/linux-study-clean/net/802/mrp.c
File Facts
- System
- Linux kernel
- Corpus path
net/802/mrp.c- Extension
.c- Size
- 25854 bytes
- Lines
- 954
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/timer.hlinux/skbuff.hlinux/netdevice.hlinux/etherdevice.hlinux/rtnetlink.hlinux/slab.hlinux/module.hnet/mrp.hlinux/unaligned.h
Detected Declarations
function mrp_attrvalue_incfunction mrp_attr_cmpfunction mrp_attr_destroyfunction mrp_attr_destroy_allfunction mrp_pdu_initfunction mrp_pdu_append_end_markfunction mrp_pdu_queuefunction mrp_queue_xmitfunction mrp_pdu_append_msg_hdrfunction mrp_pdu_append_vecattr_hdrfunction mrp_pdu_append_vecattr_eventfunction mrp_cbfunction memcmpfunction mrp_attr_eventfunction mrp_request_joinfunction mrp_request_leavefunction mrp_mad_eventfunction mrp_join_timer_armfunction mrp_join_timerfunction mrp_periodic_timer_armfunction mrp_periodic_timerfunction mrp_pdu_parse_end_markfunction mrp_pdu_parse_vecattr_eventfunction mrp_pdu_parse_vecattrfunction mrp_pdu_parse_msgfunction mrp_rcvfunction mrp_init_portfunction mrp_release_portfunction mrp_init_applicantfunction mrp_uninit_applicantfunction mrp_register_applicationfunction mrp_unregister_applicationexport mrp_request_joinexport mrp_request_leaveexport mrp_init_applicantexport mrp_uninit_applicantexport mrp_register_applicationexport mrp_unregister_application
Annotated Snippet
mrp_cb(app->pdu)->mh->attrlen != attr->len) {
if (mrp_pdu_append_msg_hdr(app, attr->type, attr->len) < 0)
goto queue;
}
/* If there is no VectorAttribute header for this Message in the PDU,
* or this attribute's value does not sequentially follow the previous
* attribute's value, add a new VectorAttribute header to the PDU.
*/
if (!mrp_cb(app->pdu)->vah ||
memcmp(mrp_cb(app->pdu)->attrvalue, attr->value, attr->len)) {
if (mrp_pdu_append_vecattr_hdr(app, attr->value, attr->len) < 0)
goto queue;
}
len = be16_to_cpu(get_unaligned(&mrp_cb(app->pdu)->vah->lenflags));
pos = len % 3;
/* Events are packed into Vectors in the PDU, three to a byte. Add a
* byte to the end of the Vector if necessary.
*/
if (!pos) {
if (skb_tailroom(app->pdu) < sizeof(u8))
goto queue;
vaevents = __skb_put(app->pdu, sizeof(u8));
} else {
vaevents = (u8 *)(skb_tail_pointer(app->pdu) - sizeof(u8));
}
switch (pos) {
case 0:
*vaevents = vaevent * (__MRP_VECATTR_EVENT_MAX *
__MRP_VECATTR_EVENT_MAX);
break;
case 1:
*vaevents += vaevent * __MRP_VECATTR_EVENT_MAX;
break;
case 2:
*vaevents += vaevent;
break;
default:
WARN_ON(1);
}
/* Increment the length of the VectorAttribute in the PDU, as well as
* the value of the next attribute that would continue its Vector.
*/
put_unaligned(cpu_to_be16(++len), &mrp_cb(app->pdu)->vah->lenflags);
mrp_attrvalue_inc(mrp_cb(app->pdu)->attrvalue, attr->len);
return 0;
queue:
mrp_pdu_queue(app);
goto again;
}
static void mrp_attr_event(struct mrp_applicant *app,
struct mrp_attr *attr, enum mrp_event event)
{
enum mrp_applicant_state state;
state = mrp_applicant_state_table[attr->state][event];
if (state == MRP_APPLICANT_INVALID) {
WARN_ON(1);
return;
}
if (event == MRP_EVENT_TX) {
/* When appending the attribute fails, don't update its state
* in order to retry at the next TX event.
*/
switch (mrp_tx_action_table[attr->state]) {
case MRP_TX_ACTION_NONE:
case MRP_TX_ACTION_S_JOIN_IN_OPTIONAL:
case MRP_TX_ACTION_S_IN_OPTIONAL:
break;
case MRP_TX_ACTION_S_NEW:
if (mrp_pdu_append_vecattr_event(
app, attr, MRP_VECATTR_EVENT_NEW) < 0)
return;
break;
case MRP_TX_ACTION_S_JOIN_IN:
if (mrp_pdu_append_vecattr_event(
app, attr, MRP_VECATTR_EVENT_JOIN_IN) < 0)
return;
break;
case MRP_TX_ACTION_S_LV:
if (mrp_pdu_append_vecattr_event(
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/timer.h`, `linux/skbuff.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/rtnetlink.h`, `linux/slab.h`, `linux/module.h`.
- Detected declarations: `function mrp_attrvalue_inc`, `function mrp_attr_cmp`, `function mrp_attr_destroy`, `function mrp_attr_destroy_all`, `function mrp_pdu_init`, `function mrp_pdu_append_end_mark`, `function mrp_pdu_queue`, `function mrp_queue_xmit`, `function mrp_pdu_append_msg_hdr`, `function mrp_pdu_append_vecattr_hdr`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- 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.