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