fw-topology.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_NODE_CREATED = 0x00,
  22. FW_NODE_UPDATED = 0x01,
  23. FW_NODE_DESTROYED = 0x02,
  24. FW_NODE_LINK_ON = 0x03,
  25. FW_NODE_LINK_OFF = 0x04,
  26. };
  27. struct fw_port {
  28. struct fw_node *node;
  29. };
  30. struct fw_node {
  31. u16 node_id;
  32. u8 color;
  33. u8 port_count;
  34. u8 link_on : 1;
  35. u8 initiated_reset : 1;
  36. u8 b_path : 1;
  37. u8 phy_speed : 2; /* As in the self ID packet. */
  38. u8 max_speed : 2; /* Minimum of all phy-speeds on the path from the
  39. * local node to this node. */
  40. u8 max_depth : 4; /* Maximum depth to any leaf node */
  41. u8 max_hops : 4; /* Max hops in this sub tree */
  42. atomic_t ref_count;
  43. /* For serializing node topology into a list. */
  44. struct list_head link;
  45. /* Upper layer specific data. */
  46. void *data;
  47. struct fw_port ports[0];
  48. };
  49. static inline struct fw_node *
  50. fw_node(struct list_head *l)
  51. {
  52. return list_entry(l, struct fw_node, link);
  53. }
  54. static inline struct fw_node *
  55. fw_node_get(struct fw_node *node)
  56. {
  57. atomic_inc(&node->ref_count);
  58. return node;
  59. }
  60. static inline void
  61. fw_node_put(struct fw_node *node)
  62. {
  63. if (atomic_dec_and_test(&node->ref_count))
  64. kfree(node);
  65. }
  66. void
  67. fw_destroy_nodes(struct fw_card *card);
  68. int
  69. fw_compute_block_crc(u32 *block);
  70. #endif /* __fw_topology_h */