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