ieee1394_core.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380
  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. __func__);
  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. u8 local_link_speed = host->csr.lnk_spd;
  302. struct selfid *sid;
  303. struct ext_selfid *esid;
  304. int i, j, n;
  305. for (i = 0; i < (nodecount * 64); i += 64) {
  306. for (j = 0; j < nodecount; j++) {
  307. map[i+j] = IEEE1394_SPEED_MAX;
  308. }
  309. }
  310. for (i = 0; i < nodecount; i++) {
  311. cldcnt[i] = 0;
  312. }
  313. /* find direct children count and speed */
  314. for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1],
  315. n = nodecount - 1;
  316. (void *)sid >= (void *)host->topology_map; sid--) {
  317. if (sid->extended) {
  318. esid = (struct ext_selfid *)sid;
  319. if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++;
  320. if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++;
  321. if (esid->portc == SELFID_PORT_CHILD) cldcnt[n]++;
  322. if (esid->portd == SELFID_PORT_CHILD) cldcnt[n]++;
  323. if (esid->porte == SELFID_PORT_CHILD) cldcnt[n]++;
  324. if (esid->portf == SELFID_PORT_CHILD) cldcnt[n]++;
  325. if (esid->portg == SELFID_PORT_CHILD) cldcnt[n]++;
  326. if (esid->porth == SELFID_PORT_CHILD) cldcnt[n]++;
  327. } else {
  328. if (sid->port0 == SELFID_PORT_CHILD) cldcnt[n]++;
  329. if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++;
  330. if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
  331. speedcap[n] = sid->speed;
  332. if (speedcap[n] > local_link_speed)
  333. speedcap[n] = local_link_speed;
  334. n--;
  335. }
  336. }
  337. /* set self mapping */
  338. for (i = 0; i < nodecount; i++) {
  339. map[64*i + i] = speedcap[i];
  340. }
  341. /* fix up direct children count to total children count;
  342. * also fix up speedcaps for sibling and parent communication */
  343. for (i = 1; i < nodecount; i++) {
  344. for (j = cldcnt[i], n = i - 1; j > 0; j--) {
  345. cldcnt[i] += cldcnt[n];
  346. speedcap[n] = min(speedcap[n], speedcap[i]);
  347. n -= cldcnt[n] + 1;
  348. }
  349. }
  350. for (n = 0; n < nodecount; n++) {
  351. for (i = n - cldcnt[n]; i <= n; i++) {
  352. for (j = 0; j < (n - cldcnt[n]); j++) {
  353. map[j*64 + i] = map[i*64 + j] =
  354. min(map[i*64 + j], speedcap[n]);
  355. }
  356. for (j = n + 1; j < nodecount; j++) {
  357. map[j*64 + i] = map[i*64 + j] =
  358. min(map[i*64 + j], speedcap[n]);
  359. }
  360. }
  361. }
  362. /* assume a maximum speed for 1394b PHYs, nodemgr will correct it */
  363. if (local_link_speed > SELFID_SPEED_UNKNOWN)
  364. for (i = 0; i < nodecount; i++)
  365. if (speedcap[i] == SELFID_SPEED_UNKNOWN)
  366. speedcap[i] = local_link_speed;
  367. }
  368. /**
  369. * hpsb_selfid_received - hand over received selfid packet to the core
  370. *
  371. * For host driver module usage. Safe to use in interrupt context.
  372. *
  373. * The host driver should have done a successful complement check (second
  374. * quadlet is complement of first) beforehand.
  375. */
  376. void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid)
  377. {
  378. if (host->in_bus_reset) {
  379. HPSB_VERBOSE("Including SelfID 0x%x", sid);
  380. host->topology_map[host->selfid_count++] = sid;
  381. } else {
  382. HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d",
  383. sid, NODEID_TO_BUS(host->node_id));
  384. }
  385. }
  386. /**
  387. * hpsb_selfid_complete - notify completion of SelfID stage to the core
  388. *
  389. * For host driver module usage. Safe to use in interrupt context, although
  390. * quite complex; so you may want to run it in the bottom rather than top half.
  391. *
  392. * Notify completion of SelfID stage to the core and report new physical ID
  393. * and whether host is root now.
  394. */
  395. void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
  396. {
  397. if (!host->in_bus_reset)
  398. HPSB_NOTICE("SelfID completion called outside of bus reset!");
  399. host->node_id = LOCAL_BUS | phyid;
  400. host->is_root = isroot;
  401. if (!check_selfids(host)) {
  402. if (host->reset_retries++ < 20) {
  403. /* selfid stage did not complete without error */
  404. HPSB_NOTICE("Error in SelfID stage, resetting");
  405. host->in_bus_reset = 0;
  406. /* this should work from ohci1394 now... */
  407. hpsb_reset_bus(host, LONG_RESET);
  408. return;
  409. } else {
  410. HPSB_NOTICE("Stopping out-of-control reset loop");
  411. HPSB_NOTICE("Warning - topology map and speed map will not be valid");
  412. host->reset_retries = 0;
  413. }
  414. } else {
  415. host->reset_retries = 0;
  416. build_speed_map(host, host->node_count);
  417. }
  418. HPSB_VERBOSE("selfid_complete called with successful SelfID stage "
  419. "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id);
  420. /* irm_id is kept up to date by check_selfids() */
  421. if (host->irm_id == host->node_id) {
  422. host->is_irm = 1;
  423. } else {
  424. host->is_busmgr = 0;
  425. host->is_irm = 0;
  426. }
  427. if (isroot) {
  428. host->driver->devctl(host, ACT_CYCLE_MASTER, 1);
  429. host->is_cycmst = 1;
  430. }
  431. atomic_inc(&host->generation);
  432. host->in_bus_reset = 0;
  433. highlevel_host_reset(host);
  434. }
  435. static DEFINE_SPINLOCK(pending_packets_lock);
  436. /**
  437. * hpsb_packet_sent - notify core of sending a packet
  438. *
  439. * For host driver module usage. Safe to call from within a transmit packet
  440. * routine.
  441. *
  442. * Notify core of sending a packet. Ackcode is the ack code returned for async
  443. * transmits or ACKX_SEND_ERROR if the transmission failed completely; ACKX_NONE
  444. * for other cases (internal errors that don't justify a panic).
  445. */
  446. void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
  447. int ackcode)
  448. {
  449. unsigned long flags;
  450. spin_lock_irqsave(&pending_packets_lock, flags);
  451. packet->ack_code = ackcode;
  452. if (packet->no_waiter || packet->state == hpsb_complete) {
  453. /* if packet->no_waiter, must not have a tlabel allocated */
  454. spin_unlock_irqrestore(&pending_packets_lock, flags);
  455. hpsb_free_packet(packet);
  456. return;
  457. }
  458. atomic_dec(&packet->refcnt); /* drop HC's reference */
  459. /* here the packet must be on the host->pending_packets queue */
  460. if (ackcode != ACK_PENDING || !packet->expect_response) {
  461. packet->state = hpsb_complete;
  462. list_del_init(&packet->queue);
  463. spin_unlock_irqrestore(&pending_packets_lock, flags);
  464. queue_packet_complete(packet);
  465. return;
  466. }
  467. packet->state = hpsb_pending;
  468. packet->sendtime = jiffies;
  469. spin_unlock_irqrestore(&pending_packets_lock, flags);
  470. mod_timer(&host->timeout, jiffies + host->timeout_interval);
  471. }
  472. /**
  473. * hpsb_send_phy_config - transmit a PHY configuration packet on the bus
  474. * @host: host that PHY config packet gets sent through
  475. * @rootid: root whose force_root bit should get set (-1 = don't set force_root)
  476. * @gapcnt: gap count value to set (-1 = don't set gap count)
  477. *
  478. * This function sends a PHY config packet on the bus through the specified
  479. * host.
  480. *
  481. * Return value: 0 for success or negative error number otherwise.
  482. */
  483. int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
  484. {
  485. struct hpsb_packet *packet;
  486. quadlet_t d = 0;
  487. int retval = 0;
  488. if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 ||
  489. (rootid == -1 && gapcnt == -1)) {
  490. HPSB_DEBUG("Invalid Parameter: rootid = %d gapcnt = %d",
  491. rootid, gapcnt);
  492. return -EINVAL;
  493. }
  494. if (rootid != -1)
  495. d |= PHYPACKET_PHYCONFIG_R | rootid << PHYPACKET_PORT_SHIFT;
  496. if (gapcnt != -1)
  497. d |= PHYPACKET_PHYCONFIG_T | gapcnt << PHYPACKET_GAPCOUNT_SHIFT;
  498. packet = hpsb_make_phypacket(host, d);
  499. if (!packet)
  500. return -ENOMEM;
  501. packet->generation = get_hpsb_generation(host);
  502. retval = hpsb_send_packet_and_wait(packet);
  503. hpsb_free_packet(packet);
  504. return retval;
  505. }
  506. /**
  507. * hpsb_send_packet - transmit a packet on the bus
  508. * @packet: packet to send
  509. *
  510. * The packet is sent through the host specified in the packet->host field.
  511. * Before sending, the packet's transmit speed is automatically determined
  512. * using the local speed map when it is an async, non-broadcast packet.
  513. *
  514. * Possibilities for failure are that host is either not initialized, in bus
  515. * reset, the packet's generation number doesn't match the current generation
  516. * number or the host reports a transmit error.
  517. *
  518. * Return value: 0 on success, negative errno on failure.
  519. */
  520. int hpsb_send_packet(struct hpsb_packet *packet)
  521. {
  522. struct hpsb_host *host = packet->host;
  523. if (host->is_shutdown)
  524. return -EINVAL;
  525. if (host->in_bus_reset ||
  526. (packet->generation != get_hpsb_generation(host)))
  527. return -EAGAIN;
  528. packet->state = hpsb_queued;
  529. /* This just seems silly to me */
  530. WARN_ON(packet->no_waiter && packet->expect_response);
  531. if (!packet->no_waiter || packet->expect_response) {
  532. unsigned long flags;
  533. atomic_inc(&packet->refcnt);
  534. /* Set the initial "sendtime" to 10 seconds from now, to
  535. prevent premature expiry. If a packet takes more than
  536. 10 seconds to hit the wire, we have bigger problems :) */
  537. packet->sendtime = jiffies + 10 * HZ;
  538. spin_lock_irqsave(&pending_packets_lock, flags);
  539. list_add_tail(&packet->queue, &host->pending_packets);
  540. spin_unlock_irqrestore(&pending_packets_lock, flags);
  541. }
  542. if (packet->node_id == host->node_id) {
  543. /* it is a local request, so handle it locally */
  544. quadlet_t *data;
  545. size_t size = packet->data_size + packet->header_size;
  546. data = kmalloc(size, GFP_ATOMIC);
  547. if (!data) {
  548. HPSB_ERR("unable to allocate memory for concatenating header and data");
  549. return -ENOMEM;
  550. }
  551. memcpy(data, packet->header, packet->header_size);
  552. if (packet->data_size)
  553. memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
  554. dump_packet("send packet local", packet->header, packet->header_size, -1);
  555. hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
  556. hpsb_packet_received(host, data, size, 0);
  557. kfree(data);
  558. return 0;
  559. }
  560. if (packet->type == hpsb_async &&
  561. NODEID_TO_NODE(packet->node_id) != ALL_NODES)
  562. packet->speed_code =
  563. host->speed[NODEID_TO_NODE(packet->node_id)];
  564. dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
  565. return host->driver->transmit_packet(host, packet);
  566. }
  567. /* We could just use complete() directly as the packet complete
  568. * callback, but this is more typesafe, in the sense that we get a
  569. * compiler error if the prototype for complete() changes. */
  570. static void complete_packet(void *data)
  571. {
  572. complete((struct completion *) data);
  573. }
  574. /**
  575. * hpsb_send_packet_and_wait - enqueue packet, block until transaction completes
  576. * @packet: packet to send
  577. *
  578. * Return value: 0 on success, negative errno on failure.
  579. */
  580. int hpsb_send_packet_and_wait(struct hpsb_packet *packet)
  581. {
  582. struct completion done;
  583. int retval;
  584. init_completion(&done);
  585. hpsb_set_packet_complete_task(packet, complete_packet, &done);
  586. retval = hpsb_send_packet(packet);
  587. if (retval == 0)
  588. wait_for_completion(&done);
  589. return retval;
  590. }
  591. static void send_packet_nocare(struct hpsb_packet *packet)
  592. {
  593. if (hpsb_send_packet(packet) < 0) {
  594. hpsb_free_packet(packet);
  595. }
  596. }
  597. static size_t packet_size_to_data_size(size_t packet_size, size_t header_size,
  598. size_t buffer_size, int tcode)
  599. {
  600. size_t ret = packet_size <= header_size ? 0 : packet_size - header_size;
  601. if (unlikely(ret > buffer_size))
  602. ret = buffer_size;
  603. if (unlikely(ret + header_size != packet_size))
  604. HPSB_ERR("unexpected packet size %zd (tcode %d), bug?",
  605. packet_size, tcode);
  606. return ret;
  607. }
  608. static void handle_packet_response(struct hpsb_host *host, int tcode,
  609. quadlet_t *data, size_t size)
  610. {
  611. struct hpsb_packet *packet;
  612. int tlabel = (data[0] >> 10) & 0x3f;
  613. size_t header_size;
  614. unsigned long flags;
  615. spin_lock_irqsave(&pending_packets_lock, flags);
  616. list_for_each_entry(packet, &host->pending_packets, queue)
  617. if (packet->tlabel == tlabel &&
  618. packet->node_id == (data[1] >> 16))
  619. goto found;
  620. spin_unlock_irqrestore(&pending_packets_lock, flags);
  621. HPSB_DEBUG("unsolicited response packet received - %s",
  622. "no tlabel match");
  623. dump_packet("contents", data, 16, -1);
  624. return;
  625. found:
  626. switch (packet->tcode) {
  627. case TCODE_WRITEQ:
  628. case TCODE_WRITEB:
  629. if (unlikely(tcode != TCODE_WRITE_RESPONSE))
  630. break;
  631. header_size = 12;
  632. size = 0;
  633. goto dequeue;
  634. case TCODE_READQ:
  635. if (unlikely(tcode != TCODE_READQ_RESPONSE))
  636. break;
  637. header_size = 16;
  638. size = 0;
  639. goto dequeue;
  640. case TCODE_READB:
  641. if (unlikely(tcode != TCODE_READB_RESPONSE))
  642. break;
  643. header_size = 16;
  644. size = packet_size_to_data_size(size, header_size,
  645. packet->allocated_data_size,
  646. tcode);
  647. goto dequeue;
  648. case TCODE_LOCK_REQUEST:
  649. if (unlikely(tcode != TCODE_LOCK_RESPONSE))
  650. break;
  651. header_size = 16;
  652. size = packet_size_to_data_size(min(size, (size_t)(16 + 8)),
  653. header_size,
  654. packet->allocated_data_size,
  655. tcode);
  656. goto dequeue;
  657. }
  658. spin_unlock_irqrestore(&pending_packets_lock, flags);
  659. HPSB_DEBUG("unsolicited response packet received - %s",
  660. "tcode mismatch");
  661. dump_packet("contents", data, 16, -1);
  662. return;
  663. dequeue:
  664. list_del_init(&packet->queue);
  665. spin_unlock_irqrestore(&pending_packets_lock, flags);
  666. if (packet->state == hpsb_queued) {
  667. packet->sendtime = jiffies;
  668. packet->ack_code = ACK_PENDING;
  669. }
  670. packet->state = hpsb_complete;
  671. memcpy(packet->header, data, header_size);
  672. if (size)
  673. memcpy(packet->data, data + 4, size);
  674. queue_packet_complete(packet);
  675. }
  676. static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
  677. quadlet_t *data, size_t dsize)
  678. {
  679. struct hpsb_packet *p;
  680. p = hpsb_alloc_packet(dsize);
  681. if (unlikely(p == NULL)) {
  682. /* FIXME - send data_error response */
  683. HPSB_ERR("out of memory, cannot send response packet");
  684. return NULL;
  685. }
  686. p->type = hpsb_async;
  687. p->state = hpsb_unused;
  688. p->host = host;
  689. p->node_id = data[1] >> 16;
  690. p->tlabel = (data[0] >> 10) & 0x3f;
  691. p->no_waiter = 1;
  692. p->generation = get_hpsb_generation(host);
  693. if (dsize % 4)
  694. p->data[dsize / 4] = 0;
  695. return p;
  696. }
  697. #define PREP_ASYNC_HEAD_RCODE(tc) \
  698. packet->tcode = tc; \
  699. packet->header[0] = (packet->node_id << 16) | (packet->tlabel << 10) \
  700. | (1 << 8) | (tc << 4); \
  701. packet->header[1] = (packet->host->node_id << 16) | (rcode << 12); \
  702. packet->header[2] = 0
  703. static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
  704. quadlet_t data)
  705. {
  706. PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE);
  707. packet->header[3] = data;
  708. packet->header_size = 16;
  709. packet->data_size = 0;
  710. }
  711. static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode,
  712. int length)
  713. {
  714. if (rcode != RCODE_COMPLETE)
  715. length = 0;
  716. PREP_ASYNC_HEAD_RCODE(TCODE_READB_RESPONSE);
  717. packet->header[3] = length << 16;
  718. packet->header_size = 16;
  719. packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0);
  720. }
  721. static void fill_async_write_resp(struct hpsb_packet *packet, int rcode)
  722. {
  723. PREP_ASYNC_HEAD_RCODE(TCODE_WRITE_RESPONSE);
  724. packet->header_size = 12;
  725. packet->data_size = 0;
  726. }
  727. static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode,
  728. int length)
  729. {
  730. if (rcode != RCODE_COMPLETE)
  731. length = 0;
  732. PREP_ASYNC_HEAD_RCODE(TCODE_LOCK_RESPONSE);
  733. packet->header[3] = (length << 16) | extcode;
  734. packet->header_size = 16;
  735. packet->data_size = length;
  736. }
  737. static void handle_incoming_packet(struct hpsb_host *host, int tcode,
  738. quadlet_t *data, size_t size,
  739. int write_acked)
  740. {
  741. struct hpsb_packet *packet;
  742. int length, rcode, extcode;
  743. quadlet_t buffer;
  744. nodeid_t source = data[1] >> 16;
  745. nodeid_t dest = data[0] >> 16;
  746. u16 flags = (u16) data[0];
  747. u64 addr;
  748. /* FIXME?
  749. * Out-of-bounds lengths are left for highlevel_read|write to cap. */
  750. switch (tcode) {
  751. case TCODE_WRITEQ:
  752. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  753. rcode = highlevel_write(host, source, dest, data + 3,
  754. addr, 4, flags);
  755. goto handle_write_request;
  756. case TCODE_WRITEB:
  757. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  758. rcode = highlevel_write(host, source, dest, data + 4,
  759. addr, data[3] >> 16, flags);
  760. handle_write_request:
  761. if (rcode < 0 || write_acked ||
  762. NODEID_TO_NODE(data[0] >> 16) == NODE_MASK)
  763. return;
  764. /* not a broadcast write, reply */
  765. packet = create_reply_packet(host, data, 0);
  766. if (packet) {
  767. fill_async_write_resp(packet, rcode);
  768. send_packet_nocare(packet);
  769. }
  770. return;
  771. case TCODE_READQ:
  772. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  773. rcode = highlevel_read(host, source, &buffer, addr, 4, flags);
  774. if (rcode < 0)
  775. return;
  776. packet = create_reply_packet(host, data, 0);
  777. if (packet) {
  778. fill_async_readquad_resp(packet, rcode, buffer);
  779. send_packet_nocare(packet);
  780. }
  781. return;
  782. case TCODE_READB:
  783. length = data[3] >> 16;
  784. packet = create_reply_packet(host, data, length);
  785. if (!packet)
  786. return;
  787. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  788. rcode = highlevel_read(host, source, packet->data, addr,
  789. length, flags);
  790. if (rcode < 0) {
  791. hpsb_free_packet(packet);
  792. return;
  793. }
  794. fill_async_readblock_resp(packet, rcode, length);
  795. send_packet_nocare(packet);
  796. return;
  797. case TCODE_LOCK_REQUEST:
  798. length = data[3] >> 16;
  799. extcode = data[3] & 0xffff;
  800. addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
  801. packet = create_reply_packet(host, data, 8);
  802. if (!packet)
  803. return;
  804. if (extcode == 0 || extcode >= 7) {
  805. /* let switch default handle error */
  806. length = 0;
  807. }
  808. switch (length) {
  809. case 4:
  810. rcode = highlevel_lock(host, source, packet->data, addr,
  811. data[4], 0, extcode, flags);
  812. fill_async_lock_resp(packet, rcode, extcode, 4);
  813. break;
  814. case 8:
  815. if (extcode != EXTCODE_FETCH_ADD &&
  816. extcode != EXTCODE_LITTLE_ADD) {
  817. rcode = highlevel_lock(host, source,
  818. packet->data, addr,
  819. data[5], data[4],
  820. extcode, flags);
  821. fill_async_lock_resp(packet, rcode, extcode, 4);
  822. } else {
  823. rcode = highlevel_lock64(host, source,
  824. (octlet_t *)packet->data, addr,
  825. *(octlet_t *)(data + 4), 0ULL,
  826. extcode, flags);
  827. fill_async_lock_resp(packet, rcode, extcode, 8);
  828. }
  829. break;
  830. case 16:
  831. rcode = highlevel_lock64(host, source,
  832. (octlet_t *)packet->data, addr,
  833. *(octlet_t *)(data + 6),
  834. *(octlet_t *)(data + 4),
  835. extcode, flags);
  836. fill_async_lock_resp(packet, rcode, extcode, 8);
  837. break;
  838. default:
  839. rcode = RCODE_TYPE_ERROR;
  840. fill_async_lock_resp(packet, rcode, extcode, 0);
  841. }
  842. if (rcode < 0)
  843. hpsb_free_packet(packet);
  844. else
  845. send_packet_nocare(packet);
  846. return;
  847. }
  848. }
  849. /**
  850. * hpsb_packet_received - hand over received packet to the core
  851. *
  852. * For host driver module usage.
  853. *
  854. * The contents of data are expected to be the full packet but with the CRCs
  855. * left out (data block follows header immediately), with the header (i.e. the
  856. * first four quadlets) in machine byte order and the data block in big endian.
  857. * *@data can be safely overwritten after this call.
  858. *
  859. * If the packet is a write request, @write_acked is to be set to true if it was
  860. * ack_complete'd already, false otherwise. This argument is ignored for any
  861. * other packet type.
  862. */
  863. void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
  864. int write_acked)
  865. {
  866. int tcode;
  867. if (unlikely(host->in_bus_reset)) {
  868. HPSB_DEBUG("received packet during reset; ignoring");
  869. return;
  870. }
  871. dump_packet("received packet", data, size, -1);
  872. tcode = (data[0] >> 4) & 0xf;
  873. switch (tcode) {
  874. case TCODE_WRITE_RESPONSE:
  875. case TCODE_READQ_RESPONSE:
  876. case TCODE_READB_RESPONSE:
  877. case TCODE_LOCK_RESPONSE:
  878. handle_packet_response(host, tcode, data, size);
  879. break;
  880. case TCODE_WRITEQ:
  881. case TCODE_WRITEB:
  882. case TCODE_READQ:
  883. case TCODE_READB:
  884. case TCODE_LOCK_REQUEST:
  885. handle_incoming_packet(host, tcode, data, size, write_acked);
  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. while (!kthread_should_stop()) {
  972. INIT_LIST_HEAD(&tmp);
  973. spin_lock_irq(&pending_packets_lock);
  974. list_splice_init(&hpsbpkt_queue, &tmp);
  975. spin_unlock_irq(&pending_packets_lock);
  976. list_for_each_entry_safe(packet, p, &tmp, queue) {
  977. list_del_init(&packet->queue);
  978. packet->complete_routine(packet->complete_data);
  979. }
  980. set_current_state(TASK_INTERRUPTIBLE);
  981. spin_lock_irq(&pending_packets_lock);
  982. may_schedule = list_empty(&hpsbpkt_queue);
  983. spin_unlock_irq(&pending_packets_lock);
  984. if (may_schedule)
  985. schedule();
  986. __set_current_state(TASK_RUNNING);
  987. }
  988. return 0;
  989. }
  990. static int __init ieee1394_init(void)
  991. {
  992. int i, ret;
  993. /* non-fatal error */
  994. if (hpsb_init_config_roms()) {
  995. HPSB_ERR("Failed to initialize some config rom entries.\n");
  996. HPSB_ERR("Some features may not be available\n");
  997. }
  998. khpsbpkt_thread = kthread_run(hpsbpkt_thread, NULL, "khpsbpkt");
  999. if (IS_ERR(khpsbpkt_thread)) {
  1000. HPSB_ERR("Failed to start hpsbpkt thread!\n");
  1001. ret = PTR_ERR(khpsbpkt_thread);
  1002. goto exit_cleanup_config_roms;
  1003. }
  1004. if (register_chrdev_region(IEEE1394_CORE_DEV, 256, "ieee1394")) {
  1005. HPSB_ERR("unable to register character device major %d!\n", IEEE1394_MAJOR);
  1006. ret = -ENODEV;
  1007. goto exit_release_kernel_thread;
  1008. }
  1009. ret = bus_register(&ieee1394_bus_type);
  1010. if (ret < 0) {
  1011. HPSB_INFO("bus register failed");
  1012. goto release_chrdev;
  1013. }
  1014. for (i = 0; fw_bus_attrs[i]; i++) {
  1015. ret = bus_create_file(&ieee1394_bus_type, fw_bus_attrs[i]);
  1016. if (ret < 0) {
  1017. while (i >= 0) {
  1018. bus_remove_file(&ieee1394_bus_type,
  1019. fw_bus_attrs[i--]);
  1020. }
  1021. bus_unregister(&ieee1394_bus_type);
  1022. goto release_chrdev;
  1023. }
  1024. }
  1025. ret = class_register(&hpsb_host_class);
  1026. if (ret < 0)
  1027. goto release_all_bus;
  1028. hpsb_protocol_class = class_create(THIS_MODULE, "ieee1394_protocol");
  1029. if (IS_ERR(hpsb_protocol_class)) {
  1030. ret = PTR_ERR(hpsb_protocol_class);
  1031. goto release_class_host;
  1032. }
  1033. ret = init_csr();
  1034. if (ret) {
  1035. HPSB_INFO("init csr failed");
  1036. ret = -ENOMEM;
  1037. goto release_class_protocol;
  1038. }
  1039. if (disable_nodemgr) {
  1040. HPSB_INFO("nodemgr and IRM functionality disabled");
  1041. /* We shouldn't contend for IRM with nodemgr disabled, since
  1042. nodemgr implements functionality required of ieee1394a-2000
  1043. IRMs */
  1044. hpsb_disable_irm = 1;
  1045. return 0;
  1046. }
  1047. if (hpsb_disable_irm) {
  1048. HPSB_INFO("IRM functionality disabled");
  1049. }
  1050. ret = init_ieee1394_nodemgr();
  1051. if (ret < 0) {
  1052. HPSB_INFO("init nodemgr failed");
  1053. goto cleanup_csr;
  1054. }
  1055. return 0;
  1056. cleanup_csr:
  1057. cleanup_csr();
  1058. release_class_protocol:
  1059. class_destroy(hpsb_protocol_class);
  1060. release_class_host:
  1061. class_unregister(&hpsb_host_class);
  1062. release_all_bus:
  1063. for (i = 0; fw_bus_attrs[i]; i++)
  1064. bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
  1065. bus_unregister(&ieee1394_bus_type);
  1066. release_chrdev:
  1067. unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
  1068. exit_release_kernel_thread:
  1069. kthread_stop(khpsbpkt_thread);
  1070. exit_cleanup_config_roms:
  1071. hpsb_cleanup_config_roms();
  1072. return ret;
  1073. }
  1074. static void __exit ieee1394_cleanup(void)
  1075. {
  1076. int i;
  1077. if (!disable_nodemgr)
  1078. cleanup_ieee1394_nodemgr();
  1079. cleanup_csr();
  1080. class_destroy(hpsb_protocol_class);
  1081. class_unregister(&hpsb_host_class);
  1082. for (i = 0; fw_bus_attrs[i]; i++)
  1083. bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
  1084. bus_unregister(&ieee1394_bus_type);
  1085. kthread_stop(khpsbpkt_thread);
  1086. hpsb_cleanup_config_roms();
  1087. unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
  1088. }
  1089. fs_initcall(ieee1394_init);
  1090. module_exit(ieee1394_cleanup);
  1091. /* Exported symbols */
  1092. /** hosts.c **/
  1093. EXPORT_SYMBOL(hpsb_alloc_host);
  1094. EXPORT_SYMBOL(hpsb_add_host);
  1095. EXPORT_SYMBOL(hpsb_resume_host);
  1096. EXPORT_SYMBOL(hpsb_remove_host);
  1097. EXPORT_SYMBOL(hpsb_update_config_rom_image);
  1098. /** ieee1394_core.c **/
  1099. EXPORT_SYMBOL(hpsb_speedto_str);
  1100. EXPORT_SYMBOL(hpsb_protocol_class);
  1101. EXPORT_SYMBOL(hpsb_set_packet_complete_task);
  1102. EXPORT_SYMBOL(hpsb_alloc_packet);
  1103. EXPORT_SYMBOL(hpsb_free_packet);
  1104. EXPORT_SYMBOL(hpsb_send_packet);
  1105. EXPORT_SYMBOL(hpsb_reset_bus);
  1106. EXPORT_SYMBOL(hpsb_read_cycle_timer);
  1107. EXPORT_SYMBOL(hpsb_bus_reset);
  1108. EXPORT_SYMBOL(hpsb_selfid_received);
  1109. EXPORT_SYMBOL(hpsb_selfid_complete);
  1110. EXPORT_SYMBOL(hpsb_packet_sent);
  1111. EXPORT_SYMBOL(hpsb_packet_received);
  1112. EXPORT_SYMBOL_GPL(hpsb_disable_irm);
  1113. /** ieee1394_transactions.c **/
  1114. EXPORT_SYMBOL(hpsb_get_tlabel);
  1115. EXPORT_SYMBOL(hpsb_free_tlabel);
  1116. EXPORT_SYMBOL(hpsb_make_readpacket);
  1117. EXPORT_SYMBOL(hpsb_make_writepacket);
  1118. EXPORT_SYMBOL(hpsb_make_streampacket);
  1119. EXPORT_SYMBOL(hpsb_make_lockpacket);
  1120. EXPORT_SYMBOL(hpsb_make_lock64packet);
  1121. EXPORT_SYMBOL(hpsb_make_phypacket);
  1122. EXPORT_SYMBOL(hpsb_read);
  1123. EXPORT_SYMBOL(hpsb_write);
  1124. EXPORT_SYMBOL(hpsb_lock);
  1125. EXPORT_SYMBOL(hpsb_packet_success);
  1126. /** highlevel.c **/
  1127. EXPORT_SYMBOL(hpsb_register_highlevel);
  1128. EXPORT_SYMBOL(hpsb_unregister_highlevel);
  1129. EXPORT_SYMBOL(hpsb_register_addrspace);
  1130. EXPORT_SYMBOL(hpsb_unregister_addrspace);
  1131. EXPORT_SYMBOL(hpsb_allocate_and_register_addrspace);
  1132. EXPORT_SYMBOL(hpsb_get_hostinfo);
  1133. EXPORT_SYMBOL(hpsb_create_hostinfo);
  1134. EXPORT_SYMBOL(hpsb_destroy_hostinfo);
  1135. EXPORT_SYMBOL(hpsb_set_hostinfo_key);
  1136. EXPORT_SYMBOL(hpsb_get_hostinfo_bykey);
  1137. EXPORT_SYMBOL(hpsb_set_hostinfo);
  1138. /** nodemgr.c **/
  1139. EXPORT_SYMBOL(hpsb_node_fill_packet);
  1140. EXPORT_SYMBOL(hpsb_node_write);
  1141. EXPORT_SYMBOL(__hpsb_register_protocol);
  1142. EXPORT_SYMBOL(hpsb_unregister_protocol);
  1143. /** csr.c **/
  1144. EXPORT_SYMBOL(hpsb_update_config_rom);
  1145. /** dma.c **/
  1146. EXPORT_SYMBOL(dma_prog_region_init);
  1147. EXPORT_SYMBOL(dma_prog_region_alloc);
  1148. EXPORT_SYMBOL(dma_prog_region_free);
  1149. EXPORT_SYMBOL(dma_region_init);
  1150. EXPORT_SYMBOL(dma_region_alloc);
  1151. EXPORT_SYMBOL(dma_region_free);
  1152. EXPORT_SYMBOL(dma_region_sync_for_cpu);
  1153. EXPORT_SYMBOL(dma_region_sync_for_device);
  1154. EXPORT_SYMBOL(dma_region_mmap);
  1155. EXPORT_SYMBOL(dma_region_offset_to_bus);
  1156. /** iso.c **/
  1157. EXPORT_SYMBOL(hpsb_iso_xmit_init);
  1158. EXPORT_SYMBOL(hpsb_iso_recv_init);
  1159. EXPORT_SYMBOL(hpsb_iso_xmit_start);
  1160. EXPORT_SYMBOL(hpsb_iso_recv_start);
  1161. EXPORT_SYMBOL(hpsb_iso_recv_listen_channel);
  1162. EXPORT_SYMBOL(hpsb_iso_recv_unlisten_channel);
  1163. EXPORT_SYMBOL(hpsb_iso_recv_set_channel_mask);
  1164. EXPORT_SYMBOL(hpsb_iso_stop);
  1165. EXPORT_SYMBOL(hpsb_iso_shutdown);
  1166. EXPORT_SYMBOL(hpsb_iso_xmit_queue_packet);
  1167. EXPORT_SYMBOL(hpsb_iso_xmit_sync);
  1168. EXPORT_SYMBOL(hpsb_iso_recv_release_packets);
  1169. EXPORT_SYMBOL(hpsb_iso_n_ready);
  1170. EXPORT_SYMBOL(hpsb_iso_packet_sent);
  1171. EXPORT_SYMBOL(hpsb_iso_packet_received);
  1172. EXPORT_SYMBOL(hpsb_iso_wake);
  1173. EXPORT_SYMBOL(hpsb_iso_recv_flush);
  1174. /** csr1212.c **/
  1175. EXPORT_SYMBOL(csr1212_attach_keyval_to_directory);
  1176. EXPORT_SYMBOL(csr1212_detach_keyval_from_directory);
  1177. EXPORT_SYMBOL(csr1212_get_keyval);
  1178. EXPORT_SYMBOL(csr1212_new_directory);
  1179. EXPORT_SYMBOL(csr1212_parse_keyval);
  1180. EXPORT_SYMBOL(csr1212_read);
  1181. EXPORT_SYMBOL(csr1212_release_keyval);