ieee1394_core.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. /*
  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. #include <linux/kernel.h>
  23. #include <linux/list.h>
  24. #include <linux/string.h>
  25. #include <linux/init.h>
  26. #include <linux/slab.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/module.h>
  29. #include <linux/moduleparam.h>
  30. #include <linux/bitops.h>
  31. #include <linux/kdev_t.h>
  32. #include <linux/freezer.h>
  33. #include <linux/suspend.h>
  34. #include <linux/kthread.h>
  35. #include <linux/preempt.h>
  36. #include <linux/time.h>
  37. #include <asm/system.h>
  38. #include <asm/byteorder.h>
  39. #include "ieee1394_types.h"
  40. #include "ieee1394.h"
  41. #include "hosts.h"
  42. #include "ieee1394_core.h"
  43. #include "highlevel.h"
  44. #include "ieee1394_transactions.h"
  45. #include "csr.h"
  46. #include "nodemgr.h"
  47. #include "dma.h"
  48. #include "iso.h"
  49. #include "config_roms.h"
  50. /*
  51. * Disable the nodemgr detection and config rom reading functionality.
  52. */
  53. static int disable_nodemgr;
  54. module_param(disable_nodemgr, int, 0444);
  55. MODULE_PARM_DESC(disable_nodemgr, "Disable nodemgr functionality.");
  56. /* Disable Isochronous Resource Manager functionality */
  57. int hpsb_disable_irm = 0;
  58. module_param_named(disable_irm, hpsb_disable_irm, bool, 0444);
  59. MODULE_PARM_DESC(disable_irm,
  60. "Disable Isochronous Resource Manager functionality.");
  61. /* We are GPL, so treat us special */
  62. MODULE_LICENSE("GPL");
  63. /* Some globals used */
  64. const char *hpsb_speedto_str[] = { "S100", "S200", "S400", "S800", "S1600", "S3200" };
  65. struct class *hpsb_protocol_class;
  66. #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
  67. static void dump_packet(const char *text, quadlet_t *data, int size, int speed)
  68. {
  69. int i;
  70. size /= 4;
  71. size = (size > 4 ? 4 : size);
  72. printk(KERN_DEBUG "ieee1394: %s", text);
  73. if (speed > -1 && speed < 6)
  74. printk(" at %s", hpsb_speedto_str[speed]);
  75. printk(":");
  76. for (i = 0; i < size; i++)
  77. printk(" %08x", data[i]);
  78. printk("\n");
  79. }
  80. #else
  81. #define dump_packet(a,b,c,d) do {} while (0)
  82. #endif
  83. static void abort_requests(struct hpsb_host *host);
  84. static void queue_packet_complete(struct hpsb_packet *packet);
  85. /**
  86. * hpsb_set_packet_complete_task - set task that runs when a packet completes
  87. * @packet: the packet whose completion we want the task added to
  88. * @routine: function to call
  89. * @data: data (if any) to pass to the above function
  90. *
  91. * Set the task that runs when a packet completes. You cannot call this more
  92. * than once on a single packet before it is sent.
  93. *
  94. * Typically, the complete @routine is responsible to call hpsb_free_packet().
  95. */
  96. void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
  97. void (*routine)(void *), void *data)
  98. {
  99. WARN_ON(packet->complete_routine != NULL);
  100. packet->complete_routine = routine;
  101. packet->complete_data = data;
  102. return;
  103. }
  104. /**
  105. * hpsb_alloc_packet - allocate new packet structure
  106. * @data_size: size of the data block to be allocated, in bytes
  107. *
  108. * This function allocates, initializes and returns a new &struct hpsb_packet.
  109. * It can be used in interrupt context. A header block is always included and
  110. * initialized with zeros. Its size is big enough to contain all possible 1394
  111. * headers. The data block is only allocated if @data_size is not zero.
  112. *
  113. * For packets for which responses will be received the @data_size has to be big
  114. * enough to contain the response's data block since no further allocation
  115. * occurs at response matching time.
  116. *
  117. * The packet's generation value will be set to the current generation number
  118. * for ease of use. Remember to overwrite it with your own recorded generation
  119. * number if you can not be sure that your code will not race with a bus reset.
  120. *
  121. * Return value: A pointer to a &struct hpsb_packet or NULL on allocation
  122. * failure.
  123. */
  124. struct hpsb_packet *hpsb_alloc_packet(size_t data_size)
  125. {
  126. struct hpsb_packet *packet;
  127. data_size = ((data_size + 3) & ~3);
  128. packet = kzalloc(sizeof(*packet) + data_size, GFP_ATOMIC);
  129. if (!packet)
  130. return NULL;
  131. packet->state = hpsb_unused;
  132. packet->generation = -1;
  133. INIT_LIST_HEAD(&packet->driver_list);
  134. INIT_LIST_HEAD(&packet->queue);
  135. atomic_set(&packet->refcnt, 1);
  136. if (data_size) {
  137. packet->data = packet->embedded_data;
  138. packet->allocated_data_size = data_size;
  139. }
  140. return packet;
  141. }
  142. /**
  143. * hpsb_free_packet - free packet and data associated with it
  144. * @packet: packet to free (is NULL safe)
  145. *
  146. * Frees @packet->data only if it was allocated through hpsb_alloc_packet().
  147. */
  148. void hpsb_free_packet(struct hpsb_packet *packet)
  149. {
  150. if (packet && atomic_dec_and_test(&packet->refcnt)) {
  151. BUG_ON(!list_empty(&packet->driver_list) ||
  152. !list_empty(&packet->queue));
  153. kfree(packet);
  154. }
  155. }
  156. /**
  157. * hpsb_reset_bus - initiate bus reset on the given host
  158. * @host: host controller whose bus to reset
  159. * @type: one of enum reset_types
  160. *
  161. * Returns 1 if bus reset already in progress, 0 otherwise.
  162. */
  163. int hpsb_reset_bus(struct hpsb_host *host, int type)
  164. {
  165. if (!host->in_bus_reset) {
  166. host->driver->devctl(host, RESET_BUS, type);
  167. return 0;
  168. } else {
  169. return 1;
  170. }
  171. }
  172. /**
  173. * hpsb_read_cycle_timer - read cycle timer register and system time
  174. * @host: host whose isochronous cycle timer register is read
  175. * @cycle_timer: address of bitfield to return the register contents
  176. * @local_time: address to return the system time
  177. *
  178. * The format of * @cycle_timer, is described in OHCI 1.1 clause 5.13. This
  179. * format is also read from non-OHCI controllers. * @local_time contains the
  180. * system time in microseconds since the Epoch, read at the moment when the
  181. * cycle timer was read.
  182. *
  183. * Return value: 0 for success or error number otherwise.
  184. */
  185. int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer,
  186. u64 *local_time)
  187. {
  188. int ctr;
  189. struct timeval tv;
  190. unsigned long flags;
  191. if (!host || !cycle_timer || !local_time)
  192. return -EINVAL;
  193. preempt_disable();
  194. local_irq_save(flags);
  195. ctr = host->driver->devctl(host, GET_CYCLE_COUNTER, 0);
  196. if (ctr)
  197. do_gettimeofday(&tv);
  198. local_irq_restore(flags);
  199. preempt_enable();
  200. if (!ctr)
  201. return -EIO;
  202. *cycle_timer = ctr;
  203. *local_time = tv.tv_sec * 1000000ULL + tv.tv_usec;
  204. return 0;
  205. }
  206. /**
  207. * hpsb_bus_reset - notify a bus reset to the core
  208. *
  209. * For host driver module usage. Safe to use in interrupt context, although
  210. * quite complex; so you may want to run it in the bottom rather than top half.
  211. *
  212. * Returns 1 if bus reset already in progress, 0 otherwise.
  213. */
  214. int hpsb_bus_reset(struct hpsb_host *host)
  215. {
  216. if (host->in_bus_reset) {
  217. HPSB_NOTICE("%s called while bus reset already in progress",
  218. __FUNCTION__);
  219. return 1;
  220. }
  221. abort_requests(host);
  222. host->in_bus_reset = 1;
  223. host->irm_id = -1;
  224. host->is_irm = 0;
  225. host->busmgr_id = -1;
  226. host->is_busmgr = 0;
  227. host->is_cycmst = 0;
  228. host->node_count = 0;
  229. host->selfid_count = 0;
  230. return 0;
  231. }
  232. /*
  233. * Verify num_of_selfids SelfIDs and return number of nodes. Return zero in
  234. * case verification failed.
  235. */
  236. static int check_selfids(struct hpsb_host *host)
  237. {
  238. int nodeid = -1;
  239. int rest_of_selfids = host->selfid_count;
  240. struct selfid *sid = (struct selfid *)host->topology_map;
  241. struct ext_selfid *esid;
  242. int esid_seq = 23;
  243. host->nodes_active = 0;
  244. while (rest_of_selfids--) {
  245. if (!sid->extended) {
  246. nodeid++;
  247. esid_seq = 0;
  248. if (sid->phy_id != nodeid) {
  249. HPSB_INFO("SelfIDs failed monotony check with "
  250. "%d", sid->phy_id);
  251. return 0;
  252. }
  253. if (sid->link_active) {
  254. host->nodes_active++;
  255. if (sid->contender)
  256. host->irm_id = LOCAL_BUS | sid->phy_id;
  257. }
  258. } else {
  259. esid = (struct ext_selfid *)sid;
  260. if ((esid->phy_id != nodeid)
  261. || (esid->seq_nr != esid_seq)) {
  262. HPSB_INFO("SelfIDs failed monotony check with "
  263. "%d/%d", esid->phy_id, esid->seq_nr);
  264. return 0;
  265. }
  266. esid_seq++;
  267. }
  268. sid++;
  269. }
  270. esid = (struct ext_selfid *)(sid - 1);
  271. while (esid->extended) {
  272. if ((esid->porta == SELFID_PORT_PARENT) ||
  273. (esid->portb == SELFID_PORT_PARENT) ||
  274. (esid->portc == SELFID_PORT_PARENT) ||
  275. (esid->portd == SELFID_PORT_PARENT) ||
  276. (esid->porte == SELFID_PORT_PARENT) ||
  277. (esid->portf == SELFID_PORT_PARENT) ||
  278. (esid->portg == SELFID_PORT_PARENT) ||
  279. (esid->porth == SELFID_PORT_PARENT)) {
  280. HPSB_INFO("SelfIDs failed root check on "
  281. "extended SelfID");
  282. return 0;
  283. }
  284. esid--;
  285. }
  286. sid = (struct selfid *)esid;
  287. if ((sid->port0 == SELFID_PORT_PARENT) ||
  288. (sid->port1 == SELFID_PORT_PARENT) ||
  289. (sid->port2 == SELFID_PORT_PARENT)) {
  290. HPSB_INFO("SelfIDs failed root check");
  291. return 0;
  292. }
  293. host->node_count = nodeid + 1;
  294. return 1;
  295. }
  296. static void build_speed_map(struct hpsb_host *host, int nodecount)
  297. {
  298. u8 cldcnt[nodecount];
  299. u8 *map = host->speed_map;
  300. u8 *speedcap = host->speed;
  301. struct selfid *sid;
  302. struct ext_selfid *esid;
  303. int i, j, n;
  304. for (i = 0; i < (nodecount * 64); i += 64) {
  305. for (j = 0; j < nodecount; j++) {
  306. map[i+j] = IEEE1394_SPEED_MAX;
  307. }
  308. }
  309. for (i = 0; i < nodecount; i++) {
  310. cldcnt[i] = 0;
  311. }
  312. /* find direct children count and speed */
  313. for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1],
  314. n = nodecount - 1;
  315. (void *)sid >= (void *)host->topology_map; sid--) {
  316. if (sid->extended) {
  317. esid = (struct ext_selfid *)sid;
  318. if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++;
  319. if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++;
  320. if (esid->portc == SELFID_PORT_CHILD) cldcnt[n]++;
  321. if (esid->portd == SELFID_PORT_CHILD) cldcnt[n]++;
  322. if (esid->porte == SELFID_PORT_CHILD) cldcnt[n]++;
  323. if (esid->portf == SELFID_PORT_CHILD) cldcnt[n]++;
  324. if (esid->portg == SELFID_PORT_CHILD) cldcnt[n]++;
  325. if (esid->porth == SELFID_PORT_CHILD) cldcnt[n]++;
  326. } else {
  327. if (sid->port0 == SELFID_PORT_CHILD) cldcnt[n]++;
  328. if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++;
  329. if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
  330. speedcap[n] = sid->speed;
  331. n--;
  332. }
  333. }
  334. /* set self mapping */
  335. for (i = 0; i < nodecount; i++) {
  336. map[64*i + i] = speedcap[i];
  337. }
  338. /* fix up direct children count to total children count;
  339. * also fix up speedcaps for sibling and parent communication */
  340. for (i = 1; i < nodecount; i++) {
  341. for (j = cldcnt[i], n = i - 1; j > 0; j--) {
  342. cldcnt[i] += cldcnt[n];
  343. speedcap[n] = min(speedcap[n], speedcap[i]);
  344. n -= cldcnt[n] + 1;
  345. }
  346. }
  347. for (n = 0; n < nodecount; n++) {
  348. for (i = n - cldcnt[n]; i <= n; i++) {
  349. for (j = 0; j < (n - cldcnt[n]); j++) {
  350. map[j*64 + i] = map[i*64 + j] =
  351. min(map[i*64 + j], speedcap[n]);
  352. }
  353. for (j = n + 1; j < nodecount; j++) {
  354. map[j*64 + i] = map[i*64 + j] =
  355. min(map[i*64 + j], speedcap[n]);
  356. }
  357. }
  358. }
  359. #if SELFID_SPEED_UNKNOWN != IEEE1394_SPEED_MAX
  360. /* assume maximum speed for 1394b PHYs, nodemgr will correct it */
  361. for (n = 0; n < nodecount; n++)
  362. if (speedcap[n] == SELFID_SPEED_UNKNOWN)
  363. speedcap[n] = IEEE1394_SPEED_MAX;
  364. #endif
  365. }
  366. /**
  367. * hpsb_selfid_received - hand over received selfid packet to the core
  368. *
  369. * For host driver module usage. Safe to use in interrupt context.
  370. *
  371. * The host driver should have done a successful complement check (second
  372. * quadlet is complement of first) beforehand.
  373. */
  374. void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid)
  375. {
  376. if (host->in_bus_reset) {
  377. HPSB_VERBOSE("Including SelfID 0x%x", sid);
  378. host->topology_map[host->selfid_count++] = sid;
  379. } else {
  380. HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d",
  381. sid, NODEID_TO_BUS(host->node_id));
  382. }
  383. }
  384. /**
  385. * hpsb_selfid_complete - notify completion of SelfID stage to the core
  386. *
  387. * For host driver module usage. Safe to use in interrupt context, although
  388. * quite complex; so you may want to run it in the bottom rather than top half.
  389. *
  390. * Notify completion of SelfID stage to the core and report new physical ID
  391. * and whether host is root now.
  392. */
  393. void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
  394. {
  395. if (!host->in_bus_reset)
  396. HPSB_NOTICE("SelfID completion called outside of bus reset!");
  397. host->node_id = LOCAL_BUS | phyid;
  398. host->is_root = isroot;
  399. if (!check_selfids(host)) {
  400. if (host->reset_retries++ < 20) {
  401. /* selfid stage did not complete without error */
  402. HPSB_NOTICE("Error in SelfID stage, resetting");
  403. host->in_bus_reset = 0;
  404. /* this should work from ohci1394 now... */
  405. hpsb_reset_bus(host, LONG_RESET);
  406. return;
  407. } else {
  408. HPSB_NOTICE("Stopping out-of-control reset loop");
  409. HPSB_NOTICE("Warning - topology map and speed map will not be valid");
  410. host->reset_retries = 0;
  411. }
  412. } else {
  413. host->reset_retries = 0;
  414. build_speed_map(host, host->node_count);
  415. }
  416. HPSB_VERBOSE("selfid_complete called with successful SelfID stage "
  417. "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id);
  418. /* irm_id is kept up to date by check_selfids() */
  419. if (host->irm_id == host->node_id) {
  420. host->is_irm = 1;
  421. } else {
  422. host->is_busmgr = 0;
  423. host->is_irm = 0;
  424. }
  425. if (isroot) {
  426. host->driver->devctl(host, ACT_CYCLE_MASTER, 1);
  427. host->is_cycmst = 1;
  428. }
  429. atomic_inc(&host->generation);
  430. host->in_bus_reset = 0;
  431. highlevel_host_reset(host);
  432. }
  433. static DEFINE_SPINLOCK(pending_packets_lock);
  434. /**
  435. * hpsb_packet_sent - notify core of sending a packet
  436. *
  437. * For host driver module usage. Safe to call from within a transmit packet
  438. * routine.
  439. *
  440. * Notify core of sending a packet. Ackcode is the ack code returned for async
  441. * transmits or ACKX_SEND_ERROR if the transmission failed completely; ACKX_NONE
  442. * for other cases (internal errors that don't justify a panic).
  443. */
  444. void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
  445. int ackcode)
  446. {
  447. unsigned long flags;
  448. spin_lock_irqsave(&pending_packets_lock, flags);
  449. packet->ack_code = ackcode;
  450. if (packet->no_waiter || packet->state == hpsb_complete) {
  451. /* if packet->no_waiter, must not have a tlabel allocated */
  452. spin_unlock_irqrestore(&pending_packets_lock, flags);
  453. hpsb_free_packet(packet);
  454. return;
  455. }
  456. atomic_dec(&packet->refcnt); /* drop HC's reference */
  457. /* here the packet must be on the host->pending_packets queue */
  458. if (ackcode != ACK_PENDING || !packet->expect_response) {
  459. packet->state = hpsb_complete;
  460. list_del_init(&packet->queue);
  461. spin_unlock_irqrestore(&pending_packets_lock, flags);
  462. queue_packet_complete(packet);
  463. return;
  464. }
  465. packet->state = hpsb_pending;
  466. packet->sendtime = jiffies;
  467. spin_unlock_irqrestore(&pending_packets_lock, flags);
  468. mod_timer(&host->timeout, jiffies + host->timeout_interval);
  469. }
  470. /**
  471. * hpsb_send_phy_config - transmit a PHY configuration packet on the bus
  472. * @host: host that PHY config packet gets sent through
  473. * @rootid: root whose force_root bit should get set (-1 = don't set force_root)
  474. * @gapcnt: gap count value to set (-1 = don't set gap count)
  475. *
  476. * This function sends a PHY config packet on the bus through the specified
  477. * host.
  478. *
  479. * Return value: 0 for success or negative error number otherwise.
  480. */
  481. int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
  482. {
  483. struct hpsb_packet *packet;
  484. quadlet_t d = 0;
  485. int retval = 0;
  486. if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 ||
  487. (rootid == -1 && gapcnt == -1)) {
  488. HPSB_DEBUG("Invalid Parameter: rootid = %d gapcnt = %d",
  489. rootid, gapcnt);
  490. return -EINVAL;
  491. }
  492. if (rootid != -1)
  493. d |= PHYPACKET_PHYCONFIG_R | rootid << PHYPACKET_PORT_SHIFT;
  494. if (gapcnt != -1)
  495. d |= PHYPACKET_PHYCONFIG_T | gapcnt << PHYPACKET_GAPCOUNT_SHIFT;
  496. packet = hpsb_make_phypacket(host, d);
  497. if (!packet)
  498. return -ENOMEM;
  499. packet->generation = get_hpsb_generation(host);
  500. retval = hpsb_send_packet_and_wait(packet);
  501. hpsb_free_packet(packet);
  502. return retval;
  503. }
  504. /**
  505. * hpsb_send_packet - transmit a packet on the bus
  506. * @packet: packet to send
  507. *
  508. * The packet is sent through the host specified in the packet->host field.
  509. * Before sending, the packet's transmit speed is automatically determined
  510. * using the local speed map when it is an async, non-broadcast packet.
  511. *
  512. * Possibilities for failure are that host is either not initialized, in bus
  513. * reset, the packet's generation number doesn't match the current generation
  514. * number or the host reports a transmit error.
  515. *
  516. * Return value: 0 on success, negative errno on failure.
  517. */
  518. int hpsb_send_packet(struct hpsb_packet *packet)
  519. {
  520. struct hpsb_host *host = packet->host;
  521. if (host->is_shutdown)
  522. return -EINVAL;
  523. if (host->in_bus_reset ||
  524. (packet->generation != get_hpsb_generation(host)))
  525. return -EAGAIN;
  526. packet->state = hpsb_queued;
  527. /* This just seems silly to me */
  528. WARN_ON(packet->no_waiter && packet->expect_response);
  529. if (!packet->no_waiter || packet->expect_response) {
  530. unsigned long flags;
  531. atomic_inc(&packet->refcnt);
  532. /* Set the initial "sendtime" to 10 seconds from now, to
  533. prevent premature expiry. If a packet takes more than
  534. 10 seconds to hit the wire, we have bigger problems :) */
  535. packet->sendtime = jiffies + 10 * HZ;
  536. spin_lock_irqsave(&pending_packets_lock, flags);
  537. list_add_tail(&packet->queue, &host->pending_packets);
  538. spin_unlock_irqrestore(&pending_packets_lock, flags);
  539. }
  540. if (packet->node_id == host->node_id) {
  541. /* it is a local request, so handle it locally */
  542. quadlet_t *data;
  543. size_t size = packet->data_size + packet->header_size;
  544. data = kmalloc(size, GFP_ATOMIC);
  545. if (!data) {
  546. HPSB_ERR("unable to allocate memory for concatenating header and data");
  547. return -ENOMEM;
  548. }
  549. memcpy(data, packet->header, packet->header_size);
  550. if (packet->data_size)
  551. memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
  552. dump_packet("send packet local", packet->header, packet->header_size, -1);
  553. hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
  554. hpsb_packet_received(host, data, size, 0);
  555. kfree(data);
  556. return 0;
  557. }
  558. if (packet->type == hpsb_async &&
  559. NODEID_TO_NODE(packet->node_id) != ALL_NODES)
  560. packet->speed_code =
  561. host->speed[NODEID_TO_NODE(packet->node_id)];
  562. dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
  563. return host->driver->transmit_packet(host, packet);
  564. }
  565. /* We could just use complete() directly as the packet complete
  566. * callback, but this is more typesafe, in the sense that we get a
  567. * compiler error if the prototype for complete() changes. */
  568. static void complete_packet(void *data)
  569. {
  570. complete((struct completion *) data);
  571. }
  572. /**
  573. * hpsb_send_packet_and_wait - enqueue packet, block until transaction completes
  574. * @packet: packet to send
  575. *
  576. * Return value: 0 on success, negative errno on failure.
  577. */
  578. int hpsb_send_packet_and_wait(struct hpsb_packet *packet)
  579. {
  580. struct completion done;
  581. int retval;
  582. init_completion(&done);
  583. hpsb_set_packet_complete_task(packet, complete_packet, &done);
  584. retval = hpsb_send_packet(packet);
  585. if (retval == 0)
  586. wait_for_completion(&done);
  587. return retval;
  588. }
  589. static void send_packet_nocare(struct hpsb_packet *packet)
  590. {
  591. if (hpsb_send_packet(packet) < 0) {
  592. hpsb_free_packet(packet);
  593. }
  594. }
  595. static size_t packet_size_to_data_size(size_t packet_size, size_t header_size,
  596. size_t buffer_size, int tcode)
  597. {
  598. size_t ret = packet_size <= header_size ? 0 : packet_size - header_size;
  599. if (unlikely(ret > buffer_size))
  600. ret = buffer_size;
  601. if (unlikely(ret + header_size != packet_size))
  602. HPSB_ERR("unexpected packet size %zd (tcode %d), bug?",
  603. packet_size, tcode);
  604. return ret;
  605. }
  606. static void handle_packet_response(struct hpsb_host *host, int tcode,
  607. quadlet_t *data, size_t size)
  608. {
  609. struct hpsb_packet *packet;
  610. int tlabel = (data[0] >> 10) & 0x3f;
  611. size_t header_size;
  612. unsigned long flags;
  613. spin_lock_irqsave(&pending_packets_lock, flags);
  614. list_for_each_entry(packet, &host->pending_packets, queue)
  615. if (packet->tlabel == tlabel &&
  616. packet->node_id == (data[1] >> 16))
  617. goto found;
  618. spin_unlock_irqrestore(&pending_packets_lock, flags);
  619. HPSB_DEBUG("unsolicited response packet received - %s",
  620. "no tlabel match");
  621. dump_packet("contents", data, 16, -1);
  622. return;
  623. found:
  624. switch (packet->tcode) {
  625. case TCODE_WRITEQ:
  626. case TCODE_WRITEB:
  627. if (unlikely(tcode != TCODE_WRITE_RESPONSE))
  628. break;
  629. header_size = 12;
  630. size = 0;
  631. goto dequeue;
  632. case TCODE_READQ:
  633. if (unlikely(tcode != TCODE_READQ_RESPONSE))
  634. break;
  635. header_size = 16;
  636. size = 0;
  637. goto dequeue;
  638. case TCODE_READB:
  639. if (unlikely(tcode != TCODE_READB_RESPONSE))
  640. break;
  641. header_size = 16;
  642. size = packet_size_to_data_size(size, header_size,
  643. packet->allocated_data_size,
  644. tcode);
  645. goto dequeue;
  646. case TCODE_LOCK_REQUEST:
  647. if (unlikely(tcode != TCODE_LOCK_RESPONSE))
  648. break;
  649. header_size = 16;
  650. size = packet_size_to_data_size(min(size, (size_t)(16 + 8)),
  651. header_size,
  652. packet->allocated_data_size,
  653. tcode);
  654. goto dequeue;
  655. }
  656. spin_unlock_irqrestore(&pending_packets_lock, flags);
  657. HPSB_DEBUG("unsolicited response packet received - %s",
  658. "tcode mismatch");
  659. dump_packet("contents", data, 16, -1);
  660. return;
  661. dequeue:
  662. list_del_init(&packet->queue);
  663. spin_unlock_irqrestore(&pending_packets_lock, flags);
  664. if (packet->state == hpsb_queued) {
  665. packet->sendtime = jiffies;
  666. packet->ack_code = ACK_PENDING;
  667. }
  668. packet->state = hpsb_complete;
  669. memcpy(packet->header, data, header_size);
  670. if (size)
  671. memcpy(packet->data, data + 4, size);
  672. queue_packet_complete(packet);
  673. }
  674. static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
  675. quadlet_t *data, size_t dsize)
  676. {
  677. struct hpsb_packet *p;
  678. p = hpsb_alloc_packet(dsize);
  679. if (unlikely(p == NULL)) {
  680. /* FIXME - send data_error response */
  681. HPSB_ERR("out of memory, cannot send response packet");
  682. return NULL;
  683. }
  684. p->type = hpsb_async;
  685. p->state = hpsb_unused;
  686. p->host = host;
  687. p->node_id = data[1] >> 16;
  688. p->tlabel = (data[0] >> 10) & 0x3f;
  689. p->no_waiter = 1;
  690. p->generation = get_hpsb_generation(host);
  691. if (dsize % 4)
  692. p->data[dsize / 4] = 0;
  693. return p;
  694. }
  695. #define PREP_ASYNC_HEAD_RCODE(tc) \
  696. packet->tcode = tc; \
  697. packet->header[0] = (packet->node_id << 16) | (packet->tlabel << 10) \
  698. | (1 << 8) | (tc << 4); \
  699. packet->header[1] = (packet->host->node_id << 16) | (rcode << 12); \
  700. packet->header[2] = 0
  701. static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
  702. quadlet_t data)
  703. {
  704. PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE);
  705. packet->header[3] = data;
  706. packet->header_size = 16;
  707. packet->data_size = 0;
  708. }
  709. static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode,
  710. int length)
  711. {
  712. if (rcode != RCODE_COMPLETE)
  713. length = 0;
  714. PREP_ASYNC_HEAD_RCODE(TCODE_READB_RESPONSE);
  715. packet->header[3] = length << 16;
  716. packet->header_size = 16;
  717. packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0);
  718. }
  719. static void fill_async_write_resp(struct hpsb_packet *packet, int rcode)
  720. {
  721. PREP_ASYNC_HEAD_RCODE(TCODE_WRITE_RESPONSE);
  722. packet->header_size = 12;
  723. packet->data_size = 0;
  724. }
  725. static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode,
  726. int length)
  727. {
  728. if (rcode != RCODE_COMPLETE)
  729. length = 0;
  730. PREP_ASYNC_HEAD_RCODE(TCODE_LOCK_RESPONSE);
  731. packet->header[3] = (length << 16) | extcode;
  732. packet->header_size = 16;
  733. packet->data_size = length;
  734. }
  735. static void handle_incoming_packet(struct hpsb_host *host, int tcode,
  736. quadlet_t *data, size_t size,
  737. int write_acked)
  738. {
  739. struct hpsb_packet *packet;
  740. int length, rcode, extcode;
  741. quadlet_t buffer;
  742. nodeid_t source = data[1] >> 16;
  743. nodeid_t dest = data[0] >> 16;
  744. u16 flags = (u16) data[0];
  745. u64 addr;
  746. /* FIXME?
  747. * Out-of-bounds lengths are left for highlevel_read|write to cap. */
  748. switch (tcode) {
  749. case TCODE_WRITEQ:
  750. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  751. rcode = highlevel_write(host, source, dest, data + 3,
  752. addr, 4, flags);
  753. goto handle_write_request;
  754. case TCODE_WRITEB:
  755. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  756. rcode = highlevel_write(host, source, dest, data + 4,
  757. addr, data[3] >> 16, flags);
  758. handle_write_request:
  759. if (rcode < 0 || write_acked ||
  760. NODEID_TO_NODE(data[0] >> 16) == NODE_MASK)
  761. return;
  762. /* not a broadcast write, reply */
  763. packet = create_reply_packet(host, data, 0);
  764. if (packet) {
  765. fill_async_write_resp(packet, rcode);
  766. send_packet_nocare(packet);
  767. }
  768. return;
  769. case TCODE_READQ:
  770. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  771. rcode = highlevel_read(host, source, &buffer, addr, 4, flags);
  772. if (rcode < 0)
  773. return;
  774. packet = create_reply_packet(host, data, 0);
  775. if (packet) {
  776. fill_async_readquad_resp(packet, rcode, buffer);
  777. send_packet_nocare(packet);
  778. }
  779. return;
  780. case TCODE_READB:
  781. length = data[3] >> 16;
  782. packet = create_reply_packet(host, data, length);
  783. if (!packet)
  784. return;
  785. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  786. rcode = highlevel_read(host, source, packet->data, addr,
  787. length, flags);
  788. if (rcode < 0) {
  789. hpsb_free_packet(packet);
  790. return;
  791. }
  792. fill_async_readblock_resp(packet, rcode, length);
  793. send_packet_nocare(packet);
  794. return;
  795. case TCODE_LOCK_REQUEST:
  796. length = data[3] >> 16;
  797. extcode = data[3] & 0xffff;
  798. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  799. packet = create_reply_packet(host, data, 8);
  800. if (!packet)
  801. return;
  802. if (extcode == 0 || extcode >= 7) {
  803. /* let switch default handle error */
  804. length = 0;
  805. }
  806. switch (length) {
  807. case 4:
  808. rcode = highlevel_lock(host, source, packet->data, addr,
  809. data[4], 0, extcode, flags);
  810. fill_async_lock_resp(packet, rcode, extcode, 4);
  811. break;
  812. case 8:
  813. if (extcode != EXTCODE_FETCH_ADD &&
  814. extcode != EXTCODE_LITTLE_ADD) {
  815. rcode = highlevel_lock(host, source,
  816. packet->data, addr,
  817. data[5], data[4],
  818. extcode, flags);
  819. fill_async_lock_resp(packet, rcode, extcode, 4);
  820. } else {
  821. rcode = highlevel_lock64(host, source,
  822. (octlet_t *)packet->data, addr,
  823. *(octlet_t *)(data + 4), 0ULL,
  824. extcode, flags);
  825. fill_async_lock_resp(packet, rcode, extcode, 8);
  826. }
  827. break;
  828. case 16:
  829. rcode = highlevel_lock64(host, source,
  830. (octlet_t *)packet->data, addr,
  831. *(octlet_t *)(data + 6),
  832. *(octlet_t *)(data + 4),
  833. extcode, flags);
  834. fill_async_lock_resp(packet, rcode, extcode, 8);
  835. break;
  836. default:
  837. rcode = RCODE_TYPE_ERROR;
  838. fill_async_lock_resp(packet, rcode, extcode, 0);
  839. }
  840. if (rcode < 0)
  841. hpsb_free_packet(packet);
  842. else
  843. send_packet_nocare(packet);
  844. return;
  845. }
  846. }
  847. /**
  848. * hpsb_packet_received - hand over received packet to the core
  849. *
  850. * For host driver module usage.
  851. *
  852. * The contents of data are expected to be the full packet but with the CRCs
  853. * left out (data block follows header immediately), with the header (i.e. the
  854. * first four quadlets) in machine byte order and the data block in big endian.
  855. * *@data can be safely overwritten after this call.
  856. *
  857. * If the packet is a write request, @write_acked is to be set to true if it was
  858. * ack_complete'd already, false otherwise. This argument is ignored for any
  859. * other packet type.
  860. */
  861. void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
  862. int write_acked)
  863. {
  864. int tcode;
  865. if (unlikely(host->in_bus_reset)) {
  866. HPSB_DEBUG("received packet during reset; ignoring");
  867. return;
  868. }
  869. dump_packet("received packet", data, size, -1);
  870. tcode = (data[0] >> 4) & 0xf;
  871. switch (tcode) {
  872. case TCODE_WRITE_RESPONSE:
  873. case TCODE_READQ_RESPONSE:
  874. case TCODE_READB_RESPONSE:
  875. case TCODE_LOCK_RESPONSE:
  876. handle_packet_response(host, tcode, data, size);
  877. break;
  878. case TCODE_WRITEQ:
  879. case TCODE_WRITEB:
  880. case TCODE_READQ:
  881. case TCODE_READB:
  882. case TCODE_LOCK_REQUEST:
  883. handle_incoming_packet(host, tcode, data, size, write_acked);
  884. break;
  885. case TCODE_CYCLE_START:
  886. /* simply ignore this packet if it is passed on */
  887. break;
  888. default:
  889. HPSB_DEBUG("received packet with bogus transaction code %d",
  890. tcode);
  891. break;
  892. }
  893. }
  894. static void abort_requests(struct hpsb_host *host)
  895. {
  896. struct hpsb_packet *packet, *p;
  897. struct list_head tmp;
  898. unsigned long flags;
  899. host->driver->devctl(host, CANCEL_REQUESTS, 0);
  900. INIT_LIST_HEAD(&tmp);
  901. spin_lock_irqsave(&pending_packets_lock, flags);
  902. list_splice_init(&host->pending_packets, &tmp);
  903. spin_unlock_irqrestore(&pending_packets_lock, flags);
  904. list_for_each_entry_safe(packet, p, &tmp, queue) {
  905. list_del_init(&packet->queue);
  906. packet->state = hpsb_complete;
  907. packet->ack_code = ACKX_ABORTED;
  908. queue_packet_complete(packet);
  909. }
  910. }
  911. void abort_timedouts(unsigned long __opaque)
  912. {
  913. struct hpsb_host *host = (struct hpsb_host *)__opaque;
  914. struct hpsb_packet *packet, *p;
  915. struct list_head tmp;
  916. unsigned long flags, expire, j;
  917. spin_lock_irqsave(&host->csr.lock, flags);
  918. expire = host->csr.expire;
  919. spin_unlock_irqrestore(&host->csr.lock, flags);
  920. j = jiffies;
  921. INIT_LIST_HEAD(&tmp);
  922. spin_lock_irqsave(&pending_packets_lock, flags);
  923. list_for_each_entry_safe(packet, p, &host->pending_packets, queue) {
  924. if (time_before(packet->sendtime + expire, j))
  925. list_move_tail(&packet->queue, &tmp);
  926. else
  927. /* Since packets are added to the tail, the oldest
  928. * ones are first, always. When we get to one that
  929. * isn't timed out, the rest aren't either. */
  930. break;
  931. }
  932. if (!list_empty(&host->pending_packets))
  933. mod_timer(&host->timeout, j + host->timeout_interval);
  934. spin_unlock_irqrestore(&pending_packets_lock, flags);
  935. list_for_each_entry_safe(packet, p, &tmp, queue) {
  936. list_del_init(&packet->queue);
  937. packet->state = hpsb_complete;
  938. packet->ack_code = ACKX_TIMEOUT;
  939. queue_packet_complete(packet);
  940. }
  941. }
  942. static struct task_struct *khpsbpkt_thread;
  943. static LIST_HEAD(hpsbpkt_queue);
  944. static void queue_packet_complete(struct hpsb_packet *packet)
  945. {
  946. unsigned long flags;
  947. if (packet->no_waiter) {
  948. hpsb_free_packet(packet);
  949. return;
  950. }
  951. if (packet->complete_routine != NULL) {
  952. spin_lock_irqsave(&pending_packets_lock, flags);
  953. list_add_tail(&packet->queue, &hpsbpkt_queue);
  954. spin_unlock_irqrestore(&pending_packets_lock, flags);
  955. wake_up_process(khpsbpkt_thread);
  956. }
  957. return;
  958. }
  959. /*
  960. * Kernel thread which handles packets that are completed. This way the
  961. * packet's "complete" function is asynchronously run in process context.
  962. * Only packets which have a "complete" function may be sent here.
  963. */
  964. static int hpsbpkt_thread(void *__hi)
  965. {
  966. struct hpsb_packet *packet, *p;
  967. struct list_head tmp;
  968. int may_schedule;
  969. while (!kthread_should_stop()) {
  970. INIT_LIST_HEAD(&tmp);
  971. spin_lock_irq(&pending_packets_lock);
  972. list_splice_init(&hpsbpkt_queue, &tmp);
  973. spin_unlock_irq(&pending_packets_lock);
  974. list_for_each_entry_safe(packet, p, &tmp, queue) {
  975. list_del_init(&packet->queue);
  976. packet->complete_routine(packet->complete_data);
  977. }
  978. set_current_state(TASK_INTERRUPTIBLE);
  979. spin_lock_irq(&pending_packets_lock);
  980. may_schedule = list_empty(&hpsbpkt_queue);
  981. spin_unlock_irq(&pending_packets_lock);
  982. if (may_schedule)
  983. schedule();
  984. __set_current_state(TASK_RUNNING);
  985. }
  986. return 0;
  987. }
  988. static int __init ieee1394_init(void)
  989. {
  990. int i, ret;
  991. /* non-fatal error */
  992. if (hpsb_init_config_roms()) {
  993. HPSB_ERR("Failed to initialize some config rom entries.\n");
  994. HPSB_ERR("Some features may not be available\n");
  995. }
  996. khpsbpkt_thread = kthread_run(hpsbpkt_thread, NULL, "khpsbpkt");
  997. if (IS_ERR(khpsbpkt_thread)) {
  998. HPSB_ERR("Failed to start hpsbpkt thread!\n");
  999. ret = PTR_ERR(khpsbpkt_thread);
  1000. goto exit_cleanup_config_roms;
  1001. }
  1002. if (register_chrdev_region(IEEE1394_CORE_DEV, 256, "ieee1394")) {
  1003. HPSB_ERR("unable to register character device major %d!\n", IEEE1394_MAJOR);
  1004. ret = -ENODEV;
  1005. goto exit_release_kernel_thread;
  1006. }
  1007. ret = bus_register(&ieee1394_bus_type);
  1008. if (ret < 0) {
  1009. HPSB_INFO("bus register failed");
  1010. goto release_chrdev;
  1011. }
  1012. for (i = 0; fw_bus_attrs[i]; i++) {
  1013. ret = bus_create_file(&ieee1394_bus_type, fw_bus_attrs[i]);
  1014. if (ret < 0) {
  1015. while (i >= 0) {
  1016. bus_remove_file(&ieee1394_bus_type,
  1017. fw_bus_attrs[i--]);
  1018. }
  1019. bus_unregister(&ieee1394_bus_type);
  1020. goto release_chrdev;
  1021. }
  1022. }
  1023. ret = class_register(&hpsb_host_class);
  1024. if (ret < 0)
  1025. goto release_all_bus;
  1026. hpsb_protocol_class = class_create(THIS_MODULE, "ieee1394_protocol");
  1027. if (IS_ERR(hpsb_protocol_class)) {
  1028. ret = PTR_ERR(hpsb_protocol_class);
  1029. goto release_class_host;
  1030. }
  1031. ret = init_csr();
  1032. if (ret) {
  1033. HPSB_INFO("init csr failed");
  1034. ret = -ENOMEM;
  1035. goto release_class_protocol;
  1036. }
  1037. if (disable_nodemgr) {
  1038. HPSB_INFO("nodemgr and IRM functionality disabled");
  1039. /* We shouldn't contend for IRM with nodemgr disabled, since
  1040. nodemgr implements functionality required of ieee1394a-2000
  1041. IRMs */
  1042. hpsb_disable_irm = 1;
  1043. return 0;
  1044. }
  1045. if (hpsb_disable_irm) {
  1046. HPSB_INFO("IRM functionality disabled");
  1047. }
  1048. ret = init_ieee1394_nodemgr();
  1049. if (ret < 0) {
  1050. HPSB_INFO("init nodemgr failed");
  1051. goto cleanup_csr;
  1052. }
  1053. return 0;
  1054. cleanup_csr:
  1055. cleanup_csr();
  1056. release_class_protocol:
  1057. class_destroy(hpsb_protocol_class);
  1058. release_class_host:
  1059. class_unregister(&hpsb_host_class);
  1060. release_all_bus:
  1061. for (i = 0; fw_bus_attrs[i]; i++)
  1062. bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
  1063. bus_unregister(&ieee1394_bus_type);
  1064. release_chrdev:
  1065. unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
  1066. exit_release_kernel_thread:
  1067. kthread_stop(khpsbpkt_thread);
  1068. exit_cleanup_config_roms:
  1069. hpsb_cleanup_config_roms();
  1070. return ret;
  1071. }
  1072. static void __exit ieee1394_cleanup(void)
  1073. {
  1074. int i;
  1075. if (!disable_nodemgr)
  1076. cleanup_ieee1394_nodemgr();
  1077. cleanup_csr();
  1078. class_destroy(hpsb_protocol_class);
  1079. class_unregister(&hpsb_host_class);
  1080. for (i = 0; fw_bus_attrs[i]; i++)
  1081. bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
  1082. bus_unregister(&ieee1394_bus_type);
  1083. kthread_stop(khpsbpkt_thread);
  1084. hpsb_cleanup_config_roms();
  1085. unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
  1086. }
  1087. module_init(ieee1394_init);
  1088. module_exit(ieee1394_cleanup);
  1089. /* Exported symbols */
  1090. /** hosts.c **/
  1091. EXPORT_SYMBOL(hpsb_alloc_host);
  1092. EXPORT_SYMBOL(hpsb_add_host);
  1093. EXPORT_SYMBOL(hpsb_resume_host);
  1094. EXPORT_SYMBOL(hpsb_remove_host);
  1095. EXPORT_SYMBOL(hpsb_update_config_rom_image);
  1096. /** ieee1394_core.c **/
  1097. EXPORT_SYMBOL(hpsb_speedto_str);
  1098. EXPORT_SYMBOL(hpsb_protocol_class);
  1099. EXPORT_SYMBOL(hpsb_set_packet_complete_task);
  1100. EXPORT_SYMBOL(hpsb_alloc_packet);
  1101. EXPORT_SYMBOL(hpsb_free_packet);
  1102. EXPORT_SYMBOL(hpsb_send_packet);
  1103. EXPORT_SYMBOL(hpsb_reset_bus);
  1104. EXPORT_SYMBOL(hpsb_read_cycle_timer);
  1105. EXPORT_SYMBOL(hpsb_bus_reset);
  1106. EXPORT_SYMBOL(hpsb_selfid_received);
  1107. EXPORT_SYMBOL(hpsb_selfid_complete);
  1108. EXPORT_SYMBOL(hpsb_packet_sent);
  1109. EXPORT_SYMBOL(hpsb_packet_received);
  1110. EXPORT_SYMBOL_GPL(hpsb_disable_irm);
  1111. /** ieee1394_transactions.c **/
  1112. EXPORT_SYMBOL(hpsb_get_tlabel);
  1113. EXPORT_SYMBOL(hpsb_free_tlabel);
  1114. EXPORT_SYMBOL(hpsb_make_readpacket);
  1115. EXPORT_SYMBOL(hpsb_make_writepacket);
  1116. EXPORT_SYMBOL(hpsb_make_streampacket);
  1117. EXPORT_SYMBOL(hpsb_make_lockpacket);
  1118. EXPORT_SYMBOL(hpsb_make_lock64packet);
  1119. EXPORT_SYMBOL(hpsb_make_phypacket);
  1120. EXPORT_SYMBOL(hpsb_read);
  1121. EXPORT_SYMBOL(hpsb_write);
  1122. EXPORT_SYMBOL(hpsb_packet_success);
  1123. /** highlevel.c **/
  1124. EXPORT_SYMBOL(hpsb_register_highlevel);
  1125. EXPORT_SYMBOL(hpsb_unregister_highlevel);
  1126. EXPORT_SYMBOL(hpsb_register_addrspace);
  1127. EXPORT_SYMBOL(hpsb_unregister_addrspace);
  1128. EXPORT_SYMBOL(hpsb_allocate_and_register_addrspace);
  1129. EXPORT_SYMBOL(hpsb_get_hostinfo);
  1130. EXPORT_SYMBOL(hpsb_create_hostinfo);
  1131. EXPORT_SYMBOL(hpsb_destroy_hostinfo);
  1132. EXPORT_SYMBOL(hpsb_set_hostinfo_key);
  1133. EXPORT_SYMBOL(hpsb_get_hostinfo_bykey);
  1134. EXPORT_SYMBOL(hpsb_set_hostinfo);
  1135. /** nodemgr.c **/
  1136. EXPORT_SYMBOL(hpsb_node_fill_packet);
  1137. EXPORT_SYMBOL(hpsb_node_write);
  1138. EXPORT_SYMBOL(__hpsb_register_protocol);
  1139. EXPORT_SYMBOL(hpsb_unregister_protocol);
  1140. /** csr.c **/
  1141. EXPORT_SYMBOL(hpsb_update_config_rom);
  1142. /** dma.c **/
  1143. EXPORT_SYMBOL(dma_prog_region_init);
  1144. EXPORT_SYMBOL(dma_prog_region_alloc);
  1145. EXPORT_SYMBOL(dma_prog_region_free);
  1146. EXPORT_SYMBOL(dma_region_init);
  1147. EXPORT_SYMBOL(dma_region_alloc);
  1148. EXPORT_SYMBOL(dma_region_free);
  1149. EXPORT_SYMBOL(dma_region_sync_for_cpu);
  1150. EXPORT_SYMBOL(dma_region_sync_for_device);
  1151. EXPORT_SYMBOL(dma_region_mmap);
  1152. EXPORT_SYMBOL(dma_region_offset_to_bus);
  1153. /** iso.c **/
  1154. EXPORT_SYMBOL(hpsb_iso_xmit_init);
  1155. EXPORT_SYMBOL(hpsb_iso_recv_init);
  1156. EXPORT_SYMBOL(hpsb_iso_xmit_start);
  1157. EXPORT_SYMBOL(hpsb_iso_recv_start);
  1158. EXPORT_SYMBOL(hpsb_iso_recv_listen_channel);
  1159. EXPORT_SYMBOL(hpsb_iso_recv_unlisten_channel);
  1160. EXPORT_SYMBOL(hpsb_iso_recv_set_channel_mask);
  1161. EXPORT_SYMBOL(hpsb_iso_stop);
  1162. EXPORT_SYMBOL(hpsb_iso_shutdown);
  1163. EXPORT_SYMBOL(hpsb_iso_xmit_queue_packet);
  1164. EXPORT_SYMBOL(hpsb_iso_xmit_sync);
  1165. EXPORT_SYMBOL(hpsb_iso_recv_release_packets);
  1166. EXPORT_SYMBOL(hpsb_iso_n_ready);
  1167. EXPORT_SYMBOL(hpsb_iso_packet_sent);
  1168. EXPORT_SYMBOL(hpsb_iso_packet_received);
  1169. EXPORT_SYMBOL(hpsb_iso_wake);
  1170. EXPORT_SYMBOL(hpsb_iso_recv_flush);
  1171. /** csr1212.c **/
  1172. EXPORT_SYMBOL(csr1212_attach_keyval_to_directory);
  1173. EXPORT_SYMBOL(csr1212_detach_keyval_from_directory);
  1174. EXPORT_SYMBOL(csr1212_get_keyval);
  1175. EXPORT_SYMBOL(csr1212_new_directory);
  1176. EXPORT_SYMBOL(csr1212_parse_keyval);
  1177. EXPORT_SYMBOL(csr1212_read);
  1178. EXPORT_SYMBOL(csr1212_release_keyval);