nodemgr.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (C) 2000 Andreas E. Bombe
  3. * 2001 Ben Collins <bcollins@debian.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software Foundation,
  17. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. #ifndef _IEEE1394_NODEMGR_H
  20. #define _IEEE1394_NODEMGR_H
  21. #include <linux/device.h>
  22. #include <asm/system.h>
  23. #include <asm/types.h>
  24. #include "ieee1394_core.h"
  25. #include "ieee1394_transactions.h"
  26. #include "ieee1394_types.h"
  27. struct csr1212_csr;
  28. struct csr1212_keyval;
  29. struct hpsb_host;
  30. struct ieee1394_device_id;
  31. /* This is the start of a Node entry structure. It should be a stable API
  32. * for which to gather info from the Node Manager about devices attached
  33. * to the bus. */
  34. struct bus_options {
  35. u8 irmc; /* Iso Resource Manager Capable */
  36. u8 cmc; /* Cycle Master Capable */
  37. u8 isc; /* Iso Capable */
  38. u8 bmc; /* Bus Master Capable */
  39. u8 pmc; /* Power Manager Capable (PNP spec) */
  40. u8 cyc_clk_acc; /* Cycle clock accuracy */
  41. u8 max_rom; /* Maximum block read supported in the CSR */
  42. u8 generation; /* Incremented when configrom changes */
  43. u8 lnkspd; /* Link speed */
  44. u16 max_rec; /* Maximum packet size node can receive */
  45. };
  46. #define UNIT_DIRECTORY_VENDOR_ID 0x01
  47. #define UNIT_DIRECTORY_MODEL_ID 0x02
  48. #define UNIT_DIRECTORY_SPECIFIER_ID 0x04
  49. #define UNIT_DIRECTORY_VERSION 0x08
  50. #define UNIT_DIRECTORY_HAS_LUN_DIRECTORY 0x10
  51. #define UNIT_DIRECTORY_LUN_DIRECTORY 0x20
  52. #define UNIT_DIRECTORY_HAS_LUN 0x40
  53. /*
  54. * A unit directory corresponds to a protocol supported by the
  55. * node. If a node supports eg. IP/1394 and AV/C, its config rom has a
  56. * unit directory for each of these protocols.
  57. */
  58. struct unit_directory {
  59. struct node_entry *ne; /* The node which this directory belongs to */
  60. octlet_t address; /* Address of the unit directory on the node */
  61. u8 flags; /* Indicates which entries were read */
  62. quadlet_t vendor_id;
  63. struct csr1212_keyval *vendor_name_kv;
  64. quadlet_t model_id;
  65. struct csr1212_keyval *model_name_kv;
  66. quadlet_t specifier_id;
  67. quadlet_t version;
  68. quadlet_t directory_id;
  69. unsigned int id;
  70. int ignore_driver;
  71. int length; /* Number of quadlets */
  72. struct device device;
  73. struct device unit_dev;
  74. struct csr1212_keyval *ud_kv;
  75. u32 lun; /* logical unit number immediate value */
  76. };
  77. struct node_entry {
  78. u64 guid; /* GUID of this node */
  79. u32 guid_vendor_id; /* Top 24bits of guid */
  80. struct hpsb_host *host; /* Host this node is attached to */
  81. nodeid_t nodeid; /* NodeID */
  82. struct bus_options busopt; /* Bus Options */
  83. bool needs_probe;
  84. unsigned int generation; /* Synced with hpsb generation */
  85. /* The following is read from the config rom */
  86. u32 vendor_id;
  87. struct csr1212_keyval *vendor_name_kv;
  88. u32 capabilities;
  89. struct device device;
  90. struct device node_dev;
  91. /* Means this node is not attached anymore */
  92. bool in_limbo;
  93. struct csr1212_csr *csr;
  94. };
  95. struct hpsb_protocol_driver {
  96. /* The name of the driver, e.g. SBP2 or IP1394 */
  97. const char *name;
  98. /*
  99. * The device id table describing the protocols and/or devices
  100. * supported by this driver. This is used by the nodemgr to
  101. * decide if a driver could support a given node, but the
  102. * probe function below can implement further protocol
  103. * dependent or vendor dependent checking.
  104. */
  105. const struct ieee1394_device_id *id_table;
  106. /*
  107. * The update function is called when the node has just
  108. * survived a bus reset, i.e. it is still present on the bus.
  109. * However, it may be necessary to reestablish the connection
  110. * or login into the node again, depending on the protocol. If the
  111. * probe fails (returns non-zero), we unbind the driver from this
  112. * device.
  113. */
  114. int (*update)(struct unit_directory *ud);
  115. /* Our LDM structure */
  116. struct device_driver driver;
  117. };
  118. int __hpsb_register_protocol(struct hpsb_protocol_driver *, struct module *);
  119. static inline int hpsb_register_protocol(struct hpsb_protocol_driver *driver)
  120. {
  121. return __hpsb_register_protocol(driver, THIS_MODULE);
  122. }
  123. void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver);
  124. static inline int hpsb_node_entry_valid(struct node_entry *ne)
  125. {
  126. return ne->generation == get_hpsb_generation(ne->host);
  127. }
  128. void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *packet);
  129. int hpsb_node_write(struct node_entry *ne, u64 addr,
  130. quadlet_t *buffer, size_t length);
  131. static inline int hpsb_node_read(struct node_entry *ne, u64 addr,
  132. quadlet_t *buffer, size_t length)
  133. {
  134. unsigned int g = ne->generation;
  135. smp_rmb();
  136. return hpsb_read(ne->host, ne->nodeid, g, addr, buffer, length);
  137. }
  138. static inline int hpsb_node_lock(struct node_entry *ne, u64 addr, int extcode,
  139. quadlet_t *buffer, quadlet_t arg)
  140. {
  141. unsigned int g = ne->generation;
  142. smp_rmb();
  143. return hpsb_lock(ne->host, ne->nodeid, g, addr, extcode, buffer, arg);
  144. }
  145. int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *));
  146. int init_ieee1394_nodemgr(void);
  147. void cleanup_ieee1394_nodemgr(void);
  148. /* The template for a host device */
  149. extern struct device nodemgr_dev_template_host;
  150. /* Bus attributes we export */
  151. extern struct bus_attribute *const fw_bus_attrs[];
  152. #endif /* _IEEE1394_NODEMGR_H */