blob: ee45259573c8b3c9450637e07047bb5f58ab9d2b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * IEEE 1394 for Linux
3 *
4 * Core support: hpsb_packet management, packet handling and forwarding to
5 * highlevel or lowlevel code
6 *
7 * Copyright (C) 1999, 2000 Andreas E. Bombe
8 * 2002 Manfred Weihs <weihs@ict.tuwien.ac.at>
9 *
10 * This code is licensed under the GPL. See the file COPYING in the root
11 * directory of the kernel sources for details.
12 *
13 *
14 * Contributions:
15 *
16 * Manfred Weihs <weihs@ict.tuwien.ac.at>
17 * loopback functionality in hpsb_send_packet
18 * allow highlevel drivers to disable automatic response generation
19 * and to generate responses themselves (deferred)
20 *
21 */
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/kernel.h>
24#include <linux/list.h>
25#include <linux/string.h>
26#include <linux/init.h>
27#include <linux/slab.h>
28#include <linux/interrupt.h>
29#include <linux/module.h>
30#include <linux/moduleparam.h>
31#include <linux/bitops.h>
32#include <linux/kdev_t.h>
Rafael J. Wysocki83144182007-07-17 04:03:35 -070033#include <linux/freezer.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/suspend.h>
Ben Collinsf6542402006-06-12 18:15:50 -040035#include <linux/kthread.h>
Pieter Palmers3dc5ea92007-02-03 17:44:39 +010036#include <linux/preempt.h>
37#include <linux/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Pieter Palmers3dc5ea92007-02-03 17:44:39 +010039#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <asm/byteorder.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
42#include "ieee1394_types.h"
43#include "ieee1394.h"
44#include "hosts.h"
45#include "ieee1394_core.h"
46#include "highlevel.h"
47#include "ieee1394_transactions.h"
48#include "csr.h"
49#include "nodemgr.h"
50#include "dma.h"
51#include "iso.h"
52#include "config_roms.h"
53
54/*
55 * Disable the nodemgr detection and config rom reading functionality.
56 */
Ben Collins1934b8b2005-07-09 20:01:23 -040057static int disable_nodemgr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058module_param(disable_nodemgr, int, 0444);
59MODULE_PARM_DESC(disable_nodemgr, "Disable nodemgr functionality.");
60
61/* Disable Isochronous Resource Manager functionality */
62int hpsb_disable_irm = 0;
Stefan Richter23e93f12006-03-28 20:03:34 -050063module_param_named(disable_irm, hpsb_disable_irm, bool, 0444);
Linus Torvalds1da177e2005-04-16 15:20:36 -070064MODULE_PARM_DESC(disable_irm,
65 "Disable Isochronous Resource Manager functionality.");
66
67/* We are GPL, so treat us special */
68MODULE_LICENSE("GPL");
69
70/* Some globals used */
71const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S3200" };
gregkh@suse.de7e25ab92005-03-23 09:53:36 -080072struct class *hpsb_protocol_class;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
Jody McIntyredb2fd662005-09-30 11:59:09 -070075static void dump_packet(const char *text, quadlet_t *data, int size, int speed)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
77 int i;
78
79 size /= 4;
80 size = (size > 4 ? 4 : size);
81
82 printk(KERN_DEBUG "ieee1394: %s", text);
Jody McIntyredb2fd662005-09-30 11:59:09 -070083 if (speed > -1 && speed < 6)
84 printk(" at %s", hpsb_speedto_str[speed]);
85 printk(":");
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 for (i = 0; i < size; i++)
87 printk(" %08x", data[i]);
88 printk("\n");
89}
90#else
Stefan Richter611aa192006-08-02 18:44:00 +020091#define dump_packet(a,b,c,d) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif
93
94static void abort_requests(struct hpsb_host *host);
95static void queue_packet_complete(struct hpsb_packet *packet);
96
97
98/**
Stefan Richterafd65462007-03-05 03:06:23 +010099 * hpsb_set_packet_complete_task - set task that runs when a packet completes
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 * @packet: the packet whose completion we want the task added to
101 * @routine: function to call
102 * @data: data (if any) to pass to the above function
Stefan Richterafd65462007-03-05 03:06:23 +0100103 *
104 * Set the task that runs when a packet completes. You cannot call this more
105 * than once on a single packet before it is sent.
Stefan Richter7542e0e2007-03-25 22:22:40 +0200106 *
107 * Typically, the complete @routine is responsible to call hpsb_free_packet().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 */
109void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
110 void (*routine)(void *), void *data)
111{
112 WARN_ON(packet->complete_routine != NULL);
113 packet->complete_routine = routine;
114 packet->complete_data = data;
115 return;
116}
117
118/**
119 * hpsb_alloc_packet - allocate new packet structure
Stefan Richter7542e0e2007-03-25 22:22:40 +0200120 * @data_size: size of the data block to be allocated, in bytes
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 *
122 * This function allocates, initializes and returns a new &struct hpsb_packet.
Stefan Richter7542e0e2007-03-25 22:22:40 +0200123 * It can be used in interrupt context. A header block is always included and
124 * initialized with zeros. Its size is big enough to contain all possible 1394
125 * headers. The data block is only allocated if @data_size is not zero.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 *
127 * For packets for which responses will be received the @data_size has to be big
128 * enough to contain the response's data block since no further allocation
129 * occurs at response matching time.
130 *
131 * The packet's generation value will be set to the current generation number
132 * for ease of use. Remember to overwrite it with your own recorded generation
133 * number if you can not be sure that your code will not race with a bus reset.
134 *
135 * Return value: A pointer to a &struct hpsb_packet or NULL on allocation
136 * failure.
137 */
138struct hpsb_packet *hpsb_alloc_packet(size_t data_size)
139{
Stefan Richter7542e0e2007-03-25 22:22:40 +0200140 struct hpsb_packet *packet;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
142 data_size = ((data_size + 3) & ~3);
143
Stefan Richter7542e0e2007-03-25 22:22:40 +0200144 packet = kzalloc(sizeof(*packet) + data_size, GFP_ATOMIC);
145 if (!packet)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 return NULL;
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 packet->state = hpsb_unused;
149 packet->generation = -1;
150 INIT_LIST_HEAD(&packet->driver_list);
Stefan Richter7542e0e2007-03-25 22:22:40 +0200151 INIT_LIST_HEAD(&packet->queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 atomic_set(&packet->refcnt, 1);
153
154 if (data_size) {
Stefan Richter7542e0e2007-03-25 22:22:40 +0200155 packet->data = packet->embedded_data;
156 packet->allocated_data_size = data_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 return packet;
159}
160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161/**
162 * hpsb_free_packet - free packet and data associated with it
163 * @packet: packet to free (is NULL safe)
164 *
Stefan Richter7542e0e2007-03-25 22:22:40 +0200165 * Frees @packet->data only if it was allocated through hpsb_alloc_packet().
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 */
167void hpsb_free_packet(struct hpsb_packet *packet)
168{
169 if (packet && atomic_dec_and_test(&packet->refcnt)) {
Stefan Richter7542e0e2007-03-25 22:22:40 +0200170 BUG_ON(!list_empty(&packet->driver_list) ||
171 !list_empty(&packet->queue));
172 kfree(packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 }
174}
175
Stefan Richterafd65462007-03-05 03:06:23 +0100176/**
177 * hpsb_reset_bus - initiate bus reset on the given host
178 * @host: host controller whose bus to reset
179 * @type: one of enum reset_types
180 *
181 * Returns 1 if bus reset already in progress, 0 otherwise.
182 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183int hpsb_reset_bus(struct hpsb_host *host, int type)
184{
Stefan Richter741854e2005-12-01 18:52:03 -0500185 if (!host->in_bus_reset) {
186 host->driver->devctl(host, RESET_BUS, type);
187 return 0;
188 } else {
189 return 1;
190 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191}
192
Pieter Palmers3dc5ea92007-02-03 17:44:39 +0100193/**
194 * hpsb_read_cycle_timer - read cycle timer register and system time
195 * @host: host whose isochronous cycle timer register is read
196 * @cycle_timer: address of bitfield to return the register contents
197 * @local_time: address to return the system time
198 *
199 * The format of * @cycle_timer, is described in OHCI 1.1 clause 5.13. This
200 * format is also read from non-OHCI controllers. * @local_time contains the
201 * system time in microseconds since the Epoch, read at the moment when the
202 * cycle timer was read.
203 *
204 * Return value: 0 for success or error number otherwise.
205 */
206int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer,
207 u64 *local_time)
208{
209 int ctr;
210 struct timeval tv;
211 unsigned long flags;
212
213 if (!host || !cycle_timer || !local_time)
214 return -EINVAL;
215
216 preempt_disable();
217 local_irq_save(flags);
218
219 ctr = host->driver->devctl(host, GET_CYCLE_COUNTER, 0);
220 if (ctr)
221 do_gettimeofday(&tv);
222
223 local_irq_restore(flags);
224 preempt_enable();
225
226 if (!ctr)
227 return -EIO;
228 *cycle_timer = ctr;
229 *local_time = tv.tv_sec * 1000000ULL + tv.tv_usec;
230 return 0;
231}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
Stefan Richterafd65462007-03-05 03:06:23 +0100233/**
234 * hpsb_bus_reset - notify a bus reset to the core
235 *
236 * For host driver module usage. Safe to use in interrupt context, although
237 * quite complex; so you may want to run it in the bottom rather than top half.
238 *
239 * Returns 1 if bus reset already in progress, 0 otherwise.
240 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241int hpsb_bus_reset(struct hpsb_host *host)
242{
Stefan Richter741854e2005-12-01 18:52:03 -0500243 if (host->in_bus_reset) {
244 HPSB_NOTICE("%s called while bus reset already in progress",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 __FUNCTION__);
Stefan Richter741854e2005-12-01 18:52:03 -0500246 return 1;
247 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248
Stefan Richter741854e2005-12-01 18:52:03 -0500249 abort_requests(host);
250 host->in_bus_reset = 1;
251 host->irm_id = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 host->is_irm = 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500253 host->busmgr_id = -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 host->is_busmgr = 0;
255 host->is_cycmst = 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500256 host->node_count = 0;
257 host->selfid_count = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
Stefan Richter741854e2005-12-01 18:52:03 -0500259 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260}
261
262
263/*
264 * Verify num_of_selfids SelfIDs and return number of nodes. Return zero in
265 * case verification failed.
266 */
267static int check_selfids(struct hpsb_host *host)
268{
Stefan Richter741854e2005-12-01 18:52:03 -0500269 int nodeid = -1;
270 int rest_of_selfids = host->selfid_count;
271 struct selfid *sid = (struct selfid *)host->topology_map;
272 struct ext_selfid *esid;
273 int esid_seq = 23;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
275 host->nodes_active = 0;
276
Stefan Richter741854e2005-12-01 18:52:03 -0500277 while (rest_of_selfids--) {
278 if (!sid->extended) {
279 nodeid++;
280 esid_seq = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Stefan Richter741854e2005-12-01 18:52:03 -0500282 if (sid->phy_id != nodeid) {
283 HPSB_INFO("SelfIDs failed monotony check with "
284 "%d", sid->phy_id);
285 return 0;
286 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288 if (sid->link_active) {
289 host->nodes_active++;
290 if (sid->contender)
291 host->irm_id = LOCAL_BUS | sid->phy_id;
292 }
Stefan Richter741854e2005-12-01 18:52:03 -0500293 } else {
294 esid = (struct ext_selfid *)sid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Stefan Richter741854e2005-12-01 18:52:03 -0500296 if ((esid->phy_id != nodeid)
297 || (esid->seq_nr != esid_seq)) {
298 HPSB_INFO("SelfIDs failed monotony check with "
299 "%d/%d", esid->phy_id, esid->seq_nr);
300 return 0;
301 }
302 esid_seq++;
303 }
304 sid++;
305 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Stefan Richter741854e2005-12-01 18:52:03 -0500307 esid = (struct ext_selfid *)(sid - 1);
308 while (esid->extended) {
309 if ((esid->porta == SELFID_PORT_PARENT) ||
Stefan Richterd7758462005-12-01 18:51:56 -0500310 (esid->portb == SELFID_PORT_PARENT) ||
311 (esid->portc == SELFID_PORT_PARENT) ||
312 (esid->portd == SELFID_PORT_PARENT) ||
313 (esid->porte == SELFID_PORT_PARENT) ||
314 (esid->portf == SELFID_PORT_PARENT) ||
315 (esid->portg == SELFID_PORT_PARENT) ||
316 (esid->porth == SELFID_PORT_PARENT)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 HPSB_INFO("SelfIDs failed root check on "
318 "extended SelfID");
319 return 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500320 }
321 esid--;
322 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
Stefan Richter741854e2005-12-01 18:52:03 -0500324 sid = (struct selfid *)esid;
Stefan Richterd7758462005-12-01 18:51:56 -0500325 if ((sid->port0 == SELFID_PORT_PARENT) ||
326 (sid->port1 == SELFID_PORT_PARENT) ||
327 (sid->port2 == SELFID_PORT_PARENT)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 HPSB_INFO("SelfIDs failed root check");
329 return 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500330 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
332 host->node_count = nodeid + 1;
Stefan Richter741854e2005-12-01 18:52:03 -0500333 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334}
335
336static void build_speed_map(struct hpsb_host *host, int nodecount)
337{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 u8 cldcnt[nodecount];
Stefan Richter741854e2005-12-01 18:52:03 -0500339 u8 *map = host->speed_map;
Ben Collins647dcb52006-06-12 18:12:37 -0400340 u8 *speedcap = host->speed;
Stefan Richter741854e2005-12-01 18:52:03 -0500341 struct selfid *sid;
342 struct ext_selfid *esid;
343 int i, j, n;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
Stefan Richter741854e2005-12-01 18:52:03 -0500345 for (i = 0; i < (nodecount * 64); i += 64) {
346 for (j = 0; j < nodecount; j++) {
347 map[i+j] = IEEE1394_SPEED_MAX;
348 }
349 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
Stefan Richter741854e2005-12-01 18:52:03 -0500351 for (i = 0; i < nodecount; i++) {
352 cldcnt[i] = 0;
353 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
Stefan Richter741854e2005-12-01 18:52:03 -0500355 /* find direct children count and speed */
356 for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1],
357 n = nodecount - 1;
358 (void *)sid >= (void *)host->topology_map; sid--) {
359 if (sid->extended) {
360 esid = (struct ext_selfid *)sid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
Stefan Richterd7758462005-12-01 18:51:56 -0500362 if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++;
363 if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++;
364 if (esid->portc == SELFID_PORT_CHILD) cldcnt[n]++;
365 if (esid->portd == SELFID_PORT_CHILD) cldcnt[n]++;
366 if (esid->porte == SELFID_PORT_CHILD) cldcnt[n]++;
367 if (esid->portf == SELFID_PORT_CHILD) cldcnt[n]++;
368 if (esid->portg == SELFID_PORT_CHILD) cldcnt[n]++;
369 if (esid->porth == SELFID_PORT_CHILD) cldcnt[n]++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 } else {
Stefan Richterd7758462005-12-01 18:51:56 -0500371 if (sid->port0 == SELFID_PORT_CHILD) cldcnt[n]++;
372 if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++;
373 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
Stefan Richter741854e2005-12-01 18:52:03 -0500375 speedcap[n] = sid->speed;
376 n--;
377 }
378 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
Stefan Richter741854e2005-12-01 18:52:03 -0500380 /* set self mapping */
381 for (i = 0; i < nodecount; i++) {
382 map[64*i + i] = speedcap[i];
383 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
Stefan Richter741854e2005-12-01 18:52:03 -0500385 /* fix up direct children count to total children count;
386 * also fix up speedcaps for sibling and parent communication */
387 for (i = 1; i < nodecount; i++) {
388 for (j = cldcnt[i], n = i - 1; j > 0; j--) {
389 cldcnt[i] += cldcnt[n];
390 speedcap[n] = min(speedcap[n], speedcap[i]);
391 n -= cldcnt[n] + 1;
392 }
393 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
Stefan Richter741854e2005-12-01 18:52:03 -0500395 for (n = 0; n < nodecount; n++) {
396 for (i = n - cldcnt[n]; i <= n; i++) {
397 for (j = 0; j < (n - cldcnt[n]); j++) {
398 map[j*64 + i] = map[i*64 + j] =
399 min(map[i*64 + j], speedcap[n]);
400 }
401 for (j = n + 1; j < nodecount; j++) {
402 map[j*64 + i] = map[i*64 + j] =
403 min(map[i*64 + j], speedcap[n]);
404 }
405 }
406 }
Ben Collins647dcb52006-06-12 18:12:37 -0400407
Stefan Richter433a87d2006-07-03 12:02:27 -0400408#if SELFID_SPEED_UNKNOWN != IEEE1394_SPEED_MAX
Ben Collins647dcb52006-06-12 18:12:37 -0400409 /* assume maximum speed for 1394b PHYs, nodemgr will correct it */
410 for (n = 0; n < nodecount; n++)
Stefan Richter433a87d2006-07-03 12:02:27 -0400411 if (speedcap[n] == SELFID_SPEED_UNKNOWN)
Ben Collins647dcb52006-06-12 18:12:37 -0400412 speedcap[n] = IEEE1394_SPEED_MAX;
Stefan Richter433a87d2006-07-03 12:02:27 -0400413#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414}
415
416
Stefan Richterafd65462007-03-05 03:06:23 +0100417/**
418 * hpsb_selfid_received - hand over received selfid packet to the core
419 *
420 * For host driver module usage. Safe to use in interrupt context.
421 *
422 * The host driver should have done a successful complement check (second
423 * quadlet is complement of first) beforehand.
424 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid)
426{
Stefan Richter741854e2005-12-01 18:52:03 -0500427 if (host->in_bus_reset) {
428 HPSB_VERBOSE("Including SelfID 0x%x", sid);
429 host->topology_map[host->selfid_count++] = sid;
430 } else {
431 HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 sid, NODEID_TO_BUS(host->node_id));
Stefan Richter741854e2005-12-01 18:52:03 -0500433 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434}
435
Stefan Richterafd65462007-03-05 03:06:23 +0100436/**
437 * hpsb_selfid_complete - notify completion of SelfID stage to the core
438 *
439 * For host driver module usage. Safe to use in interrupt context, although
440 * quite complex; so you may want to run it in the bottom rather than top half.
441 *
442 * Notify completion of SelfID stage to the core and report new physical ID
443 * and whether host is root now.
444 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
446{
447 if (!host->in_bus_reset)
448 HPSB_NOTICE("SelfID completion called outside of bus reset!");
449
Stefan Richter741854e2005-12-01 18:52:03 -0500450 host->node_id = LOCAL_BUS | phyid;
451 host->is_root = isroot;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Stefan Richter741854e2005-12-01 18:52:03 -0500453 if (!check_selfids(host)) {
454 if (host->reset_retries++ < 20) {
455 /* selfid stage did not complete without error */
456 HPSB_NOTICE("Error in SelfID stage, resetting");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 host->in_bus_reset = 0;
458 /* this should work from ohci1394 now... */
Stefan Richter741854e2005-12-01 18:52:03 -0500459 hpsb_reset_bus(host, LONG_RESET);
460 return;
461 } else {
462 HPSB_NOTICE("Stopping out-of-control reset loop");
463 HPSB_NOTICE("Warning - topology map and speed map will not be valid");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 host->reset_retries = 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500465 }
466 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 host->reset_retries = 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500468 build_speed_map(host, host->node_count);
469 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471 HPSB_VERBOSE("selfid_complete called with successful SelfID stage "
472 "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id);
473
Stefan Richter741854e2005-12-01 18:52:03 -0500474 /* irm_id is kept up to date by check_selfids() */
475 if (host->irm_id == host->node_id) {
476 host->is_irm = 1;
477 } else {
478 host->is_busmgr = 0;
479 host->is_irm = 0;
480 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Stefan Richter741854e2005-12-01 18:52:03 -0500482 if (isroot) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 host->driver->devctl(host, ACT_CYCLE_MASTER, 1);
484 host->is_cycmst = 1;
485 }
486 atomic_inc(&host->generation);
487 host->in_bus_reset = 0;
Stefan Richter741854e2005-12-01 18:52:03 -0500488 highlevel_host_reset(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489}
490
Stefan Richter7542e0e2007-03-25 22:22:40 +0200491static spinlock_t pending_packets_lock = SPIN_LOCK_UNLOCKED;
492
Stefan Richterafd65462007-03-05 03:06:23 +0100493/**
494 * hpsb_packet_sent - notify core of sending a packet
495 *
496 * For host driver module usage. Safe to call from within a transmit packet
497 * routine.
498 *
499 * Notify core of sending a packet. Ackcode is the ack code returned for async
500 * transmits or ACKX_SEND_ERROR if the transmission failed completely; ACKX_NONE
501 * for other cases (internal errors that don't justify a panic).
502 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
Stefan Richter741854e2005-12-01 18:52:03 -0500504 int ackcode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505{
506 unsigned long flags;
507
Stefan Richter7542e0e2007-03-25 22:22:40 +0200508 spin_lock_irqsave(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
510 packet->ack_code = ackcode;
511
512 if (packet->no_waiter || packet->state == hpsb_complete) {
513 /* if packet->no_waiter, must not have a tlabel allocated */
Stefan Richter7542e0e2007-03-25 22:22:40 +0200514 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 hpsb_free_packet(packet);
516 return;
517 }
518
519 atomic_dec(&packet->refcnt); /* drop HC's reference */
Stefan Richter7542e0e2007-03-25 22:22:40 +0200520 /* here the packet must be on the host->pending_packets queue */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
522 if (ackcode != ACK_PENDING || !packet->expect_response) {
523 packet->state = hpsb_complete;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200524 list_del_init(&packet->queue);
525 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 queue_packet_complete(packet);
527 return;
528 }
529
530 packet->state = hpsb_pending;
531 packet->sendtime = jiffies;
532
Stefan Richter7542e0e2007-03-25 22:22:40 +0200533 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534
535 mod_timer(&host->timeout, jiffies + host->timeout_interval);
536}
537
538/**
539 * hpsb_send_phy_config - transmit a PHY configuration packet on the bus
540 * @host: host that PHY config packet gets sent through
541 * @rootid: root whose force_root bit should get set (-1 = don't set force_root)
542 * @gapcnt: gap count value to set (-1 = don't set gap count)
543 *
Stefan Richterafd65462007-03-05 03:06:23 +0100544 * This function sends a PHY config packet on the bus through the specified
545 * host.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 *
Stefan Richterafd65462007-03-05 03:06:23 +0100547 * Return value: 0 for success or negative error number otherwise.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 */
549int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
550{
551 struct hpsb_packet *packet;
Stefan Richter546513f2005-12-01 18:52:01 -0500552 quadlet_t d = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 int retval = 0;
554
555 if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 ||
556 (rootid == -1 && gapcnt == -1)) {
557 HPSB_DEBUG("Invalid Parameter: rootid = %d gapcnt = %d",
558 rootid, gapcnt);
559 return -EINVAL;
560 }
561
Stefan Richter546513f2005-12-01 18:52:01 -0500562 if (rootid != -1)
563 d |= PHYPACKET_PHYCONFIG_R | rootid << PHYPACKET_PORT_SHIFT;
564 if (gapcnt != -1)
565 d |= PHYPACKET_PHYCONFIG_T | gapcnt << PHYPACKET_GAPCOUNT_SHIFT;
566
567 packet = hpsb_make_phypacket(host, d);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 if (!packet)
569 return -ENOMEM;
570
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 packet->generation = get_hpsb_generation(host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 retval = hpsb_send_packet_and_wait(packet);
573 hpsb_free_packet(packet);
574
575 return retval;
576}
577
578/**
579 * hpsb_send_packet - transmit a packet on the bus
580 * @packet: packet to send
581 *
582 * The packet is sent through the host specified in the packet->host field.
583 * Before sending, the packet's transmit speed is automatically determined
584 * using the local speed map when it is an async, non-broadcast packet.
585 *
586 * Possibilities for failure are that host is either not initialized, in bus
587 * reset, the packet's generation number doesn't match the current generation
588 * number or the host reports a transmit error.
589 *
590 * Return value: 0 on success, negative errno on failure.
591 */
592int hpsb_send_packet(struct hpsb_packet *packet)
593{
594 struct hpsb_host *host = packet->host;
595
Stefan Richter741854e2005-12-01 18:52:03 -0500596 if (host->is_shutdown)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 return -EINVAL;
598 if (host->in_bus_reset ||
599 (packet->generation != get_hpsb_generation(host)))
Stefan Richter741854e2005-12-01 18:52:03 -0500600 return -EAGAIN;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
Stefan Richter741854e2005-12-01 18:52:03 -0500602 packet->state = hpsb_queued;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
604 /* This just seems silly to me */
605 WARN_ON(packet->no_waiter && packet->expect_response);
606
607 if (!packet->no_waiter || packet->expect_response) {
Stefan Richter7542e0e2007-03-25 22:22:40 +0200608 unsigned long flags;
609
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 atomic_inc(&packet->refcnt);
Ben Collins1934b8b2005-07-09 20:01:23 -0400611 /* Set the initial "sendtime" to 10 seconds from now, to
612 prevent premature expiry. If a packet takes more than
613 10 seconds to hit the wire, we have bigger problems :) */
Jody McIntyre6262d062005-05-16 21:54:05 -0700614 packet->sendtime = jiffies + 10 * HZ;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200615 spin_lock_irqsave(&pending_packets_lock, flags);
616 list_add_tail(&packet->queue, &host->pending_packets);
617 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 }
619
Stefan Richter741854e2005-12-01 18:52:03 -0500620 if (packet->node_id == host->node_id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 /* it is a local request, so handle it locally */
622
Stefan Richter741854e2005-12-01 18:52:03 -0500623 quadlet_t *data;
624 size_t size = packet->data_size + packet->header_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Stefan Richter741854e2005-12-01 18:52:03 -0500626 data = kmalloc(size, GFP_ATOMIC);
627 if (!data) {
628 HPSB_ERR("unable to allocate memory for concatenating header and data");
629 return -ENOMEM;
630 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631
Stefan Richter741854e2005-12-01 18:52:03 -0500632 memcpy(data, packet->header, packet->header_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Stefan Richter741854e2005-12-01 18:52:03 -0500634 if (packet->data_size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
636
Stefan Richter741854e2005-12-01 18:52:03 -0500637 dump_packet("send packet local", packet->header, packet->header_size, -1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
Stefan Richter741854e2005-12-01 18:52:03 -0500639 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
640 hpsb_packet_received(host, data, size, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641
Stefan Richter741854e2005-12-01 18:52:03 -0500642 kfree(data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643
Stefan Richter741854e2005-12-01 18:52:03 -0500644 return 0;
645 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646
Ben Collins647dcb52006-06-12 18:12:37 -0400647 if (packet->type == hpsb_async &&
648 NODEID_TO_NODE(packet->node_id) != ALL_NODES)
Stefan Richter741854e2005-12-01 18:52:03 -0500649 packet->speed_code =
Ben Collins647dcb52006-06-12 18:12:37 -0400650 host->speed[NODEID_TO_NODE(packet->node_id)];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651
Stefan Richter741854e2005-12-01 18:52:03 -0500652 dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653
Stefan Richter741854e2005-12-01 18:52:03 -0500654 return host->driver->transmit_packet(host, packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655}
656
657/* We could just use complete() directly as the packet complete
658 * callback, but this is more typesafe, in the sense that we get a
659 * compiler error if the prototype for complete() changes. */
660
661static void complete_packet(void *data)
662{
663 complete((struct completion *) data);
664}
665
Stefan Richterafd65462007-03-05 03:06:23 +0100666/**
667 * hpsb_send_packet_and_wait - enqueue packet, block until transaction completes
668 * @packet: packet to send
669 *
670 * Return value: 0 on success, negative errno on failure.
671 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672int hpsb_send_packet_and_wait(struct hpsb_packet *packet)
673{
674 struct completion done;
675 int retval;
676
677 init_completion(&done);
678 hpsb_set_packet_complete_task(packet, complete_packet, &done);
679 retval = hpsb_send_packet(packet);
680 if (retval == 0)
681 wait_for_completion(&done);
682
683 return retval;
684}
685
686static void send_packet_nocare(struct hpsb_packet *packet)
687{
Stefan Richter741854e2005-12-01 18:52:03 -0500688 if (hpsb_send_packet(packet) < 0) {
689 hpsb_free_packet(packet);
690 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691}
692
Stefan Richter7542e0e2007-03-25 22:22:40 +0200693static size_t packet_size_to_data_size(size_t packet_size, size_t header_size,
694 size_t buffer_size, int tcode)
695{
696 size_t ret = packet_size <= header_size ? 0 : packet_size - header_size;
697
698 if (unlikely(ret > buffer_size))
699 ret = buffer_size;
700
701 if (unlikely(ret + header_size != packet_size))
Randy Dunlap504945c2007-04-03 13:00:47 -0700702 HPSB_ERR("unexpected packet size %zd (tcode %d), bug?",
Stefan Richter7542e0e2007-03-25 22:22:40 +0200703 packet_size, tcode);
704 return ret;
705}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706
707static void handle_packet_response(struct hpsb_host *host, int tcode,
708 quadlet_t *data, size_t size)
709{
Stefan Richter7542e0e2007-03-25 22:22:40 +0200710 struct hpsb_packet *packet;
711 int tlabel = (data[0] >> 10) & 0x3f;
712 size_t header_size;
Stefan Richter741854e2005-12-01 18:52:03 -0500713 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714
Stefan Richter7542e0e2007-03-25 22:22:40 +0200715 spin_lock_irqsave(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716
Stefan Richter7542e0e2007-03-25 22:22:40 +0200717 list_for_each_entry(packet, &host->pending_packets, queue)
718 if (packet->tlabel == tlabel &&
719 packet->node_id == (data[1] >> 16))
720 goto found;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721
Stefan Richter7542e0e2007-03-25 22:22:40 +0200722 spin_unlock_irqrestore(&pending_packets_lock, flags);
723 HPSB_DEBUG("unsolicited response packet received - %s",
724 "no tlabel match");
725 dump_packet("contents", data, 16, -1);
726 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727
Stefan Richter7542e0e2007-03-25 22:22:40 +0200728found:
Stefan Richter741854e2005-12-01 18:52:03 -0500729 switch (packet->tcode) {
730 case TCODE_WRITEQ:
731 case TCODE_WRITEB:
Stefan Richter7542e0e2007-03-25 22:22:40 +0200732 if (unlikely(tcode != TCODE_WRITE_RESPONSE))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 break;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200734 header_size = 12;
735 size = 0;
736 goto dequeue;
737
Stefan Richter741854e2005-12-01 18:52:03 -0500738 case TCODE_READQ:
Stefan Richter7542e0e2007-03-25 22:22:40 +0200739 if (unlikely(tcode != TCODE_READQ_RESPONSE))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 break;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200741 header_size = 16;
742 size = 0;
743 goto dequeue;
744
Stefan Richter741854e2005-12-01 18:52:03 -0500745 case TCODE_READB:
Stefan Richter7542e0e2007-03-25 22:22:40 +0200746 if (unlikely(tcode != TCODE_READB_RESPONSE))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 break;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200748 header_size = 16;
749 size = packet_size_to_data_size(size, header_size,
750 packet->allocated_data_size,
751 tcode);
752 goto dequeue;
753
Stefan Richter741854e2005-12-01 18:52:03 -0500754 case TCODE_LOCK_REQUEST:
Stefan Richter7542e0e2007-03-25 22:22:40 +0200755 if (unlikely(tcode != TCODE_LOCK_RESPONSE))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 break;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200757 header_size = 16;
758 size = packet_size_to_data_size(min(size, (size_t)(16 + 8)),
759 header_size,
760 packet->allocated_data_size,
761 tcode);
762 goto dequeue;
Stefan Richter741854e2005-12-01 18:52:03 -0500763 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764
Stefan Richter7542e0e2007-03-25 22:22:40 +0200765 spin_unlock_irqrestore(&pending_packets_lock, flags);
766 HPSB_DEBUG("unsolicited response packet received - %s",
767 "tcode mismatch");
768 dump_packet("contents", data, 16, -1);
769 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770
Stefan Richter7542e0e2007-03-25 22:22:40 +0200771dequeue:
772 list_del_init(&packet->queue);
773 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774
775 if (packet->state == hpsb_queued) {
776 packet->sendtime = jiffies;
777 packet->ack_code = ACK_PENDING;
778 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 packet->state = hpsb_complete;
Stefan Richter7542e0e2007-03-25 22:22:40 +0200780
781 memcpy(packet->header, data, header_size);
782 if (size)
783 memcpy(packet->data, data + 4, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
785 queue_packet_complete(packet);
786}
787
788
789static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
790 quadlet_t *data, size_t dsize)
791{
Stefan Richter741854e2005-12-01 18:52:03 -0500792 struct hpsb_packet *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793
Stefan Richter741854e2005-12-01 18:52:03 -0500794 p = hpsb_alloc_packet(dsize);
795 if (unlikely(p == NULL)) {
796 /* FIXME - send data_error response */
Stefan Richter7542e0e2007-03-25 22:22:40 +0200797 HPSB_ERR("out of memory, cannot send response packet");
Stefan Richter741854e2005-12-01 18:52:03 -0500798 return NULL;
799 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800
Stefan Richter741854e2005-12-01 18:52:03 -0500801 p->type = hpsb_async;
802 p->state = hpsb_unused;
803 p->host = host;
804 p->node_id = data[1] >> 16;
805 p->tlabel = (data[0] >> 10) & 0x3f;
806 p->no_waiter = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807
808 p->generation = get_hpsb_generation(host);
809
810 if (dsize % 4)
811 p->data[dsize / 4] = 0;
812
Stefan Richter741854e2005-12-01 18:52:03 -0500813 return p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814}
815
816#define PREP_ASYNC_HEAD_RCODE(tc) \
817 packet->tcode = tc; \
818 packet->header[0] = (packet->node_id << 16) | (packet->tlabel << 10) \
819 | (1 << 8) | (tc << 4); \
820 packet->header[1] = (packet->host->node_id << 16) | (rcode << 12); \
821 packet->header[2] = 0
822
823static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
Stefan Richter741854e2005-12-01 18:52:03 -0500824 quadlet_t data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825{
826 PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE);
827 packet->header[3] = data;
828 packet->header_size = 16;
829 packet->data_size = 0;
830}
831
832static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode,
Stefan Richter741854e2005-12-01 18:52:03 -0500833 int length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834{
835 if (rcode != RCODE_COMPLETE)
836 length = 0;
837
838 PREP_ASYNC_HEAD_RCODE(TCODE_READB_RESPONSE);
839 packet->header[3] = length << 16;
840 packet->header_size = 16;
841 packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0);
842}
843
844static void fill_async_write_resp(struct hpsb_packet *packet, int rcode)
845{
846 PREP_ASYNC_HEAD_RCODE(TCODE_WRITE_RESPONSE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 packet->header_size = 12;
848 packet->data_size = 0;
849}
850
851static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode,
Stefan Richter741854e2005-12-01 18:52:03 -0500852 int length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853{
854 if (rcode != RCODE_COMPLETE)
855 length = 0;
856
857 PREP_ASYNC_HEAD_RCODE(TCODE_LOCK_RESPONSE);
858 packet->header[3] = (length << 16) | extcode;
859 packet->header_size = 16;
860 packet->data_size = length;
861}
862
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863static void handle_incoming_packet(struct hpsb_host *host, int tcode,
Stefan Richterd4c60082007-03-18 00:55:15 +0100864 quadlet_t *data, size_t size,
865 int write_acked)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866{
Stefan Richter741854e2005-12-01 18:52:03 -0500867 struct hpsb_packet *packet;
868 int length, rcode, extcode;
869 quadlet_t buffer;
870 nodeid_t source = data[1] >> 16;
871 nodeid_t dest = data[0] >> 16;
872 u16 flags = (u16) data[0];
873 u64 addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874
Stefan Richterd4c60082007-03-18 00:55:15 +0100875 /* FIXME?
876 * Out-of-bounds lengths are left for highlevel_read|write to cap. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877
Stefan Richter741854e2005-12-01 18:52:03 -0500878 switch (tcode) {
879 case TCODE_WRITEQ:
880 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
Stefan Richterd4c60082007-03-18 00:55:15 +0100881 rcode = highlevel_write(host, source, dest, data + 3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 addr, 4, flags);
Stefan Richterd4c60082007-03-18 00:55:15 +0100883 goto handle_write_request;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884
Stefan Richter741854e2005-12-01 18:52:03 -0500885 case TCODE_WRITEB:
886 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
Stefan Richterd4c60082007-03-18 00:55:15 +0100887 rcode = highlevel_write(host, source, dest, data + 4,
888 addr, data[3] >> 16, flags);
889handle_write_request:
890 if (rcode < 0 || write_acked ||
891 NODEID_TO_NODE(data[0] >> 16) == NODE_MASK)
892 return;
893 /* not a broadcast write, reply */
894 packet = create_reply_packet(host, data, 0);
895 if (packet) {
Stefan Richter741854e2005-12-01 18:52:03 -0500896 fill_async_write_resp(packet, rcode);
897 send_packet_nocare(packet);
898 }
Stefan Richterd4c60082007-03-18 00:55:15 +0100899 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900
Stefan Richter741854e2005-12-01 18:52:03 -0500901 case TCODE_READQ:
902 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
903 rcode = highlevel_read(host, source, &buffer, addr, 4, flags);
Stefan Richterd4c60082007-03-18 00:55:15 +0100904 if (rcode < 0)
905 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906
Stefan Richterd4c60082007-03-18 00:55:15 +0100907 packet = create_reply_packet(host, data, 0);
908 if (packet) {
Stefan Richter741854e2005-12-01 18:52:03 -0500909 fill_async_readquad_resp(packet, rcode, buffer);
910 send_packet_nocare(packet);
911 }
Stefan Richterd4c60082007-03-18 00:55:15 +0100912 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913
Stefan Richter741854e2005-12-01 18:52:03 -0500914 case TCODE_READB:
915 length = data[3] >> 16;
Stefan Richterd4c60082007-03-18 00:55:15 +0100916 packet = create_reply_packet(host, data, length);
917 if (!packet)
918 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919
Stefan Richter741854e2005-12-01 18:52:03 -0500920 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
921 rcode = highlevel_read(host, source, packet->data, addr,
922 length, flags);
Stefan Richterd4c60082007-03-18 00:55:15 +0100923 if (rcode < 0) {
Stefan Richter741854e2005-12-01 18:52:03 -0500924 hpsb_free_packet(packet);
Stefan Richterd4c60082007-03-18 00:55:15 +0100925 return;
Stefan Richter741854e2005-12-01 18:52:03 -0500926 }
Stefan Richterd4c60082007-03-18 00:55:15 +0100927 fill_async_readblock_resp(packet, rcode, length);
928 send_packet_nocare(packet);
929 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930
Stefan Richter741854e2005-12-01 18:52:03 -0500931 case TCODE_LOCK_REQUEST:
932 length = data[3] >> 16;
933 extcode = data[3] & 0xffff;
934 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935
Stefan Richterd4c60082007-03-18 00:55:15 +0100936 packet = create_reply_packet(host, data, 8);
937 if (!packet)
938 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939
Stefan Richterd4c60082007-03-18 00:55:15 +0100940 if (extcode == 0 || extcode >= 7) {
Stefan Richter741854e2005-12-01 18:52:03 -0500941 /* let switch default handle error */
942 length = 0;
943 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944
Stefan Richter741854e2005-12-01 18:52:03 -0500945 switch (length) {
946 case 4:
947 rcode = highlevel_lock(host, source, packet->data, addr,
Stefan Richterd4c60082007-03-18 00:55:15 +0100948 data[4], 0, extcode, flags);
Stefan Richter741854e2005-12-01 18:52:03 -0500949 fill_async_lock_resp(packet, rcode, extcode, 4);
950 break;
951 case 8:
Stefan Richterd4c60082007-03-18 00:55:15 +0100952 if (extcode != EXTCODE_FETCH_ADD &&
953 extcode != EXTCODE_LITTLE_ADD) {
Stefan Richter741854e2005-12-01 18:52:03 -0500954 rcode = highlevel_lock(host, source,
955 packet->data, addr,
956 data[5], data[4],
957 extcode, flags);
958 fill_async_lock_resp(packet, rcode, extcode, 4);
959 } else {
960 rcode = highlevel_lock64(host, source,
961 (octlet_t *)packet->data, addr,
962 *(octlet_t *)(data + 4), 0ULL,
963 extcode, flags);
964 fill_async_lock_resp(packet, rcode, extcode, 8);
965 }
966 break;
967 case 16:
968 rcode = highlevel_lock64(host, source,
969 (octlet_t *)packet->data, addr,
970 *(octlet_t *)(data + 6),
971 *(octlet_t *)(data + 4),
972 extcode, flags);
973 fill_async_lock_resp(packet, rcode, extcode, 8);
974 break;
975 default:
976 rcode = RCODE_TYPE_ERROR;
Stefan Richterd4c60082007-03-18 00:55:15 +0100977 fill_async_lock_resp(packet, rcode, extcode, 0);
Stefan Richter741854e2005-12-01 18:52:03 -0500978 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979
Stefan Richterd4c60082007-03-18 00:55:15 +0100980 if (rcode < 0)
Stefan Richter741854e2005-12-01 18:52:03 -0500981 hpsb_free_packet(packet);
Stefan Richterd4c60082007-03-18 00:55:15 +0100982 else
983 send_packet_nocare(packet);
984 return;
Stefan Richter741854e2005-12-01 18:52:03 -0500985 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987
Stefan Richterafd65462007-03-05 03:06:23 +0100988/**
989 * hpsb_packet_received - hand over received packet to the core
990 *
991 * For host driver module usage.
992 *
993 * The contents of data are expected to be the full packet but with the CRCs
994 * left out (data block follows header immediately), with the header (i.e. the
995 * first four quadlets) in machine byte order and the data block in big endian.
996 * *@data can be safely overwritten after this call.
997 *
998 * If the packet is a write request, @write_acked is to be set to true if it was
999 * ack_complete'd already, false otherwise. This argument is ignored for any
1000 * other packet type.
1001 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
Stefan Richter741854e2005-12-01 18:52:03 -05001003 int write_acked)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004{
Stefan Richter741854e2005-12-01 18:52:03 -05001005 int tcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006
Stefan Richter7542e0e2007-03-25 22:22:40 +02001007 if (unlikely(host->in_bus_reset)) {
1008 HPSB_DEBUG("received packet during reset; ignoring");
Stefan Richter741854e2005-12-01 18:52:03 -05001009 return;
1010 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011
Stefan Richter741854e2005-12-01 18:52:03 -05001012 dump_packet("received packet", data, size, -1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013
Stefan Richter741854e2005-12-01 18:52:03 -05001014 tcode = (data[0] >> 4) & 0xf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015
Stefan Richter741854e2005-12-01 18:52:03 -05001016 switch (tcode) {
1017 case TCODE_WRITE_RESPONSE:
1018 case TCODE_READQ_RESPONSE:
1019 case TCODE_READB_RESPONSE:
1020 case TCODE_LOCK_RESPONSE:
1021 handle_packet_response(host, tcode, data, size);
1022 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023
Stefan Richter741854e2005-12-01 18:52:03 -05001024 case TCODE_WRITEQ:
1025 case TCODE_WRITEB:
1026 case TCODE_READQ:
1027 case TCODE_READB:
1028 case TCODE_LOCK_REQUEST:
1029 handle_incoming_packet(host, tcode, data, size, write_acked);
1030 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031
Stefan Richter741854e2005-12-01 18:52:03 -05001032 case TCODE_CYCLE_START:
1033 /* simply ignore this packet if it is passed on */
1034 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035
Stefan Richter741854e2005-12-01 18:52:03 -05001036 default:
Stefan Richter7542e0e2007-03-25 22:22:40 +02001037 HPSB_DEBUG("received packet with bogus transaction code %d",
1038 tcode);
Stefan Richter741854e2005-12-01 18:52:03 -05001039 break;
1040 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041}
1042
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043static void abort_requests(struct hpsb_host *host)
1044{
Stefan Richter7542e0e2007-03-25 22:22:40 +02001045 struct hpsb_packet *packet, *p;
1046 struct list_head tmp;
1047 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048
1049 host->driver->devctl(host, CANCEL_REQUESTS, 0);
1050
Stefan Richter7542e0e2007-03-25 22:22:40 +02001051 INIT_LIST_HEAD(&tmp);
1052 spin_lock_irqsave(&pending_packets_lock, flags);
1053 list_splice_init(&host->pending_packets, &tmp);
1054 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055
Stefan Richter7542e0e2007-03-25 22:22:40 +02001056 list_for_each_entry_safe(packet, p, &tmp, queue) {
1057 list_del_init(&packet->queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 packet->state = hpsb_complete;
1059 packet->ack_code = ACKX_ABORTED;
1060 queue_packet_complete(packet);
1061 }
1062}
1063
1064void abort_timedouts(unsigned long __opaque)
1065{
1066 struct hpsb_host *host = (struct hpsb_host *)__opaque;
Stefan Richter7542e0e2007-03-25 22:22:40 +02001067 struct hpsb_packet *packet, *p;
1068 struct list_head tmp;
1069 unsigned long flags, expire, j;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070
1071 spin_lock_irqsave(&host->csr.lock, flags);
1072 expire = host->csr.expire;
1073 spin_unlock_irqrestore(&host->csr.lock, flags);
1074
Stefan Richter7542e0e2007-03-25 22:22:40 +02001075 j = jiffies;
1076 INIT_LIST_HEAD(&tmp);
1077 spin_lock_irqsave(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078
Stefan Richter7542e0e2007-03-25 22:22:40 +02001079 list_for_each_entry_safe(packet, p, &host->pending_packets, queue) {
1080 if (time_before(packet->sendtime + expire, j))
1081 list_move_tail(&packet->queue, &tmp);
1082 else
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083 /* Since packets are added to the tail, the oldest
1084 * ones are first, always. When we get to one that
1085 * isn't timed out, the rest aren't either. */
1086 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 }
Stefan Richter7542e0e2007-03-25 22:22:40 +02001088 if (!list_empty(&host->pending_packets))
1089 mod_timer(&host->timeout, j + host->timeout_interval);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090
Stefan Richter7542e0e2007-03-25 22:22:40 +02001091 spin_unlock_irqrestore(&pending_packets_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092
Stefan Richter7542e0e2007-03-25 22:22:40 +02001093 list_for_each_entry_safe(packet, p, &tmp, queue) {
1094 list_del_init(&packet->queue);
1095 packet->state = hpsb_complete;
1096 packet->ack_code = ACKX_TIMEOUT;
1097 queue_packet_complete(packet);
1098 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099}
1100
Ben Collinsf6542402006-06-12 18:15:50 -04001101static struct task_struct *khpsbpkt_thread;
Stefan Richter7542e0e2007-03-25 22:22:40 +02001102static LIST_HEAD(hpsbpkt_queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103
1104static void queue_packet_complete(struct hpsb_packet *packet)
1105{
Stefan Richter7542e0e2007-03-25 22:22:40 +02001106 unsigned long flags;
1107
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 if (packet->no_waiter) {
1109 hpsb_free_packet(packet);
1110 return;
1111 }
1112 if (packet->complete_routine != NULL) {
Stefan Richter7542e0e2007-03-25 22:22:40 +02001113 spin_lock_irqsave(&pending_packets_lock, flags);
1114 list_add_tail(&packet->queue, &hpsbpkt_queue);
1115 spin_unlock_irqrestore(&pending_packets_lock, flags);
Ben Collinsf6542402006-06-12 18:15:50 -04001116 wake_up_process(khpsbpkt_thread);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 }
1118 return;
1119}
1120
Stefan Richter7542e0e2007-03-25 22:22:40 +02001121/*
1122 * Kernel thread which handles packets that are completed. This way the
1123 * packet's "complete" function is asynchronously run in process context.
1124 * Only packets which have a "complete" function may be sent here.
1125 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126static int hpsbpkt_thread(void *__hi)
1127{
Stefan Richter7542e0e2007-03-25 22:22:40 +02001128 struct hpsb_packet *packet, *p;
1129 struct list_head tmp;
1130 int may_schedule;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131
Ben Collinsf6542402006-06-12 18:15:50 -04001132 while (!kthread_should_stop()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133
Stefan Richter7542e0e2007-03-25 22:22:40 +02001134 INIT_LIST_HEAD(&tmp);
1135 spin_lock_irq(&pending_packets_lock);
1136 list_splice_init(&hpsbpkt_queue, &tmp);
1137 spin_unlock_irq(&pending_packets_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138
Stefan Richter7542e0e2007-03-25 22:22:40 +02001139 list_for_each_entry_safe(packet, p, &tmp, queue) {
1140 list_del_init(&packet->queue);
1141 packet->complete_routine(packet->complete_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143
Ben Collinsf6542402006-06-12 18:15:50 -04001144 set_current_state(TASK_INTERRUPTIBLE);
Stefan Richter7542e0e2007-03-25 22:22:40 +02001145 spin_lock_irq(&pending_packets_lock);
1146 may_schedule = list_empty(&hpsbpkt_queue);
1147 spin_unlock_irq(&pending_packets_lock);
1148 if (may_schedule)
Ben Collinsf6542402006-06-12 18:15:50 -04001149 schedule();
1150 __set_current_state(TASK_RUNNING);
1151 }
1152 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153}
1154
1155static int __init ieee1394_init(void)
1156{
1157 int i, ret;
1158
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 /* non-fatal error */
1160 if (hpsb_init_config_roms()) {
1161 HPSB_ERR("Failed to initialize some config rom entries.\n");
1162 HPSB_ERR("Some features may not be available\n");
1163 }
1164
Ben Collinsf6542402006-06-12 18:15:50 -04001165 khpsbpkt_thread = kthread_run(hpsbpkt_thread, NULL, "khpsbpkt");
1166 if (IS_ERR(khpsbpkt_thread)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 HPSB_ERR("Failed to start hpsbpkt thread!\n");
Ben Collinsf6542402006-06-12 18:15:50 -04001168 ret = PTR_ERR(khpsbpkt_thread);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 goto exit_cleanup_config_roms;
1170 }
1171
1172 if (register_chrdev_region(IEEE1394_CORE_DEV, 256, "ieee1394")) {
1173 HPSB_ERR("unable to register character device major %d!\n", IEEE1394_MAJOR);
1174 ret = -ENODEV;
1175 goto exit_release_kernel_thread;
1176 }
1177
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 ret = bus_register(&ieee1394_bus_type);
1179 if (ret < 0) {
1180 HPSB_INFO("bus register failed");
Stefan Richtera8748442006-03-28 19:55:41 -05001181 goto release_chrdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 }
1183
1184 for (i = 0; fw_bus_attrs[i]; i++) {
1185 ret = bus_create_file(&ieee1394_bus_type, fw_bus_attrs[i]);
1186 if (ret < 0) {
1187 while (i >= 0) {
1188 bus_remove_file(&ieee1394_bus_type,
1189 fw_bus_attrs[i--]);
1190 }
1191 bus_unregister(&ieee1394_bus_type);
Stefan Richtera8748442006-03-28 19:55:41 -05001192 goto release_chrdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 }
1194 }
1195
1196 ret = class_register(&hpsb_host_class);
1197 if (ret < 0)
1198 goto release_all_bus;
1199
gregkh@suse.de7e25ab92005-03-23 09:53:36 -08001200 hpsb_protocol_class = class_create(THIS_MODULE, "ieee1394_protocol");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 if (IS_ERR(hpsb_protocol_class)) {
1202 ret = PTR_ERR(hpsb_protocol_class);
1203 goto release_class_host;
1204 }
1205
1206 ret = init_csr();
1207 if (ret) {
1208 HPSB_INFO("init csr failed");
1209 ret = -ENOMEM;
1210 goto release_class_protocol;
1211 }
1212
1213 if (disable_nodemgr) {
1214 HPSB_INFO("nodemgr and IRM functionality disabled");
1215 /* We shouldn't contend for IRM with nodemgr disabled, since
1216 nodemgr implements functionality required of ieee1394a-2000
1217 IRMs */
1218 hpsb_disable_irm = 1;
Stefan Richter741854e2005-12-01 18:52:03 -05001219
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 return 0;
1221 }
1222
1223 if (hpsb_disable_irm) {
1224 HPSB_INFO("IRM functionality disabled");
1225 }
1226
1227 ret = init_ieee1394_nodemgr();
1228 if (ret < 0) {
1229 HPSB_INFO("init nodemgr failed");
1230 goto cleanup_csr;
1231 }
1232
1233 return 0;
1234
1235cleanup_csr:
1236 cleanup_csr();
1237release_class_protocol:
gregkh@suse.de7e25ab92005-03-23 09:53:36 -08001238 class_destroy(hpsb_protocol_class);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239release_class_host:
1240 class_unregister(&hpsb_host_class);
1241release_all_bus:
1242 for (i = 0; fw_bus_attrs[i]; i++)
1243 bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
1244 bus_unregister(&ieee1394_bus_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245release_chrdev:
1246 unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
1247exit_release_kernel_thread:
Ben Collinsf6542402006-06-12 18:15:50 -04001248 kthread_stop(khpsbpkt_thread);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249exit_cleanup_config_roms:
1250 hpsb_cleanup_config_roms();
1251 return ret;
1252}
1253
1254static void __exit ieee1394_cleanup(void)
1255{
1256 int i;
1257
1258 if (!disable_nodemgr)
1259 cleanup_ieee1394_nodemgr();
1260
1261 cleanup_csr();
1262
gregkh@suse.de7e25ab92005-03-23 09:53:36 -08001263 class_destroy(hpsb_protocol_class);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 class_unregister(&hpsb_host_class);
1265 for (i = 0; fw_bus_attrs[i]; i++)
1266 bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
1267 bus_unregister(&ieee1394_bus_type);
1268
Ben Collinsf6542402006-06-12 18:15:50 -04001269 kthread_stop(khpsbpkt_thread);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270
1271 hpsb_cleanup_config_roms();
1272
1273 unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274}
1275
Andi Kleen8df40832006-07-27 21:54:00 +02001276fs_initcall(ieee1394_init); /* same as ohci1394 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277module_exit(ieee1394_cleanup);
1278
1279/* Exported symbols */
1280
1281/** hosts.c **/
1282EXPORT_SYMBOL(hpsb_alloc_host);
1283EXPORT_SYMBOL(hpsb_add_host);
Stefan Richter33601772007-01-07 21:49:27 +01001284EXPORT_SYMBOL(hpsb_resume_host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285EXPORT_SYMBOL(hpsb_remove_host);
1286EXPORT_SYMBOL(hpsb_update_config_rom_image);
1287
1288/** ieee1394_core.c **/
1289EXPORT_SYMBOL(hpsb_speedto_str);
1290EXPORT_SYMBOL(hpsb_protocol_class);
1291EXPORT_SYMBOL(hpsb_set_packet_complete_task);
1292EXPORT_SYMBOL(hpsb_alloc_packet);
1293EXPORT_SYMBOL(hpsb_free_packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294EXPORT_SYMBOL(hpsb_send_packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295EXPORT_SYMBOL(hpsb_reset_bus);
Pieter Palmers3dc5ea92007-02-03 17:44:39 +01001296EXPORT_SYMBOL(hpsb_read_cycle_timer);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297EXPORT_SYMBOL(hpsb_bus_reset);
1298EXPORT_SYMBOL(hpsb_selfid_received);
1299EXPORT_SYMBOL(hpsb_selfid_complete);
1300EXPORT_SYMBOL(hpsb_packet_sent);
1301EXPORT_SYMBOL(hpsb_packet_received);
1302EXPORT_SYMBOL_GPL(hpsb_disable_irm);
1303
1304/** ieee1394_transactions.c **/
1305EXPORT_SYMBOL(hpsb_get_tlabel);
1306EXPORT_SYMBOL(hpsb_free_tlabel);
1307EXPORT_SYMBOL(hpsb_make_readpacket);
1308EXPORT_SYMBOL(hpsb_make_writepacket);
1309EXPORT_SYMBOL(hpsb_make_streampacket);
1310EXPORT_SYMBOL(hpsb_make_lockpacket);
1311EXPORT_SYMBOL(hpsb_make_lock64packet);
1312EXPORT_SYMBOL(hpsb_make_phypacket);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313EXPORT_SYMBOL(hpsb_read);
1314EXPORT_SYMBOL(hpsb_write);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315EXPORT_SYMBOL(hpsb_packet_success);
1316
1317/** highlevel.c **/
1318EXPORT_SYMBOL(hpsb_register_highlevel);
1319EXPORT_SYMBOL(hpsb_unregister_highlevel);
1320EXPORT_SYMBOL(hpsb_register_addrspace);
1321EXPORT_SYMBOL(hpsb_unregister_addrspace);
1322EXPORT_SYMBOL(hpsb_allocate_and_register_addrspace);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323EXPORT_SYMBOL(hpsb_get_hostinfo);
1324EXPORT_SYMBOL(hpsb_create_hostinfo);
1325EXPORT_SYMBOL(hpsb_destroy_hostinfo);
1326EXPORT_SYMBOL(hpsb_set_hostinfo_key);
1327EXPORT_SYMBOL(hpsb_get_hostinfo_bykey);
1328EXPORT_SYMBOL(hpsb_set_hostinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329
1330/** nodemgr.c **/
1331EXPORT_SYMBOL(hpsb_node_fill_packet);
1332EXPORT_SYMBOL(hpsb_node_write);
Ben Collinsed30c262006-11-23 13:59:48 -05001333EXPORT_SYMBOL(__hpsb_register_protocol);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334EXPORT_SYMBOL(hpsb_unregister_protocol);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335
1336/** csr.c **/
1337EXPORT_SYMBOL(hpsb_update_config_rom);
1338
1339/** dma.c **/
1340EXPORT_SYMBOL(dma_prog_region_init);
1341EXPORT_SYMBOL(dma_prog_region_alloc);
1342EXPORT_SYMBOL(dma_prog_region_free);
1343EXPORT_SYMBOL(dma_region_init);
1344EXPORT_SYMBOL(dma_region_alloc);
1345EXPORT_SYMBOL(dma_region_free);
1346EXPORT_SYMBOL(dma_region_sync_for_cpu);
1347EXPORT_SYMBOL(dma_region_sync_for_device);
1348EXPORT_SYMBOL(dma_region_mmap);
1349EXPORT_SYMBOL(dma_region_offset_to_bus);
1350
1351/** iso.c **/
1352EXPORT_SYMBOL(hpsb_iso_xmit_init);
1353EXPORT_SYMBOL(hpsb_iso_recv_init);
1354EXPORT_SYMBOL(hpsb_iso_xmit_start);
1355EXPORT_SYMBOL(hpsb_iso_recv_start);
1356EXPORT_SYMBOL(hpsb_iso_recv_listen_channel);
1357EXPORT_SYMBOL(hpsb_iso_recv_unlisten_channel);
1358EXPORT_SYMBOL(hpsb_iso_recv_set_channel_mask);
1359EXPORT_SYMBOL(hpsb_iso_stop);
1360EXPORT_SYMBOL(hpsb_iso_shutdown);
1361EXPORT_SYMBOL(hpsb_iso_xmit_queue_packet);
1362EXPORT_SYMBOL(hpsb_iso_xmit_sync);
1363EXPORT_SYMBOL(hpsb_iso_recv_release_packets);
1364EXPORT_SYMBOL(hpsb_iso_n_ready);
1365EXPORT_SYMBOL(hpsb_iso_packet_sent);
1366EXPORT_SYMBOL(hpsb_iso_packet_received);
1367EXPORT_SYMBOL(hpsb_iso_wake);
1368EXPORT_SYMBOL(hpsb_iso_recv_flush);
1369
1370/** csr1212.c **/
Ben Collins1934b8b2005-07-09 20:01:23 -04001371EXPORT_SYMBOL(csr1212_attach_keyval_to_directory);
1372EXPORT_SYMBOL(csr1212_detach_keyval_from_directory);
Stefan Richterc1a37f22007-03-14 00:20:53 +01001373EXPORT_SYMBOL(csr1212_get_keyval);
1374EXPORT_SYMBOL(csr1212_new_directory);
Ben Collins1934b8b2005-07-09 20:01:23 -04001375EXPORT_SYMBOL(csr1212_parse_keyval);
Stefan Richterc1a37f22007-03-14 00:20:53 +01001376EXPORT_SYMBOL(csr1212_read);
1377EXPORT_SYMBOL(csr1212_release_keyval);