1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#define OSM_NAME "proc-osm"
31#define OSM_VERSION "1.316"
32#define OSM_DESCRIPTION "I2O ProcFS OSM"
33
34#define I2O_MAX_MODULES 4
35
36#define FMT_U64_HEX "0x%08x%08x"
37#define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
38
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>
51
52#include <asm/io.h>
53#include <asm/uaccess.h>
54#include <asm/byteorder.h>
55
56
57typedef struct _i2o_proc_entry_t {
58 char *name;
59 umode_t mode;
60 const struct file_operations *fops;
61} i2o_proc_entry;
62
63
64static struct proc_dir_entry *i2o_proc_dir_root;
65
66
67static struct i2o_driver i2o_proc_driver = {
68 .name = OSM_NAME,
69};
70
71static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
72{
73 int i;
74
75
76
77
78
79
80
81
82
83
84
85 switch (serialno[0]) {
86 case I2O_SNFORMAT_BINARY:
87 seq_printf(seq, "0x");
88 for (i = 0; i < serialno[1]; i++) {
89 seq_printf(seq, "%02X", serialno[2 + i]);
90 }
91 break;
92
93 case I2O_SNFORMAT_ASCII:
94 if (serialno[1] < ' ') {
95
96 max_len =
97 (max_len < serialno[1]) ? max_len : serialno[1];
98 serialno[1 + max_len] = '\0';
99
100
101 seq_printf(seq, "%s", &serialno[2]);
102 } else {
103
104 for (i = 0; i < serialno[1]; i++) {
105 seq_printf(seq, "%c", serialno[2 + i]);
106 }
107 }
108 break;
109
110 case I2O_SNFORMAT_UNICODE:
111 seq_printf(seq, "UNICODE Format. Can't Display\n");
112 break;
113
114 case I2O_SNFORMAT_LAN48_MAC:
115 seq_printf(seq, "LAN-48 MAC address @ %pM", &serialno[2]);
116 break;
117
118 case I2O_SNFORMAT_WAN:
119
120 seq_printf(seq, "WAN Access Address");
121 break;
122
123
124 case I2O_SNFORMAT_LAN64_MAC:
125
126 seq_printf(seq,
127 "LAN-64 MAC address @ [?:%02X:%02X:?] %pM",
128 serialno[8], serialno[9], &serialno[2]);
129 break;
130
131 case I2O_SNFORMAT_DDM:
132 seq_printf(seq,
133 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
134 *(u16 *) & serialno[2],
135 *(u16 *) & serialno[4], *(u16 *) & serialno[6]);
136 break;
137
138 case I2O_SNFORMAT_IEEE_REG64:
139 case I2O_SNFORMAT_IEEE_REG128:
140
141 seq_printf(seq,
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]);
146 break;
147
148 case I2O_SNFORMAT_UNKNOWN:
149 case I2O_SNFORMAT_UNKNOWN2:
150 default:
151 seq_printf(seq, "Unknown data format (0x%02x)", serialno[0]);
152 break;
153 }
154
155 return 0;
156}
157
158
159
160
161
162
163
164static const char *i2o_get_class_name(int class)
165{
166 int idx = 16;
167 static char *i2o_class_name[] = {
168 "Executive",
169 "Device Driver Module",
170 "Block Device",
171 "Tape Device",
172 "LAN Interface",
173 "WAN Interface",
174 "Fibre Channel Port",
175 "Fibre Channel Device",
176 "SCSI Device",
177 "ATE Port",
178 "ATE Device",
179 "Floppy Controller",
180 "Floppy Device",
181 "Secondary Bus Port",
182 "Peer Transport Agent",
183 "Peer Transport",
184 "Unknown"
185 };
186
187 switch (class & 0xfff) {
188 case I2O_CLASS_EXECUTIVE:
189 idx = 0;
190 break;
191 case I2O_CLASS_DDM:
192 idx = 1;
193 break;
194 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
195 idx = 2;
196 break;
197 case I2O_CLASS_SEQUENTIAL_STORAGE:
198 idx = 3;
199 break;
200 case I2O_CLASS_LAN:
201 idx = 4;
202 break;
203 case I2O_CLASS_WAN:
204 idx = 5;
205 break;
206 case I2O_CLASS_FIBRE_CHANNEL_PORT:
207 idx = 6;
208 break;
209 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL:
210 idx = 7;
211 break;
212 case I2O_CLASS_SCSI_PERIPHERAL:
213 idx = 8;
214 break;
215 case I2O_CLASS_ATE_PORT:
216 idx = 9;
217 break;
218 case I2O_CLASS_ATE_PERIPHERAL:
219 idx = 10;
220 break;
221 case I2O_CLASS_FLOPPY_CONTROLLER:
222 idx = 11;
223 break;
224 case I2O_CLASS_FLOPPY_DEVICE:
225 idx = 12;
226 break;
227 case I2O_CLASS_BUS_ADAPTER:
228 idx = 13;
229 break;
230 case I2O_CLASS_PEER_TRANSPORT_AGENT:
231 idx = 14;
232 break;
233 case I2O_CLASS_PEER_TRANSPORT:
234 idx = 15;
235 break;
236 }
237
238 return i2o_class_name[idx];
239}
240
241#define SCSI_TABLE_SIZE 13
242static char *scsi_devices[] = {
243 "Direct-Access Read/Write",
244 "Sequential-Access Storage",
245 "Printer",
246 "Processor",
247 "WORM Device",
248 "CD-ROM Device",
249 "Scanner Device",
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"
256};
257
258static char *chtostr(char *tmp, u8 *chars, int n)
259{
260 tmp[0] = 0;
261 return strncat(tmp, (char *)chars, n);
262}
263
264static int i2o_report_query_status(struct seq_file *seq, int block_status,
265 char *group)
266{
267 switch (block_status) {
268 case -ETIMEDOUT:
269 return seq_printf(seq, "Timeout reading group %s.\n", group);
270 case -ENOMEM:
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);
274 default:
275 return seq_printf(seq,
276 "Error reading group %s. BlockStatus 0x%02X\n",
277 group, -block_status);
278 }
279}
280
281static char *bus_strings[] = {
282 "Local Bus",
283 "ISA",
284 "EISA",
285 "PCI",
286 "PCMCIA",
287 "NUBUS",
288 "CARDBUS"
289};
290
291static int i2o_seq_show_hrt(struct seq_file *seq, void *v)
292{
293 struct i2o_controller *c = (struct i2o_controller *)seq->private;
294 i2o_hrt *hrt = (i2o_hrt *) c->hrt.virt;
295 u32 bus;
296 int i;
297
298 if (hrt->hrt_version) {
299 seq_printf(seq,
300 "HRT table for controller is too new a version.\n");
301 return 0;
302 }
303
304 seq_printf(seq, "HRT has %d entries of %d bytes each.\n",
305 hrt->num_entries, hrt->entry_len << 2);
306
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);
313
314 if (hrt->hrt_entry[i].bus_type != 0x80) {
315 bus = hrt->hrt_entry[i].bus_type;
316 seq_printf(seq, " %s Information\n",
317 bus_strings[bus]);
318
319 switch (bus) {
320 case I2O_BUS_LOCAL:
321 seq_printf(seq, " IOBase: %0#6x,",
322 hrt->hrt_entry[i].bus.local_bus.
323 LbBaseIOPort);
324 seq_printf(seq, " MemoryBase: %0#10x\n",
325 hrt->hrt_entry[i].bus.local_bus.
326 LbBaseMemoryAddress);
327 break;
328
329 case I2O_BUS_ISA:
330 seq_printf(seq, " IOBase: %0#6x,",
331 hrt->hrt_entry[i].bus.isa_bus.
332 IsaBaseIOPort);
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);
338 break;
339
340 case I2O_BUS_EISA:
341 seq_printf(seq, " IOBase: %0#6x,",
342 hrt->hrt_entry[i].bus.eisa_bus.
343 EisaBaseIOPort);
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.
349 EisaSlotNumber);
350 break;
351
352 case I2O_BUS_PCI:
353 seq_printf(seq, " Bus: %0#4x",
354 hrt->hrt_entry[i].bus.pci_bus.
355 PciBusNumber);
356 seq_printf(seq, " Dev: %0#4x",
357 hrt->hrt_entry[i].bus.pci_bus.
358 PciDeviceNumber);
359 seq_printf(seq, " Func: %0#4x",
360 hrt->hrt_entry[i].bus.pci_bus.
361 PciFunctionNumber);
362 seq_printf(seq, " Vendor: %0#6x",
363 hrt->hrt_entry[i].bus.pci_bus.
364 PciVendorID);
365 seq_printf(seq, " Device: %0#6x\n",
366 hrt->hrt_entry[i].bus.pci_bus.
367 PciDeviceID);
368 break;
369
370 default:
371 seq_printf(seq, " Unsupported Bus Type\n");
372 }
373 } else
374 seq_printf(seq, " Unknown Bus Type\n");
375 }
376
377 return 0;
378}
379
380static int i2o_seq_show_lct(struct seq_file *seq, void *v)
381{
382 struct i2o_controller *c = (struct i2o_controller *)seq->private;
383 i2o_lct *lct = (i2o_lct *) c->lct;
384 int entries;
385 int i;
386
387#define BUS_TABLE_SIZE 3
388 static char *bus_ports[] = {
389 "Generic Bus",
390 "SCSI Bus",
391 "Fibre Channel Bus"
392 };
393
394 entries = (lct->table_size - 3) / 9;
395
396 seq_printf(seq, "LCT contains %d %s\n", entries,
397 entries == 1 ? "entry" : "entries");
398 if (lct->boot_tid)
399 seq_printf(seq, "Boot Device @ ID %d\n", lct->boot_tid);
400
401 seq_printf(seq, "Current Change Indicator: %#10x\n", lct->change_ind);
402
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));
407
408
409
410
411 switch (lct->lct_entry[i].class_id & 0xFFF) {
412 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
413 switch (lct->lct_entry[i].sub_class) {
414 case 0x00:
415 seq_printf(seq, ", Direct-Access Read/Write");
416 break;
417
418 case 0x04:
419 seq_printf(seq, ", WORM Drive");
420 break;
421
422 case 0x05:
423 seq_printf(seq, ", CD-ROM Drive");
424 break;
425
426 case 0x07:
427 seq_printf(seq, ", Optical Memory Device");
428 break;
429
430 default:
431 seq_printf(seq, ", Unknown (0x%02x)",
432 lct->lct_entry[i].sub_class);
433 break;
434 }
435 break;
436
437 case I2O_CLASS_LAN:
438 switch (lct->lct_entry[i].sub_class & 0xFF) {
439 case 0x30:
440 seq_printf(seq, ", Ethernet");
441 break;
442
443 case 0x40:
444 seq_printf(seq, ", 100base VG");
445 break;
446
447 case 0x50:
448 seq_printf(seq, ", IEEE 802.5/Token-Ring");
449 break;
450
451 case 0x60:
452 seq_printf(seq, ", ANSI X3T9.5 FDDI");
453 break;
454
455 case 0x70:
456 seq_printf(seq, ", Fibre Channel");
457 break;
458
459 default:
460 seq_printf(seq, ", Unknown Sub-Class (0x%02x)",
461 lct->lct_entry[i].sub_class & 0xFF);
462 break;
463 }
464 break;
465
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].
470 sub_class]);
471 else
472 seq_printf(seq, ", Unknown Device Type");
473 break;
474
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].
479 sub_class]);
480 else
481 seq_printf(seq, ", Unknown Bus Type");
482 break;
483 }
484 seq_printf(seq, "\n");
485
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);
505 }
506
507 return 0;
508}
509
510static int i2o_seq_show_status(struct seq_file *seq, void *v)
511{
512 struct i2o_controller *c = (struct i2o_controller *)seq->private;
513 char prodstr[25];
514 int version;
515 i2o_status_block *sb = c->status_block.virt;
516
517 i2o_status_get(c);
518
519 seq_printf(seq, "Organization ID : %0#6x\n", sb->org_id);
520
521 version = sb->i2o_version;
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
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);
555
556 seq_printf(seq, "I2O version : ");
557 switch (version) {
558 case 0x00:
559 seq_printf(seq, "1.0\n");
560 break;
561 case 0x01:
562 seq_printf(seq, "1.5\n");
563 break;
564 case 0x02:
565 seq_printf(seq, "2.0\n");
566 break;
567 default:
568 seq_printf(seq, "Unknown version\n");
569 }
570
571 seq_printf(seq, "IOP State : ");
572 switch (sb->iop_state) {
573 case 0x01:
574 seq_printf(seq, "INIT\n");
575 break;
576
577 case 0x02:
578 seq_printf(seq, "RESET\n");
579 break;
580
581 case 0x04:
582 seq_printf(seq, "HOLD\n");
583 break;
584
585 case 0x05:
586 seq_printf(seq, "READY\n");
587 break;
588
589 case 0x08:
590 seq_printf(seq, "OPERATIONAL\n");
591 break;
592
593 case 0x10:
594 seq_printf(seq, "FAILED\n");
595 break;
596
597 case 0x11:
598 seq_printf(seq, "FAULTED\n");
599 break;
600
601 default:
602 seq_printf(seq, "Unknown\n");
603 break;
604 }
605
606 seq_printf(seq, "Messenger Type : ");
607 switch (sb->msg_type) {
608 case 0x00:
609 seq_printf(seq, "Memory mapped\n");
610 break;
611 case 0x01:
612 seq_printf(seq, "Memory mapped only\n");
613 break;
614 case 0x02:
615 seq_printf(seq, "Remote only\n");
616 break;
617 case 0x03:
618 seq_printf(seq, "Memory mapped and remote\n");
619 break;
620 default:
621 seq_printf(seq, "Unknown\n");
622 }
623
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);
632
633
634 memcpy(prodstr, sb->product_id, 24);
635 prodstr[24] = '\0';
636 seq_printf(seq, "Product ID : %s\n", prodstr);
637 seq_printf(seq, "Expected LCT Size : %d bytes\n",
638 sb->expected_lct_size);
639
640 seq_printf(seq, "IOP Capabilities\n");
641 seq_printf(seq, " Context Field Size Support : ");
642 switch (sb->iop_capabilities & 0x0000003) {
643 case 0:
644 seq_printf(seq, "Supports only 32-bit context fields\n");
645 break;
646 case 1:
647 seq_printf(seq, "Supports only 64-bit context fields\n");
648 break;
649 case 2:
650 seq_printf(seq, "Supports 32-bit and 64-bit context fields, "
651 "but not concurrently\n");
652 break;
653 case 3:
654 seq_printf(seq, "Supports 32-bit and 64-bit context fields "
655 "concurrently\n");
656 break;
657 default:
658 seq_printf(seq, "0x%08x\n", sb->iop_capabilities);
659 }
660 seq_printf(seq, " Current Context Field Size : ");
661 switch (sb->iop_capabilities & 0x0000000C) {
662 case 0:
663 seq_printf(seq, "not configured\n");
664 break;
665 case 4:
666 seq_printf(seq, "Supports only 32-bit context fields\n");
667 break;
668 case 8:
669 seq_printf(seq, "Supports only 64-bit context fields\n");
670 break;
671 case 12:
672 seq_printf(seq, "Supports both 32-bit or 64-bit context fields "
673 "concurrently\n");
674 break;
675 default:
676 seq_printf(seq, "\n");
677 }
678 seq_printf(seq, " Inbound Peer Support : %s\n",
679 (sb->
680 iop_capabilities & 0x00000010) ? "Supported" :
681 "Not supported");
682 seq_printf(seq, " Outbound Peer Support : %s\n",
683 (sb->
684 iop_capabilities & 0x00000020) ? "Supported" :
685 "Not supported");
686 seq_printf(seq, " Peer to Peer Support : %s\n",
687 (sb->
688 iop_capabilities & 0x00000040) ? "Supported" :
689 "Not supported");
690
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);
703
704 return 0;
705}
706
707static int i2o_seq_show_hw(struct seq_file *seq, void *v)
708{
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;
713 int token;
714 u32 hwcap;
715
716 static char *cpu_table[] = {
717 "Intel 80960 series",
718 "AMD2900 series",
719 "Motorola 68000 series",
720 "ARM series",
721 "MIPS series",
722 "Sparc series",
723 "PowerPC series",
724 "Intel x86 series"
725 };
726
727 token =
728 i2o_parm_field_get(c->exec, 0x0000, -1, &work32, sizeof(work32));
729
730 if (token < 0) {
731 i2o_report_query_status(seq, token, "0x0000 IOP Hardware");
732 return 0;
733 }
734
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 : ");
738 if (work8[16] > 8)
739 seq_printf(seq, "Unknown\n");
740 else
741 seq_printf(seq, "%s\n", cpu_table[work8[16]]);
742
743
744 seq_printf(seq, "RAM : %dkB\n", work32[1] >> 10);
745 seq_printf(seq, "Non-Volatile Mem : %dkB\n", work32[2] >> 10);
746
747 hwcap = work32[3];
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) ? "+" : "-");
759
760 return 0;
761}
762
763
764static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
765{
766 struct i2o_controller *c = (struct i2o_controller *)seq->private;
767 int token;
768 int i;
769
770 typedef struct _i2o_exec_execute_ddm_table {
771 u16 ddm_tid;
772 u8 module_type;
773 u8 reserved;
774 u16 i2o_vendor_id;
775 u16 module_id;
776 u8 module_name_version[28];
777 u32 data_size;
778 u32 code_size;
779 } i2o_exec_execute_ddm_table;
780
781 struct {
782 u16 result_count;
783 u16 pad;
784 u16 block_size;
785 u8 block_status;
786 u8 error_info_size;
787 u16 row_count;
788 u16 more_flag;
789 i2o_exec_execute_ddm_table ddm_table[I2O_MAX_MODULES];
790 } *result;
791
792 i2o_exec_execute_ddm_table ddm_table;
793 char tmp[28 + 1];
794
795 result = kmalloc(sizeof(*result), GFP_KERNEL);
796 if (!result)
797 return -ENOMEM;
798
799 token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0003, -1,
800 NULL, 0, result, sizeof(*result));
801
802 if (token < 0) {
803 i2o_report_query_status(seq, token,
804 "0x0003 Executing DDM List");
805 goto out;
806 }
807
808 seq_printf(seq,
809 "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
810 ddm_table = result->ddm_table[0];
811
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);
814
815 switch (ddm_table.module_type) {
816 case 0x01:
817 seq_printf(seq, "Downloaded DDM ");
818 break;
819 case 0x22:
820 seq_printf(seq, "Embedded DDM ");
821 break;
822 default:
823 seq_printf(seq, " ");
824 }
825
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);
832
833 seq_printf(seq, "\n");
834 }
835 out:
836 kfree(result);
837 return 0;
838}
839
840
841static int i2o_seq_show_driver_store(struct seq_file *seq, void *v)
842{
843 struct i2o_controller *c = (struct i2o_controller *)seq->private;
844 u32 work32[8];
845 int token;
846
847 token =
848 i2o_parm_field_get(c->exec, 0x0004, -1, &work32, sizeof(work32));
849 if (token < 0) {
850 i2o_report_query_status(seq, token, "0x0004 Driver Store");
851 return 0;
852 }
853
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);
859
860 return 0;
861}
862
863
864static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
865{
866 typedef struct _i2o_driver_store {
867 u16 stored_ddm_index;
868 u8 module_type;
869 u8 reserved;
870 u16 i2o_vendor_id;
871 u16 module_id;
872 u8 module_name_version[28];
873 u8 date[8];
874 u32 module_size;
875 u32 mpb_size;
876 u32 module_flags;
877 } i2o_driver_store_table;
878
879 struct i2o_controller *c = (struct i2o_controller *)seq->private;
880 int token;
881 int i;
882
883 typedef struct {
884 u16 result_count;
885 u16 pad;
886 u16 block_size;
887 u8 block_status;
888 u8 error_info_size;
889 u16 row_count;
890 u16 more_flag;
891 i2o_driver_store_table dst[I2O_MAX_MODULES];
892 } i2o_driver_result_table;
893
894 i2o_driver_result_table *result;
895 i2o_driver_store_table *dst;
896 char tmp[28 + 1];
897
898 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
899 if (result == NULL)
900 return -ENOMEM;
901
902 token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0005, -1,
903 NULL, 0, result, sizeof(*result));
904
905 if (token < 0) {
906 i2o_report_query_status(seq, token,
907 "0x0005 DRIVER STORE TABLE");
908 kfree(result);
909 return 0;
910 }
911
912 seq_printf(seq,
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) {
919 case 0x01:
920 seq_printf(seq, "Downloaded DDM ");
921 break;
922 case 0x22:
923 seq_printf(seq, "Embedded DDM ");
924 break;
925 default:
926 seq_printf(seq, " ");
927 }
928
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");
938 }
939
940 kfree(result);
941 return 0;
942}
943
944
945static int i2o_seq_show_groups(struct seq_file *seq, void *v)
946{
947 struct i2o_device *d = (struct i2o_device *)seq->private;
948 int token;
949 int i;
950 u8 properties;
951
952 typedef struct _i2o_group_info {
953 u16 group_number;
954 u16 field_count;
955 u16 row_count;
956 u8 properties;
957 u8 reserved;
958 } i2o_group_info;
959
960 struct {
961 u16 result_count;
962 u16 pad;
963 u16 block_size;
964 u8 block_status;
965 u8 error_info_size;
966 u16 row_count;
967 u16 more_flag;
968 i2o_group_info group[256];
969 } *result;
970
971 result = kmalloc(sizeof(*result), GFP_KERNEL);
972 if (!result)
973 return -ENOMEM;
974
975 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
976 result, sizeof(*result));
977
978 if (token < 0) {
979 i2o_report_query_status(seq, token, "0xF000 Params Descriptor");
980 goto out;
981 }
982
983 seq_printf(seq,
984 "# Group FieldCount RowCount Type Add Del Clear\n");
985
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);
991
992 properties = result->group[i].properties;
993 if (properties & 0x1)
994 seq_printf(seq, "Table ");
995 else
996 seq_printf(seq, "Scalar ");
997 if (properties & 0x2)
998 seq_printf(seq, " + ");
999 else
1000 seq_printf(seq, " - ");
1001 if (properties & 0x4)
1002 seq_printf(seq, " + ");
1003 else
1004 seq_printf(seq, " - ");
1005 if (properties & 0x8)
1006 seq_printf(seq, " + ");
1007 else
1008 seq_printf(seq, " - ");
1009
1010 seq_printf(seq, "\n");
1011 }
1012
1013 if (result->more_flag)
1014 seq_printf(seq, "There is more...\n");
1015 out:
1016 kfree(result);
1017 return 0;
1018}
1019
1020
1021static int i2o_seq_show_phys_device(struct seq_file *seq, void *v)
1022{
1023 struct i2o_device *d = (struct i2o_device *)seq->private;
1024 int token;
1025 int i;
1026
1027 struct {
1028 u16 result_count;
1029 u16 pad;
1030 u16 block_size;
1031 u8 block_status;
1032 u8 error_info_size;
1033 u16 row_count;
1034 u16 more_flag;
1035 u32 adapter_id[64];
1036 } result;
1037
1038 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF001, -1, NULL, 0,
1039 &result, sizeof(result));
1040
1041 if (token < 0) {
1042 i2o_report_query_status(seq, token,
1043 "0xF001 Physical Device Table");
1044 return 0;
1045 }
1046
1047 if (result.row_count)
1048 seq_printf(seq, "# AdapterId\n");
1049
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]);
1053 }
1054
1055 if (result.more_flag)
1056 seq_printf(seq, "There is more...\n");
1057
1058 return 0;
1059}
1060
1061
1062static int i2o_seq_show_claimed(struct seq_file *seq, void *v)
1063{
1064 struct i2o_device *d = (struct i2o_device *)seq->private;
1065 int token;
1066 int i;
1067
1068 struct {
1069 u16 result_count;
1070 u16 pad;
1071 u16 block_size;
1072 u8 block_status;
1073 u8 error_info_size;
1074 u16 row_count;
1075 u16 more_flag;
1076 u16 claimed_tid[64];
1077 } result;
1078
1079 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF002, -1, NULL, 0,
1080 &result, sizeof(result));
1081
1082 if (token < 0) {
1083 i2o_report_query_status(seq, token, "0xF002 Claimed Table");
1084 return 0;
1085 }
1086
1087 if (result.row_count)
1088 seq_printf(seq, "# ClaimedTid\n");
1089
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]);
1093 }
1094
1095 if (result.more_flag)
1096 seq_printf(seq, "There is more...\n");
1097
1098 return 0;
1099}
1100
1101
1102static int i2o_seq_show_users(struct seq_file *seq, void *v)
1103{
1104 struct i2o_device *d = (struct i2o_device *)seq->private;
1105 int token;
1106 int i;
1107
1108 typedef struct _i2o_user_table {
1109 u16 instance;
1110 u16 user_tid;
1111 u8 claim_type;
1112 u8 reserved1;
1113 u16 reserved2;
1114 } i2o_user_table;
1115
1116 struct {
1117 u16 result_count;
1118 u16 pad;
1119 u16 block_size;
1120 u8 block_status;
1121 u8 error_info_size;
1122 u16 row_count;
1123 u16 more_flag;
1124 i2o_user_table user[64];
1125 } *result;
1126
1127 result = kmalloc(sizeof(*result), GFP_KERNEL);
1128 if (!result)
1129 return -ENOMEM;
1130
1131 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF003, -1, NULL, 0,
1132 result, sizeof(*result));
1133
1134 if (token < 0) {
1135 i2o_report_query_status(seq, token, "0xF003 User Table");
1136 goto out;
1137 }
1138
1139 seq_printf(seq, "# Instance UserTid ClaimType\n");
1140
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);
1146 }
1147
1148 if (result->more_flag)
1149 seq_printf(seq, "There is more...\n");
1150 out:
1151 kfree(result);
1152 return 0;
1153}
1154
1155
1156static int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v)
1157{
1158 struct i2o_device *d = (struct i2o_device *)seq->private;
1159 int token;
1160 int i;
1161
1162 typedef struct _i2o_private {
1163 u16 ext_instance;
1164 u16 organization_id;
1165 u16 x_function_code;
1166 } i2o_private;
1167
1168 struct {
1169 u16 result_count;
1170 u16 pad;
1171 u16 block_size;
1172 u8 block_status;
1173 u8 error_info_size;
1174 u16 row_count;
1175 u16 more_flag;
1176 i2o_private extension[64];
1177 } result;
1178
1179 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
1180 &result, sizeof(result));
1181
1182 if (token < 0) {
1183 i2o_report_query_status(seq, token,
1184 "0xF005 Private Message Extensions (optional)");
1185 return 0;
1186 }
1187
1188 seq_printf(seq, "Instance# OrgId FunctionCode\n");
1189
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);
1194
1195 seq_printf(seq, "\n");
1196 }
1197
1198 if (result.more_flag)
1199 seq_printf(seq, "There is more...\n");
1200
1201 return 0;
1202}
1203
1204
1205static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
1206{
1207 struct i2o_device *d = (struct i2o_device *)seq->private;
1208 int token;
1209 int i;
1210
1211 struct {
1212 u16 result_count;
1213 u16 pad;
1214 u16 block_size;
1215 u8 block_status;
1216 u8 error_info_size;
1217 u16 row_count;
1218 u16 more_flag;
1219 u32 alternate_tid[64];
1220 } result;
1221
1222 token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF006, -1, NULL, 0,
1223 &result, sizeof(result));
1224
1225 if (token < 0) {
1226 i2o_report_query_status(seq, token,
1227 "0xF006 Autohorized User Table");
1228 return 0;
1229 }
1230
1231 if (result.row_count)
1232 seq_printf(seq, "# AlternateTid\n");
1233
1234 for (i = 0; i < result.row_count; i++) {
1235 seq_printf(seq, "%-2d", i);
1236 seq_printf(seq, "%#7x ", result.alternate_tid[i]);
1237 }
1238
1239 if (result.more_flag)
1240 seq_printf(seq, "There is more...\n");
1241
1242 return 0;
1243}
1244
1245
1246static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
1247{
1248 struct i2o_device *d = (struct i2o_device *)seq->private;
1249 static u32 work32[128];
1250
1251 static u16 *work16 = (u16 *) work32;
1252 int token;
1253 char tmp[16 + 1];
1254
1255 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
1256
1257 if (token < 0) {
1258 i2o_report_query_status(seq, token, "0xF100 Device Identity");
1259 return 0;
1260 }
1261
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));
1273
1274 seq_printf(seq, "Serial number : ");
1275 print_serial_number(seq, (u8 *) (work32 + 16),
1276
1277
1278
1279 sizeof(work32) - (16 * sizeof(u32)) - 2);
1280 seq_printf(seq, "\n");
1281
1282 return 0;
1283}
1284
1285static int i2o_seq_show_dev_name(struct seq_file *seq, void *v)
1286{
1287 struct i2o_device *d = (struct i2o_device *)seq->private;
1288
1289 seq_printf(seq, "%s\n", dev_name(&d->device));
1290
1291 return 0;
1292}
1293
1294
1295static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
1296{
1297 struct i2o_device *d = (struct i2o_device *)seq->private;
1298 int token;
1299
1300 struct {
1301 u16 ddm_tid;
1302 u8 module_name[24];
1303 u8 module_rev[8];
1304 u8 sn_format;
1305 u8 serial_number[12];
1306 u8 pad[256];
1307 } result;
1308
1309 char tmp[24 + 1];
1310
1311 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
1312
1313 if (token < 0) {
1314 i2o_report_query_status(seq, token, "0xF101 DDM Identity");
1315 return 0;
1316 }
1317
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));
1323
1324 seq_printf(seq, "Serial number : ");
1325 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
1326
1327
1328 seq_printf(seq, "\n");
1329
1330 return 0;
1331}
1332
1333
1334static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
1335{
1336 struct i2o_device *d = (struct i2o_device *)seq->private;
1337 int token;
1338
1339 struct {
1340 u8 device_name[64];
1341 u8 service_name[64];
1342 u8 physical_location[64];
1343 u8 instance_number[4];
1344 } result;
1345
1346 char tmp[64 + 1];
1347
1348 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
1349
1350 if (token < 0) {
1351 i2o_report_query_status(seq, token, "0xF102 User Information");
1352 return 0;
1353 }
1354
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));
1363
1364 return 0;
1365}
1366
1367
1368static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
1369{
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;
1374 int token;
1375
1376 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
1377
1378 if (token < 0) {
1379 i2o_report_query_status(seq, token,
1380 "0xF103 SGL Operating Limits");
1381 return 0;
1382 }
1383
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]);
1390
1391
1392
1393
1394
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");
1407
1408
1409
1410
1411 return 0;
1412}
1413
1414
1415static int i2o_seq_show_sensors(struct seq_file *seq, void *v)
1416{
1417 struct i2o_device *d = (struct i2o_device *)seq->private;
1418 int token;
1419
1420 struct {
1421 u16 sensor_instance;
1422 u8 component;
1423 u16 component_instance;
1424 u8 sensor_class;
1425 u8 sensor_type;
1426 u8 scaling_exponent;
1427 u32 actual_reading;
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;
1443 u8 sensor_state;
1444 u16 event_enable;
1445 } result;
1446
1447 token = i2o_parm_field_get(d, 0xF200, -1, &result, sizeof(result));
1448
1449 if (token < 0) {
1450 i2o_report_query_status(seq, token,
1451 "0xF200 Sensors (optional)");
1452 return 0;
1453 }
1454
1455 seq_printf(seq, "Sensor instance : %d\n", result.sensor_instance);
1456
1457 seq_printf(seq, "Component : %d = ", result.component);
1458 switch (result.component) {
1459 case 0:
1460 seq_printf(seq, "Other");
1461 break;
1462 case 1:
1463 seq_printf(seq, "Planar logic Board");
1464 break;
1465 case 2:
1466 seq_printf(seq, "CPU");
1467 break;
1468 case 3:
1469 seq_printf(seq, "Chassis");
1470 break;
1471 case 4:
1472 seq_printf(seq, "Power Supply");
1473 break;
1474 case 5:
1475 seq_printf(seq, "Storage");
1476 break;
1477 case 6:
1478 seq_printf(seq, "External");
1479 break;
1480 }
1481 seq_printf(seq, "\n");
1482
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");
1487
1488 seq_printf(seq, "Sensor type : %d = ", result.sensor_type);
1489 switch (result.sensor_type) {
1490 case 0:
1491 seq_printf(seq, "Other\n");
1492 break;
1493 case 1:
1494 seq_printf(seq, "Thermal\n");
1495 break;
1496 case 2:
1497 seq_printf(seq, "DC voltage (DC volts)\n");
1498 break;
1499 case 3:
1500 seq_printf(seq, "AC voltage (AC volts)\n");
1501 break;
1502 case 4:
1503 seq_printf(seq, "DC current (DC amps)\n");
1504 break;
1505 case 5:
1506 seq_printf(seq, "AC current (AC volts)\n");
1507 break;
1508 case 6:
1509 seq_printf(seq, "Door open\n");
1510 break;
1511 case 7:
1512 seq_printf(seq, "Fan operational\n");
1513 break;
1514 }
1515
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);
1546
1547 seq_printf(seq, "Sensor state : %d = ", result.sensor_state);
1548 switch (result.sensor_state) {
1549 case 0:
1550 seq_printf(seq, "Normal\n");
1551 break;
1552 case 1:
1553 seq_printf(seq, "Abnormal\n");
1554 break;
1555 case 2:
1556 seq_printf(seq, "Unknown\n");
1557 break;
1558 case 3:
1559 seq_printf(seq, "Low Catastrophic (LoCat)\n");
1560 break;
1561 case 4:
1562 seq_printf(seq, "Low (Low)\n");
1563 break;
1564 case 5:
1565 seq_printf(seq, "Low Warning (LoWarn)\n");
1566 break;
1567 case 6:
1568 seq_printf(seq, "High Warning (HiWarn)\n");
1569 break;
1570 case 7:
1571 seq_printf(seq, "High (High)\n");
1572 break;
1573 case 8:
1574 seq_printf(seq, "High Catastrophic (HiCat)\n");
1575 break;
1576 }
1577
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) ? "+" : "-");
1587 seq_printf(seq,
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) ? "+" : "-");
1596
1597 return 0;
1598}
1599
1600static int i2o_seq_open_hrt(struct inode *inode, struct file *file)
1601{
1602 return single_open(file, i2o_seq_show_hrt, PDE_DATA(inode));
1603};
1604
1605static int i2o_seq_open_lct(struct inode *inode, struct file *file)
1606{
1607 return single_open(file, i2o_seq_show_lct, PDE_DATA(inode));
1608};
1609
1610static int i2o_seq_open_status(struct inode *inode, struct file *file)
1611{
1612 return single_open(file, i2o_seq_show_status, PDE_DATA(inode));
1613};
1614
1615static int i2o_seq_open_hw(struct inode *inode, struct file *file)
1616{
1617 return single_open(file, i2o_seq_show_hw, PDE_DATA(inode));
1618};
1619
1620static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file)
1621{
1622 return single_open(file, i2o_seq_show_ddm_table, PDE_DATA(inode));
1623};
1624
1625static int i2o_seq_open_driver_store(struct inode *inode, struct file *file)
1626{
1627 return single_open(file, i2o_seq_show_driver_store, PDE_DATA(inode));
1628};
1629
1630static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file)
1631{
1632 return single_open(file, i2o_seq_show_drivers_stored, PDE_DATA(inode));
1633};
1634
1635static int i2o_seq_open_groups(struct inode *inode, struct file *file)
1636{
1637 return single_open(file, i2o_seq_show_groups, PDE_DATA(inode));
1638};
1639
1640static int i2o_seq_open_phys_device(struct inode *inode, struct file *file)
1641{
1642 return single_open(file, i2o_seq_show_phys_device, PDE_DATA(inode));
1643};
1644
1645static int i2o_seq_open_claimed(struct inode *inode, struct file *file)
1646{
1647 return single_open(file, i2o_seq_show_claimed, PDE_DATA(inode));
1648};
1649
1650static int i2o_seq_open_users(struct inode *inode, struct file *file)
1651{
1652 return single_open(file, i2o_seq_show_users, PDE_DATA(inode));
1653};
1654
1655static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file)
1656{
1657 return single_open(file, i2o_seq_show_priv_msgs, PDE_DATA(inode));
1658};
1659
1660static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file)
1661{
1662 return single_open(file, i2o_seq_show_authorized_users,
1663 PDE_DATA(inode));
1664};
1665
1666static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file)
1667{
1668 return single_open(file, i2o_seq_show_dev_identity, PDE_DATA(inode));
1669};
1670
1671static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file)
1672{
1673 return single_open(file, i2o_seq_show_ddm_identity, PDE_DATA(inode));
1674};
1675
1676static int i2o_seq_open_uinfo(struct inode *inode, struct file *file)
1677{
1678 return single_open(file, i2o_seq_show_uinfo, PDE_DATA(inode));
1679};
1680
1681static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file)
1682{
1683 return single_open(file, i2o_seq_show_sgl_limits, PDE_DATA(inode));
1684};
1685
1686static int i2o_seq_open_sensors(struct inode *inode, struct file *file)
1687{
1688 return single_open(file, i2o_seq_show_sensors, PDE_DATA(inode));
1689};
1690
1691static int i2o_seq_open_dev_name(struct inode *inode, struct file *file)
1692{
1693 return single_open(file, i2o_seq_show_dev_name, PDE_DATA(inode));
1694};
1695
1696static const struct file_operations i2o_seq_fops_lct = {
1697 .open = i2o_seq_open_lct,
1698 .read = seq_read,
1699 .llseek = seq_lseek,
1700 .release = single_release,
1701};
1702
1703static const struct file_operations i2o_seq_fops_hrt = {
1704 .open = i2o_seq_open_hrt,
1705 .read = seq_read,
1706 .llseek = seq_lseek,
1707 .release = single_release,
1708};
1709
1710static const struct file_operations i2o_seq_fops_status = {
1711 .open = i2o_seq_open_status,
1712 .read = seq_read,
1713 .llseek = seq_lseek,
1714 .release = single_release,
1715};
1716
1717static const struct file_operations i2o_seq_fops_hw = {
1718 .open = i2o_seq_open_hw,
1719 .read = seq_read,
1720 .llseek = seq_lseek,
1721 .release = single_release,
1722};
1723
1724static const struct file_operations i2o_seq_fops_ddm_table = {
1725 .open = i2o_seq_open_ddm_table,
1726 .read = seq_read,
1727 .llseek = seq_lseek,
1728 .release = single_release,
1729};
1730
1731static const struct file_operations i2o_seq_fops_driver_store = {
1732 .open = i2o_seq_open_driver_store,
1733 .read = seq_read,
1734 .llseek = seq_lseek,
1735 .release = single_release,
1736};
1737
1738static const struct file_operations i2o_seq_fops_drivers_stored = {
1739 .open = i2o_seq_open_drivers_stored,
1740 .read = seq_read,
1741 .llseek = seq_lseek,
1742 .release = single_release,
1743};
1744
1745static const struct file_operations i2o_seq_fops_groups = {
1746 .open = i2o_seq_open_groups,
1747 .read = seq_read,
1748 .llseek = seq_lseek,
1749 .release = single_release,
1750};
1751
1752static const struct file_operations i2o_seq_fops_phys_device = {
1753 .open = i2o_seq_open_phys_device,
1754 .read = seq_read,
1755 .llseek = seq_lseek,
1756 .release = single_release,
1757};
1758
1759static const struct file_operations i2o_seq_fops_claimed = {
1760 .open = i2o_seq_open_claimed,
1761 .read = seq_read,
1762 .llseek = seq_lseek,
1763 .release = single_release,
1764};
1765
1766static const struct file_operations i2o_seq_fops_users = {
1767 .open = i2o_seq_open_users,
1768 .read = seq_read,
1769 .llseek = seq_lseek,
1770 .release = single_release,
1771};
1772
1773static const struct file_operations i2o_seq_fops_priv_msgs = {
1774 .open = i2o_seq_open_priv_msgs,
1775 .read = seq_read,
1776 .llseek = seq_lseek,
1777 .release = single_release,
1778};
1779
1780static const struct file_operations i2o_seq_fops_authorized_users = {
1781 .open = i2o_seq_open_authorized_users,
1782 .read = seq_read,
1783 .llseek = seq_lseek,
1784 .release = single_release,
1785};
1786
1787static const struct file_operations i2o_seq_fops_dev_name = {
1788 .open = i2o_seq_open_dev_name,
1789 .read = seq_read,
1790 .llseek = seq_lseek,
1791 .release = single_release,
1792};
1793
1794static const struct file_operations i2o_seq_fops_dev_identity = {
1795 .open = i2o_seq_open_dev_identity,
1796 .read = seq_read,
1797 .llseek = seq_lseek,
1798 .release = single_release,
1799};
1800
1801static const struct file_operations i2o_seq_fops_ddm_identity = {
1802 .open = i2o_seq_open_ddm_identity,
1803 .read = seq_read,
1804 .llseek = seq_lseek,
1805 .release = single_release,
1806};
1807
1808static const struct file_operations i2o_seq_fops_uinfo = {
1809 .open = i2o_seq_open_uinfo,
1810 .read = seq_read,
1811 .llseek = seq_lseek,
1812 .release = single_release,
1813};
1814
1815static const struct file_operations i2o_seq_fops_sgl_limits = {
1816 .open = i2o_seq_open_sgl_limits,
1817 .read = seq_read,
1818 .llseek = seq_lseek,
1819 .release = single_release,
1820};
1821
1822static const struct file_operations i2o_seq_fops_sensors = {
1823 .open = i2o_seq_open_sensors,
1824 .read = seq_read,
1825 .llseek = seq_lseek,
1826 .release = single_release,
1827};
1828
1829
1830
1831
1832
1833static 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},
1841 {NULL, 0, NULL}
1842};
1843
1844
1845
1846
1847static 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},
1859 {NULL, 0, NULL}
1860};
1861
1862
1863
1864
1865static i2o_proc_entry rbs_dev_entries[] = {
1866 {"dev_name", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_name},
1867 {NULL, 0, NULL}
1868};
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880static int i2o_proc_create_entries(struct proc_dir_entry *dir,
1881 i2o_proc_entry * i2o_pe, void *data)
1882{
1883 struct proc_dir_entry *tmp;
1884
1885 while (i2o_pe->name) {
1886 tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir,
1887 i2o_pe->fops, data);
1888 if (!tmp)
1889 return -1;
1890
1891 i2o_pe++;
1892 }
1893
1894 return 0;
1895}
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905static void i2o_proc_device_add(struct proc_dir_entry *dir,
1906 struct i2o_device *dev)
1907{
1908 char buff[10];
1909 struct proc_dir_entry *devdir;
1910 i2o_proc_entry *i2o_pe = NULL;
1911
1912 sprintf(buff, "%03x", dev->lct_data.tid);
1913
1914 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);
1915
1916 devdir = proc_mkdir_data(buff, 0, dir, dev);
1917 if (!devdir) {
1918 osm_warn("Could not allocate procdir!\n");
1919 return;
1920 }
1921
1922 i2o_proc_create_entries(devdir, generic_dev_entries, dev);
1923
1924
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;
1929 break;
1930 default:
1931 break;
1932 }
1933 if (i2o_pe)
1934 i2o_proc_create_entries(devdir, i2o_pe, dev);
1935}
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947static int i2o_proc_iop_add(struct proc_dir_entry *dir,
1948 struct i2o_controller *c)
1949{
1950 struct proc_dir_entry *iopdir;
1951 struct i2o_device *dev;
1952
1953 osm_debug("adding IOP /proc/i2o/%s\n", c->name);
1954
1955 iopdir = proc_mkdir_data(c->name, 0, dir, c);
1956 if (!iopdir)
1957 return -1;
1958
1959 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);
1960
1961 list_for_each_entry(dev, &c->devices, list)
1962 i2o_proc_device_add(iopdir, dev);
1963
1964 return 0;
1965}
1966
1967
1968
1969
1970
1971
1972
1973
1974static int __init i2o_proc_fs_create(void)
1975{
1976 struct i2o_controller *c;
1977
1978 i2o_proc_dir_root = proc_mkdir("i2o", NULL);
1979 if (!i2o_proc_dir_root)
1980 return -1;
1981
1982 list_for_each_entry(c, &i2o_controllers, list)
1983 i2o_proc_iop_add(i2o_proc_dir_root, c);
1984
1985 return 0;
1986};
1987
1988
1989
1990
1991
1992
1993
1994
1995static int __exit i2o_proc_fs_destroy(void)
1996{
1997 remove_proc_subtree("i2o", NULL);
1998
1999 return 0;
2000};
2001
2002
2003
2004
2005
2006
2007
2008
2009static int __init i2o_proc_init(void)
2010{
2011 int rc;
2012
2013 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
2014
2015 rc = i2o_driver_register(&i2o_proc_driver);
2016 if (rc)
2017 return rc;
2018
2019 rc = i2o_proc_fs_create();
2020 if (rc) {
2021 i2o_driver_unregister(&i2o_proc_driver);
2022 return rc;
2023 }
2024
2025 return 0;
2026};
2027
2028
2029
2030
2031
2032
2033static void __exit i2o_proc_exit(void)
2034{
2035 i2o_driver_unregister(&i2o_proc_driver);
2036 i2o_proc_fs_destroy();
2037};
2038
2039MODULE_AUTHOR("Deepak Saxena");
2040MODULE_LICENSE("GPL");
2041MODULE_DESCRIPTION(OSM_DESCRIPTION);
2042MODULE_VERSION(OSM_VERSION);
2043
2044module_init(i2o_proc_init);
2045module_exit(i2o_proc_exit);
2046