xref: /openbmc/qemu/hw/net/rocker/rocker_world.h (revision 0b2ff2ce)
1 /*
2  * QEMU rocker switch emulation - switch worlds
3  *
4  * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  */
16 
17 #ifndef _ROCKER_WORLD_H_
18 #define _ROCKER_WORLD_H_
19 
20 #include "rocker_hw.h"
21 
22 enum rocker_world_type {
23     ROCKER_WORLD_TYPE_OF_DPA = ROCKER_PORT_MODE_OF_DPA,
24     ROCKER_WORLD_TYPE_MAX,
25 };
26 
27 typedef int (world_init)(World *world);
28 typedef void (world_uninit)(World *world);
29 typedef ssize_t (world_ig)(World *world, uint32_t pport,
30                            const struct iovec *iov, int iovcnt);
31 typedef int (world_cmd)(World *world, DescInfo *info,
32                         char *buf, uint16_t cmd,
33                         RockerTlv *cmd_info_tlv);
34 
35 typedef struct world_ops {
36     world_init *init;
37     world_uninit *uninit;
38     world_ig *ig;
39     world_cmd *cmd;
40 } WorldOps;
41 
42 ssize_t world_ingress(World *world, uint32_t pport,
43                       const struct iovec *iov, int iovcnt);
44 int world_do_cmd(World *world, DescInfo *info,
45                  char *buf, uint16_t cmd, RockerTlv *cmd_info_tlv);
46 
47 World *world_alloc(Rocker *r, size_t sizeof_private,
48                    enum rocker_world_type type, WorldOps *ops);
49 void world_free(World *world);
50 void world_reset(World *world);
51 
52 void *world_private(World *world);
53 Rocker *world_rocker(World *world);
54 
55 enum rocker_world_type world_type(World *world);
56 const char *world_name(World *world);
57 
58 World *rocker_get_world(Rocker *r, enum rocker_world_type type);
59 
60 #endif /* _ROCKER_WORLD_H_ */
61