1/* 2 * Node information (ConfigROM) collection and management. 3 * 4 * Copyright (C) 2000 Andreas E. Bombe 5 * 2001 Ben Collins <bcollins@debian.net> 6 * 7 * This code is licensed under the GPL. See the file COPYING in the root 8 * directory of the kernel sources for details. 9 */ 10 11#include <linux/kernel.h> 12#include <linux/list.h> 13#include <linux/slab.h> 14#include <asm/byteorder.h> 15#include <linux/smp_lock.h> 16#include <linux/interrupt.h> 17#include <linux/kmod.h> 18#include <linux/completion.h> 19#include <linux/delay.h> 20#ifdef CONFIG_PROC_FS 21#include <linux/proc_fs.h> 22#endif 23 24#include "ieee1394_types.h" 25#include "ieee1394.h" 26#include "hosts.h" 27#include "ieee1394_transactions.h" 28#include "ieee1394_hotplug.h" 29#include "highlevel.h" 30#include "csr.h" 31#include "nodemgr.h" 32 33 34/* 35 * Basically what we do here is start off retrieving the bus_info block. 36 * From there will fill in some info about the node, verify it is of IEEE 37 * 1394 type, and that the crc checks out ok. After that we start off with 38 * the root directory, and subdirectories. To do this, we retrieve the 39 * quadlet header for a directory, find out the length, and retrieve the 40 * complete directory entry (be it a leaf or a directory). We then process 41 * it and add the info to our structure for that particular node. 42 * 43 * We verify CRC's along the way for each directory/block/leaf. The 44 * entire node structure is generic, and simply stores the information in 45 * a way that's easy to parse by the protocol interface. 46 */ 47 48/* The nodemgr maintains a number of data structures: the node list, 49 * the driver list, unit directory list and the host info list. The 50 * first three lists are accessed from process context only: /proc 51 * readers, insmod and rmmod, and the nodemgr thread. Access to these 52 * lists are serialized by means of the nodemgr_serialize mutex, which 53 * must be taken before accessing the structures and released 54 * afterwards. The host info list is only accessed during insmod, 55 * rmmod and from interrupt and allways only for a short period of 56 * time, so a spinlock is used to protect this list. 57 */ 58 59static DECLARE_MUTEX(nodemgr_serialize); 60static LIST_HEAD(node_list); 61static LIST_HEAD(driver_list); 62static LIST_HEAD(unit_directory_list); 63 64static LIST_HEAD(host_info_list); 65static spinlock_t host_info_lock = SPIN_LOCK_UNLOCKED; 66 67/* Disables use of the hotplug calls. */ 68static int nodemgr_disable_hotplug = 0; 69 70struct host_info { 71 struct hpsb_host *host; 72 struct list_head list; 73 struct completion exited; 74 struct semaphore reset_sem; 75 int pid; 76}; 77 78#ifdef CONFIG_PROC_FS 79 80#define PUTF(fmt, args...) out += sprintf(out, fmt, ## args) 81 82static int raw1394_read_proc(char *page, char **start, off_t off, 83 int count, int *eof, void *data) 84{ 85 struct list_head *lh; 86 struct node_entry *ne; 87 int len; 88 char *out = page; 89 90 if (down_interruptible(&nodemgr_serialize)) 91 return -EINTR; 92 93 list_for_each(lh, &node_list) { 94 struct list_head *l; 95 int ud_count = 0; 96 97 ne = list_entry(lh, struct node_entry, list); 98 if (!ne) 99 continue; 100 101 PUTF("Node[" NODE_BUS_FMT "] GUID[%016Lx]:\n", 102 NODE_BUS_ARGS(ne->nodeid), (unsigned long long)ne->guid); 103 104 /* Generic Node information */ 105 PUTF(" Vendor ID: `%s' [0x%06x]\n", 106 ne->vendor_name ?: "Unknown", ne->vendor_id); 107 PUTF(" Capabilities: 0x%06x\n", ne->capabilities); 108 PUTF(" Bus Options:\n"); 109 PUTF(" IRMC(%d) CMC(%d) ISC(%d) BMC(%d) PMC(%d) GEN(%d)\n" 110 " LSPD(%d) MAX_REC(%d) CYC_CLK_ACC(%d)\n", 111 ne->busopt.irmc, ne->busopt.cmc, ne->busopt.isc, ne->busopt.bmc, 112 ne->busopt.pmc, ne->busopt.generation, ne->busopt.lnkspd, 113 ne->busopt.max_rec, ne->busopt.cyc_clk_acc); 114 115 /* If this is the host entry, output some info about it aswell */ 116 if (ne->host != NULL && ne->host->node_id == ne->nodeid) { 117 PUTF(" Host Node Status:\n"); 118 PUTF(" Host Driver : %s\n", ne->host->driver->name); 119 PUTF(" Nodes connected : %d\n", ne->host->node_count); 120 PUTF(" Nodes active : %d\n", ne->host->nodes_active); 121 PUTF(" SelfIDs received: %d\n", ne->host->selfid_count); 122 PUTF(" Irm ID : [" NODE_BUS_FMT "]\n", 123 NODE_BUS_ARGS(ne->host->irm_id)); 124 PUTF(" BusMgr ID : [" NODE_BUS_FMT "]\n", 125 NODE_BUS_ARGS(ne->host->busmgr_id)); 126 PUTF(" In Bus Reset : %s\n", ne->host->in_bus_reset ? "yes" : "no"); 127 PUTF(" Root : %s\n", ne->host->is_root ? "yes" : "no"); 128 PUTF(" Cycle Master : %s\n", ne->host->is_cycmst ? "yes" : "no"); 129 PUTF(" IRM : %s\n", ne->host->is_irm ? "yes" : "no"); 130 PUTF(" Bus Manager : %s\n", ne->host->is_busmgr ? "yes" : "no"); 131 } 132 133 /* Now the unit directories */ 134 list_for_each (l, &ne->unit_directories) { 135 struct unit_directory *ud = list_entry (l, struct unit_directory, node_list); 136 int printed = 0; // small hack 137 138 PUTF(" Unit Directory %d:\n", ud_count++); 139 if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) { 140 PUTF(" Vendor/Model ID: %s [%06x]", 141 ud->vendor_name ?: "Unknown", ud->vendor_id); 142 printed = 1; 143 } 144 if (ud->flags & UNIT_DIRECTORY_MODEL_ID) { 145 if (!printed) 146 PUTF(" Vendor/Model ID: %s [%06x]", 147 ne->vendor_name ?: "Unknown", ne->vendor_id); 148 PUTF(" / %s [%06x]", ud->model_name ?: "Unknown", ud->model_id); 149 printed = 1; 150 } 151 if (printed) 152 PUTF("\n"); 153 154 if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID) 155 PUTF(" Software Specifier ID: %06x\n", ud->specifier_id); 156 if (ud->flags & UNIT_DIRECTORY_VERSION) 157 PUTF(" Software Version: %06x\n", ud->version); 158 if (ud->driver) 159 PUTF(" Driver: %s\n", ud->driver->name); 160 PUTF(" Length (in quads): %d\n", ud->count); 161 } 162 163 } 164 165 up(&nodemgr_serialize); 166 167 len = out - page; 168 len -= off; 169 if (len < count) { 170 *eof = 1; 171 if (len <= 0) 172 return 0; 173 } else 174 len = count; 175 176 *start = page + off; 177 178 return len; 179} 180 181#undef PUTF 182#endif /* CONFIG_PROC_FS */ 183 184static void nodemgr_process_config_rom(struct node_entry *ne, 185 quadlet_t busoptions); 186 187static int nodemgr_read_quadlet(struct hpsb_host *host, 188 nodeid_t nodeid, unsigned int generation, 189 octlet_t address, quadlet_t *quad) 190{ 191 int i; 192 int ret = 0; 193 194 for (i = 0; i < 3; i++) { 195 ret = hpsb_read(host, nodeid, generation, address, quad, 4); 196 if (!ret) 197 break; 198 199 set_current_state(TASK_INTERRUPTIBLE); 200 if (schedule_timeout (HZ/3)) 201 return -1; 202 } 203 *quad = be32_to_cpu(*quad); 204 205 return ret; 206} 207 208static int nodemgr_size_text_leaf(struct hpsb_host *host, 209 nodeid_t nodeid, unsigned int generation, 210 octlet_t address) 211{ 212 quadlet_t quad; 213 int size = 0; 214 215 if (nodemgr_read_quadlet(host, nodeid, generation, address, &quad)) 216 return -1; 217 218 if (CONFIG_ROM_KEY(quad) == CONFIG_ROM_DESCRIPTOR_LEAF) { 219 /* This is the offset. */ 220 address += 4 * CONFIG_ROM_VALUE(quad); 221 if (nodemgr_read_quadlet(host, nodeid, generation, address, &quad)) 222 return -1; 223 /* Now we got the size of the text descriptor leaf. */ 224 size = CONFIG_ROM_LEAF_LENGTH(quad); 225 } 226 227 return size; 228} 229 230static int nodemgr_read_text_leaf(struct node_entry *ne, 231 octlet_t address, 232 quadlet_t *quadp) 233{ 234 quadlet_t quad; 235 int i, size, ret; 236 237 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, address, &quad) 238 || CONFIG_ROM_KEY(quad) != CONFIG_ROM_DESCRIPTOR_LEAF) 239 return -1; 240 241 /* This is the offset. */ 242 address += 4 * CONFIG_ROM_VALUE(quad); 243 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, address, &quad)) 244 return -1; 245 246 /* Now we got the size of the text descriptor leaf. */ 247 size = CONFIG_ROM_LEAF_LENGTH(quad) - 2; 248 if (size <= 0) 249 return -1; 250 251 address += 4; 252 for (i = 0; i < 2; i++, address += 4, quadp++) { 253 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, address, quadp)) 254 return -1; 255 } 256 257 /* Now read the text string. */ 258 ret = -ENXIO; 259 for (; size > 0; size--, address += 4, quadp++) { 260 for (i = 0; i < 3; i++) { 261 ret = hpsb_read(ne->host, ne->nodeid, ne->generation, address, quadp, 4); 262 if (ret != -EAGAIN) 263 break; 264 } 265 if (ret) 266 break; 267 } 268 269 return ret; 270} 271 272static struct node_entry *nodemgr_scan_root_directory 273 (struct hpsb_host *host, nodeid_t nodeid, unsigned int generation) 274{ 275 octlet_t address; 276 quadlet_t quad; 277 int length; 278 int code, size, total_size; 279 struct node_entry *ne; 280 281 address = CSR_REGISTER_BASE + CSR_CONFIG_ROM; 282 283 if (nodemgr_read_quadlet(host, nodeid, generation, address, &quad)) 284 return NULL; 285 address += 4 + CONFIG_ROM_BUS_INFO_LENGTH(quad) * 4; 286 287 if (nodemgr_read_quadlet(host, nodeid, generation, address, &quad)) 288 return NULL; 289 length = CONFIG_ROM_ROOT_LENGTH(quad); 290 address += 4; 291 292 size = 0; 293 total_size = sizeof(struct node_entry); 294 for (; length > 0; length--, address += 4) { 295 if (nodemgr_read_quadlet(host, nodeid, generation, address, &quad)) 296 return NULL; 297 code = CONFIG_ROM_KEY(quad); 298 299 if (code == CONFIG_ROM_VENDOR_ID && length > 0) { 300 /* Check if there is a text descriptor leaf 301 immediately after this. */ 302 size = nodemgr_size_text_leaf(host, nodeid, generation, 303 address + 4); 304 if (size > 0) { 305 address += 4; 306 length--; 307 total_size += (size + 1) * sizeof (quadlet_t); 308 } 309 else if (size < 0) 310 return NULL; 311 } 312 } 313 ne = kmalloc(total_size, SLAB_ATOMIC); 314 if (ne != NULL) { 315 if (size != 0) { 316 ne->vendor_name 317 = (const char *) &(ne->quadlets[2]); 318 ne->quadlets[size] = 0; 319 } 320 else { 321 ne->vendor_name = NULL; 322 } 323 } 324 return ne; 325} 326 327static struct node_entry *nodemgr_create_node(octlet_t guid, quadlet_t busoptions, 328 struct hpsb_host *host, 329 nodeid_t nodeid, unsigned int generation) 330{ 331 struct node_entry *ne; 332 333 ne = nodemgr_scan_root_directory (host, nodeid, generation); 334 if (!ne) return NULL; 335 336 INIT_LIST_HEAD(&ne->list); 337 INIT_LIST_HEAD(&ne->unit_directories); 338 ne->host = host; 339 ne->nodeid = nodeid; 340 ne->guid = guid; 341 ne->generation = generation; 342 343 list_add_tail(&ne->list, &node_list); 344 345 nodemgr_process_config_rom (ne, busoptions); 346 347 HPSB_DEBUG("%s added: Node[" NODE_BUS_FMT "] GUID[%016Lx] [%s]", 348 (host->node_id == nodeid) ? "Host" : "Device", 349 NODE_BUS_ARGS(nodeid), (unsigned long long)guid, 350 ne->vendor_name ?: "Unknown"); 351 352 return ne; 353} 354 355static struct node_entry *find_entry_by_guid(u64 guid) 356{ 357 struct list_head *lh; 358 struct node_entry *ne; 359 360 list_for_each(lh, &node_list) { 361 ne = list_entry(lh, struct node_entry, list); 362 if (ne->guid == guid) return ne; 363 } 364 365 return NULL; 366} 367 368static struct node_entry *find_entry_by_nodeid(nodeid_t nodeid) 369{ 370 struct list_head *lh; 371 struct node_entry *ne; 372 373 list_for_each(lh, &node_list) { 374 ne = list_entry(lh, struct node_entry, list); 375 if (ne->nodeid == nodeid) return ne; 376 } 377 378 return NULL; 379} 380 381static struct unit_directory *nodemgr_scan_unit_directory 382 (struct node_entry *ne, octlet_t address) 383{ 384 struct unit_directory *ud; 385 quadlet_t quad; 386 u8 flags, todo; 387 int length, size, total_size, count; 388 int vendor_name_size, model_name_size; 389 390 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, address, &quad)) 391 return NULL; 392 length = CONFIG_ROM_DIRECTORY_LENGTH(quad) ; 393 address += 4; 394 395 size = 0; 396 total_size = sizeof (struct unit_directory); 397 flags = 0; 398 count = 0; 399 vendor_name_size = 0; 400 model_name_size = 0; 401 for (; length > 0; length--, address += 4) { 402 int code; 403 quadlet_t value; 404 405 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, 406 address, &quad)) 407 return NULL; 408 code = CONFIG_ROM_KEY(quad); 409 value = CONFIG_ROM_VALUE(quad); 410 411 todo = 0; 412 switch (code) { 413 case CONFIG_ROM_VENDOR_ID: 414 todo = UNIT_DIRECTORY_VENDOR_TEXT; 415 break; 416 417 case CONFIG_ROM_MODEL_ID: 418 todo = UNIT_DIRECTORY_MODEL_TEXT; 419 break; 420 421 case CONFIG_ROM_SPECIFIER_ID: 422 case CONFIG_ROM_UNIT_SW_VERSION: 423 break; 424 425 case CONFIG_ROM_DESCRIPTOR_LEAF: 426 case CONFIG_ROM_DESCRIPTOR_DIRECTORY: 427 /* TODO: read strings... icons? */ 428 break; 429 430 default: 431 /* Which types of quadlets do we want to 432 store? Only count immediate values and 433 CSR offsets for now. */ 434 code &= CONFIG_ROM_KEY_TYPE_MASK; 435 if ((code & 0x80) == 0) 436 count++; 437 break; 438 } 439 440 if (todo && length > 0) { 441 /* Check if there is a text descriptor leaf 442 immediately after this. */ 443 size = nodemgr_size_text_leaf(ne->host, 444 ne->nodeid, 445 ne->generation, 446 address + 4); 447 448 if (todo == UNIT_DIRECTORY_VENDOR_TEXT) 449 vendor_name_size = size; 450 else 451 model_name_size = size; 452 453 if (size > 0) { 454 address += 4; 455 length--; 456 flags |= todo; 457 total_size += (size + 1) * sizeof (quadlet_t); 458 } 459 else if (size < 0) 460 return NULL; 461 } 462 } 463 total_size += count * sizeof (quadlet_t); 464 ud = kmalloc (total_size, GFP_KERNEL); 465 if (ud != NULL) { 466 memset (ud, 0, sizeof *ud); 467 ud->flags = flags; 468 ud->count = count; 469 ud->vendor_name_size = vendor_name_size; 470 ud->model_name_size = model_name_size; 471 /* If there is no vendor name in the unit directory, 472 use the one in the root directory. */ 473 ud->vendor_name = ne->vendor_name; 474 } 475 return ud; 476} 477 478/* This implementation currently only scans the config rom and its 479 * immediate unit directories looking for software_id and 480 * software_version entries, in order to get driver autoloading working. 481 */ 482 483static void nodemgr_process_unit_directory(struct node_entry *ne, 484 octlet_t address) 485{ 486 struct unit_directory *ud; 487 quadlet_t quad; 488 quadlet_t *infop; 489 int length; 490 491 if (!(ud = nodemgr_scan_unit_directory(ne, address))) 492 goto unit_directory_error; 493 494 ud->ne = ne; 495 ud->address = address; 496 497 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, 498 address, &quad)) 499 goto unit_directory_error; 500 length = CONFIG_ROM_DIRECTORY_LENGTH(quad) ; 501 address += 4; 502 503 infop = (quadlet_t *) ud->quadlets; 504 for (; length > 0; length--, address += 4, infop++) { 505 int code; 506 quadlet_t value; 507 quadlet_t *quadp; 508 509 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, 510 address, &quad)) 511 goto unit_directory_error; 512 code = CONFIG_ROM_KEY(quad) ; 513 value = CONFIG_ROM_VALUE(quad); 514 515 switch (code) { 516 case CONFIG_ROM_VENDOR_ID: 517 ud->vendor_id = value; 518 ud->flags |= UNIT_DIRECTORY_VENDOR_ID; 519 if ((ud->flags & UNIT_DIRECTORY_VENDOR_TEXT) != 0) { 520 length--; 521 address += 4; 522 quadp = &(ud->quadlets[ud->count]); 523 if (nodemgr_read_text_leaf(ne, address, 524 quadp) == 0 525 && quadp[0] == 0 526 && quadp[1] == 0) { 527 /* We only support minimal 528 ASCII and English. */ 529 quadp[ud->vendor_name_size] = 0; 530 ud->vendor_name 531 = (const char *) &(quadp[2]); 532 } 533 } 534 break; 535 536 case CONFIG_ROM_MODEL_ID: 537 ud->model_id = value; 538 ud->flags |= UNIT_DIRECTORY_MODEL_ID; 539 if ((ud->flags & UNIT_DIRECTORY_MODEL_TEXT) != 0) { 540 length--; 541 address += 4; 542 quadp = &(ud->quadlets[ud->count + ud->vendor_name_size + 1]); 543 if (nodemgr_read_text_leaf(ne, address, 544 quadp) == 0 545 && quadp[0] == 0 546 && quadp[1] == 0) { 547 /* We only support minimal 548 ASCII and English. */ 549 quadp[ud->model_name_size] = 0; 550 ud->model_name 551 = (const char *) &(quadp[2]); 552 } 553 } 554 break; 555 556 case CONFIG_ROM_SPECIFIER_ID: 557 ud->specifier_id = value; 558 ud->flags |= UNIT_DIRECTORY_SPECIFIER_ID; 559 break; 560 561 case CONFIG_ROM_UNIT_SW_VERSION: 562 ud->version = value; 563 ud->flags |= UNIT_DIRECTORY_VERSION; 564 break; 565 566 case CONFIG_ROM_DESCRIPTOR_LEAF: 567 case CONFIG_ROM_DESCRIPTOR_DIRECTORY: 568 /* TODO: read strings... icons? */ 569 break; 570 571 default: 572 /* Which types of quadlets do we want to 573 store? Only count immediate values and 574 CSR offsets for now. */ 575 code &= CONFIG_ROM_KEY_TYPE_MASK; 576 if ((code & 0x80) == 0) 577 *infop = quad; 578 break; 579 } 580 } 581 582 list_add_tail(&ud->node_list, &ne->unit_directories); 583 list_add_tail(&ud->driver_list, &unit_directory_list); 584 585 return; 586 587unit_directory_error: 588 if (ud != NULL) 589 kfree(ud); 590} 591 592static void dump_directories (struct node_entry *ne) 593{ 594#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 595 struct list_head *l; 596 597 HPSB_DEBUG("vendor_id=0x%06x [%s], capabilities=0x%06x", 598 ne->vendor_id, ne->vendor_name ?: "Unknown", 599 ne->capabilities); 600 list_for_each (l, &ne->unit_directories) { 601 struct unit_directory *ud = list_entry (l, struct unit_directory, node_list); 602 HPSB_DEBUG("unit directory:"); 603 if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) 604 HPSB_DEBUG(" vendor_id=0x%06x [%s]", 605 ud->vendor_id, 606 ud->vendor_name ?: "Unknown"); 607 if (ud->flags & UNIT_DIRECTORY_MODEL_ID) 608 HPSB_DEBUG(" model_id=0x%06x [%s]", 609 ud->model_id, 610 ud->model_name ?: "Unknown"); 611 if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID) 612 HPSB_DEBUG(" sw_specifier_id=0x%06x ", ud->specifier_id); 613 if (ud->flags & UNIT_DIRECTORY_VERSION) 614 HPSB_DEBUG(" sw_version=0x%06x ", ud->version); 615 } 616#endif 617 return; 618} 619 620static void nodemgr_process_root_directory(struct node_entry *ne) 621{ 622 octlet_t address; 623 quadlet_t quad; 624 int length; 625 626 address = CSR_REGISTER_BASE + CSR_CONFIG_ROM; 627 628 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, 629 address, &quad)) 630 return; 631 address += 4 + CONFIG_ROM_BUS_INFO_LENGTH(quad) * 4; 632 633 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, 634 address, &quad)) 635 return; 636 length = CONFIG_ROM_ROOT_LENGTH(quad); 637 address += 4; 638 639 for (; length > 0; length--, address += 4) { 640 int code, value; 641 642 if (nodemgr_read_quadlet(ne->host, ne->nodeid, ne->generation, 643 address, &quad)) 644 return; 645 code = CONFIG_ROM_KEY(quad); 646 value = CONFIG_ROM_VALUE(quad); 647 648 switch (code) { 649 case CONFIG_ROM_VENDOR_ID: 650 ne->vendor_id = value; 651 /* Now check if there is a vendor name text 652 string. */ 653 if (ne->vendor_name != NULL) { 654 length--; 655 address += 4; 656 if (nodemgr_read_text_leaf(ne, address, 657 ne->quadlets) 658 != 0 659 || ne->quadlets [0] != 0 660 || ne->quadlets [1] != 0) 661 /* We only support minimal 662 ASCII and English. */ 663 ne->vendor_name = NULL; 664 } 665 break; 666 667 case CONFIG_ROM_NODE_CAPABILITES: 668 ne->capabilities = value; 669 break; 670 671 case CONFIG_ROM_UNIT_DIRECTORY: 672 nodemgr_process_unit_directory(ne, address + value * 4); 673 break; 674 675 case CONFIG_ROM_DESCRIPTOR_LEAF: 676 case CONFIG_ROM_DESCRIPTOR_DIRECTORY: 677 /* TODO: read strings... icons? */ 678 break; 679 } 680 } 681 682 dump_directories(ne); 683} 684 685#ifdef CONFIG_HOTPLUG 686 687static void nodemgr_call_policy(char *verb, struct unit_directory *ud) 688{ 689 char *argv [3], **envp, *buf, *scratch; 690 int i = 0, value; 691 692 /* User requested to disable hotplug when module was loaded. */ 693 if (nodemgr_disable_hotplug) 694 return; 695 696 if (!hotplug_path [0]) 697 return; 698 if (!current->fs->root) 699 return; 700 if (!(envp = (char **) kmalloc(20 * sizeof (char *), GFP_KERNEL))) { 701 HPSB_DEBUG ("ENOMEM"); 702 return; 703 } 704 if (!(buf = kmalloc(256, GFP_KERNEL))) { 705 kfree(envp); 706 HPSB_DEBUG("ENOMEM2"); 707 return; 708 } 709 710 /* only one standardized param to hotplug command: type */ 711 argv[0] = hotplug_path; 712 argv[1] = "ieee1394"; 713 argv[2] = 0; 714 715 /* minimal command environment */ 716 envp[i++] = "HOME=/"; 717 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 718 719#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 720 /* hint that policy agent should enter no-stdout debug mode */ 721 envp[i++] = "DEBUG=kernel"; 722#endif 723 /* extensible set of named bus-specific parameters, 724 * supporting multiple driver selection algorithms. 725 */ 726 scratch = buf; 727 728 envp[i++] = scratch; 729 scratch += sprintf(scratch, "ACTION=%s", verb) + 1; 730 envp[i++] = scratch; 731 scratch += sprintf(scratch, "VENDOR_ID=%06x", ud->ne->vendor_id) + 1; 732 envp[i++] = scratch; 733 scratch += sprintf(scratch, "GUID=%016Lx", (long long unsigned)ud->ne->guid) + 1; 734 envp[i++] = scratch; 735 scratch += sprintf(scratch, "SPECIFIER_ID=%06x", ud->specifier_id) + 1; 736 envp[i++] = scratch; 737 scratch += sprintf(scratch, "VERSION=%06x", ud->version) + 1; 738 envp[i++] = 0; 739 740 /* NOTE: user mode daemons can call the agents too */ 741#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 742 HPSB_DEBUG("NodeMgr: %s %s %016Lx", argv[0], verb, (long long unsigned)ud->ne->guid); 743#endif 744 value = call_usermodehelper(argv[0], argv, envp); 745 kfree(buf); 746 kfree(envp); 747 if (value != 0) 748 HPSB_DEBUG("NodeMgr: hotplug policy returned %d", value); 749} 750 751#else 752 753static inline void 754nodemgr_call_policy(char *verb, struct unit_directory *ud) 755{ 756#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 757 HPSB_DEBUG("NodeMgr: nodemgr_call_policy(): hotplug not enabled"); 758#endif 759 return; 760} 761 762#endif /* CONFIG_HOTPLUG */ 763 764static void nodemgr_claim_unit_directory(struct unit_directory *ud, 765 struct hpsb_protocol_driver *driver) 766{ 767 ud->driver = driver; 768 list_del(&ud->driver_list); 769 list_add_tail(&ud->driver_list, &driver->unit_directories); 770} 771 772static void nodemgr_release_unit_directory(struct unit_directory *ud) 773{ 774 ud->driver = NULL; 775 list_del(&ud->driver_list); 776 list_add_tail(&ud->driver_list, &unit_directory_list); 777} 778 779void hpsb_release_unit_directory(struct unit_directory *ud) 780{ 781 down(&nodemgr_serialize); 782 nodemgr_release_unit_directory(ud); 783 up(&nodemgr_serialize); 784} 785 786static void nodemgr_free_unit_directories(struct node_entry *ne) 787{ 788 struct list_head *lh; 789 struct unit_directory *ud; 790 791 lh = ne->unit_directories.next; 792 while (lh != &ne->unit_directories) { 793 ud = list_entry(lh, struct unit_directory, node_list); 794 lh = lh->next; 795 if (ud->driver && ud->driver->disconnect) 796 ud->driver->disconnect(ud); 797 nodemgr_release_unit_directory(ud); 798 nodemgr_call_policy("remove", ud); 799 list_del(&ud->driver_list); 800 kfree(ud); 801 } 802} 803 804static struct ieee1394_device_id * 805nodemgr_match_driver(struct hpsb_protocol_driver *driver, 806 struct unit_directory *ud) 807{ 808 struct ieee1394_device_id *id; 809 810 for (id = driver->id_table; id->match_flags != 0; id++) { 811 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) && 812 id->vendor_id != ud->vendor_id) 813 continue; 814 815 if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) && 816 id->model_id != ud->model_id) 817 continue; 818 819 if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) && 820 id->specifier_id != ud->specifier_id) 821 continue; 822 823 if ((id->match_flags & IEEE1394_MATCH_VERSION) && 824 id->version != ud->version) 825 continue; 826 827 return id; 828 } 829 830 return NULL; 831} 832 833static struct hpsb_protocol_driver * 834nodemgr_find_driver(struct unit_directory *ud) 835{ 836 struct list_head *l; 837 struct hpsb_protocol_driver *match, *driver; 838 struct ieee1394_device_id *device_id; 839 840 match = NULL; 841 list_for_each(l, &driver_list) { 842 driver = list_entry(l, struct hpsb_protocol_driver, list); 843 device_id = nodemgr_match_driver(driver, ud); 844 845 if (device_id != NULL) { 846 match = driver; 847 break; 848 } 849 } 850 851 return match; 852} 853 854static void nodemgr_bind_drivers (struct node_entry *ne) 855{ 856 struct list_head *lh; 857 struct hpsb_protocol_driver *driver; 858 struct unit_directory *ud; 859 860 list_for_each(lh, &ne->unit_directories) { 861 ud = list_entry(lh, struct unit_directory, node_list); 862 driver = nodemgr_find_driver(ud); 863 if (driver != NULL && driver->probe(ud) == 0) 864 nodemgr_claim_unit_directory(ud, driver); 865 nodemgr_call_policy("add", ud); 866 } 867} 868 869int hpsb_register_protocol(struct hpsb_protocol_driver *driver) 870{ 871 struct unit_directory *ud; 872 struct list_head *lh; 873 874 if (down_interruptible(&nodemgr_serialize)) 875 return -EINTR; 876 877 list_add_tail(&driver->list, &driver_list); 878 879 INIT_LIST_HEAD(&driver->unit_directories); 880 lh = unit_directory_list.next; 881 while (lh != &unit_directory_list) { 882 ud = list_entry(lh, struct unit_directory, driver_list); 883 lh = lh->next; 884 if (nodemgr_match_driver(driver, ud) && driver->probe(ud) == 0) 885 nodemgr_claim_unit_directory(ud, driver); 886 } 887 888 up(&nodemgr_serialize); 889 890 /* 891 * Right now registration always succeeds, but maybe we should 892 * detect clashes in protocols handled by other drivers. 893 */ 894 895 return 0; 896} 897 898void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver) 899{ 900 struct list_head *lh; 901 struct unit_directory *ud; 902 903 down(&nodemgr_serialize); 904 905 list_del(&driver->list); 906 lh = driver->unit_directories.next; 907 while (lh != &driver->unit_directories) { 908 ud = list_entry(lh, struct unit_directory, driver_list); 909 lh = lh->next; 910 if (ud->driver && ud->driver->disconnect) 911 ud->driver->disconnect(ud); 912 nodemgr_release_unit_directory(ud); 913 } 914 915 up(&nodemgr_serialize); 916} 917 918static void nodemgr_process_config_rom(struct node_entry *ne, 919 quadlet_t busoptions) 920{ 921 ne->busopt.irmc = (busoptions >> 31) & 1; 922 ne->busopt.cmc = (busoptions >> 30) & 1; 923 ne->busopt.isc = (busoptions >> 29) & 1; 924 ne->busopt.bmc = (busoptions >> 28) & 1; 925 ne->busopt.pmc = (busoptions >> 27) & 1; 926 ne->busopt.cyc_clk_acc = (busoptions >> 16) & 0xff; 927 ne->busopt.max_rec = 1 << (((busoptions >> 12) & 0xf) + 1); 928 ne->busopt.generation = (busoptions >> 4) & 0xf; 929 ne->busopt.lnkspd = busoptions & 0x7; 930 931#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 932 HPSB_DEBUG("NodeMgr: raw=0x%08x irmc=%d cmc=%d isc=%d bmc=%d pmc=%d " 933 "cyc_clk_acc=%d max_rec=%d gen=%d lspd=%d", 934 busoptions, ne->busopt.irmc, ne->busopt.cmc, 935 ne->busopt.isc, ne->busopt.bmc, ne->busopt.pmc, 936 ne->busopt.cyc_clk_acc, ne->busopt.max_rec, 937 ne->busopt.generation, ne->busopt.lnkspd); 938#endif 939 940 /* 941 * When the config rom changes we disconnect all drivers and 942 * free the cached unit directories and reread the whole 943 * thing. If this was a new device, the call to 944 * nodemgr_disconnect_drivers is a no-op and all is well. 945 */ 946 nodemgr_free_unit_directories(ne); 947 nodemgr_process_root_directory(ne); 948 nodemgr_bind_drivers(ne); 949} 950 951/* 952 * This function updates nodes that were present on the bus before the 953 * reset and still are after the reset. The nodeid and the config rom 954 * may have changed, and the drivers managing this device must be 955 * informed that this device just went through a bus reset, to allow 956 * the to take whatever actions required. 957 */ 958static void nodemgr_update_node(struct node_entry *ne, quadlet_t busoptions, 959 struct hpsb_host *host, 960 nodeid_t nodeid, unsigned int generation) 961{ 962 struct list_head *lh; 963 struct unit_directory *ud; 964 965 if (ne->nodeid != nodeid) { 966 HPSB_DEBUG("Node " NODE_BUS_FMT " changed to " NODE_BUS_FMT, 967 NODE_BUS_ARGS(ne->nodeid), NODE_BUS_ARGS(nodeid)); 968 ne->nodeid = nodeid; 969 } 970 971 if (ne->busopt.generation != ((busoptions >> 4) & 0xf)) 972 nodemgr_process_config_rom (ne, busoptions); 973 974 /* Since that's done, we can declare this record current */ 975 ne->generation = generation; 976 977 list_for_each (lh, &ne->unit_directories) { 978 ud = list_entry (lh, struct unit_directory, node_list); 979 if (ud->driver != NULL && ud->driver->update != NULL) 980 ud->driver->update(ud); 981 } 982} 983 984static int read_businfo_block(struct hpsb_host *host, nodeid_t nodeid, unsigned int generation, 985 quadlet_t *buffer, int buffer_length) 986{ 987 octlet_t addr = CSR_REGISTER_BASE + CSR_CONFIG_ROM; 988 unsigned header_size; 989 int i; 990 991 /* IEEE P1212 says that devices should support 64byte block 992 * reads, aligned on 64byte boundaries. That doesn't seem to 993 * work though, and we are forced to doing quadlet sized 994 * reads. */ 995 996#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 997 HPSB_INFO("Initiating ConfigROM request for node " NODE_BUS_FMT, 998 NODE_BUS_ARGS(nodeid)); 999#endif 1000 /* 1001 * Must retry a few times if config rom read returns zero (how long?). Will 1002 * not normally occur, but we should do the right thing. For example, with 1003 * some sbp2 devices, the bridge chipset cannot return valid config rom reads 1004 * immediately after power-on, since they need to detect the type of 1005 * device attached (disk or CD-ROM). 1006 */ 1007 for (i = 0; i < 4; i++) { 1008 if (nodemgr_read_quadlet(host, nodeid, generation, 1009 addr, &buffer[0]) < 0) { 1010 HPSB_ERR("ConfigROM quadlet transaction error for node " 1011 NODE_BUS_FMT, NODE_BUS_ARGS(nodeid)); 1012 return -1; 1013 } 1014 if (buffer[0]) 1015 break; 1016 1017 set_current_state(TASK_INTERRUPTIBLE); 1018 if (schedule_timeout (HZ/4)) 1019 return -1; 1020 } 1021 1022 header_size = buffer[0] >> 24; 1023 addr += 4; 1024 1025 if (header_size < 4) { 1026 HPSB_INFO("Node " NODE_BUS_FMT " has non-standard ROM " 1027 "format (%d quads), cannot parse", 1028 NODE_BUS_ARGS(nodeid), header_size); 1029 return -1; 1030 } 1031 1032 for (i = 1; i < buffer_length; i++, addr += 4) { 1033 if (nodemgr_read_quadlet(host, nodeid, generation, 1034 addr, &buffer[i]) < 0) { 1035 HPSB_ERR("ConfigROM quadlet transaction " 1036 "error for node " NODE_BUS_FMT, 1037 NODE_BUS_ARGS(nodeid)); 1038 return -1; 1039 } 1040 } 1041 1042 return 0; 1043} 1044 1045static void nodemgr_remove_node(struct node_entry *ne) 1046{ 1047 HPSB_DEBUG("%s removed: Node[" NODE_BUS_FMT "] GUID[%016Lx] [%s]", 1048 (ne->host->node_id == ne->nodeid) ? "Host" : "Device", 1049 NODE_BUS_ARGS(ne->nodeid), (unsigned long long)ne->guid, 1050 ne->vendor_name ?: "Unknown"); 1051 1052 nodemgr_free_unit_directories(ne); 1053 list_del(&ne->list); 1054 kfree(ne); 1055 1056 return; 1057} 1058 1059/* This is where we probe the nodes for their information and provided 1060 * features. */ 1061static void nodemgr_node_probe_one(struct hpsb_host *host, 1062 nodeid_t nodeid, int generation) 1063{ 1064 struct node_entry *ne; 1065 quadlet_t buffer[5]; 1066 octlet_t guid; 1067 1068 /* We need to detect when the ConfigROM's generation has changed, 1069 * so we only update the node's info when it needs to be. */ 1070 1071 if (read_businfo_block (host, nodeid, generation, 1072 buffer, sizeof(buffer) >> 2)) 1073 return; 1074 1075 if (buffer[1] != IEEE1394_BUSID_MAGIC) { 1076 /* This isn't a 1394 device, but we let it slide. There 1077 * was a report of a device with broken firmware which 1078 * reported '2394' instead of '1394', which is obviously a 1079 * mistake. One would hope that a non-1394 device never 1080 * gets connected to Firewire bus. If someone does, we 1081 * shouldn't be held responsible, so we'll allow it with a 1082 * warning. */ 1083 HPSB_WARN("Node " NODE_BUS_FMT " has invalid busID magic [0x%08x]", 1084 NODE_BUS_ARGS(nodeid), buffer[1]); 1085 } 1086 1087 guid = ((u64)buffer[3] << 32) | buffer[4]; 1088 ne = find_entry_by_guid(guid); 1089 1090 if (!ne) 1091 nodemgr_create_node(guid, buffer[2], host, nodeid, generation); 1092 else 1093 nodemgr_update_node(ne, buffer[2], host, nodeid, generation); 1094 1095 return; 1096} 1097 1098static void nodemgr_node_probe_cleanup(struct hpsb_host *host, unsigned int generation) 1099{ 1100 struct list_head *lh, *next; 1101 struct node_entry *ne; 1102 1103 /* Now check to see if we have any nodes that aren't referenced 1104 * any longer. */ 1105 list_for_each_safe(lh, next, &node_list) { 1106 ne = list_entry(lh, struct node_entry, list); 1107 1108 /* Only checking this host */ 1109 if (ne->host != host) 1110 continue; 1111 1112 /* If the generation didn't get updated, then either the 1113 * node was removed, or it failed the above probe. Either 1114 * way, we remove references to it, since they are 1115 * invalid. */ 1116 if (ne->generation != generation) 1117 nodemgr_remove_node(ne); 1118 } 1119 1120 return; 1121} 1122 1123static void nodemgr_node_probe(struct hpsb_host *host) 1124{ 1125 int count; 1126 struct selfid *sid = (struct selfid *)host->topology_map; 1127 nodeid_t nodeid = LOCAL_BUS; 1128 unsigned int generation; 1129 1130 /* Pause for 1/4 second, to make sure things settle down. If 1131 * schedule_timeout returns non-zero, it means we caught a signal 1132 * and need to return. */ 1133 set_current_state(TASK_INTERRUPTIBLE); 1134 if (schedule_timeout (HZ/4)) 1135 return; 1136 1137 /* Now get the generation in which the node ID's we collect 1138 * are valid. During the bus scan we will use this generation 1139 * for the read transactions, so that if another reset occurs 1140 * during the scan the transactions will fail instead of 1141 * returning bogus data. */ 1142 generation = get_hpsb_generation(host); 1143 1144 /* Scan each node on the bus */ 1145 for (count = host->selfid_count; count; count--, sid++) { 1146 if (sid->extended) 1147 continue; 1148 1149 if (!sid->link_active) { 1150 nodeid++; 1151 continue; 1152 } 1153 1154 nodemgr_node_probe_one(host, nodeid++, generation); 1155 } 1156 1157 /* If we had a bus reset while we were scanning the bus, it is 1158 * possible that we did not probe all nodes. In that case, we 1159 * skip the clean up for now, since we could remove nodes that 1160 * were still on the bus. The bus reset increased 1161 * hi->reset_sem, so there's a bus scan pending which will do 1162 * the clean up eventually. */ 1163 if (generation == get_hpsb_generation(host)) 1164 nodemgr_node_probe_cleanup(host, generation); 1165 1166 return; 1167} 1168 1169static int nodemgr_host_thread(void *__hi) 1170{ 1171 struct host_info *hi = (struct host_info *)__hi; 1172 1173 /* No userlevel access needed */ 1174 daemonize(); 1175 1176 strcpy(current->comm, "knodemgrd"); 1177 1178 /* Sit and wait for a signal to probe the nodes on the bus. This 1179 * happens when we get a bus reset. */ 1180 while (!down_interruptible(&hi->reset_sem) && 1181 !down_interruptible(&nodemgr_serialize)) { 1182 nodemgr_node_probe(hi->host); 1183 up(&nodemgr_serialize); 1184 } 1185#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 1186 HPSB_DEBUG ("NodeMgr: Exiting thread for %s", hi->host->driver->name); 1187#endif 1188 1189 complete_and_exit(&hi->exited, 0); 1190} 1191 1192struct node_entry *hpsb_guid_get_entry(u64 guid) 1193{ 1194 struct node_entry *ne; 1195 1196 down(&nodemgr_serialize); 1197 ne = find_entry_by_guid(guid); 1198 up(&nodemgr_serialize); 1199 1200 return ne; 1201} 1202 1203struct node_entry *hpsb_nodeid_get_entry(nodeid_t nodeid) 1204{ 1205 struct node_entry *ne; 1206 1207 down(&nodemgr_serialize); 1208 ne = find_entry_by_nodeid(nodeid); 1209 up(&nodemgr_serialize); 1210 1211 return ne; 1212} 1213 1214/* The following four convenience functions use a struct node_entry 1215 * for addressing a node on the bus. They are intended for use by any 1216 * process context, not just the nodemgr thread, so we need to be a 1217 * little careful when reading out the node ID and generation. The 1218 * thing that can go wrong is that we get the node ID, then a bus 1219 * reset occurs, and then we read the generation. The node ID is 1220 * possibly invalid, but the generation is current, and we end up 1221 * sending a packet to a the wrong node. 1222 * 1223 * The solution is to make sure we read the generation first, so that 1224 * if a reset occurs in the process, we end up with a stale generation 1225 * and the transactions will fail instead of silently using wrong node 1226 * ID's. 1227 */ 1228 1229void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt) 1230{ 1231 pkt->host = ne->host; 1232 pkt->generation = ne->generation; 1233 barrier(); 1234 pkt->node_id = ne->nodeid; 1235} 1236 1237int hpsb_node_read(struct node_entry *ne, u64 addr, 1238 quadlet_t *buffer, size_t length) 1239{ 1240 unsigned int generation = ne->generation; 1241 1242 barrier(); 1243 return hpsb_read(ne->host, ne->nodeid, generation, 1244 addr, buffer, length); 1245} 1246 1247int hpsb_node_write(struct node_entry *ne, u64 addr, 1248 quadlet_t *buffer, size_t length) 1249{ 1250 unsigned int generation = ne->generation; 1251 1252 barrier(); 1253 return hpsb_write(ne->host, ne->nodeid, generation, 1254 addr, buffer, length); 1255} 1256 1257int hpsb_node_lock(struct node_entry *ne, u64 addr, 1258 int extcode, quadlet_t *data, quadlet_t arg) 1259{ 1260 unsigned int generation = ne->generation; 1261 1262 barrier(); 1263 return hpsb_lock(ne->host, ne->nodeid, generation, 1264 addr, extcode, data, arg); 1265} 1266 1267static void nodemgr_add_host(struct hpsb_host *host) 1268{ 1269 struct host_info *hi = kmalloc (sizeof (struct host_info), GFP_KERNEL); 1270 unsigned long flags; 1271 1272 if (!hi) { 1273 HPSB_ERR ("NodeMgr: out of memory in add host"); 1274 return; 1275 } 1276 1277 /* Initialize the hostinfo here and start the thread. The 1278 * thread blocks on the reset semaphore until a bus reset 1279 * happens. */ 1280 hi->host = host; 1281 INIT_LIST_HEAD(&hi->list); 1282 init_completion(&hi->exited); 1283 sema_init(&hi->reset_sem, 0); 1284 1285 hi->pid = kernel_thread(nodemgr_host_thread, hi, 1286 CLONE_FS | CLONE_FILES | CLONE_SIGHAND); 1287 1288 if (hi->pid < 0) { 1289 HPSB_ERR ("NodeMgr: failed to start NodeMgr thread for %s", 1290 host->driver->name); 1291 kfree(hi); 1292 return; 1293 } 1294 1295 spin_lock_irqsave (&host_info_lock, flags); 1296 list_add_tail (&hi->list, &host_info_list); 1297 spin_unlock_irqrestore (&host_info_lock, flags); 1298 1299 return; 1300} 1301 1302static void nodemgr_host_reset(struct hpsb_host *host) 1303{ 1304 struct list_head *lh; 1305 struct host_info *hi = NULL; 1306 unsigned long flags; 1307 1308 spin_lock_irqsave (&host_info_lock, flags); 1309 list_for_each(lh, &host_info_list) { 1310 struct host_info *myhi = list_entry(lh, struct host_info, list); 1311 if (myhi->host == host) { 1312 hi = myhi; 1313 break; 1314 } 1315 } 1316 1317 if (hi != NULL) { 1318#ifdef CONFIG_IEEE1394_VERBOSEDEBUG 1319 HPSB_DEBUG ("NodeMgr: Processing host reset for %s", host->driver->name); 1320#endif 1321 up(&hi->reset_sem); 1322 } else 1323 HPSB_ERR ("NodeMgr: could not process reset of non-existent host"); 1324 1325 spin_unlock_irqrestore (&host_info_lock, flags); 1326 1327 return; 1328} 1329 1330static void nodemgr_remove_host(struct hpsb_host *host) 1331{ 1332 struct list_head *lh, *next; 1333 struct node_entry *ne; 1334 unsigned long flags; 1335 struct host_info *hi = NULL; 1336 1337 spin_lock_irqsave (&host_info_lock, flags); 1338 list_for_each_safe(lh, next, &host_info_list) { 1339 struct host_info *myhi = list_entry(lh, struct host_info, list); 1340 if (myhi->host == host) { 1341 list_del(&myhi->list); 1342 hi = myhi; 1343 break; 1344 } 1345 } 1346 spin_unlock_irqrestore (&host_info_lock, flags); 1347 1348 if (hi) { 1349 if (hi->pid >= 0) { 1350 kill_proc(hi->pid, SIGTERM, 1); 1351 wait_for_completion(&hi->exited); 1352 } 1353 kfree(hi); 1354 } 1355 else 1356 HPSB_ERR("NodeMgr: host %s does not exist, cannot remove", 1357 host->driver->name); 1358 1359 down(&nodemgr_serialize); 1360 1361 /* Even if we fail the host_info part, remove all the node 1362 * entries. */ 1363 list_for_each_safe(lh, next, &node_list) { 1364 ne = list_entry(lh, struct node_entry, list); 1365 1366 if (ne->host == host) 1367 nodemgr_remove_node(ne); 1368 } 1369 1370 up(&nodemgr_serialize); 1371 1372 return; 1373} 1374 1375static struct hpsb_highlevel_ops nodemgr_ops = { 1376 .add_host = nodemgr_add_host, 1377 .host_reset = nodemgr_host_reset, 1378 .remove_host = nodemgr_remove_host, 1379}; 1380 1381static struct hpsb_highlevel *hl; 1382 1383#define PROC_ENTRY "devices" 1384 1385void init_ieee1394_nodemgr(int disable_hotplug) 1386{ 1387 nodemgr_disable_hotplug = disable_hotplug; 1388#ifdef CONFIG_PROC_FS 1389 if (!create_proc_read_entry(PROC_ENTRY, 0444, ieee1394_procfs_entry, raw1394_read_proc, NULL)) 1390 HPSB_ERR("Can't create devices procfs entry"); 1391#endif 1392 hl = hpsb_register_highlevel("Node manager", &nodemgr_ops); 1393 if (!hl) { 1394 HPSB_ERR("NodeMgr: out of memory during ieee1394 initialization"); 1395 } 1396} 1397 1398void cleanup_ieee1394_nodemgr(void) 1399{ 1400 hpsb_unregister_highlevel(hl); 1401#ifdef CONFIG_PROC_FS 1402 remove_proc_entry(PROC_ENTRY, ieee1394_procfs_entry); 1403#endif 1404} 1405