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 I2O_MAX_MODULES 4
32 #define FMT_U64_HEX "0x%08x%08x"
33 #define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
35 #include <linux/types.h>
36 #include <linux/kernel.h>
37 #include <linux/pci.h>
38 #include <linux/i2o.h>
39 #include <linux/proc_fs.h>
40 #include <linux/seq_file.h>
41 #include <linux/init.h>
42 #include <linux/module.h>
43 #include <linux/errno.h>
44 #include <linux/spinlock.h>
45 #include <linux/workqueue.h>
48 #include <asm/uaccess.h>
49 #include <asm/byteorder.h>
51 /* Structure used to define /proc entries */
52 typedef struct _i2o_proc_entry_t
{
53 char *name
; /* entry name */
54 mode_t mode
; /* mode */
55 struct file_operations
*fops
; /* open function */
58 /* global I2O /proc/i2o entry */
59 static struct proc_dir_entry
*i2o_proc_dir_root
;
61 /* proc OSM driver struct */
62 static struct i2o_driver i2o_proc_driver
= {
66 static int print_serial_number(struct seq_file
*seq
, u8
* serialno
, int max_len
)
71 * The I2O v1.5 (and v2.0 so far) "official specification"
72 * got serial numbers WRONG!
73 * Apparently, and despite what Section 3.4.4 says and
74 * Figure 3-35 shows (pg 3-39 in the pdf doc),
75 * the convention / consensus seems to be:
76 * + First byte is SNFormat
77 * + Second byte is SNLen (but only if SNFormat==7 (?))
78 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
80 switch (serialno
[0]) {
81 case I2O_SNFORMAT_BINARY
: /* Binary */
82 seq_printf(seq
, "0x");
83 for (i
= 0; i
< serialno
[1]; i
++) {
84 seq_printf(seq
, "%02X", serialno
[2 + i
]);
88 case I2O_SNFORMAT_ASCII
: /* ASCII */
89 if (serialno
[1] < ' ') { /* printable or SNLen? */
92 (max_len
< serialno
[1]) ? max_len
: serialno
[1];
93 serialno
[1 + max_len
] = '\0';
96 seq_printf(seq
, "%s", &serialno
[2]);
98 /* print chars for specified length */
99 for (i
= 0; i
< serialno
[1]; i
++) {
100 seq_printf(seq
, "%c", serialno
[2 + i
]);
105 case I2O_SNFORMAT_UNICODE
: /* UNICODE */
106 seq_printf(seq
, "UNICODE Format. Can't Display\n");
109 case I2O_SNFORMAT_LAN48_MAC
: /* LAN-48 MAC Address */
111 "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
112 serialno
[2], serialno
[3],
113 serialno
[4], serialno
[5], serialno
[6], serialno
[7]);
116 case I2O_SNFORMAT_WAN
: /* WAN MAC Address */
117 /* FIXME: Figure out what a WAN access address looks like?? */
118 seq_printf(seq
, "WAN Access Address");
121 /* plus new in v2.0 */
122 case I2O_SNFORMAT_LAN64_MAC
: /* LAN-64 MAC Address */
123 /* FIXME: Figure out what a LAN-64 address really looks like?? */
125 "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
126 serialno
[8], serialno
[9],
127 serialno
[2], serialno
[3],
128 serialno
[4], serialno
[5], serialno
[6], serialno
[7]);
131 case I2O_SNFORMAT_DDM
: /* I2O DDM */
133 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
134 *(u16
*) & serialno
[2],
135 *(u16
*) & serialno
[4], *(u16
*) & serialno
[6]);
138 case I2O_SNFORMAT_IEEE_REG64
: /* IEEE Registered (64-bit) */
139 case I2O_SNFORMAT_IEEE_REG128
: /* IEEE Registered (128-bit) */
140 /* FIXME: Figure if this is even close?? */
142 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
143 *(u32
*) & serialno
[2],
144 *(u32
*) & serialno
[6],
145 *(u32
*) & serialno
[10], *(u32
*) & serialno
[14]);
148 case I2O_SNFORMAT_UNKNOWN
: /* Unknown 0 */
149 case I2O_SNFORMAT_UNKNOWN2
: /* Unknown 0xff */
151 seq_printf(seq
, "Unknown data format (0x%02x)", serialno
[0]);
159 * i2o_get_class_name - do i2o class name lookup
160 * @class: class number
162 * Return a descriptive string for an i2o class
164 static const char *i2o_get_class_name(int class)
167 static char *i2o_class_name
[] = {
169 "Device Driver Module",
174 "Fibre Channel Port",
175 "Fibre Channel Device",
181 "Secondary Bus Port",
182 "Peer Transport Agent",
187 switch (class & 0xfff) {
188 case I2O_CLASS_EXECUTIVE
:
194 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
197 case I2O_CLASS_SEQUENTIAL_STORAGE
:
206 case I2O_CLASS_FIBRE_CHANNEL_PORT
:
209 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL
:
212 case I2O_CLASS_SCSI_PERIPHERAL
:
215 case I2O_CLASS_ATE_PORT
:
218 case I2O_CLASS_ATE_PERIPHERAL
:
221 case I2O_CLASS_FLOPPY_CONTROLLER
:
224 case I2O_CLASS_FLOPPY_DEVICE
:
227 case I2O_CLASS_BUS_ADAPTER_PORT
:
230 case I2O_CLASS_PEER_TRANSPORT_AGENT
:
233 case I2O_CLASS_PEER_TRANSPORT
:
238 return i2o_class_name
[idx
];
241 #define SCSI_TABLE_SIZE 13
242 static char *scsi_devices
[] = {
243 "Direct-Access Read/Write",
244 "Sequential-Access Storage",
250 "Optical Memory Device",
251 "Medium Changer Device",
252 "Communications Device",
253 "Graphics Art Pre-Press Device",
254 "Graphics Art Pre-Press Device",
255 "Array Controller Device"
258 static char *chtostr(u8
* chars
, int n
)
262 return strncat(tmp
, (char *)chars
, n
);
265 static int i2o_report_query_status(struct seq_file
*seq
, int block_status
,
268 switch (block_status
) {
270 return seq_printf(seq
, "Timeout reading group %s.\n", group
);
272 return seq_printf(seq
, "No free memory to read the table.\n");
273 case -I2O_PARAMS_STATUS_INVALID_GROUP_ID
:
274 return seq_printf(seq
, "Group %s not supported.\n", group
);
276 return seq_printf(seq
,
277 "Error reading group %s. BlockStatus 0x%02X\n",
278 group
, -block_status
);
282 static char *bus_strings
[] = {
293 int i2o_seq_show_hrt(struct seq_file
*seq
, void *v
)
295 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
296 i2o_hrt
*hrt
= (i2o_hrt
*) c
->hrt
.virt
;
300 if (hrt
->hrt_version
) {
302 "HRT table for controller is too new a version.\n");
306 seq_printf(seq
, "HRT has %d entries of %d bytes each.\n",
307 hrt
->num_entries
, hrt
->entry_len
<< 2);
309 for (i
= 0; i
< hrt
->num_entries
; i
++) {
310 seq_printf(seq
, "Entry %d:\n", i
);
311 seq_printf(seq
, " Adapter ID: %0#10x\n",
312 hrt
->hrt_entry
[i
].adapter_id
);
313 seq_printf(seq
, " Controlling tid: %0#6x\n",
314 hrt
->hrt_entry
[i
].parent_tid
);
316 if (hrt
->hrt_entry
[i
].bus_type
!= 0x80) {
317 bus
= hrt
->hrt_entry
[i
].bus_type
;
318 seq_printf(seq
, " %s Information\n",
323 seq_printf(seq
, " IOBase: %0#6x,",
324 hrt
->hrt_entry
[i
].bus
.local_bus
.
326 seq_printf(seq
, " MemoryBase: %0#10x\n",
327 hrt
->hrt_entry
[i
].bus
.local_bus
.
328 LbBaseMemoryAddress
);
332 seq_printf(seq
, " IOBase: %0#6x,",
333 hrt
->hrt_entry
[i
].bus
.isa_bus
.
335 seq_printf(seq
, " MemoryBase: %0#10x,",
336 hrt
->hrt_entry
[i
].bus
.isa_bus
.
337 IsaBaseMemoryAddress
);
338 seq_printf(seq
, " CSN: %0#4x,",
339 hrt
->hrt_entry
[i
].bus
.isa_bus
.CSN
);
343 seq_printf(seq
, " IOBase: %0#6x,",
344 hrt
->hrt_entry
[i
].bus
.eisa_bus
.
346 seq_printf(seq
, " MemoryBase: %0#10x,",
347 hrt
->hrt_entry
[i
].bus
.eisa_bus
.
348 EisaBaseMemoryAddress
);
349 seq_printf(seq
, " Slot: %0#4x,",
350 hrt
->hrt_entry
[i
].bus
.eisa_bus
.
355 seq_printf(seq
, " IOBase: %0#6x,",
356 hrt
->hrt_entry
[i
].bus
.mca_bus
.
358 seq_printf(seq
, " MemoryBase: %0#10x,",
359 hrt
->hrt_entry
[i
].bus
.mca_bus
.
360 McaBaseMemoryAddress
);
361 seq_printf(seq
, " Slot: %0#4x,",
362 hrt
->hrt_entry
[i
].bus
.mca_bus
.
367 seq_printf(seq
, " Bus: %0#4x",
368 hrt
->hrt_entry
[i
].bus
.pci_bus
.
370 seq_printf(seq
, " Dev: %0#4x",
371 hrt
->hrt_entry
[i
].bus
.pci_bus
.
373 seq_printf(seq
, " Func: %0#4x",
374 hrt
->hrt_entry
[i
].bus
.pci_bus
.
376 seq_printf(seq
, " Vendor: %0#6x",
377 hrt
->hrt_entry
[i
].bus
.pci_bus
.
379 seq_printf(seq
, " Device: %0#6x\n",
380 hrt
->hrt_entry
[i
].bus
.pci_bus
.
385 seq_printf(seq
, " Unsupported Bus Type\n");
388 seq_printf(seq
, " Unknown Bus Type\n");
394 int i2o_seq_show_lct(struct seq_file
*seq
, void *v
)
396 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
397 i2o_lct
*lct
= (i2o_lct
*) c
->lct
;
401 #define BUS_TABLE_SIZE 3
402 static char *bus_ports
[] = {
408 entries
= (lct
->table_size
- 3) / 9;
410 seq_printf(seq
, "LCT contains %d %s\n", entries
,
411 entries
== 1 ? "entry" : "entries");
413 seq_printf(seq
, "Boot Device @ ID %d\n", lct
->boot_tid
);
415 seq_printf(seq
, "Current Change Indicator: %#10x\n", lct
->change_ind
);
417 for (i
= 0; i
< entries
; i
++) {
418 seq_printf(seq
, "Entry %d\n", i
);
419 seq_printf(seq
, " Class, SubClass : %s",
420 i2o_get_class_name(lct
->lct_entry
[i
].class_id
));
423 * Classes which we'll print subclass info for
425 switch (lct
->lct_entry
[i
].class_id
& 0xFFF) {
426 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
427 switch (lct
->lct_entry
[i
].sub_class
) {
429 seq_printf(seq
, ", Direct-Access Read/Write");
433 seq_printf(seq
, ", WORM Drive");
437 seq_printf(seq
, ", CD-ROM Drive");
441 seq_printf(seq
, ", Optical Memory Device");
445 seq_printf(seq
, ", Unknown (0x%02x)",
446 lct
->lct_entry
[i
].sub_class
);
452 switch (lct
->lct_entry
[i
].sub_class
& 0xFF) {
454 seq_printf(seq
, ", Ethernet");
458 seq_printf(seq
, ", 100base VG");
462 seq_printf(seq
, ", IEEE 802.5/Token-Ring");
466 seq_printf(seq
, ", ANSI X3T9.5 FDDI");
470 seq_printf(seq
, ", Fibre Channel");
474 seq_printf(seq
, ", Unknown Sub-Class (0x%02x)",
475 lct
->lct_entry
[i
].sub_class
& 0xFF);
480 case I2O_CLASS_SCSI_PERIPHERAL
:
481 if (lct
->lct_entry
[i
].sub_class
< SCSI_TABLE_SIZE
)
482 seq_printf(seq
, ", %s",
483 scsi_devices
[lct
->lct_entry
[i
].
486 seq_printf(seq
, ", Unknown Device Type");
489 case I2O_CLASS_BUS_ADAPTER_PORT
:
490 if (lct
->lct_entry
[i
].sub_class
< BUS_TABLE_SIZE
)
491 seq_printf(seq
, ", %s",
492 bus_ports
[lct
->lct_entry
[i
].
495 seq_printf(seq
, ", Unknown Bus Type");
498 seq_printf(seq
, "\n");
500 seq_printf(seq
, " Local TID : 0x%03x\n",
501 lct
->lct_entry
[i
].tid
);
502 seq_printf(seq
, " User TID : 0x%03x\n",
503 lct
->lct_entry
[i
].user_tid
);
504 seq_printf(seq
, " Parent TID : 0x%03x\n",
505 lct
->lct_entry
[i
].parent_tid
);
506 seq_printf(seq
, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
507 lct
->lct_entry
[i
].identity_tag
[0],
508 lct
->lct_entry
[i
].identity_tag
[1],
509 lct
->lct_entry
[i
].identity_tag
[2],
510 lct
->lct_entry
[i
].identity_tag
[3],
511 lct
->lct_entry
[i
].identity_tag
[4],
512 lct
->lct_entry
[i
].identity_tag
[5],
513 lct
->lct_entry
[i
].identity_tag
[6],
514 lct
->lct_entry
[i
].identity_tag
[7]);
515 seq_printf(seq
, " Change Indicator : %0#10x\n",
516 lct
->lct_entry
[i
].change_ind
);
517 seq_printf(seq
, " Event Capab Mask : %0#10x\n",
518 lct
->lct_entry
[i
].device_flags
);
524 int i2o_seq_show_status(struct seq_file
*seq
, void *v
)
526 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
529 i2o_status_block
*sb
= c
->status_block
.virt
;
531 i2o_status_get(c
); // reread the status block
533 seq_printf(seq
, "Organization ID : %0#6x\n", sb
->org_id
);
535 version
= sb
->i2o_version
;
537 /* FIXME for Spec 2.0
538 if (version == 0x02) {
539 seq_printf(seq, "Lowest I2O version supported: ");
540 switch(workspace[2]) {
542 seq_printf(seq, "1.0\n");
545 seq_printf(seq, "1.5\n");
548 seq_printf(seq, "2.0\n");
552 seq_printf(seq, "Highest I2O version supported: ");
553 switch(workspace[3]) {
555 seq_printf(seq, "1.0\n");
558 seq_printf(seq, "1.5\n");
561 seq_printf(seq, "2.0\n");
566 seq_printf(seq
, "IOP ID : %0#5x\n", sb
->iop_id
);
567 seq_printf(seq
, "Host Unit ID : %0#6x\n", sb
->host_unit_id
);
568 seq_printf(seq
, "Segment Number : %0#5x\n", sb
->segment_number
);
570 seq_printf(seq
, "I2O version : ");
573 seq_printf(seq
, "1.0\n");
576 seq_printf(seq
, "1.5\n");
579 seq_printf(seq
, "2.0\n");
582 seq_printf(seq
, "Unknown version\n");
585 seq_printf(seq
, "IOP State : ");
586 switch (sb
->iop_state
) {
588 seq_printf(seq
, "INIT\n");
592 seq_printf(seq
, "RESET\n");
596 seq_printf(seq
, "HOLD\n");
600 seq_printf(seq
, "READY\n");
604 seq_printf(seq
, "OPERATIONAL\n");
608 seq_printf(seq
, "FAILED\n");
612 seq_printf(seq
, "FAULTED\n");
616 seq_printf(seq
, "Unknown\n");
620 seq_printf(seq
, "Messenger Type : ");
621 switch (sb
->msg_type
) {
623 seq_printf(seq
, "Memory mapped\n");
626 seq_printf(seq
, "Memory mapped only\n");
629 seq_printf(seq
, "Remote only\n");
632 seq_printf(seq
, "Memory mapped and remote\n");
635 seq_printf(seq
, "Unknown\n");
638 seq_printf(seq
, "Inbound Frame Size : %d bytes\n",
639 sb
->inbound_frame_size
<< 2);
640 seq_printf(seq
, "Max Inbound Frames : %d\n",
641 sb
->max_inbound_frames
);
642 seq_printf(seq
, "Current Inbound Frames : %d\n",
643 sb
->cur_inbound_frames
);
644 seq_printf(seq
, "Max Outbound Frames : %d\n",
645 sb
->max_outbound_frames
);
647 /* Spec doesn't say if NULL terminated or not... */
648 memcpy(prodstr
, sb
->product_id
, 24);
650 seq_printf(seq
, "Product ID : %s\n", prodstr
);
651 seq_printf(seq
, "Expected LCT Size : %d bytes\n",
652 sb
->expected_lct_size
);
654 seq_printf(seq
, "IOP Capabilities\n");
655 seq_printf(seq
, " Context Field Size Support : ");
656 switch (sb
->iop_capabilities
& 0x0000003) {
658 seq_printf(seq
, "Supports only 32-bit context fields\n");
661 seq_printf(seq
, "Supports only 64-bit context fields\n");
664 seq_printf(seq
, "Supports 32-bit and 64-bit context fields, "
665 "but not concurrently\n");
668 seq_printf(seq
, "Supports 32-bit and 64-bit context fields "
672 seq_printf(seq
, "0x%08x\n", sb
->iop_capabilities
);
674 seq_printf(seq
, " Current Context Field Size : ");
675 switch (sb
->iop_capabilities
& 0x0000000C) {
677 seq_printf(seq
, "not configured\n");
680 seq_printf(seq
, "Supports only 32-bit context fields\n");
683 seq_printf(seq
, "Supports only 64-bit context fields\n");
686 seq_printf(seq
, "Supports both 32-bit or 64-bit context fields "
690 seq_printf(seq
, "\n");
692 seq_printf(seq
, " Inbound Peer Support : %s\n",
694 iop_capabilities
& 0x00000010) ? "Supported" :
696 seq_printf(seq
, " Outbound Peer Support : %s\n",
698 iop_capabilities
& 0x00000020) ? "Supported" :
700 seq_printf(seq
, " Peer to Peer Support : %s\n",
702 iop_capabilities
& 0x00000040) ? "Supported" :
705 seq_printf(seq
, "Desired private memory size : %d kB\n",
706 sb
->desired_mem_size
>> 10);
707 seq_printf(seq
, "Allocated private memory size : %d kB\n",
708 sb
->current_mem_size
>> 10);
709 seq_printf(seq
, "Private memory base address : %0#10x\n",
710 sb
->current_mem_base
);
711 seq_printf(seq
, "Desired private I/O size : %d kB\n",
712 sb
->desired_io_size
>> 10);
713 seq_printf(seq
, "Allocated private I/O size : %d kB\n",
714 sb
->current_io_size
>> 10);
715 seq_printf(seq
, "Private I/O base address : %0#10x\n",
716 sb
->current_io_base
);
721 int i2o_seq_show_hw(struct seq_file
*seq
, void *v
)
723 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
724 static u32 work32
[5];
725 static u8
*work8
= (u8
*) work32
;
726 static u16
*work16
= (u16
*) work32
;
730 static char *cpu_table
[] = {
731 "Intel 80960 series",
733 "Motorola 68000 series",
742 i2o_parm_field_get(c
->exec
, 0x0000, -1, &work32
, sizeof(work32
));
745 i2o_report_query_status(seq
, token
, "0x0000 IOP Hardware");
749 seq_printf(seq
, "I2O Vendor ID : %0#6x\n", work16
[0]);
750 seq_printf(seq
, "Product ID : %0#6x\n", work16
[1]);
751 seq_printf(seq
, "CPU : ");
753 seq_printf(seq
, "Unknown\n");
755 seq_printf(seq
, "%s\n", cpu_table
[work8
[16]]);
756 /* Anyone using ProcessorVersion? */
758 seq_printf(seq
, "RAM : %dkB\n", work32
[1] >> 10);
759 seq_printf(seq
, "Non-Volatile Mem : %dkB\n", work32
[2] >> 10);
762 seq_printf(seq
, "Capabilities : 0x%08x\n", hwcap
);
763 seq_printf(seq
, " [%s] Self booting\n",
764 (hwcap
& 0x00000001) ? "+" : "-");
765 seq_printf(seq
, " [%s] Upgradable IRTOS\n",
766 (hwcap
& 0x00000002) ? "+" : "-");
767 seq_printf(seq
, " [%s] Supports downloading DDMs\n",
768 (hwcap
& 0x00000004) ? "+" : "-");
769 seq_printf(seq
, " [%s] Supports installing DDMs\n",
770 (hwcap
& 0x00000008) ? "+" : "-");
771 seq_printf(seq
, " [%s] Battery-backed RAM\n",
772 (hwcap
& 0x00000010) ? "+" : "-");
777 /* Executive group 0003h - Executing DDM List (table) */
778 int i2o_seq_show_ddm_table(struct seq_file
*seq
, void *v
)
780 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
784 typedef struct _i2o_exec_execute_ddm_table
{
790 u8 module_name_version
[28];
793 } i2o_exec_execute_ddm_table
;
803 i2o_exec_execute_ddm_table ddm_table
[I2O_MAX_MODULES
];
806 i2o_exec_execute_ddm_table ddm_table
;
808 result
= kmalloc(sizeof(*result
), GFP_KERNEL
);
812 token
= i2o_parm_table_get(c
->exec
, I2O_PARAMS_TABLE_GET
, 0x0003, -1,
813 NULL
, 0, result
, sizeof(*result
));
816 i2o_report_query_status(seq
, token
,
817 "0x0003 Executing DDM List");
822 "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
823 ddm_table
= result
->ddm_table
[0];
825 for (i
= 0; i
< result
->row_count
; ddm_table
= result
->ddm_table
[++i
]) {
826 seq_printf(seq
, "0x%03x ", ddm_table
.ddm_tid
& 0xFFF);
828 switch (ddm_table
.module_type
) {
830 seq_printf(seq
, "Downloaded DDM ");
833 seq_printf(seq
, "Embedded DDM ");
836 seq_printf(seq
, " ");
839 seq_printf(seq
, "%-#7x", ddm_table
.i2o_vendor_id
);
840 seq_printf(seq
, "%-#8x", ddm_table
.module_id
);
841 seq_printf(seq
, "%-29s",
842 chtostr(ddm_table
.module_name_version
, 28));
843 seq_printf(seq
, "%9d ", ddm_table
.data_size
);
844 seq_printf(seq
, "%8d", ddm_table
.code_size
);
846 seq_printf(seq
, "\n");
853 /* Executive group 0004h - Driver Store (scalar) */
854 int i2o_seq_show_driver_store(struct seq_file
*seq
, void *v
)
856 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
861 i2o_parm_field_get(c
->exec
, 0x0004, -1, &work32
, sizeof(work32
));
863 i2o_report_query_status(seq
, token
, "0x0004 Driver Store");
867 seq_printf(seq
, "Module limit : %d\n"
868 "Module count : %d\n"
869 "Current space : %d kB\n"
870 "Free space : %d kB\n",
871 work32
[0], work32
[1], work32
[2] >> 10, work32
[3] >> 10);
876 /* Executive group 0005h - Driver Store Table (table) */
877 int i2o_seq_show_drivers_stored(struct seq_file
*seq
, void *v
)
879 typedef struct _i2o_driver_store
{
880 u16 stored_ddm_index
;
885 u8 module_name_version
[28];
890 } i2o_driver_store_table
;
892 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
904 i2o_driver_store_table dst
[I2O_MAX_MODULES
];
905 } i2o_driver_result_table
;
907 i2o_driver_result_table
*result
;
908 i2o_driver_store_table
*dst
;
910 result
= kmalloc(sizeof(i2o_driver_result_table
), GFP_KERNEL
);
914 token
= i2o_parm_table_get(c
->exec
, I2O_PARAMS_TABLE_GET
, 0x0005, -1,
915 NULL
, 0, result
, sizeof(*result
));
918 i2o_report_query_status(seq
, token
,
919 "0x0005 DRIVER STORE TABLE");
925 "# Module_type Vendor Mod_id Module_name Vrs"
926 "Date Mod_size Par_size Flags\n");
927 for (i
= 0, dst
= &result
->dst
[0]; i
< result
->row_count
;
928 dst
= &result
->dst
[++i
]) {
929 seq_printf(seq
, "%-3d", dst
->stored_ddm_index
);
930 switch (dst
->module_type
) {
932 seq_printf(seq
, "Downloaded DDM ");
935 seq_printf(seq
, "Embedded DDM ");
938 seq_printf(seq
, " ");
942 if (c
->i2oversion
== 0x02)
943 seq_printf(seq
, "%-d", dst
->module_state
);
946 seq_printf(seq
, "%-#7x", dst
->i2o_vendor_id
);
947 seq_printf(seq
, "%-#8x", dst
->module_id
);
948 seq_printf(seq
, "%-29s", chtostr(dst
->module_name_version
, 28));
949 seq_printf(seq
, "%-9s", chtostr(dst
->date
, 8));
950 seq_printf(seq
, "%8d ", dst
->module_size
);
951 seq_printf(seq
, "%8d ", dst
->mpb_size
);
952 seq_printf(seq
, "0x%04x", dst
->module_flags
);
954 if (c
->i2oversion
== 0x02)
955 seq_printf(seq
, "%d", dst
->notification_level
);
957 seq_printf(seq
, "\n");
964 /* Generic group F000h - Params Descriptor (table) */
965 int i2o_seq_show_groups(struct seq_file
*seq
, void *v
)
967 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
972 typedef struct _i2o_group_info
{
988 i2o_group_info group
[256];
991 result
= kmalloc(sizeof(*result
), GFP_KERNEL
);
995 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF000, -1, NULL
, 0,
996 result
, sizeof(*result
));
999 i2o_report_query_status(seq
, token
, "0xF000 Params Descriptor");
1004 "# Group FieldCount RowCount Type Add Del Clear\n");
1006 for (i
= 0; i
< result
->row_count
; i
++) {
1007 seq_printf(seq
, "%-3d", i
);
1008 seq_printf(seq
, "0x%04X ", result
->group
[i
].group_number
);
1009 seq_printf(seq
, "%10d ", result
->group
[i
].field_count
);
1010 seq_printf(seq
, "%8d ", result
->group
[i
].row_count
);
1012 properties
= result
->group
[i
].properties
;
1013 if (properties
& 0x1)
1014 seq_printf(seq
, "Table ");
1016 seq_printf(seq
, "Scalar ");
1017 if (properties
& 0x2)
1018 seq_printf(seq
, " + ");
1020 seq_printf(seq
, " - ");
1021 if (properties
& 0x4)
1022 seq_printf(seq
, " + ");
1024 seq_printf(seq
, " - ");
1025 if (properties
& 0x8)
1026 seq_printf(seq
, " + ");
1028 seq_printf(seq
, " - ");
1030 seq_printf(seq
, "\n");
1033 if (result
->more_flag
)
1034 seq_printf(seq
, "There is more...\n");
1040 /* Generic group F001h - Physical Device Table (table) */
1041 int i2o_seq_show_phys_device(struct seq_file
*seq
, void *v
)
1043 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1058 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF001, -1, NULL
, 0,
1059 &result
, sizeof(result
));
1062 i2o_report_query_status(seq
, token
,
1063 "0xF001 Physical Device Table");
1067 if (result
.row_count
)
1068 seq_printf(seq
, "# AdapterId\n");
1070 for (i
= 0; i
< result
.row_count
; i
++) {
1071 seq_printf(seq
, "%-2d", i
);
1072 seq_printf(seq
, "%#7x\n", result
.adapter_id
[i
]);
1075 if (result
.more_flag
)
1076 seq_printf(seq
, "There is more...\n");
1081 /* Generic group F002h - Claimed Table (table) */
1082 int i2o_seq_show_claimed(struct seq_file
*seq
, void *v
)
1084 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1096 u16 claimed_tid
[64];
1099 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF002, -1, NULL
, 0,
1100 &result
, sizeof(result
));
1103 i2o_report_query_status(seq
, token
, "0xF002 Claimed Table");
1107 if (result
.row_count
)
1108 seq_printf(seq
, "# ClaimedTid\n");
1110 for (i
= 0; i
< result
.row_count
; i
++) {
1111 seq_printf(seq
, "%-2d", i
);
1112 seq_printf(seq
, "%#7x\n", result
.claimed_tid
[i
]);
1115 if (result
.more_flag
)
1116 seq_printf(seq
, "There is more...\n");
1121 /* Generic group F003h - User Table (table) */
1122 int i2o_seq_show_users(struct seq_file
*seq
, void *v
)
1124 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1128 typedef struct _i2o_user_table
{
1144 i2o_user_table user
[64];
1147 result
= kmalloc(sizeof(*result
), GFP_KERNEL
);
1151 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF003, -1, NULL
, 0,
1152 result
, sizeof(*result
));
1155 i2o_report_query_status(seq
, token
, "0xF003 User Table");
1159 seq_printf(seq
, "# Instance UserTid ClaimType\n");
1161 for (i
= 0; i
< result
->row_count
; i
++) {
1162 seq_printf(seq
, "%-3d", i
);
1163 seq_printf(seq
, "%#8x ", result
->user
[i
].instance
);
1164 seq_printf(seq
, "%#7x ", result
->user
[i
].user_tid
);
1165 seq_printf(seq
, "%#9x\n", result
->user
[i
].claim_type
);
1168 if (result
->more_flag
)
1169 seq_printf(seq
, "There is more...\n");
1175 /* Generic group F005h - Private message extensions (table) (optional) */
1176 int i2o_seq_show_priv_msgs(struct seq_file
*seq
, void *v
)
1178 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1182 typedef struct _i2o_private
{
1184 u16 organization_id
;
1185 u16 x_function_code
;
1196 i2o_private extension
[64];
1199 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF000, -1, NULL
, 0,
1200 &result
, sizeof(result
));
1203 i2o_report_query_status(seq
, token
,
1204 "0xF005 Private Message Extensions (optional)");
1208 seq_printf(seq
, "Instance# OrgId FunctionCode\n");
1210 for (i
= 0; i
< result
.row_count
; i
++) {
1211 seq_printf(seq
, "%0#9x ", result
.extension
[i
].ext_instance
);
1212 seq_printf(seq
, "%0#6x ", result
.extension
[i
].organization_id
);
1213 seq_printf(seq
, "%0#6x", result
.extension
[i
].x_function_code
);
1215 seq_printf(seq
, "\n");
1218 if (result
.more_flag
)
1219 seq_printf(seq
, "There is more...\n");
1224 /* Generic group F006h - Authorized User Table (table) */
1225 int i2o_seq_show_authorized_users(struct seq_file
*seq
, void *v
)
1227 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1239 u32 alternate_tid
[64];
1242 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF006, -1, NULL
, 0,
1243 &result
, sizeof(result
));
1246 i2o_report_query_status(seq
, token
,
1247 "0xF006 Autohorized User Table");
1251 if (result
.row_count
)
1252 seq_printf(seq
, "# AlternateTid\n");
1254 for (i
= 0; i
< result
.row_count
; i
++) {
1255 seq_printf(seq
, "%-2d", i
);
1256 seq_printf(seq
, "%#7x ", result
.alternate_tid
[i
]);
1259 if (result
.more_flag
)
1260 seq_printf(seq
, "There is more...\n");
1265 /* Generic group F100h - Device Identity (scalar) */
1266 int i2o_seq_show_dev_identity(struct seq_file
*seq
, void *v
)
1268 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1269 static u32 work32
[128]; // allow for "stuff" + up to 256 byte (max) serial number
1270 // == (allow) 512d bytes (max)
1271 static u16
*work16
= (u16
*) work32
;
1274 token
= i2o_parm_field_get(d
, 0xF100, -1, &work32
, sizeof(work32
));
1277 i2o_report_query_status(seq
, token
, "0xF100 Device Identity");
1281 seq_printf(seq
, "Device Class : %s\n", i2o_get_class_name(work16
[0]));
1282 seq_printf(seq
, "Owner TID : %0#5x\n", work16
[2]);
1283 seq_printf(seq
, "Parent TID : %0#5x\n", work16
[3]);
1284 seq_printf(seq
, "Vendor info : %s\n",
1285 chtostr((u8
*) (work32
+ 2), 16));
1286 seq_printf(seq
, "Product info : %s\n",
1287 chtostr((u8
*) (work32
+ 6), 16));
1288 seq_printf(seq
, "Description : %s\n",
1289 chtostr((u8
*) (work32
+ 10), 16));
1290 seq_printf(seq
, "Product rev. : %s\n",
1291 chtostr((u8
*) (work32
+ 14), 8));
1293 seq_printf(seq
, "Serial number : ");
1294 print_serial_number(seq
, (u8
*) (work32
+ 16),
1295 /* allow for SNLen plus
1296 * possible trailing '\0'
1298 sizeof(work32
) - (16 * sizeof(u32
)) - 2);
1299 seq_printf(seq
, "\n");
1304 int i2o_seq_show_dev_name(struct seq_file
*seq
, void *v
)
1306 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1308 seq_printf(seq
, "%s\n", d
->device
.bus_id
);
1313 /* Generic group F101h - DDM Identity (scalar) */
1314 int i2o_seq_show_ddm_identity(struct seq_file
*seq
, void *v
)
1316 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1324 u8 serial_number
[12];
1325 u8 pad
[256]; // allow up to 256 byte (max) serial number
1328 token
= i2o_parm_field_get(d
, 0xF101, -1, &result
, sizeof(result
));
1331 i2o_report_query_status(seq
, token
, "0xF101 DDM Identity");
1335 seq_printf(seq
, "Registering DDM TID : 0x%03x\n", result
.ddm_tid
);
1336 seq_printf(seq
, "Module name : %s\n",
1337 chtostr(result
.module_name
, 24));
1338 seq_printf(seq
, "Module revision : %s\n",
1339 chtostr(result
.module_rev
, 8));
1341 seq_printf(seq
, "Serial number : ");
1342 print_serial_number(seq
, result
.serial_number
, sizeof(result
) - 36);
1343 /* allow for SNLen plus possible trailing '\0' */
1345 seq_printf(seq
, "\n");
1350 /* Generic group F102h - User Information (scalar) */
1351 int i2o_seq_show_uinfo(struct seq_file
*seq
, void *v
)
1353 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1358 u8 service_name
[64];
1359 u8 physical_location
[64];
1360 u8 instance_number
[4];
1363 token
= i2o_parm_field_get(d
, 0xF102, -1, &result
, sizeof(result
));
1366 i2o_report_query_status(seq
, token
, "0xF102 User Information");
1370 seq_printf(seq
, "Device name : %s\n",
1371 chtostr(result
.device_name
, 64));
1372 seq_printf(seq
, "Service name : %s\n",
1373 chtostr(result
.service_name
, 64));
1374 seq_printf(seq
, "Physical name : %s\n",
1375 chtostr(result
.physical_location
, 64));
1376 seq_printf(seq
, "Instance number : %s\n",
1377 chtostr(result
.instance_number
, 4));
1382 /* Generic group F103h - SGL Operating Limits (scalar) */
1383 int i2o_seq_show_sgl_limits(struct seq_file
*seq
, void *v
)
1385 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1386 static u32 work32
[12];
1387 static u16
*work16
= (u16
*) work32
;
1388 static u8
*work8
= (u8
*) work32
;
1391 token
= i2o_parm_field_get(d
, 0xF103, -1, &work32
, sizeof(work32
));
1394 i2o_report_query_status(seq
, token
,
1395 "0xF103 SGL Operating Limits");
1399 seq_printf(seq
, "SGL chain size : %d\n", work32
[0]);
1400 seq_printf(seq
, "Max SGL chain size : %d\n", work32
[1]);
1401 seq_printf(seq
, "SGL chain size target : %d\n", work32
[2]);
1402 seq_printf(seq
, "SGL frag count : %d\n", work16
[6]);
1403 seq_printf(seq
, "Max SGL frag count : %d\n", work16
[7]);
1404 seq_printf(seq
, "SGL frag count target : %d\n", work16
[8]);
1407 if (d->i2oversion == 0x02)
1410 seq_printf(seq
, "SGL data alignment : %d\n", work16
[8]);
1411 seq_printf(seq
, "SGL addr limit : %d\n", work8
[20]);
1412 seq_printf(seq
, "SGL addr sizes supported : ");
1413 if (work8
[21] & 0x01)
1414 seq_printf(seq
, "32 bit ");
1415 if (work8
[21] & 0x02)
1416 seq_printf(seq
, "64 bit ");
1417 if (work8
[21] & 0x04)
1418 seq_printf(seq
, "96 bit ");
1419 if (work8
[21] & 0x08)
1420 seq_printf(seq
, "128 bit ");
1421 seq_printf(seq
, "\n");
1429 /* Generic group F200h - Sensors (scalar) */
1430 int i2o_seq_show_sensors(struct seq_file
*seq
, void *v
)
1432 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1436 u16 sensor_instance
;
1438 u16 component_instance
;
1441 u8 scaling_exponent
;
1443 u32 minimum_reading
;
1444 u32 low2lowcat_treshold
;
1445 u32 lowcat2low_treshold
;
1446 u32 lowwarn2low_treshold
;
1447 u32 low2lowwarn_treshold
;
1448 u32 norm2lowwarn_treshold
;
1449 u32 lowwarn2norm_treshold
;
1450 u32 nominal_reading
;
1451 u32 hiwarn2norm_treshold
;
1452 u32 norm2hiwarn_treshold
;
1453 u32 high2hiwarn_treshold
;
1454 u32 hiwarn2high_treshold
;
1455 u32 hicat2high_treshold
;
1456 u32 hi2hicat_treshold
;
1457 u32 maximum_reading
;
1462 token
= i2o_parm_field_get(d
, 0xF200, -1, &result
, sizeof(result
));
1465 i2o_report_query_status(seq
, token
,
1466 "0xF200 Sensors (optional)");
1470 seq_printf(seq
, "Sensor instance : %d\n", result
.sensor_instance
);
1472 seq_printf(seq
, "Component : %d = ", result
.component
);
1473 switch (result
.component
) {
1475 seq_printf(seq
, "Other");
1478 seq_printf(seq
, "Planar logic Board");
1481 seq_printf(seq
, "CPU");
1484 seq_printf(seq
, "Chassis");
1487 seq_printf(seq
, "Power Supply");
1490 seq_printf(seq
, "Storage");
1493 seq_printf(seq
, "External");
1496 seq_printf(seq
, "\n");
1498 seq_printf(seq
, "Component instance : %d\n",
1499 result
.component_instance
);
1500 seq_printf(seq
, "Sensor class : %s\n",
1501 result
.sensor_class
? "Analog" : "Digital");
1503 seq_printf(seq
, "Sensor type : %d = ", result
.sensor_type
);
1504 switch (result
.sensor_type
) {
1506 seq_printf(seq
, "Other\n");
1509 seq_printf(seq
, "Thermal\n");
1512 seq_printf(seq
, "DC voltage (DC volts)\n");
1515 seq_printf(seq
, "AC voltage (AC volts)\n");
1518 seq_printf(seq
, "DC current (DC amps)\n");
1521 seq_printf(seq
, "AC current (AC volts)\n");
1524 seq_printf(seq
, "Door open\n");
1527 seq_printf(seq
, "Fan operational\n");
1531 seq_printf(seq
, "Scaling exponent : %d\n",
1532 result
.scaling_exponent
);
1533 seq_printf(seq
, "Actual reading : %d\n", result
.actual_reading
);
1534 seq_printf(seq
, "Minimum reading : %d\n", result
.minimum_reading
);
1535 seq_printf(seq
, "Low2LowCat treshold : %d\n",
1536 result
.low2lowcat_treshold
);
1537 seq_printf(seq
, "LowCat2Low treshold : %d\n",
1538 result
.lowcat2low_treshold
);
1539 seq_printf(seq
, "LowWarn2Low treshold : %d\n",
1540 result
.lowwarn2low_treshold
);
1541 seq_printf(seq
, "Low2LowWarn treshold : %d\n",
1542 result
.low2lowwarn_treshold
);
1543 seq_printf(seq
, "Norm2LowWarn treshold : %d\n",
1544 result
.norm2lowwarn_treshold
);
1545 seq_printf(seq
, "LowWarn2Norm treshold : %d\n",
1546 result
.lowwarn2norm_treshold
);
1547 seq_printf(seq
, "Nominal reading : %d\n", result
.nominal_reading
);
1548 seq_printf(seq
, "HiWarn2Norm treshold : %d\n",
1549 result
.hiwarn2norm_treshold
);
1550 seq_printf(seq
, "Norm2HiWarn treshold : %d\n",
1551 result
.norm2hiwarn_treshold
);
1552 seq_printf(seq
, "High2HiWarn treshold : %d\n",
1553 result
.high2hiwarn_treshold
);
1554 seq_printf(seq
, "HiWarn2High treshold : %d\n",
1555 result
.hiwarn2high_treshold
);
1556 seq_printf(seq
, "HiCat2High treshold : %d\n",
1557 result
.hicat2high_treshold
);
1558 seq_printf(seq
, "High2HiCat treshold : %d\n",
1559 result
.hi2hicat_treshold
);
1560 seq_printf(seq
, "Maximum reading : %d\n", result
.maximum_reading
);
1562 seq_printf(seq
, "Sensor state : %d = ", result
.sensor_state
);
1563 switch (result
.sensor_state
) {
1565 seq_printf(seq
, "Normal\n");
1568 seq_printf(seq
, "Abnormal\n");
1571 seq_printf(seq
, "Unknown\n");
1574 seq_printf(seq
, "Low Catastrophic (LoCat)\n");
1577 seq_printf(seq
, "Low (Low)\n");
1580 seq_printf(seq
, "Low Warning (LoWarn)\n");
1583 seq_printf(seq
, "High Warning (HiWarn)\n");
1586 seq_printf(seq
, "High (High)\n");
1589 seq_printf(seq
, "High Catastrophic (HiCat)\n");
1593 seq_printf(seq
, "Event_enable : 0x%02X\n", result
.event_enable
);
1594 seq_printf(seq
, " [%s] Operational state change. \n",
1595 (result
.event_enable
& 0x01) ? "+" : "-");
1596 seq_printf(seq
, " [%s] Low catastrophic. \n",
1597 (result
.event_enable
& 0x02) ? "+" : "-");
1598 seq_printf(seq
, " [%s] Low reading. \n",
1599 (result
.event_enable
& 0x04) ? "+" : "-");
1600 seq_printf(seq
, " [%s] Low warning. \n",
1601 (result
.event_enable
& 0x08) ? "+" : "-");
1603 " [%s] Change back to normal from out of range state. \n",
1604 (result
.event_enable
& 0x10) ? "+" : "-");
1605 seq_printf(seq
, " [%s] High warning. \n",
1606 (result
.event_enable
& 0x20) ? "+" : "-");
1607 seq_printf(seq
, " [%s] High reading. \n",
1608 (result
.event_enable
& 0x40) ? "+" : "-");
1609 seq_printf(seq
, " [%s] High catastrophic. \n",
1610 (result
.event_enable
& 0x80) ? "+" : "-");
1615 static int i2o_seq_open_hrt(struct inode
*inode
, struct file
*file
)
1617 return single_open(file
, i2o_seq_show_hrt
, PDE(inode
)->data
);
1620 static int i2o_seq_open_lct(struct inode
*inode
, struct file
*file
)
1622 return single_open(file
, i2o_seq_show_lct
, PDE(inode
)->data
);
1625 static int i2o_seq_open_status(struct inode
*inode
, struct file
*file
)
1627 return single_open(file
, i2o_seq_show_status
, PDE(inode
)->data
);
1630 static int i2o_seq_open_hw(struct inode
*inode
, struct file
*file
)
1632 return single_open(file
, i2o_seq_show_hw
, PDE(inode
)->data
);
1635 static int i2o_seq_open_ddm_table(struct inode
*inode
, struct file
*file
)
1637 return single_open(file
, i2o_seq_show_ddm_table
, PDE(inode
)->data
);
1640 static int i2o_seq_open_driver_store(struct inode
*inode
, struct file
*file
)
1642 return single_open(file
, i2o_seq_show_driver_store
, PDE(inode
)->data
);
1645 static int i2o_seq_open_drivers_stored(struct inode
*inode
, struct file
*file
)
1647 return single_open(file
, i2o_seq_show_drivers_stored
, PDE(inode
)->data
);
1650 static int i2o_seq_open_groups(struct inode
*inode
, struct file
*file
)
1652 return single_open(file
, i2o_seq_show_groups
, PDE(inode
)->data
);
1655 static int i2o_seq_open_phys_device(struct inode
*inode
, struct file
*file
)
1657 return single_open(file
, i2o_seq_show_phys_device
, PDE(inode
)->data
);
1660 static int i2o_seq_open_claimed(struct inode
*inode
, struct file
*file
)
1662 return single_open(file
, i2o_seq_show_claimed
, PDE(inode
)->data
);
1665 static int i2o_seq_open_users(struct inode
*inode
, struct file
*file
)
1667 return single_open(file
, i2o_seq_show_users
, PDE(inode
)->data
);
1670 static int i2o_seq_open_priv_msgs(struct inode
*inode
, struct file
*file
)
1672 return single_open(file
, i2o_seq_show_priv_msgs
, PDE(inode
)->data
);
1675 static int i2o_seq_open_authorized_users(struct inode
*inode
, struct file
*file
)
1677 return single_open(file
, i2o_seq_show_authorized_users
,
1681 static int i2o_seq_open_dev_identity(struct inode
*inode
, struct file
*file
)
1683 return single_open(file
, i2o_seq_show_dev_identity
, PDE(inode
)->data
);
1686 static int i2o_seq_open_ddm_identity(struct inode
*inode
, struct file
*file
)
1688 return single_open(file
, i2o_seq_show_ddm_identity
, PDE(inode
)->data
);
1691 static int i2o_seq_open_uinfo(struct inode
*inode
, struct file
*file
)
1693 return single_open(file
, i2o_seq_show_uinfo
, PDE(inode
)->data
);
1696 static int i2o_seq_open_sgl_limits(struct inode
*inode
, struct file
*file
)
1698 return single_open(file
, i2o_seq_show_sgl_limits
, PDE(inode
)->data
);
1701 static int i2o_seq_open_sensors(struct inode
*inode
, struct file
*file
)
1703 return single_open(file
, i2o_seq_show_sensors
, PDE(inode
)->data
);
1706 static int i2o_seq_open_dev_name(struct inode
*inode
, struct file
*file
)
1708 return single_open(file
, i2o_seq_show_dev_name
, PDE(inode
)->data
);
1711 static struct file_operations i2o_seq_fops_lct
= {
1712 .open
= i2o_seq_open_lct
,
1714 .llseek
= seq_lseek
,
1715 .release
= single_release
,
1718 static struct file_operations i2o_seq_fops_hrt
= {
1719 .open
= i2o_seq_open_hrt
,
1721 .llseek
= seq_lseek
,
1722 .release
= single_release
,
1725 static struct file_operations i2o_seq_fops_status
= {
1726 .open
= i2o_seq_open_status
,
1728 .llseek
= seq_lseek
,
1729 .release
= single_release
,
1732 static struct file_operations i2o_seq_fops_hw
= {
1733 .open
= i2o_seq_open_hw
,
1735 .llseek
= seq_lseek
,
1736 .release
= single_release
,
1739 static struct file_operations i2o_seq_fops_ddm_table
= {
1740 .open
= i2o_seq_open_ddm_table
,
1742 .llseek
= seq_lseek
,
1743 .release
= single_release
,
1746 static struct file_operations i2o_seq_fops_driver_store
= {
1747 .open
= i2o_seq_open_driver_store
,
1749 .llseek
= seq_lseek
,
1750 .release
= single_release
,
1753 static struct file_operations i2o_seq_fops_drivers_stored
= {
1754 .open
= i2o_seq_open_drivers_stored
,
1756 .llseek
= seq_lseek
,
1757 .release
= single_release
,
1760 static struct file_operations i2o_seq_fops_groups
= {
1761 .open
= i2o_seq_open_groups
,
1763 .llseek
= seq_lseek
,
1764 .release
= single_release
,
1767 static struct file_operations i2o_seq_fops_phys_device
= {
1768 .open
= i2o_seq_open_phys_device
,
1770 .llseek
= seq_lseek
,
1771 .release
= single_release
,
1774 static struct file_operations i2o_seq_fops_claimed
= {
1775 .open
= i2o_seq_open_claimed
,
1777 .llseek
= seq_lseek
,
1778 .release
= single_release
,
1781 static struct file_operations i2o_seq_fops_users
= {
1782 .open
= i2o_seq_open_users
,
1784 .llseek
= seq_lseek
,
1785 .release
= single_release
,
1788 static struct file_operations i2o_seq_fops_priv_msgs
= {
1789 .open
= i2o_seq_open_priv_msgs
,
1791 .llseek
= seq_lseek
,
1792 .release
= single_release
,
1795 static struct file_operations i2o_seq_fops_authorized_users
= {
1796 .open
= i2o_seq_open_authorized_users
,
1798 .llseek
= seq_lseek
,
1799 .release
= single_release
,
1802 static struct file_operations i2o_seq_fops_dev_name
= {
1803 .open
= i2o_seq_open_dev_name
,
1805 .llseek
= seq_lseek
,
1806 .release
= single_release
,
1809 static struct file_operations i2o_seq_fops_dev_identity
= {
1810 .open
= i2o_seq_open_dev_identity
,
1812 .llseek
= seq_lseek
,
1813 .release
= single_release
,
1816 static struct file_operations i2o_seq_fops_ddm_identity
= {
1817 .open
= i2o_seq_open_ddm_identity
,
1819 .llseek
= seq_lseek
,
1820 .release
= single_release
,
1823 static struct file_operations i2o_seq_fops_uinfo
= {
1824 .open
= i2o_seq_open_uinfo
,
1826 .llseek
= seq_lseek
,
1827 .release
= single_release
,
1830 static struct file_operations i2o_seq_fops_sgl_limits
= {
1831 .open
= i2o_seq_open_sgl_limits
,
1833 .llseek
= seq_lseek
,
1834 .release
= single_release
,
1837 static struct file_operations i2o_seq_fops_sensors
= {
1838 .open
= i2o_seq_open_sensors
,
1840 .llseek
= seq_lseek
,
1841 .release
= single_release
,
1845 * IOP specific entries...write field just in case someone
1848 static i2o_proc_entry i2o_proc_generic_iop_entries
[] = {
1849 {"hrt", S_IFREG
| S_IRUGO
, &i2o_seq_fops_hrt
},
1850 {"lct", S_IFREG
| S_IRUGO
, &i2o_seq_fops_lct
},
1851 {"status", S_IFREG
| S_IRUGO
, &i2o_seq_fops_status
},
1852 {"hw", S_IFREG
| S_IRUGO
, &i2o_seq_fops_hw
},
1853 {"ddm_table", S_IFREG
| S_IRUGO
, &i2o_seq_fops_ddm_table
},
1854 {"driver_store", S_IFREG
| S_IRUGO
, &i2o_seq_fops_driver_store
},
1855 {"drivers_stored", S_IFREG
| S_IRUGO
, &i2o_seq_fops_drivers_stored
},
1860 * Device specific entries
1862 static i2o_proc_entry generic_dev_entries
[] = {
1863 {"groups", S_IFREG
| S_IRUGO
, &i2o_seq_fops_groups
},
1864 {"phys_dev", S_IFREG
| S_IRUGO
, &i2o_seq_fops_phys_device
},
1865 {"claimed", S_IFREG
| S_IRUGO
, &i2o_seq_fops_claimed
},
1866 {"users", S_IFREG
| S_IRUGO
, &i2o_seq_fops_users
},
1867 {"priv_msgs", S_IFREG
| S_IRUGO
, &i2o_seq_fops_priv_msgs
},
1868 {"authorized_users", S_IFREG
| S_IRUGO
, &i2o_seq_fops_authorized_users
},
1869 {"dev_identity", S_IFREG
| S_IRUGO
, &i2o_seq_fops_dev_identity
},
1870 {"ddm_identity", S_IFREG
| S_IRUGO
, &i2o_seq_fops_ddm_identity
},
1871 {"user_info", S_IFREG
| S_IRUGO
, &i2o_seq_fops_uinfo
},
1872 {"sgl_limits", S_IFREG
| S_IRUGO
, &i2o_seq_fops_sgl_limits
},
1873 {"sensors", S_IFREG
| S_IRUGO
, &i2o_seq_fops_sensors
},
1878 * Storage unit specific entries (SCSI Periph, BS) with device names
1880 static i2o_proc_entry rbs_dev_entries
[] = {
1881 {"dev_name", S_IFREG
| S_IRUGO
, &i2o_seq_fops_dev_name
},
1886 * i2o_proc_create_entries - Creates proc dir entries
1887 * @dir: proc dir entry under which the entries should be placed
1888 * @i2o_pe: pointer to the entries which should be added
1889 * @data: pointer to I2O controller or device
1891 * Create proc dir entries for a I2O controller or I2O device.
1893 * Returns 0 on success or negative error code on failure.
1895 static int i2o_proc_create_entries(struct proc_dir_entry
*dir
,
1896 i2o_proc_entry
* i2o_pe
, void *data
)
1898 struct proc_dir_entry
*tmp
;
1900 while (i2o_pe
->name
) {
1901 tmp
= create_proc_entry(i2o_pe
->name
, i2o_pe
->mode
, dir
);
1906 tmp
->proc_fops
= i2o_pe
->fops
;
1915 * i2o_proc_subdir_remove - Remove child entries from a proc entry
1916 * @dir: proc dir entry from which the childs should be removed
1918 * Iterate over each i2o proc entry under dir and remove it. If the child
1919 * also has entries, remove them too.
1921 static void i2o_proc_subdir_remove(struct proc_dir_entry
*dir
)
1923 struct proc_dir_entry
*pe
, *tmp
;
1927 i2o_proc_subdir_remove(pe
);
1928 remove_proc_entry(pe
->name
, dir
);
1934 * i2o_proc_device_add - Add an I2O device to the proc dir
1935 * @dir: proc dir entry to which the device should be added
1936 * @dev: I2O device which should be added
1938 * Add an I2O device to the proc dir entry dir and create the entries for
1939 * the device depending on the class of the I2O device.
1941 static void i2o_proc_device_add(struct proc_dir_entry
*dir
,
1942 struct i2o_device
*dev
)
1945 struct proc_dir_entry
*devdir
;
1946 i2o_proc_entry
*i2o_pe
= NULL
;
1948 sprintf(buff
, "%03x", dev
->lct_data
.tid
);
1950 pr_debug("Adding device /proc/i2o/iop%d/%s\n", dev
->iop
->unit
, buff
);
1952 devdir
= proc_mkdir(buff
, dir
);
1954 printk(KERN_WARNING
"i2o: Could not allocate procdir!\n");
1960 i2o_proc_create_entries(devdir
, generic_dev_entries
, dev
);
1962 /* Inform core that we want updates about this device's status */
1963 switch (dev
->lct_data
.class_id
) {
1964 case I2O_CLASS_SCSI_PERIPHERAL
:
1965 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
1966 i2o_pe
= rbs_dev_entries
;
1972 i2o_proc_create_entries(devdir
, i2o_pe
, dev
);
1976 * i2o_proc_iop_add - Add an I2O controller to the i2o proc tree
1977 * @dir: parent proc dir entry
1978 * @c: I2O controller which should be added
1980 * Add the entries to the parent proc dir entry. Also each device is added
1981 * to the controllers proc dir entry.
1983 * Returns 0 on success or negative error code on failure.
1985 static int i2o_proc_iop_add(struct proc_dir_entry
*dir
,
1986 struct i2o_controller
*c
)
1988 struct proc_dir_entry
*iopdir
;
1989 struct i2o_device
*dev
;
1992 snprintf(buff
, 10, "iop%d", c
->unit
);
1994 pr_debug("Adding IOP /proc/i2o/%s\n", buff
);
1996 iopdir
= proc_mkdir(buff
, dir
);
2002 i2o_proc_create_entries(iopdir
, i2o_proc_generic_iop_entries
, c
);
2004 list_for_each_entry(dev
, &c
->devices
, list
)
2005 i2o_proc_device_add(iopdir
, dev
);
2011 * i2o_proc_iop_remove - Removes an I2O controller from the i2o proc tree
2012 * @dir: parent proc dir entry
2013 * @c: I2O controller which should be removed
2015 * Iterate over each i2o proc entry and search controller c. If it is found
2016 * remove it from the tree.
2018 static void i2o_proc_iop_remove(struct proc_dir_entry
*dir
,
2019 struct i2o_controller
*c
)
2021 struct proc_dir_entry
*pe
, *tmp
;
2026 if (pe
->data
== c
) {
2027 i2o_proc_subdir_remove(pe
);
2028 remove_proc_entry(pe
->name
, dir
);
2030 pr_debug("Removing IOP /proc/i2o/iop%d\n", c
->unit
);
2036 * i2o_proc_fs_create - Create the i2o proc fs.
2038 * Iterate over each I2O controller and create the entries for it.
2040 * Returns 0 on success or negative error code on failure.
2042 static int __init
i2o_proc_fs_create(void)
2044 struct i2o_controller
*c
;
2046 i2o_proc_dir_root
= proc_mkdir("i2o", NULL
);
2047 if (!i2o_proc_dir_root
)
2050 i2o_proc_dir_root
->owner
= THIS_MODULE
;
2052 list_for_each_entry(c
, &i2o_controllers
, list
)
2053 i2o_proc_iop_add(i2o_proc_dir_root
, c
);
2059 * i2o_proc_fs_destroy - Cleanup the all i2o proc entries
2061 * Iterate over each I2O controller and remove the entries for it.
2063 * Returns 0 on success or negative error code on failure.
2065 static int __exit
i2o_proc_fs_destroy(void)
2067 struct i2o_controller
*c
;
2069 list_for_each_entry(c
, &i2o_controllers
, list
)
2070 i2o_proc_iop_remove(i2o_proc_dir_root
, c
);
2072 remove_proc_entry("i2o", NULL
);
2078 * i2o_proc_init - Init function for procfs
2080 * Registers Proc OSM and creates procfs entries.
2082 * Returns 0 on success or negative error code on failure.
2084 static int __init
i2o_proc_init(void)
2088 rc
= i2o_driver_register(&i2o_proc_driver
);
2092 rc
= i2o_proc_fs_create();
2094 i2o_driver_unregister(&i2o_proc_driver
);
2102 * i2o_proc_exit - Exit function for procfs
2104 * Unregisters Proc OSM and removes procfs entries.
2106 static void __exit
i2o_proc_exit(void)
2108 i2o_driver_unregister(&i2o_proc_driver
);
2109 i2o_proc_fs_destroy();
2112 MODULE_AUTHOR("Deepak Saxena");
2113 MODULE_DESCRIPTION("I2O procfs Handler");
2114 MODULE_LICENSE("GPL");
2116 module_init(i2o_proc_init
);
2117 module_exit(i2o_proc_exit
);