xref: /openbmc/qemu/include/sysemu/spdm-socket.h (revision 5885bcef3d760e84d17eb4113e85f2aea0bd0582)
1*bc419a1cSHuai-Cheng Kuo /*
2*bc419a1cSHuai-Cheng Kuo  * QEMU SPDM socket support
3*bc419a1cSHuai-Cheng Kuo  *
4*bc419a1cSHuai-Cheng Kuo  * Permission is hereby granted, free of charge, to any person obtaining a copy
5*bc419a1cSHuai-Cheng Kuo  * of this software and associated documentation files (the "Software"), to deal
6*bc419a1cSHuai-Cheng Kuo  * in the Software without restriction, including without limitation the rights
7*bc419a1cSHuai-Cheng Kuo  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8*bc419a1cSHuai-Cheng Kuo  * copies of the Software, and to permit persons to whom the Software is
9*bc419a1cSHuai-Cheng Kuo  * furnished to do so, subject to the following conditions:
10*bc419a1cSHuai-Cheng Kuo  *
11*bc419a1cSHuai-Cheng Kuo  * The above copyright notice and this permission notice shall be included in
12*bc419a1cSHuai-Cheng Kuo  * all copies or substantial portions of the Software.
13*bc419a1cSHuai-Cheng Kuo  *
14*bc419a1cSHuai-Cheng Kuo  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*bc419a1cSHuai-Cheng Kuo  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*bc419a1cSHuai-Cheng Kuo  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*bc419a1cSHuai-Cheng Kuo  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18*bc419a1cSHuai-Cheng Kuo  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19*bc419a1cSHuai-Cheng Kuo  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20*bc419a1cSHuai-Cheng Kuo  * THE SOFTWARE.
21*bc419a1cSHuai-Cheng Kuo  */
22*bc419a1cSHuai-Cheng Kuo 
23*bc419a1cSHuai-Cheng Kuo #ifndef SPDM_REQUESTER_H
24*bc419a1cSHuai-Cheng Kuo #define SPDM_REQUESTER_H
25*bc419a1cSHuai-Cheng Kuo 
26*bc419a1cSHuai-Cheng Kuo /**
27*bc419a1cSHuai-Cheng Kuo  * spdm_socket_connect: connect to an external SPDM socket
28*bc419a1cSHuai-Cheng Kuo  * @port: port to connect to
29*bc419a1cSHuai-Cheng Kuo  * @errp: error object handle
30*bc419a1cSHuai-Cheng Kuo  *
31*bc419a1cSHuai-Cheng Kuo  * This will connect to an external SPDM socket server. On error
32*bc419a1cSHuai-Cheng Kuo  * it will return -1 and errp will be set. On success this function
33*bc419a1cSHuai-Cheng Kuo  * will return the socket number.
34*bc419a1cSHuai-Cheng Kuo  */
35*bc419a1cSHuai-Cheng Kuo int spdm_socket_connect(uint16_t port, Error **errp);
36*bc419a1cSHuai-Cheng Kuo 
37*bc419a1cSHuai-Cheng Kuo /**
38*bc419a1cSHuai-Cheng Kuo  * spdm_socket_rsp: send and receive a message to a SPDM server
39*bc419a1cSHuai-Cheng Kuo  * @socket: socket returned from spdm_socket_connect()
40*bc419a1cSHuai-Cheng Kuo  * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro
41*bc419a1cSHuai-Cheng Kuo  * @req: request buffer
42*bc419a1cSHuai-Cheng Kuo  * @req_len: request buffer length
43*bc419a1cSHuai-Cheng Kuo  * @rsp: response buffer
44*bc419a1cSHuai-Cheng Kuo  * @rsp_len: response buffer length
45*bc419a1cSHuai-Cheng Kuo  *
46*bc419a1cSHuai-Cheng Kuo  * Send platform data to a SPDM server on socket and then receive
47*bc419a1cSHuai-Cheng Kuo  * a response.
48*bc419a1cSHuai-Cheng Kuo  */
49*bc419a1cSHuai-Cheng Kuo uint32_t spdm_socket_rsp(const int socket, uint32_t transport_type,
50*bc419a1cSHuai-Cheng Kuo                          void *req, uint32_t req_len,
51*bc419a1cSHuai-Cheng Kuo                          void *rsp, uint32_t rsp_len);
52*bc419a1cSHuai-Cheng Kuo 
53*bc419a1cSHuai-Cheng Kuo /**
54*bc419a1cSHuai-Cheng Kuo  * spdm_socket_close: send a shutdown command to the server
55*bc419a1cSHuai-Cheng Kuo  * @socket: socket returned from spdm_socket_connect()
56*bc419a1cSHuai-Cheng Kuo  * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro
57*bc419a1cSHuai-Cheng Kuo  *
58*bc419a1cSHuai-Cheng Kuo  * This will issue a shutdown command to the server.
59*bc419a1cSHuai-Cheng Kuo  */
60*bc419a1cSHuai-Cheng Kuo void spdm_socket_close(const int socket, uint32_t transport_type);
61*bc419a1cSHuai-Cheng Kuo 
62*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_COMMAND_NORMAL                0x0001
63*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_COMMAND_OOB_ENCAP_KEY_UPDATE  0x8001
64*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_COMMAND_CONTINUE              0xFFFD
65*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_COMMAND_SHUTDOWN              0xFFFE
66*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_COMMAND_UNKOWN                0xFFFF
67*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_COMMAND_TEST                  0xDEAD
68*bc419a1cSHuai-Cheng Kuo 
69*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_TRANSPORT_TYPE_MCTP           0x01
70*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_TRANSPORT_TYPE_PCI_DOE        0x02
71*bc419a1cSHuai-Cheng Kuo 
72*bc419a1cSHuai-Cheng Kuo #define SPDM_SOCKET_MAX_MESSAGE_BUFFER_SIZE       0x1200
73*bc419a1cSHuai-Cheng Kuo 
74*bc419a1cSHuai-Cheng Kuo #endif
75