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