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
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
13 * This is an initial test release. The code is based on the design
14 * of the ide procfs system (drivers/block/ide-proc.c). Some code
15 * taken from 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.
20 * LAN entries by Juha Sievänen (Juha.Sievanen@cs.Helsinki.FI),
21 * Auvo Häkkinen (Auvo.Hakkinen@cs.Helsinki.FI)
22 * University of Helsinki, Department of Computer Science
32 * - Add support for any version 2.0 spec changes once 2.0 IRTOS is
33 * is available to test with
34 * - Clean up code to use official structure definitions
38 #define FMT_U64_HEX "0x%08x%08x"
39 #define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
41 #include <linux/types.h>
42 #include <linux/kernel.h>
43 #include <linux/pci.h>
44 #include <linux/i2o.h>
45 #include <linux/proc_fs.h>
46 #include <linux/seq_file.h>
47 #include <linux/init.h>
48 #include <linux/module.h>
49 #include <linux/errno.h>
50 #include <linux/spinlock.h>
51 #include <linux/workqueue.h>
54 #include <asm/uaccess.h>
55 #include <asm/byteorder.h>
60 * Structure used to define /proc entries
62 typedef struct _i2o_proc_entry_t
64 char *name; /* entry name */
65 mode_t mode; /* mode */
66 read_proc_t *read_proc; /* read func */
67 write_proc_t *write_proc; /* write func */
68 struct file_operations *fops_proc; /* file operations func */
71 // #define DRIVERDEBUG
73 static int i2o_seq_show_lct(struct seq_file *, void *);
74 static int i2o_seq_show_hrt(struct seq_file *, void *);
75 static int i2o_seq_show_status(struct seq_file *, void *);
77 static int i2o_proc_read_hw(char *, char **, off_t, int, int *, void *);
78 static int i2o_proc_read_ddm_table(char *, char **, off_t, int, int *, void *);
79 static int i2o_proc_read_driver_store(char *, char **, off_t, int, int *, void *);
80 static int i2o_proc_read_drivers_stored(char *, char **, off_t, int, int *, void *);
82 static int i2o_proc_read_groups(char *, char **, off_t, int, int *, void *);
83 static int i2o_proc_read_phys_device(char *, char **, off_t, int, int *, void *);
84 static int i2o_proc_read_claimed(char *, char **, off_t, int, int *, void *);
85 static int i2o_proc_read_users(char *, char **, off_t, int, int *, void *);
86 static int i2o_proc_read_priv_msgs(char *, char **, off_t, int, int *, void *);
87 static int i2o_proc_read_authorized_users(char *, char **, off_t, int, int *, void *);
89 static int i2o_proc_read_dev_name(char *, char **, off_t, int, int *, void *);
90 static int i2o_proc_read_dev_identity(char *, char **, off_t, int, int *, void *);
91 static int i2o_proc_read_ddm_identity(char *, char **, off_t, int, int *, void *);
92 static int i2o_proc_read_uinfo(char *, char **, off_t, int, int *, void *);
93 static int i2o_proc_read_sgl_limits(char *, char **, off_t, int, int *, void *);
95 static int i2o_proc_read_sensors(char *, char **, off_t, int, int *, void *);
97 static int print_serial_number(char *, int, u8 *, int);
99 static int i2o_proc_create_entries(void *, i2o_proc_entry *,
100 struct proc_dir_entry *);
101 static void i2o_proc_remove_entries(i2o_proc_entry *, struct proc_dir_entry *);
102 static int i2o_proc_add_controller(struct i2o_controller *,
103 struct proc_dir_entry * );
104 static void i2o_proc_remove_controller(struct i2o_controller *,
105 struct proc_dir_entry * );
106 static void i2o_proc_add_device(struct i2o_device *, struct proc_dir_entry *);
107 static void i2o_proc_remove_device(struct i2o_device *);
108 static int create_i2o_procfs(void);
109 static int destroy_i2o_procfs(void);
110 static void i2o_proc_new_dev(struct i2o_controller *, struct i2o_device *);
111 static void i2o_proc_dev_del(struct i2o_controller *, struct i2o_device *);
113 static int i2o_proc_read_lan_dev_info(char *, char **, off_t, int, int *,
115 static int i2o_proc_read_lan_mac_addr(char *, char **, off_t, int, int *,
117 static int i2o_proc_read_lan_mcast_addr(char *, char **, off_t, int, int *,
119 static int i2o_proc_read_lan_batch_control(char *, char **, off_t, int, int *,
121 static int i2o_proc_read_lan_operation(char *, char **, off_t, int, int *,
123 static int i2o_proc_read_lan_media_operation(char *, char **, off_t, int,
125 static int i2o_proc_read_lan_alt_addr(char *, char **, off_t, int, int *,
127 static int i2o_proc_read_lan_tx_info(char *, char **, off_t, int, int *,
129 static int i2o_proc_read_lan_rx_info(char *, char **, off_t, int, int *,
131 static int i2o_proc_read_lan_hist_stats(char *, char **, off_t, int, int *,
133 static int i2o_proc_read_lan_eth_stats(char *, char **, off_t, int,
135 static int i2o_proc_read_lan_tr_stats(char *, char **, off_t, int, int *,
137 static int i2o_proc_read_lan_fddi_stats(char *, char **, off_t, int, int *,
140 static struct proc_dir_entry *i2o_proc_dir_root;
145 static struct i2o_handler i2o_proc_handler =
153 0xffffffff // All classes
156 static int i2o_seq_open_hrt(struct inode *inode, struct file *file)
158 return single_open(file, i2o_seq_show_hrt, PDE(inode)->data);
161 struct file_operations i2o_seq_fops_hrt = {
162 .open = i2o_seq_open_hrt,
165 .release = single_release
168 static int i2o_seq_open_lct(struct inode *inode, struct file *file)
170 return single_open(file, i2o_seq_show_lct, PDE(inode)->data);
173 struct file_operations i2o_seq_fops_lct = {
174 .open = i2o_seq_open_lct,
177 .release = single_release
180 static int i2o_seq_open_status(struct inode *inode, struct file *file)
182 return single_open(file, i2o_seq_show_status, PDE(inode)->data);
185 struct file_operations i2o_seq_fops_status = {
186 .open = i2o_seq_open_status,
189 .release = single_release
193 * IOP specific entries...write field just in case someone
196 static i2o_proc_entry generic_iop_entries[] =
198 {"hrt", S_IFREG|S_IRUGO, NULL, NULL, &i2o_seq_fops_hrt},
199 {"lct", S_IFREG|S_IRUGO, NULL, NULL, &i2o_seq_fops_lct},
200 {"status", S_IFREG|S_IRUGO, NULL, NULL, &i2o_seq_fops_status},
201 {"hw", S_IFREG|S_IRUGO, i2o_proc_read_hw, NULL, NULL},
202 {"ddm_table", S_IFREG|S_IRUGO, i2o_proc_read_ddm_table, NULL, NULL},
203 {"driver_store", S_IFREG|S_IRUGO, i2o_proc_read_driver_store, NULL, NULL},
204 {"drivers_stored", S_IFREG|S_IRUGO, i2o_proc_read_drivers_stored, NULL, NULL},
205 {NULL, 0, NULL, NULL, NULL}
209 * Device specific entries
211 static i2o_proc_entry generic_dev_entries[] =
213 {"groups", S_IFREG|S_IRUGO, i2o_proc_read_groups, NULL, NULL},
214 {"phys_dev", S_IFREG|S_IRUGO, i2o_proc_read_phys_device, NULL, NULL},
215 {"claimed", S_IFREG|S_IRUGO, i2o_proc_read_claimed, NULL, NULL},
216 {"users", S_IFREG|S_IRUGO, i2o_proc_read_users, NULL, NULL},
217 {"priv_msgs", S_IFREG|S_IRUGO, i2o_proc_read_priv_msgs, NULL, NULL},
218 {"authorized_users", S_IFREG|S_IRUGO, i2o_proc_read_authorized_users, NULL, NULL},
219 {"dev_identity", S_IFREG|S_IRUGO, i2o_proc_read_dev_identity, NULL, NULL},
220 {"ddm_identity", S_IFREG|S_IRUGO, i2o_proc_read_ddm_identity, NULL, NULL},
221 {"user_info", S_IFREG|S_IRUGO, i2o_proc_read_uinfo, NULL, NULL},
222 {"sgl_limits", S_IFREG|S_IRUGO, i2o_proc_read_sgl_limits, NULL, NULL},
223 {"sensors", S_IFREG|S_IRUGO, i2o_proc_read_sensors, NULL, NULL},
224 {NULL, 0, NULL, NULL, NULL}
228 * Storage unit specific entries (SCSI Periph, BS) with device names
230 static i2o_proc_entry rbs_dev_entries[] =
232 {"dev_name", S_IFREG|S_IRUGO, i2o_proc_read_dev_name, NULL, NULL},
233 {NULL, 0, NULL, NULL}
236 #define SCSI_TABLE_SIZE 13
237 static char *scsi_devices[] =
239 "Direct-Access Read/Write",
240 "Sequential-Access Storage",
246 "Optical Memory Device",
247 "Medium Changer Device",
248 "Communications Device",
249 "Graphics Art Pre-Press Device",
250 "Graphics Art Pre-Press Device",
251 "Array Controller Device"
257 * Generic LAN specific entries
259 * Should groups with r/w entries have their own subdirectory?
262 static i2o_proc_entry lan_entries[] =
264 {"lan_dev_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_dev_info, NULL, NULL},
265 {"lan_mac_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_mac_addr, NULL, NULL},
266 {"lan_mcast_addr", S_IFREG|S_IRUGO|S_IWUSR,
267 i2o_proc_read_lan_mcast_addr, NULL, NULL},
268 {"lan_batch_ctrl", S_IFREG|S_IRUGO|S_IWUSR,
269 i2o_proc_read_lan_batch_control, NULL, NULL},
270 {"lan_operation", S_IFREG|S_IRUGO, i2o_proc_read_lan_operation, NULL, NULL},
271 {"lan_media_operation", S_IFREG|S_IRUGO,
272 i2o_proc_read_lan_media_operation, NULL, NULL},
273 {"lan_alt_addr", S_IFREG|S_IRUGO, i2o_proc_read_lan_alt_addr, NULL, NULL},
274 {"lan_tx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_tx_info, NULL, NULL},
275 {"lan_rx_info", S_IFREG|S_IRUGO, i2o_proc_read_lan_rx_info, NULL, NULL},
277 {"lan_hist_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_hist_stats, NULL, NULL},
278 {NULL, 0, NULL, NULL, NULL}
282 * Port specific LAN entries
285 static i2o_proc_entry lan_eth_entries[] =
287 {"lan_eth_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_eth_stats, NULL, NULL},
288 {NULL, 0, NULL, NULL, NULL}
291 static i2o_proc_entry lan_tr_entries[] =
293 {"lan_tr_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_tr_stats, NULL, NULL},
294 {NULL, 0, NULL, NULL, NULL}
297 static i2o_proc_entry lan_fddi_entries[] =
299 {"lan_fddi_stats", S_IFREG|S_IRUGO, i2o_proc_read_lan_fddi_stats, NULL, NULL},
300 {NULL, 0, NULL, NULL, NULL}
304 static char *chtostr(u8 *chars, int n)
308 return strncat(tmp, (char *)chars, n);
311 static int i2o_report_query_status(char *buf, int block_status, char *group)
313 switch (block_status)
316 return sprintf(buf, "Timeout reading group %s.\n",group);
318 return sprintf(buf, "No free memory to read the table.\n");
319 case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
320 return sprintf(buf, "Group %s not supported.\n", group);
322 return sprintf(buf, "Error reading group %s. BlockStatus 0x%02X\n",
323 group, -block_status);
327 static char* bus_strings[] =
339 static spinlock_t i2o_proc_lock = SPIN_LOCK_UNLOCKED;
341 int i2o_seq_show_hrt(struct seq_file *seq, void *v)
343 struct i2o_controller *c = (struct i2o_controller *)seq->private;
344 i2o_hrt *hrt = (i2o_hrt *)c->hrt;
350 seq_printf(seq, "HRT table for controller is too new a version.\n");
354 seq_printf(seq, "HRT has %d entries of %d bytes each.\n",
355 hrt->num_entries, hrt->entry_len << 2);
357 for(i = 0; i < hrt->num_entries; i++)
359 seq_printf(seq, "Entry %d:\n", i);
360 seq_printf(seq, " Adapter ID: %0#10x\n",
361 hrt->hrt_entry[i].adapter_id);
362 seq_printf(seq, " Controlling tid: %0#6x\n",
363 hrt->hrt_entry[i].parent_tid);
365 if(hrt->hrt_entry[i].bus_type != 0x80)
367 bus = hrt->hrt_entry[i].bus_type;
368 seq_printf(seq, " %s Information\n", bus_strings[bus]);
373 seq_printf(seq, " IOBase: %0#6x,",
374 hrt->hrt_entry[i].bus.local_bus.LbBaseIOPort);
375 seq_printf(seq, " MemoryBase: %0#10x\n",
376 hrt->hrt_entry[i].bus.local_bus.LbBaseMemoryAddress);
380 seq_printf(seq, " IOBase: %0#6x,",
381 hrt->hrt_entry[i].bus.isa_bus.IsaBaseIOPort);
382 seq_printf(seq, " MemoryBase: %0#10x,",
383 hrt->hrt_entry[i].bus.isa_bus.IsaBaseMemoryAddress);
384 seq_printf(seq, " CSN: %0#4x,",
385 hrt->hrt_entry[i].bus.isa_bus.CSN);
389 seq_printf(seq, " IOBase: %0#6x,",
390 hrt->hrt_entry[i].bus.eisa_bus.EisaBaseIOPort);
391 seq_printf(seq, " MemoryBase: %0#10x,",
392 hrt->hrt_entry[i].bus.eisa_bus.EisaBaseMemoryAddress);
393 seq_printf(seq, " Slot: %0#4x,",
394 hrt->hrt_entry[i].bus.eisa_bus.EisaSlotNumber);
398 seq_printf(seq, " IOBase: %0#6x,",
399 hrt->hrt_entry[i].bus.mca_bus.McaBaseIOPort);
400 seq_printf(seq, " MemoryBase: %0#10x,",
401 hrt->hrt_entry[i].bus.mca_bus.McaBaseMemoryAddress);
402 seq_printf(seq, " Slot: %0#4x,",
403 hrt->hrt_entry[i].bus.mca_bus.McaSlotNumber);
407 seq_printf(seq, " Bus: %0#4x",
408 hrt->hrt_entry[i].bus.pci_bus.PciBusNumber);
409 seq_printf(seq, " Dev: %0#4x",
410 hrt->hrt_entry[i].bus.pci_bus.PciDeviceNumber);
411 seq_printf(seq, " Func: %0#4x",
412 hrt->hrt_entry[i].bus.pci_bus.PciFunctionNumber);
413 seq_printf(seq, " Vendor: %0#6x",
414 hrt->hrt_entry[i].bus.pci_bus.PciVendorID);
415 seq_printf(seq, " Device: %0#6x\n",
416 hrt->hrt_entry[i].bus.pci_bus.PciDeviceID);
420 seq_printf(seq, " Unsupported Bus Type\n");
424 seq_printf(seq, " Unknown Bus Type\n");
430 int i2o_seq_show_lct(struct seq_file *seq, void *v)
432 struct i2o_controller *c = (struct i2o_controller*)seq->private;
433 i2o_lct *lct = (i2o_lct *)c->lct;
437 #define BUS_TABLE_SIZE 3
438 static char *bus_ports[] =
445 entries = (lct->table_size - 3)/9;
447 seq_printf(seq, "LCT contains %d %s\n", entries,
448 entries == 1 ? "entry" : "entries");
450 seq_printf(seq, "Boot Device @ ID %d\n", lct->boot_tid);
452 seq_printf(seq, "Current Change Indicator: %#10x\n", lct->change_ind);
454 for(i = 0; i < entries; i++)
456 seq_printf(seq, "Entry %d\n", i);
457 seq_printf(seq, " Class, SubClass : %s", i2o_get_class_name(lct->lct_entry[i].class_id));
460 * Classes which we'll print subclass info for
462 switch(lct->lct_entry[i].class_id & 0xFFF)
464 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
465 switch(lct->lct_entry[i].sub_class)
468 seq_printf(seq, ", Direct-Access Read/Write");
472 seq_printf(seq, ", WORM Drive");
476 seq_printf(seq, ", CD-ROM Drive");
480 seq_printf(seq, ", Optical Memory Device");
484 seq_printf(seq, ", Unknown (0x%02x)",
485 lct->lct_entry[i].sub_class);
491 switch(lct->lct_entry[i].sub_class & 0xFF)
494 seq_printf(seq, ", Ethernet");
498 seq_printf(seq, ", 100base VG");
502 seq_printf(seq, ", IEEE 802.5/Token-Ring");
506 seq_printf(seq, ", ANSI X3T9.5 FDDI");
510 seq_printf(seq, ", Fibre Channel");
514 seq_printf(seq, ", Unknown Sub-Class (0x%02x)",
515 lct->lct_entry[i].sub_class & 0xFF);
520 case I2O_CLASS_SCSI_PERIPHERAL:
521 if(lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
522 seq_printf(seq, ", %s",
523 scsi_devices[lct->lct_entry[i].sub_class]);
525 seq_printf(seq, ", Unknown Device Type");
528 case I2O_CLASS_BUS_ADAPTER_PORT:
529 if(lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
530 seq_printf(seq, ", %s",
531 bus_ports[lct->lct_entry[i].sub_class]);
533 seq_printf(seq, ", Unknown Bus Type");
536 seq_printf(seq, "\n");
538 seq_printf(seq, " Local TID : 0x%03x\n", lct->lct_entry[i].tid);
539 seq_printf(seq, " User TID : 0x%03x\n", lct->lct_entry[i].user_tid);
540 seq_printf(seq, " Parent TID : 0x%03x\n",
541 lct->lct_entry[i].parent_tid);
542 seq_printf(seq, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
543 lct->lct_entry[i].identity_tag[0],
544 lct->lct_entry[i].identity_tag[1],
545 lct->lct_entry[i].identity_tag[2],
546 lct->lct_entry[i].identity_tag[3],
547 lct->lct_entry[i].identity_tag[4],
548 lct->lct_entry[i].identity_tag[5],
549 lct->lct_entry[i].identity_tag[6],
550 lct->lct_entry[i].identity_tag[7]);
551 seq_printf(seq, " Change Indicator : %0#10x\n",
552 lct->lct_entry[i].change_ind);
553 seq_printf(seq, " Event Capab Mask : %0#10x\n",
554 lct->lct_entry[i].device_flags);
560 int i2o_seq_show_status(struct seq_file *seq, void *v)
562 struct i2o_controller *c = (struct i2o_controller*)seq->private;
566 i2o_status_get(c); // reread the status block
568 seq_printf(seq, "Organization ID : %0#6x\n",
569 c->status_block->org_id);
571 version = c->status_block->i2o_version;
573 /* FIXME for Spec 2.0
574 if (version == 0x02) {
575 seq_printf(seq, "Lowest I2O version supported: ");
576 switch(workspace[2]) {
578 seq_printf(seq, "1.0\n");
581 seq_printf(seq, "1.5\n");
584 seq_printf(seq, "2.0\n");
588 seq_printf(seq, "Highest I2O version supported: ");
589 switch(workspace[3]) {
591 seq_printf(seq, "1.0\n");
594 seq_printf(seq, "1.5\n");
597 seq_printf(seq, "2.0\n");
602 seq_printf(seq, "IOP ID : %0#5x\n",
603 c->status_block->iop_id);
604 seq_printf(seq, "Host Unit ID : %0#6x\n",
605 c->status_block->host_unit_id);
606 seq_printf(seq, "Segment Number : %0#5x\n",
607 c->status_block->segment_number);
609 seq_printf(seq, "I2O version : ");
612 seq_printf(seq, "1.0\n");
615 seq_printf(seq, "1.5\n");
618 seq_printf(seq, "2.0\n");
621 seq_printf(seq, "Unknown version\n");
624 seq_printf(seq, "IOP State : ");
625 switch (c->status_block->iop_state) {
627 seq_printf(seq, "INIT\n");
631 seq_printf(seq, "RESET\n");
635 seq_printf(seq, "HOLD\n");
639 seq_printf(seq, "READY\n");
643 seq_printf(seq, "OPERATIONAL\n");
647 seq_printf(seq, "FAILED\n");
651 seq_printf(seq, "FAULTED\n");
655 seq_printf(seq, "Unknown\n");
659 seq_printf(seq, "Messenger Type : ");
660 switch (c->status_block->msg_type) {
662 seq_printf(seq, "Memory mapped\n");
665 seq_printf(seq, "Memory mapped only\n");
668 seq_printf(seq,"Remote only\n");
671 seq_printf(seq, "Memory mapped and remote\n");
674 seq_printf(seq, "Unknown\n");
677 seq_printf(seq, "Inbound Frame Size : %d bytes\n",
678 c->status_block->inbound_frame_size<<2);
679 seq_printf(seq, "Max Inbound Frames : %d\n",
680 c->status_block->max_inbound_frames);
681 seq_printf(seq, "Current Inbound Frames : %d\n",
682 c->status_block->cur_inbound_frames);
683 seq_printf(seq, "Max Outbound Frames : %d\n",
684 c->status_block->max_outbound_frames);
686 /* Spec doesn't say if NULL terminated or not... */
687 memcpy(prodstr, c->status_block->product_id, 24);
689 seq_printf(seq, "Product ID : %s\n", prodstr);
690 seq_printf(seq, "Expected LCT Size : %d bytes\n",
691 c->status_block->expected_lct_size);
693 seq_printf(seq, "IOP Capabilities\n");
694 seq_printf(seq, " Context Field Size Support : ");
695 switch (c->status_block->iop_capabilities & 0x0000003) {
697 seq_printf(seq, "Supports only 32-bit context fields\n");
700 seq_printf(seq, "Supports only 64-bit context fields\n");
703 seq_printf(seq, "Supports 32-bit and 64-bit context fields, "
704 "but not concurrently\n");
707 seq_printf(seq, "Supports 32-bit and 64-bit context fields "
711 seq_printf(seq, "0x%08x\n",c->status_block->iop_capabilities);
713 seq_printf(seq, " Current Context Field Size : ");
714 switch (c->status_block->iop_capabilities & 0x0000000C) {
716 seq_printf(seq, "not configured\n");
719 seq_printf(seq, "Supports only 32-bit context fields\n");
722 seq_printf(seq, "Supports only 64-bit context fields\n");
725 seq_printf(seq, "Supports both 32-bit or 64-bit context fields "
729 seq_printf(seq, "\n");
731 seq_printf(seq, " Inbound Peer Support : %s\n",
732 (c->status_block->iop_capabilities & 0x00000010) ? "Supported" : "Not supported");
733 seq_printf(seq, " Outbound Peer Support : %s\n",
734 (c->status_block->iop_capabilities & 0x00000020) ? "Supported" : "Not supported");
735 seq_printf(seq, " Peer to Peer Support : %s\n",
736 (c->status_block->iop_capabilities & 0x00000040) ? "Supported" : "Not supported");
738 seq_printf(seq, "Desired private memory size : %d kB\n",
739 c->status_block->desired_mem_size>>10);
740 seq_printf(seq, "Allocated private memory size : %d kB\n",
741 c->status_block->current_mem_size>>10);
742 seq_printf(seq, "Private memory base address : %0#10x\n",
743 c->status_block->current_mem_base);
744 seq_printf(seq, "Desired private I/O size : %d kB\n",
745 c->status_block->desired_io_size>>10);
746 seq_printf(seq, "Allocated private I/O size : %d kB\n",
747 c->status_block->current_io_size>>10);
748 seq_printf(seq, "Private I/O base address : %0#10x\n",
749 c->status_block->current_io_base);
754 int i2o_proc_read_hw(char *buf, char **start, off_t offset, int len,
755 int *eof, void *data)
757 struct i2o_controller *c = (struct i2o_controller*)data;
758 static u32 work32[5];
759 static u8 *work8 = (u8*)work32;
760 static u16 *work16 = (u16*)work32;
764 static char *cpu_table[] =
766 "Intel 80960 series",
768 "Motorola 68000 series",
776 spin_lock(&i2o_proc_lock);
780 token = i2o_query_scalar(c, ADAPTER_TID, 0x0000, -1, &work32, sizeof(work32));
783 len += i2o_report_query_status(buf+len, token,"0x0000 IOP Hardware");
784 spin_unlock(&i2o_proc_lock);
788 len += sprintf(buf+len, "I2O Vendor ID : %0#6x\n", work16[0]);
789 len += sprintf(buf+len, "Product ID : %0#6x\n", work16[1]);
790 len += sprintf(buf+len, "CPU : ");
792 len += sprintf(buf+len, "Unknown\n");
794 len += sprintf(buf+len, "%s\n", cpu_table[work8[16]]);
795 /* Anyone using ProcessorVersion? */
797 len += sprintf(buf+len, "RAM : %dkB\n", work32[1]>>10);
798 len += sprintf(buf+len, "Non-Volatile Mem : %dkB\n", work32[2]>>10);
801 len += sprintf(buf+len, "Capabilities : 0x%08x\n", hwcap);
802 len += sprintf(buf+len, " [%s] Self booting\n",
803 (hwcap&0x00000001) ? "+" : "-");
804 len += sprintf(buf+len, " [%s] Upgradable IRTOS\n",
805 (hwcap&0x00000002) ? "+" : "-");
806 len += sprintf(buf+len, " [%s] Supports downloading DDMs\n",
807 (hwcap&0x00000004) ? "+" : "-");
808 len += sprintf(buf+len, " [%s] Supports installing DDMs\n",
809 (hwcap&0x00000008) ? "+" : "-");
810 len += sprintf(buf+len, " [%s] Battery-backed RAM\n",
811 (hwcap&0x00000010) ? "+" : "-");
813 spin_unlock(&i2o_proc_lock);
819 /* Executive group 0003h - Executing DDM List (table) */
820 int i2o_proc_read_ddm_table(char *buf, char **start, off_t offset, int len,
821 int *eof, void *data)
823 struct i2o_controller *c = (struct i2o_controller*)data;
827 typedef struct _i2o_exec_execute_ddm_table {
833 u8 module_name_version[28];
836 } i2o_exec_execute_ddm_table;
847 i2o_exec_execute_ddm_table ddm_table[MAX_I2O_MODULES];
850 i2o_exec_execute_ddm_table ddm_table;
852 result = kmalloc(sizeof(*result), GFP_KERNEL);
856 spin_lock(&i2o_proc_lock);
859 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
863 result, sizeof(*result));
866 len += i2o_report_query_status(buf+len, token,"0x0003 Executing DDM List");
870 len += sprintf(buf+len, "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
871 ddm_table=result->ddm_table[0];
873 for(i=0; i < result->row_count; ddm_table=result->ddm_table[++i])
875 len += sprintf(buf+len, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
877 switch(ddm_table.module_type)
880 len += sprintf(buf+len, "Downloaded DDM ");
883 len += sprintf(buf+len, "Embedded DDM ");
886 len += sprintf(buf+len, " ");
889 len += sprintf(buf+len, "%-#7x", ddm_table.i2o_vendor_id);
890 len += sprintf(buf+len, "%-#8x", ddm_table.module_id);
891 len += sprintf(buf+len, "%-29s", chtostr(ddm_table.module_name_version, 28));
892 len += sprintf(buf+len, "%9d ", ddm_table.data_size);
893 len += sprintf(buf+len, "%8d", ddm_table.code_size);
895 len += sprintf(buf+len, "\n");
898 spin_unlock(&i2o_proc_lock);
904 /* Executive group 0004h - Driver Store (scalar) */
905 int i2o_proc_read_driver_store(char *buf, char **start, off_t offset, int len,
906 int *eof, void *data)
908 struct i2o_controller *c = (struct i2o_controller*)data;
912 spin_lock(&i2o_proc_lock);
916 token = i2o_query_scalar(c, ADAPTER_TID, 0x0004, -1, &work32, sizeof(work32));
918 len += i2o_report_query_status(buf+len, token,"0x0004 Driver Store");
919 spin_unlock(&i2o_proc_lock);
923 len += sprintf(buf+len, "Module limit : %d\n"
924 "Module count : %d\n"
925 "Current space : %d kB\n"
926 "Free space : %d kB\n",
927 work32[0], work32[1], work32[2]>>10, work32[3]>>10);
929 spin_unlock(&i2o_proc_lock);
935 /* Executive group 0005h - Driver Store Table (table) */
936 int i2o_proc_read_drivers_stored(char *buf, char **start, off_t offset,
937 int len, int *eof, void *data)
939 typedef struct _i2o_driver_store {
940 u16 stored_ddm_index;
945 u8 module_name_version[28];
950 } i2o_driver_store_table;
952 struct i2o_controller *c = (struct i2o_controller*)data;
965 i2o_driver_store_table dst[MAX_I2O_MODULES];
966 } i2o_driver_result_table;
968 i2o_driver_result_table *result;
969 i2o_driver_store_table *dst;
974 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
978 spin_lock(&i2o_proc_lock);
980 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
981 c, ADAPTER_TID, 0x0005, -1, NULL, 0,
982 result, sizeof(*result));
985 len += i2o_report_query_status(buf+len, token,"0x0005 DRIVER STORE TABLE");
986 spin_unlock(&i2o_proc_lock);
991 len += sprintf(buf+len, "# Module_type Vendor Mod_id Module_name Vrs"
992 "Date Mod_size Par_size Flags\n");
993 for(i=0, dst=&result->dst[0]; i < result->row_count; dst=&result->dst[++i])
995 len += sprintf(buf+len, "%-3d", dst->stored_ddm_index);
996 switch(dst->module_type)
999 len += sprintf(buf+len, "Downloaded DDM ");
1002 len += sprintf(buf+len, "Embedded DDM ");
1005 len += sprintf(buf+len, " ");
1009 if(c->i2oversion == 0x02)
1010 len += sprintf(buf+len, "%-d", dst->module_state);
1013 len += sprintf(buf+len, "%-#7x", dst->i2o_vendor_id);
1014 len += sprintf(buf+len, "%-#8x", dst->module_id);
1015 len += sprintf(buf+len, "%-29s", chtostr(dst->module_name_version,28));
1016 len += sprintf(buf+len, "%-9s", chtostr(dst->date,8));
1017 len += sprintf(buf+len, "%8d ", dst->module_size);
1018 len += sprintf(buf+len, "%8d ", dst->mpb_size);
1019 len += sprintf(buf+len, "0x%04x", dst->module_flags);
1021 if(c->i2oversion == 0x02)
1022 len += sprintf(buf+len, "%d",
1023 dst->notification_level);
1025 len += sprintf(buf+len, "\n");
1028 spin_unlock(&i2o_proc_lock);
1034 /* Generic group F000h - Params Descriptor (table) */
1035 int i2o_proc_read_groups(char *buf, char **start, off_t offset, int len,
1036 int *eof, void *data)
1038 struct i2o_device *d = (struct i2o_device*)data;
1043 typedef struct _i2o_group_info
1061 i2o_group_info group[256];
1064 result = kmalloc(sizeof(*result), GFP_KERNEL);
1068 spin_lock(&i2o_proc_lock);
1072 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1073 d->controller, d->lct_data.tid, 0xF000, -1, NULL, 0,
1074 result, sizeof(*result));
1077 len = i2o_report_query_status(buf+len, token, "0xF000 Params Descriptor");
1081 len += sprintf(buf+len, "# Group FieldCount RowCount Type Add Del Clear\n");
1083 for (i=0; i < result->row_count; i++)
1085 len += sprintf(buf+len, "%-3d", i);
1086 len += sprintf(buf+len, "0x%04X ", result->group[i].group_number);
1087 len += sprintf(buf+len, "%10d ", result->group[i].field_count);
1088 len += sprintf(buf+len, "%8d ", result->group[i].row_count);
1090 properties = result->group[i].properties;
1091 if (properties & 0x1) len += sprintf(buf+len, "Table ");
1092 else len += sprintf(buf+len, "Scalar ");
1093 if (properties & 0x2) len += sprintf(buf+len, " + ");
1094 else len += sprintf(buf+len, " - ");
1095 if (properties & 0x4) len += sprintf(buf+len, " + ");
1096 else len += sprintf(buf+len, " - ");
1097 if (properties & 0x8) len += sprintf(buf+len, " + ");
1098 else len += sprintf(buf+len, " - ");
1100 len += sprintf(buf+len, "\n");
1103 if (result->more_flag)
1104 len += sprintf(buf+len, "There is more...\n");
1106 spin_unlock(&i2o_proc_lock);
1112 /* Generic group F001h - Physical Device Table (table) */
1113 int i2o_proc_read_phys_device(char *buf, char **start, off_t offset, int len,
1114 int *eof, void *data)
1116 struct i2o_device *d = (struct i2o_device*)data;
1132 spin_lock(&i2o_proc_lock);
1135 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1136 d->controller, d->lct_data.tid,
1137 0xF001, -1, NULL, 0,
1138 &result, sizeof(result));
1141 len += i2o_report_query_status(buf+len, token,"0xF001 Physical Device Table");
1142 spin_unlock(&i2o_proc_lock);
1146 if (result.row_count)
1147 len += sprintf(buf+len, "# AdapterId\n");
1149 for (i=0; i < result.row_count; i++)
1151 len += sprintf(buf+len, "%-2d", i);
1152 len += sprintf(buf+len, "%#7x\n", result.adapter_id[i]);
1155 if (result.more_flag)
1156 len += sprintf(buf+len, "There is more...\n");
1158 spin_unlock(&i2o_proc_lock);
1162 /* Generic group F002h - Claimed Table (table) */
1163 int i2o_proc_read_claimed(char *buf, char **start, off_t offset, int len,
1164 int *eof, void *data)
1166 struct i2o_device *d = (struct i2o_device*)data;
1178 u16 claimed_tid[64];
1181 spin_lock(&i2o_proc_lock);
1184 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1185 d->controller, d->lct_data.tid,
1186 0xF002, -1, NULL, 0,
1187 &result, sizeof(result));
1190 len += i2o_report_query_status(buf+len, token,"0xF002 Claimed Table");
1191 spin_unlock(&i2o_proc_lock);
1195 if (result.row_count)
1196 len += sprintf(buf+len, "# ClaimedTid\n");
1198 for (i=0; i < result.row_count; i++)
1200 len += sprintf(buf+len, "%-2d", i);
1201 len += sprintf(buf+len, "%#7x\n", result.claimed_tid[i]);
1204 if (result.more_flag)
1205 len += sprintf(buf+len, "There is more...\n");
1207 spin_unlock(&i2o_proc_lock);
1211 /* Generic group F003h - User Table (table) */
1212 int i2o_proc_read_users(char *buf, char **start, off_t offset, int len,
1213 int *eof, void *data)
1215 struct i2o_device *d = (struct i2o_device*)data;
1219 typedef struct _i2o_user_table
1237 i2o_user_table user[64];
1240 result = kmalloc(sizeof(*result), GFP_KERNEL);
1244 spin_lock(&i2o_proc_lock);
1247 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1248 d->controller, d->lct_data.tid,
1249 0xF003, -1, NULL, 0,
1250 result, sizeof(*result));
1253 len += i2o_report_query_status(buf+len, token,"0xF003 User Table");
1257 len += sprintf(buf+len, "# Instance UserTid ClaimType\n");
1259 for(i=0; i < result->row_count; i++)
1261 len += sprintf(buf+len, "%-3d", i);
1262 len += sprintf(buf+len, "%#8x ", result->user[i].instance);
1263 len += sprintf(buf+len, "%#7x ", result->user[i].user_tid);
1264 len += sprintf(buf+len, "%#9x\n", result->user[i].claim_type);
1267 if (result->more_flag)
1268 len += sprintf(buf+len, "There is more...\n");
1270 spin_unlock(&i2o_proc_lock);
1275 /* Generic group F005h - Private message extensions (table) (optional) */
1276 int i2o_proc_read_priv_msgs(char *buf, char **start, off_t offset, int len,
1277 int *eof, void *data)
1279 struct i2o_device *d = (struct i2o_device*)data;
1283 typedef struct _i2o_private
1286 u16 organization_id;
1287 u16 x_function_code;
1299 i2o_private extension[64];
1302 spin_lock(&i2o_proc_lock);
1306 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1307 d->controller, d->lct_data.tid,
1310 &result, sizeof(result));
1313 len += i2o_report_query_status(buf+len, token,"0xF005 Private Message Extensions (optional)");
1314 spin_unlock(&i2o_proc_lock);
1318 len += sprintf(buf+len, "Instance# OrgId FunctionCode\n");
1320 for(i=0; i < result.row_count; i++)
1322 len += sprintf(buf+len, "%0#9x ", result.extension[i].ext_instance);
1323 len += sprintf(buf+len, "%0#6x ", result.extension[i].organization_id);
1324 len += sprintf(buf+len, "%0#6x", result.extension[i].x_function_code);
1326 len += sprintf(buf+len, "\n");
1329 if(result.more_flag)
1330 len += sprintf(buf+len, "There is more...\n");
1332 spin_unlock(&i2o_proc_lock);
1338 /* Generic group F006h - Authorized User Table (table) */
1339 int i2o_proc_read_authorized_users(char *buf, char **start, off_t offset, int len,
1340 int *eof, void *data)
1342 struct i2o_device *d = (struct i2o_device*)data;
1355 u32 alternate_tid[64];
1358 spin_lock(&i2o_proc_lock);
1361 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
1362 d->controller, d->lct_data.tid,
1365 &result, sizeof(result));
1368 len += i2o_report_query_status(buf+len, token,"0xF006 Autohorized User Table");
1369 spin_unlock(&i2o_proc_lock);
1373 if (result.row_count)
1374 len += sprintf(buf+len, "# AlternateTid\n");
1376 for(i=0; i < result.row_count; i++)
1378 len += sprintf(buf+len, "%-2d", i);
1379 len += sprintf(buf+len, "%#7x ", result.alternate_tid[i]);
1382 if (result.more_flag)
1383 len += sprintf(buf+len, "There is more...\n");
1385 spin_unlock(&i2o_proc_lock);
1390 /* Generic group F100h - Device Identity (scalar) */
1391 int i2o_proc_read_dev_identity(char *buf, char **start, off_t offset, int len,
1392 int *eof, void *data)
1394 struct i2o_device *d = (struct i2o_device*)data;
1395 static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
1396 // == (allow) 512d bytes (max)
1397 static u16 *work16 = (u16*)work32;
1400 spin_lock(&i2o_proc_lock);
1404 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1406 &work32, sizeof(work32));
1409 len += i2o_report_query_status(buf+len, token ,"0xF100 Device Identity");
1410 spin_unlock(&i2o_proc_lock);
1414 len += sprintf(buf, "Device Class : %s\n", i2o_get_class_name(work16[0]));
1415 len += sprintf(buf+len, "Owner TID : %0#5x\n", work16[2]);
1416 len += sprintf(buf+len, "Parent TID : %0#5x\n", work16[3]);
1417 len += sprintf(buf+len, "Vendor info : %s\n", chtostr((u8 *)(work32+2), 16));
1418 len += sprintf(buf+len, "Product info : %s\n", chtostr((u8 *)(work32+6), 16));
1419 len += sprintf(buf+len, "Description : %s\n", chtostr((u8 *)(work32+10), 16));
1420 len += sprintf(buf+len, "Product rev. : %s\n", chtostr((u8 *)(work32+14), 8));
1422 len += sprintf(buf+len, "Serial number : ");
1423 len = print_serial_number(buf, len,
1425 /* allow for SNLen plus
1426 * possible trailing '\0'
1428 sizeof(work32)-(16*sizeof(u32))-2
1430 len += sprintf(buf+len, "\n");
1432 spin_unlock(&i2o_proc_lock);
1438 int i2o_proc_read_dev_name(char *buf, char **start, off_t offset, int len,
1439 int *eof, void *data)
1441 struct i2o_device *d = (struct i2o_device*)data;
1443 if ( d->dev_name[0] == '\0' )
1446 len = sprintf(buf, "%s\n", d->dev_name);
1452 /* Generic group F101h - DDM Identity (scalar) */
1453 int i2o_proc_read_ddm_identity(char *buf, char **start, off_t offset, int len,
1454 int *eof, void *data)
1456 struct i2o_device *d = (struct i2o_device*)data;
1465 u8 serial_number[12];
1466 u8 pad[256]; // allow up to 256 byte (max) serial number
1469 spin_lock(&i2o_proc_lock);
1473 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1475 &result, sizeof(result));
1478 len += i2o_report_query_status(buf+len, token,"0xF101 DDM Identity");
1479 spin_unlock(&i2o_proc_lock);
1483 len += sprintf(buf, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
1484 len += sprintf(buf+len, "Module name : %s\n", chtostr(result.module_name, 24));
1485 len += sprintf(buf+len, "Module revision : %s\n", chtostr(result.module_rev, 8));
1487 len += sprintf(buf+len, "Serial number : ");
1488 len = print_serial_number(buf, len, result.serial_number, sizeof(result)-36);
1489 /* allow for SNLen plus possible trailing '\0' */
1491 len += sprintf(buf+len, "\n");
1493 spin_unlock(&i2o_proc_lock);
1498 /* Generic group F102h - User Information (scalar) */
1499 int i2o_proc_read_uinfo(char *buf, char **start, off_t offset, int len,
1500 int *eof, void *data)
1502 struct i2o_device *d = (struct i2o_device*)data;
1508 u8 service_name[64];
1509 u8 physical_location[64];
1510 u8 instance_number[4];
1513 spin_lock(&i2o_proc_lock);
1516 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1518 &result, sizeof(result));
1521 len += i2o_report_query_status(buf+len, token,"0xF102 User Information");
1522 spin_unlock(&i2o_proc_lock);
1526 len += sprintf(buf, "Device name : %s\n", chtostr(result.device_name, 64));
1527 len += sprintf(buf+len, "Service name : %s\n", chtostr(result.service_name, 64));
1528 len += sprintf(buf+len, "Physical name : %s\n", chtostr(result.physical_location, 64));
1529 len += sprintf(buf+len, "Instance number : %s\n", chtostr(result.instance_number, 4));
1531 spin_unlock(&i2o_proc_lock);
1535 /* Generic group F103h - SGL Operating Limits (scalar) */
1536 int i2o_proc_read_sgl_limits(char *buf, char **start, off_t offset, int len,
1537 int *eof, void *data)
1539 struct i2o_device *d = (struct i2o_device*)data;
1540 static u32 work32[12];
1541 static u16 *work16 = (u16 *)work32;
1542 static u8 *work8 = (u8 *)work32;
1545 spin_lock(&i2o_proc_lock);
1549 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1551 &work32, sizeof(work32));
1554 len += i2o_report_query_status(buf+len, token,"0xF103 SGL Operating Limits");
1555 spin_unlock(&i2o_proc_lock);
1559 len += sprintf(buf, "SGL chain size : %d\n", work32[0]);
1560 len += sprintf(buf+len, "Max SGL chain size : %d\n", work32[1]);
1561 len += sprintf(buf+len, "SGL chain size target : %d\n", work32[2]);
1562 len += sprintf(buf+len, "SGL frag count : %d\n", work16[6]);
1563 len += sprintf(buf+len, "Max SGL frag count : %d\n", work16[7]);
1564 len += sprintf(buf+len, "SGL frag count target : %d\n", work16[8]);
1566 if (d->i2oversion == 0x02)
1568 len += sprintf(buf+len, "SGL data alignment : %d\n", work16[8]);
1569 len += sprintf(buf+len, "SGL addr limit : %d\n", work8[20]);
1570 len += sprintf(buf+len, "SGL addr sizes supported : ");
1571 if (work8[21] & 0x01)
1572 len += sprintf(buf+len, "32 bit ");
1573 if (work8[21] & 0x02)
1574 len += sprintf(buf+len, "64 bit ");
1575 if (work8[21] & 0x04)
1576 len += sprintf(buf+len, "96 bit ");
1577 if (work8[21] & 0x08)
1578 len += sprintf(buf+len, "128 bit ");
1579 len += sprintf(buf+len, "\n");
1582 spin_unlock(&i2o_proc_lock);
1587 /* Generic group F200h - Sensors (scalar) */
1588 int i2o_proc_read_sensors(char *buf, char **start, off_t offset, int len,
1589 int *eof, void *data)
1591 struct i2o_device *d = (struct i2o_device*)data;
1596 u16 sensor_instance;
1598 u16 component_instance;
1601 u8 scaling_exponent;
1603 u32 minimum_reading;
1604 u32 low2lowcat_treshold;
1605 u32 lowcat2low_treshold;
1606 u32 lowwarn2low_treshold;
1607 u32 low2lowwarn_treshold;
1608 u32 norm2lowwarn_treshold;
1609 u32 lowwarn2norm_treshold;
1610 u32 nominal_reading;
1611 u32 hiwarn2norm_treshold;
1612 u32 norm2hiwarn_treshold;
1613 u32 high2hiwarn_treshold;
1614 u32 hiwarn2high_treshold;
1615 u32 hicat2high_treshold;
1616 u32 hi2hicat_treshold;
1617 u32 maximum_reading;
1622 spin_lock(&i2o_proc_lock);
1625 token = i2o_query_scalar(d->controller, d->lct_data.tid,
1627 &result, sizeof(result));
1630 len += i2o_report_query_status(buf+len, token,"0xF200 Sensors (optional)");
1631 spin_unlock(&i2o_proc_lock);
1635 len += sprintf(buf+len, "Sensor instance : %d\n", result.sensor_instance);
1637 len += sprintf(buf+len, "Component : %d = ", result.component);
1638 switch (result.component)
1640 case 0: len += sprintf(buf+len, "Other");
1642 case 1: len += sprintf(buf+len, "Planar logic Board");
1644 case 2: len += sprintf(buf+len, "CPU");
1646 case 3: len += sprintf(buf+len, "Chassis");
1648 case 4: len += sprintf(buf+len, "Power Supply");
1650 case 5: len += sprintf(buf+len, "Storage");
1652 case 6: len += sprintf(buf+len, "External");
1655 len += sprintf(buf+len,"\n");
1657 len += sprintf(buf+len, "Component instance : %d\n", result.component_instance);
1658 len += sprintf(buf+len, "Sensor class : %s\n",
1659 result.sensor_class ? "Analog" : "Digital");
1661 len += sprintf(buf+len, "Sensor type : %d = ",result.sensor_type);
1662 switch (result.sensor_type)
1664 case 0: len += sprintf(buf+len, "Other\n");
1666 case 1: len += sprintf(buf+len, "Thermal\n");
1668 case 2: len += sprintf(buf+len, "DC voltage (DC volts)\n");
1670 case 3: len += sprintf(buf+len, "AC voltage (AC volts)\n");
1672 case 4: len += sprintf(buf+len, "DC current (DC amps)\n");
1674 case 5: len += sprintf(buf+len, "AC current (AC volts)\n");
1676 case 6: len += sprintf(buf+len, "Door open\n");
1678 case 7: len += sprintf(buf+len, "Fan operational\n");
1682 len += sprintf(buf+len, "Scaling exponent : %d\n", result.scaling_exponent);
1683 len += sprintf(buf+len, "Actual reading : %d\n", result.actual_reading);
1684 len += sprintf(buf+len, "Minimum reading : %d\n", result.minimum_reading);
1685 len += sprintf(buf+len, "Low2LowCat treshold : %d\n", result.low2lowcat_treshold);
1686 len += sprintf(buf+len, "LowCat2Low treshold : %d\n", result.lowcat2low_treshold);
1687 len += sprintf(buf+len, "LowWarn2Low treshold : %d\n", result.lowwarn2low_treshold);
1688 len += sprintf(buf+len, "Low2LowWarn treshold : %d\n", result.low2lowwarn_treshold);
1689 len += sprintf(buf+len, "Norm2LowWarn treshold : %d\n", result.norm2lowwarn_treshold);
1690 len += sprintf(buf+len, "LowWarn2Norm treshold : %d\n", result.lowwarn2norm_treshold);
1691 len += sprintf(buf+len, "Nominal reading : %d\n", result.nominal_reading);
1692 len += sprintf(buf+len, "HiWarn2Norm treshold : %d\n", result.hiwarn2norm_treshold);
1693 len += sprintf(buf+len, "Norm2HiWarn treshold : %d\n", result.norm2hiwarn_treshold);
1694 len += sprintf(buf+len, "High2HiWarn treshold : %d\n", result.high2hiwarn_treshold);
1695 len += sprintf(buf+len, "HiWarn2High treshold : %d\n", result.hiwarn2high_treshold);
1696 len += sprintf(buf+len, "HiCat2High treshold : %d\n", result.hicat2high_treshold);
1697 len += sprintf(buf+len, "High2HiCat treshold : %d\n", result.hi2hicat_treshold);
1698 len += sprintf(buf+len, "Maximum reading : %d\n", result.maximum_reading);
1700 len += sprintf(buf+len, "Sensor state : %d = ", result.sensor_state);
1701 switch (result.sensor_state)
1703 case 0: len += sprintf(buf+len, "Normal\n");
1705 case 1: len += sprintf(buf+len, "Abnormal\n");
1707 case 2: len += sprintf(buf+len, "Unknown\n");
1709 case 3: len += sprintf(buf+len, "Low Catastrophic (LoCat)\n");
1711 case 4: len += sprintf(buf+len, "Low (Low)\n");
1713 case 5: len += sprintf(buf+len, "Low Warning (LoWarn)\n");
1715 case 6: len += sprintf(buf+len, "High Warning (HiWarn)\n");
1717 case 7: len += sprintf(buf+len, "High (High)\n");
1719 case 8: len += sprintf(buf+len, "High Catastrophic (HiCat)\n");
1723 len += sprintf(buf+len, "Event_enable : 0x%02X\n", result.event_enable);
1724 len += sprintf(buf+len, " [%s] Operational state change. \n",
1725 (result.event_enable & 0x01) ? "+" : "-" );
1726 len += sprintf(buf+len, " [%s] Low catastrophic. \n",
1727 (result.event_enable & 0x02) ? "+" : "-" );
1728 len += sprintf(buf+len, " [%s] Low reading. \n",
1729 (result.event_enable & 0x04) ? "+" : "-" );
1730 len += sprintf(buf+len, " [%s] Low warning. \n",
1731 (result.event_enable & 0x08) ? "+" : "-" );
1732 len += sprintf(buf+len, " [%s] Change back to normal from out of range state. \n",
1733 (result.event_enable & 0x10) ? "+" : "-" );
1734 len += sprintf(buf+len, " [%s] High warning. \n",
1735 (result.event_enable & 0x20) ? "+" : "-" );
1736 len += sprintf(buf+len, " [%s] High reading. \n",
1737 (result.event_enable & 0x40) ? "+" : "-" );
1738 len += sprintf(buf+len, " [%s] High catastrophic. \n",
1739 (result.event_enable & 0x80) ? "+" : "-" );
1741 spin_unlock(&i2o_proc_lock);
1746 static int print_serial_number(char *buff, int pos, u8 *serialno, int max_len)
1750 /* 19990419 -sralston
1751 * The I2O v1.5 (and v2.0 so far) "official specification"
1752 * got serial numbers WRONG!
1753 * Apparently, and despite what Section 3.4.4 says and
1754 * Figure 3-35 shows (pg 3-39 in the pdf doc),
1755 * the convention / consensus seems to be:
1756 * + First byte is SNFormat
1757 * + Second byte is SNLen (but only if SNFormat==7 (?))
1758 * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
1762 case I2O_SNFORMAT_BINARY: /* Binary */
1763 pos += sprintf(buff+pos, "0x");
1764 for(i = 0; i < serialno[1]; i++)
1766 pos += sprintf(buff+pos, "%02X", serialno[2+i]);
1770 case I2O_SNFORMAT_ASCII: /* ASCII */
1771 if ( serialno[1] < ' ' ) /* printable or SNLen? */
1774 max_len = (max_len < serialno[1]) ? max_len : serialno[1];
1775 serialno[1+max_len] = '\0';
1778 pos += sprintf(buff+pos, "%s", &serialno[2]);
1782 /* print chars for specified length */
1783 for(i = 0; i < serialno[1]; i++)
1785 pos += sprintf(buff+pos, "%c", serialno[2+i]);
1790 case I2O_SNFORMAT_UNICODE: /* UNICODE */
1791 pos += sprintf(buff+pos, "UNICODE Format. Can't Display\n");
1794 case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
1795 pos += sprintf(buff+pos,
1796 "LAN-48 MAC address @ %02X:%02X:%02X:%02X:%02X:%02X",
1797 serialno[2], serialno[3],
1798 serialno[4], serialno[5],
1799 serialno[6], serialno[7]);
1802 case I2O_SNFORMAT_WAN: /* WAN MAC Address */
1803 /* FIXME: Figure out what a WAN access address looks like?? */
1804 pos += sprintf(buff+pos, "WAN Access Address");
1807 /* plus new in v2.0 */
1808 case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
1809 /* FIXME: Figure out what a LAN-64 address really looks like?? */
1810 pos += sprintf(buff+pos,
1811 "LAN-64 MAC address @ [?:%02X:%02X:?] %02X:%02X:%02X:%02X:%02X:%02X",
1812 serialno[8], serialno[9],
1813 serialno[2], serialno[3],
1814 serialno[4], serialno[5],
1815 serialno[6], serialno[7]);
1819 case I2O_SNFORMAT_DDM: /* I2O DDM */
1820 pos += sprintf(buff+pos,
1821 "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
1822 *(u16*)&serialno[2],
1823 *(u16*)&serialno[4],
1824 *(u16*)&serialno[6]);
1827 case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
1828 case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
1829 /* FIXME: Figure if this is even close?? */
1830 pos += sprintf(buff+pos,
1831 "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
1832 *(u32*)&serialno[2],
1833 *(u32*)&serialno[6],
1834 *(u32*)&serialno[10],
1835 *(u32*)&serialno[14]);
1839 case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */
1840 case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
1842 pos += sprintf(buff+pos, "Unknown data format (0x%02x)",
1850 const char * i2o_get_connector_type(int conn)
1853 static char *i2o_connector_type[] = {
1924 return i2o_connector_type[idx];
1928 const char * i2o_get_connection_type(int conn)
1931 static char *i2o_connection_type[] = {
1965 case I2O_LAN_UNKNOWN:
1971 case I2O_LAN_10BASE5:
1977 case I2O_LAN_10BASE2:
1980 case I2O_LAN_10BROAD36:
1983 case I2O_LAN_10BASE_T:
1986 case I2O_LAN_10BASE_FP:
1989 case I2O_LAN_10BASE_FB:
1992 case I2O_LAN_10BASE_FL:
1995 case I2O_LAN_100BASE_TX:
1998 case I2O_LAN_100BASE_FX:
2001 case I2O_LAN_100BASE_T4:
2004 case I2O_LAN_1000BASE_SX:
2007 case I2O_LAN_1000BASE_LX:
2010 case I2O_LAN_1000BASE_CX:
2013 case I2O_LAN_1000BASE_T:
2016 case I2O_LAN_100VG_ETHERNET:
2019 case I2O_LAN_100VG_TR:
2025 case I2O_LAN_16MBIT:
2028 case I2O_LAN_125MBAUD:
2031 case I2O_LAN_POINT_POINT:
2034 case I2O_LAN_ARB_LOOP:
2037 case I2O_LAN_PUBLIC_LOOP:
2040 case I2O_LAN_FABRIC:
2043 case I2O_LAN_EMULATION:
2049 case I2O_LAN_DEFAULT:
2054 return i2o_connection_type[idx];
2058 /* LAN group 0000h - Device info (scalar) */
2059 int i2o_proc_read_lan_dev_info(char *buf, char **start, off_t offset, int len,
2060 int *eof, void *data)
2062 struct i2o_device *d = (struct i2o_device*)data;
2063 static u32 work32[56];
2064 static u8 *work8 = (u8*)work32;
2065 static u16 *work16 = (u16*)work32;
2066 static u64 *work64 = (u64*)work32;
2069 spin_lock(&i2o_proc_lock);
2072 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2073 0x0000, -1, &work32, 56*4);
2075 len += i2o_report_query_status(buf+len, token, "0x0000 LAN Device Info");
2076 spin_unlock(&i2o_proc_lock);
2080 len += sprintf(buf, "LAN Type : ");
2084 len += sprintf(buf+len, "Ethernet, ");
2087 len += sprintf(buf+len, "100Base VG, ");
2090 len += sprintf(buf+len, "Token Ring, ");
2093 len += sprintf(buf+len, "FDDI, ");
2096 len += sprintf(buf+len, "Fibre Channel, ");
2099 len += sprintf(buf+len, "Unknown type (0x%04x), ", work16[0]);
2103 if (work16[1]&0x00000001)
2104 len += sprintf(buf+len, "emulated LAN, ");
2106 len += sprintf(buf+len, "physical LAN port, ");
2108 if (work16[1]&0x00000002)
2109 len += sprintf(buf+len, "full duplex\n");
2111 len += sprintf(buf+len, "simplex\n");
2113 len += sprintf(buf+len, "Address format : ");
2116 len += sprintf(buf+len, "IEEE 48bit\n");
2119 len += sprintf(buf+len, "FC IEEE\n");
2122 len += sprintf(buf+len, "Unknown (0x%02x)\n", work8[4]);
2126 len += sprintf(buf+len, "State : ");
2130 len += sprintf(buf+len, "Unknown\n");
2133 len += sprintf(buf+len, "Unclaimed\n");
2136 len += sprintf(buf+len, "Operational\n");
2139 len += sprintf(buf+len, "Suspended\n");
2142 len += sprintf(buf+len, "Resetting\n");
2145 len += sprintf(buf+len, "ERROR: ");
2146 if(work16[3]&0x0001)
2147 len += sprintf(buf+len, "TxCU inoperative ");
2148 if(work16[3]&0x0002)
2149 len += sprintf(buf+len, "RxCU inoperative ");
2150 if(work16[3]&0x0004)
2151 len += sprintf(buf+len, "Local mem alloc ");
2152 len += sprintf(buf+len, "\n");
2155 len += sprintf(buf+len, "Operational no Rx\n");
2158 len += sprintf(buf+len, "Suspended no Rx\n");
2161 len += sprintf(buf+len, "Unspecified\n");
2165 len += sprintf(buf+len, "Min packet size : %d\n", work32[2]);
2166 len += sprintf(buf+len, "Max packet size : %d\n", work32[3]);
2167 len += sprintf(buf+len, "HW address : "
2168 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2169 work8[16],work8[17],work8[18],work8[19],
2170 work8[20],work8[21],work8[22],work8[23]);
2172 len += sprintf(buf+len, "Max Tx wire speed : %d bps\n", (int)work64[3]);
2173 len += sprintf(buf+len, "Max Rx wire speed : %d bps\n", (int)work64[4]);
2175 len += sprintf(buf+len, "Min SDU packet size : 0x%08x\n", work32[10]);
2176 len += sprintf(buf+len, "Max SDU packet size : 0x%08x\n", work32[11]);
2178 spin_unlock(&i2o_proc_lock);
2182 /* LAN group 0001h - MAC address table (scalar) */
2183 int i2o_proc_read_lan_mac_addr(char *buf, char **start, off_t offset, int len,
2184 int *eof, void *data)
2186 struct i2o_device *d = (struct i2o_device*)data;
2187 static u32 work32[48];
2188 static u8 *work8 = (u8*)work32;
2191 spin_lock(&i2o_proc_lock);
2194 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2195 0x0001, -1, &work32, 48*4);
2197 len += i2o_report_query_status(buf+len, token,"0x0001 LAN MAC Address");
2198 spin_unlock(&i2o_proc_lock);
2202 len += sprintf(buf, "Active address : "
2203 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2204 work8[0],work8[1],work8[2],work8[3],
2205 work8[4],work8[5],work8[6],work8[7]);
2206 len += sprintf(buf+len, "Current address : "
2207 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2208 work8[8],work8[9],work8[10],work8[11],
2209 work8[12],work8[13],work8[14],work8[15]);
2210 len += sprintf(buf+len, "Functional address mask : "
2211 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2212 work8[16],work8[17],work8[18],work8[19],
2213 work8[20],work8[21],work8[22],work8[23]);
2215 len += sprintf(buf+len,"HW/DDM capabilities : 0x%08x\n", work32[7]);
2216 len += sprintf(buf+len," [%s] Unicast packets supported\n",
2217 (work32[7]&0x00000001)?"+":"-");
2218 len += sprintf(buf+len," [%s] Promiscuous mode supported\n",
2219 (work32[7]&0x00000002)?"+":"-");
2220 len += sprintf(buf+len," [%s] Promiscuous multicast mode supported\n",
2221 (work32[7]&0x00000004)?"+":"-");
2222 len += sprintf(buf+len," [%s] Broadcast reception disabling supported\n",
2223 (work32[7]&0x00000100)?"+":"-");
2224 len += sprintf(buf+len," [%s] Multicast reception disabling supported\n",
2225 (work32[7]&0x00000200)?"+":"-");
2226 len += sprintf(buf+len," [%s] Functional address disabling supported\n",
2227 (work32[7]&0x00000400)?"+":"-");
2228 len += sprintf(buf+len," [%s] MAC reporting supported\n",
2229 (work32[7]&0x00000800)?"+":"-");
2231 len += sprintf(buf+len,"Filter mask : 0x%08x\n", work32[6]);
2232 len += sprintf(buf+len," [%s] Unicast packets disable\n",
2233 (work32[6]&0x00000001)?"+":"-");
2234 len += sprintf(buf+len," [%s] Promiscuous mode enable\n",
2235 (work32[6]&0x00000002)?"+":"-");
2236 len += sprintf(buf+len," [%s] Promiscuous multicast mode enable\n",
2237 (work32[6]&0x00000004)?"+":"-");
2238 len += sprintf(buf+len," [%s] Broadcast packets disable\n",
2239 (work32[6]&0x00000100)?"+":"-");
2240 len += sprintf(buf+len," [%s] Multicast packets disable\n",
2241 (work32[6]&0x00000200)?"+":"-");
2242 len += sprintf(buf+len," [%s] Functional address disable\n",
2243 (work32[6]&0x00000400)?"+":"-");
2245 if (work32[7]&0x00000800) {
2246 len += sprintf(buf+len, " MAC reporting mode : ");
2247 if (work32[6]&0x00000800)
2248 len += sprintf(buf+len, "Pass only priority MAC packets to user\n");
2249 else if (work32[6]&0x00001000)
2250 len += sprintf(buf+len, "Pass all MAC packets to user\n");
2251 else if (work32[6]&0x00001800)
2252 len += sprintf(buf+len, "Pass all MAC packets (promiscuous) to user\n");
2254 len += sprintf(buf+len, "Do not pass MAC packets to user\n");
2256 len += sprintf(buf+len, "Number of multicast addresses : %d\n", work32[8]);
2257 len += sprintf(buf+len, "Perfect filtering for max %d multicast addresses\n",
2259 len += sprintf(buf+len, "Imperfect filtering for max %d multicast addresses\n",
2262 spin_unlock(&i2o_proc_lock);
2267 /* LAN group 0002h - Multicast MAC address table (table) */
2268 int i2o_proc_read_lan_mcast_addr(char *buf, char **start, off_t offset,
2269 int len, int *eof, void *data)
2271 struct i2o_device *d = (struct i2o_device*)data;
2288 result = kmalloc(sizeof(*result), GFP_KERNEL);
2292 spin_lock(&i2o_proc_lock);
2295 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
2296 d->controller, d->lct_data.tid, 0x0002, -1,
2297 NULL, 0, result, sizeof(*result));
2300 len += i2o_report_query_status(buf+len, token,"0x002 LAN Multicast MAC Address");
2304 for (i = 0; i < result->row_count; i++)
2306 memcpy(mc_addr, result->mc_addr[i], 8);
2308 len += sprintf(buf+len, "MC MAC address[%d]: "
2309 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2310 i, mc_addr[0], mc_addr[1], mc_addr[2],
2311 mc_addr[3], mc_addr[4], mc_addr[5],
2312 mc_addr[6], mc_addr[7]);
2315 spin_unlock(&i2o_proc_lock);
2320 /* LAN group 0003h - Batch Control (scalar) */
2321 int i2o_proc_read_lan_batch_control(char *buf, char **start, off_t offset,
2322 int len, int *eof, void *data)
2324 struct i2o_device *d = (struct i2o_device*)data;
2325 static u32 work32[9];
2328 spin_lock(&i2o_proc_lock);
2331 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2332 0x0003, -1, &work32, 9*4);
2334 len += i2o_report_query_status(buf+len, token,"0x0003 LAN Batch Control");
2335 spin_unlock(&i2o_proc_lock);
2339 len += sprintf(buf, "Batch mode ");
2340 if (work32[0]&0x00000001)
2341 len += sprintf(buf+len, "disabled");
2343 len += sprintf(buf+len, "enabled");
2344 if (work32[0]&0x00000002)
2345 len += sprintf(buf+len, " (current setting)");
2346 if (work32[0]&0x00000004)
2347 len += sprintf(buf+len, ", forced");
2349 len += sprintf(buf+len, ", toggle");
2350 len += sprintf(buf+len, "\n");
2352 len += sprintf(buf+len, "Max Rx batch count : %d\n", work32[5]);
2353 len += sprintf(buf+len, "Max Rx batch delay : %d\n", work32[6]);
2354 len += sprintf(buf+len, "Max Tx batch delay : %d\n", work32[7]);
2355 len += sprintf(buf+len, "Max Tx batch count : %d\n", work32[8]);
2357 spin_unlock(&i2o_proc_lock);
2361 /* LAN group 0004h - LAN Operation (scalar) */
2362 int i2o_proc_read_lan_operation(char *buf, char **start, off_t offset, int len,
2363 int *eof, void *data)
2365 struct i2o_device *d = (struct i2o_device*)data;
2366 static u32 work32[5];
2369 spin_lock(&i2o_proc_lock);
2372 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2373 0x0004, -1, &work32, 20);
2375 len += i2o_report_query_status(buf+len, token,"0x0004 LAN Operation");
2376 spin_unlock(&i2o_proc_lock);
2380 len += sprintf(buf, "Packet prepadding (32b words) : %d\n", work32[0]);
2381 len += sprintf(buf+len, "Transmission error reporting : %s\n",
2382 (work32[1]&1)?"on":"off");
2383 len += sprintf(buf+len, "Bad packet handling : %s\n",
2384 (work32[1]&0x2)?"by host":"by DDM");
2385 len += sprintf(buf+len, "Packet orphan limit : %d\n", work32[2]);
2387 len += sprintf(buf+len, "Tx modes : 0x%08x\n", work32[3]);
2388 len += sprintf(buf+len, " [%s] HW CRC suppression\n",
2389 (work32[3]&0x00000004) ? "+" : "-");
2390 len += sprintf(buf+len, " [%s] HW IPv4 checksum\n",
2391 (work32[3]&0x00000100) ? "+" : "-");
2392 len += sprintf(buf+len, " [%s] HW TCP checksum\n",
2393 (work32[3]&0x00000200) ? "+" : "-");
2394 len += sprintf(buf+len, " [%s] HW UDP checksum\n",
2395 (work32[3]&0x00000400) ? "+" : "-");
2396 len += sprintf(buf+len, " [%s] HW RSVP checksum\n",
2397 (work32[3]&0x00000800) ? "+" : "-");
2398 len += sprintf(buf+len, " [%s] HW ICMP checksum\n",
2399 (work32[3]&0x00001000) ? "+" : "-");
2400 len += sprintf(buf+len, " [%s] Loopback suppression enable\n",
2401 (work32[3]&0x00002000) ? "+" : "-");
2403 len += sprintf(buf+len, "Rx modes : 0x%08x\n", work32[4]);
2404 len += sprintf(buf+len, " [%s] FCS in payload\n",
2405 (work32[4]&0x00000004) ? "+" : "-");
2406 len += sprintf(buf+len, " [%s] HW IPv4 checksum validation\n",
2407 (work32[4]&0x00000100) ? "+" : "-");
2408 len += sprintf(buf+len, " [%s] HW TCP checksum validation\n",
2409 (work32[4]&0x00000200) ? "+" : "-");
2410 len += sprintf(buf+len, " [%s] HW UDP checksum validation\n",
2411 (work32[4]&0x00000400) ? "+" : "-");
2412 len += sprintf(buf+len, " [%s] HW RSVP checksum validation\n",
2413 (work32[4]&0x00000800) ? "+" : "-");
2414 len += sprintf(buf+len, " [%s] HW ICMP checksum validation\n",
2415 (work32[4]&0x00001000) ? "+" : "-");
2417 spin_unlock(&i2o_proc_lock);
2421 /* LAN group 0005h - Media operation (scalar) */
2422 int i2o_proc_read_lan_media_operation(char *buf, char **start, off_t offset,
2423 int len, int *eof, void *data)
2425 struct i2o_device *d = (struct i2o_device*)data;
2431 u32 connection_type;
2432 u64 current_tx_wire_speed;
2433 u64 current_rx_wire_speed;
2437 u8 duplex_mode_target;
2438 u32 connector_type_target;
2439 u32 connection_type_target;
2442 spin_lock(&i2o_proc_lock);
2445 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2446 0x0005, -1, &result, sizeof(result));
2448 len += i2o_report_query_status(buf+len, token, "0x0005 LAN Media Operation");
2449 spin_unlock(&i2o_proc_lock);
2453 len += sprintf(buf, "Connector type : %s\n",
2454 i2o_get_connector_type(result.connector_type));
2455 len += sprintf(buf+len, "Connection type : %s\n",
2456 i2o_get_connection_type(result.connection_type));
2458 len += sprintf(buf+len, "Current Tx wire speed : %d bps\n", (int)result.current_tx_wire_speed);
2459 len += sprintf(buf+len, "Current Rx wire speed : %d bps\n", (int)result.current_rx_wire_speed);
2460 len += sprintf(buf+len, "Duplex mode : %s duplex\n",
2461 (result.duplex_mode)?"Full":"Half");
2463 len += sprintf(buf+len, "Link status : ");
2464 switch (result.link_status)
2467 len += sprintf(buf+len, "Unknown\n");
2470 len += sprintf(buf+len, "Normal\n");
2473 len += sprintf(buf+len, "Failure\n");
2476 len += sprintf(buf+len, "Reset\n");
2479 len += sprintf(buf+len, "Unspecified\n");
2482 len += sprintf(buf+len, "Duplex mode target : ");
2483 switch (result.duplex_mode_target){
2485 len += sprintf(buf+len, "Half duplex\n");
2488 len += sprintf(buf+len, "Full duplex\n");
2491 len += sprintf(buf+len, "\n");
2494 len += sprintf(buf+len, "Connector type target : %s\n",
2495 i2o_get_connector_type(result.connector_type_target));
2496 len += sprintf(buf+len, "Connection type target : %s\n",
2497 i2o_get_connection_type(result.connection_type_target));
2499 spin_unlock(&i2o_proc_lock);
2503 /* LAN group 0006h - Alternate address (table) (optional) */
2504 int i2o_proc_read_lan_alt_addr(char *buf, char **start, off_t offset, int len,
2505 int *eof, void *data)
2507 struct i2o_device *d = (struct i2o_device*)data;
2520 u8 alt_addr[256][8];
2523 result = kmalloc(sizeof(*result), GFP_KERNEL);
2527 spin_lock(&i2o_proc_lock);
2530 token = i2o_query_table(I2O_PARAMS_TABLE_GET,
2531 d->controller, d->lct_data.tid,
2532 0x0006, -1, NULL, 0, result, sizeof(*result));
2535 len += i2o_report_query_status(buf+len, token, "0x0006 LAN Alternate Address (optional)");
2539 for (i=0; i < result->row_count; i++)
2541 memcpy(alt_addr,result->alt_addr[i],8);
2542 len += sprintf(buf+len, "Alternate address[%d]: "
2543 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
2544 i, alt_addr[0], alt_addr[1], alt_addr[2],
2545 alt_addr[3], alt_addr[4], alt_addr[5],
2546 alt_addr[6], alt_addr[7]);
2549 spin_unlock(&i2o_proc_lock);
2555 /* LAN group 0007h - Transmit info (scalar) */
2556 int i2o_proc_read_lan_tx_info(char *buf, char **start, off_t offset, int len,
2557 int *eof, void *data)
2559 struct i2o_device *d = (struct i2o_device*)data;
2560 static u32 work32[8];
2563 spin_lock(&i2o_proc_lock);
2566 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2567 0x0007, -1, &work32, 8*4);
2569 len += i2o_report_query_status(buf+len, token,"0x0007 LAN Transmit Info");
2570 spin_unlock(&i2o_proc_lock);
2574 len += sprintf(buf, "Tx Max SG elements per packet : %d\n", work32[0]);
2575 len += sprintf(buf+len, "Tx Max SG elements per chain : %d\n", work32[1]);
2576 len += sprintf(buf+len, "Tx Max outstanding packets : %d\n", work32[2]);
2577 len += sprintf(buf+len, "Tx Max packets per request : %d\n", work32[3]);
2579 len += sprintf(buf+len, "Tx modes : 0x%08x\n", work32[4]);
2580 len += sprintf(buf+len, " [%s] No DA in SGL\n",
2581 (work32[4]&0x00000002) ? "+" : "-");
2582 len += sprintf(buf+len, " [%s] CRC suppression\n",
2583 (work32[4]&0x00000004) ? "+" : "-");
2584 len += sprintf(buf+len, " [%s] MAC insertion\n",
2585 (work32[4]&0x00000010) ? "+" : "-");
2586 len += sprintf(buf+len, " [%s] RIF insertion\n",
2587 (work32[4]&0x00000020) ? "+" : "-");
2588 len += sprintf(buf+len, " [%s] IPv4 checksum generation\n",
2589 (work32[4]&0x00000100) ? "+" : "-");
2590 len += sprintf(buf+len, " [%s] TCP checksum generation\n",
2591 (work32[4]&0x00000200) ? "+" : "-");
2592 len += sprintf(buf+len, " [%s] UDP checksum generation\n",
2593 (work32[4]&0x00000400) ? "+" : "-");
2594 len += sprintf(buf+len, " [%s] RSVP checksum generation\n",
2595 (work32[4]&0x00000800) ? "+" : "-");
2596 len += sprintf(buf+len, " [%s] ICMP checksum generation\n",
2597 (work32[4]&0x00001000) ? "+" : "-");
2598 len += sprintf(buf+len, " [%s] Loopback enabled\n",
2599 (work32[4]&0x00010000) ? "+" : "-");
2600 len += sprintf(buf+len, " [%s] Loopback suppression enabled\n",
2601 (work32[4]&0x00020000) ? "+" : "-");
2603 spin_unlock(&i2o_proc_lock);
2607 /* LAN group 0008h - Receive info (scalar) */
2608 int i2o_proc_read_lan_rx_info(char *buf, char **start, off_t offset, int len,
2609 int *eof, void *data)
2611 struct i2o_device *d = (struct i2o_device*)data;
2612 static u32 work32[8];
2615 spin_lock(&i2o_proc_lock);
2618 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2619 0x0008, -1, &work32, 8*4);
2621 len += i2o_report_query_status(buf+len, token,"0x0008 LAN Receive Info");
2622 spin_unlock(&i2o_proc_lock);
2626 len += sprintf(buf ,"Rx Max size of chain element : %d\n", work32[0]);
2627 len += sprintf(buf+len, "Rx Max Buckets : %d\n", work32[1]);
2628 len += sprintf(buf+len, "Rx Max Buckets in Reply : %d\n", work32[3]);
2629 len += sprintf(buf+len, "Rx Max Packets in Bucket : %d\n", work32[4]);
2630 len += sprintf(buf+len, "Rx Max Buckets in Post : %d\n", work32[5]);
2632 len += sprintf(buf+len, "Rx Modes : 0x%08x\n", work32[2]);
2633 len += sprintf(buf+len, " [%s] FCS reception\n",
2634 (work32[2]&0x00000004) ? "+" : "-");
2635 len += sprintf(buf+len, " [%s] IPv4 checksum validation \n",
2636 (work32[2]&0x00000100) ? "+" : "-");
2637 len += sprintf(buf+len, " [%s] TCP checksum validation \n",
2638 (work32[2]&0x00000200) ? "+" : "-");
2639 len += sprintf(buf+len, " [%s] UDP checksum validation \n",
2640 (work32[2]&0x00000400) ? "+" : "-");
2641 len += sprintf(buf+len, " [%s] RSVP checksum validation \n",
2642 (work32[2]&0x00000800) ? "+" : "-");
2643 len += sprintf(buf+len, " [%s] ICMP checksum validation \n",
2644 (work32[2]&0x00001000) ? "+" : "-");
2646 spin_unlock(&i2o_proc_lock);
2650 static int i2o_report_opt_field(char *buf, char *field_name,
2651 int field_nbr, int supp_fields, u64 *value)
2653 if (supp_fields & (1 << field_nbr))
2654 return sprintf(buf, "%-24s : " FMT_U64_HEX "\n", field_name, U64_VAL(value));
2656 return sprintf(buf, "%-24s : Not supported\n", field_name);
2659 /* LAN group 0100h - LAN Historical statistics (scalar) */
2660 /* LAN group 0180h - Supported Optional Historical Statistics (scalar) */
2661 /* LAN group 0182h - Optional Non Media Specific Transmit Historical Statistics (scalar) */
2662 /* LAN group 0183h - Optional Non Media Specific Receive Historical Statistics (scalar) */
2664 int i2o_proc_read_lan_hist_stats(char *buf, char **start, off_t offset, int len,
2665 int *eof, void *data)
2667 struct i2o_device *d = (struct i2o_device*)data;
2680 u64 adapter_suspends;
2683 static u64 supp_groups[4]; // 0x0180
2688 u64 tx_directed_bytes;
2689 u64 tx_directed_packets;
2690 u64 tx_multicast_bytes;
2691 u64 tx_multicast_packets;
2692 u64 tx_broadcast_bytes;
2693 u64 tx_broadcast_packets;
2694 u64 tx_group_addr_packets;
2695 u64 tx_short_packets;
2696 } tx_stats; // 0x0182
2701 u64 rx_directed_bytes;
2702 u64 rx_directed_packets;
2703 u64 rx_multicast_bytes;
2704 u64 rx_multicast_packets;
2705 u64 rx_broadcast_bytes;
2706 u64 rx_broadcast_packets;
2707 u64 rx_group_addr_packets;
2708 u64 rx_short_packets;
2709 u64 rx_long_packets;
2710 u64 rx_runt_packets;
2711 } rx_stats; // 0x0183
2716 u64 ipv4_validate_success;
2717 u64 ipv4_validate_errors;
2719 u64 tcp_validate_success;
2720 u64 tcp_validate_errors;
2722 u64 udp_validate_success;
2723 u64 udp_validate_errors;
2725 u64 rsvp_validate_success;
2726 u64 rsvp_validate_errors;
2728 u64 icmp_validate_success;
2729 u64 icmp_validate_errors;
2730 } chksum_stats; // 0x0184
2732 spin_lock(&i2o_proc_lock);
2735 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2736 0x0100, -1, &stats, sizeof(stats));
2738 len += i2o_report_query_status(buf+len, token,"0x100 LAN Statistics");
2739 spin_unlock(&i2o_proc_lock);
2743 len += sprintf(buf+len, "Tx packets : " FMT_U64_HEX "\n",
2744 U64_VAL(&stats.tx_packets));
2745 len += sprintf(buf+len, "Tx bytes : " FMT_U64_HEX "\n",
2746 U64_VAL(&stats.tx_bytes));
2747 len += sprintf(buf+len, "Rx packets : " FMT_U64_HEX "\n",
2748 U64_VAL(&stats.rx_packets));
2749 len += sprintf(buf+len, "Rx bytes : " FMT_U64_HEX "\n",
2750 U64_VAL(&stats.rx_bytes));
2751 len += sprintf(buf+len, "Tx errors : " FMT_U64_HEX "\n",
2752 U64_VAL(&stats.tx_errors));
2753 len += sprintf(buf+len, "Rx errors : " FMT_U64_HEX "\n",
2754 U64_VAL(&stats.rx_errors));
2755 len += sprintf(buf+len, "Rx dropped : " FMT_U64_HEX "\n",
2756 U64_VAL(&stats.rx_dropped));
2757 len += sprintf(buf+len, "Adapter resets : " FMT_U64_HEX "\n",
2758 U64_VAL(&stats.adapter_resets));
2759 len += sprintf(buf+len, "Adapter suspends : " FMT_U64_HEX "\n",
2760 U64_VAL(&stats.adapter_suspends));
2762 /* Optional statistics follows */
2763 /* Get 0x0180 to see which optional groups/fields are supported */
2765 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2766 0x0180, -1, &supp_groups, sizeof(supp_groups));
2769 len += i2o_report_query_status(buf+len, token, "0x180 LAN Supported Optional Statistics");
2770 spin_unlock(&i2o_proc_lock);
2774 if (supp_groups[1]) /* 0x0182 */
2776 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2777 0x0182, -1, &tx_stats, sizeof(tx_stats));
2780 len += i2o_report_query_status(buf+len, token,"0x182 LAN Optional Tx Historical Statistics");
2781 spin_unlock(&i2o_proc_lock);
2785 len += sprintf(buf+len, "==== Optional TX statistics (group 0182h)\n");
2787 len += i2o_report_opt_field(buf+len, "Tx RetryCount",
2788 0, supp_groups[1], &tx_stats.tx_retries);
2789 len += i2o_report_opt_field(buf+len, "Tx DirectedBytes",
2790 1, supp_groups[1], &tx_stats.tx_directed_bytes);
2791 len += i2o_report_opt_field(buf+len, "Tx DirectedPackets",
2792 2, supp_groups[1], &tx_stats.tx_directed_packets);
2793 len += i2o_report_opt_field(buf+len, "Tx MulticastBytes",
2794 3, supp_groups[1], &tx_stats.tx_multicast_bytes);
2795 len += i2o_report_opt_field(buf+len, "Tx MulticastPackets",
2796 4, supp_groups[1], &tx_stats.tx_multicast_packets);
2797 len += i2o_report_opt_field(buf+len, "Tx BroadcastBytes",
2798 5, supp_groups[1], &tx_stats.tx_broadcast_bytes);
2799 len += i2o_report_opt_field(buf+len, "Tx BroadcastPackets",
2800 6, supp_groups[1], &tx_stats.tx_broadcast_packets);
2801 len += i2o_report_opt_field(buf+len, "Tx TotalGroupAddrPackets",
2802 7, supp_groups[1], &tx_stats.tx_group_addr_packets);
2803 len += i2o_report_opt_field(buf+len, "Tx TotalPacketsTooShort",
2804 8, supp_groups[1], &tx_stats.tx_short_packets);
2807 if (supp_groups[2]) /* 0x0183 */
2809 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2810 0x0183, -1, &rx_stats, sizeof(rx_stats));
2812 len += i2o_report_query_status(buf+len, token,"0x183 LAN Optional Rx Historical Stats");
2813 spin_unlock(&i2o_proc_lock);
2817 len += sprintf(buf+len, "==== Optional RX statistics (group 0183h)\n");
2819 len += i2o_report_opt_field(buf+len, "Rx CRCErrorCount",
2820 0, supp_groups[2], &rx_stats.rx_crc_errors);
2821 len += i2o_report_opt_field(buf+len, "Rx DirectedBytes",
2822 1, supp_groups[2], &rx_stats.rx_directed_bytes);
2823 len += i2o_report_opt_field(buf+len, "Rx DirectedPackets",
2824 2, supp_groups[2], &rx_stats.rx_directed_packets);
2825 len += i2o_report_opt_field(buf+len, "Rx MulticastBytes",
2826 3, supp_groups[2], &rx_stats.rx_multicast_bytes);
2827 len += i2o_report_opt_field(buf+len, "Rx MulticastPackets",
2828 4, supp_groups[2], &rx_stats.rx_multicast_packets);
2829 len += i2o_report_opt_field(buf+len, "Rx BroadcastBytes",
2830 5, supp_groups[2], &rx_stats.rx_broadcast_bytes);
2831 len += i2o_report_opt_field(buf+len, "Rx BroadcastPackets",
2832 6, supp_groups[2], &rx_stats.rx_broadcast_packets);
2833 len += i2o_report_opt_field(buf+len, "Rx TotalGroupAddrPackets",
2834 7, supp_groups[2], &rx_stats.rx_group_addr_packets);
2835 len += i2o_report_opt_field(buf+len, "Rx TotalPacketsTooShort",
2836 8, supp_groups[2], &rx_stats.rx_short_packets);
2837 len += i2o_report_opt_field(buf+len, "Rx TotalPacketsTooLong",
2838 9, supp_groups[2], &rx_stats.rx_long_packets);
2839 len += i2o_report_opt_field(buf+len, "Rx TotalPacketsRunt",
2840 10, supp_groups[2], &rx_stats.rx_runt_packets);
2843 if (supp_groups[3]) /* 0x0184 */
2845 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2846 0x0184, -1, &chksum_stats, sizeof(chksum_stats));
2849 len += i2o_report_query_status(buf+len, token,"0x184 LAN Optional Chksum Historical Stats");
2850 spin_unlock(&i2o_proc_lock);
2854 len += sprintf(buf+len, "==== Optional CHKSUM statistics (group 0x0184)\n");
2856 len += i2o_report_opt_field(buf+len, "IPv4 Generate",
2857 0, supp_groups[3], &chksum_stats.ipv4_generate);
2858 len += i2o_report_opt_field(buf+len, "IPv4 ValidateSuccess",
2859 1, supp_groups[3], &chksum_stats.ipv4_validate_success);
2860 len += i2o_report_opt_field(buf+len, "IPv4 ValidateError",
2861 2, supp_groups[3], &chksum_stats.ipv4_validate_errors);
2862 len += i2o_report_opt_field(buf+len, "TCP Generate",
2863 3, supp_groups[3], &chksum_stats.tcp_generate);
2864 len += i2o_report_opt_field(buf+len, "TCP ValidateSuccess",
2865 4, supp_groups[3], &chksum_stats.tcp_validate_success);
2866 len += i2o_report_opt_field(buf+len, "TCP ValidateError",
2867 5, supp_groups[3], &chksum_stats.tcp_validate_errors);
2868 len += i2o_report_opt_field(buf+len, "UDP Generate",
2869 6, supp_groups[3], &chksum_stats.udp_generate);
2870 len += i2o_report_opt_field(buf+len, "UDP ValidateSuccess",
2871 7, supp_groups[3], &chksum_stats.udp_validate_success);
2872 len += i2o_report_opt_field(buf+len, "UDP ValidateError",
2873 8, supp_groups[3], &chksum_stats.udp_validate_errors);
2874 len += i2o_report_opt_field(buf+len, "RSVP Generate",
2875 9, supp_groups[3], &chksum_stats.rsvp_generate);
2876 len += i2o_report_opt_field(buf+len, "RSVP ValidateSuccess",
2877 10, supp_groups[3], &chksum_stats.rsvp_validate_success);
2878 len += i2o_report_opt_field(buf+len, "RSVP ValidateError",
2879 11, supp_groups[3], &chksum_stats.rsvp_validate_errors);
2880 len += i2o_report_opt_field(buf+len, "ICMP Generate",
2881 12, supp_groups[3], &chksum_stats.icmp_generate);
2882 len += i2o_report_opt_field(buf+len, "ICMP ValidateSuccess",
2883 13, supp_groups[3], &chksum_stats.icmp_validate_success);
2884 len += i2o_report_opt_field(buf+len, "ICMP ValidateError",
2885 14, supp_groups[3], &chksum_stats.icmp_validate_errors);
2888 spin_unlock(&i2o_proc_lock);
2892 /* LAN group 0200h - Required Ethernet Statistics (scalar) */
2893 /* LAN group 0280h - Optional Ethernet Statistics Supported (scalar) */
2894 /* LAN group 0281h - Optional Ethernet Historical Statistics (scalar) */
2895 int i2o_proc_read_lan_eth_stats(char *buf, char **start, off_t offset,
2896 int len, int *eof, void *data)
2898 struct i2o_device *d = (struct i2o_device*)data;
2903 u64 rx_align_errors;
2904 u64 tx_one_collisions;
2905 u64 tx_multiple_collisions;
2907 u64 tx_late_collisions;
2908 u64 tx_max_collisions;
2909 u64 tx_carrier_lost;
2910 u64 tx_excessive_deferrals;
2913 static u64 supp_fields;
2918 u64 tx_heartbeat_failure;
2921 spin_lock(&i2o_proc_lock);
2924 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2925 0x0200, -1, &stats, sizeof(stats));
2928 len += i2o_report_query_status(buf+len, token,"0x0200 LAN Ethernet Statistics");
2929 spin_unlock(&i2o_proc_lock);
2933 len += sprintf(buf+len, "Rx alignment errors : " FMT_U64_HEX "\n",
2934 U64_VAL(&stats.rx_align_errors));
2935 len += sprintf(buf+len, "Tx one collisions : " FMT_U64_HEX "\n",
2936 U64_VAL(&stats.tx_one_collisions));
2937 len += sprintf(buf+len, "Tx multicollisions : " FMT_U64_HEX "\n",
2938 U64_VAL(&stats.tx_multiple_collisions));
2939 len += sprintf(buf+len, "Tx deferred : " FMT_U64_HEX "\n",
2940 U64_VAL(&stats.tx_deferred));
2941 len += sprintf(buf+len, "Tx late collisions : " FMT_U64_HEX "\n",
2942 U64_VAL(&stats.tx_late_collisions));
2943 len += sprintf(buf+len, "Tx max collisions : " FMT_U64_HEX "\n",
2944 U64_VAL(&stats.tx_max_collisions));
2945 len += sprintf(buf+len, "Tx carrier lost : " FMT_U64_HEX "\n",
2946 U64_VAL(&stats.tx_carrier_lost));
2947 len += sprintf(buf+len, "Tx excessive deferrals : " FMT_U64_HEX "\n",
2948 U64_VAL(&stats.tx_excessive_deferrals));
2950 /* Optional Ethernet statistics follows */
2951 /* Get 0x0280 to see which optional fields are supported */
2953 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2954 0x0280, -1, &supp_fields, sizeof(supp_fields));
2957 len += i2o_report_query_status(buf+len, token,"0x0280 LAN Supported Optional Ethernet Statistics");
2958 spin_unlock(&i2o_proc_lock);
2962 if (supp_fields) /* 0x0281 */
2964 token = i2o_query_scalar(d->controller, d->lct_data.tid,
2965 0x0281, -1, &stats, sizeof(stats));
2968 len += i2o_report_query_status(buf+len, token,"0x0281 LAN Optional Ethernet Statistics");
2969 spin_unlock(&i2o_proc_lock);
2973 len += sprintf(buf+len, "==== Optional ETHERNET statistics (group 0x0281)\n");
2975 len += i2o_report_opt_field(buf+len, "Rx Overrun",
2976 0, supp_fields, &hist_stats.rx_overrun);
2977 len += i2o_report_opt_field(buf+len, "Tx Underrun",
2978 1, supp_fields, &hist_stats.tx_underrun);
2979 len += i2o_report_opt_field(buf+len, "Tx HeartbeatFailure",
2980 2, supp_fields, &hist_stats.tx_heartbeat_failure);
2983 spin_unlock(&i2o_proc_lock);
2987 /* LAN group 0300h - Required Token Ring Statistics (scalar) */
2988 /* LAN group 0380h, 0381h - Optional Statistics not yet defined (TODO) */
2989 int i2o_proc_read_lan_tr_stats(char *buf, char **start, off_t offset,
2990 int len, int *eof, void *data)
2992 struct i2o_device *d = (struct i2o_device*)data;
2993 static u64 work64[13];
2996 static char *ring_status[] =
3008 "Auto-Removal Error 1",
3016 spin_lock(&i2o_proc_lock);
3019 token = i2o_query_scalar(d->controller, d->lct_data.tid,
3020 0x0300, -1, &work64, sizeof(work64));
3023 len += i2o_report_query_status(buf+len, token,"0x0300 Token Ring Statistics");
3024 spin_unlock(&i2o_proc_lock);
3028 len += sprintf(buf, "LineErrors : " FMT_U64_HEX "\n",
3029 U64_VAL(&work64[0]));
3030 len += sprintf(buf+len, "LostFrames : " FMT_U64_HEX "\n",
3031 U64_VAL(&work64[1]));
3032 len += sprintf(buf+len, "ACError : " FMT_U64_HEX "\n",
3033 U64_VAL(&work64[2]));
3034 len += sprintf(buf+len, "TxAbortDelimiter : " FMT_U64_HEX "\n",
3035 U64_VAL(&work64[3]));
3036 len += sprintf(buf+len, "BursErrors : " FMT_U64_HEX "\n",
3037 U64_VAL(&work64[4]));
3038 len += sprintf(buf+len, "FrameCopiedErrors : " FMT_U64_HEX "\n",
3039 U64_VAL(&work64[5]));
3040 len += sprintf(buf+len, "FrequencyErrors : " FMT_U64_HEX "\n",
3041 U64_VAL(&work64[6]));
3042 len += sprintf(buf+len, "InternalErrors : " FMT_U64_HEX "\n",
3043 U64_VAL(&work64[7]));
3044 len += sprintf(buf+len, "LastRingStatus : %s\n", ring_status[work64[8]]);
3045 len += sprintf(buf+len, "TokenError : " FMT_U64_HEX "\n",
3046 U64_VAL(&work64[9]));
3047 len += sprintf(buf+len, "UpstreamNodeAddress : " FMT_U64_HEX "\n",
3048 U64_VAL(&work64[10]));
3049 len += sprintf(buf+len, "LastRingID : " FMT_U64_HEX "\n",
3050 U64_VAL(&work64[11]));
3051 len += sprintf(buf+len, "LastBeaconType : " FMT_U64_HEX "\n",
3052 U64_VAL(&work64[12]));
3054 spin_unlock(&i2o_proc_lock);
3058 /* LAN group 0400h - Required FDDI Statistics (scalar) */
3059 /* LAN group 0480h, 0481h - Optional Statistics, not yet defined (TODO) */
3060 int i2o_proc_read_lan_fddi_stats(char *buf, char **start, off_t offset,
3061 int len, int *eof, void *data)
3063 struct i2o_device *d = (struct i2o_device*)data;
3064 static u64 work64[11];
3067 static char *conf_state[] =
3084 static char *ring_state[] =
3096 static char *link_state[] =
3110 spin_lock(&i2o_proc_lock);
3113 token = i2o_query_scalar(d->controller, d->lct_data.tid,
3114 0x0400, -1, &work64, sizeof(work64));
3117 len += i2o_report_query_status(buf+len, token,"0x0400 FDDI Required Statistics");
3118 spin_unlock(&i2o_proc_lock);
3122 len += sprintf(buf+len, "ConfigurationState : %s\n", conf_state[work64[0]]);
3123 len += sprintf(buf+len, "UpstreamNode : " FMT_U64_HEX "\n",
3124 U64_VAL(&work64[1]));
3125 len += sprintf(buf+len, "DownStreamNode : " FMT_U64_HEX "\n",
3126 U64_VAL(&work64[2]));
3127 len += sprintf(buf+len, "FrameErrors : " FMT_U64_HEX "\n",
3128 U64_VAL(&work64[3]));
3129 len += sprintf(buf+len, "FramesLost : " FMT_U64_HEX "\n",
3130 U64_VAL(&work64[4]));
3131 len += sprintf(buf+len, "RingMgmtState : %s\n", ring_state[work64[5]]);
3132 len += sprintf(buf+len, "LCTFailures : " FMT_U64_HEX "\n",
3133 U64_VAL(&work64[6]));
3134 len += sprintf(buf+len, "LEMRejects : " FMT_U64_HEX "\n",
3135 U64_VAL(&work64[7]));
3136 len += sprintf(buf+len, "LEMCount : " FMT_U64_HEX "\n",
3137 U64_VAL(&work64[8]));
3138 len += sprintf(buf+len, "LConnectionState : %s\n",
3139 link_state[work64[9]]);
3141 spin_unlock(&i2o_proc_lock);
3145 static int i2o_proc_create_entries(void *data, i2o_proc_entry *pentry,
3146 struct proc_dir_entry *parent)
3148 struct proc_dir_entry *ent;
3150 while(pentry->name != NULL)
3152 ent = create_proc_entry(pentry->name, pentry->mode, parent);
3156 ent->read_proc = pentry->read_proc;
3157 ent->write_proc = pentry->write_proc;
3158 if(pentry->fops_proc)
3159 ent->proc_fops = pentry->fops_proc;
3169 static void i2o_proc_remove_entries(i2o_proc_entry *pentry,
3170 struct proc_dir_entry *parent)
3172 while(pentry->name != NULL)
3174 remove_proc_entry(pentry->name, parent);
3179 static int i2o_proc_add_controller(struct i2o_controller *pctrl,
3180 struct proc_dir_entry *root )
3182 struct proc_dir_entry *dir, *dir1;
3183 struct i2o_device *dev;
3186 sprintf(buff, "iop%d", pctrl->unit);
3188 dir = proc_mkdir(buff, root);
3192 pctrl->proc_entry = dir;
3194 i2o_proc_create_entries(pctrl, generic_iop_entries, dir);
3196 for(dev = pctrl->devices; dev; dev = dev->next)
3198 sprintf(buff, "%0#5x", dev->lct_data.tid);
3200 dir1 = proc_mkdir(buff, dir);
3201 dev->proc_entry = dir1;
3204 printk(KERN_INFO "i2o_proc: Could not allocate proc dir\n");
3206 i2o_proc_add_device(dev, dir1);
3212 void i2o_proc_new_dev(struct i2o_controller *c, struct i2o_device *d)
3217 printk(KERN_INFO "Adding new device to /proc/i2o/iop%d\n", c->unit);
3219 sprintf(buff, "%0#5x", d->lct_data.tid);
3221 d->proc_entry = proc_mkdir(buff, c->proc_entry);
3225 printk(KERN_WARNING "i2o: Could not allocate procdir!\n");
3229 i2o_proc_add_device(d, d->proc_entry);
3232 void i2o_proc_add_device(struct i2o_device *dev, struct proc_dir_entry *dir)
3234 i2o_proc_create_entries(dev, generic_dev_entries, dir);
3236 /* Inform core that we want updates about this device's status */
3237 i2o_device_notify_on(dev, &i2o_proc_handler);
3238 switch(dev->lct_data.class_id)
3240 case I2O_CLASS_SCSI_PERIPHERAL:
3241 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
3242 i2o_proc_create_entries(dev, rbs_dev_entries, dir);
3245 i2o_proc_create_entries(dev, lan_entries, dir);
3246 switch(dev->lct_data.sub_class)
3248 case I2O_LAN_ETHERNET:
3249 i2o_proc_create_entries(dev, lan_eth_entries, dir);
3252 i2o_proc_create_entries(dev, lan_fddi_entries, dir);
3255 i2o_proc_create_entries(dev, lan_tr_entries, dir);
3266 static void i2o_proc_remove_controller(struct i2o_controller *pctrl,
3267 struct proc_dir_entry *parent)
3270 struct i2o_device *dev;
3272 /* Remove unused device entries */
3273 for(dev=pctrl->devices; dev; dev=dev->next)
3274 i2o_proc_remove_device(dev);
3276 if(!atomic_read(&pctrl->proc_entry->count))
3278 sprintf(buff, "iop%d", pctrl->unit);
3280 i2o_proc_remove_entries(generic_iop_entries, pctrl->proc_entry);
3281 remove_proc_entry(buff, parent);
3282 pctrl->proc_entry = NULL;
3286 void i2o_proc_remove_device(struct i2o_device *dev)
3288 struct proc_dir_entry *de=dev->proc_entry;
3291 sprintf(dev_id, "%0#5x", dev->lct_data.tid);
3293 i2o_device_notify_off(dev, &i2o_proc_handler);
3294 /* Would it be safe to remove _files_ even if they are in use? */
3295 if((de) && (!atomic_read(&de->count)))
3297 i2o_proc_remove_entries(generic_dev_entries, de);
3298 switch(dev->lct_data.class_id)
3300 case I2O_CLASS_SCSI_PERIPHERAL:
3301 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
3302 i2o_proc_remove_entries(rbs_dev_entries, de);
3306 i2o_proc_remove_entries(lan_entries, de);
3307 switch(dev->lct_data.sub_class)
3309 case I2O_LAN_ETHERNET:
3310 i2o_proc_remove_entries(lan_eth_entries, de);
3313 i2o_proc_remove_entries(lan_fddi_entries, de);
3316 i2o_proc_remove_entries(lan_tr_entries, de);
3321 remove_proc_entry(dev_id, dev->controller->proc_entry);
3325 void i2o_proc_dev_del(struct i2o_controller *c, struct i2o_device *d)
3328 printk(KERN_INFO "Deleting device %d from iop%d\n",
3329 d->lct_data.tid, c->unit);
3332 i2o_proc_remove_device(d);
3335 static int create_i2o_procfs(void)
3337 struct i2o_controller *pctrl = NULL;
3340 i2o_proc_dir_root = proc_mkdir("i2o", NULL);
3341 if(!i2o_proc_dir_root)
3343 i2o_proc_dir_root->owner = THIS_MODULE;
3345 for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
3347 pctrl = i2o_find_controller(i);
3350 i2o_proc_add_controller(pctrl, i2o_proc_dir_root);
3351 i2o_unlock_controller(pctrl);
3358 static int __exit destroy_i2o_procfs(void)
3360 struct i2o_controller *pctrl = NULL;
3363 for(i = 0; i < MAX_I2O_CONTROLLERS; i++)
3365 pctrl = i2o_find_controller(i);
3368 i2o_proc_remove_controller(pctrl, i2o_proc_dir_root);
3369 i2o_unlock_controller(pctrl);
3373 if(!atomic_read(&i2o_proc_dir_root->count))
3374 remove_proc_entry("i2o", NULL);
3381 int __init i2o_proc_init(void)
3383 if (i2o_install_handler(&i2o_proc_handler) < 0)
3385 printk(KERN_ERR "i2o_proc: Unable to install PROC handler.\n");
3389 if(create_i2o_procfs())
3395 MODULE_AUTHOR("Deepak Saxena");
3396 MODULE_DESCRIPTION("I2O procfs Handler");
3397 MODULE_LICENSE("GPL");
3399 static void __exit i2o_proc_exit(void)
3401 destroy_i2o_procfs();
3402 i2o_remove_handler(&i2o_proc_handler);
3406 module_init(i2o_proc_init);
3408 module_exit(i2o_proc_exit);