xref: /openbmc/hiomapd/protocol.h (revision 1e531afd1698c5613004e2bf4e73bda4364fa6d6)
1 /* SPDX-License-Identifier: Apache-2.0 */
2 /* Copyright (C) 2018 IBM Corp. */
3 
4 #ifndef PROTOCOL_H
5 #define PROTOCOL_H
6 
7 struct mbox_context;
8 
9 /*
10  * The GET_MBOX_INFO command is special as it can change the interface based on
11  * negotiation. As such we need to accommodate all response types
12  */
13 struct protocol_get_info {
14 	struct {
15 		uint8_t api_version;
16 	} req;
17 	struct {
18 		uint8_t api_version;
19 		union {
20 			struct {
21 				uint16_t read_window_size;
22 				uint16_t write_window_size;
23 			} v1;
24 			struct {
25 				uint8_t block_size_shift;
26 				uint16_t timeout;
27 			} v2;
28 		};
29 	} resp;
30 };
31 
32 struct protocol_ops {
33 	int (*get_info)(struct mbox_context *context,
34 			struct protocol_get_info *io);
35 };
36 
37 int protocol_init(struct mbox_context *context);
38 void protocol_free(struct mbox_context *context);
39 
40 int protocol_negotiate_version(struct mbox_context *context, uint8_t requested);
41 
42 /* Protocol v1 */
43 int protocol_v1_get_info(struct mbox_context *context,
44 			 struct protocol_get_info *io);
45 
46 /* Protocol v2 */
47 int protocol_v2_get_info(struct mbox_context *context,
48 			 struct protocol_get_info *io);
49 
50 #endif /* PROTOCOL_H */
51