fw-topology.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* -*- c-basic-offset: 8 -*-
  2. *
  3. * fw-topology.h -- Incremental bus scan, based on bus topology
  4. *
  5. * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software Foundation,
  19. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __fw_topology_h
  22. #define __fw_topology_h
  23. enum {
  24. FW_TOPOLOGY_A = 0x01,
  25. FW_TOPOLOGY_B = 0x02,
  26. FW_TOPOLOGY_MIXED = 0x03,
  27. };
  28. enum {
  29. FW_NODE_CREATED = 0x00,
  30. FW_NODE_UPDATED = 0x01,
  31. FW_NODE_DESTROYED = 0x02,
  32. FW_NODE_LINK_ON = 0x03,
  33. FW_NODE_LINK_OFF = 0x04,
  34. };
  35. struct fw_port {
  36. struct fw_node *node;
  37. unsigned speed : 3; /* S100, S200, ... S3200 */
  38. };
  39. struct fw_node {
  40. u16 node_id;
  41. u8 color;
  42. u8 port_count;
  43. unsigned link_on : 1;
  44. unsigned initiated_reset : 1;
  45. unsigned b_path : 1;
  46. u8 phy_speed : 3; /* As in the self ID packet. */
  47. u8 max_speed : 5; /* Minimum of all phy-speeds and port speeds on
  48. * the path from the local node to this node. */
  49. u8 max_depth : 4; /* Maximum depth to any leaf node */
  50. u8 max_hops : 4; /* Max hops in this sub tree */
  51. atomic_t ref_count;
  52. /* For serializing node topology into a list. */
  53. struct list_head link;
  54. /* Upper layer specific data. */
  55. void *data;
  56. struct fw_port ports[0];
  57. };
  58. static inline struct fw_node *
  59. fw_node(struct list_head *l)
  60. {
  61. return list_entry (l, struct fw_node, link);
  62. }
  63. static inline struct fw_node *
  64. fw_node_get(struct fw_node *node)
  65. {
  66. atomic_inc(&node->ref_count);
  67. return node;
  68. }
  69. static inline void
  70. fw_node_put(struct fw_node *node)
  71. {
  72. if (atomic_dec_and_test(&node->ref_count))
  73. kfree(node);
  74. }
  75. void
  76. fw_destroy_nodes(struct fw_card *card);
  77. u16
  78. crc16_itu_t(const u32 *buffer, size_t length);
  79. #endif /* __fw_topology_h */