File: mctp.7

package info (click to toggle)
manpages 6.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,184 kB
  • sloc: sh: 575; python: 222; perl: 190; makefile: 29; lisp: 22
file content (183 lines) | stat: -rw-r--r-- 4,596 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH mctp 7 2025-05-17 "Linux man-pages (unreleased)"
.SH NAME
mctp \- Management Component Transport Protocol
.SH SYNOPSIS
.nf
.BR "#include <linux/mctp.h>" \
"  /* MCTP address type and protocol constants */"
.B #include <sys/socket.h>
.P
.IB mctp_socket " = socket(AF_MCTP, SOCK_DGRAM, 0);"
.fi
.SH DESCRIPTION
Linux implements the Management Component Transport Protocol (MCTP),
specified by DMTF spec DSP0236,
currently at version 1.
This is a connectionless protocol,
typically used between devices within a server system.
Message reliability and ordering are not guaranteed,
but message boundaries are preserved.
.P
The API for MCTP messaging uses a standard sockets interface,
using the
.BR sendto (2)
and
.BR recvfrom (2)
classes of system calls to transfer messages.
Messages may be fragmented into packets before transmission,
and reassembled at the remote endpoint.
This fragmentation and reassembly is transparent to user space.
.SS Address format
MCTP addresses
(also referred to as EIDs, or Endpoint Identifiers)
are single-byte values,
typed as
.IR mctp_eid_t .
Packets between a local and remote endpoint
are identified by
the source and destination EIDs,
plus a three-bit tag value.
.P
Addressing data is passed in socket system calls through a
.I sockaddr_mctp
structure,
defined as:
.P
.in +4n
.EX
typedef uint8_t        mctp_eid_t;
\&
struct mctp_addr {
    mctp_eid_t         s_addr;
};
\&
struct sockaddr_mctp {
    unsigned short     smctp_family;  /* = AF_MCTP */
    uint16_t           __smctp_pad0;
    int                smctp_network; /* local network identifier */
    struct mctp_addr   smctp_addr;    /* EID */
    uint8_t            smctp_type;    /* message type byte */
    uint8_t            smctp_tag;     /* tag value & owner */
    uint8_t            __smctp_pad1;
};
.EE
.in
.SS Sending messages
Messages can be transmitted using the
.BR sendto (2)
and
.BR sendmsg (2)
system calls,
by providing a
.I sockaddr_mctp
structure
describing the addressing parameters.
.P
.in +4n
.EX
ssize_t               n;
const char            *buf;
struct sockaddr_mctp  addr;
\&
/* unused fields must be zero */
memset(&addr, 0, sizeof(addr));
\&
/* set message destination */
addr.smctp_family = AF_MCTP;
addr.smctp_network = 0;
addr.smctp_addr.s_addr = 8; /* remote EID */
addr.smctp_tag = MCTP_TAG_OWNER;
addr.smctp_type = MYPROGRAM_MCTP_TYPE_ECHO; /* example type */
\&
buf = "hello, world!"
\&
n = sendto(sd, buf, 13, 0,
           (struct sockaddr *) &addr, sizeof(addr));
.EE
.in
.P
Here, the sender owns the message tag; so
.B MCTP_TAG_OWNER
is used as the tag data.
The kernel will allocate a specific tag value for this message.
If no tag is available,
.BR sendto (2)
will return an error,
with errno set to
.BR EBUSY .
This allocated tag remains associated with the socket,
so that any replies to the sent message will be received by the same socket.
.P
Sending a MCTP message requires the
.B CAP_NET_RAW
capability.
.SS Receiving messages
Messages can be received using the
.BR recvfrom (2)
and
.BR recvmsg (2)
system calls.
.P
.in +4n
.EX
char                  buf[13];
socklen_t             addrlen;
struct sockaddr_mctp  addr;
\&
addrlen = sizeof(addr);
\&
n = recvfrom(sd, buf, sizeof(buf), 0,
             (struct sockaddr *) &addr, &addrlen);
.EE
.in
.P
In order to receive an incoming message,
the receiver will need to
either have previously sent a message to the same endpoint,
or performed a
.BR bind (2)
to receive all messages of a certain type:
.P
.in +4n
.EX
struct sockaddr_mctp  addr;
\&
addr.smctp_family = AF_MCTP;
addr.smctp_network = MCTP_NET_ANY;
addr.smctp_addr.s_addr = MCTP_ADDR_ANY;
addr.smctp_type = MYPROGRAM_MCTP_TYPE_ECHO; /* our 'echo' type */
\&
int rc = bind(sd, (struct sockaddr *) &addr, sizeof(addr));
.EE
.in
.P
This call requires the
.B CAP_NET_BIND_SERVICE
capability,
and will result in
the socket receiving all messages sent to locally-assigned EIDs,
for the specified message type.
.P
After a
.BR recvfrom (2)
or
.BR recvmsg (2)
returns a success condition,
the provided address argument
will be populated with the sender's network and EID,
as well as the tag value used for the message.
Any reply to this message should pass the same address and tag value
(with the TO bit cleared)
to indicate that is is directed to the same remote endpoint.
.SH SEE ALSO
.BR socket (7)
.P
.I linux.git/Documentation/networking/mctp.rst
.P
.UR https://www.dmtf.org/\:standards/\:pmci
The DSP0236 specification
.UE .