2 #ifndef _IEEE1394_HOSTS_H
3 #define _IEEE1394_HOSTS_H
5 #include <linux/wait.h>
6 #include <linux/tqueue.h>
8 #include "ieee1394_types.h"
15 /* private fields (hosts, do not use them) */
16 struct hpsb_host
*next
;
18 struct list_head pending_packets
;
19 spinlock_t pending_pkt_lock
;
20 struct tq_struct timeout_tq
;
22 /* A bitmask where a set bit means that this tlabel is in use.
23 * FIXME - should be handled per node instead of per bus. */
26 spinlock_t tlabel_lock
;
27 wait_queue_head_t tlabel_wait
;
30 quadlet_t
*topology_map
;
32 struct csr_control csr
;
34 unsigned char iso_listen_count
[64];
36 /* readonly fields for hosts */
37 struct hpsb_host_template
*template;
39 int node_count
; /* number of identified nodes on this bus */
40 int selfid_count
; /* total number of SelfIDs received */
42 nodeid_t node_id
; /* node ID of this host */
43 nodeid_t irm_id
; /* ID of this bus' isochronous resource manager */
44 nodeid_t busmgr_id
; /* ID of this bus' bus manager */
46 unsigned initialized
:1; /* initialized and usable */
47 unsigned in_bus_reset
:1; /* in bus reset / SelfID stage */
48 unsigned attempt_root
:1; /* attempt to become root during next reset */
50 /* this nodes' duties on the bus */
56 /* fields readable and writeable by the hosts */
59 int embedded_hostdata
[0];
65 /* Host is requested to reset its bus and cancel all outstanding async
66 * requests. If arg == 1, it shall also attempt to become root on the
67 * bus. Return void. */
70 /* Arg is void, return value is the hardware cycle counter value. */
73 /* Set the hardware cycle counter to the value in arg, return void.
74 * FIXME - setting is probably not required. */
77 /* Configure hardware for new bus ID in arg, return void. */
80 /* If arg true, start sending cycle start packets, stop if arg == 0.
84 /* Cancel all outstanding async requests without resetting the bus.
88 /* Decrease module usage count if arg == 0, increase otherwise. Return
92 /* Start or stop receiving isochronous channel in arg. Return void.
93 * This acts as an optimization hint, hosts are not required not to
94 * listen on unrequested channels. */
99 struct hpsb_host_template
{
100 struct hpsb_host_template
*next
;
102 struct hpsb_host
*hosts
;
105 /* fields above will be ignored and overwritten after registering */
107 /* This should be the name of the driver (single word) and must not be
111 /* This function shall detect all available adapters of this type and
112 * call hpsb_get_host for each one. The initialize_host function will
113 * be called to actually set up these adapters. The number of detected
114 * adapters or zero if there are none must be returned.
116 int (*detect_hosts
) (struct hpsb_host_template
*template);
118 /* After detecting and registering hosts, this function will be called
119 * for every registered host. It shall set up the host to be fully
120 * functional for bus operations and return 0 for failure.
122 int (*initialize_host
) (struct hpsb_host
*host
);
124 /* To unload modules, this function is provided. It shall free all
125 * resources this host is using (if host is not NULL) or free all
126 * resources globally allocated by the driver (if host is NULL).
128 void (*release_host
) (struct hpsb_host
*host
);
130 /* This function must store a pointer to the configuration ROM into the
131 * location referenced to by pointer and return the size of the ROM. It
132 * may not fail. If any allocation is required, it must be done
135 size_t (*get_rom
) (struct hpsb_host
*host
, const quadlet_t
**pointer
);
137 /* This function shall implement packet transmission based on
138 * packet->type. It shall CRC both parts of the packet (unless
139 * packet->type == raw) and do byte-swapping as necessary or instruct
140 * the hardware to do so. It can return immediately after the packet
141 * was queued for sending. After sending, hpsb_sent_packet() has to be
142 * called. Return 0 for failure.
143 * NOTE: The function must be callable in interrupt context.
145 int (*transmit_packet
) (struct hpsb_host
*host
,
146 struct hpsb_packet
*packet
);
148 /* This function requests miscellanous services from the driver, see
149 * above for command codes and expected actions. Return -1 for unknown
150 * command, though that should never happen.
152 int (*devctl
) (struct hpsb_host
*host
, enum devctl_cmd command
, int arg
);
157 /* mid level internal use */
158 void register_builtin_lowlevels(void);
160 /* high level internal use */
161 struct hpsb_highlevel
;
162 void hl_all_hosts(struct hpsb_highlevel
*hl
, int init
);
165 * These functions are for lowlevel (host) driver use.
167 int hpsb_register_lowlevel(struct hpsb_host_template
*tmpl
);
168 void hpsb_unregister_lowlevel(struct hpsb_host_template
*tmpl
);
171 * Get a initialized host structure with hostdata_size bytes allocated in
172 * embedded_hostdata for free usage. Returns NULL for failure.
174 struct hpsb_host
*hpsb_get_host(struct hpsb_host_template
*tmpl
,
175 size_t hostdata_size
);
178 * Increase / decrease host usage counter. Increase function will return true
179 * only if successful (host still existed). Decrease function expects host to
182 int hpsb_inc_host_usage(struct hpsb_host
*host
);
183 void hpsb_dec_host_usage(struct hpsb_host
*host
);
185 #endif /* _IEEE1394_HOSTS_H */