rocker_world.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef ROCKER_WORLD_H
  17. #define ROCKER_WORLD_H
  18. #include "rocker_hw.h"
  19. enum rocker_world_type {
  20. ROCKER_WORLD_TYPE_OF_DPA = ROCKER_PORT_MODE_OF_DPA,
  21. ROCKER_WORLD_TYPE_MAX,
  22. };
  23. typedef int (world_init)(World *world);
  24. typedef void (world_uninit)(World *world);
  25. typedef ssize_t (world_ig)(World *world, uint32_t pport,
  26. const struct iovec *iov, int iovcnt);
  27. typedef int (world_cmd)(World *world, DescInfo *info,
  28. char *buf, uint16_t cmd,
  29. RockerTlv *cmd_info_tlv);
  30. typedef struct world_ops {
  31. const char *name;
  32. world_init *init;
  33. world_uninit *uninit;
  34. world_ig *ig;
  35. world_cmd *cmd;
  36. } WorldOps;
  37. ssize_t world_ingress(World *world, uint32_t pport,
  38. const struct iovec *iov, int iovcnt);
  39. int world_do_cmd(World *world, DescInfo *info,
  40. char *buf, uint16_t cmd, RockerTlv *cmd_info_tlv);
  41. World *world_alloc(Rocker *r, size_t sizeof_private,
  42. enum rocker_world_type type, WorldOps *ops);
  43. void world_free(World *world);
  44. void world_reset(World *world);
  45. void *world_private(World *world);
  46. Rocker *world_rocker(World *world);
  47. enum rocker_world_type world_type(World *world);
  48. const char *world_name(World *world);
  49. World *rocker_get_world(Rocker *r, enum rocker_world_type type);
  50. #endif /* ROCKER_WORLD_H */