fw-topology.h 2.2 KB

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