ieee1394_core.c 37 KB

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