blob: c14713949e8ed68626261210d8fddd132e9bfe88 [file] [log] [blame]
Andrew Jeffery1e531af2018-08-07 13:32:57 +09301/* SPDX-License-Identifier: Apache-2.0 */
2/* Copyright (C) 2018 IBM Corp. */
3
4#ifndef PROTOCOL_H
5#define PROTOCOL_H
6
7struct 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 */
13struct 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
32struct protocol_ops {
33 int (*get_info)(struct mbox_context *context,
34 struct protocol_get_info *io);
35};
36
37int protocol_init(struct mbox_context *context);
38void protocol_free(struct mbox_context *context);
39
40int protocol_negotiate_version(struct mbox_context *context, uint8_t requested);
41
42/* Protocol v1 */
43int protocol_v1_get_info(struct mbox_context *context,
44 struct protocol_get_info *io);
45
46/* Protocol v2 */
47int protocol_v2_get_info(struct mbox_context *context,
48 struct protocol_get_info *io);
49
50#endif /* PROTOCOL_H */