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