ieee1394_core.c 39 KB

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