hosts.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #ifndef _IEEE1394_HOSTS_H
  2. #define _IEEE1394_HOSTS_H
  3. #include <linux/device.h>
  4. #include <linux/wait.h>
  5. #include <linux/list.h>
  6. #include <linux/timer.h>
  7. #include <linux/skbuff.h>
  8. #include <asm/semaphore.h>
  9. #include "ieee1394_types.h"
  10. #include "csr.h"
  11. struct hpsb_packet;
  12. struct hpsb_iso;
  13. struct hpsb_host {
  14. struct list_head host_list;
  15. void *hostdata;
  16. atomic_t generation;
  17. struct sk_buff_head pending_packet_queue;
  18. struct timer_list timeout;
  19. unsigned long timeout_interval;
  20. unsigned char iso_listen_count[64];
  21. int node_count; /* number of identified nodes on this bus */
  22. int selfid_count; /* total number of SelfIDs received */
  23. int nodes_active; /* number of nodes that are actually active */
  24. nodeid_t node_id; /* node ID of this host */
  25. nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
  26. nodeid_t busmgr_id; /* ID of this bus' bus manager */
  27. /* this nodes state */
  28. unsigned in_bus_reset:1;
  29. unsigned is_shutdown:1;
  30. /* this nodes' duties on the bus */
  31. unsigned is_root:1;
  32. unsigned is_cycmst:1;
  33. unsigned is_irm:1;
  34. unsigned is_busmgr:1;
  35. int reset_retries;
  36. quadlet_t *topology_map;
  37. u8 *speed_map;
  38. struct csr_control csr;
  39. /* Per node tlabel pool allocation */
  40. struct hpsb_tlabel_pool tpool[64];
  41. struct hpsb_host_driver *driver;
  42. struct pci_dev *pdev;
  43. int id;
  44. struct device device;
  45. struct class_device class_dev;
  46. int update_config_rom;
  47. struct work_struct delayed_reset;
  48. unsigned int config_roms;
  49. struct list_head addr_space;
  50. };
  51. enum devctl_cmd {
  52. /* Host is requested to reset its bus and cancel all outstanding async
  53. * requests. If arg == 1, it shall also attempt to become root on the
  54. * bus. Return void. */
  55. RESET_BUS,
  56. /* Arg is void, return value is the hardware cycle counter value. */
  57. GET_CYCLE_COUNTER,
  58. /* Set the hardware cycle counter to the value in arg, return void.
  59. * FIXME - setting is probably not required. */
  60. SET_CYCLE_COUNTER,
  61. /* Configure hardware for new bus ID in arg, return void. */
  62. SET_BUS_ID,
  63. /* If arg true, start sending cycle start packets, stop if arg == 0.
  64. * Return void. */
  65. ACT_CYCLE_MASTER,
  66. /* Cancel all outstanding async requests without resetting the bus.
  67. * Return void. */
  68. CANCEL_REQUESTS,
  69. /* Start or stop receiving isochronous channel in arg. Return void.
  70. * This acts as an optimization hint, hosts are not required not to
  71. * listen on unrequested channels. */
  72. ISO_LISTEN_CHANNEL,
  73. ISO_UNLISTEN_CHANNEL
  74. };
  75. enum isoctl_cmd {
  76. /* rawiso API - see iso.h for the meanings of these commands
  77. (they correspond exactly to the hpsb_iso_* API functions)
  78. * INIT = allocate resources
  79. * START = begin transmission/reception
  80. * STOP = halt transmission/reception
  81. * QUEUE/RELEASE = produce/consume packets
  82. * SHUTDOWN = deallocate resources
  83. */
  84. XMIT_INIT,
  85. XMIT_START,
  86. XMIT_STOP,
  87. XMIT_QUEUE,
  88. XMIT_SHUTDOWN,
  89. RECV_INIT,
  90. RECV_LISTEN_CHANNEL, /* multi-channel only */
  91. RECV_UNLISTEN_CHANNEL, /* multi-channel only */
  92. RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */
  93. RECV_START,
  94. RECV_STOP,
  95. RECV_RELEASE,
  96. RECV_SHUTDOWN,
  97. RECV_FLUSH
  98. };
  99. enum reset_types {
  100. /* 166 microsecond reset -- only type of reset available on
  101. non-1394a capable IEEE 1394 controllers */
  102. LONG_RESET,
  103. /* Short (arbitrated) reset -- only available on 1394a capable
  104. IEEE 1394 capable controllers */
  105. SHORT_RESET,
  106. /* Variants, that set force_root before issueing the bus reset */
  107. LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
  108. /* Variants, that clear force_root before issueing the bus reset */
  109. LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
  110. };
  111. struct hpsb_host_driver {
  112. struct module *owner;
  113. const char *name;
  114. /* The hardware driver may optionally support a function that is used
  115. * to set the hardware ConfigROM if the hardware supports handling
  116. * reads to the ConfigROM on its own. */
  117. void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom);
  118. /* This function shall implement packet transmission based on
  119. * packet->type. It shall CRC both parts of the packet (unless
  120. * packet->type == raw) and do byte-swapping as necessary or instruct
  121. * the hardware to do so. It can return immediately after the packet
  122. * was queued for sending. After sending, hpsb_sent_packet() has to be
  123. * called. Return 0 on success, negative errno on failure.
  124. * NOTE: The function must be callable in interrupt context.
  125. */
  126. int (*transmit_packet) (struct hpsb_host *host,
  127. struct hpsb_packet *packet);
  128. /* This function requests miscellanous services from the driver, see
  129. * above for command codes and expected actions. Return -1 for unknown
  130. * command, though that should never happen.
  131. */
  132. int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
  133. /* ISO transmission/reception functions. Return 0 on success, -1
  134. * (or -EXXX errno code) on failure. If the low-level driver does not
  135. * support the new ISO API, set isoctl to NULL.
  136. */
  137. int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg);
  138. /* This function is mainly to redirect local CSR reads/locks to the iso
  139. * management registers (bus manager id, bandwidth available, channels
  140. * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
  141. * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
  142. * as OHCI uses). data and compare are the new data and expected data
  143. * respectively, return value is the old value.
  144. */
  145. quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
  146. quadlet_t data, quadlet_t compare);
  147. };
  148. struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
  149. struct device *dev);
  150. int hpsb_add_host(struct hpsb_host *host);
  151. void hpsb_remove_host(struct hpsb_host *h);
  152. /* The following 2 functions are deprecated and will be removed when the
  153. * raw1394/libraw1394 update is complete. */
  154. int hpsb_update_config_rom(struct hpsb_host *host,
  155. const quadlet_t *new_rom, size_t size, unsigned char rom_version);
  156. int hpsb_get_config_rom(struct hpsb_host *host, quadlet_t *buffer,
  157. size_t buffersize, size_t *rom_size, unsigned char *rom_version);
  158. /* Updates the configuration rom image of a host. rom_version must be the
  159. * current version, otherwise it will fail with return value -1. If this
  160. * host does not support config-rom-update, it will return -EINVAL.
  161. * Return value 0 indicates success.
  162. */
  163. int hpsb_update_config_rom_image(struct hpsb_host *host);
  164. #endif /* _IEEE1394_HOSTS_H */