blob: d7827c05b65ba9495dfc828aa575026ddc0ddfb9 [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 {
Andrew Jefferyab666a52018-08-07 14:28:09 +093033 int (*reset)(struct mbox_context *context);
Andrew Jeffery1e531af2018-08-07 13:32:57 +093034 int (*get_info)(struct mbox_context *context,
35 struct protocol_get_info *io);
36};
37
38int protocol_init(struct mbox_context *context);
39void protocol_free(struct mbox_context *context);
40
41int protocol_negotiate_version(struct mbox_context *context, uint8_t requested);
42
43/* Protocol v1 */
Andrew Jefferyab666a52018-08-07 14:28:09 +093044int protocol_v1_reset(struct mbox_context *context);
Andrew Jeffery1e531af2018-08-07 13:32:57 +093045int protocol_v1_get_info(struct mbox_context *context,
46 struct protocol_get_info *io);
47
48/* Protocol v2 */
49int protocol_v2_get_info(struct mbox_context *context,
50 struct protocol_get_info *io);
51
52#endif /* PROTOCOL_H */