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/slab.h>
44 #include <linux/proc_fs.h>
45 #include <linux/seq_file.h>
46 #include <linux/init.h>
47 #include <linux/module.h>
48 #include <linux/errno.h>
49 #include <linux/spinlock.h>
50 #include <linux/workqueue.h>
53 #include <asm/uaccess.h>
54 #include <asm/byteorder.h>
56 /* Structure used to define /proc entries */
57 typedef struct _i2o_proc_entry_t
{
58 char *name
; /* entry name */
59 umode_t mode
; /* mode */
60 const struct file_operations
*fops
; /* open function */
63 /* global I2O /proc/i2o entry */
64 static struct proc_dir_entry
*i2o_proc_dir_root
;
66 /* proc OSM driver struct */
67 static struct i2o_driver i2o_proc_driver
= {
71 static int print_serial_number(struct seq_file
*seq
, u8
* serialno
, int max_len
)
76 * The I2O v1.5 (and v2.0 so far) "official specification"
77 * got serial numbers WRONG!
78 * Apparently, and despite what Section 3.4.4 says and
79 * Figure 3-35 shows (pg 3-39 in the pdf doc),
80 * the convention / consensus seems to be:
81 * + First byte is SNFormat
82 * + Second byte is SNLen (but only if SNFormat==7 (?))
83 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
85 switch (serialno
[0]) {
86 case I2O_SNFORMAT_BINARY
: /* Binary */
87 seq_printf(seq
, "0x");
88 for (i
= 0; i
< serialno
[1]; i
++) {
89 seq_printf(seq
, "%02X", serialno
[2 + i
]);
93 case I2O_SNFORMAT_ASCII
: /* ASCII */
94 if (serialno
[1] < ' ') { /* printable or SNLen? */
97 (max_len
< serialno
[1]) ? max_len
: serialno
[1];
98 serialno
[1 + max_len
] = '\0';
101 seq_printf(seq
, "%s", &serialno
[2]);
103 /* print chars for specified length */
104 for (i
= 0; i
< serialno
[1]; i
++) {
105 seq_printf(seq
, "%c", serialno
[2 + i
]);
110 case I2O_SNFORMAT_UNICODE
: /* UNICODE */
111 seq_printf(seq
, "UNICODE Format. Can't Display\n");
114 case I2O_SNFORMAT_LAN48_MAC
: /* LAN-48 MAC Address */
115 seq_printf(seq
, "LAN-48 MAC address @ %pM", &serialno
[2]);
118 case I2O_SNFORMAT_WAN
: /* WAN MAC Address */
119 /* FIXME: Figure out what a WAN access address looks like?? */
120 seq_printf(seq
, "WAN Access Address");
123 /* plus new in v2.0 */
124 case I2O_SNFORMAT_LAN64_MAC
: /* LAN-64 MAC Address */
125 /* FIXME: Figure out what a LAN-64 address really looks like?? */
127 "LAN-64 MAC address @ [?:%02X:%02X:?] %pM",
128 serialno
[8], serialno
[9], &serialno
[2]);
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
:
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(char *tmp
, u8
*chars
, int n
)
261 return strncat(tmp
, (char *)chars
, n
);
264 static int i2o_report_query_status(struct seq_file
*seq
, int block_status
,
267 switch (block_status
) {
269 return seq_printf(seq
, "Timeout reading group %s.\n", group
);
271 return seq_printf(seq
, "No free memory to read the table.\n");
272 case -I2O_PARAMS_STATUS_INVALID_GROUP_ID
:
273 return seq_printf(seq
, "Group %s not supported.\n", group
);
275 return seq_printf(seq
,
276 "Error reading group %s. BlockStatus 0x%02X\n",
277 group
, -block_status
);
281 static char *bus_strings
[] = {
291 static int i2o_seq_show_hrt(struct seq_file
*seq
, void *v
)
293 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
294 i2o_hrt
*hrt
= (i2o_hrt
*) c
->hrt
.virt
;
298 if (hrt
->hrt_version
) {
300 "HRT table for controller is too new a version.\n");
304 seq_printf(seq
, "HRT has %d entries of %d bytes each.\n",
305 hrt
->num_entries
, hrt
->entry_len
<< 2);
307 for (i
= 0; i
< hrt
->num_entries
; i
++) {
308 seq_printf(seq
, "Entry %d:\n", i
);
309 seq_printf(seq
, " Adapter ID: %0#10x\n",
310 hrt
->hrt_entry
[i
].adapter_id
);
311 seq_printf(seq
, " Controlling tid: %0#6x\n",
312 hrt
->hrt_entry
[i
].parent_tid
);
314 if (hrt
->hrt_entry
[i
].bus_type
!= 0x80) {
315 bus
= hrt
->hrt_entry
[i
].bus_type
;
316 seq_printf(seq
, " %s Information\n",
321 seq_printf(seq
, " IOBase: %0#6x,",
322 hrt
->hrt_entry
[i
].bus
.local_bus
.
324 seq_printf(seq
, " MemoryBase: %0#10x\n",
325 hrt
->hrt_entry
[i
].bus
.local_bus
.
326 LbBaseMemoryAddress
);
330 seq_printf(seq
, " IOBase: %0#6x,",
331 hrt
->hrt_entry
[i
].bus
.isa_bus
.
333 seq_printf(seq
, " MemoryBase: %0#10x,",
334 hrt
->hrt_entry
[i
].bus
.isa_bus
.
335 IsaBaseMemoryAddress
);
336 seq_printf(seq
, " CSN: %0#4x,",
337 hrt
->hrt_entry
[i
].bus
.isa_bus
.CSN
);
341 seq_printf(seq
, " IOBase: %0#6x,",
342 hrt
->hrt_entry
[i
].bus
.eisa_bus
.
344 seq_printf(seq
, " MemoryBase: %0#10x,",
345 hrt
->hrt_entry
[i
].bus
.eisa_bus
.
346 EisaBaseMemoryAddress
);
347 seq_printf(seq
, " Slot: %0#4x,",
348 hrt
->hrt_entry
[i
].bus
.eisa_bus
.
353 seq_printf(seq
, " Bus: %0#4x",
354 hrt
->hrt_entry
[i
].bus
.pci_bus
.
356 seq_printf(seq
, " Dev: %0#4x",
357 hrt
->hrt_entry
[i
].bus
.pci_bus
.
359 seq_printf(seq
, " Func: %0#4x",
360 hrt
->hrt_entry
[i
].bus
.pci_bus
.
362 seq_printf(seq
, " Vendor: %0#6x",
363 hrt
->hrt_entry
[i
].bus
.pci_bus
.
365 seq_printf(seq
, " Device: %0#6x\n",
366 hrt
->hrt_entry
[i
].bus
.pci_bus
.
371 seq_printf(seq
, " Unsupported Bus Type\n");
374 seq_printf(seq
, " Unknown Bus Type\n");
380 static int i2o_seq_show_lct(struct seq_file
*seq
, void *v
)
382 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
383 i2o_lct
*lct
= (i2o_lct
*) c
->lct
;
387 #define BUS_TABLE_SIZE 3
388 static char *bus_ports
[] = {
394 entries
= (lct
->table_size
- 3) / 9;
396 seq_printf(seq
, "LCT contains %d %s\n", entries
,
397 entries
== 1 ? "entry" : "entries");
399 seq_printf(seq
, "Boot Device @ ID %d\n", lct
->boot_tid
);
401 seq_printf(seq
, "Current Change Indicator: %#10x\n", lct
->change_ind
);
403 for (i
= 0; i
< entries
; i
++) {
404 seq_printf(seq
, "Entry %d\n", i
);
405 seq_printf(seq
, " Class, SubClass : %s",
406 i2o_get_class_name(lct
->lct_entry
[i
].class_id
));
409 * Classes which we'll print subclass info for
411 switch (lct
->lct_entry
[i
].class_id
& 0xFFF) {
412 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
413 switch (lct
->lct_entry
[i
].sub_class
) {
415 seq_printf(seq
, ", Direct-Access Read/Write");
419 seq_printf(seq
, ", WORM Drive");
423 seq_printf(seq
, ", CD-ROM Drive");
427 seq_printf(seq
, ", Optical Memory Device");
431 seq_printf(seq
, ", Unknown (0x%02x)",
432 lct
->lct_entry
[i
].sub_class
);
438 switch (lct
->lct_entry
[i
].sub_class
& 0xFF) {
440 seq_printf(seq
, ", Ethernet");
444 seq_printf(seq
, ", 100base VG");
448 seq_printf(seq
, ", IEEE 802.5/Token-Ring");
452 seq_printf(seq
, ", ANSI X3T9.5 FDDI");
456 seq_printf(seq
, ", Fibre Channel");
460 seq_printf(seq
, ", Unknown Sub-Class (0x%02x)",
461 lct
->lct_entry
[i
].sub_class
& 0xFF);
466 case I2O_CLASS_SCSI_PERIPHERAL
:
467 if (lct
->lct_entry
[i
].sub_class
< SCSI_TABLE_SIZE
)
468 seq_printf(seq
, ", %s",
469 scsi_devices
[lct
->lct_entry
[i
].
472 seq_printf(seq
, ", Unknown Device Type");
475 case I2O_CLASS_BUS_ADAPTER
:
476 if (lct
->lct_entry
[i
].sub_class
< BUS_TABLE_SIZE
)
477 seq_printf(seq
, ", %s",
478 bus_ports
[lct
->lct_entry
[i
].
481 seq_printf(seq
, ", Unknown Bus Type");
484 seq_printf(seq
, "\n");
486 seq_printf(seq
, " Local TID : 0x%03x\n",
487 lct
->lct_entry
[i
].tid
);
488 seq_printf(seq
, " User TID : 0x%03x\n",
489 lct
->lct_entry
[i
].user_tid
);
490 seq_printf(seq
, " Parent TID : 0x%03x\n",
491 lct
->lct_entry
[i
].parent_tid
);
492 seq_printf(seq
, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
493 lct
->lct_entry
[i
].identity_tag
[0],
494 lct
->lct_entry
[i
].identity_tag
[1],
495 lct
->lct_entry
[i
].identity_tag
[2],
496 lct
->lct_entry
[i
].identity_tag
[3],
497 lct
->lct_entry
[i
].identity_tag
[4],
498 lct
->lct_entry
[i
].identity_tag
[5],
499 lct
->lct_entry
[i
].identity_tag
[6],
500 lct
->lct_entry
[i
].identity_tag
[7]);
501 seq_printf(seq
, " Change Indicator : %0#10x\n",
502 lct
->lct_entry
[i
].change_ind
);
503 seq_printf(seq
, " Event Capab Mask : %0#10x\n",
504 lct
->lct_entry
[i
].device_flags
);
510 static int i2o_seq_show_status(struct seq_file
*seq
, void *v
)
512 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
515 i2o_status_block
*sb
= c
->status_block
.virt
;
517 i2o_status_get(c
); // reread the status block
519 seq_printf(seq
, "Organization ID : %0#6x\n", sb
->org_id
);
521 version
= sb
->i2o_version
;
523 /* FIXME for Spec 2.0
524 if (version == 0x02) {
525 seq_printf(seq, "Lowest I2O version supported: ");
526 switch(workspace[2]) {
528 seq_printf(seq, "1.0\n");
531 seq_printf(seq, "1.5\n");
534 seq_printf(seq, "2.0\n");
538 seq_printf(seq, "Highest I2O version supported: ");
539 switch(workspace[3]) {
541 seq_printf(seq, "1.0\n");
544 seq_printf(seq, "1.5\n");
547 seq_printf(seq, "2.0\n");
552 seq_printf(seq
, "IOP ID : %0#5x\n", sb
->iop_id
);
553 seq_printf(seq
, "Host Unit ID : %0#6x\n", sb
->host_unit_id
);
554 seq_printf(seq
, "Segment Number : %0#5x\n", sb
->segment_number
);
556 seq_printf(seq
, "I2O version : ");
559 seq_printf(seq
, "1.0\n");
562 seq_printf(seq
, "1.5\n");
565 seq_printf(seq
, "2.0\n");
568 seq_printf(seq
, "Unknown version\n");
571 seq_printf(seq
, "IOP State : ");
572 switch (sb
->iop_state
) {
574 seq_printf(seq
, "INIT\n");
578 seq_printf(seq
, "RESET\n");
582 seq_printf(seq
, "HOLD\n");
586 seq_printf(seq
, "READY\n");
590 seq_printf(seq
, "OPERATIONAL\n");
594 seq_printf(seq
, "FAILED\n");
598 seq_printf(seq
, "FAULTED\n");
602 seq_printf(seq
, "Unknown\n");
606 seq_printf(seq
, "Messenger Type : ");
607 switch (sb
->msg_type
) {
609 seq_printf(seq
, "Memory mapped\n");
612 seq_printf(seq
, "Memory mapped only\n");
615 seq_printf(seq
, "Remote only\n");
618 seq_printf(seq
, "Memory mapped and remote\n");
621 seq_printf(seq
, "Unknown\n");
624 seq_printf(seq
, "Inbound Frame Size : %d bytes\n",
625 sb
->inbound_frame_size
<< 2);
626 seq_printf(seq
, "Max Inbound Frames : %d\n",
627 sb
->max_inbound_frames
);
628 seq_printf(seq
, "Current Inbound Frames : %d\n",
629 sb
->cur_inbound_frames
);
630 seq_printf(seq
, "Max Outbound Frames : %d\n",
631 sb
->max_outbound_frames
);
633 /* Spec doesn't say if NULL terminated or not... */
634 memcpy(prodstr
, sb
->product_id
, 24);
636 seq_printf(seq
, "Product ID : %s\n", prodstr
);
637 seq_printf(seq
, "Expected LCT Size : %d bytes\n",
638 sb
->expected_lct_size
);
640 seq_printf(seq
, "IOP Capabilities\n");
641 seq_printf(seq
, " Context Field Size Support : ");
642 switch (sb
->iop_capabilities
& 0x0000003) {
644 seq_printf(seq
, "Supports only 32-bit context fields\n");
647 seq_printf(seq
, "Supports only 64-bit context fields\n");
650 seq_printf(seq
, "Supports 32-bit and 64-bit context fields, "
651 "but not concurrently\n");
654 seq_printf(seq
, "Supports 32-bit and 64-bit context fields "
658 seq_printf(seq
, "0x%08x\n", sb
->iop_capabilities
);
660 seq_printf(seq
, " Current Context Field Size : ");
661 switch (sb
->iop_capabilities
& 0x0000000C) {
663 seq_printf(seq
, "not configured\n");
666 seq_printf(seq
, "Supports only 32-bit context fields\n");
669 seq_printf(seq
, "Supports only 64-bit context fields\n");
672 seq_printf(seq
, "Supports both 32-bit or 64-bit context fields "
676 seq_printf(seq
, "\n");
678 seq_printf(seq
, " Inbound Peer Support : %s\n",
680 iop_capabilities
& 0x00000010) ? "Supported" :
682 seq_printf(seq
, " Outbound Peer Support : %s\n",
684 iop_capabilities
& 0x00000020) ? "Supported" :
686 seq_printf(seq
, " Peer to Peer Support : %s\n",
688 iop_capabilities
& 0x00000040) ? "Supported" :
691 seq_printf(seq
, "Desired private memory size : %d kB\n",
692 sb
->desired_mem_size
>> 10);
693 seq_printf(seq
, "Allocated private memory size : %d kB\n",
694 sb
->current_mem_size
>> 10);
695 seq_printf(seq
, "Private memory base address : %0#10x\n",
696 sb
->current_mem_base
);
697 seq_printf(seq
, "Desired private I/O size : %d kB\n",
698 sb
->desired_io_size
>> 10);
699 seq_printf(seq
, "Allocated private I/O size : %d kB\n",
700 sb
->current_io_size
>> 10);
701 seq_printf(seq
, "Private I/O base address : %0#10x\n",
702 sb
->current_io_base
);
707 static int i2o_seq_show_hw(struct seq_file
*seq
, void *v
)
709 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
710 static u32 work32
[5];
711 static u8
*work8
= (u8
*) work32
;
712 static u16
*work16
= (u16
*) work32
;
716 static char *cpu_table
[] = {
717 "Intel 80960 series",
719 "Motorola 68000 series",
728 i2o_parm_field_get(c
->exec
, 0x0000, -1, &work32
, sizeof(work32
));
731 i2o_report_query_status(seq
, token
, "0x0000 IOP Hardware");
735 seq_printf(seq
, "I2O Vendor ID : %0#6x\n", work16
[0]);
736 seq_printf(seq
, "Product ID : %0#6x\n", work16
[1]);
737 seq_printf(seq
, "CPU : ");
739 seq_printf(seq
, "Unknown\n");
741 seq_printf(seq
, "%s\n", cpu_table
[work8
[16]]);
742 /* Anyone using ProcessorVersion? */
744 seq_printf(seq
, "RAM : %dkB\n", work32
[1] >> 10);
745 seq_printf(seq
, "Non-Volatile Mem : %dkB\n", work32
[2] >> 10);
748 seq_printf(seq
, "Capabilities : 0x%08x\n", hwcap
);
749 seq_printf(seq
, " [%s] Self booting\n",
750 (hwcap
& 0x00000001) ? "+" : "-");
751 seq_printf(seq
, " [%s] Upgradable IRTOS\n",
752 (hwcap
& 0x00000002) ? "+" : "-");
753 seq_printf(seq
, " [%s] Supports downloading DDMs\n",
754 (hwcap
& 0x00000004) ? "+" : "-");
755 seq_printf(seq
, " [%s] Supports installing DDMs\n",
756 (hwcap
& 0x00000008) ? "+" : "-");
757 seq_printf(seq
, " [%s] Battery-backed RAM\n",
758 (hwcap
& 0x00000010) ? "+" : "-");
763 /* Executive group 0003h - Executing DDM List (table) */
764 static int i2o_seq_show_ddm_table(struct seq_file
*seq
, void *v
)
766 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
770 typedef struct _i2o_exec_execute_ddm_table
{
776 u8 module_name_version
[28];
779 } i2o_exec_execute_ddm_table
;
789 i2o_exec_execute_ddm_table ddm_table
[I2O_MAX_MODULES
];
792 i2o_exec_execute_ddm_table ddm_table
;
795 result
= kmalloc(sizeof(*result
), GFP_KERNEL
);
799 token
= i2o_parm_table_get(c
->exec
, I2O_PARAMS_TABLE_GET
, 0x0003, -1,
800 NULL
, 0, result
, sizeof(*result
));
803 i2o_report_query_status(seq
, token
,
804 "0x0003 Executing DDM List");
809 "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
810 ddm_table
= result
->ddm_table
[0];
812 for (i
= 0; i
< result
->row_count
; ddm_table
= result
->ddm_table
[++i
]) {
813 seq_printf(seq
, "0x%03x ", ddm_table
.ddm_tid
& 0xFFF);
815 switch (ddm_table
.module_type
) {
817 seq_printf(seq
, "Downloaded DDM ");
820 seq_printf(seq
, "Embedded DDM ");
823 seq_printf(seq
, " ");
826 seq_printf(seq
, "%-#7x", ddm_table
.i2o_vendor_id
);
827 seq_printf(seq
, "%-#8x", ddm_table
.module_id
);
828 seq_printf(seq
, "%-29s",
829 chtostr(tmp
, ddm_table
.module_name_version
, 28));
830 seq_printf(seq
, "%9d ", ddm_table
.data_size
);
831 seq_printf(seq
, "%8d", ddm_table
.code_size
);
833 seq_printf(seq
, "\n");
840 /* Executive group 0004h - Driver Store (scalar) */
841 static int i2o_seq_show_driver_store(struct seq_file
*seq
, void *v
)
843 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
848 i2o_parm_field_get(c
->exec
, 0x0004, -1, &work32
, sizeof(work32
));
850 i2o_report_query_status(seq
, token
, "0x0004 Driver Store");
854 seq_printf(seq
, "Module limit : %d\n"
855 "Module count : %d\n"
856 "Current space : %d kB\n"
857 "Free space : %d kB\n",
858 work32
[0], work32
[1], work32
[2] >> 10, work32
[3] >> 10);
863 /* Executive group 0005h - Driver Store Table (table) */
864 static int i2o_seq_show_drivers_stored(struct seq_file
*seq
, void *v
)
866 typedef struct _i2o_driver_store
{
867 u16 stored_ddm_index
;
872 u8 module_name_version
[28];
877 } i2o_driver_store_table
;
879 struct i2o_controller
*c
= (struct i2o_controller
*)seq
->private;
891 i2o_driver_store_table dst
[I2O_MAX_MODULES
];
892 } i2o_driver_result_table
;
894 i2o_driver_result_table
*result
;
895 i2o_driver_store_table
*dst
;
898 result
= kmalloc(sizeof(i2o_driver_result_table
), GFP_KERNEL
);
902 token
= i2o_parm_table_get(c
->exec
, I2O_PARAMS_TABLE_GET
, 0x0005, -1,
903 NULL
, 0, result
, sizeof(*result
));
906 i2o_report_query_status(seq
, token
,
907 "0x0005 DRIVER STORE TABLE");
913 "# Module_type Vendor Mod_id Module_name Vrs"
914 "Date Mod_size Par_size Flags\n");
915 for (i
= 0, dst
= &result
->dst
[0]; i
< result
->row_count
;
916 dst
= &result
->dst
[++i
]) {
917 seq_printf(seq
, "%-3d", dst
->stored_ddm_index
);
918 switch (dst
->module_type
) {
920 seq_printf(seq
, "Downloaded DDM ");
923 seq_printf(seq
, "Embedded DDM ");
926 seq_printf(seq
, " ");
929 seq_printf(seq
, "%-#7x", dst
->i2o_vendor_id
);
930 seq_printf(seq
, "%-#8x", dst
->module_id
);
931 seq_printf(seq
, "%-29s",
932 chtostr(tmp
, dst
->module_name_version
, 28));
933 seq_printf(seq
, "%-9s", chtostr(tmp
, dst
->date
, 8));
934 seq_printf(seq
, "%8d ", dst
->module_size
);
935 seq_printf(seq
, "%8d ", dst
->mpb_size
);
936 seq_printf(seq
, "0x%04x", dst
->module_flags
);
937 seq_printf(seq
, "\n");
944 /* Generic group F000h - Params Descriptor (table) */
945 static int i2o_seq_show_groups(struct seq_file
*seq
, void *v
)
947 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
952 typedef struct _i2o_group_info
{
968 i2o_group_info group
[256];
971 result
= kmalloc(sizeof(*result
), GFP_KERNEL
);
975 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF000, -1, NULL
, 0,
976 result
, sizeof(*result
));
979 i2o_report_query_status(seq
, token
, "0xF000 Params Descriptor");
984 "# Group FieldCount RowCount Type Add Del Clear\n");
986 for (i
= 0; i
< result
->row_count
; i
++) {
987 seq_printf(seq
, "%-3d", i
);
988 seq_printf(seq
, "0x%04X ", result
->group
[i
].group_number
);
989 seq_printf(seq
, "%10d ", result
->group
[i
].field_count
);
990 seq_printf(seq
, "%8d ", result
->group
[i
].row_count
);
992 properties
= result
->group
[i
].properties
;
993 if (properties
& 0x1)
994 seq_printf(seq
, "Table ");
996 seq_printf(seq
, "Scalar ");
997 if (properties
& 0x2)
998 seq_printf(seq
, " + ");
1000 seq_printf(seq
, " - ");
1001 if (properties
& 0x4)
1002 seq_printf(seq
, " + ");
1004 seq_printf(seq
, " - ");
1005 if (properties
& 0x8)
1006 seq_printf(seq
, " + ");
1008 seq_printf(seq
, " - ");
1010 seq_printf(seq
, "\n");
1013 if (result
->more_flag
)
1014 seq_printf(seq
, "There is more...\n");
1020 /* Generic group F001h - Physical Device Table (table) */
1021 static int i2o_seq_show_phys_device(struct seq_file
*seq
, void *v
)
1023 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1038 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF001, -1, NULL
, 0,
1039 &result
, sizeof(result
));
1042 i2o_report_query_status(seq
, token
,
1043 "0xF001 Physical Device Table");
1047 if (result
.row_count
)
1048 seq_printf(seq
, "# AdapterId\n");
1050 for (i
= 0; i
< result
.row_count
; i
++) {
1051 seq_printf(seq
, "%-2d", i
);
1052 seq_printf(seq
, "%#7x\n", result
.adapter_id
[i
]);
1055 if (result
.more_flag
)
1056 seq_printf(seq
, "There is more...\n");
1061 /* Generic group F002h - Claimed Table (table) */
1062 static int i2o_seq_show_claimed(struct seq_file
*seq
, void *v
)
1064 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1076 u16 claimed_tid
[64];
1079 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF002, -1, NULL
, 0,
1080 &result
, sizeof(result
));
1083 i2o_report_query_status(seq
, token
, "0xF002 Claimed Table");
1087 if (result
.row_count
)
1088 seq_printf(seq
, "# ClaimedTid\n");
1090 for (i
= 0; i
< result
.row_count
; i
++) {
1091 seq_printf(seq
, "%-2d", i
);
1092 seq_printf(seq
, "%#7x\n", result
.claimed_tid
[i
]);
1095 if (result
.more_flag
)
1096 seq_printf(seq
, "There is more...\n");
1101 /* Generic group F003h - User Table (table) */
1102 static int i2o_seq_show_users(struct seq_file
*seq
, void *v
)
1104 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1108 typedef struct _i2o_user_table
{
1124 i2o_user_table user
[64];
1127 result
= kmalloc(sizeof(*result
), GFP_KERNEL
);
1131 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF003, -1, NULL
, 0,
1132 result
, sizeof(*result
));
1135 i2o_report_query_status(seq
, token
, "0xF003 User Table");
1139 seq_printf(seq
, "# Instance UserTid ClaimType\n");
1141 for (i
= 0; i
< result
->row_count
; i
++) {
1142 seq_printf(seq
, "%-3d", i
);
1143 seq_printf(seq
, "%#8x ", result
->user
[i
].instance
);
1144 seq_printf(seq
, "%#7x ", result
->user
[i
].user_tid
);
1145 seq_printf(seq
, "%#9x\n", result
->user
[i
].claim_type
);
1148 if (result
->more_flag
)
1149 seq_printf(seq
, "There is more...\n");
1155 /* Generic group F005h - Private message extensions (table) (optional) */
1156 static int i2o_seq_show_priv_msgs(struct seq_file
*seq
, void *v
)
1158 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1162 typedef struct _i2o_private
{
1164 u16 organization_id
;
1165 u16 x_function_code
;
1176 i2o_private extension
[64];
1179 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF000, -1, NULL
, 0,
1180 &result
, sizeof(result
));
1183 i2o_report_query_status(seq
, token
,
1184 "0xF005 Private Message Extensions (optional)");
1188 seq_printf(seq
, "Instance# OrgId FunctionCode\n");
1190 for (i
= 0; i
< result
.row_count
; i
++) {
1191 seq_printf(seq
, "%0#9x ", result
.extension
[i
].ext_instance
);
1192 seq_printf(seq
, "%0#6x ", result
.extension
[i
].organization_id
);
1193 seq_printf(seq
, "%0#6x", result
.extension
[i
].x_function_code
);
1195 seq_printf(seq
, "\n");
1198 if (result
.more_flag
)
1199 seq_printf(seq
, "There is more...\n");
1204 /* Generic group F006h - Authorized User Table (table) */
1205 static int i2o_seq_show_authorized_users(struct seq_file
*seq
, void *v
)
1207 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1219 u32 alternate_tid
[64];
1222 token
= i2o_parm_table_get(d
, I2O_PARAMS_TABLE_GET
, 0xF006, -1, NULL
, 0,
1223 &result
, sizeof(result
));
1226 i2o_report_query_status(seq
, token
,
1227 "0xF006 Autohorized User Table");
1231 if (result
.row_count
)
1232 seq_printf(seq
, "# AlternateTid\n");
1234 for (i
= 0; i
< result
.row_count
; i
++) {
1235 seq_printf(seq
, "%-2d", i
);
1236 seq_printf(seq
, "%#7x ", result
.alternate_tid
[i
]);
1239 if (result
.more_flag
)
1240 seq_printf(seq
, "There is more...\n");
1245 /* Generic group F100h - Device Identity (scalar) */
1246 static int i2o_seq_show_dev_identity(struct seq_file
*seq
, void *v
)
1248 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1249 static u32 work32
[128]; // allow for "stuff" + up to 256 byte (max) serial number
1250 // == (allow) 512d bytes (max)
1251 static u16
*work16
= (u16
*) work32
;
1255 token
= i2o_parm_field_get(d
, 0xF100, -1, &work32
, sizeof(work32
));
1258 i2o_report_query_status(seq
, token
, "0xF100 Device Identity");
1262 seq_printf(seq
, "Device Class : %s\n", i2o_get_class_name(work16
[0]));
1263 seq_printf(seq
, "Owner TID : %0#5x\n", work16
[2]);
1264 seq_printf(seq
, "Parent TID : %0#5x\n", work16
[3]);
1265 seq_printf(seq
, "Vendor info : %s\n",
1266 chtostr(tmp
, (u8
*) (work32
+ 2), 16));
1267 seq_printf(seq
, "Product info : %s\n",
1268 chtostr(tmp
, (u8
*) (work32
+ 6), 16));
1269 seq_printf(seq
, "Description : %s\n",
1270 chtostr(tmp
, (u8
*) (work32
+ 10), 16));
1271 seq_printf(seq
, "Product rev. : %s\n",
1272 chtostr(tmp
, (u8
*) (work32
+ 14), 8));
1274 seq_printf(seq
, "Serial number : ");
1275 print_serial_number(seq
, (u8
*) (work32
+ 16),
1276 /* allow for SNLen plus
1277 * possible trailing '\0'
1279 sizeof(work32
) - (16 * sizeof(u32
)) - 2);
1280 seq_printf(seq
, "\n");
1285 static int i2o_seq_show_dev_name(struct seq_file
*seq
, void *v
)
1287 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1289 seq_printf(seq
, "%s\n", dev_name(&d
->device
));
1294 /* Generic group F101h - DDM Identity (scalar) */
1295 static int i2o_seq_show_ddm_identity(struct seq_file
*seq
, void *v
)
1297 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1305 u8 serial_number
[12];
1306 u8 pad
[256]; // allow up to 256 byte (max) serial number
1311 token
= i2o_parm_field_get(d
, 0xF101, -1, &result
, sizeof(result
));
1314 i2o_report_query_status(seq
, token
, "0xF101 DDM Identity");
1318 seq_printf(seq
, "Registering DDM TID : 0x%03x\n", result
.ddm_tid
);
1319 seq_printf(seq
, "Module name : %s\n",
1320 chtostr(tmp
, result
.module_name
, 24));
1321 seq_printf(seq
, "Module revision : %s\n",
1322 chtostr(tmp
, result
.module_rev
, 8));
1324 seq_printf(seq
, "Serial number : ");
1325 print_serial_number(seq
, result
.serial_number
, sizeof(result
) - 36);
1326 /* allow for SNLen plus possible trailing '\0' */
1328 seq_printf(seq
, "\n");
1333 /* Generic group F102h - User Information (scalar) */
1334 static int i2o_seq_show_uinfo(struct seq_file
*seq
, void *v
)
1336 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1341 u8 service_name
[64];
1342 u8 physical_location
[64];
1343 u8 instance_number
[4];
1348 token
= i2o_parm_field_get(d
, 0xF102, -1, &result
, sizeof(result
));
1351 i2o_report_query_status(seq
, token
, "0xF102 User Information");
1355 seq_printf(seq
, "Device name : %s\n",
1356 chtostr(tmp
, result
.device_name
, 64));
1357 seq_printf(seq
, "Service name : %s\n",
1358 chtostr(tmp
, result
.service_name
, 64));
1359 seq_printf(seq
, "Physical name : %s\n",
1360 chtostr(tmp
, result
.physical_location
, 64));
1361 seq_printf(seq
, "Instance number : %s\n",
1362 chtostr(tmp
, result
.instance_number
, 4));
1367 /* Generic group F103h - SGL Operating Limits (scalar) */
1368 static int i2o_seq_show_sgl_limits(struct seq_file
*seq
, void *v
)
1370 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1371 static u32 work32
[12];
1372 static u16
*work16
= (u16
*) work32
;
1373 static u8
*work8
= (u8
*) work32
;
1376 token
= i2o_parm_field_get(d
, 0xF103, -1, &work32
, sizeof(work32
));
1379 i2o_report_query_status(seq
, token
,
1380 "0xF103 SGL Operating Limits");
1384 seq_printf(seq
, "SGL chain size : %d\n", work32
[0]);
1385 seq_printf(seq
, "Max SGL chain size : %d\n", work32
[1]);
1386 seq_printf(seq
, "SGL chain size target : %d\n", work32
[2]);
1387 seq_printf(seq
, "SGL frag count : %d\n", work16
[6]);
1388 seq_printf(seq
, "Max SGL frag count : %d\n", work16
[7]);
1389 seq_printf(seq
, "SGL frag count target : %d\n", work16
[8]);
1392 if (d->i2oversion == 0x02)
1395 seq_printf(seq
, "SGL data alignment : %d\n", work16
[8]);
1396 seq_printf(seq
, "SGL addr limit : %d\n", work8
[20]);
1397 seq_printf(seq
, "SGL addr sizes supported : ");
1398 if (work8
[21] & 0x01)
1399 seq_printf(seq
, "32 bit ");
1400 if (work8
[21] & 0x02)
1401 seq_printf(seq
, "64 bit ");
1402 if (work8
[21] & 0x04)
1403 seq_printf(seq
, "96 bit ");
1404 if (work8
[21] & 0x08)
1405 seq_printf(seq
, "128 bit ");
1406 seq_printf(seq
, "\n");
1414 /* Generic group F200h - Sensors (scalar) */
1415 static int i2o_seq_show_sensors(struct seq_file
*seq
, void *v
)
1417 struct i2o_device
*d
= (struct i2o_device
*)seq
->private;
1421 u16 sensor_instance
;
1423 u16 component_instance
;
1426 u8 scaling_exponent
;
1428 u32 minimum_reading
;
1429 u32 low2lowcat_treshold
;
1430 u32 lowcat2low_treshold
;
1431 u32 lowwarn2low_treshold
;
1432 u32 low2lowwarn_treshold
;
1433 u32 norm2lowwarn_treshold
;
1434 u32 lowwarn2norm_treshold
;
1435 u32 nominal_reading
;
1436 u32 hiwarn2norm_treshold
;
1437 u32 norm2hiwarn_treshold
;
1438 u32 high2hiwarn_treshold
;
1439 u32 hiwarn2high_treshold
;
1440 u32 hicat2high_treshold
;
1441 u32 hi2hicat_treshold
;
1442 u32 maximum_reading
;
1447 token
= i2o_parm_field_get(d
, 0xF200, -1, &result
, sizeof(result
));
1450 i2o_report_query_status(seq
, token
,
1451 "0xF200 Sensors (optional)");
1455 seq_printf(seq
, "Sensor instance : %d\n", result
.sensor_instance
);
1457 seq_printf(seq
, "Component : %d = ", result
.component
);
1458 switch (result
.component
) {
1460 seq_printf(seq
, "Other");
1463 seq_printf(seq
, "Planar logic Board");
1466 seq_printf(seq
, "CPU");
1469 seq_printf(seq
, "Chassis");
1472 seq_printf(seq
, "Power Supply");
1475 seq_printf(seq
, "Storage");
1478 seq_printf(seq
, "External");
1481 seq_printf(seq
, "\n");
1483 seq_printf(seq
, "Component instance : %d\n",
1484 result
.component_instance
);
1485 seq_printf(seq
, "Sensor class : %s\n",
1486 result
.sensor_class
? "Analog" : "Digital");
1488 seq_printf(seq
, "Sensor type : %d = ", result
.sensor_type
);
1489 switch (result
.sensor_type
) {
1491 seq_printf(seq
, "Other\n");
1494 seq_printf(seq
, "Thermal\n");
1497 seq_printf(seq
, "DC voltage (DC volts)\n");
1500 seq_printf(seq
, "AC voltage (AC volts)\n");
1503 seq_printf(seq
, "DC current (DC amps)\n");
1506 seq_printf(seq
, "AC current (AC volts)\n");
1509 seq_printf(seq
, "Door open\n");
1512 seq_printf(seq
, "Fan operational\n");
1516 seq_printf(seq
, "Scaling exponent : %d\n",
1517 result
.scaling_exponent
);
1518 seq_printf(seq
, "Actual reading : %d\n", result
.actual_reading
);
1519 seq_printf(seq
, "Minimum reading : %d\n", result
.minimum_reading
);
1520 seq_printf(seq
, "Low2LowCat treshold : %d\n",
1521 result
.low2lowcat_treshold
);
1522 seq_printf(seq
, "LowCat2Low treshold : %d\n",
1523 result
.lowcat2low_treshold
);
1524 seq_printf(seq
, "LowWarn2Low treshold : %d\n",
1525 result
.lowwarn2low_treshold
);
1526 seq_printf(seq
, "Low2LowWarn treshold : %d\n",
1527 result
.low2lowwarn_treshold
);
1528 seq_printf(seq
, "Norm2LowWarn treshold : %d\n",
1529 result
.norm2lowwarn_treshold
);
1530 seq_printf(seq
, "LowWarn2Norm treshold : %d\n",
1531 result
.lowwarn2norm_treshold
);
1532 seq_printf(seq
, "Nominal reading : %d\n", result
.nominal_reading
);
1533 seq_printf(seq
, "HiWarn2Norm treshold : %d\n",
1534 result
.hiwarn2norm_treshold
);
1535 seq_printf(seq
, "Norm2HiWarn treshold : %d\n",
1536 result
.norm2hiwarn_treshold
);
1537 seq_printf(seq
, "High2HiWarn treshold : %d\n",
1538 result
.high2hiwarn_treshold
);
1539 seq_printf(seq
, "HiWarn2High treshold : %d\n",
1540 result
.hiwarn2high_treshold
);
1541 seq_printf(seq
, "HiCat2High treshold : %d\n",
1542 result
.hicat2high_treshold
);
1543 seq_printf(seq
, "High2HiCat treshold : %d\n",
1544 result
.hi2hicat_treshold
);
1545 seq_printf(seq
, "Maximum reading : %d\n", result
.maximum_reading
);
1547 seq_printf(seq
, "Sensor state : %d = ", result
.sensor_state
);
1548 switch (result
.sensor_state
) {
1550 seq_printf(seq
, "Normal\n");
1553 seq_printf(seq
, "Abnormal\n");
1556 seq_printf(seq
, "Unknown\n");
1559 seq_printf(seq
, "Low Catastrophic (LoCat)\n");
1562 seq_printf(seq
, "Low (Low)\n");
1565 seq_printf(seq
, "Low Warning (LoWarn)\n");
1568 seq_printf(seq
, "High Warning (HiWarn)\n");
1571 seq_printf(seq
, "High (High)\n");
1574 seq_printf(seq
, "High Catastrophic (HiCat)\n");
1578 seq_printf(seq
, "Event_enable : 0x%02X\n", result
.event_enable
);
1579 seq_printf(seq
, " [%s] Operational state change. \n",
1580 (result
.event_enable
& 0x01) ? "+" : "-");
1581 seq_printf(seq
, " [%s] Low catastrophic. \n",
1582 (result
.event_enable
& 0x02) ? "+" : "-");
1583 seq_printf(seq
, " [%s] Low reading. \n",
1584 (result
.event_enable
& 0x04) ? "+" : "-");
1585 seq_printf(seq
, " [%s] Low warning. \n",
1586 (result
.event_enable
& 0x08) ? "+" : "-");
1588 " [%s] Change back to normal from out of range state. \n",
1589 (result
.event_enable
& 0x10) ? "+" : "-");
1590 seq_printf(seq
, " [%s] High warning. \n",
1591 (result
.event_enable
& 0x20) ? "+" : "-");
1592 seq_printf(seq
, " [%s] High reading. \n",
1593 (result
.event_enable
& 0x40) ? "+" : "-");
1594 seq_printf(seq
, " [%s] High catastrophic. \n",
1595 (result
.event_enable
& 0x80) ? "+" : "-");
1600 static int i2o_seq_open_hrt(struct inode
*inode
, struct file
*file
)
1602 return single_open(file
, i2o_seq_show_hrt
, PDE_DATA(inode
));
1605 static int i2o_seq_open_lct(struct inode
*inode
, struct file
*file
)
1607 return single_open(file
, i2o_seq_show_lct
, PDE_DATA(inode
));
1610 static int i2o_seq_open_status(struct inode
*inode
, struct file
*file
)
1612 return single_open(file
, i2o_seq_show_status
, PDE_DATA(inode
));
1615 static int i2o_seq_open_hw(struct inode
*inode
, struct file
*file
)
1617 return single_open(file
, i2o_seq_show_hw
, PDE_DATA(inode
));
1620 static int i2o_seq_open_ddm_table(struct inode
*inode
, struct file
*file
)
1622 return single_open(file
, i2o_seq_show_ddm_table
, PDE_DATA(inode
));
1625 static int i2o_seq_open_driver_store(struct inode
*inode
, struct file
*file
)
1627 return single_open(file
, i2o_seq_show_driver_store
, PDE_DATA(inode
));
1630 static int i2o_seq_open_drivers_stored(struct inode
*inode
, struct file
*file
)
1632 return single_open(file
, i2o_seq_show_drivers_stored
, PDE_DATA(inode
));
1635 static int i2o_seq_open_groups(struct inode
*inode
, struct file
*file
)
1637 return single_open(file
, i2o_seq_show_groups
, PDE_DATA(inode
));
1640 static int i2o_seq_open_phys_device(struct inode
*inode
, struct file
*file
)
1642 return single_open(file
, i2o_seq_show_phys_device
, PDE_DATA(inode
));
1645 static int i2o_seq_open_claimed(struct inode
*inode
, struct file
*file
)
1647 return single_open(file
, i2o_seq_show_claimed
, PDE_DATA(inode
));
1650 static int i2o_seq_open_users(struct inode
*inode
, struct file
*file
)
1652 return single_open(file
, i2o_seq_show_users
, PDE_DATA(inode
));
1655 static int i2o_seq_open_priv_msgs(struct inode
*inode
, struct file
*file
)
1657 return single_open(file
, i2o_seq_show_priv_msgs
, PDE_DATA(inode
));
1660 static int i2o_seq_open_authorized_users(struct inode
*inode
, struct file
*file
)
1662 return single_open(file
, i2o_seq_show_authorized_users
,
1666 static int i2o_seq_open_dev_identity(struct inode
*inode
, struct file
*file
)
1668 return single_open(file
, i2o_seq_show_dev_identity
, PDE_DATA(inode
));
1671 static int i2o_seq_open_ddm_identity(struct inode
*inode
, struct file
*file
)
1673 return single_open(file
, i2o_seq_show_ddm_identity
, PDE_DATA(inode
));
1676 static int i2o_seq_open_uinfo(struct inode
*inode
, struct file
*file
)
1678 return single_open(file
, i2o_seq_show_uinfo
, PDE_DATA(inode
));
1681 static int i2o_seq_open_sgl_limits(struct inode
*inode
, struct file
*file
)
1683 return single_open(file
, i2o_seq_show_sgl_limits
, PDE_DATA(inode
));
1686 static int i2o_seq_open_sensors(struct inode
*inode
, struct file
*file
)
1688 return single_open(file
, i2o_seq_show_sensors
, PDE_DATA(inode
));
1691 static int i2o_seq_open_dev_name(struct inode
*inode
, struct file
*file
)
1693 return single_open(file
, i2o_seq_show_dev_name
, PDE_DATA(inode
));
1696 static const struct file_operations i2o_seq_fops_lct
= {
1697 .open
= i2o_seq_open_lct
,
1699 .llseek
= seq_lseek
,
1700 .release
= single_release
,
1703 static const struct file_operations i2o_seq_fops_hrt
= {
1704 .open
= i2o_seq_open_hrt
,
1706 .llseek
= seq_lseek
,
1707 .release
= single_release
,
1710 static const struct file_operations i2o_seq_fops_status
= {
1711 .open
= i2o_seq_open_status
,
1713 .llseek
= seq_lseek
,
1714 .release
= single_release
,
1717 static const struct file_operations i2o_seq_fops_hw
= {
1718 .open
= i2o_seq_open_hw
,
1720 .llseek
= seq_lseek
,
1721 .release
= single_release
,
1724 static const struct file_operations i2o_seq_fops_ddm_table
= {
1725 .open
= i2o_seq_open_ddm_table
,
1727 .llseek
= seq_lseek
,
1728 .release
= single_release
,
1731 static const struct file_operations i2o_seq_fops_driver_store
= {
1732 .open
= i2o_seq_open_driver_store
,
1734 .llseek
= seq_lseek
,
1735 .release
= single_release
,
1738 static const struct file_operations i2o_seq_fops_drivers_stored
= {
1739 .open
= i2o_seq_open_drivers_stored
,
1741 .llseek
= seq_lseek
,
1742 .release
= single_release
,
1745 static const struct file_operations i2o_seq_fops_groups
= {
1746 .open
= i2o_seq_open_groups
,
1748 .llseek
= seq_lseek
,
1749 .release
= single_release
,
1752 static const struct file_operations i2o_seq_fops_phys_device
= {
1753 .open
= i2o_seq_open_phys_device
,
1755 .llseek
= seq_lseek
,
1756 .release
= single_release
,
1759 static const struct file_operations i2o_seq_fops_claimed
= {
1760 .open
= i2o_seq_open_claimed
,
1762 .llseek
= seq_lseek
,
1763 .release
= single_release
,
1766 static const struct file_operations i2o_seq_fops_users
= {
1767 .open
= i2o_seq_open_users
,
1769 .llseek
= seq_lseek
,
1770 .release
= single_release
,
1773 static const struct file_operations i2o_seq_fops_priv_msgs
= {
1774 .open
= i2o_seq_open_priv_msgs
,
1776 .llseek
= seq_lseek
,
1777 .release
= single_release
,
1780 static const struct file_operations i2o_seq_fops_authorized_users
= {
1781 .open
= i2o_seq_open_authorized_users
,
1783 .llseek
= seq_lseek
,
1784 .release
= single_release
,
1787 static const struct file_operations i2o_seq_fops_dev_name
= {
1788 .open
= i2o_seq_open_dev_name
,
1790 .llseek
= seq_lseek
,
1791 .release
= single_release
,
1794 static const struct file_operations i2o_seq_fops_dev_identity
= {
1795 .open
= i2o_seq_open_dev_identity
,
1797 .llseek
= seq_lseek
,
1798 .release
= single_release
,
1801 static const struct file_operations i2o_seq_fops_ddm_identity
= {
1802 .open
= i2o_seq_open_ddm_identity
,
1804 .llseek
= seq_lseek
,
1805 .release
= single_release
,
1808 static const struct file_operations i2o_seq_fops_uinfo
= {
1809 .open
= i2o_seq_open_uinfo
,
1811 .llseek
= seq_lseek
,
1812 .release
= single_release
,
1815 static const struct file_operations i2o_seq_fops_sgl_limits
= {
1816 .open
= i2o_seq_open_sgl_limits
,
1818 .llseek
= seq_lseek
,
1819 .release
= single_release
,
1822 static const struct file_operations i2o_seq_fops_sensors
= {
1823 .open
= i2o_seq_open_sensors
,
1825 .llseek
= seq_lseek
,
1826 .release
= single_release
,
1830 * IOP specific entries...write field just in case someone
1833 static i2o_proc_entry i2o_proc_generic_iop_entries
[] = {
1834 {"hrt", S_IFREG
| S_IRUGO
, &i2o_seq_fops_hrt
},
1835 {"lct", S_IFREG
| S_IRUGO
, &i2o_seq_fops_lct
},
1836 {"status", S_IFREG
| S_IRUGO
, &i2o_seq_fops_status
},
1837 {"hw", S_IFREG
| S_IRUGO
, &i2o_seq_fops_hw
},
1838 {"ddm_table", S_IFREG
| S_IRUGO
, &i2o_seq_fops_ddm_table
},
1839 {"driver_store", S_IFREG
| S_IRUGO
, &i2o_seq_fops_driver_store
},
1840 {"drivers_stored", S_IFREG
| S_IRUGO
, &i2o_seq_fops_drivers_stored
},
1845 * Device specific entries
1847 static i2o_proc_entry generic_dev_entries
[] = {
1848 {"groups", S_IFREG
| S_IRUGO
, &i2o_seq_fops_groups
},
1849 {"phys_dev", S_IFREG
| S_IRUGO
, &i2o_seq_fops_phys_device
},
1850 {"claimed", S_IFREG
| S_IRUGO
, &i2o_seq_fops_claimed
},
1851 {"users", S_IFREG
| S_IRUGO
, &i2o_seq_fops_users
},
1852 {"priv_msgs", S_IFREG
| S_IRUGO
, &i2o_seq_fops_priv_msgs
},
1853 {"authorized_users", S_IFREG
| S_IRUGO
, &i2o_seq_fops_authorized_users
},
1854 {"dev_identity", S_IFREG
| S_IRUGO
, &i2o_seq_fops_dev_identity
},
1855 {"ddm_identity", S_IFREG
| S_IRUGO
, &i2o_seq_fops_ddm_identity
},
1856 {"user_info", S_IFREG
| S_IRUGO
, &i2o_seq_fops_uinfo
},
1857 {"sgl_limits", S_IFREG
| S_IRUGO
, &i2o_seq_fops_sgl_limits
},
1858 {"sensors", S_IFREG
| S_IRUGO
, &i2o_seq_fops_sensors
},
1863 * Storage unit specific entries (SCSI Periph, BS) with device names
1865 static i2o_proc_entry rbs_dev_entries
[] = {
1866 {"dev_name", S_IFREG
| S_IRUGO
, &i2o_seq_fops_dev_name
},
1871 * i2o_proc_create_entries - Creates proc dir entries
1872 * @dir: proc dir entry under which the entries should be placed
1873 * @i2o_pe: pointer to the entries which should be added
1874 * @data: pointer to I2O controller or device
1876 * Create proc dir entries for a I2O controller or I2O device.
1878 * Returns 0 on success or negative error code on failure.
1880 static int i2o_proc_create_entries(struct proc_dir_entry
*dir
,
1881 i2o_proc_entry
* i2o_pe
, void *data
)
1883 struct proc_dir_entry
*tmp
;
1885 while (i2o_pe
->name
) {
1886 tmp
= proc_create_data(i2o_pe
->name
, i2o_pe
->mode
, dir
,
1887 i2o_pe
->fops
, data
);
1898 * i2o_proc_device_add - Add an I2O device to the proc dir
1899 * @dir: proc dir entry to which the device should be added
1900 * @dev: I2O device which should be added
1902 * Add an I2O device to the proc dir entry dir and create the entries for
1903 * the device depending on the class of the I2O device.
1905 static void i2o_proc_device_add(struct proc_dir_entry
*dir
,
1906 struct i2o_device
*dev
)
1909 struct proc_dir_entry
*devdir
;
1910 i2o_proc_entry
*i2o_pe
= NULL
;
1912 sprintf(buff
, "%03x", dev
->lct_data
.tid
);
1914 osm_debug("adding device /proc/i2o/%s/%s\n", dev
->iop
->name
, buff
);
1916 devdir
= proc_mkdir_data(buff
, 0, dir
, dev
);
1918 osm_warn("Could not allocate procdir!\n");
1922 i2o_proc_create_entries(devdir
, generic_dev_entries
, dev
);
1924 /* Inform core that we want updates about this device's status */
1925 switch (dev
->lct_data
.class_id
) {
1926 case I2O_CLASS_SCSI_PERIPHERAL
:
1927 case I2O_CLASS_RANDOM_BLOCK_STORAGE
:
1928 i2o_pe
= rbs_dev_entries
;
1934 i2o_proc_create_entries(devdir
, i2o_pe
, dev
);
1938 * i2o_proc_iop_add - Add an I2O controller to the i2o proc tree
1939 * @dir: parent proc dir entry
1940 * @c: I2O controller which should be added
1942 * Add the entries to the parent proc dir entry. Also each device is added
1943 * to the controllers proc dir entry.
1945 * Returns 0 on success or negative error code on failure.
1947 static int i2o_proc_iop_add(struct proc_dir_entry
*dir
,
1948 struct i2o_controller
*c
)
1950 struct proc_dir_entry
*iopdir
;
1951 struct i2o_device
*dev
;
1953 osm_debug("adding IOP /proc/i2o/%s\n", c
->name
);
1955 iopdir
= proc_mkdir_data(c
->name
, 0, dir
, c
);
1959 i2o_proc_create_entries(iopdir
, i2o_proc_generic_iop_entries
, c
);
1961 list_for_each_entry(dev
, &c
->devices
, list
)
1962 i2o_proc_device_add(iopdir
, dev
);
1968 * i2o_proc_fs_create - Create the i2o proc fs.
1970 * Iterate over each I2O controller and create the entries for it.
1972 * Returns 0 on success or negative error code on failure.
1974 static int __init
i2o_proc_fs_create(void)
1976 struct i2o_controller
*c
;
1978 i2o_proc_dir_root
= proc_mkdir("i2o", NULL
);
1979 if (!i2o_proc_dir_root
)
1982 list_for_each_entry(c
, &i2o_controllers
, list
)
1983 i2o_proc_iop_add(i2o_proc_dir_root
, c
);
1989 * i2o_proc_fs_destroy - Cleanup the all i2o proc entries
1991 * Iterate over each I2O controller and remove the entries for it.
1993 * Returns 0 on success or negative error code on failure.
1995 static int __exit
i2o_proc_fs_destroy(void)
1997 remove_proc_subtree("i2o", NULL
);
2003 * i2o_proc_init - Init function for procfs
2005 * Registers Proc OSM and creates procfs entries.
2007 * Returns 0 on success or negative error code on failure.
2009 static int __init
i2o_proc_init(void)
2013 printk(KERN_INFO OSM_DESCRIPTION
" v" OSM_VERSION
"\n");
2015 rc
= i2o_driver_register(&i2o_proc_driver
);
2019 rc
= i2o_proc_fs_create();
2021 i2o_driver_unregister(&i2o_proc_driver
);
2029 * i2o_proc_exit - Exit function for procfs
2031 * Unregisters Proc OSM and removes procfs entries.
2033 static void __exit
i2o_proc_exit(void)
2035 i2o_driver_unregister(&i2o_proc_driver
);
2036 i2o_proc_fs_destroy();
2039 MODULE_AUTHOR("Deepak Saxena");
2040 MODULE_LICENSE("GPL");
2041 MODULE_DESCRIPTION(OSM_DESCRIPTION
);
2042 MODULE_VERSION(OSM_VERSION
);
2044 module_init(i2o_proc_init
);
2045 module_exit(i2o_proc_exit
);