2 * procfs handler for Linux I2O subsystem
4 * (c) Copyright 1999 Deepak Saxena
6 * Originally written by Deepak Saxena(deepak@plexity.net)
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * This is an initial test release. The code is based on the design of the
14 * ide procfs system (drivers/block/ide-proc.c). Some code taken from
15 * i2o-core module by Alan Cox.
17 * DISCLAIMER: This code is still under development/test and may cause
18 * your system to behave unpredictably. Use at your own discretion.
22 * Juha Sievänen (Juha.Sievanen@cs.Helsinki.FI),
23 * Auvo Häkkinen (Auvo.Hakkinen@cs.Helsinki.FI)
24 * University of Helsinki, Department of Computer Science
26 * Markus Lidel <Markus.Lidel@shadowconnect.com>
27 * Changes for new I2O API
30 #define OSM_NAME "proc-osm"
31 #define OSM_VERSION "1.316"
32 #define OSM_DESCRIPTION "I2O ProcFS OSM"
34 #define I2O_MAX_MODULES 4
36 #define FMT_U64_HEX "0x%08x%08x"
37 #define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
39 #include <linux/types.h>
40 #include <linux/kernel.h>
41 #include <linux/pci.h>
42 #include <linux/i2o.h>
43 #include <linux/proc_fs.h>
44 #include <linux/seq_file.h>
45 #include <linux/init.h>
46 #include <linux/module.h>
47 #include <linux/errno.h>
48 #include <linux/spinlock.h>
49 #include <linux/workqueue.h>
52 #include <asm/uaccess.h>
53 #include <asm/byteorder.h>
55 /* Structure used to define /proc entries */
56 typedef struct _i2o_proc_entry_t {
57 char *name; /* entry name */
58 mode_t mode; /* mode */
59 struct file_operations *fops; /* open function */
62 /* global I2O /proc/i2o entry */
63 static struct proc_dir_entry *i2o_proc_dir_root;
65 /* proc OSM driver struct */
66 static struct i2o_driver i2o_proc_driver = {
70 static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
75 * The I2O v1.5 (and v2.0 so far) "official specification"
76 * got serial numbers WRONG!
77 * Apparently, and despite what Section 3.4.4 says and
78 * Figure 3-35 shows (pg 3-39 in the pdf doc),
79 * the convention / consensus seems to be:
80 * + First byte is SNFormat
81 * + Second byte is SNLen (but only if SNFormat==7 (?))
82 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
84 switch (serialno[0]) {
85 case I2O_SNFORMAT_BINARY: /* Binary */
86 seq_printf(seq, "0x");
87 for (i = 0; i < serialno[1]; i++) {
88 seq_printf(seq, "%02X", serialno[2 + i]);
92 case I2O_SNFORMAT_ASCII: /* ASCII */
93 if (serialno[1] < ' ') { /* printable or SNLen? */
96 (max_len < serialno[1]) ? max_len : serialno[1];
97 serialno[1 + max_len] = '\0';
100 seq_printf(seq, "%s", &serialno[2]);
102 /* print chars for specified length */
103 for (i = 0; i < serialno[1]; i++) {
104 seq_printf(seq, "%c", serialno[2 + i]);
109 case I2O_SNFORMAT_UNICODE: /* UNICODE */
110 seq_printf(seq, "UNICODE Format. Can't Display\n");
113 case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
115 "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
116 serialno[2], serialno[3],
117 serialno[4], serialno[5], serialno[6], serialno[7]);
120 case I2O_SNFORMAT_WAN: /* WAN MAC Address */
121 /* FIXME: Figure out what a WAN access address looks like?? */
122 seq_printf(seq, "WAN Access Address");
125 /* plus new in v2.0 */
126 case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
127 /* FIXME: Figure out what a LAN-64 address really looks like?? */
129 "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
130 serialno[8], serialno[9],
131 serialno[2], serialno[3],
132 serialno[4], serialno[5], serialno[6], serialno[7]);
135 case I2O_SNFORMAT_DDM: /* I2O DDM */
137 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
138 *(u16 *) & serialno[2],
139 *(u16 *) & serialno[4], *(u16 *) & serialno[6]);
142 case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
143 case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
144 /* FIXME: Figure if this is even close?? */
146 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
147 *(u32 *) & serialno[2],
148 *(u32 *) & serialno[6],
149 *(u32 *) & serialno[10], *(u32 *) & serialno[14]);
152 case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */
153 case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
155 seq_printf(seq, "Unknown data format (0x%02x)", serialno[0]);
163 * i2o_get_class_name - do i2o class name lookup
164 * @class: class number
166 * Return a descriptive string for an i2o class
168 static const char *i2o_get_class_name(int class)
171 static char *i2o_class_name[] = {
173 "Device Driver Module",
178 "Fibre Channel Port",
179 "Fibre Channel Device",
185 "Secondary Bus Port",
186 "Peer Transport Agent",
191 switch (class & 0xfff) {
192 case I2O_CLASS_EXECUTIVE:
198 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
201 case I2O_CLASS_SEQUENTIAL_STORAGE:
210 case I2O_CLASS_FIBRE_CHANNEL_PORT:
213 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL:
216 case I2O_CLASS_SCSI_PERIPHERAL:
219 case I2O_CLASS_ATE_PORT:
222 case I2O_CLASS_ATE_PERIPHERAL:
225 case I2O_CLASS_FLOPPY_CONTROLLER:
228 case I2O_CLASS_FLOPPY_DEVICE:
231 case I2O_CLASS_BUS_ADAPTER:
234 case I2O_CLASS_PEER_TRANSPORT_AGENT:
237 case I2O_CLASS_PEER_TRANSPORT:
242 return i2o_class_name[idx];
245 #define SCSI_TABLE_SIZE 13
246 static char *scsi_devices[] = {
247 "Direct-Access Read/Write",
248 "Sequential-Access Storage",
254 "Optical Memory Device",
255 "Medium Changer Device",
256 "Communications Device",
257 "Graphics Art Pre-Press Device",
258 "Graphics Art Pre-Press Device",
259 "Array Controller Device"
262 static char *chtostr(u8 * chars, int n)
266 return strncat(tmp, (char *)chars, n);
269 static int i2o_report_query_status(struct seq_file *seq, int block_status,
272 switch (block_status) {
274 return seq_printf(seq, "Timeout reading group %s.\n", group);
276 return seq_printf(seq, "No free memory to read the table.\n");
277 case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
278 return seq_printf(seq, "Group %s not supported.\n", group);
280 return seq_printf(seq,
281 "Error reading group %s. BlockStatus 0x%02X\n",
282 group, -block_status);
286 static char *bus_strings[] = {
297 static int i2o_seq_show_hrt(struct seq_file *seq, void *v)
299 struct i2o_controller *c = (struct i2o_controller *)seq->private;
300 i2o_hrt *hrt = (i2o_hrt *) c->hrt.virt;
304 if (hrt->hrt_version) {
306 "HRT table for controller is too new a version.\n");
310 seq_printf(seq, "HRT has %d entries of %d bytes each.\n",
311 hrt->num_entries, hrt->entry_len << 2);
313 for (i = 0; i < hrt->num_entries; i++) {
314 seq_printf(seq, "Entry %d:\n", i);
315 seq_printf(seq, " Adapter ID: %0#10x\n",
316 hrt->hrt_entry[i].adapter_id);
317 seq_printf(seq, " Controlling tid: %0#6x\n",
318 hrt->hrt_entry[i].parent_tid);
320 if (hrt->hrt_entry[i].bus_type != 0x80) {
321 bus = hrt->hrt_entry[i].bus_type;
322 seq_printf(seq, " %s Information\n",
327 seq_printf(seq, " IOBase: %0#6x,",
328 hrt->hrt_entry[i].bus.local_bus.
330 seq_printf(seq, " MemoryBase: %0#10x\n",
331 hrt->hrt_entry[i].bus.local_bus.
332 LbBaseMemoryAddress);
336 seq_printf(seq, " IOBase: %0#6x,",
337 hrt->hrt_entry[i].bus.isa_bus.
339 seq_printf(seq, " MemoryBase: %0#10x,",
340 hrt->hrt_entry[i].bus.isa_bus.
341 IsaBaseMemoryAddress);
342 seq_printf(seq, " CSN: %0#4x,",
343 hrt->hrt_entry[i].bus.isa_bus.CSN);
347 seq_printf(seq, " IOBase: %0#6x,",
348 hrt->hrt_entry[i].bus.eisa_bus.
350 seq_printf(seq, " MemoryBase: %0#10x,",
351 hrt->hrt_entry[i].bus.eisa_bus.
352 EisaBaseMemoryAddress);
353 seq_printf(seq, " Slot: %0#4x,",
354 hrt->hrt_entry[i].bus.eisa_bus.
359 seq_printf(seq, " IOBase: %0#6x,",
360 hrt->hrt_entry[i].bus.mca_bus.
362 seq_printf(seq, " MemoryBase: %0#10x,",
363 hrt->hrt_entry[i].bus.mca_bus.
364 McaBaseMemoryAddress);
365 seq_printf(seq, " Slot: %0#4x,",
366 hrt->hrt_entry[i].bus.mca_bus.
371 seq_printf(seq, " Bus: %0#4x",
372 hrt->hrt_entry[i].bus.pci_bus.
374 seq_printf(seq, " Dev: %0#4x",
375 hrt->hrt_entry[i].bus.pci_bus.
377 seq_printf(seq, " Func: %0#4x",
378 hrt->hrt_entry[i].bus.pci_bus.
380 seq_printf(seq, " Vendor: %0#6x",
381 hrt->hrt_entry[i].bus.pci_bus.
383 seq_printf(seq, " Device: %0#6x\n",
384 hrt->hrt_entry[i].bus.pci_bus.
389 seq_printf(seq, " Unsupported Bus Type\n");
392 seq_printf(seq, " Unknown Bus Type\n");
398 static int i2o_seq_show_lct(struct seq_file *seq, void *v)
400 struct i2o_controller *c = (struct i2o_controller *)seq->private;
401 i2o_lct *lct = (i2o_lct *) c->lct;
405 #define BUS_TABLE_SIZE 3
406 static char *bus_ports[] = {
412 entries = (lct->table_size - 3) / 9;
414 seq_printf(seq, "LCT contains %d %s\n", entries,
415 entries == 1 ? "entry" : "entries");
417 seq_printf(seq, "Boot Device @ ID %d\n", lct->boot_tid);
419 seq_printf(seq, "Current Change Indicator: %#10x\n", lct->change_ind);
421 for (i = 0; i < entries; i++) {
422 seq_printf(seq, "Entry %d\n", i);
423 seq_printf(seq, " Class, SubClass : %s",
424 i2o_get_class_name(lct->lct_entry[i].class_id));
427 * Classes which we'll print subclass info for
429 switch (lct->lct_entry[i].class_id & 0xFFF) {
430 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
431 switch (lct->lct_entry[i].sub_class) {
433 seq_printf(seq, ", Direct-Access Read/Write");
437 seq_printf(seq, ", WORM Drive");
441 seq_printf(seq, ", CD-ROM Drive");
445 seq_printf(seq, ", Optical Memory Device");
449 seq_printf(seq, ", Unknown (0x%02x)",
450 lct->lct_entry[i].sub_class);
456 switch (lct->lct_entry[i].sub_class & 0xFF) {
458 seq_printf(seq, ", Ethernet");
462 seq_printf(seq, ", 100base VG");
466 seq_printf(seq, ", IEEE 802.5/Token-Ring");
470 seq_printf(seq, ", ANSI X3T9.5 FDDI");
474 seq_printf(seq, ", Fibre Channel");
478 seq_printf(seq, ", Unknown Sub-Class (0x%02x)",
479 lct->lct_entry[i].sub_class & 0xFF);
484 case I2O_CLASS_SCSI_PERIPHERAL:
485 if (lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
486 seq_printf(seq, ", %s",
487 scsi_devices[lct->lct_entry[i].
490 seq_printf(seq, ", Unknown Device Type");
493 case I2O_CLASS_BUS_ADAPTER:
494 if (lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
495 seq_printf(seq, ", %s",
496 bus_ports[lct->lct_entry[i].
499 seq_printf(seq, ", Unknown Bus Type");
502 seq_printf(seq, "\n");
504 seq_printf(seq, " Local TID : 0x%03x\n",
505 lct->lct_entry[i].tid);
506 seq_printf(seq, " User TID : 0x%03x\n",
507 lct->lct_entry[i].user_tid);
508 seq_printf(seq, " Parent TID : 0x%03x\n",
509 lct->lct_entry[i].parent_tid);
510 seq_printf(seq, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
511 lct->lct_entry[i].identity_tag[0],
512 lct->lct_entry[i].identity_tag[1],
513 lct->lct_entry[i].identity_tag[2],
514 lct->lct_entry[i].identity_tag[3],
515 lct->lct_entry[i].identity_tag[4],
516 lct->lct_entry[i].identity_tag[5],
517 lct->lct_entry[i].identity_tag[6],
518 lct->lct_entry[i].identity_tag[7]);
519 seq_printf(seq, " Change Indicator : %0#10x\n",
520 lct->lct_entry[i].change_ind);
521 seq_printf(seq, " Event Capab Mask : %0#10x\n",
522 lct->lct_entry[i].device_flags);
528 static int i2o_seq_show_status(struct seq_file *seq, void *v)
530 struct i2o_controller *c = (struct i2o_controller *)seq->private;
533 i2o_status_block *sb = c->status_block.virt;
535 i2o_status_get(c); // reread the status block
537 seq_printf(seq, "Organization ID : %0#6x\n", sb->org_id);
539 version = sb->i2o_version;
541 /* FIXME for Spec 2.0
542 if (version == 0x02) {
543 seq_printf(seq, "Lowest I2O version supported: ");
544 switch(workspace[2]) {
546 seq_printf(seq, "1.0\n");
549 seq_printf(seq, "1.5\n");
552 seq_printf(seq, "2.0\n");
556 seq_printf(seq, "Highest I2O version supported: ");
557 switch(workspace[3]) {
559 seq_printf(seq, "1.0\n");
562 seq_printf(seq, "1.5\n");
565 seq_printf(seq, "2.0\n");
570 seq_printf(seq, "IOP ID : %0#5x\n", sb->iop_id);
571 seq_printf(seq, "Host Unit ID : %0#6x\n", sb->host_unit_id);
572 seq_printf(seq, "Segment Number : %0#5x\n", sb->segment_number);
574 seq_printf(seq, "I2O version : ");
577 seq_printf(seq, "1.0\n");
580 seq_printf(seq, "1.5\n");
583 seq_printf(seq, "2.0\n");
586 seq_printf(seq, "Unknown version\n");
589 seq_printf(seq, "IOP State : ");
590 switch (sb->iop_state) {
592 seq_printf(seq, "INIT\n");
596 seq_printf(seq, "RESET\n");
600 seq_printf(seq, "HOLD\n");
604 seq_printf(seq, "READY\n");
608 seq_printf(seq, "OPERATIONAL\n");
612 seq_printf(seq, "FAILED\n");
616 seq_printf(seq, "FAULTED\n");
620 seq_printf(seq, "Unknown\n");
624 seq_printf(seq, "Messenger Type : ");
625 switch (sb->msg_type) {
627 seq_printf(seq, "Memory mapped\n");
630 seq_printf(seq, "Memory mapped only\n");
633 seq_printf(seq, "Remote only\n");
636 seq_printf(seq, "Memory mapped and remote\n");
639 seq_printf(seq, "Unknown\n");
642 seq_printf(seq, "Inbound Frame Size : %d bytes\n",
643 sb->inbound_frame_size << 2);
644 seq_printf(seq, "Max Inbound Frames : %d\n",
645 sb->max_inbound_frames);
646 seq_printf(seq, "Current Inbound Frames : %d\n",
647 sb->cur_inbound_frames);
648 seq_printf(seq, "Max Outbound Frames : %d\n",
649 sb->max_outbound_frames);
651 /* Spec doesn't say if NULL terminated or not... */
652 memcpy(prodstr, sb->product_id, 24);
654 seq_printf(seq, "Product ID : %s\n", prodstr);
655 seq_printf(seq, "Expected LCT Size : %d bytes\n",
656 sb->expected_lct_size);
658 seq_printf(seq, "IOP Capabilities\n");
659 seq_printf(seq, " Context Field Size Support : ");
660 switch (sb->iop_capabilities & 0x0000003) {
662 seq_printf(seq, "Supports only 32-bit context fields\n");
665 seq_printf(seq, "Supports only 64-bit context fields\n");
668 seq_printf(seq, "Supports 32-bit and 64-bit context fields, "
669 "but not concurrently\n");
672 seq_printf(seq, "Supports 32-bit and 64-bit context fields "
676 seq_printf(seq, "0x%08x\n", sb->iop_capabilities);
678 seq_printf(seq, " Current Context Field Size : ");
679 switch (sb->iop_capabilities & 0x0000000C) {
681 seq_printf(seq, "not configured\n");
684 seq_printf(seq, "Supports only 32-bit context fields\n");
687 seq_printf(seq, "Supports only 64-bit context fields\n");
690 seq_printf(seq, "Supports both 32-bit or 64-bit context fields "
694 seq_printf(seq, "\n");
696 seq_printf(seq, " Inbound Peer Support : %s\n",
698 iop_capabilities & 0x00000010) ? "Supported" :
700 seq_printf(seq, " Outbound Peer Support : %s\n",
702 iop_capabilities & 0x00000020) ? "Supported" :
704 seq_printf(seq, " Peer to Peer Support : %s\n",
706 iop_capabilities & 0x00000040) ? "Supported" :
709 seq_printf(seq, "Desired private memory size : %d kB\n",
710 sb->desired_mem_size >> 10);
711 seq_printf(seq, "Allocated private memory size : %d kB\n",
712 sb->current_mem_size >> 10);
713 seq_printf(seq, "Private memory base address : %0#10x\n",
714 sb->current_mem_base);
715 seq_printf(seq, "Desired private I/O size : %d kB\n",
716 sb->desired_io_size >> 10);
717 seq_printf(seq, "Allocated private I/O size : %d kB\n",
718 sb->current_io_size >> 10);
719 seq_printf(seq, "Private I/O base address : %0#10x\n",
720 sb->current_io_base);
725 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
727 struct i2o_controller *c = (struct i2o_controller *)seq->private;
728 static u32 work32[5];
729 static u8 *work8 = (u8 *) work32;
730 static u16 *work16 = (u16 *) work32;
734 static char *cpu_table[] = {
735 "Intel 80960 series",
737 "Motorola 68000 series",
746 i2o_parm_field_get(c->exec, 0x0000, -1, &work32, sizeof(work32));
749 i2o_report_query_status(seq, token, "0x0000 IOP Hardware");
753 seq_printf(seq, "I2O Vendor ID : %0#6x\n", work16[0]);
754 seq_printf(seq, "Product ID : %0#6x\n", work16[1]);
755 seq_printf(seq, "CPU : ");
757 seq_printf(seq, "Unknown\n");
759 seq_printf(seq, "%s\n", cpu_table[work8[16]]);
760 /* Anyone using ProcessorVersion? */
762 seq_printf(seq, "RAM : %dkB\n", work32[1] >> 10);
763 seq_printf(seq, "Non-Volatile Mem : %dkB\n", work32[2] >> 10);
766 seq_printf(seq, "Capabilities : 0x%08x\n", hwcap);
767 seq_printf(seq, " [%s] Self booting\n",
768 (hwcap & 0x00000001) ? "+" : "-");
769 seq_printf(seq, " [%s] Upgradable IRTOS\n",
770 (hwcap & 0x00000002) ? "+" : "-");
771 seq_printf(seq, " [%s] Supports downloading DDMs\n",
772 (hwcap & 0x00000004) ? "+" : "-");
773 seq_printf(seq, " [%s] Supports installing DDMs\n",
774 (hwcap & 0x00000008) ? "+" : "-");
775 seq_printf(seq, " [%s] Battery-backed RAM\n",
776 (hwcap & 0x00000010) ? "+" : "-");
781 /* Executive group 0003h - Executing DDM List (table) */
782 static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
784 struct i2o_controller *c = (struct i2o_controller *)seq->private;
788 typedef struct _i2o_exec_execute_ddm_table {
794 u8 module_name_version[28];
797 } i2o_exec_execute_ddm_table;
807 i2o_exec_execute_ddm_table ddm_table[I2O_MAX_MODULES];
810 i2o_exec_execute_ddm_table ddm_table;
812 result = kmalloc(sizeof(*result), GFP_KERNEL);
816 token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0003, -1,
817 NULL, 0, result, sizeof(*result));
820 i2o_report_query_status(seq, token,
821 "0x0003 Executing DDM List");
826 "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
827 ddm_table = result->ddm_table[0];
829 for (i = 0; i < result->row_count; ddm_table = result->ddm_table[++i]) {
830 seq_printf(seq, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
832 switch (ddm_table.module_type) {
834 seq_printf(seq, "Downloaded DDM ");
837 seq_printf(seq, "Embedded DDM ");
840 seq_printf(seq, " ");
843 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
844 seq_printf(seq, "%-#8x", ddm_table.module_id);
845 seq_printf(seq, "%-29s",
846 chtostr(ddm_table.module_name_version, 28));
847 seq_printf(seq, "%9d ", ddm_table.data_size);
848 seq_printf(seq, "%8d", ddm_table.code_size);
850 seq_printf(seq, "\n");
857 /* Executive group 0004h - Driver Store (scalar) */
858 static int i2o_seq_show_driver_store(struct seq_file *seq, void *v)
860 struct i2o_controller *c = (struct i2o_controller *)seq->private;
865 i2o_parm_field_get(c->exec, 0x0004, -1, &work32, sizeof(work32));
867 i2o_report_query_status(seq, token, "0x0004 Driver Store");
871 seq_printf(seq, "Module limit : %d\n"
872 "Module count : %d\n"
873 "Current space : %d kB\n"
874 "Free space : %d kB\n",
875 work32[0], work32[1], work32[2] >> 10, work32[3] >> 10);
880 /* Executive group 0005h - Driver Store Table (table) */
881 static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
883 typedef struct _i2o_driver_store {
884 u16 stored_ddm_index;
889 u8 module_name_version[28];
894 } i2o_driver_store_table;
896 struct i2o_controller *c = (struct i2o_controller *)seq->private;
908 i2o_driver_store_table dst[I2O_MAX_MODULES];
909 } i2o_driver_result_table;
911 i2o_driver_result_table *result;
912 i2o_driver_store_table *dst;
914 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
918 token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0005, -1,
919 NULL, 0, result, sizeof(*result));
922 i2o_report_query_status(seq, token,
923 "0x0005 DRIVER STORE TABLE");
929 "# Module_type Vendor Mod_id Module_name Vrs"
930 "Date Mod_size Par_size Flags\n");
931 for (i = 0, dst = &result->dst[0]; i < result->row_count;
932 dst = &result->dst[++i]) {
933 seq_printf(seq, "%-3d", dst->stored_ddm_index);
934 switch (dst->module_type) {
936 seq_printf(seq, "Downloaded DDM ");
939 seq_printf(seq, "Embedded DDM ");
942 seq_printf(seq, " ");
945 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
946 seq_printf(seq, "%-#8x", dst->module_id);
947 seq_printf(seq, "%-29s", chtostr(dst->module_name_version, 28));
948 seq_printf(seq, "%-9s", chtostr(dst->date, 8));
949 seq_printf(seq, "%8d ", dst->module_size);
950 seq_printf(seq, "%8d ", dst->mpb_size);
951 seq_printf(seq, "0x%04x", dst->module_flags);
952 seq_printf(seq, "\n");
959 /* Generic group F000h - Params Descriptor (table) */
960 static int i2o_seq_show_groups(struct seq_file *seq, void *v)
962 struct i2o_device *d = (struct i2o_device *)seq->private;
967 typedef struct _i2o_group_info {
983 i2o_group_info group[256];
986 result = kmalloc(sizeof(*result), GFP_KERNEL);
990 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
991 result, sizeof(*result));
994 i2o_report_query_status(seq, token, "0xF000 Params Descriptor");
999 "# Group FieldCount RowCount Type Add Del Clear\n");
1001 for (i = 0; i < result->row_count; i++) {
1002 seq_printf(seq, "%-3d", i);
1003 seq_printf(seq, "0x%04X ", result->group[i].group_number);
1004 seq_printf(seq, "%10d ", result->group[i].field_count);
1005 seq_printf(seq, "%8d ", result->group[i].row_count);
1007 properties = result->group[i].properties;
1008 if (properties & 0x1)
1009 seq_printf(seq, "Table ");
1011 seq_printf(seq, "Scalar ");
1012 if (properties & 0x2)
1013 seq_printf(seq, " + ");
1015 seq_printf(seq, " - ");
1016 if (properties & 0x4)
1017 seq_printf(seq, " + ");
1019 seq_printf(seq, " - ");
1020 if (properties & 0x8)
1021 seq_printf(seq, " + ");
1023 seq_printf(seq, " - ");
1025 seq_printf(seq, "\n");
1028 if (result->more_flag)
1029 seq_printf(seq, "There is more...\n");
1035 /* Generic group F001h - Physical Device Table (table) */
1036 static int i2o_seq_show_phys_device(struct seq_file *seq, void *v)
1038 struct i2o_device *d = (struct i2o_device *)seq->private;
1053 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF001, -1, NULL, 0,
1054 &result, sizeof(result));
1057 i2o_report_query_status(seq, token,
1058 "0xF001 Physical Device Table");
1062 if (result.row_count)
1063 seq_printf(seq, "# AdapterId\n");
1065 for (i = 0; i < result.row_count; i++) {
1066 seq_printf(seq, "%-2d", i);
1067 seq_printf(seq, "%#7x\n", result.adapter_id[i]);
1070 if (result.more_flag)
1071 seq_printf(seq, "There is more...\n");
1076 /* Generic group F002h - Claimed Table (table) */
1077 static int i2o_seq_show_claimed(struct seq_file *seq, void *v)
1079 struct i2o_device *d = (struct i2o_device *)seq->private;
1091 u16 claimed_tid[64];
1094 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF002, -1, NULL, 0,
1095 &result, sizeof(result));
1098 i2o_report_query_status(seq, token, "0xF002 Claimed Table");
1102 if (result.row_count)
1103 seq_printf(seq, "# ClaimedTid\n");
1105 for (i = 0; i < result.row_count; i++) {
1106 seq_printf(seq, "%-2d", i);
1107 seq_printf(seq, "%#7x\n", result.claimed_tid[i]);
1110 if (result.more_flag)
1111 seq_printf(seq, "There is more...\n");
1116 /* Generic group F003h - User Table (table) */
1117 static int i2o_seq_show_users(struct seq_file *seq, void *v)
1119 struct i2o_device *d = (struct i2o_device *)seq->private;
1123 typedef struct _i2o_user_table {
1139 i2o_user_table user[64];
1142 result = kmalloc(sizeof(*result), GFP_KERNEL);
1146 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF003, -1, NULL, 0,
1147 result, sizeof(*result));
1150 i2o_report_query_status(seq, token, "0xF003 User Table");
1154 seq_printf(seq, "# Instance UserTid ClaimType\n");
1156 for (i = 0; i < result->row_count; i++) {
1157 seq_printf(seq, "%-3d", i);
1158 seq_printf(seq, "%#8x ", result->user[i].instance);
1159 seq_printf(seq, "%#7x ", result->user[i].user_tid);
1160 seq_printf(seq, "%#9x\n", result->user[i].claim_type);
1163 if (result->more_flag)
1164 seq_printf(seq, "There is more...\n");
1170 /* Generic group F005h - Private message extensions (table) (optional) */
1171 static int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v)
1173 struct i2o_device *d = (struct i2o_device *)seq->private;
1177 typedef struct _i2o_private {
1179 u16 organization_id;
1180 u16 x_function_code;
1191 i2o_private extension[64];
1194 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
1195 &result, sizeof(result));
1198 i2o_report_query_status(seq, token,
1199 "0xF005 Private Message Extensions (optional)");
1203 seq_printf(seq, "Instance# OrgId FunctionCode\n");
1205 for (i = 0; i < result.row_count; i++) {
1206 seq_printf(seq, "%0#9x ", result.extension[i].ext_instance);
1207 seq_printf(seq, "%0#6x ", result.extension[i].organization_id);
1208 seq_printf(seq, "%0#6x", result.extension[i].x_function_code);
1210 seq_printf(seq, "\n");
1213 if (result.more_flag)
1214 seq_printf(seq, "There is more...\n");
1219 /* Generic group F006h - Authorized User Table (table) */
1220 static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
1222 struct i2o_device *d = (struct i2o_device *)seq->private;
1234 u32 alternate_tid[64];
1237 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF006, -1, NULL, 0,
1238 &result, sizeof(result));
1241 i2o_report_query_status(seq, token,
1242 "0xF006 Autohorized User Table");
1246 if (result.row_count)
1247 seq_printf(seq, "# AlternateTid\n");
1249 for (i = 0; i < result.row_count; i++) {
1250 seq_printf(seq, "%-2d", i);
1251 seq_printf(seq, "%#7x ", result.alternate_tid[i]);
1254 if (result.more_flag)
1255 seq_printf(seq, "There is more...\n");
1260 /* Generic group F100h - Device Identity (scalar) */
1261 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
1263 struct i2o_device *d = (struct i2o_device *)seq->private;
1264 static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
1265 // == (allow) 512d bytes (max)
1266 static u16 *work16 = (u16 *) work32;
1269 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
1272 i2o_report_query_status(seq, token, "0xF100 Device Identity");
1276 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
1277 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
1278 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
1279 seq_printf(seq, "Vendor info : %s\n",
1280 chtostr((u8 *) (work32 + 2), 16));
1281 seq_printf(seq, "Product info : %s\n",
1282 chtostr((u8 *) (work32 + 6), 16));
1283 seq_printf(seq, "Description : %s\n",
1284 chtostr((u8 *) (work32 + 10), 16));
1285 seq_printf(seq, "Product rev. : %s\n",
1286 chtostr((u8 *) (work32 + 14), 8));
1288 seq_printf(seq, "Serial number : ");
1289 print_serial_number(seq, (u8 *) (work32 + 16),
1290 /* allow for SNLen plus
1291 * possible trailing '\0'
1293 sizeof(work32) - (16 * sizeof(u32)) - 2);
1294 seq_printf(seq, "\n");
1299 static int i2o_seq_show_dev_name(struct seq_file *seq, void *v)
1301 struct i2o_device *d = (struct i2o_device *)seq->private;
1303 seq_printf(seq, "%s\n", d->device.bus_id);
1308 /* Generic group F101h - DDM Identity (scalar) */
1309 static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
1311 struct i2o_device *d = (struct i2o_device *)seq->private;
1319 u8 serial_number[12];
1320 u8 pad[256]; // allow up to 256 byte (max) serial number
1323 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
1326 i2o_report_query_status(seq, token, "0xF101 DDM Identity");
1330 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
1331 seq_printf(seq, "Module name : %s\n",
1332 chtostr(result.module_name, 24));
1333 seq_printf(seq, "Module revision : %s\n",
1334 chtostr(result.module_rev, 8));
1336 seq_printf(seq, "Serial number : ");
1337 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
1338 /* allow for SNLen plus possible trailing '\0' */
1340 seq_printf(seq, "\n");
1345 /* Generic group F102h - User Information (scalar) */
1346 static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
1348 struct i2o_device *d = (struct i2o_device *)seq->private;
1353 u8 service_name[64];
1354 u8 physical_location[64];
1355 u8 instance_number[4];
1358 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
1361 i2o_report_query_status(seq, token, "0xF102 User Information");
1365 seq_printf(seq, "Device name : %s\n",
1366 chtostr(result.device_name, 64));
1367 seq_printf(seq, "Service name : %s\n",
1368 chtostr(result.service_name, 64));
1369 seq_printf(seq, "Physical name : %s\n",
1370 chtostr(result.physical_location, 64));
1371 seq_printf(seq, "Instance number : %s\n",
1372 chtostr(result.instance_number, 4));
1377 /* Generic group F103h - SGL Operating Limits (scalar) */
1378 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
1380 struct i2o_device *d = (struct i2o_device *)seq->private;
1381 static u32 work32[12];
1382 static u16 *work16 = (u16 *) work32;
1383 static u8 *work8 = (u8 *) work32;
1386 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
1389 i2o_report_query_status(seq, token,
1390 "0xF103 SGL Operating Limits");
1394 seq_printf(seq, "SGL chain size : %d\n", work32[0]);
1395 seq_printf(seq, "Max SGL chain size : %d\n", work32[1]);
1396 seq_printf(seq, "SGL chain size target : %d\n", work32[2]);
1397 seq_printf(seq, "SGL frag count : %d\n", work16[6]);
1398 seq_printf(seq, "Max SGL frag count : %d\n", work16[7]);
1399 seq_printf(seq, "SGL frag count target : %d\n", work16[8]);
1402 if (d->i2oversion == 0x02)
1405 seq_printf(seq, "SGL data alignment : %d\n", work16[8]);
1406 seq_printf(seq, "SGL addr limit : %d\n", work8[20]);
1407 seq_printf(seq, "SGL addr sizes supported : ");
1408 if (work8[21] & 0x01)
1409 seq_printf(seq, "32 bit ");
1410 if (work8[21] & 0x02)
1411 seq_printf(seq, "64 bit ");
1412 if (work8[21] & 0x04)
1413 seq_printf(seq, "96 bit ");
1414 if (work8[21] & 0x08)
1415 seq_printf(seq, "128 bit ");
1416 seq_printf(seq, "\n");
1424 /* Generic group F200h - Sensors (scalar) */
1425 static int i2o_seq_show_sensors(struct seq_file *seq, void *v)
1427 struct i2o_device *d = (struct i2o_device *)seq->private;
1431 u16 sensor_instance;
1433 u16 component_instance;
1436 u8 scaling_exponent;
1438 u32 minimum_reading;
1439 u32 low2lowcat_treshold;
1440 u32 lowcat2low_treshold;
1441 u32 lowwarn2low_treshold;
1442 u32 low2lowwarn_treshold;
1443 u32 norm2lowwarn_treshold;
1444 u32 lowwarn2norm_treshold;
1445 u32 nominal_reading;
1446 u32 hiwarn2norm_treshold;
1447 u32 norm2hiwarn_treshold;
1448 u32 high2hiwarn_treshold;
1449 u32 hiwarn2high_treshold;
1450 u32 hicat2high_treshold;
1451 u32 hi2hicat_treshold;
1452 u32 maximum_reading;
1457 token = i2o_parm_field_get(d, 0xF200, -1, &result, sizeof(result));
1460 i2o_report_query_status(seq, token,
1461 "0xF200 Sensors (optional)");
1465 seq_printf(seq, "Sensor instance : %d\n", result.sensor_instance);
1467 seq_printf(seq, "Component : %d = ", result.component);
1468 switch (result.component) {
1470 seq_printf(seq, "Other");
1473 seq_printf(seq, "Planar logic Board");
1476 seq_printf(seq, "CPU");
1479 seq_printf(seq, "Chassis");
1482 seq_printf(seq, "Power Supply");
1485 seq_printf(seq, "Storage");
1488 seq_printf(seq, "External");
1491 seq_printf(seq, "\n");
1493 seq_printf(seq, "Component instance : %d\n",
1494 result.component_instance);
1495 seq_printf(seq, "Sensor class : %s\n",
1496 result.sensor_class ? "Analog" : "Digital");
1498 seq_printf(seq, "Sensor type : %d = ", result.sensor_type);
1499 switch (result.sensor_type) {
1501 seq_printf(seq, "Other\n");
1504 seq_printf(seq, "Thermal\n");
1507 seq_printf(seq, "DC voltage (DC volts)\n");
1510 seq_printf(seq, "AC voltage (AC volts)\n");
1513 seq_printf(seq, "DC current (DC amps)\n");
1516 seq_printf(seq, "AC current (AC volts)\n");
1519 seq_printf(seq, "Door open\n");
1522 seq_printf(seq, "Fan operational\n");
1526 seq_printf(seq, "Scaling exponent : %d\n",
1527 result.scaling_exponent);
1528 seq_printf(seq, "Actual reading : %d\n", result.actual_reading);
1529 seq_printf(seq, "Minimum reading : %d\n", result.minimum_reading);
1530 seq_printf(seq, "Low2LowCat treshold : %d\n",
1531 result.low2lowcat_treshold);
1532 seq_printf(seq, "LowCat2Low treshold : %d\n",
1533 result.lowcat2low_treshold);
1534 seq_printf(seq, "LowWarn2Low treshold : %d\n",
1535 result.lowwarn2low_treshold);
1536 seq_printf(seq, "Low2LowWarn treshold : %d\n",
1537 result.low2lowwarn_treshold);
1538 seq_printf(seq, "Norm2LowWarn treshold : %d\n",
1539 result.norm2lowwarn_treshold);
1540 seq_printf(seq, "LowWarn2Norm treshold : %d\n",
1541 result.lowwarn2norm_treshold);
1542 seq_printf(seq, "Nominal reading : %d\n", result.nominal_reading);
1543 seq_printf(seq, "HiWarn2Norm treshold : %d\n",
1544 result.hiwarn2norm_treshold);
1545 seq_printf(seq, "Norm2HiWarn treshold : %d\n",
1546 result.norm2hiwarn_treshold);
1547 seq_printf(seq, "High2HiWarn treshold : %d\n",
1548 result.high2hiwarn_treshold);
1549 seq_printf(seq, "HiWarn2High treshold : %d\n",
1550 result.hiwarn2high_treshold);
1551 seq_printf(seq, "HiCat2High treshold : %d\n",
1552 result.hicat2high_treshold);
1553 seq_printf(seq, "High2HiCat treshold : %d\n",
1554 result.hi2hicat_treshold);
1555 seq_printf(seq, "Maximum reading : %d\n", result.maximum_reading);
1557 seq_printf(seq, "Sensor state : %d = ", result.sensor_state);
1558 switch (result.sensor_state) {
1560 seq_printf(seq, "Normal\n");
1563 seq_printf(seq, "Abnormal\n");
1566 seq_printf(seq, "Unknown\n");
1569 seq_printf(seq, "Low Catastrophic (LoCat)\n");
1572 seq_printf(seq, "Low (Low)\n");
1575 seq_printf(seq, "Low Warning (LoWarn)\n");
1578 seq_printf(seq, "High Warning (HiWarn)\n");
1581 seq_printf(seq, "High (High)\n");
1584 seq_printf(seq, "High Catastrophic (HiCat)\n");
1588 seq_printf(seq, "Event_enable : 0x%02X\n", result.event_enable);
1589 seq_printf(seq, " [%s] Operational state change. \n",
1590 (result.event_enable & 0x01) ? "+" : "-");
1591 seq_printf(seq, " [%s] Low catastrophic. \n",
1592 (result.event_enable & 0x02) ? "+" : "-");
1593 seq_printf(seq, " [%s] Low reading. \n",
1594 (result.event_enable & 0x04) ? "+" : "-");
1595 seq_printf(seq, " [%s] Low warning. \n",
1596 (result.event_enable & 0x08) ? "+" : "-");
1598 " [%s] Change back to normal from out of range state. \n",
1599 (result.event_enable & 0x10) ? "+" : "-");
1600 seq_printf(seq, " [%s] High warning. \n",
1601 (result.event_enable & 0x20) ? "+" : "-");
1602 seq_printf(seq, " [%s] High reading. \n",
1603 (result.event_enable & 0x40) ? "+" : "-");
1604 seq_printf(seq, " [%s] High catastrophic. \n",
1605 (result.event_enable & 0x80) ? "+" : "-");
1610 static int i2o_seq_open_hrt(struct inode *inode, struct file *file)
1612 return single_open(file, i2o_seq_show_hrt, PDE(inode)->data);
1615 static int i2o_seq_open_lct(struct inode *inode, struct file *file)
1617 return single_open(file, i2o_seq_show_lct, PDE(inode)->data);
1620 static int i2o_seq_open_status(struct inode *inode, struct file *file)
1622 return single_open(file, i2o_seq_show_status, PDE(inode)->data);
1625 static int i2o_seq_open_hw(struct inode *inode, struct file *file)
1627 return single_open(file, i2o_seq_show_hw, PDE(inode)->data);
1630 static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file)
1632 return single_open(file, i2o_seq_show_ddm_table, PDE(inode)->data);
1635 static int i2o_seq_open_driver_store(struct inode *inode, struct file *file)
1637 return single_open(file, i2o_seq_show_driver_store, PDE(inode)->data);
1640 static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file)
1642 return single_open(file, i2o_seq_show_drivers_stored, PDE(inode)->data);
1645 static int i2o_seq_open_groups(struct inode *inode, struct file *file)
1647 return single_open(file, i2o_seq_show_groups, PDE(inode)->data);
1650 static int i2o_seq_open_phys_device(struct inode *inode, struct file *file)
1652 return single_open(file, i2o_seq_show_phys_device, PDE(inode)->data);
1655 static int i2o_seq_open_claimed(struct inode *inode, struct file *file)
1657 return single_open(file, i2o_seq_show_claimed, PDE(inode)->data);
1660 static int i2o_seq_open_users(struct inode *inode, struct file *file)
1662 return single_open(file, i2o_seq_show_users, PDE(inode)->data);
1665 static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file)
1667 return single_open(file, i2o_seq_show_priv_msgs, PDE(inode)->data);
1670 static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file)
1672 return single_open(file, i2o_seq_show_authorized_users,
1676 static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file)
1678 return single_open(file, i2o_seq_show_dev_identity, PDE(inode)->data);
1681 static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file)
1683 return single_open(file, i2o_seq_show_ddm_identity, PDE(inode)->data);
1686 static int i2o_seq_open_uinfo(struct inode *inode, struct file *file)
1688 return single_open(file, i2o_seq_show_uinfo, PDE(inode)->data);
1691 static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file)
1693 return single_open(file, i2o_seq_show_sgl_limits, PDE(inode)->data);
1696 static int i2o_seq_open_sensors(struct inode *inode, struct file *file)
1698 return single_open(file, i2o_seq_show_sensors, PDE(inode)->data);
1701 static int i2o_seq_open_dev_name(struct inode *inode, struct file *file)
1703 return single_open(file, i2o_seq_show_dev_name, PDE(inode)->data);
1706 static struct file_operations i2o_seq_fops_lct = {
1707 .open = i2o_seq_open_lct,
1709 .llseek = seq_lseek,
1710 .release = single_release,
1713 static struct file_operations i2o_seq_fops_hrt = {
1714 .open = i2o_seq_open_hrt,
1716 .llseek = seq_lseek,
1717 .release = single_release,
1720 static struct file_operations i2o_seq_fops_status = {
1721 .open = i2o_seq_open_status,
1723 .llseek = seq_lseek,
1724 .release = single_release,
1727 static struct file_operations i2o_seq_fops_hw = {
1728 .open = i2o_seq_open_hw,
1730 .llseek = seq_lseek,
1731 .release = single_release,
1734 static struct file_operations i2o_seq_fops_ddm_table = {
1735 .open = i2o_seq_open_ddm_table,
1737 .llseek = seq_lseek,
1738 .release = single_release,
1741 static struct file_operations i2o_seq_fops_driver_store = {
1742 .open = i2o_seq_open_driver_store,
1744 .llseek = seq_lseek,
1745 .release = single_release,
1748 static struct file_operations i2o_seq_fops_drivers_stored = {
1749 .open = i2o_seq_open_drivers_stored,
1751 .llseek = seq_lseek,
1752 .release = single_release,
1755 static struct file_operations i2o_seq_fops_groups = {
1756 .open = i2o_seq_open_groups,
1758 .llseek = seq_lseek,
1759 .release = single_release,
1762 static struct file_operations i2o_seq_fops_phys_device = {
1763 .open = i2o_seq_open_phys_device,
1765 .llseek = seq_lseek,
1766 .release = single_release,
1769 static struct file_operations i2o_seq_fops_claimed = {
1770 .open = i2o_seq_open_claimed,
1772 .llseek = seq_lseek,
1773 .release = single_release,
1776 static struct file_operations i2o_seq_fops_users = {
1777 .open = i2o_seq_open_users,
1779 .llseek = seq_lseek,
1780 .release = single_release,
1783 static struct file_operations i2o_seq_fops_priv_msgs = {
1784 .open = i2o_seq_open_priv_msgs,
1786 .llseek = seq_lseek,
1787 .release = single_release,
1790 static struct file_operations i2o_seq_fops_authorized_users = {
1791 .open = i2o_seq_open_authorized_users,
1793 .llseek = seq_lseek,
1794 .release = single_release,
1797 static struct file_operations i2o_seq_fops_dev_name = {
1798 .open = i2o_seq_open_dev_name,
1800 .llseek = seq_lseek,
1801 .release = single_release,
1804 static struct file_operations i2o_seq_fops_dev_identity = {
1805 .open = i2o_seq_open_dev_identity,
1807 .llseek = seq_lseek,
1808 .release = single_release,
1811 static struct file_operations i2o_seq_fops_ddm_identity = {
1812 .open = i2o_seq_open_ddm_identity,
1814 .llseek = seq_lseek,
1815 .release = single_release,
1818 static struct file_operations i2o_seq_fops_uinfo = {
1819 .open = i2o_seq_open_uinfo,
1821 .llseek = seq_lseek,
1822 .release = single_release,
1825 static struct file_operations i2o_seq_fops_sgl_limits = {
1826 .open = i2o_seq_open_sgl_limits,
1828 .llseek = seq_lseek,
1829 .release = single_release,
1832 static struct file_operations i2o_seq_fops_sensors = {
1833 .open = i2o_seq_open_sensors,
1835 .llseek = seq_lseek,
1836 .release = single_release,
1840 * IOP specific entries...write field just in case someone
1843 static i2o_proc_entry i2o_proc_generic_iop_entries[] = {
1844 {"hrt", S_IFREG | S_IRUGO, &i2o_seq_fops_hrt},
1845 {"lct", S_IFREG | S_IRUGO, &i2o_seq_fops_lct},
1846 {"status", S_IFREG | S_IRUGO, &i2o_seq_fops_status},
1847 {"hw", S_IFREG | S_IRUGO, &i2o_seq_fops_hw},
1848 {"ddm_table", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_table},
1849 {"driver_store", S_IFREG | S_IRUGO, &i2o_seq_fops_driver_store},
1850 {"drivers_stored", S_IFREG | S_IRUGO, &i2o_seq_fops_drivers_stored},
1855 * Device specific entries
1857 static i2o_proc_entry generic_dev_entries[] = {
1858 {"groups", S_IFREG | S_IRUGO, &i2o_seq_fops_groups},
1859 {"phys_dev", S_IFREG | S_IRUGO, &i2o_seq_fops_phys_device},
1860 {"claimed", S_IFREG | S_IRUGO, &i2o_seq_fops_claimed},
1861 {"users", S_IFREG | S_IRUGO, &i2o_seq_fops_users},
1862 {"priv_msgs", S_IFREG | S_IRUGO, &i2o_seq_fops_priv_msgs},
1863 {"authorized_users", S_IFREG | S_IRUGO, &i2o_seq_fops_authorized_users},
1864 {"dev_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_identity},
1865 {"ddm_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_identity},
1866 {"user_info", S_IFREG | S_IRUGO, &i2o_seq_fops_uinfo},
1867 {"sgl_limits", S_IFREG | S_IRUGO, &i2o_seq_fops_sgl_limits},
1868 {"sensors", S_IFREG | S_IRUGO, &i2o_seq_fops_sensors},
1873 * Storage unit specific entries (SCSI Periph, BS) with device names
1875 static i2o_proc_entry rbs_dev_entries[] = {
1876 {"dev_name", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_name},
1881 * i2o_proc_create_entries - Creates proc dir entries
1882 * @dir: proc dir entry under which the entries should be placed
1883 * @i2o_pe: pointer to the entries which should be added
1884 * @data: pointer to I2O controller or device
1886 * Create proc dir entries for a I2O controller or I2O device.
1888 * Returns 0 on success or negative error code on failure.
1890 static int i2o_proc_create_entries(struct proc_dir_entry *dir,
1891 i2o_proc_entry * i2o_pe, void *data)
1893 struct proc_dir_entry *tmp;
1895 while (i2o_pe->name) {
1896 tmp = create_proc_entry(i2o_pe->name, i2o_pe->mode, dir);
1901 tmp->proc_fops = i2o_pe->fops;
1910 * i2o_proc_subdir_remove - Remove child entries from a proc entry
1911 * @dir: proc dir entry from which the childs should be removed
1913 * Iterate over each i2o proc entry under dir and remove it. If the child
1914 * also has entries, remove them too.
1916 static void i2o_proc_subdir_remove(struct proc_dir_entry *dir)
1918 struct proc_dir_entry *pe, *tmp;
1922 i2o_proc_subdir_remove(pe);
1923 remove_proc_entry(pe->name, dir);
1929 * i2o_proc_device_add - Add an I2O device to the proc dir
1930 * @dir: proc dir entry to which the device should be added
1931 * @dev: I2O device which should be added
1933 * Add an I2O device to the proc dir entry dir and create the entries for
1934 * the device depending on the class of the I2O device.
1936 static void i2o_proc_device_add(struct proc_dir_entry *dir,
1937 struct i2o_device *dev)
1940 struct proc_dir_entry *devdir;
1941 i2o_proc_entry *i2o_pe = NULL;
1943 sprintf(buff, "%03x", dev->lct_data.tid);
1945 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);
1947 devdir = proc_mkdir(buff, dir);
1949 osm_warn("Could not allocate procdir!\n");
1955 i2o_proc_create_entries(devdir, generic_dev_entries, dev);
1957 /* Inform core that we want updates about this device's status */
1958 switch (dev->lct_data.class_id) {
1959 case I2O_CLASS_SCSI_PERIPHERAL:
1960 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
1961 i2o_pe = rbs_dev_entries;
1967 i2o_proc_create_entries(devdir, i2o_pe, dev);
1971 * i2o_proc_iop_add - Add an I2O controller to the i2o proc tree
1972 * @dir: parent proc dir entry
1973 * @c: I2O controller which should be added
1975 * Add the entries to the parent proc dir entry. Also each device is added
1976 * to the controllers proc dir entry.
1978 * Returns 0 on success or negative error code on failure.
1980 static int i2o_proc_iop_add(struct proc_dir_entry *dir,
1981 struct i2o_controller *c)
1983 struct proc_dir_entry *iopdir;
1984 struct i2o_device *dev;
1986 osm_debug("adding IOP /proc/i2o/%s\n", c->name);
1988 iopdir = proc_mkdir(c->name, dir);
1994 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);
1996 list_for_each_entry(dev, &c->devices, list)
1997 i2o_proc_device_add(iopdir, dev);
2003 * i2o_proc_iop_remove - Removes an I2O controller from the i2o proc tree
2004 * @dir: parent proc dir entry
2005 * @c: I2O controller which should be removed
2007 * Iterate over each i2o proc entry and search controller c. If it is found
2008 * remove it from the tree.
2010 static void i2o_proc_iop_remove(struct proc_dir_entry *dir,
2011 struct i2o_controller *c)
2013 struct proc_dir_entry *pe, *tmp;
2018 if (pe->data == c) {
2019 i2o_proc_subdir_remove(pe);
2020 remove_proc_entry(pe->name, dir);
2022 osm_debug("removing IOP /proc/i2o/%s\n", c->name);
2028 * i2o_proc_fs_create - Create the i2o proc fs.
2030 * Iterate over each I2O controller and create the entries for it.
2032 * Returns 0 on success or negative error code on failure.
2034 static int __init i2o_proc_fs_create(void)
2036 struct i2o_controller *c;
2038 i2o_proc_dir_root = proc_mkdir("i2o", NULL);
2039 if (!i2o_proc_dir_root)
2042 i2o_proc_dir_root->owner = THIS_MODULE;
2044 list_for_each_entry(c, &i2o_controllers, list)
2045 i2o_proc_iop_add(i2o_proc_dir_root, c);
2051 * i2o_proc_fs_destroy - Cleanup the all i2o proc entries
2053 * Iterate over each I2O controller and remove the entries for it.
2055 * Returns 0 on success or negative error code on failure.
2057 static int __exit i2o_proc_fs_destroy(void)
2059 struct i2o_controller *c;
2061 list_for_each_entry(c, &i2o_controllers, list)
2062 i2o_proc_iop_remove(i2o_proc_dir_root, c);
2064 remove_proc_entry("i2o", NULL);
2070 * i2o_proc_init - Init function for procfs
2072 * Registers Proc OSM and creates procfs entries.
2074 * Returns 0 on success or negative error code on failure.
2076 static int __init i2o_proc_init(void)
2080 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
2082 rc = i2o_driver_register(&i2o_proc_driver);
2086 rc = i2o_proc_fs_create();
2088 i2o_driver_unregister(&i2o_proc_driver);
2096 * i2o_proc_exit - Exit function for procfs
2098 * Unregisters Proc OSM and removes procfs entries.
2100 static void __exit i2o_proc_exit(void)
2102 i2o_driver_unregister(&i2o_proc_driver);
2103 i2o_proc_fs_destroy();
2106 MODULE_AUTHOR("Deepak Saxena");
2107 MODULE_LICENSE("GPL");
2108 MODULE_DESCRIPTION(OSM_DESCRIPTION);
2109 MODULE_VERSION(OSM_VERSION);
2111 module_init(i2o_proc_init);
2112 module_exit(i2o_proc_exit);