rio.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * RapidIO interconnect services
  3. *
  4. * Copyright 2005 MontaVista Software, Inc.
  5. * Matt Porter <mporter@kernel.crashing.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/device.h>
  13. #include <linux/list.h>
  14. #include <linux/rio.h>
  15. /* Functions internal to the RIO core code */
  16. extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
  17. u8 hopcount, int ftr);
  18. extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
  19. u16 destid, u8 hopcount);
  20. extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
  21. u8 hopcount, u32 from);
  22. extern int rio_create_sysfs_dev_files(struct rio_dev *rdev);
  23. extern int rio_enum_mport(struct rio_mport *mport);
  24. extern int rio_disc_mport(struct rio_mport *mport);
  25. extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid,
  26. u8 hopcount, u16 table, u16 route_destid,
  27. u8 route_port);
  28. extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid,
  29. u8 hopcount, u16 table, u16 route_destid,
  30. u8 *route_port);
  31. extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid,
  32. u8 hopcount, u16 table);
  33. extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
  34. /* Structures internal to the RIO core code */
  35. extern struct device_attribute rio_dev_attrs[];
  36. extern spinlock_t rio_global_list_lock;
  37. extern struct rio_route_ops __start_rio_route_ops[];
  38. extern struct rio_route_ops __end_rio_route_ops[];
  39. /* Helpers internal to the RIO core code */
  40. #define DECLARE_RIO_ROUTE_SECTION(section, name, vid, did, add_hook, get_hook, clr_hook) \
  41. static const struct rio_route_ops __rio_route_##name __used \
  42. __section(section) = { vid, did, add_hook, get_hook, clr_hook };
  43. /**
  44. * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations
  45. * @vid: RIO vendor ID
  46. * @did: RIO device ID
  47. * @add_hook: Callback that adds a route entry
  48. * @get_hook: Callback that gets a route entry
  49. *
  50. * Manipulating switch route tables in RIO is switch specific. This
  51. * registers a switch by vendor and device ID with two callbacks for
  52. * modifying and retrieving route entries in a switch. A &struct
  53. * rio_route_ops is initialized with the ops and placed into a
  54. * RIO-specific kernel section.
  55. */
  56. #define DECLARE_RIO_ROUTE_OPS(vid, did, add_hook, get_hook, clr_hook) \
  57. DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, vid##did, \
  58. vid, did, add_hook, get_hook, clr_hook)
  59. #define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
  60. #define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
  61. /*
  62. * RapidIO Error Management
  63. */
  64. extern struct rio_em_ops __start_rio_em_ops[];
  65. extern struct rio_em_ops __end_rio_em_ops[];
  66. /* Helpers internal to the RIO core code */
  67. #define DECLARE_RIO_EM_SECTION(section, name, vid, did, init_hook, em_hook) \
  68. static const struct rio_em_ops __rio_em_##name __used \
  69. __section(section) = { vid, did, init_hook, em_hook };
  70. /**
  71. * DECLARE_RIO_EM_OPS - Registers switch EM operations
  72. * @vid: RIO vendor ID
  73. * @did: RIO device ID
  74. * @init_hook: Callback that initializes device specific EM
  75. * @em_hook: Callback that handles device specific EM
  76. *
  77. * A &struct rio_em_ops is initialized with the ops and placed into a
  78. * RIO-specific kernel section.
  79. */
  80. #define DECLARE_RIO_EM_OPS(vid, did, init_hook, em_hook) \
  81. DECLARE_RIO_EM_SECTION(.rio_em_ops, vid##did, \
  82. vid, did, init_hook, em_hook)