rio.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 int rio_create_sysfs_dev_files(struct rio_dev *rdev);
  19. extern int rio_enum_mport(struct rio_mport *mport);
  20. extern int rio_disc_mport(struct rio_mport *mport);
  21. /* Structures internal to the RIO core code */
  22. extern struct device_attribute rio_dev_attrs[];
  23. extern spinlock_t rio_global_list_lock;
  24. extern struct rio_route_ops __start_rio_route_ops[];
  25. extern struct rio_route_ops __end_rio_route_ops[];
  26. /* Helpers internal to the RIO core code */
  27. #define DECLARE_RIO_ROUTE_SECTION(section, vid, did, add_hook, get_hook) \
  28. static struct rio_route_ops __rio_route_ops __attribute_used__ \
  29. __attribute__((__section__(#section))) = { vid, did, add_hook, get_hook };
  30. /**
  31. * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations
  32. * @vid: RIO vendor ID
  33. * @did: RIO device ID
  34. * @add_hook: Callback that adds a route entry
  35. * @get_hook: Callback that gets a route entry
  36. *
  37. * Manipulating switch route tables in RIO is switch specific. This
  38. * registers a switch by vendor and device ID with two callbacks for
  39. * modifying and retrieving route entries in a switch. A &struct
  40. * rio_route_ops is initialized with the ops and placed into a
  41. * RIO-specific kernel section.
  42. */
  43. #define DECLARE_RIO_ROUTE_OPS(vid, did, add_hook, get_hook) \
  44. DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, \
  45. vid, did, add_hook, get_hook)
  46. #ifdef CONFIG_RAPIDIO_8_BIT_TRANSPORT
  47. #define RIO_GET_DID(x) ((x & 0x00ff0000) >> 16)
  48. #define RIO_SET_DID(x) ((x & 0x000000ff) << 16)
  49. #else
  50. #define RIO_GET_DID(x) (x & 0xffff)
  51. #define RIO_SET_DID(x) (x & 0xffff)
  52. #endif